Escape log¶
A record of defects that reached production, and — the point of the file — what now stops each one from happening again.
Every entry is written by /postmortem. The command's deliverable is not the
code fix; it is the answer to a single question:
Which gate should have caught this, and why didn't it?
A defect that produced a fix commit and nothing else has taught the system
nothing, and will be paid for again. A defect that produced a new check, a new
fixture in RUNS, or a re-anchored assertion has been converted into
permanent capability.
How to read an entry¶
- Escape class determines the fix:
| Class | Meaning | Fix |
|---|---|---|
gate-not-run |
a catching gate existed but didn't run at that point | move the gate earlier |
path-never-exercised |
the gate ran but no fixture reached the code | build the portfolio, register it in RUNS |
test-shared-the-assumption |
a test covered it and passed, written from the same wrong sentence | re-anchor to a source of truth |
no-assertion-of-presence |
output was absent/null rather than wrong | assert presence |
wrong-premise |
the plan bullet was wrong and was faithfully implemented | strengthen Wave 0 |
no-gate-exists |
nothing could have caught it | create the gate |
ungateable |
not mechanically detectable | .claude/LESSONS.md entry, with reasoning |
caught-and-parked |
a gate fired, and the record of the finding became its resting place | ratchet the finding register; give every parked entry an owning bullet |
caught-and-parked was added on 2026-08-09. It is for the case where a gate did
catch it, said so, and the wrong number shipped anyway. It is a distinct class
because its fix targets the register of tolerated findings rather than the
output — the only one of the eight that does — and because the shape recurs
across at least four parallel registers here (KNOWN_DISAGREEMENTS,
classification_table.toml's [[known_disagreement]], known_broken_rules,
known_vacuous_rules) plus strict xfails and plan bullets. Note that
no-gate-exists would prescribe roughly the right fix, so narrative fidelity
alone is not the argument.
An entry may also carry no class, and say why. A defect in a gate is not a defect that escaped one, and the eight classes all presume the latter — so forcing a class on it would prescribe the wrong fix. Leave the field unclassed with the reasoning, and name the class you would coin if it recurs.
- Verified red records the command and the failure line, confirming the new
gate fails without the fix. A gate nobody has seen fail is not a gate. Along
with the escape class and the gate change, it is what closes the defect: an
entry missing any of the three means the defect is still open, whatever
landed in
src/.
Related¶
.claude/LESSONS.md— the working set of traps every agent reads before starting. Entries graduate out of it into executable checks.scripts/arch_check.py— the numbered architectural invariants. Each one is a lesson that graduated.tests/acceptance/reporting/test_supervisory_validations.py— the two-way-ratcheted register of published EBA/BoE rules; the estate's strongest oracle for reporting defects.
The first six entries were written together on 2026-08-09, from a review of the
validation estate rather than from six separate /postmortem runs. The first four
are the escapes this project had already established with evidence and never
recorded — the file having sat at zero entries while defects reached published
output is itself the first thing the review found. The last two came out of the
review itself, one of them a measured escape and one a defect in a gate that had
not yet shipped.
Their gate changes land in the same change-set as this file, not in an
earlier release, and each was still under adversarial review when its entry was
written. Every Gate change field therefore names the item that owns it; if a
review returns revise, that field and its Verified red are what must be
re-checked, and a red produced against a revised gate is not evidence for the
gate that shipped.
2026-08-09 — Estate coverage is measured to four decimal places and gated on nothing¶
- Defect: The four C 07.00 off-balance-sheet defects recorded in
.claude/LESSONS.mdB5 reached published output because every golden portfolio was 100% drawn loans. No data ever flowed through the off-balance-sheet columns, so the four published rules that tie them out (boe_b0471,v6364_m,v1659_m,v1661_m) were never evaluated, and the supervisory gate — which fails open — was green throughout. The metric that measures exactly this condition was already computed and consulted by nothing. Measured over the current 16-run matrix: 12.85% template-cell liveness, 55,553 dead cells, 785 never-evaluated rules, and only 257 CRR / 289 Basel 3.1 published rules binding. - Rule: Not a regulatory escape. The regulatory content at risk is whatever lives in the 55,553 dead cells, which is the point: an unlit cell has no direction and no magnitude until something lights it.
- Origin:
scripts/coverage_report.pyandscripts/coverage_baseline.json, merged with the independent validation system (2026-08-08).--checkwas written, documented as a ratchet, and never called — not by CI, not byscripts/arch_check.py, not by any test. - Escape class:
gate-not-run - What the fix does and does not cover — reachability, not correctness: every
ratcheted quantity here is value-insensitive by construction. Liveness
counts cells that are non-null; "binding" counts a rule that reaches
PASSorFAIL. So a defect that changes a number in a cell that stays populated cannot move any of these metrics at all — it moves them only if it happens to null a cell or make a rule unevaluable. The worked example is the dropped+ airb_sl_exclterm in C 02.00 row 0340: a full supervisory run does not detect it either (8 passed with the defect live). This gate makes blind spots visible; catching a wrong value in a reachable cell is the supervisory register's job, and the C 02.00 subtotal shows the register currently fails at that too. Two escapes, two separate fixes — a reader who merges them will conclude the estate is better defended than it is. - Why every gate missed it: the gate was not weak, absent or wrongly anchored — it was unwired. A ratchet that no runner invokes has exactly the same effect on a defect as no ratchet, while reading in the repository like coverage is under control.
Be precise about what wiring it would have bought, because the obvious claim is
false. coverage_report.py was added on 2026-08-08 (2a1e200c), and the
off-balance-sheet portfolio that surfaced the original B5 C 07.00 defects was
built on 2026-08-01 (00b13b83) — the ratchet did not exist when they escaped.
More fundamentally, a ratchet fails on movement: a cell that was already dead
moves nothing, so wiring this gate would not have caught either the original B5
defects or their recurrence. What it prevents is the next one — a live cell
going dead, or a binding rule un-binding — and what it makes visible is the
standing blind spot's size. That is worth having, and it is not the same claim as
"this would have caught B5".
And the same inertness rotted the baseline it ratchets against.
The figures banked until this batch (251 / 277 / 1298 / 52817) reproduce at
neither matrix: re-measured on today's tree against the exact RUNS tuple of
the commit that banked them (13046bee, recovered with git show), the same
code yields 253 / 279 / 1300 / 52803. Nothing had re-derived those numbers
since they were written, so they had stopped describing the estate before the
matrix moved at all — a stronger statement of the same escape than "the matrix
grew". Nothing noticed, because the baseline recorded no field saying which
matrix, or which tree, it was measured over. A stale baseline is the second
failure mode of an unwired instrument, and the one that survives the wiring.
Do not read the dead_cells rise (52,817 → 55,553) as lost coverage: live
cells rose 7,891 → 8,193, against 63,746 declared, so the ceiling moved because
the declared population grew. And do not reason from the metric families moving in
opposite directions — they are independent, so a real cell-coverage loss alongside
an unrelated rule-coverage gain would look identical. The live-cell count is the
decisive evidence; the direction of dead_cells alone is not evidence of
anything. That property is the subject of its own entry below — the two cell
metrics are not floors.
- Gate change: in this change-set, from task 0.2 —
tests/contracts/test_coverage_ratchet.py (three always-on structural tests,
including test_the_coverage_ratchet_is_invoked_by_ci, which asserts the CI job
still invokes the script so unwiring it again fails locally, plus one
@pytest.mark.slow test that shells out to the real ~46s measurement) and the
coverage-ratchet job in .github/workflows/ci.yml running
scripts/coverage_report.py --check. Deliberately not in
scripts/arch_check.py or arch_metrics.json: the measurement is ~46s warm and
arch_check runs on every commit via the pre-commit hook, so this is a
considered placement rather than an omission to file.
The staleness limb closed too, in the same change-set from task 0.2b: the
baseline is re-banked over the 16-run matrix at 257 / 289 / 1285 / 55553 / 785
and now carries a provenance block naming the runs it was measured over, so
--check reports a matrix change as INVALID rather than as a regression and
a baseline with no provenance is called out as predating the field. That is the
structural fix, not a re-measurement: the failure was that the numbers could not
say what they described. Reducing the blind spot itself remains task 1.4.
- Verified red: two — one attacking the wiring, one attacking the ratchet.
The one that matches this escape class — the coverage-ratchet job removed from
a scratch copy of ci.yml, which is precisely the state the estate was in:
.github/workflows/ci.yml has no `coverage-ratchet` job. The coverage ratchet is
implemented but unrun, which is how it spent its whole life before P5.21: a
change can kill a live cell or un-bind a published rule with every gate still
green (.claude/LESSONS.md B5). Restore the job.
And the ratchet itself rejecting a regression — a measurement moved as a defect that kills one column would move it, against the banked figures:
[REGRESSED] union_binding_rules_crr: 257 -> 256 (may not decrease)
[REGRESSED] cells_live: 8193 -> 8181 (may not decrease)
[REGRESSED] dead_cells: 55553 -> 55565 (may not increase)
[REGRESSED] never_evaluated_rules: 785 -> 786 (may not increase)
Both run without mutating the tree. Task 0.2 also drove the real test body
through six perturbations — including a typo'd metric name, which would otherwise
surface as a KeyError 46 seconds into CI — and ran the slow test for real to a
genuine 1 failed in 46.66s.
Live caveat, and it belongs in this field rather than a footnote: --check
does not run at all as of this commit. cells_live is in _RATCHET_MIN and is
not in the banked baseline, so _check_baseline raises KeyError: 'cells_live'
— which is the typo'd-metric-name failure mode arriving for real, from a metric
addition rather than a typo. The invocation guard passes throughout, because it
asserts that CI invokes the script, not that the script works. So the red
above was produced against the baseline with cells_live banked at 8,193, which
is the state task 0.2b is landing, not the state on disk. Until that lands the
gate is wired and broken, and the honest reading of this entry is that its
escape is closed and its replacement gate is not yet demonstrably running.
The invocation guard is weaker than its own red suggests, and saying so here
is the point of the field. Its verified red exercises only the form where the
--check invocation is deleted outright. A skeptic defeated it five other
ways, each leaving the guard green: run: commented out, if: false,
continue-on-error: true, the step deleted with the command left behind in a
comment, and the workflow's on: triggers removed. A hardening is landing in
this batch. Separately, the metric choice has a defect of its own — an absolute
dead_cells ceiling can reward coverage loss, since dropping a template
removes dead cells; ratcheting cells_live instead is filed. An escape log that
overstates a gate's strength commits the error it exists to record.
- Lesson: partially graduated — B5 stays as prose. The ledger's 2026-08-09
row records B5 as PARTIALLY GRADUATED … STILL OPEN, narrowed to three: the
cell-granular case (the C 08.01 r0253 shape), the row-granular case (C 08.04's
single column is live while six of nine movement rows never carry a figure), and
never_evaluated_rules, the supervisory-register half. The first of those is
exactly what the paragraph above concedes these metrics cannot see. Since the
ledger's convention is that graduated prose gets deleted, calling this "graduated"
would invite destroying the two-leg fixture pattern that is currently the only
form the cell-granular case has. Do not delete it.
2026-08-09 — A defect that empties a column leaves all five register ratchets green¶
- Defect: A supervisory rule whose operands are all null or zero evaluates
to
VACUOUS. The per-run summary countsVACUOUSseparately fromPASSandNOT_EVALUATED— and then nothing constrains it. So a change that empties a column flips its rulesPASS→VACUOUS, the register's five ratchet tests stay green, and the estate's strongest reporting oracle reports success for a column it stopped checking. - Rule: Not a regulatory escape. The exposure is every published EBA/BoE rule whose operands can be emptied — i.e. all of them.
- Origin:
tests/acceptance/reporting/test_supervisory_validations.py. The summary was deliberately built to keep the four statuses apart (test_the_summary_keeps_unevaluable_rules_apart_from_passesasserts they are all reported and sum to the enforced population) — a correct and useful design, one step short of a gate. - Escape class:
no-assertion-of-presence - Why every gate missed it: the register asserts that no enforced rule
breaks, and vacuity is not breakage — it is the absence of an evaluation. The
count was recorded and treated as informational, which means the number moved
and no test cared. Note this is the neighbour of
path-never-exercised, not an instance of it: the 2026-08-08 recurrence proved that class's prescribed fix (build the portfolio, register it inRUNS) is necessary and not sufficient — the portfolio was registered and the cell was dead. C 08.01 r0253 held0.00in all six goldens, so the mandatory Tier 2 gate was structurally incapable of seeing a change to that column. Closing it took a two-leg fixture (a live cell that survives the change plus one that moves) and activated five previously-VACUOUSrules toPASS, includingboe_b0752_27, the r0253 tie-out itself.
The same interlock is live right now on the FCSM path, which is what makes this
worth reading twice. The seven Art. 197 capital understatements in the last
entry are unreachable by the estate's only FCSM golden portfolio
(reporting_funded_protection_portfolio.py), because both of its pledges are
CQS 1 — a CQS 1 security carries the obligor's own weight, so the defect cannot
express itself there. And that portfolio is the one deliberately withheld from
RUNS, having been registered against a config that silenced the very feature
it exists to exercise (B5's third form). So the defect sits behind two
independent layers of unreachability: a portfolio outside the register, and a
fixture shape that would not show it even inside. Neither vacuity nor coverage
can see that; only the oracle did.
- Gate change: in this change-set, from task 0.3 — a two-way vacuity ratchet
in the same register, keyed on (regime, rule_id) and stored as
known_vacuous_rules in
tests/expected_outputs/reporting/validation_known_breaks.json:
test_no_rule_falls_to_vacuous_outside_the_baseline (leg f) fails a rule that
falls to vacuity outside the register, and
test_no_baseline_vacuous_rule_asserts_again_without_being_removed (leg g)
fails a register entry that starts asserting again, so the population can only
shrink deliberately. Both drive extracted predicates
(_rules_newly_vacuous / _rules_no_longer_vacuous) rather than inline
logic. Baselined at 218 rules — 57 CRR / 161 Basel 3.1, 143 Error and 75
Warning severity — each carrying a written reason.
It is not a per-run count. The key matches known_broken_rules because a
vacuous rule has no failing coordinate to key on, and the 85 rule ids shared
across the two published extracts would otherwise collide. Membership is the
union over the sixteen runs: a rule qualifies only if it reaches a verdict
somewhere and never reaches PASS or FAIL anywhere. The per-run VACUOUS
counts stay in the register's summary block, descriptive and unasserted — the
ratchet does not read them. The consequence is worth knowing before relying on
it: a defect that empties a column on one portfolio while another portfolio
still exercises the same rule does not move this population, and that case
belongs to the goldens. Leg (f) catches the rule that stops asserting anything
anywhere, which is the case no other gate saw.
- Verified red: both legs, driven through the real test functions with a
synthetic measured set against the real committed register — deliberately not
a faked pipeline run. Leg (f), inserting b31/boe_b0752_27 (the C 08.01 r0253
tie-out, which passes on irb-classes today and is therefore absent from the
register) as vacuity-only, with its real measured facts:
1 published rule(s) now hold ONLY VACUOUSLY, 1 of them Error-severity. Every
operand was null or exactly zero, so the rule asserts nothing about our figures
while still reporting a green outcome:
b31/boe_b0752_27 [ERROR] held vacuously on 3 coordinate(s) across 4 portfolio(s)
rule: {t: OF08.01.01.01, r: 0070, c: 0253} = sum({t: OF08.02.01.01, c: 0253})
This is how a defect that empties a column passes this gate (LESSONS B5,
recurrence 2026-08-08). Find what emptied the cells.
Leg (g), removing b31/boe_b0958 (the OF 07.00 defaulted-exposure footing)
from the measured set, reported the entry leaving the vacuity population and
demanded the distinction that matters — banked activation versus a cell or run
that went away, "the estate got WORSE — fix that instead of deleting the
entry". I independently exercised the same _rules_newly_vacuous predicate
against the committed 218-entry register while writing this entry and saw it
reject the same rule. Register regeneration is idempotent over the curated
reasons; the suite is green at 8 tests.
- Lesson: second production-class recurrence of .claude/LESSONS.md B5, and
the second time B5 has been fixed as prose. Its executable form is this ratchet
plus the coverage ratchet in the entry above; B5's prose should retain only the
two-leg fixture pattern, which neither ratchet can express. The recurrence case
is now load-bearing rather than illustrative: boe_b0752_27 passes on
irb-classes and remains vacuous on rich, crm-substitution and art199, so
that one registered run is the whole reason it sits outside the vacuity
population — re-empty r0253 and leg (f) fires. Its 26 siblings
(boe_b0752_*, boe_b0814_*, boe_b0757, all Error severity) are in the
register with the B5 discharge precedent written on each entry, so the family is
ratcheted rather than merely known.
2026-08-09 — The detection rate of the whole estate is unknown, and the instrument that measures it would have lied¶
- Defect: Two compounding things. (1)
scripts/defect_injection.py— 22 mutants, a data-driven gate ladder, reachability as a first-class verdict — has never been run as a campaign, so no scorecard exists and the estate's detection rate is unmeasured. The plan that commissioned it (docs/plans/independent-validation-system.md:455) says that before the harness existed nobody could say whether the rate was 40% or 90%; that sentence is still true, because building the instrument and reading it are different acts. (2) Every gate command in the ladder was hardcoded to spawn throughuv run. On a runner without a usableuv, every gate fails to spawn, each failure scores as a detection, and the harness publishes a fictitious detection rate near 100%. This is measured, not hypothetical: on this project's own sandbox the defaultuv runpath exits 2 withCould not acquire lock … Read-only file system, so--ladder legacyrun here before the fix would have reported ~100% detection and zero escapes. The one number the harness exists to produce was the number it was most likely to get wrong. - Rule: Not a regulatory escape.
- Origin:
scripts/defect_injection.py, merged 2026-08-08 with the independent validation system. - Escape class:
gate-not-run, for the unrun campaign. Limb (2) is a defect in a gate rather than one that escaped a gate, and the taxonomy has no class for that; it is recorded here rather than given a class it does not fit. The general shape is worth naming: a gate that can go red for a reason unrelated to the defect scores that red as success, so any instrument whose signal is "something failed" needs to distinguish failed from did not run. - Why every gate missed it: nothing consumes the scorecard, so its absence
is invisible — there is no baseline to regress against and no CI job to go
red. Limb (2) survived review because the ladder is declared in the form a
developer types, and on a developer's machine
uv runworks; the failure mode only appears on a runner nobody had tried. - Gate change: in this change-set, from the injection-harness runner
override —
DEFECT_INJECTION_PYTHON(INTERPRETER_ENV_VAR,scripts/defect_injection.py:127) retargets the ladder through a named interpreter via a singleresolve_commandchokepoint (:150) that every gate command and the baseline command pass through. A partially retargeted ladder is worse than an unretargeted one, so a command it cannot rewrite is a hard error rather than a silent pass-through.preflight()(:187) then importsrwa_calc.engine.pipeline— not barerwa_calc, whose lazy__init__imports in ~150µs without touching polars — and raisesInterpreterUnusable, exiting 2 frommain(), so a broken interpreter aborts the campaign instead of reddening every gate.
Owed, not done: no test guards any of this. Nothing under tests/ imports
defect_injection at all. The graduation target is a contract test asserting
that an unset env var leaves every LADDER command and baseline_cmd byte
identical, and that preflight() raises on a nonexistent interpreter. Until
that exists the guard is correct-by-inspection-and-one-manual-run, which is what
this file exists to stop people calling a gate.
- Verified red: the pre-flight aborting a real campaign invocation
(--ladder fast --mutants control-reachable-output-floor-schedule) with
DEFECT_INJECTION_PYTHON=/nonexistent/python, exit code 2, before the baseline
digest capture and before any mutant was applied:
SPAWN PRE-FLIGHT FAILED — CAMPAIGN ABORTED, NOTHING SCORED
command /nonexistent/python -c import rwa_calc.engine.pipeline
reason the executable does not exist ([Errno 2] No such file or directory: '/nonexistent/python')
Two further reds from the same guard: /usr/bin/python3 spawns but cannot
import (reason it exited 1, with the ModuleNotFoundError quoted), and the
default uv run path in this sandbox gives reason it exited 2 with
Could not acquire lock … Read-only file system — the escape this guard actually
closes. Separately, I exercised resolve_command in-process and saw it refuse
both shapes it cannot rewrite (a command not beginning uv run, and
uv run watchfire check) rather than passing them through, which is the
silent-partial-retarget failure mode.
The campaign itself is still unrun, and no scorecard exists. Only
--reachability-only probes have run, which execute no gates; their two outputs
were written under tmp/dij/ and deleted by another agent's rm -rf tmp, and a
third run died in out.write_text because main() never creates --out's
parent directory. The default output path is scripts/defect_scorecard.json,
which is gitignored. Anyone quoting a detection rate for this workstream today
is quoting a number that does not exist. Filed as task 0.1, with the nightly
campaign and a detection-rate ratchet as task S.3.
Closed for the runner override; the reachability probe is a separate instrument
and it is open. A 22-mutant probe run (1,164s) produced four mismatches out of
22, including the deliberate UNREACHABLE control moving output — so the probe
currently reports reachable for a mutant chosen to be unreachable, which would
corrupt the denominator of any detection rate it is used to compute
(UNREACHABLE mutants are excluded from numerator and denominator both). Task
0.1a. A third defect, task 0.1b, has the harness rewriting mutation targets with
CRLF line endings. Splitting the claim matters here: two of the three instrument
defects in this entry are still live, and only the spawn path is demonstrably
fixed.
- Lesson: this is the second of these four entries whose class is
gate-not-run for the same underlying reason — the estate's habit is to build
the measurement and stop before wiring it. That is a pattern rather than two
slips, and the coverage ratchet's test_the_coverage_ratchet_is_invoked_by_ci
is the shape of its fix: an instrument ships with a test that it is invoked.
2026-08-09 — Eleven wrong numbers found by the oracle and parked as accepted disagreements, eight of them understating capital¶
- Defect:
KNOWN_DISAGREEMENTSintests/oracle/test_oracle.pyholds 11 entries, allxfail(strict=True)rather than fixed, and eight of them understate capital. Seven of the eight were added inside this batch by the CRM oracle (7c454be1), which is the fact this entry is really about: the register grew 4 → 11 in a matter of hours with nothing constraining its size. ORC-280— the largest. Art. 197 collateral eligibility is never applied on the Art. 222 Financial Collateral Simple Method path. At full cover on a CQS 5 sovereign security the oracle gives 1,500,000 against the engine's 1,000,000 — an understatement of 33.3%, the whole exposure moving from the obligor's 150% to the security's own Art. 114(2) 100%.ORC-257,ORC-258,ORC-275,ORC-278,ORC-279,ORC-281— the same defect at 30% cover, each understating 10.0% (1,500,000 against 1,350,000), across Art. 197(1)(b) rated and unrated sovereigns, Art. 197(1)(d) rated and unrated corporates, Art. 197(1)(f) equity, and the Art. 218 credit-linked note on which the engine raisesCRM019and then recognises the pledge anyway. The family's own reason text is unambiguous: "DIRECTION IS UNIFORMLY ANTI-CONSERVATIVE OR NEUTRAL, never conservative." Mechanism:engine/crm/processor.pyrunscompute_fcsm_columnsat Step 3.8, beforeapply_haircutsat Step 4 — andapply_haircutsis the only place the engine overrides a firm-supplied eligibility attestation, so the Simple Method recognises collateral the Comprehensive Method rejects.ORC-282, the Comprehensive-Method control, passes, which localises it to the one method.ORC-109— CRR Art. 121(1) Table 5 not applied to the institution class: at CQS 6 the engine returned 100% against a required 150%, an understatement by a third, withORC-105(CQS 1) andORC-020(CQS 2) as the conservative limbs of the same unwired ladder. This family is being discharged as this entry is written — P1.316 has wiredcp_sovereign_cqsthrough Table 5 under task S.2, so all three leave the register. It is recorded here because it was parked for a day with a known capital shortfall in it, not because it is still open.ORC-142— PS1/26 Art. 154(4A)(b) limb (iii): the 10% IRB mortgage RWEA floor applied to residential property outside the UK (oracle 0.00, engine 373,345.27). Conservative in direction, and unrepresentable rather than mis-gated: no module underengine/irb/reads any obligor or property country column, so no input could switch it off. Rescoped under task #21 — the fix needs aproperty_country_codecarrier, not the obligor-country gate the original framing implied.
The count in this paragraph is a snapshot, and that is the point. It was 4
when the entry was drafted, 11 when it was corrected, and lower again by the time
P1.316 lands. A register whose size is recorded in prose is stale the moment the
register moves, which is exactly why the fix is a ratchet and not a sentence.
- Rule: CRR Art. 197(1)(b)/(d)/(f), Art. 198(1)(a), Art. 218, Art. 222,
Art. 114(2); CRR Art. 121(1) Table 5 and Art. 121(2); PS1/26 Art. 121(6),
Art. 154(4A)(b), Art. 163(1)(b)-(c).
- Origin: found 2026-08-08 by the independent oracle, on merge of the
validation estate. The engine defects themselves predate it.
- Escape class: caught-and-parked — the eighth class, added with this entry.
The case for a new class is not that the existing labels read wrong
narratively; this file's own discriminator is that the class determines the fix,
and no-gate-exists → "create the gate" would in fact produce the register
ratchet named below. A class added to fit one datum is fitted, not derived. It
earns its place on two other grounds. First, the shape recurs across at least
four parallel registers in this repository — KNOWN_DISAGREEMENTS,
classification_table.toml's [[known_disagreement]] D1-D7, known_broken_rules
and known_vacuous_rules — plus strict xfails and plan bullets, so it is a
standing structural feature rather than one incident. Second, its fix targets
the register rather than a detector, which none of the other seven prescribe:
every one of them ends in something that looks at the output, and this one ends
in something that looks at the list of things we have agreed to tolerate. The
4 → 11 growth inside hours of the class being coined is the class earning its keep.
- Why every gate missed it: no gate missed it. strict=True is real discipline
in one direction — it prevents a silent fix, because an entry that starts
agreeing becomes an XPASS and a hard failure — and none at all in the other.
KNOWN_DISAGREEMENTS has no size ratchet, no owning bullet per entry and no
expiry, so seven new capital understatements were added in one batch and every
gate stayed green. The register was built to make findings triageable and became
the place they are stored.
- Gate change: filed as task #28 while this entry was being corrected — a
two-way ratchet on the size of KNOWN_DISAGREEMENTS plus a requirement that each
entry names an owning plan bullet. The 4 → 11 growth is what moved it from a
nice-to-have to the urgent item: the entry described a mechanism, and the
mechanism then fired. Code fixes tracked separately: the Art. 121 family under
P1.316 (landing now, task S.2, which must delete all three entries in the same
change), the FCSM family needing the Art. 197 gate factored out of
apply_haircuts so it applies to the Simple Method input as well — explicitly
not a step reorder, since Step 3.8 must precede the Comprehensive computation
that IRB LGD still needs — and ORC-142 under task #21.
- Verified red: n/a for detection — the disagreements are red today, by design,
as strict xfails. NOT VERIFIED for the disposition ratchet, which does not
exist yet. By this file's closing rule the escape therefore remains open, which is
the correct state to record: what exists today is the detection, not the
correction.
- Lesson: candidate for .claude/LESSONS.md — a strict xfail is a decision
to ship the wrong number; it needs an owner and a date, not just a reason.
Filed with the team lead rather than added here, since this file does not own
that one.
2026-08-09 — The register does not notice a term dropped from a C 02.00 subtotal¶
- Defect:
reporting/corep/c02.pybuilds C 02.00 row 0340 (A-IRB corporate) asairb_corp + airb_sl_excl. With+ airb_sl_exclremoved — the A-IRB specialised-lending contribution silently leaving the row — a full run of the supervisory validation suite reported8 passed. The mutation was live in the tree while that run happened. Direction: the term is only ever added, so dropping it understates the reported A-IRB corporate figure, and its RWEA goes missing from the class breakdown while the approach total still counts it —.claude/LESSONS.mdB6's shape, arrived at through a dropped term rather than a re-key. - Rule: COREP C 02.00 row 0340 composition. Ten published rules name that
cell; the two that bear on it are
v0211_m(ERROR, footing identity{r0310} = {r0320} + … + {r0410}) andv4252_i(ERROR, cross-template identity{C 02.00, r0340, c0010} == {C 08.01.a, r0010, c0260, s0007}). - Origin: the mutation was transient, injected during task 0.3's work. The escape is the register's inability to see it, which is a standing property of the estate.
- Escape class:
gate-not-run. The catching gate is not missing — this repository ships it.v0211_mis a live ERROR-severity footing identity insrc/rwa_calc/reporting/validations/rules/crr-eba-v3.0-credit-risk.json, and it is never evaluated. That is the class's definition exactly, and it is whyno-gate-existswould be the wrong label: the fix is to make an existing rule run, not to invent a check. -
Why every gate missed it:
v0211_mis one of four live ERROR rules on the C 02.00 hierarchy that are never evaluated anywhere —v0204_m,v0207_m,v0210_m,v0211_m; the fifth rule in that family,v0205_m, is WARNING severity, andv0207_mdoes evaluate, so "none of them runs" is false and the split is the evidence. The mechanism is not that C 02.00 sits outside the machinery: the recorded reason is{'row_not_emitted': 8}, so C 02.00 is in the cellspec executor and the rows the rules name are not emitted.v0210_mneeds r0250-0300 andv0211_mneeds r0310-0410, which the repo does not emit;v0207_mneeds r0060-0211, which it does — hence one evaluates and the others do not. That mechanism is already written verbatim in plan item P1.318, uncited until now. Two consequences worth stating plainly: -
The estate ships the rule that detects its own headline own-funds defect and never runs it.
v0204_masserts{r0010} = {r0040} + {r0490} + {r0520} + {r0590} + {r0630} + {r0640} + {r0680} + {r0690}, which on a credit-only book forcesr0040 == r0010; ourr0040isr0010 / 12.5.v0210_mgivesr0250five children, so r0250 is a parent where the engine puts the institutions leaf — the row-axis shift of task #17, detected by a rule we already own. - The second candidate mechanism is real but secondary:
v4252_i, the only cell-level tie-out of r0340 (== {C 08.01.a, r0010, c0260, s0007}), carriesif_value_missing: do not run rule, so a missing sheet silently removes it. Fail-open by the publisher's own semantics, on top of a rule set that is not being evaluated anyway.
What is not the explanation: the path is exercised. The cell is populated and
C 02.00 is emitted on every portfolio. And the coverage ratchet cannot see the
value defect — its metrics are value-insensitive (first entry) — but it can see
precisely this: an ERROR rule that never runs is one of the 785
never_evaluated_rules that entry counts and that nothing gated. These five
are concrete instances of that aggregate, which is what an aggregate is for.
- Gate change: deferred and filed — task #16 for this data point (it feeds
step 0.1's scorecard), task #17 for the row-axis shift, task #19 for the four
unevaluated ERROR rules. Making v0204_m/v0210_m/v0211_m evaluate is the
fix that catches the row shift and the subtotal composition together, but it is
not cheap: emitting the rows those rules address is plan item P1.318,
Effort: L, single-stream, moving 10 golden frames plus the validation
baseline. I said "cheapest of the three" in an earlier draft and that was wrong.
Independent re-derivation of C 02.00's class rows in tests/conformance/ remains
the second layer.
- Verified red: inverted — the gate was observed not firing, which is the
strongest evidence in this file. A full supervisory run with the mutation live
reported 8 passed. That is a measured negative result rather than an inference
from reading the rules: whatever the register checks, it does not check this.
- Lesson: this is the estate's first ESCAPED verdict, and it arrived free as
a side effect of another item — before the injection campaign built to produce
such verdicts has run even once (tasks 0.1 / 0.1a). Logged in the same run and
deliberately not chased: C 02.00: row 0300 (14,625,069.66) exceeds its class
breakdown (21,574.13) — a headline own-funds row exceeding the sum of its own
class rows, a live B6 condition that the estate emits as a log line and nothing
fails on.
2026-08-09 — A ratchet that can be satisfied by deleting the coverage it measures¶
- Defect: two of the coverage ratchet's five metrics are not floors.
template_cell_liveness_bpis a ratio whose denominator shrinks with its numerator, anddead_cellsis an absolute count of the complement (declared − live). Analytically, dropping N declared cells of which K are live passes both ratchets wheneverK/N ≤ 0.1285— so deleting any region less live than the estate's own average improves both numbers. Measured: droppingb31/richloses 689 live cells whiletemplate_cell_liveness_bpimproves 1285 → 1374 anddead_cellsimproves 55,553 → 47,123. Across 16 leave-one-out runs the two cell metrics never caught anything on their own, and on 4 of 16 they registered an improvement while real liveness fell; every genuine red came from a binding-rule fall or anever_evaluatedrise. "Cell liveness may not FALL" is therefore not a coverage floor, and the CI comment and the script's docstrings say that it is. - Rule: Not a regulatory escape.
- Origin:
scripts/coverage_report.py,_RATCHET_MIN/_RATCHET_MAX— in this change-set. The gate had not shipped. - Escape class: none of the eight, and it should not be forced. Every
class presumes a defect that reached production; this one was caught by
adversarial review of a gate before it landed, and its subject is the gate
rather than the engine. It is recorded here because this file's question — which
gate should have caught this — has a real answer worth keeping (adversarial
review of a new gate's metric algebra, which is what did catch it), and because
anyone tracing the coverage ratchet's history needs to find it. If entries of
this shape recur,
gate-unfitis the name to give them; one instance is not a taxonomy. - Why nothing else would have caught it: the metric algebra is invisible to tests. Every structural test of the ratchet — including task 0.2's six perturbations — checks that a declared regression is rejected, which these metrics do correctly. None asks whether the quantity being ratcheted is the quantity that matters. Only leave-one-out measurement over the real matrix exposes it, and nothing in the estate does that automatically.
- Gate change: in this change-set, from task 0.2b, and half-landed as of this
commit —
cells_liveis in_RATCHET_MINin the code and is not in the banked baseline, so--checkcurrently raisesKeyError: 'cells_live'rather than gating. The floor value is 8,193; banking it is what completes this, and until then the gate this entry describes is broken rather than working. It is already computed aspayload["cells"]["live"], it fell in 15 of the 16 deletions and in both config-silencing variants, and it never rose on a loss. Filed separately:never_evaluated_error_severity_{crr,b31}(175 / 195) is computed and unratcheted, so swapping one ERROR-severity never-evaluated rule in for one INFO out is invisible to the flat total — while the script's own docstring calls an ERROR rule that never runs anywhere the worst case in the estate. - Verified red: the leave-one-out measurement is itself the red, and it is red
in the diagnostic direction — the two metrics passed while coverage fell, on
4 of 16 deletions.
cells_livewas then checked against the same 16 deletions before being adopted and fell in 15; the one deletion it did not catch is a residual the follow-up should name rather than leave implied. - Lesson: the executable form is the
cells_livefloor itself. The transferable rule — ratchet the quantity you care about, not a ratio of it and not its complement — is offered to the operator as a.claude/LESSONS.mdentry, since a ratio-shaped ratchet reads as a floor to every reviewer who does not do the algebra.
2026-08-11 — The release script's test run happens before the mutation it should catch¶
- Defect:
scripts/deploy.pybumped the package version and regenerated two of the four generated artifacts. Three targets embed the version in their own output —docs/data-model/regulatory-tables.md(generate_regulatory_tables.py:811),docs/development/confidence-matrix.mdandtests/contracts/data/confidence_snapshot.json(generate_confidence_matrix.py:525,747) — so the bump alone was sufficient to make all three stale, with no other change in the tree. v0.3.25 was committed and tagged in that state; CI on the release commit failedtest_regulatory_tables_page_is_freshandtest_confidence_matrix_is_fresh. A second, latent instance rode along:generate_citation_matrix.pywritestests/contracts/data/citation_snapshot.json, whichGIT_STAGE_FILESnever staged — the same defect, one release away from firing. - Rule: Not a regulatory escape.
- Origin:
scripts/deploy.py::build_release/GIT_STAGE_FILES, standing since the generated pages acquired their version stamps. Every prior release had the same hole; it only became visible when a freshness contract test covered the stamped targets. - Escape class:
gate-not-run, with a twist worth recording. A catching gate existed and was in fine health: both freshness contract tests ship, run in the default suite, and pass.deploy.pyruns the suite as step one and bumps the version as step two, so the gate measured a tree in which the defect did not yet exist. The class table prescribes "move the gate earlier"; here the correct move is the opposite, later — after the mutation. The class is about a gate that ran at the wrong point, and earlier is simply the common case, not the definition. If this shape recurs, the prescription column should read "move the gate to the other side of the mutation". - Why every gate missed it: ordering, and nothing else. Local
pytestpassed (measured pre-bump). The pre-commit gate passed (same reason). CI was the only gate positioned after the mutation, and CI is the last one — by the time it spoke, the version commit and the annotated tag existed, and the tag had been pushed. Note what this rules out: it is not that the freshness tests are weak or that a path went unexercised. They are strong and they ran. A gate's position in the sequence is part of its specification, and nothing in this estate had ever stated the position of these two. - Gate change:
scripts/deploy.py::build_releasenow runs both version-stamped generators after the bump, andGIT_STAGE_FILEScarries their three targets pluscitation_snapshot.json. That fixes the instance. The category is closed bytests/contracts/test_release_regeneration.py, which discovers version-stamped generators by inspection — anyscripts/generate_*.pyreadingpyproject.toml's version — and fails when one is not invoked bydeploy.py. Discovery is deliberately not a hand-maintained list, because a hand-maintained list is exactly what was wrong. Its companion test asserts the sweep is non-empty, so a drifted heuristic fails loudly instead of passing vacuously. - Verified red: run against the real pre-fix
deploy.pyat6f513697:
RED against pre-fix deploy.py (6f513697).
Not regenerated by the release script:
- generate_confidence_matrix.py
- generate_regulatory_tables.py
Green against the shipped deploy.py (2 passed). The red is produced from
the actual defective commit, not a reconstruction of it.
- Lesson: a gate that runs before the step it protects has not run. The
release script's ordering — test, then mutate, then commit — reads as
conscientious and is precisely backwards for anything the mutation itself can
break. Worth a .claude/LESSONS.md entry in the operator's judgement, because
the shape generalises past releases: any sequence that validates and then
transforms has this hole.
2026-08-11 — A wheel outgrew the pinned uploader, and no gate in the release flow could see it¶
- Defect: publishing v0.3.25 to PyPI failed with
Checking dist/rwa_calc-0.3.25-py3-none-any.whl: ERROR
InvalidDistribution: Invalid distribution metadata:
'2.5' is not a valid metadata version
uv build resolves the build backend fresh on every run, and the current
backend emits Metadata-Version: 2.5. .github/workflows/publish.yml pinned
pypa/gh-action-pypi-publish at cef22109… (v1.14.0), whose vendored Twine 6
predates 2.5 and refuses it. Nothing in this repository changed: v0.3.24
published on 5 August and v0.3.25 did not, because one of the two components
moved on its own.
- Rule: Not a regulatory escape.
- Origin: standing since the action was pinned. The pin is correct practice —
it is the reason the failure was a clean refusal rather than a supply-chain
surprise — but pinning one side of a two-sided compatibility relation converts
"we are current" into "we are frozen against a moving target".
- Escape class: no-gate-exists. Nothing anywhere — locally, in the
pre-commit gate, in CI, or in deploy.py — inspected a built distribution.
uv build was run for its exit code alone, and its exit code is 0 for a
perfectly well-formed wheel that this particular uploader happens to reject.
- Why every gate missed it: the whole estate tests the source tree, and
this defect does not exist in the source tree. It exists only in the artifact,
and only in relation to a version pinned in a YAML file that no test reads.
Note in particular that twine check alone would not have caught it: any
Twine new enough to install today accepts 2.5 happily, so a local twine check
is green on precisely the wheel that fails. The failure is not "malformed
distribution", it is "distribution newer than the pinned publisher" — a skew
between two versions, visible only when both are read together. A gate built on
the obvious reading of this incident would not have caught this incident.
- Gate change: scripts/check_distribution.py — reads Metadata-Version
from every built wheel and sdist, reads the pinned publisher version out of
publish.yml, and fails when the former outruns what the latter accepts
(PUBLISHER_METADATA_SUPPORT). Invoked from deploy.py::build_release and
from the CI build job, with uvx twine check dist/* alongside it in CI for
the malformed-distribution class it does cover. tests/contracts/test_distribution_gate.py
covers the checker and asserts both call sites still exist — this project has
shipped an inert ratchet before, and a script nothing calls reports success
forever. An empty dist/ is a failure, not a pass.
- Verified red: the shipped gate, via
check_distributions(dist_dir, workflow) — the gate exposes no path-typed CLI
argument, so a reproduction calls the function, exactly as the contract tests
do — against the real v0.3.25 artifacts with the pre-fix pin from 451e97db:
Built distributions declare core metadata newer than the pinned publisher accepts.
- rwa_calc-0.3.25-py3-none-any.whl declares Metadata-Version 2.5
- rwa_calc-0.3.25.tar.gz declares Metadata-Version 2.5
pypa/gh-action-pypi-publish is pinned at v1.14.0, which accepts up to Metadata-Version 2.4
Exit 1. Green (exit 0) against the shipped v1.14.2 pin. Both the artifacts and
the pin are the genuine article, so this reproduces the escape rather than
modelling it. The disarm case was checked too: replacing the deploy.py call
site fails test_gate_is_actually_invoked.
- Note — the gate's own first version failed the quality gate: it took
--dist-dir / --workflow as type=Path CLI arguments, which SonarCloud
flagged as pythonsecurity:S8707 (MAJOR), taking new_security_rating to C
against a required A. That is the third instance of this rule here, after
injection_ratchet.py and coverage_report.py's bank(). The remedy is
already settled and is not a containment guard: commit a5d34c0d records
two successive attempts at resolve-then-contain that left the finding in place.
Both path arguments were therefore removed rather than sanitised, and
test_gate_exposes_no_path_typed_cli_argument now asserts that no type=Path
argument returns.
Three instances of one rule, each fixed the same way, is a lesson that has
proven it cannot survive as prose, so it was graduated to arch_check.py
check 19: no type=Path argparse argument anywhere in scripts/. Verified
red by restoring this script's own pre-fix body from d4fdcee6 — the exact
code SonarCloud rejected — which the check names argument by argument:
scripts/check_distribution.py: add_argument(--dist-dir) uses type=Path...
scripts/check_distribution.py: add_argument(--workflow) uses type=Path...
arch_check exit=1
Exit 0 once restored. Running it for the first time found nine further
instances that no one had counted — coverage_report.py --out,
defect_injection.py --out, five in impact_report.py, two in
parity_gate.py. They ship as a shrink-only CLI_PATH_ARG_ALLOWLIST
rather than being fixed here, because draining them means touching four
scripts and their workflow call sites; filed as task #36. Two things are worth
recording about that number. It is more than double the instances anyone knew
about, which is the usual result of converting prose into a check. And
coverage_report.py is on the list despite commit 89bf0323 having already
fixed this rule in that same file — the earlier pass removed bank()'s
baseline_path and left --out untouched, which is precisely what
per-instance fixing looks like from the outside: a file that has been "fixed"
and still carries the defect.
- Lesson: pinning one side of a compatibility relation makes the other side
a moving target, and the skew is nobody's regression. Neither component was
wrong; both were doing their job. The general form — when you freeze one of two
things that must agree, something has to assert they still agree — is the part
worth carrying, and it applies to every pinned tool in this repo, not just the
uploader.
2026-08-12 — The input contract was written, unit-tested, and connected to nothing¶
- Defect: 10 of the 14 public validators in
src/rwa_calc/contracts/validation.py— 402 lines, every one of them carrying green unit tests — could not be reached from any production path undersrc/.validate_pd_range,validate_lgd_range,validate_ccf_modelled,validate_non_negative_amounts,validate_schema,validate_schema_to_errors,validate_required_columns,validate_raw_data_bundle,validate_resolved_hierarchy_bundle, andvalidate_aggregated_bundle— the last of which is the output-bounds guard (RW > 1250%, RW < 0, RWA < 0, null EAD) that would have run on every result the engine has ever produced. 48 unit tests pass over that code in 2.7 seconds, testing logic that never runs on customer data.
The consequence is measured, not inferred. On CRR, £1m senior corporate, F-IRB:
a risk feed sending PD = 1.5 to mean "1.5%" returns RWA £603.67 against a
correct £1,119,286.69 — an understatement of 99.9461%, a £1,118,683 capital
shortfall on every £1m of exposure, with no exception, no null and no
CalculationError. LGD = -0.2 returns £0.00. Maturity = -3 years returns
£776,750.85. CQS = 0, 7 or 99 on a corporate returns RW 100%, which moves
capital in both directions — 100% against a true 20% at CQS 1, and 100%
against 150% at CQS 6 on an institution. Every one of those is a number a
reviewer would accept.
- Rule: Not a single regulatory article — the exposure is the input domain of
every article the engine implements. The output-bounds limb is the closest to a
named rule: RW is capped at 1250% (CRR Art. 92 / PS1/26), and
validate_aggregated_bundle is the only thing in the estate that would have
said so.
- Origin: src/rwa_calc/contracts/validation.py. The escape is old and was
already documented: docs/plans/engine-defensiveness-boundary-hardening.md,
written 2026-05-29, states in its root-cause line that "the
contracts/validation.py bundle validators were never wired into
pipeline.py." That sentence was still true 2.5 months later, which is the part
of this entry worth reading twice — the finding did not escape detection, it
escaped conversion into a gate.
- Escape class: gate-not-run. The catching gate is not missing; this
repository ships it, with tests. It is never invoked on customer data. That is
the class's definition exactly, and it is why no-gate-exists would prescribe
the wrong fix — nothing needed inventing, only wiring. It is the fourth
entry in this file to carry that class, and the fifth measured instance of the
habit the log itself names: build the measurement and stop before wiring it.
- Why every gate missed it: no gate looks at reachability. Every existing
guard in the estate answers "is this output right?", and an unreachable
validator produces no output to be wrong. Worse, it produces the opposite of a
signal: 48 passing unit tests over 402 lines of validation logic read, to any
reviewer and to every coverage instrument, as an input contract that is
enforced. Coverage tooling counts those lines as covered, because they are —
by tests, not by the pipeline.
Note the asymmetry with the four earlier gate-not-run entries. Those were
instruments nobody had run yet; this one had been run, its finding recorded in
a plan document, and the plan document then sat. A written root-cause line is not
a gate. Prose has now failed at this five times.
- Gate change: scripts/arch_check.py check 20 —
check_guard_reachability, registered in main() so
python scripts/arch_check.py runs it on every commit via the pre-commit hook.
Every public function in contracts/validation.py (the input contract, which is
guard-shaped in whole) and every guard-named public function elsewhere under
contracts/ (validate_ / check_ / assert_ / require_ / ensure_) must
be transitively reachable from production code under src/. Scoped by shape
rather than by path so a future contracts/checks.py is covered on the day it
is written; deliberately not extended to the layer's create_empty_* factories
and *_error constructors, 10 of which are unreachable today and would have
given the check a ten-entry allowlist on arrival.
Three properties are load-bearing, each aimed at a way this file records gates going soft:
GUARD_REACHABILITY_ALLOWLISTis empty by design. Seeding it with the ten known-unreachable validators would have made the check vacuous on arrival — thecaught-and-parkedshape, where a gate fires, the finding is filed, and the wrong behaviour ships anyway. Stale entries are themselves violations, so the list can only be drained.CONTRACTS_GUARD_SURFACEpins the population, because reachability alone is satisfiable by removing the thing it measures: renamevalidate_pd_rangeto_validate_pd_rangeand it leaves the measured set; delete it and the violation leaves with it. This repo has shipped that shape before — four back-compat shells silently disarmed a regression guard that readmodule.__file__(check 18). Deleting a guard stays legitimate; it just has to be deliberate, so the pin is removed in the same change and a reviewer sees which guard went away. It fired for real during this batch (see below).tests/contracts/test_guard_reachability_gate.py::test_every_arch_check_check_is_registeredgeneralises the wiring assertion past check 20: nocheck_*function inarch_check.pymay exist withoutmain()invoking it. An unregistered check is this escape class committed inside the gate itself.
The analysis has exactly one implementation. scripts/validator_reachability.py
— the census this grew out of, and the reproduce command in the proposal — now
reads measure_guard_reachability from arch_check instead of keeping its own
copy, and test_the_reachability_analysis_has_one_implementation asserts both
that it does and that the two agree on the population. The dependency points
diagnostic → gate and never the other way, so the gate keeps working if the
diagnostic is renamed or deleted.
- Verified red: two, and the second was not planned.
(1) The escape itself, check 20 run against the committed pre-wiring tree
(git archive aa2182bd src, so the measurement is of the state that shipped
rather than of a scratch mutation):
[FAIL] Contracts guards are reachable from production (wire it, or delete it)
contracts/validation.py:1140: validate_aggregated_bundle -- guard unreachable from production
contracts/validation.py:403: validate_ccf_modelled -- guard unreachable from production
contracts/validation.py:373: validate_lgd_range -- guard unreachable from production
contracts/validation.py:317: validate_non_negative_amounts -- guard unreachable from production
contracts/validation.py:348: validate_pd_range -- guard unreachable from production
contracts/validation.py:236: validate_raw_data_bundle -- guard unreachable from production
contracts/validation.py:151: validate_required_columns -- guard unreachable from production
contracts/validation.py:277: validate_resolved_hierarchy_bundle -- guard unreachable from production
contracts/validation.py:64: validate_schema -- guard unreachable from production
contracts/validation.py:176: validate_schema_to_errors -- guard unreachable from production
Total: 10 violation(s)
Ten violations, zero allowlist entries, and the same ten the proposal's census named — an AST-based reference analysis independently reproducing the seed script's regex-based answer.
(2) The population pin, firing unprompted. While the wiring work was landing
in parallel, five of the ten validators were deleted rather than wired
(validate_schema, validate_schema_to_errors, validate_required_columns,
validate_raw_data_bundle, validate_resolved_hierarchy_bundle). The
reachability limb went green as they disappeared — exactly the defusal the pin
exists for — and the pin caught all five:
contracts: validation.py::validate_schema -- pinned in CONTRACTS_GUARD_SURFACE but no
longer a public module-level function there. Check 20 may not be satisfied by deleting,
privatising or relocating the guard it measures; if the removal is deliberate, delete
the pin in the same commit so a reviewer sees it
This is the strongest evidence in the entry, because it was not a constructed
probe: the check's anti-defusal limb fired on real concurrent work within an
hour of being written, on a removal nobody had announced. Two of those five
deletions are prescribed by the proposal; the other three are a wider call, and
the pin is what turned them into a decision somebody has to state. Before the
pins were dropped the removal was verified complete — definitions and their
private helpers gone, and no reference to any of the five surviving anywhere
under src/ or tests/ — so what the change-set records is a finished
deletion, not a half-migration. The consequence worth stating plainly: the
estate now ships no declared-vs-actual schema-drift check at all.
(3) Six adversarial perturbations, run against a throwaway copy of src/
so the real tree was never mutated (a killed injection run leaving a live
mutation in src/ has cost this project hours before). Control: 0 violations.
Privatising validate_pd_range to _validate_pd_range → 1 (the pin, not the
reachability limb, which goes quiet — that is the defusal). Deleting
validate_lgd_range outright → 1. A new contracts/checks.py::validate_nothing
that nothing calls → 1, which is the scope-by-shape decision earning its keep:
the check covers a module it has never seen, so hard-coding validation.py
would have let that through. Deleting contracts/validation.py entirely → 9.
And the negative control that matters, since a gate that fires on everything
is not a gate: a new non-guard public function in the same unreachable
position (create_empty_thing) → 0 violations, confirming the scope
boundary is the one documented rather than an accident.
- Lesson: this is the fifth instance of the estate's dominant meta-pattern and
the second time it has been "fixed" by writing it down. .claude/LESSONS.md
carries the graduation rule for exactly this case — a lesson that reaches
production twice cannot survive as prose — so the entry belongs in the
Graduation ledger rather than the working set. Check 20 is the same move check
14 made on Polars namespaces: it removes the category, not the instances.
What remains prose, because no check can express it: the proposal's other three
phases (declare the input domain as data, fuzz the pathology axis, make absence
loud) are what stop the next silent-plausible-number defect; check 20 only
guarantees that a guard we have already written is running.
2026-08-12 — The registers of tolerated findings had no size gate and named no owner, and the count everyone quoted was wrong in both directions¶
- Defect: This file's 2026-08-09 entry 4 recorded eleven wrong numbers parked as accepted disagreements and named its own gate change — a ratchet plus an owning bullet per entry — then closed its Verified red field with "NOT VERIFIED for the disposition ratchet, which does not exist yet. By this file's closing rule the escape therefore remains open." It stayed open for three days. This entry is that closure, and it is filed as its own entry rather than an edit because the interval produced two findings of its own.
First: the population was never counted again. Measured on
fix/input-domain-correctness, 2026-08-12 — KNOWN_DISAGREEMENTS holds 8
entries, 7 of them understating capital: six FCSM cases at 10.0% and
ORC-280 at 33.3%. The eighth, ORC-142, runs the other way (engine applies
a 373,345.27 mortgage-floor adjustment where the oracle applies 0.00) and its
limb is unrepresentable rather than mis-gated. So "11 entries, 8 understating"
— the figure in docs/plans/test-space-correctness-proposal.md, in
IMPLEMENTATION_PLAN.md P5.41, and in this file's own entry 4 heading — was
wrong on both numbers by the time anyone acted on it. Three of the eleven
(the Art. 121(1) Table 5 family) were discharged by P1.316 hours after entry 4
was written. Entry 4 predicted this in terms: "a register whose size is recorded
in prose is stale the moment the register moves, which is exactly why the fix is
a ratchet and not a sentence." Its own heading is now the worked example.
Second: not one of sixteen entries named an owner. Across both declared
registers — 8 in KNOWN_DISAGREEMENTS, 8 in tests/conformance/classification_table.toml
(D1–D7 including D1b, which is why the parallel register is 8 and not the 7
everything referring to it says) — 0/16 reason strings named the plan bullet
responsible for the fix, against .claude/LESSONS.md B7's explicit instruction
to put one there. All sixteen owning bullets already existed in
IMPLEMENTATION_PLAN.md; nothing linked an entry to one, so a register of
sixteen shipped-wrong numbers had zero accountable owners while every bullet
that would have fixed them sat filed and unreferenced.
- Rule: Not a regulatory escape in itself. The regulatory content at risk is
what the sixteen entries park: CRR Art. 197(1)(b)/(d)/(f), Art. 198(1)(a),
Art. 218, Art. 222, Art. 114(2); PS1/26 Art. 154(4A)(b); CRR Art. 154(4)(c) /
PS1/26 Art. 147(5A)(c); PS1/26 Art. 147(4C)(b)(ii); CRR Art. 147(2)/(3)/(7).
- Origin: tests/oracle/test_oracle.py::KNOWN_DISAGREEMENTS and
tests/conformance/classification_table.toml. Both were built correctly —
tests/oracle/README.md is emphatic that when the engine and the oracle
disagree you adjust neither — and both were built without a size gate.
- Escape class: caught-and-parked. Confirmed against the definition at the
top of this file rather than assumed: "a gate fired, and the record of the
finding became its resting place", fix "ratchet the finding register; give
every parked entry an owning bullet". Both limbs match exactly, and the
prescribed fix is the fix that landed. Worth noting that the class's own
justification — "the shape recurs across at least four parallel registers here"
— is what made the shared mechanism below the right answer rather than four
bespoke ratchets.
- Why every gate missed it: xfail(strict=True) is a real gate in exactly one
direction. It fails when an entry starts agreeing, so a silent fix is
impossible and requirement (b) has always been enforced at the only place that
can enforce it. Nothing anywhere constrained growth, and nothing read the
reason strings at all — they are prose attached to a marker, and prose is not
parsed. The population could therefore rise without limit while every gate
including the two mandatory Tier 2 ones stayed green, which is precisely what
4 → 11 in one batch looked like from the outside: a green suite.
- Gate change: in this change-set, from P5.41. ONE mechanism, two runners.
- scripts/tolerated_findings.py — the shared primitive: a direction-neutral
generic set-diff (diff) and the owner grammar (owner_of / unowned).
Extracted from the supervisory register rather than written fresh.
- scripts/check_parked_registers.py --check — the gate over the two
declared registers, against scripts/parked_registers_baseline.json.
- tests/contracts/test_parked_register_ratchet.py — 13 tests. Three run the
real gate over the real registers, including one that shells the CLI; ten
drive the mechanism synthetically so both directions are demonstrable in
milliseconds.
- tests/acceptance/reporting/test_supervisory_validations.py — all seven legs
now route their set arithmetic through the same diff. Semantics-preserving:
8 passed, unchanged.
Script and pytest, for a stated reason. The four registers split on what it
costs to compute current membership. The supervisory three are measured — a
union over sixteen pipeline runs, and only pytest owns the fixtures that produce
them — so that ratchet stays where the data is. The two declared ones are a dict
literal and a TOML array; reading them is a few milliseconds, so they get a
script, which buys the explicit --update-baseline verb that makes banking a
separate reviewable act from checking.
Deliberately in-suite rather than a CI job. This file's 2026-08-09 entry 1 records a CI-only invocation guard defeated six ways while staying green. A millisecond census belongs where nobody has to remember to run it.
Stronger than the bullet asked: additions are shrink-only, not two-way.
--update-baseline prunes departed ids and refreshes owners and refuses to
add, so banking a new parked finding means hand-editing the baseline — a diff
in a file whose whole purpose is to be reviewed. Every other ratchet in this repo
can be satisfied by re-banking a worse number; this one cannot, because what it
counts is figures an independent derivation has shown are wrong.
Removals stay free, and the docstrings say why: a gate that reddens on a fix
teaches people to stop fixing, and strict=True already forces the entry's
removal in the same change. The residual hole is stated in
scripts/tolerated_findings.py rather than hidden — while a baseline id is
stale it is slack in the addition gate — and closing it would mean gating
removals.
Requirement (c) landed as ownership, not as a grandfathered exception set.
All 16 entries carry an OWNER: P<n>.<n> token; every owning bullet already
existed and no new bullet was filed. ORC-142 → P1.337;
ORC-257/258/275/278/279/280/281 → P1.330; D1/D1b → P1.320; D2 →
P1.321; D3/D4/D6 → P1.303; D5/D7 → P1.322. The grammar is
an explicit token and not a bare P\d+\.\d+ scan, which was tried and rejected
on measurement: _ART_154_4A_B_SCOPE already reads "Since P1.319,
engine/irb/adjustments.py gates on the first two and not the third" — a
historical reference to the bullet that narrowed the gate, not an owner for
what remains. A bare regex would have passed the one entry whose ownership was
hardest to establish and failed the seven whose owner was obvious; it would have
measured prose style, not accountability. That case is pinned by
test_a_historical_bullet_reference_is_not_an_owner.
- Verified red: six, and the first two are the ones this entry's class
demands. All were produced against the real registers — four by writing the
perturbation to disk and restoring it in a finally, so nothing was faked
in-process.
(1) A ninth disagreement added to tests/oracle/test_oracle.py, driven through
the suite (2 failed, 11 passed):
NEW PARKED FINDING (tests/oracle/test_oracle.py::KNOWN_DISAGREEMENTS): 1 entry/entries outside the committed baseline:
ORC-999 (owner: P1.330)
This register may only SHRINK. Every entry is a number we have independent evidence is WRONG and are shipping anyway, so growing the population is a decision, not a side effect.
FIX THE DEFECT. If the finding is genuinely accepted, hand-edit parked_registers_baseline.json to add the id with its owning bullet — --update-baseline will not do it for you.
(2) The owner token stripped from _ART_197_FCSM_ELIGIBILITY — requirement (c),
firing on all seven consumers of the shared reason (3 failed, 10 passed):
NO OWNING BULLET (tests/oracle/test_oracle.py::KNOWN_DISAGREEMENTS): 7 entry/entries name no plan bullet:
ORC-257
ORC-258
ORC-275
ORC-278
ORC-279
ORC-280
ORC-281
An entry with no owner is the review finding, not the xfail (.claude/LESSONS.md B7). Add `OWNER: P<tier>.<n>` to the entry's reason text, naming the IMPLEMENTATION_PLAN.md bullet that owns the fix — and file that bullet in the same change if it does not exist yet.
(3) and (4) are the same two against the other register, proving the mechanism
is shared and not a single-register special case — a ninth
[[known_disagreement]] appended to classification_table.toml gives
NEW PARKED FINDING … D8-synthetic-ninth (owner: P1.303), and stripping D2's
token gives NO OWNING BULLET … D2-large-corporate-test-keys-on-one-entity-type-string.
Both exit 1.
(5) The whole gate before the fix, on the untouched tree, which is the state the
estate was actually in — two NO OWNING BULLET blocks, 8 entry/entries each,
naming all sixteen ids, exit 1.
(6) The shrink-only claim attacked directly, since a refusal that is only
documented is not a refusal. --update-baseline asked to bank the ninth entry:
baseline banked at 16 parked finding(s)
REFUSED to bank 1 NEW entry/entries:
oracle_known_disagreements: ORC-999
Additions are shrink-only. Fix the defect, or hand-edit parked_registers_baseline.json so the decision to ship a known-wrong number appears in the diff.
with the baseline file byte-identical afterwards — checked, not assumed.
What this gate does NOT do, and it is the thing a reader will assume. It
constrains the size of the register. It does not shrink it, and it says nothing
about whether any of the sixteen parked numbers is right. Seven capital
understatements are still shipping today; P1.330 and P1.337 own them. This is a
ratchet, so it fails on movement — the sixteen entries already there move it
not at all, and a reader who takes a green gate as evidence the estate is clean
has read it exactly backwards. Draining is Phase 4's actual objective; this only
stops the queue growing while that happens.
- Lesson: .claude/LESSONS.md B7 is now graduable, and the graduation is
filed rather than performed here — following entry 4's own precedent, since
this file does not own .claude/LESSONS.md and two other agents were editing
the tree concurrently. Both of B7's limbs are executable for both declared
registers: membership (--check on the baseline) and ownership (the OWNER:
token), so its Detect line — "a register entry naming no bullet is the thing to
catch in review" — is no longer a thing to catch in review. What should survive
the trim is the judgment B7 carries and no check can: that registering the
disagreement is the right first move, and that the failure is treating the
registration as the end of it. Keep B8 ("ratchet the accumulator, not a ratio")
as prose in full: this mechanism
applies it — the accumulator is the id set, so a register that grows by one and
shrinks by one is detected as movement — but B8's own worked example is about
choosing the right metric, which no check can express. What also does not
graduate, and belongs here rather than in a lesson: the count in the bullet was
wrong, in a bullet whose entire subject was that counts in prose go stale. The
ratchet fixes the register; nothing fixes a figure typed into a sentence.
2026-08-12 — Three input pathologies produce a plausible number and no signal, and the codes that would report two of them are declared with no producer¶
- Defect: three distinct silent-wrong-number paths, all found in the first
hours of the
tests/robustness/suite existing. Each returns a populated results row a reviewer would accept.
(1) An orphan or null counterparty_reference. Every counterparty-attribute
join in the hierarchy stage is how="left" — the obligor rating/CQS lift at
engine/stages/hierarchy/enrich.py:131-135, the entity-type gate lookup at
:253, and the graph joins at graph.py:388-420 — so a loan whose obligor
cannot be found survives with null obligor attributes, classifies to other,
and takes the 100% fallback risk weight. Measured on CRR, one GBP
1,000,000 senior loan: a CQS 6 corporate is CRR Art. 122 150% = GBP
1,500,000; pointed at a reference that does not exist it returns GBP
1,000,000, a 33.3% understatement on a one-character typo. The direction
reverses with the obligor's true class — a CQS 1 corporate is 20% = GBP 200,000
and orphaning it returns GBP 1,000,000, a 5x overstatement — so the defect
is not conservative in either direction. A null counterparty_reference
reaches the identical fallback, which matters because that is the more common
feed shape (an outer join upstream, or a column never populated).
ERROR_ORPHAN_REFERENCE (DQ005) is declared in contracts/errors.py:93 and
re-exported from contracts/__init__.py, and appears nowhere else under src/.
(2) An unreadable numeric is indistinguishable from an absent one.
FIXED while this entry was being written — see the closing section below;
the measurement here is the pre-fix state, and is what the new gate was verified
red against. EdgeContract.conform_lenient (contracts/edges.py:198-251) cast every
mismatched declared column with strict=False, so Polars turns a value it
cannot parse into a null, missing comes back empty, and no data-quality
error is emitted. Composed with the input contract's own (correct) rule that
null is never a domain violation, the result is a hole. Measured: the same GBP
1,000,000 loan whose drawn_amount arrives as the string "1,000,000.00" — a
plain CSV export with a thousands separator — reports ead_final = 0.00 and
rwa_final = 0.00 against a correct GBP 200,000, with no error. Seven ordinary
export artefacts do this (£1000000, 1 000 000, (1000000), n/a, the empty
string, a truncated 1.0e). CSVLoader reads with pl.scan_csv, which infers
such a column as String, so this was the shipped CSV path and not a contrived
bundle.
(3) A duplicated input row vanishes.
engine/stages/classify/permissions.py:261 de-duplicates on
exposure_reference after the model-permission join — correct for its own
purpose, which is to stop a fan-out when several permissions match — and in
doing so collapses genuine duplicate INPUT rows. Three input loan rows produce
two output rows and no error; a whole file delivered twice loses every duplicate
silently. ERROR_DUPLICATE_KEY (DQ004) exists but is emitted only for the
org-hierarchy multi-parent case (engine/stages/hierarchy/graph.py:474), never
for an exposure table.
- Rule: no single article. As with the 2026-08-12 input-contract entry above,
the exposure is the input domain of every article the engine implements. The
closest named rules are the ones the fallback silently substitutes for: CRR
Art. 122 (corporate SA risk weights by CQS) for (1), and CRR Art. 111 (exposure
value) for (2), where a GBP 1m exposure is reported at GBP 0.
- Origin: (1) engine/stages/hierarchy/enrich.py; (2)
contracts/edges.py::conform_lenient; (3)
engine/stages/classify/permissions.py.
- Escape class: no-gate-exists for all three, and the word exists is doing
precise work in (1) and (3). An error code is declared for each; no producer
is. That is a recognisable relative of the four gate-not-run entries above —
the estate's habit of building the instrument and stopping before wiring it —
but it is not the same class and would not take the same fix. A constant with no
producer is not a gate that failed to run; there is nothing to move earlier. It
has to be written. What it shares with gate-not-run is the appearance of
coverage: ERROR_ORPHAN_REFERENCE in an __all__ reads, to a reviewer and to
every grep, as referential integrity that is enforced.
- Why every gate missed it: the whole estate is organised on one axis — by
regulatory rule, does Art. 123 work? — and every generator in it starts from
a valid portfolio. tests/properties/strategies.py bounds PD to
[0.0003, 0.20] and amounts to at least GBP 10k with every field populated, and
its docstring says so plainly. The oracle, the conformance table, the goldens
and the supervisory register all consume well-formed fixtures. Nothing in 1,081
test files asked what happens when the data is wrong, so a wrong answer to
that question could not be observed.
Two structural specifics are worth recording beyond that general point. First,
tests/acceptance/stress/test_stress_pipeline.py::TestRowCountPreservation is
the only place in the estate that states a count identity between input and
output rows, and it counts a clean portfolio — so (3), which is exactly a
row-count defect, was outside its reach by construction. Second, (2) is
pinned at unit level: tests/contracts/test_edge_contracts.py:368-380
(test_dtype_mismatch_cast_not_raised) asserts that an uncastable value becomes
null with missing == []. That test is
correct about conform_lenient's contract and says nothing about the
end-to-end consequence, which is a GBP 1m exposure reporting zero capital. A
test can pin a mechanism faithfully and leave its consequence unexamined.
- Gate change: tests/robustness/ — a new suite driving the FULL pipeline
(not calculate_branch) over deliberately broken inputs, asserting a triage
invariant rather than a hand-derived number so it scales to as many generated
shapes as the runner will pay for. Six generators: unit-scale errors on every
ratio column, out-of-domain numerics read off the Phase 1 ColumnSpec.domain
declarations, one nulled optional field at a time, unknown enum strings with
case and whitespace variants, sign flips / duplicate keys / orphan foreign keys,
and structural extremes up to 1M rows. tests/robustness/harness.py owns the
invariant; .github/workflows/nightly-robustness.yml runs it nightly under CRR
and Basel 3.1 as separate matrix legs, and both pyproject.toml's addopts and
ci.yml's test job exclude the robustness marker so it never enters the dev
loop.
The invariant has four clauses, not the two the proposal drafted, and the
two additions are what make it usable rather than what soften it. Clause (c)
accepts a table/column-level aggregate error, because _collect_domain_violations
names at most sample_cap=5 rows per column and summarises the rest, and DQ001
/ DQ010 name no row at all — without it the suite reports false failures on
correct behaviour, which is how a suite gets switched off. Clause (d) — the row
produced no output row and no error mentions it — is the failure, and is what
catches (1) and (3). A fifth outcome, collapsed, counts input rows as well
as references, because a duplicate reference IS present in the output and is
therefore invisible to any per-reference identity.
The join back to the input row is on source_exposure_reference, never
exposure_reference: the RE splitter, guarantee substitution and the
facility-undrawn leg all make the latter non-unique per input row, and joining
on it would report every correct split as a vanished row.
Not gated per-PR, deliberately. This is a search, not a regression check; its output is a list of shapes to triage. It is also red on arrival on exactly the three defects above, which is the deliverable rather than a fault in the workflow — a green run would mean they were fixed, not that the search found nothing. - Verified red — each defect against its own new test, before any fix, on the quiet tree:
.venv/bin/python -m pytest tests/robustness/ -m robustness -o addopts= -q
E AssertionError: an exposure whose counterparty_reference 'CP_DOES_NOT_EXIST'
matches no counterparty produced GBP 1,000,000.00 against a correct GBP
1,500,000.00 — a 33.3% understatement — and the run raised NO error at all.
DQ005 ERROR_ORPHAN_REFERENCE is declared in contracts/errors.py and emitted
nowhere in src/.
E AssertionError: an exposure with no counterparty_reference at all produced
GBP 1,000,000.00 and no error names it
E AssertionError: 1 input row(s) unaccounted for (3 input rows -> 2 output rows)
injections: ['loans.loan_reference (duplicated row)']
accumulated error codes: ['<no errors at all>']
[collapsed] loans:LN000 — 2 input rows share this reference and collapsed
to 1 output row(s); no error says so
E AssertionError: drawn_amount='1,000,000.00' could not be cast, was silently
nulled, and produced a zero-capital exposure with no error
All four assertions state what ought to be true and none pins the wrong
number, so a fix turns each one green rather than requiring the test to be
rewritten (.claude/LESSONS.md C1) — which is not merely a claim about the
tests but a measured fact about one of them, since the fourth went green under
DQ014 without being touched. The measured control values are asserted
first in each test, so a failure is unambiguously about the missing signal and
not about the risk weights having moved underneath the test.
- Defect (2) is CLOSED, by the gate rather than around it. The eight
test_cast_failures.py tests were written red against the measurement above and
handed to the concurrent Phase 1 work as an acceptance check. DQ014
ERROR_UNREADABLE_INPUT_DTYPE now reports a column supplied in a dtype whose
cast is destructive: seal_lenient returns LossyCast findings alongside
missing, the loader turns them into one error per (table, column)
(engine/loader.py:223-234), and tests/fixtures/raw_bundle.py routes them into
the bundle's error list so an in-memory bundle carries the same load-boundary
errors a production load would. All eight tests flipped green with no edit to
any of them, which is the strongest available form of this evidence: the gate
was written first, observed red, and turned green by the fix rather than by being
rewritten. Deliberately NOT routed through DQ003 ERROR_TYPE_MISMATCH, which
Phase 0 retired as unfirable, nor through DQ001 — a value that is present and
unreadable needs the feed RE-SENT where a missing column needs it EXTENDED, and
test_an_uncastable_value_is_not_reported_as_a_missing_column pins the
distinction.
- Defects (1) and (3) are now CLOSED as well, and by the same route: the four
remaining tests were turned green by the fix, with no edit to any of them.
DQ005 has a producer, DQ004 has an exposure-table producer, and both are read
off DECLARATIONS in data/schemas.py rather than hand-written per column —
TABLE_FOREIGN_KEYS (a new ForeignKey declaration alongside NumericDomain
/ EnumDomain) and TABLE_UNIQUE_KEYS, both consumed by
contracts/validation.py::validate_referential_integrity and
::validate_duplicate_keys. Three decisions in that fix are worth recording
because each was a fork where the obvious move was wrong:
The join stays how="left". The recommendation above ("emit DQ005 from
the counterparty-enrichment join by counting left-join misses") was followed in
substance and not in location. The detection sits at the INPUT gate, which runs
on both pipeline entries, because the information is strictly richer there: at
the join the miss is a null obligor attribute, indistinguishable from an
obligor row that exists and has no rating, and the reference that was supplied
— the one thing an operator needs to repair the feed — has already been
consumed. Nothing in the fix drops a row: an exposure that has left the
portfolio is worse than one priced off a fallback, because its capital is gone
and no total says so.
Null and orphan carry DIFFERENT codes, against this entry's own
recommendation that they "should carry the same code". They reach the same
engine fallback, which is exactly why the distinction has to be drawn at the
gate or not at all — downstream both are a null attribute and the information
is gone. But they are repaired in different files: an orphan needs the PARENT
feed extended or corrected (DQ005), a null needs THIS row's column populated
(DQ001, absent_reference_error, category DATA_QUALITY to keep it apart from
the seal's missing-COLUMN DQ001 under SCHEMA_VALIDATION). One code would have
sent an operator looking in the wrong file.
DQ004 is uncapped here, breaking the module's own sample_cap contract,
and deliberately. The domain gates sample a property of a COLUMN — naming any 5
of 900 out-of-domain rows locates the repair — whereas a duplicate key is a
property of a ROW, and a sampled duplicate leaves every un-sampled row exactly
as unaccounted-for as it was before the gate existed. That is also precisely
what tests/robustness/harness.py encodes by refusing to let clause (c) excuse
a collapsed row. The population is bounded by the number of DISTINCT
duplicated keys: zero on well-formed input, equal to the corruption on broken
input.
Cost of the two new materialisations, measured on a synthetic portfolio where every reference resolves and every key is unique (so both checks pay their full scan and emit nothing): 1.06% of a full pipeline run at 100k loans / 10k counterparties, 0.63% at 1M loans. Both live in the input gate, which already collects per table; no collect was added to a lazy stage.
Two fixture repairs were needed and neither loosened an assertion.
tests/unit/test_loader.py::test_scrub_and_validate_returns_empty_for_valid_data
passed pl.LazyFrame() for loans and facilities — a zero-COLUMN frame is not a
zero-ROW one, and the seal's literals broadcast it to a single phantom
all-null row, so the "valid data" bundle contained an exposure with no
obligor. It now declares a key column and is genuinely empty.
tests/contracts/test_validation.py::test_clean_bundle_raises_nothing declared
a rating for a counterparty absent from the bundle and gave its loan and
facility no obligor at all; it now names an obligor that exists. Both were
asserting that a broken bundle is silent.
- Lesson: a declared error code with no producer is negative coverage. It
reads as enforcement to every reviewer, to every grep and to every import-graph
tool, while enforcing nothing — the same shape as the 402 lines of unreachable
validators in the entry above, one level further out. Check 20
(check_guard_reachability) closed the unreachable-validator case; the
unreachable-code case is its exact analogue and is mechanically checkable in
the same way: every ERROR_* constant in contracts/errors.py should either
have a producer under src/ or be explicitly listed as reserved, as Phase 0 did
for DQ003. Two of the three defects in this entry sat behind a declared code;
the third had no code at all until DQ014 was written for it, so the check would
have flagged exactly the two that were flaggable.
That is the graduation candidate this entry files; it is not performed here
because scripts/arch_check.py was being edited by another agent in the same
tree and check 20's own entry records the same reason for the same restraint.
2026-08-17 — Two fixes for one taint finding, neither of which touched the flow the tool reported¶
- Defect:
pythonsecurity:S2083(BLOCKER) onscripts/generate_regulatory_tables.pysurvived two fixes written to close it. Commit2b1be086introducedTARGET_PATHSand removedtargets.items()as the write-loop iterator; its successor went further and bound the loop variable directly off the constant at the sink, duplicating a comparison to do so. Neither moved the finding, because the flow SonarCloud actually reports is not about the path. It is two steps, identical on both versions (line numbers frommaster/ the PR head):
source line 821 / 848: path.read_text(...) in _splice → the file CONTENT
sink line 703 / 729: path.write_text(desired, ...) → "a malicious value
can be used as argument"
_splice reads the target to preserve the hand-written prose outside the
GENERATED markers; that content becomes targets[path], then desired,
then the write's data argument. The taint is the content. Writing
file-derived content to a compile-time-constant path is not path injection,
so there was never a structural fix to find — the flow is the feature.
- Rule: Not a regulatory escape. No RWA number is affected; the script is
developer/CI codegen whose only external input is a boolean --check flag.
- Origin: the diagnosis, not the code. sonar-project.properties asserted
that "scripts/ findings are always structural" and cited this very file as
the worked example, so both fixes started from a premise the tool's own
evidence contradicts.
- Escape class: wrong-premise. The premise ("the write path is taken from
a mapping whose values were read off disk, therefore S2083") was wrong and was
faithfully implemented twice, which is exactly what the class describes. Note
that test-shared-the-assumption also fits the symptom —
test_generator_write_paths_do_not_come_from_the_rendered_mapping passed
against an unfixed finding, because it encoded the same wrong sentence — but
it prescribes re-anchoring the test, and re-anchoring a test to a false
mechanism produces a better-engineered wrong gate. The first attempt at this
entry made that mistake: it classed the escape test-shared-the-assumption
and shipped an AST gate asserting the write path is bound from the constant,
a property that is real, cheap, and irrelevant to what was flagged. The class
has to name the wrong belief, not the instrument that agreed with it.
- Why every gate missed it: only SonarCloud can see this flow, and nothing
in the loop ever read what it said. The finding arrives as a rule name plus
one line number, and both fixes were designed from that — the rule's title
("I/O function calls should not be vulnerable to path injection") points at
the path, and the flow points at the content. The full source → sink was
available the whole time and never fetched: SonarCloud uploads SARIF to GitHub
code scanning, so codeFlows is two gh api calls away and needs no
SonarCloud credentials. Local gates cannot substitute — ruff and
arch_check have no taint model, and the freshness tests measure output bytes
and were green throughout, correctly, since both refactors were
behaviour-neutral.
- Gate change: the misdirecting premise is deleted at its source. The
S6549 / S2083 note in sonar-project.properties no longer claims
scripts/ findings are always structural; it records this flow verbatim, and
carries the gh api incantation that retrieves any flow from the SARIF
without SonarCloud access. .claude/LESSONS.md gains the trap in
Trap/Why/Detect form, Detect being that command. The finding itself is
resolved as Accepted in the SonarCloud platform (issue
AaAMt-IEKije7nS9AwhB), which is the only mechanism available: taint findings
cannot be suppressed from the properties file under Automatic Analysis, as the
same note already recorded.
This is prose-tier and that is a real weakness, so the stronger form is filed
rather than hand-waved: scripts/sonar_flow.py, a helper that takes an alert
number or rule key and prints the source → sink chain, would make the
retrieval a command nobody can skip rather than a paragraph they must
remember. It is not built here because the fix for a wrong premise is to
delete the premise, and shipping a new script alongside it would put a second
unreviewed thing in the same change-set.
- Verified red: the retrieval run against the pre-fix commit
(6456d808, master) returns the true flow, contradicting the premise that
shipped in both fixes:
RULE: pythonsecurity:S2083 in scripts/generate_regulatory_tables.py
step 1: line 821 Source: a user can craft an HTTP request with malicious content
step 2: line 703 Sink: this invocation is not safe; a malicious value can be
used as argument
Line 821 on master is for line in path.read_text(encoding="utf-8") inside
_splice — the content read, not a path expression. Two minutes of this
against the original finding would have prevented both fixes; that is the
sense in which the gate is observed red.
- Lesson: a taint finding is a flow, not a line. The rule name tells you
the sink family and nothing about the source, and a sink can be reported for a
tainted argument rather than a tainted path — which inverts the whole
remedy. The tell here was misread twice as evidence: read_text sitting
unflagged beside a flagged write_text looks like proof that provenance is
the variable, when it only means the read takes no tainted argument. Fetch the
codeFlows first; every fix designed from the rule title alone in this repo
has failed.
2026-08-30 — The two reconciliation surfaces disagreed about what an exposure is, and 135 tests could not express the disagreement¶
- Defect: This estate has two reconciliation surfaces, and they answered "is
this the same exposure?" differently. The exposure-grain component
reconciliation has always collapsed a split exposure's legs onto the base
reference —
ReconciliationRunnercallsaggregate_to_key_grain(analysis/reconciliation.py:178), which runs_coalesce_to_parent(analysis/_collapse.py:73-75). The cell-grain template waterfall inanalysis/return_recon.pydid not. The grain inconsistency is the defect and the wrong number below is its symptom, and that ordering is what makes the collapse the right answer rather than merely an effective one: "is this the same exposure" is a base-grain question, and the waterfall was asking it of legs.
The symptom. Our sealed ledger splits one exposure into several legs — a
guarantee into L1__G_BANK / L1__REM, a mixed property into M1_rre /
M1_cre, a facility into an _UNDRAWN row — each stamped with the pre-split
reference, while a projected legacy extract carries the whole loan under that
original reference and no base reference at all. Keyed on exposure_reference
the two sides shared no key, so a cell where both engines agree to the penny
reported the whole loan as missing from BOTH sides at once. The four-way
additivity contract could not catch it, because two equal and opposite
population terms sum to the same 0.00 as no terms at all:
CellDecomposition.reconciles stayed true throughout.
What the fix did, stated narrowly, because the tempting sentence is wrong.
It did not surface a finding that was hidden. The delta was always the cell's
delta and reconciles was always true. What was wrong is the attribution:
on the measured differing portfolio the signed terms explained a 5,400
difference as +6,918,900 ours-only against −6,913,500 theirs-only — two
large, equal and opposite scope terms netting to the right number for the
wrong reason, sending an analyst hunting 6.9m of missing scope when the finding
is 1,800 of expected-loss difference per cell. The claim that survives someone
checking it is the narrow one: the fix deleted a fabricated scope finding
that never existed, and re-attributed a real finding from scope to valuation.
It hid nothing. No cell's delta changes anywhere.
And it traded no detection away — measured, not argued. The obvious worry
is that collapsing the key blinds the waterfall to a genuinely dropped split
leg. Three cases were measured on C 08.03 corporate row 0080 col 0090 under
both frameworks, ours = the guaranteed leg (60k) only against theirs = the
whole loan (100k): (A) an agreeing split, where nothing is wrong; (B) a leg
moved to another row; (C) a leg genuinely dropped, which is a real scope
failure. After the fix B and C are byte-identical at the cell (measurement
−40,000, one key, reconciles true). Under the old keying B and C were also
byte-identical — and case A raised the same alarm, population_ours_only
100,000 against population_theirs_only −100,000. The old population term
fired on every split exposure in the book whether or not anything was lost, so
it had zero discriminating power for a dropped leg: it did not detect case C,
it drowned it. Discriminating power went from one signal across three cases to
two — silent on A, breaking on B and C. The closing argument: the only book in
which the old alarm carried information is one with no split exposures at all,
and in that book case C cannot arise, because there is no split leg to drop.
Case C is caught elsewhere and already shipping — post-collapse the base exists
on both sides, so it lands in the component reconciliation's break as a
40,000 value break on a named exposure. What separates "moved" from "dropped"
in the waterfall is sheet-wide non-conservation of the terms, and nothing
presents that to an analyst as such; that residual is pre-existing, is not
introduced here, and is filed rather than closed.
Not a corner case: 21 of 128 bases in the fixture estate hold more than one
leg, carrying 13.9% of RWA.
- Rule: Not a regulatory escape. No RWA figure and no published cell moves.
What was wrong is the explanation attached to a difference between two
returns — which is the evidence a migrating firm uses to decide whether its
parallel run ties out, and which of the two engines to go and look at.
- Origin: src/rwa_calc/analysis/return_recon.py, shipped in v0.3.28
(2026-08-29) with the four-way waterfall. The defect is as old as the feature.
- Escape class: path-never-exercised. The gate ran — 135 tests across
tests/unit/analysis/test_return_recon.py and
tests/unit/ui/test_views_return_recon.py, exercising this exact code — and no
fixture reached the defect, because every leg in both suites set
source_exposure_reference == exposure_reference. A split leg could not be
expressed in the fixture vocabulary, so no assertion about one could be
written, right or wrong. The class's prescribed fix is "build the portfolio,
register it", and that is what landed.
- Why every gate missed it: three independent reasons, and only the first is
the escape class.
The fixtures could not express the input. Every leg carried its own reference as its base reference, which is the one shape in which the buggy key and the correct key agree.
The output contract was satisfied by the wrong answer. reconciles scores the
four terms against the reported delta, and it is exact — but it is a
statement about a sum, and the defect's signature is two equal and opposite
terms. Every additivity assertion in the suite passed on the defective output,
correctly. An identity that a defect satisfies is not a weak identity; it is an
identity about the wrong quantity.
The one hazard adjacent to this fix announced itself at runtime for the
feature's whole life and nothing asserted on it: row_migration logs a
WARNING saying "the first is used and the matrix may be wrong". That is the
_group_legs collapse hazard, and it was carried in prose, and in a log line,
and in no test. A log line is not a gate.
- Gate change: four, all in this change-set.
- Split-leg portfolios, built and asserted —
tests/unit/analysis/test_return_recon.pyandtests/unit/ui/test_views_return_recon.py, 135 → 163 tests (c898d950). Split exposures on the IRB C 08.03 path and on the standardised C 07.00 path (test_a_standardised_re_split_pairs_against_the_legacy_whole_loanand three siblings — the real-estate and facility splits, which are the commonest split shapes in a migration book and which no earlier fixture reached, plus the first split-leg coverage ofsheet_placement); bothKEY_COLUMNSsettings (test_both_key_column_settings_name_the_same_grain); the plan-frame presence contract (test_every_recon_template_plan_frame_carries_the_base_reference); andtest_the_migration_matrix_conserves_a_split_exposures_money, a conservation detector for the_group_legshazard, which previously had none. - The mutation evidence made durable —
tests/mutations/(909e69cb): five isolating pytest plugins that each change exactly one thing in production code and restore it in afinally, plus a README carrying the measured red set of each. They lived in a job scratch directory and would have vanished with the session; this file's discipline closes a defect on evidence a gate was observed red, so that evidence has to outlive the run that produced it. - Fixture adequacy asserted inside the test — both assertions open
test_the_migration_matrix_conserves_a_split_exposures_money, and are greppable by their messages rather than by position (line numbers as atc898d950, wheregit showwill still find them once the file moves):bases.count(...) == 2attest_return_recon.py:1528— "the group holds no split exposure — collapsing the key would be a no-op and this test would prove nothing" — and_SPLIT_G_LEG.ead != _SPLIT_REM_LEG.eadat:1532— "equal legs make.first()undetectable". The pre-existing_combinedfixture fails the first of those, which is precisely why its sibling test was vacuous for the life of the feature. This is the batch's real graduation: a test that states the property its own fixture must have cannot silently become a no-op. - The drill-through's own suite —
tests/unit/ui/test_views_recon_placement.py(513937ef,d1538f0b), 348 → 355 tests, with six further isolating mutations each reddening exactly its own detector.
What these fixtures do not cover, said here rather than left to be
discovered. The decomposable-cell census taken over the projected legacy
mapping yields 1,820 decomposable cells on C 07.00 and none at all on
C 08.01 or C 08.03 — the mapping is too thin to make either template
decomposable on that run. So any sentence of the form "measured across all
three templates" is false of the census: it is a C 07.00 measurement. The new
fixtures do reach C 08.01 and C 08.03, by construction (5,400 of expected-loss
difference on C 08.01, 843,600 of row placement on C 08.03) — which is a
different and narrower kind of evidence, hand-built cells rather than a census.
- Verified red: the pre-fix keying, restored as an isolating mutation —
mutate_prefix_key swaps _comparison_key back to pl.col(key_column) and
restores it in a finally, so nothing on disk is modified while it runs. It
ships, and it reproduces against the finished 163-test baseline at c898d950:
PYTHONPATH=tests/mutations uv run pytest \
tests/unit/analysis/test_return_recon.py tests/unit/ui/test_views_return_recon.py \
-q -p mutate_prefix_key
22 failed, 141 passed
population_ours_only 100000.0 where 0.0 expected
measurement 0.0 where -30000.0 / -40000.0 expected
Those 22 are every split test plus both key_column guards, and they are the
measurement of the gate gap: on the pre-fix tree the same code produced no
failures at all, because no fixture could express a split leg. The four sibling
probes, from the same committed table — mutate_drop_base_ref 24 red,
mutate_no_third_rung 4, mutate_no_presence_filter 2,
mutate_collapse_group_legs 2.
An earlier red was taken during implementation, against a mid-tree at 145 tests that was never committed. It is deliberately not quoted here: nobody can ever check it, and a figure no one can check does not belong in this field.
The last two are the ones this entry turns on, because before their guards existed both mutations were completely silent.
mutate_no_presence_filterremoves the presence filter from_key_rungs. That filter is on the hot production path — the projected legacy plan frame has nosource_exposure_referencecolumn at all — so removing it raisesColumnNotFoundErroron every real reconciliation, and the suite was blind to it because every fixture pinned the column intoschema_overridesas a typed null. Null and absent are different code paths, and both occur on the same side at once.mutate_collapse_group_legsis the "tidy up the two inconsistent key expressions" change the module now forbids in prose._group_legsprices with.first(), so collapsing distinct split legs onto one base key keeps one leg's money and discards the other's: 40,000 ofrwa_finaland 400,000 ofead_finalagainst the conservation invariantrow_migration's own docstring states. Reproduced on two portfolios with different totals but identical losses to the penny, which is what shows the loss is one specific leg rather than something proportional to portfolio size.
Two caveats belong in this field rather than in a footnote. First,
c898d950's commit message lists six mutations and gives the pre-fix keying
as 20 red; the committed README lists five plugins and gives 22. Two of the
six — a reversed coalesce, and a break of the _key_money / _side_keys
lockstep — were not preserved as plugins, so they are not reproducible and
should not be quoted. Where the two disagree, the README is the durable artifact
and its figures are the ones to cite. Second, the discrepancy was not
re-measured for this entry: analysis/return_recon.py was under concurrent edit
in the same worktree while it was written, and running a mutation probe against
a mid-edit file is one of the four false-green mechanisms recorded below
(.claude/LESSONS.md C12).
What a later reader can reproduce, and what they can only read — because this
entry had to be made self-contained before it could close anything. Every
field that closes the defect is reproducible from the repository alone: the
escape class (check out 358e4ce2; the two pre-fix suites hold 135 tests in
which every leg sets source_exposure_reference == exposure_reference), the
four gate changes (all committed files, with the two adequacy assertions pinned
to c898d950), and the verified red (five plugins that ship, a baseline that is
a commit, the invocation printed above). Nothing in that set needs anything
outside git.
The supporting measurements — the three-case A/B/C refutation, the
+6,918,900 / −6,913,500 attribution terms and the 5,400 they concealed, the
843,600 of row placement, the 1,820-cell C 07.00 census, and the two-portfolio
reproduction of the 40,000 / 400,000 — are stated in full in this entry's own
prose above, and that is deliberate. Their working record was batch state
under .claude/state/, which .gitignore excludes wholesale, and the archive
path that convention names sits inside the ignored directory, so none of it
reaches the repository and all of it dies with the worktree. They are therefore
recorded findings rather than figures anyone can re-derive, and this entry is
their only durable home. Do not add a citation pointing at batch state to
"support" them; there will be nothing on the other end.
- The same escape, one level out, in the code this batch wrote. The
drill-through built on top of this fix (513937ef) shipped with five defects
its author found by reviewing its own new code, each reproduced before being
fixed, and all 340 existing tests passed against two of them — which is the
finding, not the fix. A composite reconciliation key was token-matched segment
by segment, so a segment coinciding with another exposure's reference merged
that exposure's rows in, fabricating a row the loan never reached and
destroying a real band move by adding a second provable leaf. A || inside a
legitimate reference under a single-column mapping resolved half a reference to
a whole loan, silently. A scheme-relative Referer (//evil.example/...)
skipped the same-origin test entirely — an empty scheme made the guard skip
itself — and a malformed one raised and 500'd the page. The tri-state
parent-row flag was flattened at the render boundary, so a row False on ours
and None on theirs claimed "provably contains and duplicates no other row"
for both sides. And the single-leaf rule was unasserted: C 08.01 rows 0020 and
0070 are different cuts of one book rather than a tree, so an exposure can
reach two provable leaves — under the mutation each side picks its leaf from
unguaranteed Polars row order, the two can differ by chance, and the panel
renders a fabricated band move on a byte-identical exposure. A sixth followed
in d1538f0b: a key that cannot be read was rendering as "this exposure
reached no instrumented row", which is a different and false claim. Four of the
six are one shape — two distinct facts collapsing into one blank — which is the
shape of the defect this whole batch exists to fix.
- Lesson: four entries added to .claude/LESSONS.md — B9 (a log line is
not a gate, and neither is an alarm that always fires), C10 (careless about
scope, not about facts), C11 (a fixture is a claim: assert its adequacy and
check its label against its cause) and C12 (four ways a green mutation probe
lies) — plus a fold into B1 for the null-versus-absent mirror image. C11 and
C12 are the two closest to graduating: C11 already has an executable form in a
single test, and C12's second, third and fourth mechanisms are all mechanically
checkable from a shared plugin base in tests/mutations/. Both are filed in the
ledger's candidates list.
2026-09-05 — Basel 3.1 C 07.00 deducts on-balance-sheet netting twice, and no registered portfolio had a netting agreement¶
- Defect: on the Basel 3.1 OF 07.00 template the netted deposit is deducted
once in column 0035 "(-) Adjustment due to on-balance sheet netting" (so column
0040 is already net of it) and again inside column 0130 "(-) Financial
collateral: adjusted value", because CRR Art. 219 turns the netted deposit into
synthetic cash collateral that the CRM stage merges into the ordinary
collateral frame, and
reporting/corep/c07.pysums the wholecollateral_adjusted_valuecarrier into 0130. Column 0150 (fully adjusted exposure value) is therefore understated by the netting amount while column 0200 (exposure value, fromead_final) is correct. Measured on the newnettingportfolio (five unrated corporates, all drawn, GBP): col 0040 19,000,000, col 0130 −3,000,000, col 0150 16,000,000, col 0200 19,000,000. Under CRR the template has no column 0035, so the chain nets once and ties. The defect is pre-existing and independent of PR #487's perimeter change: with the Feature disabled (only the same-counterparty agreement nets) the same sheet reads col 0150 20,000,000 against col 0200 21,000,000. - Rule:
boe_b0471(ERROR — "{c0200} = {c0150} − 0.9·{c0160} − 0.8·{c0170} − 0.6·{c0171} − 0.5·{c0180}", the end-exposure-value derivation) andboe_b0556(WARNING — "{c0200} ≤ {c0150}"), both live on OF 07.00.01.01;boe_b0555(an OF 07.00 collateral/exposure-value relation) left the vacuity population on the same run and now asserts. - Origin:
src/rwa_calc/reporting/corep/c07.py— col 0035 was added underif is_b31asSum("on_bs_netting_amount")while col 0130 kept summing the undifferentiatedcollateral_adjusted_value. The carrier that would separate them — the post-haircut, post-mismatch adjusted value of theNETTING_synthetic collateral per beneficiary — does not exist on the sealed ledger;on_bs_netting_amountis the pre-haircut pro-rata allocation, which coincides with it only for same-currency, maturity-matched deposits. - Escape class:
path-never-exercised.boe_b0471is a live ERROR rule and the register ran on every commit, but no portfolio inRUNScarried a netting agreement at all — the template-cell census had classifiedcorep/c07_00/0035asNO_FIXTURE("no fixture supplies a netting agreement") for the template's whole life, so the rule was evaluated over sheets on which 0035 was structurally null and the double deduction summed to zero. Only three fixture builders in the estate set anetting_agreement_reference(P1.238, P1.241,r1_negative_gross), none of them a reporting portfolio. - Why nothing else would have caught it: the unit tests for C 07.00 build
their frames from the sealed carrier names and never populate
on_bs_netting_amountandcollateral_adjusted_valueon the same row; the golden portfolios have no deposits; the P1.238/P1.241 acceptance twins assert RWA, not template cells; and the engine's own EAD path is correct (it nets once), so no engine-level test can see a reporting-layer double count. - Gate change:
tests/fixtures/reporting_netting_portfolio.pyregistered inRUNS(two runs,crr/b31×netting) and captured as goldens undertests/expected_outputs/reporting/netting_{crr,b31}/, pinned bytests/acceptance/reporting/test_reporting_netting_golden.py(per-leg netting, C 07.00 rows 0010/0070, the Basel 3.1-only col 0035, the CRR absence of it, the single CRM016 record, and a two-limbed Feature test). Landed in PR #487. The two breaks are banked invalidation_known_breaks.jsonwith this mechanism as their written reason, so the register shrinks by two the day the fix lands. Code fix deferred, design recorded here: seal a per-exposureon_bs_netting_adjusted_value(the adjusted value of theNETTING_collateral rows after Art. 223 haircuts and Art. 237-239 mismatch scaling) from the CRM stage throughcontracts/edges.pyand the re-split carriers; under Basel 3.1 report it in col 0035 and subtract it from col 0130, so 0150 = 0200 for an all-drawn book in every currency case; leave CRR untouched (no 0035).C 08.01col 0035 sits beside the LGD-collateral columns 0170-0210 and needs the same review. - Verified red:
uv run pytest tests/acceptance/reporting/test_supervisory_validations.py -n 4 -qon the unchanged reporting code with the two netting runs registered —2 failed, 6 passed:b31/boe_b0471 [ERROR] left = 19,000,000.0000 vs right = 16,000,000.0000 on 2 cell(s)atOF07.00.01.01[corporate][r0010]and[r0230], andb31/boe_b0556 [WARNING] left = 19,000,000.0000 vs right = 16,000,000.0000 on 3 cell(s). The golden test's own cell pins (col 0200 == 19,000,000) pass on the same run, which is the point: the exposure value is right and the intermediate column is wrong, and only the published identity between them sees it. - Lesson: LESSONS B5 in its plainest form — the column was dead, the census
said so, and the ERROR rule over it was green for the life of the template.
The transferable rule is already in the file: a
NO_FIXTUREclassification in the template-cell baseline is a list of gates that are not running, and the change that lights one should expect the register to move. - Fix landed (2026-11-13): the deferred design, as recorded. The CRM stage
seals
on_bs_netting_adjusted_value— the netted deposit's value after the Art. 224 currency and Art. 237–239 maturity adjustments, the netting part ofcollateral_adjusted_value(engine/crm/collateral.py, flagged byengine/crm/expressions.py::flag_netting_rows) — throughcontracts/edges.py, the schemas and the re-split carriers. Under Basel 3.1, OF 07.00 col 0035 reports it (capped per row at the exposure net of provisions, since Art. 219(1) floors the netted value at zero) and cols 0130 / 0140 leave the deposit out. CRR is unchanged. No RWA, EAD or risk weight moved in any of the registered runs. Two things the record did not foresee:on_bs_netting_amountwas missing from the guarantee row-split carriers, so a partly guaranteed netted loan carried the whole netting on both legs (300 became 600); and under the Simple Method the new carrier is zeroed for SA with the collateral value it is part of. - Gate change (fix): the rule itself is now an assertion —
tests/acceptance/reporting/test_of07_netting_single_deduction.pyholds col 0200 = col 0150 − (0.9·0160 + 0.8·0170 + 0.6·0171 + 0.5·0180) and col 0200 ≤ col 0150 on every reported row, non-vacuously (col 0035 must carry a figure). The registered netting portfolio is same-currency and maturity-matched, so it cannot tell the adjusted value from the allocation;tests/fixtures/reporting_netting_mismatch_portfolio.pycan, and is registered inRUNS. Without it the fix would have leftboe_b0555(col 0130 ≤ col 0140) vacuous on every run — col 0130 was non-zero under Basel 3.1 only through the double count — and the coverage ratchet measured that as Basel 3.1 binding rules 365 → 364. - Verified red (fix): against the unchanged reporting code,
uv run pytest tests/acceptance/reporting/test_of07_netting_single_deduction.py -q -n 0—10 failed, 4 passed(the four passing are the CRR controls, which must pass on both sides):b31 corporate r0010: c0200 19,000,000.00 != c0150 16,000,000.00andassert -300000.0 == -173626.57156237616(col 0035 carried the allocation, not the adjusted value). The carrier's unit tests:23 failed(KeyError: 'on_bs_netting_adjusted_value'; the split legassert 600.0 == 300.0). After: all pass.boe_b0471andboe_b0556leave the register's known breaks;boe_b04711 → 0 portfolios on the filing ratchet. - Found while fixing, not fixed (capital-affecting; for the firm to sequence): the netting FX haircut is keyed on the wrong currency once FX conversion has run (a EUR deposit against a GBP loan gets no haircut — EAD 700 where 733.94 is due on a 300 / 1,000 pair, understating capital); and the engine scales the haircut to a 20-day liquidation period where PS1/26 Art. 219(2) says "The institution shall apply a 10 business day liquidation period" (overstating it). Both closed by the 2026-11-13 netting currency entry below (plan P1.382 / P1.383, PR #521). The figure due is not 733.94 once both land: Basel 3.1 gives EAD 724 (300 × 0.92 at 10 days). Under CRR the pair is not netted at all (EAD 1,000), because CRR Art. 219 recognises same-currency loans and deposits only. The defect was also wider than noted here: with any collateral file in the bundle, no netted deposit was haircut, whatever its currency.
2026-09-05 — A window nested inside a window made the classifier eleven times slower, and the one instrument that measured it asserted nothing¶
- Defect: commit
8ec7d302(P1.320, "count each facility limit once in the QRRE obligor aggregate", authored 2026-08-15) rewroteengine/classify/subtypes.py::qrre_obligor_aggregate_limit_exprso that acum_sum().over([counterparty_reference, parent_facility_reference])ordinal and amax().over([...same keys])group limit sit inside the input ofdeduped_limit.sum().over("counterparty_reference"). Polars evaluates a window's input inside the outer group-by context, so both inner windows re-run once per obligor group: per-row cost stops being a function of row count and becomes a function of row count times group count. It first shipped in v0.3.27 on 2026-08-28 and was present through v0.3.32.
Measured 2026-09-04, same machine, back to back, CreditRiskCalc.calculate()
on the repository's 100k-counterparty synthetic book (373,568 result rows, CRR
standardised):
| v0.3.26 | v0.3.32 | |
|---|---|---|
| classifier stage | 495 ms | 5,640 ms |
| total run | 11.8 s | 18.6 s |
With only that one function reverted, v0.3.32 measured 9.4-11.3 s across
three runs against 9.5-11.8 s for v0.3.26, so the function accounts for the
whole regression and nothing else in the release range does. The expression
alone, in one with_columns at 800k legs: 46 ms in the v0.3.26 form
against 45,851 ms in the shipped form, growing roughly 4x per row
doubling. And the decisive control — each window alone costs ≤151 ms at
400k rows, so neither window is expensive and only the nesting is. A user
reported a real book going from under one minute to over three; the measured
curve predicts that at roughly 1.7M legs, which is a prediction about their
shape rather than a measurement on their data, and is recorded here as such.
- Rule: Not a regulatory escape. No RWA figure moves, in either regime,
on any portfolio. The P1.320 rewrite was regulatorily correct — CRR
Art. 154(4)(c) caps the aggregate nominal exposure to a single individual, so a
facility's limit must be counted once however many legs it carries — and the
fix below preserves it exactly. What escaped is cost, not capital.
- Origin: src/rwa_calc/engine/classify/subtypes.py, commit 8ec7d302,
2026-08-15. Released 2026-08-28 in v0.3.27 and live for five releases.
- Escape class: no-gate-exists. The instrument existed and the assertion
did not: the CI benchmarks job ran test_classifier_100k on every push from
the day the defect landed, recorded the 11x stage regression every time, and
uploaded it — so gate-not-run is the wrong label, because the job did run
and simply had no failure condition to reach.
- Why every gate missed it: three independent reasons, none of them a weak
assertion.
Nothing in the estate is big enough for the defect to be visible. Every fixture and golden portfolio is under 40k rows, where the penalty is about 60 ms — comfortably inside the noise of a test run. The defect's signature is a curve, and a single-point measurement cannot carry one.
The tests that cover this function pin behaviour, not cost. The P1.320 unit and acceptance tests assert the aggregate limit is right, and it is right; they pass identically on both forms of the expression, before and after. A correctness gate cannot fail on a performance defect however thorough it is, which is why the gate change below is a scaling assertion rather than more coverage of the same property.
The benchmark job produces a number and compares it to nothing.
.github/workflows/ci.yml's benchmarks job runs tests/benchmarks under
-m 'benchmark and not slow' and uploads benchmark-results.json as an
artifact. There is no baseline, no ratchet and no threshold, so the job cannot
fail. The 11x classifier regression was therefore recorded on every run from
2026-08-15 onwards and read by nobody. And the marker is deselected from both
places a developer would otherwise meet it — pyproject.toml's addopts for
the dev loop, and CI's own test job — so the only path to the number was
downloading an artifact from a green build. This is the estate's standing habit
in its purest form: build the measurement, ship it, wire it to nothing.
- Gate change: two, both in this change-set, and they close different halves
— one measures the cost, one forbids the shape.
tests/unit/classifier/test_p1_320_qrre_aggregate_scaling.py— drivesclassify_exposure_subtypesat 100k and 400k synthetic legs in the default dev loop (no marker, so it is not deselected anywhere) and asserts the 4x frame costs less than 8x the small one and under 3 s in absolute terms. The ratio is the assertion that matches the defect's shape; the absolute budget stops a uniformly slow machine passing a quadratic curve. ItsTestTheMeasuredPathIsLiveclass carries the adequacy assertions — the window keys are non-degenerate (multi-leg obligors, multi-facility obligors, and both null slices present), and the QRRE limb both fires and discriminates at each size, anchored toExposureClassrather than to a hand-written list — so the file cannot silently degrade into timing a dead path. Those assertions hold on the pre-change engine too, by design: they are the premise of the timing, not part of it.scripts/arch_check.pycheck 21 —check_no_nested_window_expressions— an AST scan ofengine/that fails any.over()whose input contains another.over(). It follows local-name bindings within one function body, because the shipped defect bound the nested expression to a local first and a scan of the call chain alone would not have seen it; each name resolves to the last binding that ends strictly before the outer window's own line, so a self-rebinding statement cannot make a window find itself. Only the input is scanned, not the partition arguments, since the input is what Polars re-evaluates per group. No allowlist. It is contract-tested bytests/contracts/test_nested_window_gate.py, which pins the check's registration in thearch_checkrun, the two flagged shapes (direct nesting and nesting through a local), the clean two-step remedy, and — the reason the source-order rule exists at all — the real false-positive shape inengine/supporting_factors.py, whose single legitimate window sits in a statement that rebinds the frame name and which a source-order-blind resolver flags as nested against itself.- Verified red: taken on this worktree at
cb59e53cwith the two new test files present and before the engine rewrite, so both gates are observed failing against the code that actually shipped.
The scaling test, 2 failed, 4 passed in 19.94s — the ratio limb and the
absolute limb, from the same pair of measurements:
test_classifier_cost_scales_linearly_in_row_count
assert 18.3 < 8.0
(100,000 rows: 0.281s -> 400,000 rows: 5.129s)
test_classifier_stays_within_the_absolute_budget_at_scale
assert 5.129 < 3.0
The contract test was 10 failed in 7.96s before check 21 existed, which is
the trivial red. The one that matters came next: with the check implemented and
the engine still on the shipped expression, it named exactly one violation in
the whole engine tree —
src\rwa_calc\engine\classify\subtypes.py:374: nested Polars window -- this .over()'s
input contains another .over(), which Polars re-evaluates once per outer group.
Compute the inner result as its own column in a preceding with_columns and read it
back with pl.col()
— with the contract suite at 1 failed, 9 passed, the single failure being
test_engine_has_no_nested_window_expressions. A check that finds one instance
and no others across the engine tree is the useful outcome: it is neither
vacuous nor a false-positive generator, and the one shape that could have made
it the latter is pinned as a test.
- The fix, stated narrowly: the same expression tree, split across two
with_columns. The per-leg deduplicated contribution is materialised as the
scratch column _qrre_deduped_limit, the obligor sum reads it back with
pl.col(), and the helper is dropped before the stage returns, so the classify
exit schema is unchanged. After the rewrite the same measurement gives
0.095 s at 100k rows and 0.382 s at 400k, a ratio of 4.02x against a 4x row
increase. The aggregate is bit-identical to the shipped form on a 400k-leg
frame — 0 mismatches, 20,581 QRRE rows on both sides — and the P1.320 unit and
acceptance tests pass unchanged. Both @cites("CRR Art. 154(4)") and
@cites("PS1/26, paragraph 147") are retained, and the function keeps its
name so tests/contracts/data/citation_snapshot.json does not move.
- Lesson: graduated on the first occurrence, so there is no prose entry.
The transferable rule — a nested Polars window is quadratic in group count,
and no correctness gate can see it — is mechanically checkable from the AST,
which is the strongest form available, so it lands as check 21 with a row in
the .claude/LESSONS.md Graduation ledger rather than as a Trap / Why /
Detect entry that would have to recur before earning a check. The residual
worth naming, because check 21 does not cover it: the benchmark job still
compares against nothing. Check 21 forbids one known-quadratic shape and the
scaling test guards one stage; neither would catch a different construct
slowing a different stage by the same order. Ratcheting benchmark-results.json
against a stored baseline is the general form, and it is not built here.
2026-09-05 — A matched short-dated interbank pair lost its whole netting benefit to a mismatch that did not exist¶
- Defect: an F-IRB loan to an institution, fully offset by a negative-balance
deposit under one on-balance-sheet netting agreement, in the same currency and
with the SAME maturity date, reported LGD 45% and full RWA.
on_bs_netting_amountwas populated (the pair pooled) andtotal_collateral_for_lgdwas 0 (the syntheticNETTING_cash row was zeroed). Reported by a user; confirmed by the operator on 2026-09-05: the shared maturity was under 91 days from the reporting date. Measured on an F-IRB institution obligor under CRR, 1m loan and 1m deposit: matched at 6 months and 5 years gives LGD 0.00 and RWA 0; matched at 91, 89, 30 and 7 days, and one day before the reporting date, gives LGD 0.45 and RWA 776,751. Basel 3.1 identical. Direct collateral with a matched short residual fails the same way (a 0.1-year cash deposit against a one-month loan). - Rule: CRR Art. 237(1) — "a maturity mismatch occurs when the residual maturity of the credit protection is less than that of the protected exposure. Where protection has a residual maturity of less than three months and the maturity of the protection is less than the maturity of the underlying exposure that protection does not qualify" (crr.pdf p.232); Art. 238(1) — "Subject to a maximum of five years, the effective maturity of the underlying shall be the longest possible remaining time" — a cap, no floor. PS1/26 Art. 219(3) routes netting through Art. 237-239 unchanged and Art. 219(2) prescribes the treatment for the currency case, so the regime carry-forward is word-for-word on the point that matters.
- Origin:
engine/crm/haircuts.py::apply_maturity_mismatchderived the exposure residual as.clip(lower_bound=0.25, upper_bound=5.0)and then askedcoll_maturity < _exposure_maturity_years. The collateral residual was not floored, so any matched pair under 0.25 years (91 days on the /365.25 basis) compared as protection-shorter-than-exposure, entered the gate chain, and hit the< 0.25three-month zero. A past-dated pair has a negative residual on both sides and fails the same comparison. The floor was there to keep the scaling denominatorT − 0.25positive, but the scaling branch is reached only witht >= 0.25andt < T, where the denominator is positive on its own. The guarantee twin (engine/crm/guarantees.py::_apply_maturity_mismatch_to_guarantees, P1.232) had already been rewritten to compare raw residuals and carries a comment recording that the collateral twin still floored — the divergence was known and never closed. - Escape class:
path-never-exercised. The estate's netting fixtures (P1.238, P1.241,reporting_netting_portfolio,r1_negative_gross) all carry deposits maturing months or years out; the P1.241 "matched" control is a six-year deposit against a five-year loan. No fixture anywhere had a matched pair inside three months, which is the ordinary tenor of interbank money. The one unit test that mentioned the floor,test_exposure_maturity_floored_at_0_25, covered only collateral LONGER than a one-month exposure (factor 1.0 either way), so it documented the clip without ever exercising the matched limb. - Why nothing else would have caught it: the treatment was silent —
ERROR_MATURITY_MISMATCH(CRM002) was declared incontracts/errors.pyand produced nowhere, so a zeroed deposit left no record; the supervisory validation register cannot see LGD* on an F-IRB row that never reaches a registered portfolio; and thelgdexport column carries the unsecured supervisory LGD on every F-IRB row, so the number the user read (0.45) was the same whether the collateral had been applied or not — onlylgd_flooredand the RWA told the two cases apart. - Gate change: (1)
tests/unit/crm/test_maturity_mismatch.py::TestMatchedAndShortDatedProtection— matched pairs at 7/30/60/89/91 days, a past-dated pair, a matched pair with a short original term, a genuine sub-three-month mismatch (still zeroed), a just-over-three-months mismatch (scales, denominator positive without a floor), and the Basel 3.1 twin; the pinning test retitled totest_collateral_outliving_a_one_month_exposure_keeps_full_value. (2)tests/acceptance/{crr,basel31}/test_art237_matched_short_dated_netting_firb.pyon the new in-memorytests/fixtures/matched_short_netting/builder — the user's shape exactly: F-IRB institution, same currency, same maturity, negative balance deposit — assertinglgd_floored == 0and RWA 0 at 7/60/89 days and past-dated, a six-month control, and a real 30-day-vs-2-year mismatch that must stay zeroed AND now raise CRM002. (3) P1.241 gainsmatched_shortandmatched_pastscenarios in both regimes with the hand-calc corrected (no floor on T). (4)engine/crm/haircuts.py::_record_maturity_mismatch_adjustmentsproduces CRM002 as one rolled-up count per run (zeroed and scaled rows), pinned bytests/unit/crm/test_crm002_maturity_zeroed_warning.py. Deferred to P1.367: a registeredRUNSinterbank netting portfolio so Tier 2 and the template-cell census see the treatment. - Verified red:
uv run pytest tests/unit/crm/test_maturity_mismatch.py -n 0 -qon the unchanged engine —8 failed, 13 passed, every new matched caseassert 0.0 == 1.0 ± 1.0e-06onmaturity_adjustment_factor; anduv run pytest tests/acceptance/crr/test_art237_matched_short_dated_netting_firb.py -n 0 -q—5 failed, 2 passed:matched_7d,matched_60d,matched_89dandmatched_pasteachassert 0.0 == 1000000.0ontotal_collateral_for_lgd, and the mismatch controlassert Falseon CRM002 presence. The six-month control and the no-warning test passed on the same run, which localises the defect to the sub-three-month window. - Lesson: the rule's own words are the assertion. "Less than" is a strict comparison on the residuals as they are; a floor applied to one side of it for an arithmetic convenience elsewhere changed the rule's meaning for an entire tenor bucket, and the twin that had been corrected said so in a comment nobody acted on. LESSONS C10's question — "which call site did I measure this on, and is there a second one?" — applies to a comment that names its sibling's divergence: a known divergence between twins is a plan bullet, not a comment. Second, the silence: a treatment that can remove 100% of a protection's value must say so; declaring an error code and producing it nowhere is the shape LESSONS B9 warns about, and the 2026-08-12 entry names two more codes in the same state.
2026-09-05 — A BLOCKER taint finding was recorded as accepted, was not accepted, and sat open on master for three weeks¶
- Defect:
pythonsecurity:S2083(BLOCKER) onscripts/generate_regulatory_tables.py:703— the single open code-scanning alert onmaster(GitHub alert 35), raised 2026-08-16 and still open on 2026-09-05. The 2026-08-17 entry above closed this finding by recording it as "resolved as Accepted in the SonarCloud platform (issueAaAMt-IEKije7nS9AwhB)". It was not.masterreports the issue under a different key entirely, and it has never been resolved:
AZ__l2AI-nu7-4qGDJNX BLOCKER OPEN scripts/generate_regulatory_tables.py:703
AZ8Ke_9KFFhzEQA0N41T BLOCKER ACCEPTED src/rwa_calc/ui/app/recon_signoff.py:244
The second row is the control: an accept in this project does land, and does
show as ACCEPTED/WONTFIX. The key named in the record is on neither list,
so the accept was applied to something else — most likely a branch-scoped
duplicate on the PR — while the issue on master was never touched.
- Rule: Not a regulatory escape. No RWA number is affected; the script is
developer/CI codegen whose only external input is a boolean --check flag.
- Origin: the closure, not the code. The generator is byte-for-byte the
version the 2026-08-17 entry analysed, and that analysis was correct — the
flow really does run from _splice's content read to the write's data
argument, re-fetched here from today's SARIF and unchanged. What failed was
the remedy: a platform action with no artefact in this repository was
recorded as done, in a commit message, a properties note and a test
docstring, and nothing anywhere could disagree with it.
- Escape class: caught-and-parked. The gate fired and kept firing; the
record of the finding became its resting place. It is the class whose fix
targets the register of tolerated findings rather than the output, and the
register here was three pieces of prose asserting an accept that no one had
checked. no-gate-exists is the near miss and is wrong: SonarCloud caught
this on the day it was introduced and has reported it on every analysis of
master since.
- Why every gate missed it: nothing in the repository can observe a platform
accept, so "accepted" was unfalsifiable prose. Local gates cannot substitute —
ruff and arch_check have no taint model, and the freshness tests measure
output bytes and were correctly green throughout. CI is also no help by
design: SonarCloud's finding surfaces as a GitHub code-scanning alert, not
as a failing job, so master CI has been green for three weeks with a BLOCKER
alert open on it. The alert was found by a human reading the security tab.
- Gate change: the finding is fixed structurally rather than accepted, and
the property is gated executably.
The 2026-08-17 entry concluded "there was never a structural fix to find —
the flow is the feature", and stopped one step short of its own lesson. The
flow is indeed the feature: _splice must read each target to preserve the
hand-written prose outside the GENERATED markers, and the script must write
the result back, so the content is file-derived and cannot stop being so. But
that entry had already named the mechanism — "a sink can be reported for a
tainted argument rather than a tainted path" — and the remedy follows
from it: the content does not have to be an argument to a call that also
takes a path. main() now opens the target and writes to the stream, so
the path-taking call carries only the constant-derived path and a literal
mode:
tests/contracts/test_docs_freshness.py::test_generator_keeps_spliced_content_out_of_a_path_taking_call
parses the generator and fails on any write_text / write_bytes call, so
the shape cannot come back. The S6549 / S2083 note in
sonar-project.properties records the remedy, drops the false claim, and now
carries the one-line command that makes any future accept falsifiable:
An accept remains legitimate where the path genuinely is the trust root
(recon_signoff.py above). What is no longer legitimate is recording one
without verifying it landed.
- Verified red: the new gate run against the pre-fix generator restored
from master (45f5b315) fails on the flagged line itself —
AssertionError: scripts/generate_regulatory_tables.py hands its rendered
content to a path-taking write call:
line 703: .write_text(...)
— and passes on the fix, with tests/contracts/test_docs_freshness.py
6 passed. The closure claim is independently red too: the anonymous
SonarCloud query above (no credentials needed) returns OPEN for the
generator's issue against a record that said Accepted, and
gh api .../code-scanning/alerts/35 --jq .state returns open with
dismissed_at: null.
- Lesson: a remedy that leaves no artefact in the repository is not closed
until something outside the repository has been asked. The closing rule
already says a defect is closed by its escape-log entry rather than its fix
commit — this entry is the case where the escape-log entry itself was the
resting place, because its named gate change was an action in another system
that nobody verified. Where a fix is a platform action, the entry must carry
the query that proves it, and the query must be run. Second, and narrower:
when an analysis correctly identifies a mechanism but concludes no fix
exists, re-read the mechanism for the remedy it implies. "The sink is
reported for a tainted argument" and "there is no structural fix" cannot both
be true — the first names exactly what to remove.
2026-09-08 — C 08.06's placement block was reported as a population block, blaming the one mapping that was correct¶
- Defect: a firm mapping a mixed legacy extract for return reconciliation — SA, FIRB and AIRB rows alongside its specialised-lending book — was told:
your mapping cannot produce this template — its approach labels
(advanced_irb, foundation_irb, standardised) fall outside the population it reports
Their extract did carry slotting, correctly mapped;
present_approaches contained slotting while that sentence was on screen.
The real cause was elsewhere entirely: the SL columns carried a placeholder
("N/A") on the non-slotting rows, which put sl_type and
slotting_category outside the engine vocabulary and made
_vocabulary_permits refuse C 08.06 on _SLOTTING_PLACEMENT_MAPPINGS. The
message named [components.approach], the one table already right, and said
nothing about the two [carriers.*] tables that were wrong.
And the block itself was wrong, which the first pass at this entry missed.
Told the placeholders were the cause, the firm cleared them and was refused
again. _label_facts measures the placement columns' vocabulary over the
WHOLE ledger, so a value on a row C 08.06 can never read — its population is
slotting-only — was refusing the template. The rows carrying the placeholder
were exactly the rows the template excludes. Naming the cause correctly is
worth nothing if the cause should not have been a cause.
- Rule: not a regulatory escape — no RWA number is affected. C 08.06 / OF
08.06 (Reg (EU) 2021/451 Annex II; PS1/26 Annex I/II) simply went unproduced
on the compare surface, with a reason that sent the analyst the wrong way.
- Origin: LedgerCoverage.blocking_labels is a set subtraction —
present_approaches - TEMPLATE_POPULATION_LABELS[template_id] — so on a mixed
extract it is non-empty whatever made the template unreachable. Its
docstring anticipated exactly this and guarded one case ("or when it is
blocked by a missing COLUMN instead — a different fix"), but the placement
block is a third cause and was added to _vocabulary_permits without a
matching accessor. ui/views/return_recon.py::_template_block then walked
columns → labels, found columns empty, and printed the subtraction.
_warn_unreachable had it right on the same coverage record and in the same
run — the log said "invalid or null slotting placement values in sl_type,
slotting_category" — so the two surfaces disagreed about the cause, and only
the one nobody reads was correct.
- Escape class: no-assertion-of-presence, in its diagnostic form. Every
gate asserted the block was present and none asserted the reason named the
cause. tests/unit/analysis/test_legacy_ledger.py covered all four placement
blocks and asserted blocking_columns("c08_06") == () — pinning that this is
not a column problem, one step from the defect, without ever asking what the
surface says instead. no-gate-exists is the near miss and is wrong: the
gates existed and ran green; they were pointed at reachability rather than at
the sentence.
- Why every gate missed it: the fixture had the right shape all along —
_LEGACY_ROWS's Approach column is SA, SA, AIRB, AIRB, FIRB, SA, SA,
SLOT, SLOT, SLOT, precisely the mix that makes the subtraction misfire — so
this was never path-never-exercised. Both existing placement tests ran over
it and passed. The UI test file tests _template_block's siblings
(test_an_unreachable_template_is_still_offered_with_the_blocking_columns)
but only that a blocked_reason is non-empty, which the wrong sentence
satisfies. Nothing anywhere compared the two surfaces' accounts of one
coverage record, which is what would have caught it: _warn_unreachable and
_template_block are the same decision written twice.
- Gate change: the cause becomes a named thing the analysis layer owns, so a
surface cannot invent its own answer.
LedgerCoverage.blocking_placement() (src/rwa_calc/analysis/legacy_ledger.py)
returns the placement mappings the refusal keyed on; blocking_labels()
returns () when placement is the cause, so it can no longer misattribute
through either of its two callers — nor through a third written later —
rather than only through the one surface that was reported;
and _warn_unreachable now reads the accessor instead of recomputing the
intersection inline, so the log and the UI cannot drift apart again. The UI
gains the matching branch, ordered columns → placement → labels.
Regression gates: test_a_placement_block_does_not_blame_the_approach_labels
(all three placement carriers; asserts slotting is in
present_approaches while the block stands) and
test_a_slotting_placement_block_names_the_carriers_not_the_approaches.
Second change, for the block itself: the refusal is now scoped to the
slotting book, matching the scoping the null check already had. The placement
scan counts rows of the slotting population whose discriminator is null or
out of vocabulary, and LedgerCoverage.invalid_placements carries that set;
_vocabulary_permits keys on it instead of on the whole-ledger
unmapped_labels. The whole-ledger measurement is still REPORTED — C 07.00's
rows 0021-0023 read sl_type off SA rows, so an unmapped value there is worth
naming — so nothing diagnostic is lost and only the refusal narrows. An
unmapped blank now renders <blank> instead of a hole in the remedy line,
because a blank is precisely what an analyst produces when told to clear a
placeholder. Gate:
test_a_placeholder_on_the_non_slotting_rows_does_not_block_c08_06, over five
placeholder shapes including the empty and whitespace strings.
Note what did NOT change: every pre-existing block test targets a slotting row
(index 7 or 9 of _LEGACY_ROWS) and all still fire. That is the evidence the
scoping is narrow rather than merely permissive — had the fix been "stop
blocking", those tests would have gone green-by-deletion.
- Verified red: both gates were run against the unfixed tree first. The UI
gate reproduces the reported sentence verbatim —
AssertionError: assert 'sl_type' in 'your mapping cannot produce this template —
its approach labels (advanced_irb, foundation_irb, standardised) fall outside
the population it reports'
— and the analysis gate fails AttributeError: 'LedgerCoverage' object has no
attribute 'blocking_placement' on all three parameters. The over-refusal gate
was run red too, on all seven of its parameters:
After both fixes, tests/unit/analysis/, tests/unit/ui/, tests/unit/api/
are 1037 passed and tests/contracts tests/integration 1510 passed.
- Lesson: a derived explanation must be refused when it is not the reason,
not merely computed when it is. blocking_labels answers "which approaches
are not in the population" — a question with an answer on almost every mixed
extract — and the caller treated a non-empty answer as evidence it was the
cause. Where several causes can block one outcome, each needs its own
accessor, and the accessors need to be mutually exclusive at the source
rather than by call order in each consumer; otherwise every new consumer
re-derives the precedence and one of them gets it wrong. The tell was
available for free: two surfaces printed different causes for the same
coverage record in the same run.
Second, and the one that cost the user a second round trip: a comment
admitting a check over-reports is a defect report, not a caveat.
_label_facts carried, in capitals, the sentence "it can over-report on an
extract that reuses one source column across approaches" — an accurate
description of this exact escape, written before it happened, directly above
the code that caused it. It read as a documented trade-off ("conservative in
the right direction") because the cost was invisible: an over-report on a
reachability check is not a noisy warning, it is a template silently
withheld. Conservatism is only free where the failure mode is a false alarm;
where it is a refusal, "conservative" and "wrong" are the same thing, and the
scoping that made it correct was three lines and available all along. When a
comment says a check may fire on rows the consumer cannot read, ask what
firing costs before accepting it.
2026-09-08 — The C 07.00 exposure-class axis was our own vocabulary, and the register's scope resolution summed two of our sheets into the class total it was checking¶
- Defect: a user reading the COREP output asked why
retail_mortgageswas appearing as an exposure class on C 07.00, since it is not one. They were right. C 07.00 and OF 07.00 keyed their sheet (z) axis on this repo's internalExposureClassvalues instead of on the Art. 112(1) classes the templates index.reporting/kernel/bases.py::sheet_axisbuilds the axis asdata[class_col].drop_nulls().unique(), so whatever string the sealed class carrier happens to hold becomes a sheet, with no membership test anywhere between the classifier and the submission.
So corporate_sme opened a sheet beside corporate, and retail_mortgage /
residential_mortgage / commercial_mortgage opened three sheets for the
single class (i). The Art. 112(1)(g) and (i) class totals were therefore
reported nowhere, and row 0020 "of which: SME" was null on the very sheet
that should have carried it. Measured on the b31 estate before the fix: sheet
corporate r0010 = 8,000,000 with r0020 NULL, beside a separate
corporate_sme sheet of 500,000; retail_mortgage 400,000 beside
commercial_mortgage 10,000,000 with no class-(i) total anywhere. Two further
non-conforming keys were reachable in production and hit by no fixture:
retail_qrre and residential_mortgage. Fixed in PR #497 (eb546935,
merged as f42cf9c4); after it corporate reports 8,500,000 with r0020 =
500,000, and real_estate 10,400,000 split across r0330 / r0340.
- Rule: CRR Art. 112(1)(a)-(q) — the class list the C 07.00 z-axis indexes.
COREP Annex II ¶47 and PS1/26 Annex II ¶47 both require the total and each
exposure class in a separate dimension, and ¶56 assigns them in the
Art. 112(2) Table A2 order (checked against
ps1-26-annex-ii-reporting-instructions.pdf p.77 by the review that filed
P5.65; not re-extracted for this entry). The published rule the axis broke is
EBA v4240_i — ERROR, live —
{C 02.00, r0130, c0010} == {C 07.00.a, r0010, c0220, s0008}.
- Origin: two places, and the second is why it survived.
reporting/corep/c07.py keyed the sheet off the sealed class directly, and
reporting/validations/scope.py then declared the same wrong axis to the
validator: _C07_SHEETS z0008 held ("corporate", "corporate_sme"), z0009
("retail_other", "retail_qrre") and z0010 the three mortgage classes, with
the same three shapes on the _OF07_SHEETS twin. Standing since C 07.00
acquired a sheet axis. Found by a user reading the output.
- Escape class: test-shared-the-assumption.
tests/unit/reporting/corep/test_c07.py covered the sheet axis and passed
while indexing three keys — secured_by_re_residential,
secured_by_re_commercial, secured_by_re_property — that are not
ExposureClass members at all. Production and its tests were written from
one invented vocabulary, so both sides agreed and both were wrong. The class's
prescribed fix, re-anchor to a source of truth, is exactly what shipped:
tests/contracts/test_c07_art112_sheet_axis.py anchors every assertion on
domain.enums.ExposureClass, on the sibling template's C02_00_SA_CLASS_MAP,
and on the published z-axis in SHEET_INDEX_MAPS — three things that cannot
drift with C07_00_SA_SHEET_MAP.
The register limb carries no class, and forcing one would prescribe the
wrong fix. The supervisory register did not fail to catch this; it converted
it into a pass (below). That is a defect in a gate, which this file's own
preamble says to leave unclassed — and it is the second instance of the
shape the 2026-08-09 ratchet entry conditionally named gate-unfit, a gate
measuring something that is not the quantity that matters. That entry said one
instance is not a taxonomy. Two may be, and the naming is the operator's call;
the difference worth recording is that the first was caught by adversarial
review before its gate shipped, while this one shipped, ran green, and
masked a live defect for as long as C 07.00 has had a sheet axis.
- Why every gate missed it: the strongest gate in the estate was
structurally incapable of binding, and its green was manufactured by the
defect itself. reporting/validations/scope.py::resolve_sheet_codes returns
every bundle_key a published z-code names, and the evaluator then
aggregates the rule's reference across all of them
(reporting/validations/evaluate.py::_sum_cells, whose own docstring names
this exact case: "or from a publisher sheet code that maps onto more than one
of our sheets"). With z0008 holding two keys, the live ERROR rule v4240_i
compared C 02.00 row 0130 against the sum of two of our sheets — a figure
appearing in no submitted workbook. A faithful pre/post comparison of the
whole register is identical in both states: 27 broken / 4 uncovered / 188
vacuous either way, not one rule outcome moved. Corroborating that from the
other side, eb546935 does not touch
tests/expected_outputs/reporting/validation_known_breaks.json at all. The
multi-key mapping did not merely fail to catch the defect; it masked it.
Nothing else was positioned to see it either.
- **The goldens pinned it.** The pre-fix estate carried
`corep__c07_00__corporate_sme.ndjson` and
`corep__c07_00__retail_mortgage.ndjson` as golden files — one per wrong
sheet — so the golden gate was green *because* it had recorded the wrong
axis. Goldens ratchet against change, not against conformance, and a wrong
axis presents to them as a set of filenames.
- **The coverage ratchets are blind to it by construction.** The cells were
populated and the rules bound; an axis error redistributes figures across
sheets without nulling a cell or un-binding a rule, so no liveness or
binding-rule metric moves (first entry in this file).
- **The two unfixtured keys fail open.** A sheet we emit that no z-code
addresses resolves to `sheet_not_emitted`, and every rule scoped to it is
skipped rather than failed — so `residential_mortgage` and `retail_qrre`
would have cost coverage silently rather than reddening anything.
- Gate change: the invariant is graduated executably in two halves that measure different things, and the wrong axis is additionally caught in positive form.
scripts/arch_check.py check 22 — check_sheet_code_single_bundle_key,
registered in main() so it runs on every commit through the pre-commit hook.
An AST scan of reporting/validations/**/*.py: every SheetCode(...) — and
any call passing bundle_keys= at all, which is what catches
replace(entry, bundle_keys=...) — may carry at most one bundle key. It
is unconditional and has no allowlist, which the estate can afford because
no map violates it after #497; measured population 67 SheetCode entries
across all four maps, zero violations. It walks whole modules, so a map
built inside a builder function or a class body is still seen, and it fails
loudly rather than silently if it finds zero SheetCode literals or if
reporting/validations/ moves out from under it — an unmeasured invariant
reads exactly like a satisfied one.
Two cardinalities stay legal, deliberately. An empty tuple is a skip, not
a zero (z0012 and s0015 use it; filed as P2.55 and P2.54). And the reverse
shape — several z-codes onto one of our sheets — is the DPM's Art. 147(2)(d)
IRB axis being genuinely finer than ours (z0013 SME and z0014 non-SME both
address our single retail_mortgage sheet), made safe by the existing
sheet_scope_not_closed refusal. A "simplification" to a 1:1 axis would break
the IRB templates. _C08_SHEETS / _OF08_SHEETS were clean before #497 and
after it, which is the evidence the invariant is aimed at the one direction.
tests/contracts/test_sheet_index_bundle_key_cardinality.py carries the
same invariant over the map the evaluator actually resolves, rather than over
source literals, and pins the reverse shape and its closure guard beside it so
neither can be removed without the other being read. Its last limb asserts the
arch-gate half exists and is dispatched by main(), locating the check by
what it reads rather than by its name — a guard that is built and never wired
is this estate's dominant meta-pattern, and it is why arch_check grew check
20.
tests/contracts/test_c07_art112_sheet_axis.py is the positive form: the
C 07.00 sheet axis must be in 1:1 correspondence with the C 02.00 SA class
rows, since COREP Annex II §1.3.1 makes C 02.00 rows 0070-0211 identities
against the C 07.00 sheet for the same Art. 112(1) letter. So the class is now
caught two ways — at pytest time by the axis correspondence, at arch-gate time
by the cardinality invariant — and the two are anchored on different sources.
The axis review that produced this entry also filed P5.65 (this
graduation) plus P1.371, P1.372, P2.53, P2.54, P2.55 and
P5.66: further Art. 112(1) axis gaps that the fix exposes rather than
causes, none of them closed here.
- Verified red: the shipped check run against the pre-fix source produces
6 violations — z0008, z0009 and z0010 in each of _C07_SHEETS and
_OF07_SHEETS — and 0 on the current tree:
scope.py:143: _C07_SHEETS sheet code '0008' maps to 2 bundle keys
(corporate, corporate_sme). resolve_sheet_codes returns EVERY key for a scoped
code, so the rule evaluator aggregates the publisher's reference across all of
them and asserts against a figure that appears in no submitted workbook ...
The sample is tests/contracts/data/scope_pre_art112_class_axis_fix.py.txt,
verbatim eb546935^:src/rwa_calc/reporting/validations/scope.py, so the red is
reproducible from the repository rather than only from history; it was also
reproduced independently straight from git show while this entry was
written. The measured population is 67 in both states, which matters — the
red is a change in cardinality, not in how much the check can see.
The contract file's limb 3 runs the identical predicate over those pre-fix
entries transcribed verbatim, carrying z0007 unchanged as a single-key
control, so a predicate that flagged every entry or none of them fails there.
And its companion holds the requested z-code and the emitted sheet set fixed
while varying only the map, showing the pre-fix entry handing the evaluator
both corporate and corporate_sme where the live one hands it one — the
masking measured rather than argued.
- Lesson: a gate that normalises its input before asserting on it will
report the normalisation as a pass. Summing a multi-cell reference is a
reasonable reading — _sum_cells documents it as "the only additive reading"
— and it quietly reassembled the class total the workbook had lost, so the
register asserted against a correct figure the submission did not contain.
Where a validator canonicalises its input, the canonicalisation is part of the
assertion and needs a gate of its own; here that gate is a cardinality
invariant on the mapping, not a check on any number.
Narrower, and the reason this was a user's finding rather than a test's: a
template's axis is a published vocabulary, not a free string. unique()
over a sealed column produces an axis-shaped object that is not an axis, and
once one exists the tests written against it inherit its vocabulary — which is
how secured_by_re_property, a string belonging to no enum in the repository,
came to sit in a passing test asserting on a regulatory return.
2026-11-13 — Basel 3.1 OF 09.02 reported its RWEA in a column the template does not have, and three tests said that was right¶
- Defect: the Basel 3.1 layout of OF 09.02 (geographical breakdown, IRB)
carried the risk-weighted exposure amount in column 0125 and had no column
0110. The published template is the reverse: its column codes run
… 0105, 0107, 0110, 0120, 0130— one RWEA column, 0110, and no 0125 (PS1/26 Annex I, "OF 09.02", header row of codes; the Bank of England taxonomy v4.1.1 agrees). 0125 is the CRR column "after supporting factors". So every IRB return wrote its country RWEA where a filing has no cell for it, and left empty the cell the Bank's rules read. Measured over the Basel 3.1 matrix: 24 non-zero figures with no place in the taxonomy, across seven portfolios. - Rule:
boe_b0278andboe_b0296(ERROR — OF 09.02 country-total RWEA for institutions and for qualifying revolving equals the matching OF 08.01 sheet's column 0260). Both read OF 09.02 c0110 as unreported, so zero, against a real figure. Nine v4.0.0 rules over c0110 were not evaluated at all. - Origin:
src/rwa_calc/reporting/corep/templates.py,B31_C09_02_COLUMNS, under the comment "adds 0107 (defaulted EV), removes 0110/0121/0122". The supporting factors do go; the surviving RWEA column was taken to keep the CRR "post" code, as it does on OF 07.00, OF 08.01 and OF 09.01. On OF 09.02 the Bank kept the "pre" code instead. - Escape class:
test-shared-the-assumption. Five tests asserted the wrong layout in so many words:test_b31_column_refslisted…, "0120", "0125", "0130";test_b31_removes_supporting_factor_columns,test_no_supporting_factor_columnsandtest_b31_has_no_supporting_factor_columnseach asserted"0110" not inthe Basel 3.1 columns; and the acceptance testtest_basel_31_declares_no_supporting_factor_columnsasserted the "pre" column absent on every template. All five were written from the same sentence as the layout. - Why nothing else would have caught it: the supervisory register runs the
published rules on our frames by column code, and a rule whose column does
not exist is
NOT_EVALUATED, not broken — the nine rules were simply counted innever_evaluated_rules. The goldens pin whatever layout is generated. The only thing with an independent idea of the layout is the taxonomy pack, which is compiled from the Bank's own files, and it was not in the repository until the filing package was built. - Gate change: the filing-mapping ratchet
(
scripts/filing_mapping_report.py --check) — the gate that found it — holds the result two ways.unplaced_by_reasonno longer carriesc09_02|column_not_in_taxonomy, and no cell of that breakdown may rise, so the column cannot come back. And the ratchet gainederror_rule_breakswith a per-rule breakdown (error_rules_by_rule), added with this entry: the Error-severity rules of the v4.1.1 rule book that a placed return breaks, as (rule, portfolio) pairs, none of which may rise. The five tests are re-anchored to the published template and cite it. - Verified red:
uv run pytest tests/unit/reporting/corep/test_c09_02.py -q -n 0with the tests re-anchored and the layout unchanged —4 failed, 48 passed, the new value test failing withpolars.exceptions.ColumnNotFoundError: "0110" not found. Anduv run python scripts/filing_mapping_report.py --checkwith the new metric and the old baseline:[FAIL] the baseline does not bank error_rule_breaks, so nothing holds it. After the fix the same script, against the baseline banked before it, reports what moved and refuses it until read:[FAIL] Error-severity rule boe_b0284 is broken on more portfolios: 0 -> 2(and four more). - What the fix moved, rule by rule (LESSONS C4 — never a delta alone):
boe_b0278andboe_b0296now hold.boe_b0284,boe_b0293,boe_b0302,boe_b1055andboe_b1060now break. Those five are the RWEA members of the "OF 09.02 country total = OF 08.01 sheet" family, whose exposure members were already breaking because the OF 08.01 corporate and retail sheets are not placed; they went unevaluated only while the OF 09.02 side was empty too. On the template-level register two rules became reachable and break:boe_b0303, whose v4.0.0 text lists columns0010; 0110against a sum of RWEA and which the Bank withdrew in v4.1.1, andboe_b0908, a Warning-severity plausibility check that exposure value exceeds RWEA. Both are invalidation_known_breaks.jsonwith measured reasons. - Lesson: a regime change that removes a pair of columns does not say which code the survivor keeps, and the answer is not uniform across one family of templates. Read the code row of the published template; do not infer it from the sibling templates.
2026-11-13 — OF 08.07 reported a share of nothing as 0.0, and the register's own reason for tolerating the broken rule said there was no answer to report¶
- Defect: on OF 08.07 / C 08.07 (scope of use of the IRB and SA
approaches), columns 0030, 0040 and 0050 are the shares of a roll-out class's
exposure under permanent partial use, under a roll-out plan and under the IRB
approach. Each is defined as a quotient over the row's column 0020 (PS1/26
Annex II §3.3.10.2: "Institutions shall calculate this percentage by
dividing (1) by (2)", (2) being "the total exposure value for all exposures
in that roll-out class as disclosed in column 0020"). On a class the firm
has no exposure to, column 0020 is zero and there is no quotient — and the template reported
0.0in all three cells. A return holding those cells asserts three measured shares that total zero. - Rule:
boe_b0778(ERROR, v4.1.1 PRA001 —sum({OF 08.07, c: 0030; 0040; 0050}) = 1on each roll-out row) and its CRR twinv09796_m(WARNING). Under the gateway's evaluation a reported 0.0 is a fact, so the rule binds and fails; an unreported cell does not bind. Measured with the taxonomy-faithful engine: broken on all thirteen Basel 3.1 portfolios, SA-only ones included. - Origin:
src/rwa_calc/reporting/corep/c08_07.py—_pct_ppu,_pct_irband_c08_07_rollout_pcteach guarded the division withif total <= 0: return 0.0(and the expression form with.otherwise(0.0)). The guard was written to avoid a division by zero and chose a number where the template has none. - Escape class:
caught-and-parked. The supervisory register did fire:b31/boe_b0778andcrr/v09796_msat inknown_broken_ruleson every portfolio, under the reason "limit of the published rule, not of our output … A row with no exposure admits no partition — 0/0 has no answer — and the rule carries no emptiness guard". The reason states the fix (no answer) and draws the opposite conclusion (so the rule is at fault). It could not have drawn the right one from what it measured: the template-level engine zero-fills an empty cell, so to it0.0and "not reported" are the same number and the rule fails either way. Two unit tests (test_c0807_zero_ead_class,test_zero_denominator_row) pinned0.0and share the assumption, but they are not why it shipped — the register entry is. - Why nothing else would have caught it: every other gate reads our frames with the register's zero-fill, or pins the generated value. The difference between an empty cell and a zero exists only in a filed instance, and only an engine that evaluates rules over reported facts can see it.
- Gate change:
error_rule_breaksin the filing-mapping ratchet (scripts/filing_mapping_report.py --check,scripts/filing_mapping_baseline.json). It runs the Bank's v4.1.1 rules on the canonical return with the gateway's semantics — the engine whose verdicts are pinned to Arelle's — and no rule's portfolio count may rise;boe_b0778is banked at zero. The two unit tests are re-anchored to the instruction text, andtest_the_three_shares_total_one_wherever_they_are_reportedholds the rule itself on the generated frame. The register entries stay, with their reason rewritten to say what they now are: an artefact of the zero-fill, owned by the retirement of the template-level engine. - Verified red: with
c08_07.pyrestored to its committed text and everything else in place,uv run python scripts/filing_mapping_report.py --checkreports[FAIL] error_rule_breaks rose: 119 -> 132 (may not rise)and[FAIL] Error-severity rule boe_b0778 is broken on more portfolios: 0 -> 13 (no rule's count may rise);uv run pytest tests/unit/reporting/corep/test_c08_07.py -q -n 0reports3 failed, 58 passed(the two re-anchored tests and the new one). With the fix:[OK] no metric movedand61 passed. - What the fix moved, rule by rule:
boe_b077813 → 0 portfolios. No other rule's count moved;placed_cells,unplaced_figuresandstructure_findingsare unchanged.boe_b0779(row 0260 equals the sum of rows 0180–0250, read on column 0050) still breaks on four portfolios and is not this defect: column 0050 is a ratio, the instruction text scopes the row sum to "columns 0060-0150", and the two rules cannot both hold on that column. It stays in the register as a limit of the published rules. - Not fixed here: Annex II §3.3.10.1 limits OF 08.07 to institutions with permission to use the IRB approach; the template is still generated for an SA-only run. That is a scope question, not a cell value, and is left open.
- Lesson: a register reason that says "there is no answer here" is a finding about our output until an engine that can tell "no answer" from "zero" has agreed. Where the tolerated rule fails only on empty-denominator rows, check what the cell holds before blaming the rule.
2026-11-13 — Basel 3.1 OF 07.00 reported figures in cells the published template greys out, and a column it does not have¶
- Defect: the Basel 3.1 layout of OF 07.00 (credit risk, standardised
approach) carried a value in every cell of every row it computed. The
published template does not: PS1/26 Annex I greys out a large part of the
grid, and the Bank of England taxonomy (v4.1.1, tables
OF07.00.01.01...05) holds no data point for a greyed cell. Four families were being reported where there is no cell — the CRM substitution block (cols 0050–0140) on the risk-weight rows 0140–0280, visibly the col 0100 inflow and col 0110; every column before the exposure value on the counterparty-credit-risk rows 0090–0130; col 0211 on rows that are neither a netting-set row nor a risk-weight row; and the ECAI breakdown (0230/0235/0240) on most "of which" rows. Separately the layout declared a column 0020, "Exposures deducted from own funds", which OF 07.00 does not have; Annex II §3.2.2 ¶48(b) puts such exposures outside the scope of the template. Measured over the Basel 3.1 matrix: 64 non-zero figures with no place in a return, on 47 distinct cells, across eleven portfolios; over the reference outputs, 447 cells held a value (403 a zero, 44 a figure) where the template is grey. - Rule: none fires, which is the point. A rule is written over cells the template has; a figure in a cell it does not have is not broken, it is unfileable. The filing package refuses to write a return that leaves figures out, so every SA return was blocked on these.
- Origin:
src/rwa_calc/reporting/corep/c07.py::_row_cellsbuilds "the full 24-column surface of one row" for every row, and nothing downstream removed any of it. The intermediates are needed — col 0150 on a risk-weight row is a formula reached through that row's col 0100 and col 0110, andboe_b0719decomposes the Total row's col 0150 over those rows — so they were computed, and being computed, reported. Column 0020 came from plan item P2.12, which added it to both regimes' layouts. - Escape class:
no-gate-existsfor the grey cells,wrong-premisefor column 0020. No gate compared the layout with the template's cell list: the supervisory register evaluates rules by row and column code and never asks whether a populated cell exists; the goldens pin what is generated. For column 0020 the plan bullet was wrong and was faithfully implemented, with four tests asserting the column present under Basel 3.1. - Gate change:
tests/contracts/test_of07_published_cells.py— the layout's columns and rows must be the published ones, and the declared grey cells (src/rwa_calc/reporting/corep/of07_published_cells.py) must equal the cells the taxonomy lacks exactly, in both directions: a declaration that blanks a cell the template has fails as loudly as one that leaves a grey cell reported. The declaration rides on everySheetPlan(unreported) and is applied as the last pass (postpass.blank_unreported_cells);lineage.describe_celldescribes such a cell as kindunreported, so the drill-down and the membership and return-reconciliation tie-outs do not treat it as a cell of the sheet.tests/unit/reporting/corep/test_c07_published_cells.pyholds that the generator honours the declaration and that the arithmetic through the blanked cells is intact. The filing-mapping ratchet banksc07_00|cell_not_reportableat 5, and no cell of that breakdown may rise. - Verified red: with an empty declaration and the layout unchanged,
uv run pytest tests/contracts/test_of07_published_cells.py -q -n 0—2 failed, 3 passed:Left contains one more item: '0020'andcells the template lacks that are still reported … Left contains 674 more items, first extra item: ('0010', '0020'). The generator tests before the pass existed:6 failed, 5 passed, e.g.Left contains 34 more items, first extra item: ('corporate', '0230', '0060'). - What the fix moved: every difference in the regenerated reference outputs
was classified cell by cell — column 0020 removed (always null), and 447
cells blanked, all at declared positions; nothing else.
unplaced_figures1001 → 954. No rule's verdict moved on either engine, and the supervisory register is unchanged. The coverage ratchet's floor fell deliberately:cells_live8754 → 8336, because 418 addresses that used to hold a value were never cells of the template; the baseline note says so. - Not fixed here, each stated so it is not mistaken for done: the five figures still unplaced are memorandum row 0320 on the 'in default' sheet — Annex II ¶55 asks for the row there while the taxonomy publishes rows 0300/0320 on sheets 0001–0004 and 0007–0009 only, the open question recorded as P1.377. The CRR C 07.00 layout is untouched, column 0020 included: no EBA template or taxonomy is held to check it against. And the template still has no Total sheet (0001), which Annex II ¶47 requires.
- Lesson: a generator that computes a row cell by cell will report every cell it computes unless something says which are cells. "Which cells exist" is a fact about the published template, separate from "what does each cell mean", and it needs its own source and its own gate.
2026-11-13 — C 07.00 / OF 07.00 was produced without its Total sheet, and the map that names the published sheet codes recorded the gap as design¶
- Defect: the standardised-approach template is required twice over — "The information in OF CR SA is required for the total exposure across all exposure classes and individually for each of the exposure classes under the Standardised Approach. The total figures as well as the information of each exposure class shall be reported in a separate dimension" (PS1/26 Annex II §3.2.2 ¶47; the C 07.00 instructions say the same). The generator produced the class sheets only. The published sheet code 0001 was empty in every return under both regimes.
- Rule:
boe_b0713(ERROR, v4.1.1 PRA001 — row 0010 of sheet 0001 equals the sum of row 0010 over sheets 0002–0017, on columns 0010, 0030, 0035, 0200 and 0220). Broken on eleven of the thirteen Basel 3.1 portfolios: a sum of class sheets against a total that was not reported. On the template-level engine the rules scoped to sheet 0001 were not broken — they were not evaluated at all. - Origin:
src/rwa_calc/reporting/corep/c07.pykeys its sheets on the Art. 112(1) exposure class and nothing else. The gap was known and written down:src/rwa_calc/reporting/filing/sheet_maps.pydeclaredSheetCode("0001", "Total (all SA exposure classes)", (), …)— the published code, correctly named, with an empty tuple of our sheets — and a register reason described it as "z0001 (Total) … carry empty bundle_keys by design (no ExposureClass analogue)". - Escape class:
no-assertion-of-presence. Nothing was wrong on any sheet that existed; one sheet was absent, and absence produces no failing rule on an engine that evaluates the cells it is given. The empty tuple made every rule on the sheet "not evaluated", which every count reported as a property of the estate rather than as a hole. - Gate change: presence is now asserted three ways.
tests/unit/reporting/corep/test_c07_total_sheet.pyrequires the sheet, its layout, and every cell to be the sum of the class sheets (empty where no class reports — a sum over nothing is not a measured zero).tests/contracts/test_of07_published_cells.pyrequires the published code 0001 to address the generated sheet in both sheet maps, and the rows kept off the Total to be exactly those the taxonomy has no cell for on it. And the filing-mapping ratchet banksboe_b0713at zero portfolios, where no rule's count may rise. - Verified red: with the sheet removed from
COREPGenerator._generate_all_c07and everything else in place,uv run pytest tests/unit/reporting/corep/test_c07_total_sheet.py -q -n 0fails onAssertionError: assert 'total' in {'central_govt_central_bank': …}andKeyError: 'total', and the template index test onassert ['corporate'] == ['corporate', 'total']. Before the change the banked breakdown heldboe_b0713at 11. - How the sheet is built, and why:
c07_total_sheetadds the reported class sheets cell by cell; it is not a second execution over the whole population. Every row is evaluated per sheet over that sheet's own population — the real-estate rows exist on the real-estate sheet alone, a substitution inflow lands on the protection provider's sheet, each cell reads its own basis — so the sum of the sheets is the only total consistent with them, and it is whatboe_b0713states. It has no execution plan, so a cell on it has no drill-down; the API and the UI say it is a sum and point at the class sheets (lineage.summed_sheet_reason). - What it cost the readers:
bundle.c07_00now holds one sheet that is the sum of the others, so anything that adds up every sheet counts each exposure twice. One production tie-out and 48 tests did; they readc07_class_sheets(...)now. The vocabulary guardtests/conformance/test_reporting_class_keys.pyneeded more than admitting the new key: counting it put the sheet-key maps at 13 class values in 16 keys, a hair above the discovery floor, where one stray key would have taken them out of the check altogether. The key is left out of the ratio, and the test plants that typo. - What the fix moved, rule by rule (LESSONS C4):
on the v4.1.1 engine two rules moved —
boe_b071311 → 0 portfolios, andboe_b0710_10 → 1. On the template-level engine 58 rules changed state and none regressed: no rule that passed now fails or goes unevaluated. 36 now pass on at least one portfolio where they had asserted nothing or were not evaluated, among themboe_b0713and the EBA'sv4728_m; 21 moved from not evaluated to holding only at zero. One rule that was vacuous now fails —boe_b0710_1again.boe_b0710_1is theboe_b0710question (column 0150 against a conversion-factor breakdown the instructions define for off-balance-sheet items) on memorandum row 0320 of the Total. It is reachable only now: the taxonomy publishes rows 0300/0320 on sheets 0001–0004 and 0007–0009, our figure sits on the 'in default' class sheet (P1.377), and the Total is the first published sheet to carry it. It needs a regulatory reading, not a code change; the register records both sides. - A reading this corrected: the register held
boe_b0959({r0015} >= {r0010}) as "a published-rule defect … asserts defaulted >= total, which no correct report can satisfy". Its scope is the nine "(-)" columns, which are reported as negatives — so it says the defaulted part of a deduction is no larger than the whole, and it now passes on real provisions on the Total sheet of two portfolios. The entry has left the vacuous register; the rule was right. - A finding it exposed, not fixed here:
structure_findingsrose 8 → 9 and is banked deliberately. The taxonomy makes the Total's RWEA (row 0010, column 0220) one data point with OF 02.00 rows 0050 and 0060. The Total's figure is the SA RWEA; our OF 02.00 row 0050 holds the credit-risk total, because the C 02.00 / OF 02.00 row codes are offset from the published ones. That defect has its own entry to come; this is it showing on one more cell. - Lesson: an empty tuple with a good comment is a defect with a description. Where a published code names something we do not produce, the record should be a failing or ratcheted check on its absence, not a sentence saying the absence is intended.
2026-11-13 — Equity and CIU holdings reached the geographical breakdown with no country, and a test recorded that as the state of things¶
- Defect: C 09.01 / OF 09.01 breaks exposures down by "residence of the obligor", "the country of incorporation of the obligor" (PS1/26 Annex II §3.4 ¶86). An equity or CIU holding was reported on the all-countries sheet and on no country sheet, although its counterparty has a country in the input. The country sheets therefore did not add up to the total. Measured on the off-balance-sheet reporting portfolio: country sheets 25,000,000 of original exposure against a total of 33,000,000 — the difference one CIU holding whose counterparty is in GB; on the main reporting portfolio the gap was the whole equity table, 7,000,000.
- Rule:
boe_b0904(ERROR, v4.1.1 PRA001 — on OF 09.01 row 0170, the sum of the country sheets equals the all-countries sheet). Broken on both portfolios that hold equity or CIU units. - Origin: equity exposures travel beside the unified exposure frame — the
hierarchy stage converts their currency and passes them on, the equity
calculator risk-weights them, and they rejoin the main flow only in the
aggregator. They never pass through the classifier, which is where every
other exposure acquires its counterparty's attributes
(
engine/classify/attributes.py:country_code→cp_country_code). The aggregator derives the reported country fromcp_country_code; for an equity leg there was none. - Escape class:
caught-and-parked. It was seen, measured and written down — in a test.tests/acceptance/reporting/test_p2_54_ciu_class_o.pycarriedtest_the_country_sheet_carries_no_equity_table_leg, whose class docstring read "Measured: the equity-table legs reach no country sheet at all … despite the obligor carryingcountry_code="GB"", and which asserted both the null rows and that the gap between the two sheets "is exactly the equity table". It was written honestly, as a tripwire so that assertions aimed at the country sheet could not pass vacuously — and it made the defect a passing test. No plan item owned it. - Gate change:
tests/acceptance/reporting/test_c09_01_country_total.pyasserts the rule itself — the country sheets add up to the all-countries sheet on the three money columns, under both regimes — and that the equity leg carries its counterparty's country on the ledger. The tripwire is inverted intotest_the_country_sheet_carries_the_equity_table_legs, which holds the country sheet to the all-countries one on every equity-table row. The filing-mapping ratchet banksboe_b0904at zero portfolios. - Verified red: before the fix,
uv run pytest tests/acceptance/reporting/test_c09_01_country_total.py -q -n 0failed onassert [None] == ['GB']and onassert 25000000.0 == 33000000.0 ± 33(original exposure),14800000.0 == 22800000.0(exposure value) and13550000.0 == 16350000.0(RWEA), under both regimes. After it:8 passed. The old tripwire, run against the fix, failed as it was written to:C 09.01 [GB] r0140 now publishes [6000000.0, 6000000.0, 28000000.0]. An equity-table leg has reached a country sheet. - The fix, and what it deliberately does not do:
engine/hierarchy/enrich.py::attach_obligor_country_to_equityjoins the counterparty's country onto the equity exposures in the hierarchy stage. Only the country: the other counterparty attributes are not joined, because several reporting predicates read them and an equity holding acquiring an entity type is a change with its own evidence to bring. And such a leg is not routed to the "other countries" area, which would also have made the rule pass: the instructions reserve that area for supranational organisations (¶85–86), and a leg whose country is known is not one. - What the fix moved: no RWA, EAD or risk weight — the acceptance and oracle
suites are unchanged. Three reference sheets, all C 09.01
[GB]: rows 0140, 0142/0143, 0150 and the total now carry the equity table.boe_b09042 → 0 portfolios; no other rule on either engine. - Lesson: a test that asserts a wrong state "so that it cannot go unexamined" has examined it and then filed it. A tripwire for a known defect needs an owner — a plan item or a ratcheted count — or it is a passing test for the defect.
2026-11-13 — C 02.00 / OF 02.00 addressed its rows by codes that were not the published ones, and 87 tests read the rows by the same codes¶
- Defect: the own-funds-requirements template was laid out from row headings, and its row codes were not the publishers' in either regime. The credit-risk RWEA was reported at row 0050 where both templates have it at 0040; the approach totals at 0220 / 0240 / 0300 against the published 0240 / 0250 / 0310; the other risk types at other codes again (settlement at 0430 against 0490, operational risk at 0640 against 0590, CVA at 0590 against 0640). Three figures were in another figure's cell, which is worse than having no cell: an "own funds requirement (8%)" in row 0040, which both templates define as the credit-risk RWEA; CRR supervisory slotting in row 0410, "Retail - Other non-SME"; and, under Basel 3.1, the Art. 123B currency-mismatch memorandum figure in row 0500, "Settlement/delivery risk in the non-Trading book". Under Basel 3.1 columns 0020 and 0030 were filled on every row, where the template has column 0030 on four rows and column 0020 on the modelled rows only; row 0010 column 0030 repeated the total instead of stating the floor; and the multiplier was reported in column 0010 as a percentage (60.0) — or as 0.0 when no floor summary was passed, which no production path did — never as the rate 0.6 in column 0030.
- Rules: four ERROR rules of the Bank's v4.1.1 rule book broke on 13 of
13 registered Basel 3.1 portfolios —
boe_b0359(the multiplier is one of 0.55 … 0.725),boe_b0716(row 0040 column 0020 = SA + the modelled book on SA),boe_b0793(the floor) andboe_b1093(row 0040 = rows 0050 + 0240 + 0460 + 0470). The structure check refused the return on eight of them (STR007), and 53 distinct C 02.00 addresses carried a figure the taxonomy has no cell for. On the EBA sidev0204_m,v0205_m,v0210_mandv0211_m— the footing rules of C 02.00 — had never been evaluated: they could resolve no row. - Origin: there was no template to compare with when the layout was
written, and it was never compared afterwards. PS1/26 Annex I's OF 02.00
workbook was listed in
IMPLEMENTATION_PLAN.md(P1.349) as an artefact still to acquire; the Bank's taxonomy, which states every row, label and cell, was packaged only whenrwa-filerwas built. - Escape class:
test-shared-the-assumption.tests/unit/reporting/corep/test_c02_00.pyheld 87 tests, every one reading a row by the code the generator wrote it to. They pinned the arithmetic of each figure exactly and could say nothing about where the figure was. The filing-mapping ratchet then recorded the consequences — four rules at 13 portfolios each, theSTR007, the unplaced cells — as the measured state. - Gate change:
tests/contracts/test_of02_published_cells.pyholds the Basel 3.1 layout to the taxonomy — every row and column is a published one, every row carries the published label (a code can be right and its meaning wrong), the cells each row reports are exactly the cells the template has, in both directions, and the generated template files with nothing left over.tests/unit/reporting/corep/test_c02_00_published_rows.pystates the EBA footing rules as assertions for CRR, with a guard that each is not vacuous on its frame. Where a figure is reported is now one table (reporting/corep/c02_rows.py: a figure, its CRR row, its Basel 3.1 row, or the statement that the template has no such row), and the generator addresses no row by code. - Verified red: the two new files against the unchanged generator:
117 failed, 13 passed in 5.45s— among themOF 02.00 has no row ['0190', '0220', '0260', '0300', '0330', '0340', '0370', '0380', '0420', '0430', '0440'],figures reported where OF 02.00 has no cell: [('0010', '0020'), ('0034', '0010'), …](97 cells) andassert 'Supervisory slotting' == 'Retail - Other non-SME'. The declaration was written before its own tests, so it was mutated instead — an extra column on row 0050 and F-IRB institutions moved to row 0270:5 failed, 5 passed. - What the fix moved: no RWA, EAD or risk weight. The twelve C 02.00
reference outputs, and nothing else among the goldens. On the filing ratchet:
unplaced figures 954 → 901, structure findings 9 → 1, Error-rule breaks
107 → 52.
boe_b0359,boe_b0716andboe_b1093hold on 13 of 13;boe_b0793on 8. The supervisory register loses two known breaks (boe_b0638,boe_b0652) and gains none. Two false cross-template findings on the CRR reporting portfolio are gone — the equity term sat on the wrong tie, so each was off by exactly the IRB equity, 25,100,000. Seven recorded "RWEA with no detail row" caveats are gone, the largest 16,063,845.09 of A-IRB RWEA whose class the corporate split did not recognise. - What it exposed, and is left open with an owner:
- Column 0010 is un-floored, and OF 08.01 is not. The taxonomy makes
OF 02.00 row 0010 column 0010 one data point with OF 02.01's U-TREA, and
each IRB class row one data point with an OF 08.01 sheet total. So the
floor's add-on belongs in neither — but OF 08.01 still sums
rwa_final, which carries the engine's pro-rata add-on. On the one registered portfolio whose floor binds, the tie-outirb_rwea_c08_01_vs_c02now reports 1,559,200.00 against 1,105,491.29: the 453,708.71 is the add-on. This is P1.369, and the data-point identity is new evidence for its option (a). - The engine's floor is not the template's. On the same portfolio
total_rwea_c02_vs_ov1reports 1,643,200 against 1,699,200: the engine floors the modelled subset only (P1.367). The template reportsx · S-TREA + OF-ADJand logs the difference; the log line is banked as a recorded caveat inscripts/template_cell_coverage_baseline.json. boe_b0793computesx · (S-TREA + OF-ADJ). Art. 92(2A) and Annex II §1.3.1 both givex · S-TREA + OF-ADJ, which is what is reported, so the rule breaks on the five portfolios whose OF-ADJ is not zero (on the main reporting portfolio by 2,580,750 = (1 − x) · |OF-ADJ|). A reading for the firm to take to the Bank; not changed to suit the rule.- Lesson: a test that reads a cell by the address the generator wrote it to tests the arithmetic and assumes the address. The address needs its own source: here the taxonomy, compared row by row, label by label, cell by cell.
2026-11-13 — The rule engine read a figure only in the cell that named it, and failed rules the gateway passes¶
- Defect: the taxonomy shows some data points in two tables. The A-IRB total
is OF 02.00 row 0310 and the total of OF 08.01's sheet 0001; each IRB class
row of OF 02.00 is the total of an OF 08.01 sheet; the SA total is OF 02.00
rows 0050 and 0060 and the OF 07.00 Total sheet. Such a figure is one fact
in a submission, wherever it is shown.
rwa_filer.boeindexed a return by the cells its facts named, so a figure given through one table was "not reported" in the other, and a rule comparing the two read it against the reference's default of zero. The same engine on the same return read back from its own file passed the rule, because the reader places a fact in every reported table that shows it. - Rules: the cross-template family "the figure is the same in both
templates" —
boe_b0621,boe_b0622,boe_b0625,boe_b0643,boe_b0644,boe_b0649,boe_b1060among them, all ERROR. Measured on the IRB-classes portfolio once OF 02.00 row 0310 held the A-IRB total:boe_b0622failed 80,755.66 against 0. - Origin: two paths into the engine, with different closure. A return read
from a file is placed by
xbrl/reader.py::_place— "a fact is placed in every reported template that shows its data point". A return built cell by cell by the reporting adapter names only the cells our generators fill. - Escape class:
no-gate-exists. The engine's verdicts are pinned to Arelle's on returns read from files, and the referee differential compares the two engines on returns where our generators happened to fill both cells. Nothing evaluated a return that named one cell of a shared data point; and until OF 02.00's rows held the right figures, the two sides of these rules were a mis-keyed zero and a default zero, which agree. - Gate change:
packages/rwa-filer/tests/boe/test_engine.py—test_a_fact_is_read_in_every_reported_table_that_shows_its_data_point, and the invariant the defect broke,test_the_verdict_is_the_same_before_and_after_the_return_is_filed: a return and the same return read back from its file get the same verdict. Two guards hold the edges: a cell the return names itself is not overwritten by its twin (two values for one data point isSTR007, the structure check's finding), and a table that is not reported gains nothing. - Verified red: with the engine step disabled,
2 failed, 54 passed—assert ('FAIL', (0, 1)) == ('PASS', (1, 0)). Which of the two verdicts is the gateway's was settled with Arelle, not by argument: a synthetic instance carrying the A-IRB total through OF 02.00 alone was loaded by Arelle 2.47.5 with the Bank's v4.1.1 package — 135 rules evaluated — and Arelle agrees with the engine's read-back path on 1,441 of 1,441. So PASS is the gateway's verdict, and the cell-by-cell path now gives it too. - The fix:
rwa_filer/boe/engine.py::_shown_in_every_reported_tablegives the engine's store each fact in every other reported cell of its data point, before any rule is evaluated. Open-row tables are left out, as the structure check leaves them out. - What the fix moved: on the filing ratchet, seven rules that were failing
for this reason alone now pass. Two that could not be evaluated now are, and
break:
boe_b0738andboe_b0751on the two IRB portfolios, on OF 08.01's Total A-IRB sheet — the gateway sees the one cell of that sheet OF 02.00 shares, and nothing else of a sheet we do not produce. That is the true state, and its owner is the OF 08 sheet split.boe_b0284andboe_b0293now pass on one portfolio and fail on the other with real figures on both sides (37,918,294.87 of corporate RWEA on OF 09.02 against 22,989,230.53 across the OF 08.01 corporate sheet totals, known through OF 02.00's rows), where before they compared a figure with nothing. - A second, smaller thing in the same place: two templates add the same
exposures up in different orders, and the sums differ in the last binary
digit (51,355,833.33333333 against …336 for the SA total). The structure
check compares the cells of a data point exactly, rightly, so the return was
refused over rounding.
reporting/filing/canonical.pynow files one value where the cells agree to eleven significant figures and leaves them as generated where they do not — a penny on a 50m figure is still refused (tests/unit/reporting/filing/test_canonical.py, observed red:2 failedbefore, and3 failedwith the step disabled). - Lesson: an engine with two ways in has two definitions of its input unless something states that they are one. "The same return, before and after it is filed" is that statement, and it is cheap to assert.
2026-11-13 — The Basel 3.1 IRB templates were laid out on a sheet axis coarser than the published one, and the filing ratchet banked every figure on them as unplaceable¶
- Defect: PS1/26 publishes OF 08.01, 08.02, 08.03 and 08.05 on a 17-sheet
axis — fifteen exposure-class-and-approach sheets (F-IRB institutions, A-IRB
specialised lending, F-IRB other general corporates non-SME, retail secured
by residential property SME, …) and a Total per approach. We generated them
on one sheet per exposure class. A class sheet is coarser than the published
axis —
corporateanswers five published sheets,retail_mortgagefour — so no figure on it could be put on any one published sheet, and none was filed: 816 distinct non-zero figures over the 13 Basel 3.1 portfolios (OF 08.01 356, 08.02 203, 08.03 198, 08.05 55, 08.04 4). The two Total sheets were not produced at all. - Rules: every Bank rule that reads an OF 08 sheet by code was NOT_EVALUATED on every portfolio, and the cross-template rules that read OF 08.01 beside OF 02.00 or OF 09.02 compared a figure with nothing.
- Escape class:
caught-and-parked. The filing-mapping ratchet measured the gap from the day the canonical return was built (sheet_coarser_than_published_axis) and its baseline recorded the count as the state.filing/sheet_maps.py::_OF08_SHEETSstated the coarseness in its own entries — two published codes per key, labelled "1st approach" and "2nd approach" — and the template engine's sample sheet maps describe that as "the case the closure logic exists for". The gap was measured, named and accommodated; nothing owned closing it. - Gate change:
tests/contracts/test_of08_published_sheets.pyholds the Basel 3.1 sheet axis to the PRA001 taxonomy in both directions — the declared sheets are exactly the published codes of every OF 08 table, each carries the published label and takes the approach, size and property its dimension members name, no two codes share a key, each sheet total is one data point with its OF 02.00 row, and a book with a leg for every sheet emits every published sheet and nothing the taxonomy cannot place. The sheet definition is one table (reporting/corep/irb_sheets.py) that OF 02.00 and OF 08 both read, so the two templates cannot place a leg differently. - Verified red: the contract and unit tests against the unchanged
generator:
120 failed, 33 passed(the 33 test the declaration alone); representative failuresassert 975.0 == 255.0(a sheet carrying the whole class instead of its own approach and size) andAssertionError: assert 2.0 == 1(one class sheet answering two published codes). The declaration was then mutated eight ways — a label, an approach, a dropped sheet, the SME, commercial-property and financial-or-large flags, the OF 02.00 row, one code mapped to two keys — and every mutation turned the contract test red. - The fix:
reporting/corep/irb_sheets.py(the axis and the leg classification, moved out ofc02.py) andreporting/corep/c08_sheets.py(sheet keys, the two Totals,c08_class_sheetsfor consumers that add up class sheets). Every slotting leg is on sheet 0010 row 0080 and on the F-IRB-and-slotting Total, and OF 08.02 / 08.03 / 08.05 exclude slotting (Annex II row 0080, ¶75, ¶77, ¶77A). A pair the published axis has no sheet for (an A-IRB institution, say) goes on an off-axis key, is counted in its approach's Total as OF 02.00 counts it, and is recorded as an error — never dropped and never put on a neighbouring sheet. A Total averages each parameter only over the legs that carry it (Annex II c0250: maturity "shall not be filled in … for exposures subject to the slotting approach"). CRR is unchanged: no EBA taxonomy is held to lay its axis out against, and no CRR output moved. - What the fix moved: no RWA, EAD or risk weight. The money columns of the
old class sheets and the new sheets agree exactly. Filing ratchet: placed
cells 2,349 → 4,106; unplaced figures 901 → 523 (
sheet_coarser816 → 0). Coverage: Basel 3.1 binding rules 365 → 397, live cells 9,171 → 10,309. - What it exposed — true before, visible now, each left open:
- Maturity is reported as a fraction against integer-typed data points (OF 08.01 c0250 in days, OF 08.03 c0080 in years): STR006, which now keeps four more IRB portfolios out of the referee's golden set.
- OF 09.02 classifies "financial and large corporates" from
cp_apply_fi_scalarwhere OF 02.00 / OF 08 readexposure_subclass(boe_b1034,b1051–b1055on irb-shapes). - The retail-guarantor leg (crm-substitution S2) is on its obligor's sheet in
OF 08 and under retail in OF 09.02 — downstream of the missing CRR Art. 201
eligibility gate recorded in
c02.py. - OF 08.01 rows 0031–0035 (off-balance-sheet by conversion factor) are empty
while row 0030 carries the total (
boe_b0741,b0742); column 0010 (PD) is never emitted (boe_b0356, Warning); retail sheets report c0250, which Annex II says they must not; and OF 08.01 has per-sheet greyed cells we still fill (60 figures). - On the binding-floor portfolio OF 02.00 r0297 (un-floored) and OF 08.01
sheet 0012 c0260 (post-floor) are one data point with two values (STR007,
boe_b0621) — plan item P1.369. - The Bank's
boe_b0735–b0739include the FIRB-and-slotting sheets on OF 08.03, which ¶77 says excludes slotting; the gap is exactly row 0080. - Lesson: a ratchet that banks a gap as "the state" is a register, not a gate. A breakdown reason in a filing measure needs an owner the way a known break does.
2026-11-13 — The template-level rule engine widened a same-sheet sum to every sheet when the sheet was absent¶
- Defect: a rule evaluated on one sheet of OF 08.01 that sums a column of
OF 08.02 without naming a sheet reads OF 08.02 on the same sheet
(
boe_b0752_*,boe_b0814_*: OF 08.01 row 0070 = the sum of OF 08.02 on that sheet).rwa_filer.validate.evaluate._reference_sheetsfell back to EVERY OF 08.02 sheet when OF 08.02 did not carry the one in question, and so compared one sheet's row 0070 with the whole template. - Found by: the supervisory register, on the day the OF 08 sheets took the published axis. OF 08.02 excludes slotting, so the FIRB-and-slotting sheet is absent there whenever it holds only slotting: 19 rules broke on irb-shapes. Before, the coordinate was skipped by the luck of a missing row.
- Escape class:
no-gate-exists. Nothing tested a same-axis reference to a sheet the referenced table does not carry; the only fallback test was the one where there is no sheet to follow. - Gate change:
packages/rwa-filer/tests/validate/test_evaluation_semantics.py—test_a_sum_over_a_sheet_the_summed_table_does_not_carry_is_skipped_not_widened, and beside ittest_a_sum_with_no_sheet_context_still_spans_every_sheet, which holds the fallback the fix keeps. - Verified red:
1 failed, 1 passedbefore the fix —assert ('FAIL', '') == ('NOT_EVALUATED', 'sheet_not_emitted')(it read the corporate sheet's 99 against the institution sheet's 5). After: both pass, and the 19 register breaks are gone. No CRR outcome moved. - The fix: a sheet of the table's own axis that the table does not carry is
sheet_not_emittedfor that reference; the every-sheet fallback is kept for a coordinate with no sheet on that axis.
2026-11-13 — A parallel batch hung forever on Linux under Python 3.13, and the two tests that detect it had only ever run where the default start method hides it¶
- Defect:
rwa_calc.api.run_batchwith two or more runs to dispatch could fail ever to return on Linux under Python 3.13 — and did whenever the caller had already run a Polars query.api/batch.py::_make_executorbuilt itsProcessPoolExecutorwith nomp_context, so the pool tookmultiprocessing's default start method —forkon Linux up to 3.13. A forked worker is a copy of the caller in which Polars is already initialised but none of its threads exist, and its firstLazyFrame.collect()waits on a thread pool that is not there. Captured withfaulthandleron the hung processes: the parent inconcurrent.futures.as_completed(_run_parallel,batch.py:642as it then stood), each child inLazyFrame.collect←has_rows(engine/utils.py:123) ←_load_file_optional(engine/loader.py) ←ParquetLoader.load←PipelineOrchestrator.run←CreditRiskCalc.calculate←_run_scope, bottoming out inmultiprocessing/popen_fork.py. The same inheritance left the per-worker Polars thread cap unapplied: the pool the initializer sizes had been sized in the parent.
It is an availability defect, not a numerical one. Nothing wrong was ever
published — the batch produced no result, no error, no timeout and no
BATCH00x code. There is therefore no sign or magnitude to state in capital
terms; the magnitude is "the group submission and its solo entities do not
come back".
Blast radius. Linux, Python 3.13 — which is the floor pyproject.toml
declares (requires-python = ">=3.13") — in every release from 0.3.29 to
0.3.34: the measurements below are on the current tree, and api/batch.py
has exactly one commit in its history, so they all carry this code. The
population is library callers; run_batch is exported from rwa_calc.api
and nothing inside the package calls it. The trigger, measured, is narrower
than "fork": the caller must have run a Polars query before the pool is
created.
| Caller on Linux / CPython 3.13.18, same two-scope batch | Outcome |
|---|---|
| fresh process, data already on disk, nothing run first | completes, 0.7s |
| one warm-up query in the parent, then the batch | hangs (killed at 40s) |
| a script that writes its input frame first | hangs (timeout 90, exit 124, 0.5s CPU) |
| a serial batch, then a parallel one (the equivalence test) | hangs (timeout 120, exit 124, 3.0s CPU) |
So a one-shot script could work, which is the worst shape for a defect to
have: it passes the smoke test and fails in the long-lived host — a service,
a notebook, any process that reads the first batch's results before starting
the next. Not affected: Windows and macOS (spawn), Linux on Python
3.14+ (forkserver), and the serial path (max_workers=1,
RWA_BATCH_SERIAL=1) everywhere.
- Rule: Not a regulatory escape; no article governs it. The controlling
text is CPython's own, emitted at the moment of the fork and visible in the
failing test's output: "This process (pid=584) is multi-threaded, use of
fork() may lead to deadlocks in the child."
- Origin: 9e572c3 (2026-08-29, feat(api): batch scoped calculations over
a process pool (P1)), released in 0.3.29. Not a /next-items batch. The
module's design assumed spawn from the first line — its docstring argues
from "a spawned child imports the initializer's module during bootstrap" and
calls the picklability of its job "what Windows spawn requires" — while the
code left the choice to the platform. The design was written as a property of
the module and implemented as a property of the host.
- Escape class: path-never-exercised. Two tests that detect the defect
were already in the suite and ran on every push — the first since the commit
that added the feature, the second in its present form since the day after
(b570ad7):
TestSerialParallelEquivalence::test_parallel_and_serial_batches_agree hangs
under fork, and
TestWorkerPolarsCap::test_the_initializer_caps_the_worker_before_polars_is_imported
fails with assert 1 == 2. Neither was ever driven down the fork path,
because no environment the gates run in has fork as its default. That is
this class with the interpreter in the role the fixture portfolio usually
plays: the gate ran, and nothing it ran on reached the code. gate-not-run is
the near miss and is wrong — nothing needed moving earlier; the tests ran at
the right tier, on the wrong interpreter.
- Why every gate missed it: the gates run in two environments, and both
hide it.
- **CI runs whatever `python3` the runner image ships.**
`.github/workflows/ci.yml` names no interpreter and the repo has no
`.python-version`, so `uv sync` takes the system one. From the log of the
most recent `master` run (43438755694), identically in all eight jobs:
`Using CPython 3.14.4 interpreter at: /usr/bin/python3`, and in the Tests
job `platform linux -- Python 3.14.4, pytest-9.1.1`. Python 3.14 changed
the Linux default to `forkserver`, whose children are forked from a
separate server process rather than from the caller, so they never
inherit the caller's running Polars. So the declared floor is 3.13 and the
interpreter CI runs is 3.14. Reproduced here on
CPython 3.14.6 against the pre-fix source: all 35 pre-existing tests in
`test_batch.py` pass, the hanging one included.
- **The dev box is Windows**, where `spawn` is the only start method there
is.
- **The first bite was closed as an instance.** One day after the feature
landed, `b570ad7` (*fix(tests): make the worker Polars-cap test
independent of the start method*) fixed a CI failure caused by the
`forkserver` capturing its environment — by making the *test* calibrate,
and by writing into its docstring that the result was "correct under fork,
forkserver and spawn alike". Nobody had run it under `fork`, where it
fails — and fails with `assert 1 == 2`, the very line that commit records
for *deleting the initializer*, because under `fork` the initializer might
as well not be there. That is `.claude/LESSONS.md` C10 exactly (a claim
quantified over three start methods, measured on two). It was a red CI
run rather than a production escape, so it left no entry here and no
lesson, and the start method's second bite arrived with nothing waiting
for it.
- **A hang is not a failure.** No real-pool test bounds its wait and the
suite has no timeout plugin, so under xdist `--dist=loadfile` the symptom
is one worker going quiet and the run stalling at ~99% — which reads as a
slow box, not as a red test. Filed as P5.73.
- Gate change: the fix for this class is normally "build the portfolio and register it" — here, add the missing interpreter. The stronger form was available and was taken instead: delete the path, so there is no environment left to forget.
src/rwa_calc/api/batch.py — _make_executor now builds both of its
pools on multiprocessing.get_context(WORKER_START_METHOD), with
WORKER_START_METHOD = "spawn": the one start method every platform has, and
the one the module's design already assumed. forkserver was the
alternative and was rejected because it does not exist on Windows, which
would have kept two worker behaviours and with them the category.
tests/unit/api/test_batch.py::TestWorkerStartMethod pins it two ways,
because each has a blind spot the other covers:
- `test_the_pool_is_built_on_an_explicit_spawn_context[uncapped|capped]`
asserts on the arguments both construction branches pass. It starts no
process, so it is red on **every** platform — including Windows and macOS,
where the default is already `spawn` and no observation of a running pool
can tell "pinned" from "left to the platform".
- `test_a_real_worker_runs_as_a_spawned_process` asks a real worker which
`multiprocessing` process class it is running as. Red wherever the default
is not `spawn`, by whatever route the pin is lost. It reads the process
class rather than `multiprocessing.get_start_method()` because the latter
is useless here: measured, a spawned child reports its *parent's default*
(`fork`) whatever context started it.
With the pool pinned, the two pre-existing detectors now run down the same path on every interpreter, so they have stopped being platform-conditional.
Deferred, filed as P5.72: CI still never runs the declared floor
interpreter, and its interpreter is still chosen by the runner image. This
defect no longer needs that leg, but the next 3.13-versus-3.14 difference
will. It is a CI-cost decision (roughly one more Tests job per push) and is
left to the operator rather than taken here.
- Verified red: in a detached worktree at the pre-fix commit 0fd6435
carrying the final test files, with rwa_calc.api.batch.__file__ printed and
confirmed to be the worktree's copy (PYTHONPATH=.:src, per the 2026-08-15
ledger row).
Linux, CPython 3.13.18 (default fork):
$ python -m pytest "tests/unit/api/test_batch.py::TestWorkerStartMethod" \
"tests/unit/api/test_batch.py::TestWorkerPolarsCap::test_the_initializer_caps_the_worker_before_polars_is_imported" -n 0 -q
E AssertionError: no mp_context: the pool would take the platform's default start method
E AssertionError: no mp_context: the pool would take the platform's default start method
E AssertionError: assert 'ForkProcess' == 'SpawnProcess'
E assert 1 == 2
4 failed, 3 warnings in 0.49s
$ timeout 120 uv run pytest "tests/unit/api/test_batch.py::TestSerialParallelEquivalence::test_parallel_and_serial_batches_agree" -n 0 -q
(no output; exit 124 after 2m0.014s, 2.987s of CPU)
Linux, CPython 3.14.6 (default forkserver — CI's interpreter line), the
whole file:
$ python -m pytest tests/unit/api/test_batch.py -n 0 -q
E AssertionError: no mp_context: the pool would take the platform's default start method
E AssertionError: no mp_context: the pool would take the platform's default start method
E AssertionError: assert 'ForkServerProcess' == 'SpawnProcess'
3 failed, 35 passed, 4 warnings in 9.25s
That second run is the one that matters for CI: without the fix, the three
new tests are the only red on the interpreter CI uses, and the 35 that
were there before are green. With the fix: 38 passed on 3.13.18 (9.79s) and
on 3.14.6 (10.34s), and the plain-script reproductions that hung now print
DONE in 1.2s parallel=True success=[True, True] with the default still
reported as fork.
Not observed: Windows and macOS — there was no such host. The
construction test's red there is by construction (it starts no process), not
by observation; the real-worker test is green there with or without the pin,
which is its stated blind spot.
- Lesson: graduated — see the 2026-11-13 row of the Graduation ledger in
.claude/LESSONS.md. A default that varies by platform and interpreter is an
input, and it was an input nobody had varied. The fix is not a wider test
matrix; it is to stop taking the default, the same shape as the skill-value
graduation: not "be more careful which Python the tests run on" but "make the
module incapable of behaving differently by host". The second half is about
the first bite — a test-only fix to a platform-dependent failure is a claim
that the product is right on every platform, and it was written down as one
("under fork, forkserver and spawn alike") on the evidence of two.
2026-11-13 — A netted deposit's currency haircut compared the reporting currency with the loan's, so a cross-currency netting went un-haircut¶
- Defect: on-balance-sheet netting turns a deposit (a negative-drawn loan
under a
netting_agreement_reference) into syntheticNETTING_<loan>cash collateral, and the Art. 224(1) Table 4 currency-mismatch adjustment (H_fx) should then turn on whether the deposit and the loan are denominated in the same currency. Measured through the fullPipelineOrchestrator(STANDARDISED, one unrated corporate, a 300 deposit and a 1,000 loan under one agreement, anfx_ratestable at 1.0 so only the haircut differs, base GBP), identical in CRR and Basel 3.1. Each cell is the loan'scollateral_adjusted_value/ead_final:
| deposit / loan | no collateral file | any collateral file present |
|---|---|---|
| GBP / GBP | 300 / 700 | 300 / 700 |
| EUR / GBP | 300 / 700 — real mismatch, no haircut | 300 / 700 |
| GBP / EUR | 266.06 / 733.94 — right by coincidence | 300 / 700 — no haircut |
| EUR / EUR | 266.06 / 733.94 — no mismatch, haircut anyway | 300 / 700 |
The bolded mismatch cells understate capital. The EUR / EUR cell overstates it. The collateral-file column is the common production shape. In it, no netted deposit was ever haircut, whatever its currency. - Rule: - UK CRR Art. 219 (legislation.gov.uk, onshored text): "Loans to and deposits with the lending institution subject to on-balance sheet netting are to be treated by that institution as cash collateral for the purpose of calculating the effect of funded credit protection for those loans and deposits of the lending institution subject to on-balance sheet netting which are denominated in the same currency." - PS1/26 Art. 219(2) (ps126app1.pdf, page 191 of 492, read with pymupdf): "Where there is a currency mismatch between the exposure referred to in point (b)(i) of paragraph 1 and the loans and deposits referred to in point (b)(ii) of paragraph 1, the institution shall reflect the mismatch by applying the appropriate volatility adjustment specified in Table 4 in paragraph 1 of Article 224 to the value of the protection."
In both texts the currency that matters is each leg's denomination. The two
regimes then part on the consequence of a mismatch: CRR recognises no
cross-currency netting at all, and PS1/26 haircuts it. The regime
consequences are separate fixes (below); this entry is the shared carrier
defect.
- Origin: FXConverter runs before CRM and rewrites currency to the
reporting currency on every exposure, keeping the denomination in
original_currency.
- The generator. engine/crm/collateral.py::generate_netting_collateral is
built from that already-converted exposures frame. It pooled deposits on
currency and wrote it onto the synthetic row as currency, with no
original_currency.
- The haircut test. HaircutCalculator.apply_haircuts compares the
collateral's original_currency, chosen per frame (whenever the column
exists), against exposure_currency. The processor sources
exposure_currency from the loan's original_currency.
- No collateral file. The comparison is therefore "reporting currency vs
loan denomination", which gives the inverted cells above.
- With a collateral file. FXConverter.convert_collateral adds
original_currency to the user collateral. The processor diagonal-concats
the synthetic rows onto it, so they arrive with a null there. null !=
exposure_currency is null, and when(null) takes the otherwise(0.0)
branch. H_fx was off for every netted deposit.
- Pooling. Pooling on the rebased currency also merged deposits in
different denominations under one agreement into a single pool.
- History. P1.135 fixed exactly this carrier for user collateral, by having
FXConverter.convert_collateral preserve original_currency. It never reached
the second producer of rows in the same frame.
- Escape class: path-never-exercised.
- No fixture had the shape. Every netting fixture in the estate is
single-currency: P1.238, P1.241, reporting_netting_portfolio,
r1_negative_gross and matched_short_netting are all GBP.
- The unit tests could not see it. The CRM unit tests build frames with
currency == original_currency, a shape FXConverter never produces for a
foreign-currency row. At unit level the EUR-deposit / GBP-loan case
therefore haircuts correctly.
- The one test named for this behaviour never ran it.
tests/unit/crm/test_netting.py::test_currency_mismatch_fx_haircut
("FX mismatch between negative and positive loans → 8%") sets
agreement_ref=None and hands the haircut stage a pre-built row. It never
runs the generator, and under CRR it pins a haircut as the consequence of a
netting mismatch, which Art. 219 does not grant. Its docstring now says so.
- Why nothing else would have caught it:
- No identity is broken. The adjusted value is internally consistent from
C 07.00 col 0130 through to col 0200, so no supervisory rule fires. The
number is wrong; no relation between numbers is.
- The reporting goldens cannot see it. Every registered netting portfolio
is single-currency.
- P1.135's regression tests pin the right branch on the wrong rows. They
cover the original_currency comparison on hand-built user-collateral rows,
never on generator output.
- Gate change:
1. tests/acceptance/{crr,basel31}/test_art219_netting_currency_mismatch.py
on the in-memory tests/fixtures/netting_currency/ builder. Coverage:
- The four currency pairs, each run with and without a collateral file in
the bundle.
- A GBP + EUR deposit pool against one GBP loan.
- Both regimes, through the full pipeline, with an fx_rates table.
It carries two **adequacy assertions** (LESSONS C11): every loan row was
rebased (`currency == GBP`, `original_currency` == its denomination), and
the collateral file is live (the unrelated loan it secures is reduced).
Without those the fixture could not express the defect. The
regime-independent property is `test_mismatched_deposit_nets_less_than_matched_deposit`:
the same deposit relieves a loan in another currency strictly less than one
in its own. It isolates *which* currencies are compared from *how* a
mismatch is treated. `test_mixed_pool_sits_between_its_two_currency_bounds`
pins the two-pool split end to end: `ead(gbp_gbp) < ead(mixed_pool) <
ead(eur_gbp)`. It was added after review found the mixed pool otherwise
pinned only by strict xfails and a unit frame. A single mutation re-keying
the pool on the rebased currency collapses it to 700 and reddens it.
tests/unit/crm/test_collateral_submodules.py: pools split by deposit denomination, including after a rebase. This replaces a test that asserted only"GBP" in currencies.tests/unit/crm/test_collateral_fx_mismatch.py::test_null_original_currency_falls_back_to_currency_per_row.- The engine fix:
engine/crm/netting.py(moved out ofcollateral.py, which had no room undermax_engine_module_loc) pools on, and carries, the deposit'soriginal_currency.apply_haircutsand the life-insurance Art. 233(3) test fall back per row viacoalesce, not per frame.
Deferred to P1.386: a cross-currency netting leg in a RUNS portfolio, so
Tier 2 and the template-cell census see the treatment.
- Verified red:
- Acceptance tests. uv run pytest tests/acceptance/crr/test_art219_netting_currency_mismatch.py tests/acceptance/basel31/test_art219_netting_currency_mismatch.py -n 0 -q,
run in a detached worktree at the pre-fix commit (module path printed and
confirmed as the worktree's), gave 12 failed, 45 passed, 25 xfailed:
- In each regime, eur_eur failed with
assert 733.9411254969543 == 700.0.
- All four mismatch-vs-matched limbs failed: assert 700.0 > 700.0
(eur_gbp, and both *_coll pairs) and
assert 733.9411254969543 > 733.9411254969543 (gbp_eur).
- Unit tests. The three new unit tests gave 3 failed, 47 passed on the
same tree. The per-row fallback test fails as {'COLL_002': 0.0} where 0.08
is due.
- After the fix: 59 passed, 25 xfailed (the two extra passes are the
mixed-pool brackets, which fail pre-fix with all three loans at 700). The xfails are the rows whose
final figure needs the two regime fixes, and each is strict.
- Related, fixed separately (each with its own commit and review):
- PS1/26 Art. 219(2) prescribes a 10 business day liquidation period for
a netted deposit. The engine gave the synthetic row the haircut stage's
default instead: 20 days (11.314%, not 8%), or 5 days for an SFT-flagged
loan. Correcting it is RWA-REDUCING, except on an SFT loan, where it
increases RWA. Art. 219(2)'s Art. 226(1) non-daily scale-up still does not
reach netting rows (P1.388).
- CRR Art. 219 recognises same-currency netting only. The engine haircut a
cross-currency deposit instead of excluding it. Correcting it is
RWA-increasing under CRR.
Found during the same work and filed rather than fixed: P1.387, the
simple method's Art. 222(6) same-currency 0% carve-out compares the rebased
currency on both sides.
- Lesson: a column whose meaning changes at a boundary changes it for every
producer downstream of that boundary. P1.135 repaired the producer it was
looking at and left the second one, built from the other side of the same
conversion, carrying currency with its new meaning.
The concat half is LESSONS B1's mirror image in its sharpest form: the
column existing is not the row having a value. X if "X" in names else Y
chosen once per frame is wrong on any frame assembled by
pl.concat(how="diagonal"). That idiom appeared at two collateral consumers
(haircuts.py, life_insurance.py), and only one of them was in the bug
report. Graduation candidate, not built here: an arch_check rule flagging
per-frame column selection inside engine/crm/ modules that read the merged
collateral frame.
2026-11-13 — C 07.00 / OF 07.00 took one loan's unused collateral off every other loan on the sheet¶
- Defect: column 0130 "(-) Financial collateral adjusted value (Cvam)" summed
the whole
collateral_adjusted_valuecarrier, and the only floor was the CELL's —0150 = max(0, 0110 - 0130)over the sheet's totals. The engine floors each SA exposure at zero after its OWN collateral (Art. 223(5), E = max{0, ...};engine/crm/collateral.py), so collateral larger than its loan is simply unused there, but on the template it came off every other loan on the sheet. Measured through the full pipeline, STANDARDISED, one unrated corporate with two GBP loans (100 secured by 300 of cash, 1,000 unsecured), identically in both regimes: col 0010 1,100; col 0130 -300; col 0150 800; col 0200 1,000*. Under CRR the same happens when the excess is a netted deposit larger than its loan (300 against 100 gives the identical cells), because CRR reports the deposit in col 0130; under Basel 3.1 col 0035 was already capped per row (_netting_reduction_expr). No EAD or RWA was wrong. - Rule:
boe_b0471(ERROR) andboe_b0556(WARNING) under Basel 3.1;v0308_m(ERROR) andv8726_m(WARNING) under CRR — col 0200 against col 0150. - Origin:
src/rwa_calc/reporting/corep/c07.py— col 0130 boundSum(collateral_adjusted_value)(or its netting-carved twin) uncapped, while every other per-row magnitude on the sheet (the substitution block, col 0035) is capped at the row's exposure. - Escape class:
path-never-exercised. Every rule that sees it is live and the register ran on every commit; col 0130 was live in several registered portfolios. But no registered portfolio held an SA exposure whose collateral EXCEEDS it, so the per-exposure floor was never reached and the cell-levelmaxnever bound. This is LESSONS B5 in a fourth form: registered, live cell, and no fixture driving a row past the clamp the defect lives behind. - The reading taken: col 0130 is capped per exposure at what is left of it
after col 0030, col 0035 and the substitution block (its own share of col
0110, which is EVA with col 0120 unmodelled); col 0140 is NOT scaled with it.
Annex II's col 0130 instruction gives only the Cvam formula; the block heading
over cols 0050-0100 states "Collateral that has an effect on the exposure value
... shall be capped at the exposure value";
boe_b0699/v0307_m({c0150} = {c0110} + {c0120} + {c0130}, live ERROR) admit no other reading once col 0150 is the per-exposure E*; and EBA Q&A 2015_2010 answers this case for C 07.00 — col 0150 "shall be floored to zero", col 0130 "reported as calculated ... however capped at the volatility adjusted value EVA ... in line with validation rule v0307_m", and in its worked example col 0140 stays at its calculated -10 while col 0130 moves from -110 to -105. - Gate change:
tests/fixtures/reporting_over_collateralised_portfolio.pyregistered inRUNSunder both regimes — two over-collateralised loans (one with a maturity mismatch, so col 0140 is live and pins the unscaled reading), a deposit netted against a smaller loan (the CRR form), and a loan whose collateral is BELOW it that the cap must leave alone (LESSONS B5's surviving leg).tests/acceptance/reporting/test_c07_collateral_columns.pystates the published identities per regime on real pipeline output, andtests/unit/reporting/corep/test_c07_collateral_cap.pypins each mechanism (provisions, the substitution block, col 0035, the CRR deposit, the unscaled col 0140). - Verified red: with the portfolio registered and
c07.pyat its pre-fix revision,uv run pytest tests/acceptance/reporting/test_supervisory_validations.py -n 0 -q—1 failed, 7 passed:4 NEW supervisory validation break(s), 2 of them Error-severity:b31/boe_b0471 [ERROR] left = 1,300,000.0000 vs right = 1,015,789.4737 on 4 cell(s),b31/boe_b0556,crr/v0308_m [ERROR] left = 1,300,000.0000 vs right = 815,789.4737 on 4 cell(s),crr/v8726_m— each regime red on its own. The acceptance file:9 failed, 8 passed(the passes are the controls, the engine-unchanged pin and the col 0140 pin); the unit file:14 failed, 2 passed. After the fix all pass, and the register banks the new runs only onto the four existing estate-wide entries. - Lesson: a live cell proves a figure flows through a column, not that any row ever crossed the clamp inside it. For a per-row cap or floor, the fixture must hold a row past it AND a row short of it.
2026-11-13 — Under the Simple Method C 07.00 col 0140 reported the collateral's whole market value as a volatility adjustment¶
- Defect: under the Art. 222 Financial Collateral Simple Method
engine/crm/simple_method.py::undo_sa_ead_reductionzeroes an SA row'scollateral_adjusted_value(the method does not reduce the exposure value) and keepscollateral_market_value. Column 0140 "(-) Of which: volatility and maturity adjustments" was market less adjusted (_financial_collateral_exprs), so it reported the entire market value as an adjustment under a column 0130 — the column it is an "of which" of — of zero. Measured ontests/fixtures/reporting_netting_portfolio.pyunder CRR with the Simple Method: corporate row 0010 col 0130 0.00, col 0140 -3,000,000; on thefcsmportfolio col 0140 -1,200,000 in both regimes. Annex II: cols 0120-0140 "shall be reported for exposures subject to the Financial Collateral Comprehensive Method"; EBA Q&A 2015_2010 puts Simple-Method exposures in cols 050-100. No EAD or RWA was wrong. - Rule:
boe_b0555(Basel 3.1, WARNING — {c0130} <= {c0140}). Its EBA twinv0008_his deactivated, so no enforced CRR rule sees it. - Escape class:
caught-and-parked. Thefcsmportfolio is the estate's only Simple-Method book and is deliberately withheld fromRUNS(P1.347). When it was registered correctly in 2026-08 it was measured to expose "six breaks, two of them ERROR-severity", and the record named only the two. Re-measured on the pre-fix code (BoE rules now v4.1.1, so this is today's set, not proven to be August's), the book's breaks beyond the estate-wide register entries are exactly six with the same two ERRORs —v0308_m,v8726_m,e4895_n(CRR),boe_b0471,boe_b0556,boe_b0555(Basel 3.1) — andboe_b0555is this defect. The gate fired; the count became its resting place. - Gate change:
tests/acceptance/reporting/test_c07_collateral_columns.pyasserts on real pipeline output, without registration, that no row reports anything in cols 0130 / 0140 under the Simple Method (thefcsmbook in both regimes, thenettingbook under CRR) and — the surviving leg — that the samefcsmbook under the Comprehensive Method keeps both columns live. The register cannot see the Simple-Method path until P1.347 registers the book; that bullet now itemises the five breaks that remain. - Verified red: against the pre-fix
c07.py,uv run pytest tests/acceptance/reporting/test_c07_collateral_columns.py -n 0—test_simple_method_collateral_is_not_reported_as_a_comprehensive_adjustmentfailed forfcsm-crr,fcsm-b31andnetting-crr(total r0010: c0130 0.0, c0140 -1200000.0); the comprehensive control passed. The unit file's Simple-Method case failed in both regimes. After: all pass, andboe_b0555no longer breaks on thefcsmbook. - Lesson: a parked count is not an itemised one — "six breaks" carried a defect nobody had named for three months. Record every rule a parked portfolio breaks, by ID.
2026-11-14 — The CRR Framework heading opened the SA-CCR page, and SA-CCR was missing from the sidebar¶
- Defect: the "CRR Framework" nav section in
zensical.tomlhad no index page of its own. Under thenavigation.indexestheme feature Zensical makes the firstindex.mddirectly inside a section that section's index, wherever it sits, so the section's 10th child,specifications/crr/ccr/index.md, became its index. On every CRR page the "SA-CCR (Counterparty Credit Risk)" entry was absent from the sidebar and the heading linked to../ccr/.zensical buildexited 0 and no link broke. It predates the tab split; the same mechanism had just been fixed forreconciliation/index.mdin OpenAfterHours/rwa_calculator#527. - Escape class:
no-gate-exists. Nothing reads the nav's shape: the build does not warn, andcheck_doc_links.pysees only links. The Reconciliation fix was recorded as a comment beside that one entry, which is why the identical case two levels down survived it. - Gate change:
tests/contracts/test_docs_nav_section_indexes.pyfails any nav section whose firstindex.mdpage is not at position 0, read fromzensical.tomlin the dev loop, with no build. Another test pins that the detector flags the pre-fix CRR shape and passes a one-page section. The fix itself isdocs/specifications/crr/index.mdat position 0 of the section. - Verified red: before the fix,
uv run pytest tests/contracts/test_docs_nav_section_indexes.py -n0 -q—1 failed, 2 passed:RWA Calculator > Specifications > CRR Framework: child 9 is specifications/crr/ccr/index.md. The builtsite/specifications/crr/sa-risk-weights/index.htmlhad the heading at../ccr/and ten children, none of them SA-CCR. After:3 passed; the heading points at the new index and all eleven entries are listed, SA-CCR and SFT included. - Lesson: a fix recorded as a comment next to the one entry it bit is prose, and the next instance elsewhere in the nav had no reason to read it.
2026-11-14 — Every rwa-calc release from 0.2.24 to 0.3.34 installed and could not import rwa_calc.api¶
- Defect: in a clean environment,
uv add rwa-calc(orpip install rwa-calc) followed byfrom rwa_calc.api import CreditRiskCalcraised
File ".../site-packages/rwa_calc/contracts/config.py", line 24, in <module>
from watchfire import cites
ModuleNotFoundError: No module named 'watchfire'
and so did rwa-ui, including uvx --from rwa-calc rwa-ui. 79 modules under
src/rwa_calc import watchfire at module level for the @cites decorator;
watchfire==0.3.1 was declared only in the dev extra and in
[dependency-groups].dev, neither of which a user's install includes.
import rwa_calc on its own succeeds — the package __init__ reaches no module
that needs it — which is why a shallow smoke check passes. Reproduced in a fresh
uv init --python 3.13 project against PyPI 0.3.34. Scope, measured from
PyPI's per-version metadata rather than inferred: 0.2.10–0.2.23 declared
watchfire==0.3.1 unconditionally; 0.2.24 (2026-06-07) through 0.3.34
(2026-09-05) — 38 consecutive releases over three months — declared it only
under extra == "dev" / "all", while the 0.2.24 wheel already imported it
in 42 modules and 0.3.34 in 77. No figure was ever wrong; the package could not
produce one. This is total unavailability for anyone installing without the dev
extra, not a misstatement of capital.
- Rule: not a regulatory escape. A wheel's users get exactly its unconditional
Requires-Dist entries (core metadata specification); extras and dependency
groups are opt-in and installed for no one by default.
- Origin: 2888cad5 (2026-06-07, "chore(deps): update watchfire version in
pyproject.toml", body "Remove redundant watchfire dependency"), a manual commit
with no [batch …] footer, moved watchfire==0.3.1 and ty out of
[project].dependencies into the dev extra; it shipped as 0.2.24 the same
day. Moving ty was right — nothing under src/ imports it. Moving watchfire
was not — 42 modules did. The next commit to touch pyproject.toml,
875127f5, the same afternoon, met the identical No module named 'watchfire'
in arch_check after a plain uv sync, and fixed it by adding watchfire to
[dependency-groups].dev: for developers only.
- Escape class: no-gate-exists. Nothing anywhere installed the rwa-calc
wheel. Every CI job, the dev-loop suite, arch_check, and deploy.py's
pre-release test run execute in the workspace dev environment (uv sync --extra
dev, or the default-synced dev group), where watchfire is always present.
deploy.py and publish.yml did build the wheel, and checked its metadata
(check_distribution.py) and its rendering (twine check) — neither installs
it. The one job in the estate that runs a package where only its declared
dependencies exist, rwa-filer (isolated), names this exact failure mode in its
own comment ("a dependency rwa-filer forgot to declare … would pass there and
fail only for a user who installed the wheel on its own"), and was built for the
workspace member only; the root package never had one. gate-not-run was
considered and rejected: that job never runs rwa-calc's code in any form, so
there was no catching gate to move earlier.
- Why every gate missed it: the dev environment is a strict superset of a
user's, and every gate ran in the superset. A missing runtime dependency cannot
be expressed there — not by a thorough test, not by any test — so the class
was invisible by construction, not by oversight of a case. The general form was
already on record: the 2026-08-11 entry above says "the whole estate tests the
source tree, and this defect does not exist in the source tree. It exists only
in the artifact", and the gate built then read the artifact's metadata without
ever installing it. The symptom itself had appeared in this repository at least
twice and was both times read as a developer-environment problem: 875127f5
on the day of the move, and the 2026-08-15 row of the .claude/LESSONS.md
Graduation ledger, where a commit from a worktree failed on No module named
'watchfire'. The error users got was in the project's own history, twice,
filed as tooling.
- Gate change: scripts/check_wheel_install.py. It builds every workspace
wheel from the tree (uv build --all-packages --wheel), installs one into a
fresh environment on the floor of its Requires-Python, holding the wheel, its
unconditional dependencies, and the workspace wheels it declares taken from the
same build (so the gate measures this tree, not whatever PyPI holds), and then,
under python -I from a scratch directory:
imports every module the wheel ships; resolves every console_scripts
entry; runs the per-package PROBES (from rwa_calc.api import CreditRiskCalc;
from rwa_calc.ui.app.main import create_app, rulepack-diff --help,
rwa-filer --version); and serves rwa-ui's create_app on a free loopback
port, requiring GET / and a static asset that page references to answer 200,
which also catches package data missing from the wheel. Each import probe
reports where the package came from, and a path outside the fresh environment
is a failure. Two shallower designs were measured and rejected: importing the
top-level package passes the broken wheel (above), and a pkgutil.walk_packages
walk of the installed package silently skips rwa_calc/data/, which has no
__init__.py and holds schemas and column_spec — so the module list is
read from the wheel's own file listing.
Wired in three places: a new wheel-install CI job (every push, both packages,
and deliberately no uv sync of its own), publish.yml's build job before
upload, and deploy.py's build_release / build_member after the build and
before anything is tagged. tests/contracts/test_wheel_install_gate.py drives
the probes on a hand-built wheel installed offline — a module importing an
undeclared distribution behind a clean __init__ FAILS, the same wheel cleaned
PASSES, a module under a directory without __init__.py is still imported, a
wheel shipping nothing fails rather than passes — and asserts all three call
sites; tests/contracts/test_release_coverage.py fails until a new workspace
member has an entry in PROBES. Each was observed red under an isolating
mutation: probing only the top-level package (2 tests red), skipping the
__init__-less directory (1), dropping the gate from build_release (1),
commenting out the CI run: line (1). Code fix: watchfire==0.3.1 moved to
[project].dependencies, removed from the dev extra and group, exact pin kept
because @cites raises CitationParseError at import time on a citation its
parser rejects.
- Verified red: Step 4b route 1. The shipped gate, copied into a detached
worktree of the pre-fix commit 828849fa, python3
scripts/check_wheel_install.py --package rwa-calc:
rwa-calc: the wheel does not work from a clean install.
- import rwa_calc.analysis.comparison -> ModuleNotFoundError: No module named 'watchfire'
...
- import rwa_calc.api -> ModuleNotFoundError: No module named 'watchfire'
...
- console script rwa-ui = rwa_calc.ui.app.main:main -> ModuleNotFoundError: No module named 'watchfire'
- from rwa_calc.api import CreditRiskCalc; from rwa_calc.ui.app.main import create_app failed:
- the app from rwa_calc.ui.app.main:create_app exited with 1 before answering:
Exit 1: 216 of the 266 shipped modules fail, every one on watchfire;
rulepack-diff --help passes, its module reaching no @cites. On the genuine
article as well: the same probes against the published
rwa_calc-0.3.34-py3-none-any.whl, installed from PyPI with its declared
dependencies, report 208 failed imports, all watchfire, and the same three
entry-point failures. After the fix, on this tree: imported all 266 modules,
resolved console scripts: rulepack-diff, rwa-ui, served
rwa_calc.ui.app.main:create_app: GET / -> 200, GET /static/favicon.png -> 200,
rwa-filer imported all 43 modules; exit 0 in about 9 seconds. Separately, the
real rwa-ui console script, run from a clean install of the built wheel,
answered GET / with 200 (<title>RWA Calculator</title>).
- Not closed by this entry: 0.2.24–0.3.34 stay broken on PyPI until the next
release ships. The workaround is to add the dependency by hand (uv add rwa-calc
watchfire==0.3.1, or uvx --from rwa-calc --with watchfire==0.3.1 rwa-ui).
Whether to yank those releases is a maintainer decision and was not taken here.
- Lesson: graduated to a check — the 2026-11-14 row of the .claude/LESSONS.md
Graduation ledger. The general form: a gate whose environment is a superset
of the user's cannot see what the user lacks. And No module named X from a
dev gate says what the package needs before it says anything about the dev
environment.