✓ Human-authored analysis; AI used for formatting and proofreading.
You have a security tool that exports facts. Five different reasoning engines consume those facts and produce different shapes of answer. Z3 produces SAT/UNSAT, Soufflé counts reachable tuples, Clingo enumerates violation atoms, Prolog produces proof trees, a risk model produces probabilities. Each engine has a committed golden output for a known fixture. Three questions you cannot answer by running the engines:
- Is the spec describing each engine's reasoning agent-comprehensible? If a different engineer reads the spec, will they arrive at the same answer?
- Is the golden actually correct? Or is it a snapshot of a buggy run committed once and never re-verified?
- When the answer is wrong, which side drifted? The engine's? The spec's? The golden's?
I ran five trials. Two of them caught real defects with one on each side of the contract. The framework was designed to distinguish them.
The trial format
Each trial is a self-contained directory with three files:
reasoning-specs/trials/clingo-violation-atoms/ ├── spec.yaml ← full spec (includes expected_result + validation) ├── spec-trial.yaml ← the trial copy (expected_result + validation stripped) ├── golden.yaml ← just the expected_result + validation (the answer key) ├── input.jsonl ← the fixture data the spec references └── export-schema.md ← documentation of the input format The trial agent reads only spec-trial.yaml, input.<ext>, and export-schema.md. It produces an answer in the format the spec specifies. The validator diffs the answer against golden.yaml. The trial agent never reads the answer key.
A spec looks like this:
question: > Is there an S3 bucket that allows public read AND has Public Access Block disabled? If SAT, name the bucket. input: source: stave export-sir --format smt2 + appended query format: smt-lib fixture: input.smt2 required_fields: - has_type(<arn>, "aws_s3_bucket") - has_public_read(<arn>, "true"|"false") - has_public_access_blocked(<arn>, "true"|"false") reasoning: steps: - step: 1 action: Read the SMT-LIB document... input: input.smt2 output: An in-solver model of the per-asset facts rule: Treat the document literally. Closed-world axioms forbid... - step: 2 action: Read the query block... ... - step: 3 action: Decide satisfiability and, if SAT, report the witness. ... output: format: text schema: verdict: SAT | UNSAT witness: When SAT, the bucket ARN. Omitted when UNSAT. expected_result: verdict: SAT witness: arn:aws:s3:::acme-customer-uploads validation: exact_match: - verdict - witness semantic_match: [] ignore: - solver warnings preceding the verdict line - whitespace around the (get-value …) tuple The validation block is the foundational part. Three categories:
-
exact_match— these fields must be byte-identical -
semantic_match— meaning must match, wording can vary (e.g., "at least one proof in the output must be rooted at this ARN/action pair, but ordering is free") -
ignore— fields where divergence isn't a defect (timestamps, ordering, whitespace, indentation)
Every entry in ignore: is paid for by experience. The Prolog trial's ignore list had ordering of the 12 proofs, indentation width that directly prevented a false-FAIL on a correct answer when the blind sub-agent chose alphabetical ordering with 2-space indent.
The two kinds of defect
I ran five trials. Three passed straight. Two failed. The two failures were in different categories:
Category A: the spec was wrong
The Clingo spec said:
Apply rule
mfa_disabled. For every user pool whose
mfa_enforcedpredicate has object "false", emit one
violation atom.
The trial agent followed this literally, queried for the mfa_enforced predicate, and found nothing. Because the actual JSONL export emits has_mfa_enforced with the has_ prefix. The catalog's projection convention is always has_<property> for booleans; the spec author (me, last round) wrote the bare name.
The trial produced 3 violations instead of 4. The validator diffed against the golden (4 violations) and flagged the gap.
How I knew it was a spec defect, not an engine defect: the trial agent's output agreed neither with the engine's output (4 violations from examples/clingo-constraints/expected/output.txt) nor with the golden. The trial agent did exactly what the spec said. The spec said the wrong thing.
Fix: correct the predicate name in spec.yaml step 3 + add a convention note ("the JSONL export uses the has_<property> naming convention; do not strip the prefix"). Re-strip to produce a fresh spec-trial.yaml. The blind re-run by a fresh sub-agent produced all 4 violations.
Category C: the golden was wrong
The Prolog spec said proof_trees_count: 6, derived from a Phase 1 inventory comment that read "three resources × two actions (s3:GetObject, s3:ListBucket)."
The actual golden file had 12 proofs. Three resources × four actions. The role's has_action set contained dynamodb:GetItem and dynamodb:Query too; the original transcription only counted the S3 pair.
The trial agent computed the cartesian product correctly: 4 × 3 = 12. The validator diffed against the golden (6) and flagged the gap.
How I knew it was a golden defect, not a spec defect: the trial agent's output matched the actual engine's output (12 proofs from examples/prolog-proof-trees/expected/output.txt) but not the golden (6). The trial agent was right. The golden was wrong.
Fix: correct expected_result.proof_trees_count: 6 → 12 in spec.yaml plus a note explaining the cartesian-product semantic. Re-strip. Blind re-run produced 12.
The diagnostic table
The two failure shapes give a useful diagnostic:
| Trial output vs engine output | Trial output vs golden | Diagnosis |
|---|---|---|
| Disagrees | Disagrees | Spec is wrong (Category A) — the agent's reasoning followed the spec but reached an answer neither side validates |
| Agrees | Disagrees | Golden is wrong (Category C) — the agent reproduced the engine's actual output; the answer key was mis-transcribed |
| Agrees | Agrees | Both sides match — trial PASSES |
| Disagrees | Agrees | Engine drift — the engine's behaviour changed; spec + golden are stale but mutually consistent. Re-run the engine to refresh both. |
The validation block, combined with the engine's actual current output, distinguishes among spec drift, golden drift, and engine drift. You can't get this distinction from a single test that compares "engine output" against "expected output" alone. The engine output is the expected output by construction.
Blind matters
Same-session trials are insufficient. The spec author and the trial runner share context. The runner knows the answer even if the formal "spec-trial.yaml" doesn't contain it. The pass rate is inflated.
A truly blind trial spawns a fresh sub-agent. The agent has no access to:
- The unstripped
spec.yaml(containsexpected_result) -
golden.yaml(the answer key) - The source
examples/<engine>/directory (where the original engine + its committed output live) - Any other file in the repo
Only spec-trial.yaml, input.<ext>, and export-schema.md. The agent produces an answer; the validator compares.
Two blind re-runs validated the two spec fixes from same-session round 1:
Prolog blind: correctly produced 12 proofs (the corrected golden). The agent's confidence was "medium". It flagged the spec's ordering and indentation as under-specified. Both are already in the ignore: list. The flag confirmed the ignore-list entries were doing real work.
Clingo blind: correctly used has_mfa_enforced (with the prefix). The convention note added in round 1 ("the catalog's JSONL export uses the has_<property> naming convention; do not strip the prefix") was understood by an agent with zero prior context. The spec's prose carries the rule; the agent recovered it.
The leak audit
Before running blind, check that the spec doesn't accidentally leak the answer. The audit:
for trial_dir in trials: spec_text = open(f"{trial_dir}/spec-trial.yaml").read() golden = yaml.safe_load(open(f"{trial_dir}/golden.yaml")) for value in walk_values(golden["expected_result"]): if str(value) in spec_text: print(f"LEAK in {trial_dir}: {value!r}") I found three leaks. Two were structural, one was removable:
| Trial | Leak | Removable? |
|---|---|---|
| Z3 | example ARN in step-3 output description ("e.g. arn:aws:s3:::acme-customer-uploads") | yes — replaced with <bucket-arn> placeholder |
| Clingo | the four violation atom names in the rule definitions | no — the names ARE the rules; can't remove without breaking the spec |
| PRISM | step names + per-step probabilities in the context block | no — the parameters ARE the model |
Structural leaks aren't defects. The Clingo spec describes the rules to apply; the trial agent must still pair the rule names with the right subjects from the input data. Listing the atom names doesn't give away which assets each rule fires on.
The removable Z3 leak was a placeholder in the spec author's prose, not part of the rule. Easy fix.
What earns each piece of the framework
Five trials, each piece I wrote at some point I wondered "do I really need this?" Here's what each piece caught:
| Piece | What it caught |
|---|---|
expected_result | The committed answer the validator diffs against. Caught: nothing on its own — it's just a recording. |
validation.exact_match | Pinpoints the fields that must match precisely. Caught: every match/mismatch I report above is keyed off these lines. |
validation.semantic_match | Saves the trial when wording or order varies. Caught: the Prolog first_proof_root test — agent reported a different first proof, but the validation rule said "at least one proof must be rooted at the S3:GetObject pair," and it was. |
validation.ignore | Saves the trial when ordering/indentation varies. Caught: the Prolog blind agent's alphabetical-sort ordering would have FAILED an exact-match check on the proof sequence. |
spec-trial.yaml (golden-stripped copy) | Forces the trial agent to derive the answer. Caught: the entire framework's premise. |
export-schema.md | Documents the input format alongside the spec. Caught: the blind Clingo agent used the has_<property> naming convention from the schema doc, which was the fix needed. |
| Blind sub-agent | Validates the spec is agent-comprehensible. Caught: both spec fixes from round 1 held under fully blind conditions; the framework is verified for re-use. |
Every piece earned its place. The expected_result-on-its-own line (the only one that "caught nothing") is the data; everything else is the test infrastructure around it.
What it generalises to
The framework isn't Stave-specific. Anywhere you have:
- A tool that produces structured output (logs, CSV, JSON, …)
- Multiple downstream consumers (reasoning engines, dashboards, audit reports, …)
- Each consumer has a known-correct answer for some fixture
…you can wrap the answer in this trial format. The validation-block-and-blind-agent pattern catches both spec drift and golden drift in the same run, distinguishes them via the diagnostic table, and produces a regression suite that survives spec or upstream evolution.
The two-defect catch rate over five trials in this exercise was 40%. That's roughly the rate you'd expect for any test format that earns its keep. Half the defects are in the answer key, half are in the prose describing the reasoning. A test format that didn't distinguish would have produced four passes and one fail and you wouldn't have known why.
Five trial packages is at reasoning-specs/trials/ for reference.
How this relates to existing compliance mods
The validate-spec + blind-agent trial format generalizes to any catalog where the "answer key" is the foundational artifact. Framework-coverage catalogs like turbot/steampipe-mod-aws-compliance have their own answer-key shape: each control's expected ok/alarm verdict against published fixture data, exercised through Powerpipe's mod-test harness. That works because the reasoning is one-step (SQL → row → verdict). Stave's reasoning specs need the blind-agent trial because the reasoning has multiple steps (snapshot → CEL → compound aggregation → SMT-LIB export → solver verdict) and a defect can hide at any layer. Two test-format choices for two reasoning depths; both deterministic; both catch drift at their respective layers. Comparison: aws-compliance-mod.