feat(p22): stage 0's unknown-code refusal NAMES the codes the project buys

P21 was the first ANCHORED stress round and it bought something real -- must_refuse 5/5, all
five caught on stage0-baseline. It cost something measured just as clearly: 0 of 20 approaches
validated, and 26 of 26 rejections (20 approach rows plus 6 own-proposals -- a LARGER population
than the 20) read `unknown cost code '<invention>': not in project P's cost baseline (5 known
codes)`. The model invented signalregulering_konstruksjon, VENTIL_IMP, RIGG01, baerelag_asfalt
and 22 more, and it could not have done otherwise: the price schedule reaches the VALIDATOR and
never the proposer, and the refusal stated the COUNT of known codes, not one name. Step 5 feeds
that sentence verbatim into the next attempt -- and "you guessed wrong, there are five right
answers" carries nothing to correct towards.

The contrast already lived in the same stage: the MAGNITUDE half NAMES the baseline value, and
that is the half that let the loop converge in session 94. This gives that property to the other
half, in one place, and Step 5 carries it forward for free.

The window is a FIXED COUNT of whole codes (20), never a share, and it counts codes rather than
characters because a character cut can sever a code mid-name and hand the proposer an identifier
that exists nowhere. The cut is announced; a schedule that fits is not marked truncated; the
order is the schedule's own.

Measured with denominators: every cost baseline in this repo or its measured corpora is at most
six codes, and the largest real delivered price schedule measured is K2's prissammenstilling at
14 priced rows. Nothing measured reaches the window; it exists for the R761-style mengdebeskrivelse.

Load-bearing MEASURED (tests/test_named_known_codes_loadbearing.py, 10 arms), eight mutations all
red against the WHOLE suite + green control 1873/5 (from 1863/5, superset, 0 removed) and golden
demo-transcript.stdout BYTE-UNCHANGED (shasum -a 1 of the CONTENT = ea8c534773acdbe41ae68f2c55724d69aaf8be4f):
A1 revert to the bare count (7 red) - A2 a share instead of a fixed window (6) - A3 sorted (1) -
A4 silent cut (2) - A5 character slice (3) - A6 no bound at all (3) - A7 break the rejection_stage
marker (2, one an OLDER independent witness) - A8 grow the magnitude half with a code list
(2, one an OLDER independent witness).

Honesty limits, stated: no paid run yet confirms this changes the outcome live (that is DEL D);
the truncation branch is exercised only synthetically because nothing measured reaches the window;
and the schedule still does not reach the prompt, so the first attempt guesses as before.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Kjell Tore Guttormsen 2026-09-15 22:52:37 +02:00
commit 0a81de2d76
4 changed files with 302 additions and 3 deletions

View file

@ -154,6 +154,50 @@ def baseline_from_project(project: Project) -> CostBaseline:
)
#: P22 DEL A - how many of the project's OWN cost codes the stage-0 refusal names.
#:
#: A FIXED WINDOW, never a share of the schedule: a share scales with the corpus again, only with
#: a smaller constant, which is the exact regression the catalogue excerpt's
#: ``_CATALOGUE_EXCERPT_CHARS`` exists for. It counts CODES rather than characters for a measured
#: reason - a character cut can sever a code mid-name and hand the proposer an identifier that
#: exists nowhere, the ``_index_excerpt`` rule inverted (a path that never existed is worse than
#: no path). A count window can only ever emit whole codes.
#:
#: MEASURED with denominators (okt 126): every cost baseline anywhere in this repo or its measured
#: corpora is at most SIX codes - the five context sets carry 5/5/5/5/6, the two shipped
#: ``shared/examples`` baselines carry 1 each, and MAJOR-4's derivation of the synthetic K2 price
#: schedule yields 3 - while the largest REAL delivered price schedule measured is K2's
#: ``prissammenstilling-sheet-1.md``, 14 priced rows of 118 lines. Nothing measured reaches this
#: window. It exists for the unmeasured R761-style mengdebeskrivelse, where a Norwegian road
#: contract is priced BY prosesskode and the corpus declares 2 727 of them.
_KNOWN_CODE_WINDOW: Final = 20
def _known_codes_clause(baseline: CostBaseline) -> str:
"""The parenthetical of stage 0's unknown-code refusal: how many codes the project buys, and
which ones (P22 DEL A).
MEASURED (P21 round 5): all 26 rejections across six paid runs named an invented code and
answered with a COUNT - ``(5 known codes)`` - so the sentence Step 5 feeds verbatim into the
next attempt carried nothing to correct towards, and 0 of 20 approaches validated. The
magnitude half of this same stage NAMES the baseline value, and that is the half that let the
loop converge in okt 94. This is that half's property, given to the other one.
Bound by ``_KNOWN_CODE_WINDOW`` - a fixed count of WHOLE codes, see the constant. The cut is
ANNOUNCED (``first N:``) rather than left for the reader to subtract from the denominator,
which stays in either branch; a schedule that FITS is not marked truncated and gets its whole
list. Omission, never a lie in either direction (``index_truncated``'s rule).
The order is the SCHEDULE's own. A sort would invent a ranking the project never stated, and
the window would then be an alphabetical accident rather than the head of the document the
operator wrote."""
codes = list(baseline.items)
listed = ", ".join(repr(c) for c in codes[:_KNOWN_CODE_WINDOW])
if len(codes) <= _KNOWN_CODE_WINDOW:
return f"{len(codes)} known codes: {listed}"
return f"{len(codes)} known codes, first {_KNOWN_CODE_WINDOW}: {listed}"
def _reconcile_against_baseline(
proposal: SavingsProposal, baseline: CostBaseline, tolerance: float
) -> Rejection | None:
@ -194,7 +238,7 @@ def _reconcile_against_baseline(
if line is None:
violations.append(
f"unknown cost code {item.code!r}: not in project {baseline.project_id}'s "
f"cost baseline ({len(baseline.items)} known codes)"
f"cost baseline ({_known_codes_clause(baseline)})"
)
continue
for field, claimed, actual in (