From a98d138c731ba5d111fb62a3587f6a34b82edf36 Mon Sep 17 00:00:00 2001 From: Drew T <50529377+Druthulu@users.noreply.github.com> Date: Fri, 31 Jul 2026 14:05:56 -0600 Subject: [PATCH] docs(phase-30): SS127 the -O0 idiom set + SESSION-28 wave checkpoint (honest ROI) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SS127/SS127a/SS127b distil what the wave's agents kept re-deriving, because the index fired on only 3 of 15 targets: - the -O0 CONSTANT-OFFSET FOLD: `p->f` folds to `lbu 3(r)`, `p[i]` does NOT (addiu + 0-displacement load). At -O2 these converge, which is why nothing in SS1-SS126 covers it. - the -O0 regime generally: spill/reload pairs are REAL named locals; load-delay nops and redundant copies are normal; write plain C, the -O2 steering levers are inert here. - SS127a: SS71 sibling-first is the STRONGEST -O0 lever — an -O0 TU is a near-uniform code regime, so a banked sibling's shape transfers far better than at -O2. - SS127b: two agents' decisive levers came from a SOURCE COMMENT in ov_SC01_077_o0.c, not from docs/. Promote levers out of source comments or every future agent re-buys them. Checkpoint records the wave AND its honest ROI: 1.33M tokens for 12 banks and +0.00pp headline. The value is contingent on three reach-138 functions, and all three are currently unpropagated (func_8013C08C 0/137, SS94 type-carry) or gate-failed (func_8013BD74 CARVE-REFUSED, func_8013B83C CC1-FAIL). Fix propagation before wave 2 — drafting more x2-reach targets is not where the leverage is. --- .run/backlog.jsonl | 2 -- docs/cookbook-index.md | 16 +++++++++++--- docs/matching-cookbook.md | 44 +++++++++++++++++++++++++++++++++++++ docs/progress.fleet.md | 16 +++++++------- phase-ends/CURRENT_PHASE.md | 30 ++++++++++++++++++++++++- 5 files changed, 94 insertions(+), 14 deletions(-) diff --git a/.run/backlog.jsonl b/.run/backlog.jsonl index bf2fc6e3ad..c349e1aa89 100644 --- a/.run/backlog.jsonl +++ b/.run/backlog.jsonl @@ -363,7 +363,6 @@ {"ts": "2026-07-01 06:44:24", "addr": null, "name": "func_80182724", "reach": null, "klass": null, "nins": null, "status": "near", "closeness": 10, "where_stuck": "residual: 10 mismatch", "best_draft": ".run/backlog_drafts/func_80182724.c", "binary": "ov_SC02_027", "source": "bulk-harvest", "residual": null, "passes_tried": null} {"ts": "2026-07-01 06:44:56", "addr": null, "name": "func_8017F624", "reach": null, "klass": null, "nins": null, "status": "near", "closeness": 9, "where_stuck": "residual: 9 mismatch", "best_draft": ".run/backlog_drafts/func_8017F624.c", "binary": "ov_SC03_101", "source": "bulk-harvest", "residual": null, "passes_tried": null} {"ts": "2026-07-01 06:44:51", "addr": null, "name": "func_8017F0EC", "reach": null, "klass": null, "nins": null, "status": "near", "closeness": 6, "where_stuck": "residual: 6 mismatch", "best_draft": ".run/backlog_drafts/func_8017F0EC.c", "binary": "ov_SC03_095", "source": "bulk-harvest", "residual": null, "passes_tried": null} -{"ts": "2026-07-01 07:22:14", "addr": null, "name": "func_80184028", "reach": null, "klass": null, "nins": null, "status": "near", "closeness": 11, "where_stuck": "residual: 11 mismatch", "best_draft": ".run/backlog_drafts/func_80184028.c", "binary": "ov_SC03_014", "source": "bulk-harvest", "residual": null, "passes_tried": null} {"ts": "2026-07-01 07:22:21", "addr": null, "name": "func_8018773C", "reach": null, "klass": null, "nins": null, "status": "near", "closeness": 1, "where_stuck": "residual: 1 mismatch", "best_draft": ".run/backlog_drafts/func_8018773C.c", "binary": "ov_SC03_089", "source": "bulk-harvest", "residual": null, "passes_tried": null} {"ts": "2026-07-01 07:22:47", "addr": null, "name": "func_80182EC0", "reach": null, "klass": null, "nins": null, "status": "near", "closeness": 10, "where_stuck": "residual: 10 mismatch", "best_draft": ".run/backlog_drafts/func_80182EC0.c", "binary": "ov_SC04_000", "source": "bulk-harvest", "residual": null, "passes_tried": null} {"ts": "2026-07-01 07:22:17", "addr": null, "name": "func_8017DB78", "reach": null, "klass": null, "nins": null, "status": "near", "closeness": 0, "where_stuck": "match_one MATCH but gate rejected (declaration/TU plumbing)", "best_draft": ".run/backlog_drafts/func_8017DB78.c", "binary": "ov_SC03_011", "source": "bulk-harvest", "residual": null, "passes_tried": null} @@ -671,7 +670,6 @@ {"ts": "2026-07-02 15:29:02", "addr": null, "name": "func_80186D64", "reach": null, "klass": null, "nins": null, "status": "near", "closeness": 10, "where_stuck": "residual: 10 mismatch", "best_draft": ".run/backlog_drafts/func_80186D64.c", "binary": "ov_SC06_029", "source": "bulk-harvest", "residual": null, "passes_tried": null} {"ts": "2026-07-02 22:52:42", "addr": "0x801412a8", "name": "func_801412A8", "reach": 134, "klass": "regalloc-order", "nins": 198, "status": "near", "closeness": 110, "where_stuck": "110 mismatch (count-exact 198/198). S11 LUID(x)alloc: register-assignment permutation + prim2 store-schedule. \u00a731 permuter seed (was mis-logged 164).", "best_draft": ".run/backlog_drafts/func_801412A8.c", "binary": "ov_SC01_077", "source": "T1-relog", "residual": null, "passes_tried": null} {"ts": "2026-07-09 21:32:59", "addr": "0x8013bd74", "name": "func_8013BD74", "reach": 1, "klass": "struct", "nins": 198, "status": "near", "closeness": 192, "where_stuck": "none \u2014 MATCH", "best_draft": ".run/backlog_drafts/func_8013BD74.c", "binary": "ov_SC01_077", "source": "worker", "residual": null, "passes_tried": null} -{"ts": "2026-07-14 12:56:16", "addr": "0x8013c08c", "name": "func_8013C08C", "reach": 134, "klass": "O0", "nins": 27, "status": "near", "closeness": 26, "where_stuck": "WAVE: 26 mismatch", "best_draft": ".run/backlog_drafts/func_8013C08C.c", "binary": "ov_SC01_077", "source": "worker", "residual": null, "passes_tried": null} {"ts": "2026-07-14 12:56:25", "addr": "0x8017c294", "name": "func_8017C294", "reach": 2, "klass": "regalloc-order", "nins": 246, "status": "near", "closeness": 230, "where_stuck": "structurally matched (246 ins, param_3 in $fp, spurious psVar7[1] giv killed via", "best_draft": ".run/backlog_drafts/func_8017C294.c", "binary": "ov_SC01_077", "source": "worker", "residual": null, "passes_tried": null} {"ts": "2026-07-14 12:20:02", "addr": "0x80185ba4", "name": "func_80185BA4", "reach": 1, "klass": "WAVE", "nins": 177, "status": "failed", "closeness": null, "where_stuck": "won't compile standalone (loose-typing / missing decl)", "best_draft": null, "binary": "ov_SC01_077", "source": "worker", "residual": null, "passes_tried": null} {"ts": "2026-07-14 19:01:18", "addr": null, "name": "func_8017D9B8", "reach": null, "klass": null, "nins": null, "status": "near", "closeness": 15, "where_stuck": "residual: 15 mismatch", "best_draft": ".run/backlog_drafts/func_8017D9B8.c", "binary": "ov_SC04_018", "source": "worker", "residual": null, "passes_tried": null} diff --git a/docs/cookbook-index.md b/docs/cookbook-index.md index 04968e5d56..7593c0b48f 100644 --- a/docs/cookbook-index.md +++ b/docs/cookbook-index.md @@ -2,7 +2,7 @@ > **Generated by `tools/cookbook_index.py` — do not hand-edit** (R33). Regenerate after adding a cookbook section. > -> `docs/matching-cookbook.md` is ~716 KB / 337 sections. Grepping it blind is how three P30 wave-1 agents each "discovered" an idiom that was already written down. **Start here, then read the section.** A section appears under every symptom it addresses. +> `docs/matching-cookbook.md` is ~716 KB / 342 sections. Grepping it blind is how three P30 wave-1 agents each "discovered" an idiom that was already written down. **Start here, then read the section.** A section appears under every symptom it addresses. **How to use:** name what you SEE in the diff (a stolen delay slot, an extra `la`, a swapped register pair, a `conflicting types` error), find that symptom below, read those sections first. If nothing fits, THEN grind — and add a section when you win. @@ -238,7 +238,7 @@ - **§125** — Split the CARVE from the BODY before calling a jr residue a wall — and measure it by SHA from a CLEAN tree (P30 SESSION-28; **this section's first draft was WRONG and the method caught it**) L8199 - **§126** — The carve-within-a-carve: an ADDRESS RANGE is not an OPTIMIZATION REGION (P30 T2, byte-proven end-to-end) L8257 -### optimisation level (-O0/-O2) (8) +### optimisation level (-O0/-O2) (11) - **§6** — Per-module optimization mixing — the -O0 boot module (Phase 7) L246 - **Detecting** — the opt level (do this first) L254 @@ -248,6 +248,9 @@ - **§39** — The ×1→×134 giant-endgame: propagate a matched **-O2** giant via the NATIVE DEFINE-macro path (Phase 24 T7 §G close, 2026-07-08) L2530 - **§116** — Optimization level is a property of the FILE, not the function: read a family 0/N against the member's stub HOME (Phase 29 T79) L7870 - **§3-The** — finding: opt level is per FILE, so the file's contents must be opt-HOMOGENEOUS L8272 +- **§127** — The `-O0` regime: the CONSTANT-OFFSET FOLD, and why `-O0` needs its own idiom set (P30 T3 wave, 15 targets) L8342 +- **§3-The** — rest of the `-O0` regime (write PLAIN C, and mean it) L8360 +- **§127a** — §71 (sibling-first) is the strongest `-O0` lever, and it beats the index L8370 ### family propagation & sweeps (65) @@ -491,7 +494,7 @@ - **§125** — Split the CARVE from the BODY before calling a jr residue a wall — and measure it by SHA from a CLEAN tree (P30 SESSION-28; **this section's first draft was WRONG and the method caught it**) L8199 - **§3-The** — meta-lesson L8250 -### (unbucketed — title matched no symptom vocabulary) (88) +### (unbucketed — title matched no symptom vocabulary) (90) - **§3-How** — to use this L30 - **§1** — Idiom catalog (asm pattern → C that produces it) L39 @@ -581,6 +584,8 @@ - **§3-The** — corrected results (each SHA-verified, from a clean tree, restore re-verified) L8231 - **§3-The** — instrument trap that hid it (and it is §124's shape again) L8283 - **§3-The** — mechanics L8292 +- **§3-The** — idiom they kept re-deriving: the constant-offset fold L8349 +- **§127b** — the knowledge was in a SOURCE COMMENT, not the cookbook L8379 ## All sections, in order @@ -922,3 +927,8 @@ - **§3-The** — instrument trap that hid it (and it is §124's shape again) L8283 - **§3-The** — mechanics L8292 - **§126a** — a bare `except: continue` around a coverage-asserting oracle re-creates the silent skip (P30 S28) L8310 +- **§127** — The `-O0` regime: the CONSTANT-OFFSET FOLD, and why `-O0` needs its own idiom set (P30 T3 wave, 15 targets) L8342 +- **§3-The** — idiom they kept re-deriving: the constant-offset fold L8349 +- **§3-The** — rest of the `-O0` regime (write PLAIN C, and mean it) L8360 +- **§127a** — §71 (sibling-first) is the strongest `-O0` lever, and it beats the index L8370 +- **§127b** — the knowledge was in a SOURCE COMMENT, not the cookbook L8379 diff --git a/docs/matching-cookbook.md b/docs/matching-cookbook.md index 2f0915db14..b02f198ec1 100644 --- a/docs/matching-cookbook.md +++ b/docs/matching-cookbook.md @@ -8338,3 +8338,47 @@ why. A total is only trustworthy if the denominator was asserted. *(It also cost credibility in the other direction: I used the bad number to call the T0(f) pin of "2,192 open members" STALE. The pin was right. Re-derivation is only worth more than a carried number if the re-derivation is sound — R35 applies to the re-measurement as much as the original.)* + +## §127 — The `-O0` regime: the CONSTANT-OFFSET FOLD, and why `-O0` needs its own idiom set (P30 T3 wave, 15 targets) + +The `-O0` population is now large (the P30 T2 routing put **2,200+ open stubs** into `-O0` TUs), and +a 15-target wave against it showed the cookbook is written almost entirely for `-O2`. **The index +fired on only 3 of 15 targets**, and multiple agents INDEPENDENTLY re-derived the same idiom — the +signature that a body of knowledge has a hole (§124's lesson applied to the index itself). + +### The idiom they kept re-deriving: the constant-offset fold +At `-O0`, gcc-2.7.2 folds a **constant** struct offset into the load's displacement but will NOT fold +an **indexed** one: +```c +p->f /* -> lbu $v0, 3($s0) — offset folded into the load */ +p[i] /* -> addiu $v0,$s0,..; lw 0($v0) — address computed FIRST, then a 0-displacement load */ +``` +So when the target shows `lbu 3(reg)` you must write the **member access**; when it shows +`addiu` + a 0-displacement load you must write the **indexed** form. At `-O2` these converge and the +distinction is invisible — which is why nothing in §1–§126 covers it. + +### The rest of the `-O0` regime (write PLAIN C, and mean it) +- Frame-pointer prologue `addu $fp,$sp,$zero` (`21F0A003`) is the detector (§6/§116); **every** check + needs `--o0` or you chase a phantom SIZE-MISMATCH. +- Every local is spilled to the frame and reloaded at each use. A `0x18($fp)` spill/reload pair is a + **real named local**, not a compiler temp — declare it. +- Load-delay `nop`s and redundant `addu rd,rs,$zero` copies are normal; do not "clean" them. +- Do **not** hand-optimize, do not add temporaries to help the compiler. At `-O0` the C maps almost + 1:1 to the asm; the usual `-O2` steering levers (pins, live-length dials, statement reordering) are + mostly inert and mostly a distraction. + +### §127a — §71 (sibling-first) is the strongest `-O0` lever, and it beats the index +Several targets fell immediately to an **already-banked sibling in the same TU**. `func_80184868` +matched off the exact shape banked hours earlier in the same `_o0d` file: +```c +s32 ret; ret = func_8001ABBC(0, 0, &D_xxxxxxxx, 0, 0); return ret; +``` +**Before drafting an `-O0` function, read the banked functions in its own `_o0*` file.** An `-O0` TU +is a near-uniform code regime, so a sibling's shape transfers far more reliably than at `-O2`. + +### §127b — the knowledge was in a SOURCE COMMENT, not the cookbook +Two agents reported their decisive levers came from the header comment at the top of +`src/ov_SC01_077/ov_SC01_077_o0.c`, not from `docs/`. That comment is real, hard-won knowledge sitting +where only someone already editing that file will find it. **When a lever is discovered in a source +comment, promote it to the cookbook and leave a pointer** — otherwise every future agent pays to +rediscover it, which is exactly what happened here across 12 of 15 targets. diff --git a/docs/progress.fleet.md b/docs/progress.fleet.md index 86a4b40bfc..fb6b38549f 100644 --- a/docs/progress.fleet.md +++ b/docs/progress.fleet.md @@ -4,16 +4,16 @@ # cross-binary collapsible-byte leverage: docs/duplicates.cross.md. # THREE progress metrics (all matter — see the labels): -FLEET fn-count byte-ident: 329556 / 353720 = 93.17% (REAL+LINKED+empties; FUNCTION-count, ×134-inflated — one crack counts per overlay) -FLEET instr-weighted : 11708337 / 13141652 = 89.1% (shipped .text across main + resident + 138 overlays; the decomp.dev-DISPLAY number) -FLEET distinct-code(uniq): 4530286 / 5634875 = 80.4% (72016/87459 unique fns; the DISTINCT-RE number) +FLEET fn-count byte-ident: 329568 / 353720 = 93.17% (REAL+LINKED+empties; FUNCTION-count, ×134-inflated — one crack counts per overlay) +FLEET instr-weighted : 11708919 / 13141652 = 89.1% (shipped .text across main + resident + 138 overlays; the decomp.dev-DISPLAY number) +FLEET distinct-code(uniq): 4530868 / 5634875 = 80.4% (72028/87459 unique fns; the DISTINCT-RE number) MAIN game-code weighted : 436 / 60201 = 0.7% (INCLUDED in the fleet numbers above since 2026-07-22 — roadmap §1 metrics contract; LINKED-excluding Ghidra sig dated 2026-06-14; caveat is R34: no independent second oracle for a PS-X EXE, NOT drift) - (fleet EXCLUDING main, for continuity with pre-2026-07-22 readings: 11707901 / 13081451 = 89.5%) + (fleet EXCLUDING main, for continuity with pre-2026-07-22 readings: 11708483 / 13081451 = 89.5%) -FLEET REAL substantive : 327701 (of which dedup-shared 240422 via 1905 groups / 240496 instances) +FLEET REAL substantive : 327713 (of which dedup-shared 240422 via 1905 groups / 240496 instances) FLEET LINKED PsyQ objs : 959 FLEET NON_MATCHING : 7 (0 in any default build — G4) -FLEET INCLUDE_ASM stubs : 24157 +FLEET INCLUDE_ASM stubs : 24145 FLEET matchable : 353720 | binary | REAL | shared | LINKED | byte-ident | matchable | byte-ident % | @@ -28,7 +28,7 @@ FLEET matchable : 353720 | ov_SC01_008 | 2334 | 1740 | 0 | 2336 | 2426 | 96.3% | | ov_SC01_009 | 2359 | 1741 | 0 | 2360 | 2507 | 94.1% | | ov_SC01_074 | 2340 | 1741 | 0 | 2342 | 2425 | 96.6% | -| ov_SC01_077 | 2501 | 1707 | 0 | 2503 | 2585 | 96.8% | +| ov_SC01_077 | 2502 | 1707 | 0 | 2504 | 2585 | 96.9% | | ov_SC01_080 | 2374 | 1744 | 0 | 2374 | 2512 | 94.5% | | ov_SC01_084 | 2395 | 1749 | 0 | 2400 | 2579 | 93.1% | | ov_SC02_000 | 2451 | 1788 | 0 | 2451 | 2683 | 91.4% | @@ -56,7 +56,7 @@ FLEET matchable : 353720 | ov_SC03_011 | 2361 | 1744 | 0 | 2367 | 2527 | 93.7% | | ov_SC03_012 | 2336 | 1744 | 0 | 2337 | 2406 | 97.1% | | ov_SC03_013 | 2363 | 1744 | 0 | 2363 | 2493 | 94.8% | -| ov_SC03_014 | 2440 | 1772 | 0 | 2440 | 2685 | 90.9% | +| ov_SC03_014 | 2451 | 1772 | 0 | 2451 | 2685 | 91.3% | | ov_SC03_015 | 2439 | 1772 | 0 | 2439 | 2685 | 90.8% | | ov_SC03_023 | 2347 | 1744 | 0 | 2348 | 2435 | 96.4% | | ov_SC03_024 | 2413 | 1749 | 0 | 2420 | 2641 | 91.6% | diff --git a/phase-ends/CURRENT_PHASE.md b/phase-ends/CURRENT_PHASE.md index 6b84ebeb0a..9d2356c7a3 100644 --- a/phase-ends/CURRENT_PHASE.md +++ b/phase-ends/CURRENT_PHASE.md @@ -110,7 +110,7 @@ stub on a named wall/behemoth/queue ledger** — 140/140 byte-identical througho # 🛑 SESSION-28 CHECKPOINT (2026-07-31 08:1x) — FRESH SESSION SAFE HERE > Supersedes SESSION-27 below. **Nothing is running. Tree lock FREE. Tree clean** but for the R23 -> `db.*.gbf` churn (never stage). **HEAD `commit:1279`** (+ this doc commit). +> `db.*.gbf` churn (never stage). **HEAD `commit:1281`** (+ this doc commit). > Effort: opened **xHigh** → **Max** for the jr re-measurement and the T2 probe ladder → back to > **xHigh** for the driver + sweep. `make tools-health` RC=0 at session open. > **R22 clean-fleet run FIVE times this session, 140/140 every time.** @@ -206,6 +206,34 @@ probe, since the transform is byte-neutral by construction. bare `except: continue`, swallowing the R32 coverage assertion. True: **2,184 stubs / 138 overlays** — which **vindicates the T0(f) "2,192 open members" pin I had called stale**. Cookbook **§126a**. +## 🌊 T3 WAVE 1 (Ultracode, 30 agents, 1.33M tok) — 15 drafted / 15 rtu-confirmed / **12 BANKED** +Target: the population the `-O0` routing made draftable. Every drafter self-checked with +`match_one --o0` + `rtu_match --o0`; every MATCH was then re-run by an independent skeptic told to +default to REFUTED ⇒ 15/15 confirmed, 0 disputed. **Whole-binary gate: 12/15** — textbook §52b. +The 3 failures are NAMED INTEGRATION classes, none a compiler wall: +`func_8013BD74` **CARVE-REFUSED** (it is a jr fn — needs the §81 carve chain; **reach 138**) · +`func_8013B83C` **CC1-FAIL** (real-TU compile, error not yet read; **reach 138**) · +`func_80184058` **PLUMBING**. + +⚠️ **`func_8013C08C` (reach 138) IS BANKED BUT NOT PROPAGATED.** First sweep said "0 families" — +the map still listed it as a stub; regenerated per the `crack-wave-sweep-map-regen` path, then the +sweep found 137 candidates and banked **0/137**. Per **§94 a family 0/N is a TYPE-CARRY failure +until proven otherwise**, and this body carries a §100 body-scoped typedef ⇒ lift its local types +transitively and re-sweep. **Open, NOT a wall.** + +📉 **ROI, honestly:** 1.33M tokens bought 12 banks and **+0.00pp headline** (93.17/89.1/80.4 +unchanged at displayed precision; distinct 72,016→72,028). The wave's real value is contingent — +it rests on the three **reach-138** functions, and all three are currently unpropagated or +gate-failed. **Fix the propagation before running wave 2**: drafting more ×2-reach targets is not +where the leverage is. + +📓 **Flywheel (R16), the uncomfortable number: the index fired on only 3/15.** Agents independently +re-derived the same undocumented idiom, and two found their decisive levers in a SOURCE COMMENT in +`ov_SC01_077_o0.c` rather than in `docs/`. Distilled as **§127** (the `-O0` regime: the +CONSTANT-OFFSET FOLD `p->f`→`lbu 3(r)` vs `p[i]`→`addiu;lw 0(r)`; spills are real named locals; +write plain C), **§127a** (§71 sibling-first is the strongest `-O0` lever — read the banked fns in +the target's own `_o0*` file first), **§127b** (promote levers out of source comments). + ## ▶ RESUME HERE (nothing blocked except where noted) 0. **[T3, breadth] DRAFT the 2,200 newly-`-O0`-routed stubs** — 16 distinct addresses × ~137 overlays, cached Ghidra-C seeds confirmed present, `match_one --o0` is the per-fn check. Crack one