Files
Jonathan Boniface 041e199248
Some checks failed
check agents / check (push) Failing after 12s
ALZ-F02 Assessment: critic code checks (ADR 0011), represents edges (ADR 0012)
- Critic 0.2.0 / 0.2.1: K-04 (risk), K-05 (confidence), K-06 (TCO), K-07 (routing) and K-11
  (schema and 7R enum) run in code in the critic's hooks (app/arithmetic.py,
  app/business_logic.py); post_process sets those checks, the rejected dispositions, the
  sign-off queue and the verdict. The model keeps the judgement checks; a different reading of
  a code check is kept in unverified_claims. K-07 checks the disposition agent's own queue.
  Tests on the records of run exec_4d88027a4d26, whose model sums were wrong.
- A represents edge is not a dependency (ADR 0012): risk scorer 0.1.1 and disposition 0.1.2
  leave it out of dependents and dependencies; the disposition and critic prompts carry the
  risk scorer's rule. Run exec_1f518b04d6e4: APP-001's risk 1.00 -> 0.00, out of the tail.
- The scaffold declares the critic's hooks, copies app/ in its Dockerfile, and keeps its
  app/ and tests/ when regenerating.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-06 13:20:40 +00:00

50 lines
2.2 KiB
Python

"""The critic's mechanical checks run in code (F02 ADR 0011); the model judges the rest.
`pre_process` works out K-04 to K-07 and K-11 from the producers' records, before the model runs, and shows the
result to the model as `checked_in_code`. `post_process` then sets those checks, the sign-off queue and the verdict
in the reply. What the model judged (K-01 to K-03, K-08 to K-10, K-12) is kept as it wrote it; where its reading of a
code check differs, it's kept in `unverified_claims` for the Engagement Lead.
The two hooks run in the same request, so the result passes between them in a ContextVar: one per request, never
shared between requests that run at once.
"""
from __future__ import annotations
import contextvars
import logging
from typing import Any, Optional
from app import arithmetic
logger = logging.getLogger(__name__)
_found: contextvars.ContextVar[Optional[dict]] = contextvars.ContextVar("critic_checked_in_code", default=None)
def pre_process(payload: dict) -> Optional[Any]:
if (payload.get("preconditions") or {}).get("failed"):
_found.set(None) # the planner refused: the critic returns fail on K-01 alone, and nothing is checked here
return None
found = arithmetic.check(payload)
_found.set(found)
payload["checked_in_code"] = {
"note": "K-04, K-05, K-06, K-07 and K-11 are checked in code from the producers' records (ADR 0011), and "
"their results are set in your reply after you answer. Report them as you find them; the other checks "
"are yours alone.",
"K-04": found["K-04"] or "every risk score recalculates",
"K-05": found["K-05"] or "every confidence recalculates",
"K-06": found["K-06"] or "every TCO model adds up against the rate card",
"K-07": found["K-07"] or "the disposition agent routed exactly its dispositions below 0.80",
"K-11": found["K-11"] or "every record passed the input contract; every category is in the 7R enum",
}
return payload
def post_process(result: dict) -> Optional[dict]:
found = _found.get()
if found is None:
if result.get("verdict") is not None:
logger.info("critic_code_checks_skipped")
return None
_found.set(None)
return arithmetic.apply(result, found)