Skip to main content

Module post_turn_verify

Module post_turn_verify 

Source
Expand description

Post-turn verification — “generate first, heal second”.

Alternative to mid-decode Webizen Sentinel gating: run the LLM at full resident speed (like Ollama), then verify and self-heal the completed draft against the quant-graph fact table and a lightweight CML-shaped claim extract before finalising the turn.

§Why this exists

Mid-token governance (Phase-8 rings) is architecturally important for hard fail-closed signals, but continuous logit inspection is not what makes Qualia slower than Ollama — the GPU GEMV path is. Post-turn verify still earns its keep: it recovers quality from aggressive INT4 without taxing every token, and produces an auditable HTML/CML surface for the principal.

§Pipeline

  1. LLM emits plain draft (no mid-decode interrupt).
  2. Extract crude claims / capital-style facts from draft + prompt.
  3. quant_graph_grounding repair when high-stakes needles mismatch.
  4. Emit VerifiedTurn with plain final text + HTML presentation + CML Turtle.

Structs§

VerifiedTurn
Result of post-turn verification / self-heal.
VerifyCheck
One atomic check against the local fact / ontology surface.

Functions§

maybe_verify_turn
When FastVerify (or quant-graph post path) is active, heal draft → final presentation.
return_html_as_text
Env: return HTML as the primary text field from the agent when FastVerify is on.
verify_and_heal_turn
Full post-turn pass: graph ground + claim checks + HTML/CML packaging.