Skip to main content

Module output_validator

Module output_validator 

Source
Expand description

Script-backed validators for an agent’s final output.

A blueprint can name any format it likes, and most of them are formats this codebase has never heard of. The built-in checks cover a handful that can be parsed with a crate we already ship; everything else would mean owning that format’s parser and schema language, which is a cost the output system deliberately does not take on.

So the knowledge lives with the person who has it. An agent that produces a2ui, a house report format, or a dialect of CSV nobody else uses ships a .rhai file beside its blueprint that says what “valid” means:

// @validator a2ui
fn validate(content) {
    let doc = parse_json(content);
    if doc.root == () { return "the document has no `root` node"; }
    ()   // fine
}

One function, one contract: return () when the answer is fine, or a string saying what is wrong. The string goes back to the agent as the same [error] refusal a schema failure produces, and it tries again. Rhai passes by value, so a return value is the only thing a script can say - the same shape the region hooks use.

Execution runs on a fresh hardened engine per call: no filesystem, no network, no eval, operation-bounded. A validator that throws, loops, or returns something that is neither () nor a string is an authoring error, reported as such rather than being allowed to fail every submission.

Structs§

OutputValidator
A compiled output validator, ready to call.

Enums§

Verdict
What a validator said about one submission.

Functions§

compile
Compile an output validator and check its shape.
validate
Run validator over content.