docs(phase-12): T3 harvest checkpoint — REAL 102/145 (71.7%); recovery path recorded

Resident engine harvest this session: REAL 1 -> 102 (71.72% byte-identical) via 5 ultracode
workflow passes + a deterministic byte-gate. 41 stubs remain in two classes recorded in
CURRENT_PHASE.md: (a) ~21 extern-type-conflict casualties (match_one matched them standalone;
the single-TU whole build conflicts on ~25 shared symbols -> unify extern types in resident.c,
widening definitions where byte-identical), (b) ~20 documented compiler-internal residuals
(cross-jump/regalloc -> decomp-permuter + cookbook §3a). Both binaries byte-identical.
This commit is contained in:
Drew T
2026-06-16 13:20:21 -06:00
parent 393d34604b
commit f5209b6ef3
+4 -1
View File
@@ -48,7 +48,10 @@
- **Batch 1** (hand-matched): 6 trivial accessors. REAL 2→8.
- **Batch 2** (workflow): `resident-harvest-draft` (16 parallel agents) drafted matching C for all 135 unmatched fns (asm + cookbook + worked examples → `.run/drafts/<fn>.c`, no builds/no Ghidra; 14/16 agents ok, 2 hit API-500); `tools/harvest_verify.py` (new) byte-gated each draft vs `8e17e02f` (chunk+bisect, self-correcting). **62/127 verified byte-identical in one pass.** Cleaned 35 redundant `#include`. **REAL 8→70 (48.28%); byte-identical 49.66%.** Clean rebuild green both binaries. Commit `commit:0071`.
- **Batch 3** (`commit:0071`→ this): two redraft workflow passes (`resident-harvest-redraft` + retry-resilient `resident-harvest-redraft3`, both seeded by prior drafts + a debugging checklist; the first hit transient server rate-limiting → 8 landed, the retry-wave second pass recovered all 13 batches → +9). Byte-gated via `tools/harvest_verify.py` (drafts2 then drafts3). **REAL 70→78→87 (60.0%); byte-identical 61.38%.** Both binaries clean-rebuild green.
- **Harvest summary:** REAL **1.4%→61.4%** this session (87/145), all hand-matched engine C, via parallel-draft (3 workflow passes, 79 fns) + deterministic byte-gate. **56 stubs remain** — the agents' notes confirm most are pure scheduling/regalloc residuals (permuter/§10 territory) or the big GPU display-list / loader state-machine fns (100–344 ins). Blind drafting has plateaued; the hard tail needs a **per-function asm-differ/permuter loop** (next) + serial Ghidra. Intra-resident dedup collapse (6 h_exact/9 h_norm) still TODO.
- **Batches 3b–5** (`commit:0073`→`commit:0075`): two more workflow passes — retry-resilient redraft (+9→REAL 87), then `tools/match_one.py` (new: per-function isolated compile + relocation-masked diff vs the `.s`) enabling an **iteration loop** (agents compile→read diff→fix), +13→REAL 102. Plus a typedef-strip fix (some drafts inlined `typedef ... u8;` → C89 redefinition compile-fail, not a byte miss; +2).
- **HARVEST RESULT (this session): REAL 1 → 102 / 145 = 71.72% byte-identical**, all hand-matched engine C, via 5 ultracode workflow passes + a deterministic byte-gate (`harvest_verify.py`). Both binaries byte-identical (resident `8e17e02f`, main `143dbb89`). New reusable tooling: `harvest_verify.py`, `match_one.py` (→ Phase-13 overlays).
- **41 stubs remain, two classes:** (a) **~21 extern-conflict casualties** — match_one MATCHED them standalone but the whole-build TU has a conflicting extern type for a shared symbol (a caller declares a callee `s32` to drop an `andi` while another decl/def says `u16`). Recover by **unifying extern types in `resident.c`** (often widening a definition's return type where byte-identical) — NOT separate TUs (splat places resident as one address-ordered object). (b) **~20 genuine compiler-internal residuals** — cross-jump tail-merge / block-reorder / regalloc the agents documented as **decomp-permuter (`tools/permuter/`) + cookbook §3a** territory (e.g. `func_800D06E8` driven 257→118 masked-word diffs; `func_800D128C` cross-jump). Honest P9 deferrals.
- **Still TODO in T3:** the extern-unification recovery (~21) + permuter residuals; intra-resident dedup collapse (6 h_exact/9 h_norm). **Cookbook-worthy idioms found** (R16, fold into §11/§10 at T6): struct-copy prologue (local = global table), void-dispatcher-is-actually-s32-returning, `*10`→`2x+8x` decomposition, masked-compare `andi` survives only when the load's range is unprovable.
- **T4–T6 (revised):** pending.
## Blockers / decisions