From 926fc3f1c000a54eafd4fed1fefca793b7bc2e49 Mon Sep 17 00:00:00 2001 From: Drew T <50529377+Druthulu@users.noreply.github.com> Date: Wed, 26 Aug 2026 21:33:45 -0600 Subject: [PATCH] =?UTF-8?q?docs(cookbook):=20=C2=A7307=20=E2=80=94=20the?= =?UTF-8?q?=20brute-force-statement-orders=20lever=20has=20a=20BYTE-EVIDEN?= =?UTF-8?q?CED=20BOUND=20(12/12=20permutations=20byte-identical=20on=20fun?= =?UTF-8?q?c=5F8001BC6C,=20corroborated=20on=20func=5F80021284);=20a=20fan?= =?UTF-8?q?-out=20copy's=20priority=20is=20rank=5Ffor=5Fschedule-internal,?= =?UTF-8?q?=20unreachable=20from=20source=20order=20=E2=80=94=20recognise?= =?UTF-8?q?=20the=20all-same-closeness=20tell=20and=20route=20to=20the=20p?= =?UTF-8?q?ermuter.=20Plus=20t5=5Fdistill=5Fargs=20--novel-only=20(P31=20S?= =?UTF-8?q?63=20T5.5)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/cookbook-index.md | 10 ++++++--- docs/matching-cookbook.md | 43 +++++++++++++++++++++++++++++++++++++++ tools/t5_distill_args.py | 18 ++++++++++++++-- 3 files changed, 66 insertions(+), 5 deletions(-) diff --git a/docs/cookbook-index.md b/docs/cookbook-index.md index 034f986c7..69ca2c5db 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 / 913 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 / 914 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. @@ -85,7 +85,7 @@ - **ADDENDUM** — to §253 — SECOND byte-proven card (upgrade from single-observation), and the placement face: postfix-in-condition parks the RMW store in the branch delay slot L29251 - **§306** — A HAZARD `nop` IN FRONT OF A DIV-RESULT STORE IS A STATEMENT-ORDER DEFECT: THE INDEPENDENT TRAILING STATEMENT MUST BE WRITTEN *BEFORE* THE DIVISION-CONSUMING ONE (P31 S62 T4; byte-proven func_8017E7D0) L29789 -### instruction scheduling (57) +### instruction scheduling (58) - **§3-T2** — Source statement order drives instruction scheduling L78 - **§3** — When a diff is pure scheduling → decomp-permuter (harness built, Phase 6) L107 @@ -144,6 +144,7 @@ - **§284** — COMBINE CAN REASSOCIATE TWO SEQUENTIAL BITWISE-AND MASKS INTO ONE AGAINST THE PRE-MASK VALUE; AN ASM IN/OUT FENCE RIGHT AFTER THE FIRST MASK BLOCKS IT (P31, wave dd, `func_8018087C`, ov_SC04_020, byte-proven) (P31 S60; waves #, byte-proven) L28989 - **§298** — THE SHARED-TAIL POSITION DIAGNOSTIC: A FOLDED TAIL *BETWEEN* SWITCH ARMS MEANS PER-ARM DUPLICATED STATEMENTS, NOT A HOISTED POST-SWITCH STATEMENT (P31 S61; waves g0e/g0f, `func_80181B68`, ov_SC06_016, byte-proven 68/68) L29457 - **§299** — TWO INDEPENDENT EXTRACTION CHAINS EMIT CONTIGUOUSLY INSIDE ONE EXPRESSION; ONLY A STATEMENT BOUNDARY MAKES THE SCHEDULER INTERLEAVE THEM (P31 S61; wave m0a, `func_8003A404`, main, byte-proven 8/8) L29482 +- **§307** — THE BRUTE-FORCE-THE-STATEMENT-ORDERS LEVER HAS A BOUND: A FAN-OUT COPY'S PRIORITY IS SCHEDULER-INTERNAL, AND NO SOURCE ORDER REACHES IT (P31 S63; byte-evidenced NEGATIVE result, main wave) L29854 ### register allocation & pins (102) @@ -637,7 +638,7 @@ - **ADDENDUM** — to §127 — the -O0 constant-offset fold keys on the MEMBER-ACCESS tree shape, not on the index being constant L29085 - **ADDENDUM** — to §261a — FOUR MORE -O0 DIALS BEYOND THE RELOAD COUNT (boot.c + md_MAIN_011/003, wave m0a/g0a/g0f, byte-proven) L29113 -### family propagation & sweeps (107) +### family propagation & sweeps (108) - **§8d** — Templating a body INTO a TU must not CHANGE its declaration environment — demote the carried data externs (Phase 26 session 8, byte-proven on `func_8015AE2C` ×133) L483 - **§11** — Cross-binary dedup & code-sharing (Phase 11 — "one match unlocks many") L908 @@ -746,6 +747,7 @@ - **ADDENDUM** — to §127 — the -O0 constant-offset fold keys on the MEMBER-ACCESS tree shape, not on the index being constant L29085 - **§296** — THE FRAME CHECK OUTRANKS THE ATLAS LEVER: READ PROLOGUE/EPILOGUE BEFORE DRAFTING ANY C — A REAL TELL CAN LIVE INSIDE AN UNREACHABLE FRAGMENT (P31 S61; wave m0a, 16 cards byte-proven; extends §179-C) L29371 - **§297** — ONE GIV SERVING MIXED-WIDTH LOADS *AND* A STORE NEEDS STRUCT-MEMBER SPELLING; CAST/INDEX SPELLINGS RE-SPLIT THE PSEUDO (P31 S61; wave m0a, `func_800347C8`, main, byte-proven 31/31) L29414 +- **§307** — THE BRUTE-FORCE-THE-STATEMENT-ORDERS LEVER HAS A BOUND: A FAN-OUT COPY'S PRIORITY IS SCHEDULER-INTERNAL, AND NO SOURCE ORDER REACHES IT (P31 S63; byte-evidenced NEGATIVE result, main wave) L29854 ### integration / TU plumbing (60) @@ -2297,6 +2299,7 @@ - **§305** — "CARVE-REFUSED" AT GATE TIME IS THREE NAMED, DETERMINISTIC CLASSES — NONE OF THEM A CARVE (P31 S62 T3; 28 resolver drafts autopsied 28/28) L29737 - **§306** — A HAZARD `nop` IN FRONT OF A DIV-RESULT STORE IS A STATEMENT-ORDER DEFECT: THE INDEPENDENT TRAILING STATEMENT MUST BE WRITTEN *BEFORE* THE DIVISION-CONSUMING ONE (P31 S62 T4; byte-proven func_8017E7D0) L29789 - **§306a** — T4 DISTILL ADDENDA (P31 S62; four byte-proven refinements to existing laws, verified against the book by an independent verifier; each names its parent §) L29816 +- **§307** — THE BRUTE-FORCE-THE-STATEMENT-ORDERS LEVER HAS A BOUND: A FAN-OUT COPY'S PRIORITY IS SCHEDULER-INTERNAL, AND NO SOURCE ORDER REACHES IT (P31 S63; byte-evidenced NEGATIVE result, main wave) L29854 --- @@ -3222,3 +3225,4 @@ Notes routinely quote that as a section id. This table resolves it. Grep bait: ` | L29737 | §305 | "CARVE-REFUSED" AT GATE TIME IS THREE NAMED, DETERMINISTIC CLASSES — NONE OF THEM A CARVE | | L29789 | §306 | A HAZARD `nop` IN FRONT OF A DIV-RESULT STORE IS A STATEMENT-ORDER DEFECT: THE INDEPENDENT | | L29816 | §306a | T4 DISTILL ADDENDA (P31 S62; four byte-proven refinements to existing laws, verified again | +| L29854 | §307 | THE BRUTE-FORCE-THE-STATEMENT-ORDERS LEVER HAS A BOUND: A FAN-OUT COPY'S PRIORITY IS SCHED | diff --git a/docs/matching-cookbook.md b/docs/matching-cookbook.md index 0b9482c6f..c05c5f3b3 100644 --- a/docs/matching-cookbook.md +++ b/docs/matching-cookbook.md @@ -29850,3 +29850,46 @@ same address in another overlay is usually unrelated code. `api_agent.prior_draf candidate only when the symbols it references overlap the target `.s`'s relocations (law 1c); the haiku arm re-run on its misses with the filtered packs banked 2 more. Read "warm start" as "a body whose symbols are this .s's symbols", never as "a body with this name". + +## §307 — THE BRUTE-FORCE-THE-STATEMENT-ORDERS LEVER HAS A BOUND: A FAN-OUT COPY'S PRIORITY IS SCHEDULER-INTERNAL, AND NO SOURCE ORDER REACHES IT (P31 S63; byte-evidenced NEGATIVE result, main wave) + +**Why this is here.** `docs/cookbook-index.md` L22 sends every "same instruction multiset, one contiguous +window, loads/registers ROTATED inside it" residual to the **cheapest lever: brute-force the N independent +statement orders** (`gcc-2.7.2-map/sched.md` §S1/§S4). That lever is real and cheap — but it is NOT +universal, and until now nothing recorded where it stops. Two functions in the S63 main wave each +exhausted it and stayed NEAR, which is worth more banked than re-discovered. + +**The shape it cannot reach.** A value in a register is (a) COPIED to preserve it across an imminent +reuse of the same hardreg, and (b) also the source of a sibling one-shot derivation. The target computes +the derivation directly from the original register (the two chains run parallel from `$v0`); gcc-2.7.2 +emits the *preserving copy first* and then chains the derivation through the copy. + + target: addu $t0,$v0,$zero / addiu $t7,$v0,-0xA0 <- both read $v0 + gcc: addu $t0,$v0,$zero / addiu $t7,$t0,-0xA0 <- second chains through the copy + +**Byte evidence — `func_8001BC6C` (main, 69 ins).** The agent hard-pinned every temp to its exact target +hardreg (`$2`–`$15`), got the first 9 instructions byte-exact, then ran **all 12 permutations** of the two +independent-statement groups through `match_one`: **every permutation produced byte-identical output**, +closeness pinned at 61. An opaque-`__asm__` barrier around the first group moved closeness 61 → 58 but +never removed the extra instruction. The same swap recurs at a second, independent site in the same +function (the `D_800B9A02`/`D_800A6610` pair) — i.e. it is a rule of the scheduler, not an accident of +one window. **Corroborating instance — `func_80021284` (main, 220 ins, closeness 25):** 7 head +instructions where no source order wins both the `%hi`/`%lo` pair placement and the `lw` position +(12 orders measured), plus 18 in a trailing if-block where local-alloc swaps two splice masks +`$a0`↔`$a1` (6 statement orders AND bitfield-vs-explicit-mask all byte-identical). + +**THE LAW.** When the residual is a fan-out copy scheduled ahead of a sibling derivation from the same +source register, `rank_for_schedule`'s priority — not the LUID order the C statement sequence controls — +decides it. Statement order is then a *constant function* of the output: the permutation sweep is +provably inert, and each permutation still costs a compile. + +**WHAT TO DO INSTEAD.** (1) Recognise the tell — permutations that all return the SAME closeness are the +signature; stop after the first 2–3, not after N!. (2) Register pins do not help either: pinning fixes +*which* register, not the scheduler's ready-list priority (both functions were already fully pinned). +(3) Route it to the permuter/T6 wall track, which searches a space source order cannot express. This is +the §3-The/`rank_for_schedule` family, and it is the case those entries did not yet cover. + +**Cross-link:** cookbook-index L22 (the brute-force lever) now has a documented BOUND — check §307 +before spending a permutation sweep; §5a/§34's `__asm__("")` fence moves closeness here but does not +close it, which is itself the discriminator between a delay-slot-filler residual (fence works) and a +ready-list-priority residual (fence only perturbs). diff --git a/tools/t5_distill_args.py b/tools/t5_distill_args.py index 5b369be2c..50c57fe34 100644 --- a/tools/t5_distill_args.py +++ b/tools/t5_distill_args.py @@ -25,6 +25,12 @@ def main(): help="the drafting run's transcript dir (holds journal.jsonl + agent-*.jsonl); repeatable") ap.add_argument('--label', default='', help="provenance string for the cookbook header, e.g. 'P31 S63 t5a'") ap.add_argument('--all-arms', action='store_true') + ap.add_argument('--novel-only', action='store_true', + help="select only transcripts whose agent NOTE carries a novelty signal (says the " + "cookbook lacks the lever, or names a lever/negative result). The t5a run measured " + "the base rate: 34 distilled -> 16 trivial, 5 novelty claims -> 1 ADDENDUM, so " + "distilling every banked transcript spends ~30x the tokens for the same book. " + "The FULL denominator is always printed (R41); this filter is reported, not hidden.") ap.add_argument('--out', default='') a = ap.parse_args() if len(a.wave) != len(a.wfdir): @@ -61,8 +67,16 @@ def main(): if not hit or not os.path.exists(hit[0]): missing.append('%s/%s/%s' % (os.path.basename(wave), arm, fn)); continue out.append({'fn': fn, 'arm': arm, 'transcript': hit[0], 'note': hit[1]}) - print('waves %d; banked %d (union-gated %d); transcripts found %d; label %r' - % (len(a.wave), tot_banked, tot_union, len(out), a.label)) + NOVEL = ('not in the cookbook', 'not in cookbook', 'cookbook did not have', "cookbook does not", + 'NEW IDIOM', 'NEW:', 'NEW fact', 'the cookbook does not cover', 'does not yet cover', + 'negative result', 'addendum', 'Cookbook-worthy', 'no cookbook lever', 'unlocked it') + n_all = len(out) + if a.novel_only: + out = [r for r in out if any(k.lower() in (r['note'] or '').lower() for k in NOVEL)] + print('waves %d; banked %d (union-gated %d); transcripts found %d; selected %d%s; label %r' + % (len(a.wave), tot_banked, tot_union, n_all, len(out), + ' by novelty signal (%d NOT distilled — no signal in their note)' % (n_all - len(out)) if a.novel_only else '', + a.label)) if missing: print('NO TRANSCRIPT for %d banked draft(s) — NOT distilled (R32, reported not skipped): %s' % (len(missing), ' '.join(missing[:20])))