Skip to main content

MnaVerificationCheck

Namespace: MNALIB  ·  Library: MNA Library

#include <mna/mna_verification.h>

struct MNALIB::MnaVerificationCheck

A declarative check (pre- or post-condition) attached to a graph node.

Evaluated by the executor; can warn, abort, or log an informational note.

Verification check for a graph node.

src/examples/ex_mna/main.cpp
MnaVerification& checks = graph.node("shift").verification;
checks.explanation = "Adds the offset; the result must stay positive.";
MnaVerificationCheck positive;
positive.id = "out_positive";
positive.description = "Output is positive";
positive.phase = "post"; // "pre" sees attributes and inputs, "post" also outputs
positive.expression = "out > 0"; // or MnaScript code whose exit code 0 passes
positive.severity = "error"; // a failed "error" check stops the run
checks.checks.append(positive);
graph.node("source").attributes["value"] = -2.0;
graph.node("source").dirty = true;
const MnaGraphExecutor::Context checked = MnaGraphExecutor::executeIncremental(graph, ctx);
const MnaVerificationResult& verdict = checks.postResults.first();
const MnaProvenance& provenance = checks.provenance; // versions, host, input SHA-256, timing

Public Methods​

toJson()​


toCbor()​


Static Methods​

fromJson(json)​


fromCbor(cbor)​


Example​

Used in examples​

ex_mna​

MNA library: register operations, build and run a graph, bind parameters and save a project.

src/examples/ex_mna/main.cpp, line 173
MnaVerification& checks = graph.node("shift").verification;
checks.explanation = "Adds the offset; the result must stay positive.";
MnaVerificationCheck positive;
positive.id = "out_positive";
positive.description = "Output is positive";
positive.phase = "post"; // "pre" sees attributes and inputs, "post" also outputs
positive.expression = "out > 0"; // or MnaScript code whose exit code 0 passes
positive.severity = "error"; // a failed "error" check stops the run
checks.checks.append(positive);
graph.node("source").attributes["value"] = -2.0;
graph.node("source").dirty = true;
const MnaGraphExecutor::Context checked = MnaGraphExecutor::executeIncremental(graph, ctx);
const MnaVerificationResult& verdict = checks.postResults.first();
const MnaProvenance& provenance = checks.provenance; // versions, host, input SHA-256, timing

Authors of this file​