Files
BFM-decomp/phase-ends/current/tasks/T10.md
T

5.8 KiB

T10 — residue coverage gate (--check-casts --residue) and 3.40 sizing

Status: done | expert: expert-opus55 | ctx-at-completion: n/a | commit: see COMMIT | coder runs: c1 opus55 done (fad97b178c, f991bab729), c2 opus55 done (1246b85c38) Done: per-site residue coverage in restruct and type_census (one shared matcher), ledger-only P/X gap closed, type_census --check-casts --residue gate and residue census written; on the T4 tree P/X uncovered 0, gate fails only on I/M uncovered and lying. Files:

  • tools/restruct.py — residue_match(latest, sites, forms) :3480 (pure; per site, multiset, key (form, s_base_norm(base), off) inside body ("S", tu, fn) via ledger_latest; covered iff entry RESIDUAL(<cause>) with non-empty cause); --check-residue per site; --residue --forms P,I,X,M (default P,X); I/M causes ABS-ADDR, GLOBAL plus residue_cause set; merged rows (copy prior latest row, append RESIDUAL entries, residue_of = prior label); residue under apply lock; selftest 101/101 (c1)
  • tools/type_census.py — --residue with --check-casts; writes .run/P37/census/residue_census.{json,txt}; selftest 67/67 (per-form covered/uncovered x3 controls, KEPT macro site under macros) (c2)
  • .run/P37/restruct/ledger.jsonl — +4,335 merged rows t10_res_ov/md/main (c1)
  • decomp-architect/corpus/tools/P10/{restruct,type_census}.py — kit-corpus copies
  • docs/ops/p39-t10-2026-10-02-check-casts-residue.md, docs/ops/INDEX.md, HOW_WE_WORK.md Tools row "type_census casts" (H7) Interfaces (shapes later tasks read):
  • type_census --check-casts --residue → check-casts: raw P= I= X= M= (uncovered P= I= X= M=); macros …(unbacked n); lying=n (ledgered n) + by-cause: <CAUSE>=<n> … (covered sites, desc); rc 1 on uncovered > 0, unbacked > 0, unledgered lying > 0. Without --residue: T2 output unchanged.
  • restruct --rung S --residue [--forms P,I,X,M] --only <seg> --label <l>; --check-residue prints uncovered <n> sites / <m> bodies, per site, forms P,X. Decisions:
  • binding: residue coverage is per site, matched on (form, normalised base, off) within the body's latest rung-S row, never on line; both gates use restruct.residue_match.
  • binding: a --residue row for a body with an existing latest S row merges (keeps KEPT/MEMBER entries and verdict) so macro backing survives.
  • I/M residue rows not written on the tree (capability + selftest only); I/M coverage is the next owner's work. Deviations:
  • c2: by-cause attribution reads each covered site's cause via rs._residue_key; the split itself is residue_match's.
  • residue_census files sit under gitignored .run/ (regenerable; not committed). Findings:
  • Per-site match exposed P/X gaps the per-body check hid: ov 14,296 sites / 4,234 bodies, md 281/99, main 3/2, shared 0 (bodies with MEMBERS/KEPT rows whose undrawn-base sites were never listed); closed by merged ledger-only rows (TNC 13,936, NO-TYPE-IN-MAP 360 in ov).
  • Gate on the T4 tree: raw P=257464 I=51505 X=13790 M=15130 (uncovered P=0 I=35625 X=0 M=14762); macros CAST_ALIAS=1173 CAST_SIGN=8429 CAST_WIDTH=10410 CAST_MISALIGNED=624 CAST_NONSTRUCT=327 (unbacked 0); lying=229 (ledgered 0), rc 1.
  • I covered 15,880 and M covered 368 come from prior rung-S rows that already listed I/M sites with causes.
  • 3.40 sizing (residue_census.txt), covered by form: P 257,464 · I 15,880 · X 13,790 · M 368; uncovered: I 35,625 · M 14,762.
  • By segment covered/uncovered: ov 267,984/48,334 · md 6,315/328 · main 1,751/321 · shared 11,452/1,404.
  • By cause (covered sites): TYPE-NOT-CANONICAL 281,252 · NO-TYPE-IN-MAP 2,966 · NO-FIELD 1,773 · NO-EDIT 482 · INDEX 479 · AGGREGATE-FIELD 369 · FILE-SCOPE 172 · TYPE-NOT-VISIBLE 9.
  • TNC concentration: 281,252 sites over 13,081 distinct map types; 50% covered by 81 types, 80% by 579, 95% by 4,384.
  • Top 50 map types, Unkstruct_ sites/bodies: 800D3888 21350/6239; 0caecd54 4340/124; dac960ce 4216/124; f8ed2b9f 4061/4061; a32b99a1 3936/123; 8e3dbe51 3930/131; 57a28935 3271/196; 1fa9e810 3144/131; 30b21035 3100/124; a2c8734a 2646/126; 198fc7cc 2580/129; ed8f1335 2356/124; 80126948 2213/705; 8016B4F8 2141/535; 80139C7C 2111/265; 80130D48 2109/317; 2729e670 2091/123; dd542e54 2016/126; f49880fd 2000/125; a8d34bce 1948/1948; 8016DF5C 1926/131; 568f7bda 1875/125; cd1bacd2 1764/126; 8011F7A8 1742/270; 84612d18 1722/123; 57db4d07 1664/128; 4692fc17 1612/124; eda88e53 1596/133; 4e09b6d9 1572/131; 8012D3B4 1565/180; 645b745d 1548/258; 0980b9f0 1441/131; b5c0372a 1441/131; 47470ce3 1404/117; a68f6d03 1364/124; 801345F8 1336/134; 8fdd92d1 1300/130; 110cf29e 1250/125; 4db8cec8 1240/124; d292c30d 1240/124; f0bc3b7a 1240/124; a459e3e5 1220/122; f9a7989e 1179/131; 80135260 1170/130; 801290DC 1149/259; 0b30043d 1128/376; 301381d4 1116/124; 4e427c01 1116/124; 4857195e 1107/123; 50a3f6b4 1040/130.
  • Many top types recur with ~123-131 bodies: likely one overlay struct duplicated per overlay family (hash-named twins); 3.40 should check twin-merge before defining each. Gotchas:
  • generalizable: a coverage check keyed on "body has any ledger row" hides per-site gaps once later sweeps add rows for other reasons; match per site, and merge new residue entries into the latest row rather than superseding it (a superseding row unbacks earlier KEPT entries). Research: none new Next task needs: T5 (or I/M owner) runs restruct --rung S --residue --forms I,M per segment once I/M causes are agreed; lying 229 still unledgered; 3.40 canonical-types campaign sizes from the top-81/579 types above. Verified: PY tools/type_census.py --selftest && PY tools/restruct.py --selftest && check-residue ov_*/md_*/main/src/shared/* → 67/67, 101/101, each uncovered 0 sites / 0 bodies, RC 0 (.run/logs/t10_verify_a.log); (PY tools/type_census.py --check-casts --residue; test $? -eq 1) → RC 0, gate line above (.run/logs/t10_verify_b.log) Full log: phase-ends/current/logs/T10.md