Chapter 46 of 60

Diagnostic AI Invariants

Concepts

CHAPTER 46 β€” Diagnostic AI Invariants

PART VIII β€” Building the AI Debugger

PURPOSE

Compiles Chapters 01–03 evidence rules into six machine-checkable reject-rules (I-1–I-6) so a checker β€” not human vigilance β€” rejects assistant reports that read well but violate structure.

CENTRAL QUESTION

Which evidence-discipline rules can be encoded as machine-checkable invariants β€” so the debugging assistant’s output is rejected by a checker, not by a tired human’s vigilance?

UNIQUE CLAIM

Only this chapter defines I-1 Separation, I-2 Grounding, I-3 Plurality, I-4 Prediction-first, I-5 Trial sufficiency, I-6 No-forbidden-evidence as LM Assertions with PASS/REJECT/PROVISIONAL verdicts, an independent (non-self-grading) checker, and structure enforced by guided decoding rather than prompting.

DEBUGGING OBJECT

One-page assistant report violating all six (zero hash-resolving quotes, one hypothesis, confidence token, single post-fix run, production edit by the assistant) β†’ constructed six-for-six REJECT; second pass under O/H/I emits three grounded observations, H1 stale-chunk vs H2 prompt-ambiguity with timestamped predictions, I-5 pending execution.

CONCEPTS INTRODUCED (only genuinely new here)

  • Six invariants as reject-rules over structured O/H/I + manifest (I-1–I-4 + I-6 = @Assert/REJECT; I-5 = @Suggest/PROVISIONAL cap)
  • Type-system mental model; checker-before-judgment; return-to-assistant naming the failed invariant (backtracking)
  • Independent-checker requirement (deterministic code preferred; any model checker blinded to producer)

CONCEPTS DEVELOPED / REUSED (with source chapter)

  • Ch01–03 rules compiled; Ch8 DbC (I-2 = precondition on OBSERVATION, I-3 = report invariant, I-4 = temporal precondition; Meyer’s blame rule: I-2 failure is the assistant’s violation); Ch44 self-preference result; Ch45 manifest hashes consumed

PREREQUISITES

Assistant’s structured O/H/I report + Ch45 bundle manifest with hashes + trial log for executed runs.

LOCAL INVARIANTS

  • Require O/H/I records against the manifest, never free prose as the decision artifact.
  • Every OBSERVATION hash-resolves; β‰₯2 hypotheses with distinct pre-dated predictions; β‰₯3 trials on varying steps or cap at PROVISIONAL; no explanation/attention/confidence/score/correlation/single-run/agreement/symptom justifications.

FAILURE MODES (this chapter’s specific ones)

  • Prompt-instead-of-checker (instructions believed self-enforcing).
  • Grading prose fluency instead of running checks; checker theater (overriding REJECT because “looks right”).
  • Score laundering (reranker scores/confidences as justifications); trial-count amnesia (“decisive” single run); assistant self-checking.

DIAGNOSTIC METHOD (3-6 steps)

  1. Require structured O/H/I against the manifest.
  2. Run I-1–I-6 mechanically; quote each violating claim verbatim; mark predictions pre/post-dated; count trials; scan justifications for forbidden sources.
  3. Emit PASS / REJECT / PROVISIONAL with blocking invariant named.
  4. Route: PASS β†’ Ch48 execution with impact sign-off; REJECT β†’ return naming invariant; PROVISIONAL β†’ run missing trials first.

RESEARCH-DERIVED IDEAS (papers/findings with bounds)

  • Singhvi et al., DSPy Assertions, arXiv:2312.13382 β€” @Assert (backtrack-or-fail) vs @Suggest (note-and-proceed); failing output + error reinjected, retry; up to +164% conformance on JSON QA/multi-hop/content-gen; bounds: those tasks, not debugging.
  • Willard & Louf, Efficient Guided Generation (Outlines), arXiv:2307.09702 β€” generation as FSM transitions; invalid structure unreachable; bounds: known distribution-distortion critiques.
  • Meyer, Applying “Design by Contract”, Computer 1992 β€” precondition/postcondition/invariant + blame rule aimed at the assistant.
  • Panickssery, Bowman & Feng, LLM self-preference, NeurIPS 2024 β€” checker must be independent; assistant grading itself is lenient.

EXPERIMENT / LAB (actual lab, H-structure)

Lab 46 (PROPOSED): checker over two reports. H1: constrained output passes I-1–I-4/I-6, free prose fails β‰₯3; H2: both pass; H3: both fail structurally. One report per regime (assistant pinned), six mechanical checks, per-invariant PASS/REJECT/PROVISIONAL with failing claims quoted. “Felt better” without verdicts is not completion.

COMPANION TOOL (name + accepts/can-establish/cannot-establish)

Diagnostic Invariant Checker β€” accepts: structured O/H/I report, manifest hashes, trial log. Can establish: whether this report satisfies evidence structure and which invariant blocks it (this report only). Cannot establish: true cause, cross-report quality, future compliance; never uses fluency, vendor capability claims, scores, agreement, single runs, symptom relief.

PREVENTION ARTIFACT

Per-invariant check log with quoted violations + PASS/REJECT/PROVISIONAL verdict feeding Ch48 routing and Ch51 fixture batteries.

READER OUTCOME (testable phrasing)

Given two assistant reports on one bundle, reader runs all six checks mechanically and records per-invariant verdicts with failing claims quoted verbatim, trial counts stated, and high-impact actions held for human raw-record verification.

DEPENDENCIES

Ch01–03 rules; Ch44 gates + self-preference; Ch45 manifest; Ch8 DbC + Daikon.

TWO INVARIANT AXES

I-1..I-6 are REPORT-SHAPE invariants (fixed, from Ch1–3, same every failure). The system under test has its own DOMAIN invariants (Ch45 “quote cites a present policy section”; “refund_id on every row into summarize”) β€” mined from passing runs via Daikon (Ch8), curated for noise, incident selects which was violated. Both checked mechanically. Ch8β†’Ch46 ledger item closed (DbC half already in text 46:76; Daikon half added).

FORWARD BRIDGE

Enforcement presupposes an enumerable competitor space to judge plurality against; Ch47 makes hypothesis generation a layer-ordered, signature-carrying procedure.

EVIDENCE / RESEARCH REQUIREMENTS

Reader’s own check log; constructed six-for-six rejection only, no measured runs.

ANTI-CLAIMS / LIMITS

One verdict covers one report on one bundle under one assistant version; warrants structure, not truth; no transfer across failures/models. UNKNOWN wherever outputs are free prose or hashes unresolvable.

Explain this chapter with AI

Copy this prompt into ChatGPT, Claude, Gemini, a local model, or another AI.

Apply this chapter with AI

Copy this prompt into ChatGPT, Claude, Gemini, a local model, or another AI.

Part VIII β€” Building the AI Debugger

The assistant that broke every rule politely

Chapter 45 froze the past; this chapter polices the consumer. A practitioner runs a well-bundled failure through a debugging assistant that returns a report violating, in one page, every rule Chapters 01–03 established: its “observations” are paraphrases, its single hypothesis arrives with no competitor, its conclusion cites the assistant’s own confidence and one passing run, and the fix ships to production without human review. The bundle was perfect. The discipline was absent β€” because nothing checked it.

OBSERVATION: the report contains zero verbatim quotes resolving to bundle hashes, one hypothesis with no alternative, a confidence token (“high confidence”), a single post-fix run, and a production edit executed by the assistant. HYPOTHESIS H1 (capable-but-unchecked): the assistant can diagnose but was never constrained. H2 (incapable): no constraint set would make this report trustworthy. H3 (process-only defect): the practitioner, not the assistant, owns the missing gates. INFERENCE: none yet β€” H1/H2/H3 separate only when the same assistant is re-run under machine-enforced rules and its outputs are checked mechanically, not by reading tone.

This chapter’s question: which evidence-discipline rules can be encoded as machine-checkable invariants β€” so the debugging assistant’s output is rejected by a checker, not by a tired human’s vigilance?

Why “instruct the assistant to be careful” fails first

The obvious move β€” a system prompt saying “be rigorous, consider alternatives, show evidence” β€” fails because prose instructions are behavior requests, not enforcement. Five violations slide through politeness:

  1. Paraphrase-as-observation. “The retriever returned irrelevant docs” with no verbatim quote or hash. Instruction-following produces plausible summaries; only a checker demanding hash-resolving quotes stops this.
  2. Single-hypothesis reporting. One story, no competitor. “Consider alternatives” yields a token alternative (“or possibly something else”) with no distinct prediction β€” undiscriminating by construction.
  3. Explanation-as-trace. “I determined the fault by weighing the reranker scores…” The assistant’s account of its own process cited as evidence. Process narratives are never traces.
  4. Score-and-confidence citation. Reranker scores, model confidence, inter-assistant agreement, or attention patterns offered as diagnostic support. Scores rank; they do not diagnose.
  5. Unverified disposal. Diagnosis flowing straight to action. A prompt cannot hold the production boundary; a separate checker with veto power can.

OPINION: a system prompt without a checker is a speed-limit sign with no radar β€” informative, decorative, and routinely ignored at velocity.

The mental model: invariants are the assistant’s type system. Just as a type checker rejects programs that “look right” but violate structure, the invariant checker rejects reports that read well but violate evidence structure β€” before any human spends judgment on them. Chapters 01–03 gave three load-bearing rules; this chapter compiles them into six machine checks.

This is literal, not metaphorical. Singhvi and colleagues’ LM Assertions are exactly this construct: a hard @Assert or soft @Suggest constraint expressed as a Python function that takes the model’s output and returns a boolean, enforced by injecting the failing output and its error message back into the prompt and retrying β€” which improved output-constraint conformance by up to 164% in their experiments (Singhvi et al., 2024). The six invariants below are LM Assertions on a debugging assistant. And the most basic one β€” that every claim comes in a labeled O/H/I record at all β€” is enforced not by asking but by guided decoding: Willard and Louf’s method reformulates generation as transitions through a finite-state machine so that structurally invalid output is simply unreachable (Willard & Louf, 2023).

The method: six invariants, mechanically checked

Each invariant is stated as a reject-rule over the assistant’s structured output (O/H/I records plus the bundle manifest):

  1. I-1 Separation. Every claim carries exactly one label: OBSERVATION (verbatim + hash), HYPOTHESIS (with prediction), or INFERENCE (with deciding run). Check: unlabeled or doubly-labeled claims β†’ REJECT.
  2. I-2 Grounding. Every OBSERVATION resolves to a bundle hash. Check: unresolving citations β†’ REJECT the claim, downgrade the report.
  3. I-3 Plurality. β‰₯2 competing hypotheses, each with a predicted outcome distinct from the others. Check: one hypothesis, or two predicting the same observable β†’ REJECT as undiscriminating.
  4. I-4 Prediction-first. Each hypothesis’s prediction timestamped before its deciding run. Check: prediction missing or post-dated β†’ INFERENCE inadmissible.
  5. I-5 Trial sufficiency. Nondeterministic steps report β‰₯3 trials; single-run claims flagged INSUFFICIENT. Check: run-count < 3 on varying steps β†’ verdict capped at provisional.
  6. I-6 No-forbidden-evidence. No claim rests on model explanation, attention/confidence/score, correlation alone, single runs, inter-assistant agreement, or downstream symptom relief. Check: pattern-match the justification field; any forbidden source β†’ REJECT the inference.
    flowchart TD
    R["assistant report as structured O / H / I records + the bundle manifest"] --> I1{"I-1 separation: every claim singly labeled O / H / I?"}
    I1 -->|no| REJ["REJECT β€” return to the assistant naming the failed invariant"]
    I1 -->|yes| I2{"I-2 grounding: every OBSERVATION resolves to a bundle hash?"}
    I2 -->|no| REJ
    I2 -->|yes| I3{"I-3 plurality: >=2 hypotheses with distinct predicted observables?"}
    I3 -->|no| REJ
    I3 -->|yes| I4{"I-4 prediction-first: each prediction timestamped before its deciding run?"}
    I4 -->|no| REJ
    I4 -->|yes| I6{"I-6: no claim rests on explanation / score / confidence / agreement / single run / symptom?"}
    I6 -->|no| REJ
    I6 -->|yes| I5{"I-5 trial sufficiency: >=3 trials on every nondeterministic step?"}
    I5 -->|no| PROV["PROVISIONAL β€” cap the verdict, run the missing trials"]
    I5 -->|yes| PASS["PASS β€” route to experiment execution + human sign-off by impact"]
  
# invariant check sketch (contract-only; illustrative, not a shipped tool)
report = load_assistant_report()  # OBSERVATION: structured O/H/I, not prose
bundle = load_manifest()          # OBSERVATION: hashes from Ch45
assert all(c.label in ("O","H","I") for c in report.claims), "I-1"
assert all(b.resolve(c.hash) for c in report.observations), "I-2"
assert len(report.hypotheses) >= 2 and distinct_predictions(report), "I-3/I-4"
assert trial_counts_ok(report, minimum=3), "I-5"
assert no_forbidden_sources(report), "I-6"  # explanation/scores/agreement/symptom
# Verdict: PASS (routable) / REJECT (returned) / PROVISIONAL (capped)

OBSERVATION (constructed illustration, not a measured run): the opening report fails I-1 (unlabeled), I-2 (no resolving quotes), I-3 (single hypothesis), I-4 (no priors), I-5 (one run), and I-6 (confidence cited) β€” six-for-six rejection. UPDATED BELIEF: H1 (capable-but-unchecked) stays live pending a constrained re-run; H2 unsupported until the assistant fails under enforcement too; H3 supported in part β€” the practitioner owned the missing checker.

No instruction-following fluency, no vendor claim about an assistant’s “reasoning capability” (attribute and date any such claim; changeable fact), and no single passing evaluation upgrades an invariant-failed report. Checkers, not adjectives.

Example: the same assistant, checked, on the second pass

Constrained to emit O/H/I records against the frozen bundle, the assistant returns: three verbatim observations (hashes resolving), H1 “stale chunk” predicting “removing chunk 4 changes the quote,” H2 “prompt ambiguity” predicting “rewording changes the quote while chunk removal does not,” predictions timestamped, three-trial plan stated, no confidence language. The checker passes I-1–I-4 and I-6, marks I-5 pending execution. The human runs the trials: chunk removal changes the quote Γ—3, rewording does not Γ—3. The machine enforced the shape; the runs supplied the content. Neither sufficed alone.

Research lineage: assertions, contracts, and where the checker lives

Hard vs. soft maps onto REJECT vs. PROVISIONAL. Singhvi and colleagues distinguish @Assert (must hold; backtrack until it does or fail) from @Suggest (should hold; note the violation and proceed) (Singhvi et al., 2024). I-1 through I-4 and I-6 are @Assert β€” a violation returns the report. I-5 (trial sufficiency) is closer to @Suggest β€” the report is not rejected, its verdict is capped at PROVISIONAL until the trials run. The backtracking mechanism β€” inject the failing claim and the invariant name, retry β€” is exactly “return to the assistant naming the failed invariant.”

The invariants are Design by Contract, aimed at the assistant. Chapter 8’s precondition / postcondition / invariant vocabulary applies directly: I-2 (grounding) is a precondition on every OBSERVATION; I-3 (plurality) is an invariant on the report as a whole; I-4 (prediction-first) is a temporal precondition on every INFERENCE. Meyer’s blame rule carries too β€” a report that fails I-2 is the assistant’s contract violation, not the human reviewer’s. Note the scope: the six here are report-shape invariants, the same for every failure because they come from Chapters 01–03. The system being debugged has its own domain invariants β€” Chapter 45’s “the quote must cite a policy section present in the snapshot,” or “refund_id present on every row entering summarize” β€” and Chapter 8 showed how to get them: Daikon proposes the properties that held across the passing runs as likely invariants, curated for noise, and the incident tells you which candidate was violated. Both kinds are checked the same mechanical way.

Independence is the load-bearing constraint. The checker cannot be the assistant grading itself β€” Chapter 44’s self-preference result (Panickssery et al.) makes an assistant a lenient judge of its own output. The checker is a separate process, ideally deterministic code rather than a second model call, and where a model is used it must not be told which system produced the report.

Lab 46: run the checker over two assistant reports (proposed)

PROPOSED, not executed: no author-measured results are reported. The evidence this chapter requires is the reader’s own check log.

Setup. Take one bundled failure and one assistant. The constraint regime (free prose vs. invariant-constrained O/H/I output) is the independent variable; failure, bundle, and assistant version (pinned) are controlled.

Task.

  1. Before running, write H1/H2/H3 with distinct predicted check outcomes: H1: “constrained output passes I-1–I-4/I-6, free output fails β‰₯3 invariants”; H2: “both pass (invariants add nothing)”; H3: “both fail (assistant cannot emit checkable structure).”
  2. Collect one report per regime; run the six checks mechanically (paper form below suffices).
  3. Record PASS/REJECT/PROVISIONAL per invariant with the failing claim quoted.
Hypothesis Predicted check signature FORECAST OBSERVATION UPDATED BELIEF
H1 checks discriminate constrained passes, free fails β‰₯3 ___ ___ live/exonerated
H2 checks add nothing both pass equally ___ ___ live/exonerated
H3 assistant incapable both fail structurally ___ ___ live/exonerated

Success criterion. Two check logs with per-invariant verdicts, failing claims quoted verbatim, and trial counts stated. A judgment of “the constrained one felt better” without per-invariant verdicts is explicitly not completion.

Companion tool: Diagnostic Invariant Checker

What it accepts: the assistant’s structured O/H/I report, the bundle manifest with hashes, and the trial log for any executed runs. What it performs: it applies I-1–I-6 mechanically, quotes each violating claim verbatim, marks predictions pre/post-dated, counts trials per nondeterministic step, scans justifications for forbidden sources, and emits PASS / REJECT / PROVISIONAL with the blocking invariant named. What it can establish: whether a report satisfies evidence structure, and which invariant blocks it β€” for the examined report only. What it cannot establish: the true cause, cross-report assistant quality, or future compliance. It never treats fluency, vendor capability claims, scores, agreement, single runs, or symptom relief as passing evidence. How its output changes your next action: PASS β†’ route to experiment execution (Ch48) with human sign-off by impact; REJECT β†’ return to the assistant naming the failed invariant; PROVISIONAL β†’ execute the missing trials before any verdict.

Paper form, sufficient for this chapter:

Report ___ on bundle ___ (assistant ___ v___)
I-1 separation __ | I-2 grounding (__/__ resolve) __ | I-3 plurality __
I-4 prediction-first __ | I-5 trials (min 3: __) __ | I-6 forbidden-source scan __
VIOLATIONS (quote claim + invariant): ___  VERDICT: PASS / REJECT / PROVISIONAL

Where a software implementation does not yet exist in the reader’s stack, this record is the tool. Structure first; judgment second.

Reusable procedure: check every assistant report the same way

  1. Require structure β€” O/H/I records against the manifest, never free prose as the decision artifact.
  2. Run six checks β€” separation, grounding, plurality, prediction-first, trials, forbidden sources.
  3. Quote violations β€” each REJECT names the claim and the invariant verbatim.
  4. Cap verdicts β€” insufficient trials β†’ PROVISIONAL maximum, regardless of plausibility.
  5. Sign off by impact β€” high-impact actions need human verification on raw records even after PASS.

Failure modes

  • Prompt-instead-of-checker. Believing instructions enforce themselves. Requests do not bind; checkers do.
  • Grading prose. A human “reviewing” fluency instead of running checks. Readability is not structure.
  • Checker theater. Running I-1–I-6 but overriding REJECT because “this one looks right.” Overrides without new evidence are narration with extra steps.
  • Score laundering. Letting reranker scores or confidences pass as justifications. Forbidden sources stay forbidden after formatting.
  • Trial-count amnesia. Passing I-5 on one run “because it was decisive.” Decisiveness is judged after repetition, not during.
  • Assistant self-checking. Letting the assistant grade its own invariants. The checker is independent or it is decoration.

Limits, per contract: one check verdict covers one report on one bundle under one assistant version; it warrants structure, not truth; constraint regimes do not transfer across failures or models. UNKNOWN wherever outputs are free prose or hashes cannot be resolved.

References

  • Arnav Singhvi, Manish Shetty, Shangyin Tan, Christopher Potts, Koushik Sen, Matei Zaharia, and Omar Khattab. LM Assertions: Enhancing Language Model Programs with Assertions. arXiv:2312.13382, 2024. https://arxiv.org/abs/2312.13382
  • Brandon T. Willard and RΓ©mi Louf. Efficient Guided Generation for Large Language Models. arXiv:2307.09702, 2023. https://arxiv.org/abs/2307.09702
  • Bertrand Meyer. Applying “Design by Contract”. Computer 25(10), 1992, pp. 40–51. https://doi.org/10.1109/2.161279
  • Arjun Panickssery, Samuel R. Bowman, and Shi Feng. LLM Evaluators Recognize and Favor Their Own Generations. NeurIPS, 2024. https://arxiv.org/abs/2404.13076

Debugging Checklist

  • Report in O/H/I structure against the manifest (not free prose)?
  • I-1: every claim singly labeled?
  • I-2: every observation hash-resolves to the bundle?
  • I-3/I-4: β‰₯2 competing hypotheses with distinct pre-dated predictions?
  • I-5: β‰₯3 trials on nondeterministic steps (else PROVISIONAL)?
  • I-6: no explanation/scores/agreement/single-run/symptom justifications?
  • Verdict recorded as PASS / REJECT / PROVISIONAL with blockers quoted?
  • High-impact action held for human verification on raw records?

What This Chapter Established

  • Diagnostic AI invariants I-1–I-6: the Chapters 01–03 rules compiled into machine-checkable reject-rules (separation, grounding, plurality, prediction-first, trial sufficiency, no-forbidden-evidence) β€” demonstrated on a constructed six-for-six rejection, no measured runs claimed.
  • The checker-before-judgment principle with the type-system mental model and the independent-checker requirement.
  • Lab 46 as a proposed two-regime check log the reader executes; the Diagnostic Invariant Checker contract (accepts/performs/can-establish/cannot-establish/next-action).
  • What was NOT proved: any assistant’s capability or incapability in general, any causal verdict, or any transfer across models or failures. One enforcement layer; nothing certified.
  • Research grounding: the invariants are LM Assertions on a debugging assistant (Singhvi et al. β€” @Assert = REJECT, @Suggest = PROVISIONAL, backtracking = return-with-error, +164% constraint conformance); the O/H/I structure is enforced by guided decoding, not instruction (Willard & Louf); the invariants are Design by Contract aimed at the assistant (Meyer), with the blame rule intact; domain invariants on the system under test are mined from passing runs (Daikon, Ch8) and checked the same way; and the checker must be independent of the assistant because a model grades its own output leniently (Panickssery et al.).

Next

The rules are enforceable β€” but enforcement presupposes something this chapter assumed: an explicit, enumerable hypothesis space to check plurality and discrimination against. A checker cannot judge “competing” without a defined space of competitors. Chapter 47, “From Symptom to Hypotheses,” makes hypothesis generation a disciplined, enumerable procedure β€” coverage over cleverness.