Commit Graph

350 Commits

Author SHA1 Message Date
Drew T a2b5ff345f feat(phase-23): lora-grind gate — +13 fns x0 propagated (fleet 63.79%) 2026-06-30 07:04:34 -06:00
Drew T 07ff65a267 feat(phase-23): lora-grind gate — +14 fns x0 propagated (fleet 63.79%) 2026-06-30 06:52:08 -06:00
Drew T 3d4f7778fa feat(phase-23): lora-grind gate — +18 fns x0 propagated (fleet 63.79%) 2026-06-30 06:46:02 -06:00
Drew T 581e27d7f4 feat(phase-23): lora-grind gate — +14 fns x0 propagated (fleet 63.78%) 2026-06-30 06:39:20 -06:00
Drew T 29800c8058 feat(phase-23): lora-grind gate — +11 fns x0 propagated (fleet 63.78%) 2026-06-30 06:32:48 -06:00
Drew T 714760a1a0 feat(phase-23): lora-grind gate — +15 fns x0 propagated (fleet 63.77%) 2026-06-30 06:27:19 -06:00
Drew T 189cc113c2 feat(phase-23): lora-grind gate — +19 fns x0 propagated (fleet 63.77%) 2026-06-30 06:20:35 -06:00
Drew T 0409ee9199 feat(phase-23): lora-grind gate — +13 fns x0 propagated (fleet 63.76%) 2026-06-30 06:14:51 -06:00
Drew T 37cc7d8dd6 feat(phase-23): lora-grind gate — +12 fns x0 propagated (fleet 63.76%) 2026-06-30 06:08:18 -06:00
Drew T fb1fe5e226 feat(phase-23): lora-grind gate — +25 fns x0 propagated (fleet 63.75%) 2026-06-30 05:53:40 -06:00
Drew T cba2addc1d feat(phase-23): lora-grind gate — +19 fns x0 propagated (fleet 63.74%) 2026-06-30 05:47:52 -06:00
Drew T c7775eb8b5 feat(phase-23): lora-grind gate — +15 fns x0 propagated (fleet 63.74%) 2026-06-30 05:36:16 -06:00
Drew T 0188638afd feat(phase-23): lora-grind gate — +1 fns x0 propagated (fleet 63.73%) 2026-06-30 05:29:37 -06:00
Drew T 865d185a8a feat(phase-23): lora-grind gate — +9 fns x0 propagated (fleet 63.73%) 2026-06-30 05:24:51 -06:00
Drew T 238a1c00d8 feat(phase-23): lora-grind gate — +17 fns x0 propagated (fleet 63.73%) 2026-06-30 05:18:19 -06:00
Drew T 9623afd3fa feat(phase-23): lora-grind gate — +10 fns x0 propagated (fleet 63.73%) 2026-06-30 05:12:09 -06:00
Drew T b03fdb1dcb feat(phase-23): lora-grind gate — +19 fns x0 propagated (fleet 63.72%) 2026-06-30 05:06:04 -06:00
Drew T 758ab7de65 feat(phase-23): lora-grind gate — +14 fns x0 propagated (fleet 63.72%) 2026-06-30 05:00:13 -06:00
Drew T aec384eccd feat(phase-23): lora-grind gate — +9 fns x0 propagated (fleet 63.68%) 2026-06-30 04:46:49 -06:00
Drew T 4359e64750 feat(phase-23): lora-grind gate — +8 fns x0 propagated (fleet 63.67%) 2026-06-30 04:40:13 -06:00
Drew T b6019333dd feat(phase-23): lora-grind gate — +4 fns x0 propagated (fleet 63.67%) 2026-06-30 04:29:10 -06:00
Drew T 066a2e5c8f feat(phase-23): local GPU serving + prompt-fix + corpus-v3 (macro+struct mining)
LM Studio was ejected, so serving is ours now: tools/serve_local.py serves base+LoRA via
Unsloth (.venv-train cu128) as an OpenAI endpoint — no llama.cpp build (this CPU has no
AVX-512, which SIGILLs the prebuilt llama-cpp-python CUDA wheels). api_draft/lora_grind hit
it unchanged.

PROMPT FIX (api_draft.LEAN_SYS + format_finetune.SYS, kept in sync): 'translate EVERY
instruction, never an empty body' — a prompt test took the small-leaf band 0/3 -> 2/3 MATCH
(the v2 corpus overfit an empty void f(void){} leaf pattern). Validated end-to-end: a fresh
ov_SC01_001 batch banked 3 via the local server + better prompt.

CORPUS-V3 (export_pairs + format_finetune):
- export_pairs now ALSO mines the 1623 DEFINE_func macro bodies in engine_core.h (the shared
  setters/return-const/dispatchers extract_defs never saw -> 96.6% of v2 was overlay-unique,
  the root of the empty-leaf overfit). Corpus 1312 inline -> 2891 (1312 inline + 1579 macros).
- format_finetune inlines engine_types.h structs in the compile-filter so struct-using bodies
  are KEPT not dropped: train 2534/2591 (97.8%) compile standalone (v2 was 1111 total).
2026-06-30 01:46:54 -06:00
Drew T 5c44a317b3 feat(phase-23): lora-grind gate — +3 fns x0 propagated (fleet 63.67%) 2026-06-30 01:38:00 -06:00
Drew T e91859fb4a feat(phase-23): grinder per-binary fix (5-layer) — unlock non-077 near-miss grinding
The grinder/backlog pipeline was ov_SC01_077-hardcoded 5 layers deep (same class as the
T7 lora_grind bug). Fixed all so the permuter grinder can process a non-077 near-miss:
1. gate_stage.append_record stores the source "binary"
2. backlog.FIELDS keeps it (else append_record dropped it)
3. backlog.load_best/_open_stubs is fleet-aware: a fn matched in ov_SC01_077 but
   propagation-stuck stays OPEN in its overlay, so it surfaces via that record instead
   of being dropped as "matched" (the grinder must SEE it to grind it)
4. p16_permute.setup takes the target binary's asm-subdir (was hardcoded 077)
5. grinder resolves per-binary asm + gates grouped by binary + allows unknown nins
Backward-compatible: legacy records (no binary) default ov_SC01_077.

Validated end-to-end: the 3 fresh reach-134 close=1 ov_SC01_000 fns now surface, resolve
to ov_SC01_000's asm, and gate via ov_SC01_000.

TWO byte-evidenced findings (redirect the fuel strategy):
- the reach>=2 close=1 fuel is MODEL semantic-misses, not permuter fuel: func_8012E27C's
  target is "return 1" but the 7B drafted an empty "void f(void){}" (corpus overfit
  empty-leaf); func_8012BF4C/AD64 are trivial sw/sh setters drafted empty. A corrected
  draft banks them (+3 byte-identical via the fixed gate, @commit:0326); the permuter cannot
  add a missing return/store. Lever = corpus-v3 leaf variety, not the permuter.
- x reach is propagation-capped: the 3 are inline-matched in ov_SC01_077_a.c (the stuck-
  local cap) -> dedup_propagate "nothing to propagate" -> banked x1. Lever = dedup-collapse.

check-all 136/136 throughout. docs/gen2-mips-matching-model.md + CURRENT_PHASE updated.
2026-06-30 00:58:13 -06:00
Drew T 117081c7d8 feat(phase-23): grinder gate — +3 fns x0 propagated (fleet 63.67%) 2026-06-30 00:52:14 -06:00
Drew T 64cc91ee83 feat(phase-22): close — tractable giants banked ×134 (fleet 63.18->63.66%), irreducible tail byte-deferred; pivot to the LLM tier (v1.21.0)
- BANKED ×134 (~17 fns): func_8015126C (canonical-extern recovery) + func_80156B74/func_80163C2C
  (struct type-lift -> engine_types.h) + the 14-fn close=0 recovery batch (recover_giant.py). 136/136
  byte-identical, dedup-check 1633/0, 0 NON_MATCHING throughout.
- IRREDUCIBLE GIANTS byte-deferred w/ evidence: func_80132784 (hoist-vs-remat + reg-lifetime),
  func_801372B0 (scheduler last-mile, structural draft banked), func_8014F74C (masked). gcc-2.7.2
  intrinsic walls -> backlog, not effort gaps. Grinder ROI audit: 7 all-time banks (all Phase 21), 0 since.
- TOOLKIT: recover_giant.py + the engine_types.h type-lift lever; cookbook §28/§28a/§28b/§28c.
  gate_stage commit tag made phase-agnostic (GATE_PHASE).
- PIVOT: Phase 23 = the offline LLM matching tier (built this session; see CURRENT_PHASE.md).
- worklog -> phase-ends/logs/Phase22.md (R19); bumps project version 1.20.0 -> 1.21.0
2026-06-30 00:26:49 -06:00
Drew T 366f7e4c7f feat(phase-23): T9 — reach>=2 targeting (lora_grind --min-reach); shared-code is the model's weak band
Add a sig-based reach oracle + --min-reach N to lora_grind so the mass-run can prefer
SHARED functions (one bank propagates x reach — the fleet-% multiplier). The oracle reads
the same .run/sig.ov_*.jsonl dedup_propagate uses (validated: 0 mismatch over 60 stubs +
the func_8017CE24=2 ground truth), so a reach>=N target is exactly one dedup_propagate
will stamp x reach after the bank.

Bounded reach>=2 mass-run (ov_SC01_000, 15 shared <=15-ins stubs): 0/15 banked, vs the
reach-1-heavy spot-run's 7/15. The model is weakest exactly on reach>=2 (shared) code:
(1) the corpus skipped the shared DEFINE_func macro bodies (export_pairs reads only src/
defs -> 96.6% of the corpus is overlay-unique), and (2) the shared engine fns are the
harder regalloc/schedule residuals. So reach>=2 model-only is NOT a fleet lever by itself.

BUT the reach>=2 drafts are high-value FUEL: 5/15 are close<=3 reach-134 near-misses
(3x close=1: func_8012E27C/BF4C/AD64) -> x134 each if closed. The real lever is
reach>=2 draft -> permuter-grinder close (x134), which needs the SAME per-binary fix T7
applied to lora_grind: grinder.py calls run_gate with no binary (-> 077) and the backlog
stores no binary field. That two-part fix is the next step. byte-neutral: check-all 136/136.

- docs/gen2-mips-matching-model.md: T9 RESULT
- phase-ends/CURRENT_PHASE.md: T9 done; next = grinder per-binary fix, then corpus-v3
2026-06-30 00:12:45 -06:00
Drew T bff03dbdb5 fix(phase-23): T7 — lora_grind broad-rotation banking (two gate bugs); ov_SC01_000 7/15
The 500-fn calibration banked 0/222 across the binary rotation. Root-caused (R14, by
reading the code + the run's own backlog — resolving a flat contradiction between two
scout agents) to TWO independent bugs in lora_grind's use of gate_stage.run_gate, NOT
model quality:
- Bug A: good_sha() passed the sha1sum line "<sha>  <name>" vs harvest_verify's bare
  sha1() -> 0 banks for EVERY binary incl. 077 (so the "0/12" was a bug artifact, not
  an exhausted tail)
- Bug B: the gate call left src/asm/out at the hardcoded ov_SC01_077 defaults -> non-077
  drafts dropped at the 077 stub-filter, silently (and the asm mis-resolution contaminated
  the backlog near-miss classification)

Fix (tools/gate_stage.py): run_gate resolves src/asm/out/good_sha from `binary` when unset
(binary-agnostic, no silent ov_SC01_077 default an overlay inherits; good_sha bare-hash
normalized) + a loud negative-control guard (0-overlap binary/src mismatch warns, so a 0
can never again masquerade as 'nothing matched'). tools/lora_grind.good_sha fixed at source.
Byte-neutral: make check-all 136/136.

Proof: ov_SC01_000 spot-run banked 7/15 (47%) byte-identical (@commit:0322); reach-2
func_8017CE24 propagated x2. ROI finding: 6/7 banks are reach-1 (overlay-unique) -> broad
rotation is high bank-RATE / low fleet-% ROI; the fleet lever is reach>=2 targeting (T9) +
corpus-v3 (T8). Backlog now correctly classified (4x close=1 = grinder fuel).

- docs/gen2-mips-matching-model.md: T7 RESULT section
- phase-ends/CURRENT_PHASE.md: T7 done; next = T8 corpus-v3 / T9 reach>=2 selection
2026-06-29 23:44:12 -06:00
Drew T 8016481036 feat(phase-23): lora-grind gate — +7 fns x0 propagated (fleet 63.67%) 2026-06-29 23:32:57 -06:00
Drew T edd62ef992 feat(phase-22): lora_grind.py — the free local-model mass-run (draft source for the grinder flywheel)
Rotates over every binary with open small stubs, drafts with the fine-tuned model (api_draft LEAN, GPU
via LM Studio), banks via gate_stage, propagates fleet-wide periodically. Near-misses -> backlog ->
grinder.py permuter closes regalloc/schedule residuals (synergy). Writes a classified near-miss
histogram (the 'missing idioms' signal -> corpus-v3 priorities). STOP/heartbeat/stats like grinder.py.
Smoke OK; histogram shows struct(49)+schedule/regalloc(94) dominate the backlog.
2026-06-29 22:10:05 -06:00
Drew T b4c312a30c feat(phase-22): FIRST free-local-model banks — 4 open stubs matched by the v2 LoRA
The fine-tuned 7B (bfm-match-7b-v2) drafted real OPEN ov_SC01_077 stubs; whole-binary gate banked 4
(func_80160B34 func_8015CC74 func_8016084C func_801705C0). Sample: 9/22 match_one proxy -> 4/22
whole-binary banked (18%; the proxy->gate gap is the TU-plumbing wall). Model is format-robust (raw .s
== normalized). api_draft: NORMALIZE_ASM bridge (unused — model handles raw .s) + ghidra_c-empty fix.
2026-06-29 21:58:09 -06:00
Drew T 6a45497a1e docs(phase-22): corpus-v2 result — POSITIVE, data was the bottleneck
Extern-block capture: compile 52->92%, train 638->1111 (non-trivial 257->813). SAME 7B retrained:
6-15 ins 0%->85%, non-trivial 0->26, meaningful(>15) 0->3. A free local 7B now matches trivial+
small-medium (<=15 ins) at 85-93% (rivals Haiku at $0). Limits: >=16 ins falls off (7B capacity),
giants compile-fail (need struct types = v3). Decision gate=GO: scale to cloud dense 14-32B.
2026-06-29 21:33:21 -06:00
Drew T 748dece7fc feat(phase-22): train_lora auto-cleans GGUF intermediates (the ~30GB that crashed C:) 2026-06-29 20:07:48 -06:00
Drew T 8537706006 feat(phase-22): corpus-v2 — capture the extern block above each def (self-contained completions)
The pilot failed because the compile-filter dropped the 536 hard (global/struct) fns: bare defs
reference undeclared D_xxxx globals -> cc1 error. The src declares them as 'extern <type> D_xxx;'
immediately ABOVE each def with correct byte-verified types. Capturing that contiguous extern block
lifts standalone-compile 52%->92% (16/40 hard fns recovered) AND teaches the model to declare globals
with the right types (a real matching skill). Fixes the trivial-bias that capped the 7B pilot.
2026-06-29 20:03:53 -06:00
Drew T 0a75c2470d docs(phase-22): LoRA pilot result — NEGATIVE on meaningful fns (corpus-starved)
7B QLoRA on 638 compile-filtered pairs: trivial ≤5-ins 39/41, but ≥6 ins 0/34, >15 ins 0/24 (=stock);
near-misses far (near≈nins). Root cause: compile-filter dropped the 536 harder global/struct fns →
no non-trivial signal. Fix = corpus-v2 (externs). Cheap-cloud (Haiku/GLM) remains the working tier.
2026-06-29 19:43:59 -06:00
Drew T 803be6341c feat(phase-22): eval_lora held-out scorer (validated) + train_lora --max-steps
eval_lora.py: feeds a fine-tuned model the LEAN asm of held-out BANKED test fns, compiles its C,
compares to the corpus target reloc-masked (banked fns have no .s — corpus carries the asm). Validated:
known-good corpus C scores MATCH vs its own asm. train_lora --max-steps for smoke runs. GPU confirmed
(3080 Ti, torch 2.10+cu128); install + corpus-filter (638/75 clean pairs) done; smoke-train running.
2026-06-29 16:49:11 -06:00
Drew T dfd97226cc feat(phase-22): format_finetune compile-filter — keep only standalone-compilable pairs
Found 50% of bare-def corpus completions fail standalone compile (undeclared globals/structs — externs
lived in TU headers). Filtering to compile-verified pairs so the pilot LoRA learns to emit COMPILABLE
matching C, not uncompilable bodies. (Drops harder struct/global fns; corpus v2 = add externs to recover.)
2026-06-29 16:43:19 -06:00
Drew T 1c80b25ac6 feat(phase-22): LoRA specialist pilot tooling — format_finetune + train_lora + api_draft LEAN
format_finetune.py: corpus -> Qwen chat-template instruction JSONL (lean asm->C, 1174 train/133 test).
train_lora.py: Unsloth QLoRA recipe (Qwen2.5-Coder-7B 4-bit, fits 12GB; merges to GGUF for LM Studio).
api_draft.py LEAN=1: ~350-tok asm-only prompt matching the training shape (fine-tuned model needs no
inlined cookbook -> fast). Datasets gitignored. Eval: beat stock-local ~0 on the held-out frozen 20.
2026-06-29 16:35:06 -06:00
Drew T 671177aece docs(phase-22): capture stock-local-model floor — 0 reliable banks, motivates the LoRA specialist
Qwen3.6-35B-A3B stock drafter: fair harness fixed compiles but model stuck at fixed near-misses
(can't refine from diff); full cookbook worse+2.3x slower than curated (dilution). Gets structure,
misses gcc-2.7.2 precision — exactly what src-pair LoRA targets. Forward: fine-tune or permuter-seed.
2026-06-29 16:26:29 -06:00
Drew T 4895843dda feat(phase-22): api_draft fair-harness — inline common.h + live cookbook + corpus examples
Gives the no-tool local model the context the agents read: common.h, live matching cookbook
(COOKBOOK_FULL toggle), 2 byte-matched corpus examples. Qwen3.6-35B-A3B result: harness fixes
compile-fails but model stays stuck at fixed near-misses; FULL cookbook worse+2.3x slower than
curated (dilution, gate-confirmed). Bottleneck is model refinement, not context.
2026-06-29 16:24:37 -06:00
Drew T ad535ad1ab feat(phase-22): gen2 matching-model design + export_pairs.py corpus miner
docs/gen2-mips-matching-model.md: the BFM/gcc-2.7.2 matching-specialist idea (LoRA on our own
gate-verified pairs — the corpus off-the-shelf RE LLMs lack). export_pairs.py mines 1307 banked
(asm<->C) pairs from build objects (asm/ is gitignored, so disasm the ROM-identical build, splat-like
format) + src defs -> datasets/match_pairs/{pairs,train,test}.jsonl (gitignored, 1174/133 split).
api_draft.py: TEMP env-tunable. .gitignore: datasets/ models/ weights.
2026-06-29 14:27:19 -06:00
Drew T 3549f756f7 feat(phase-22): api_draft.py — provider-agnostic draft worker (local/OpenRouter)
Script equivalent of one worker_wave drafter for any OpenAI-compatible endpoint (LM Studio /
llama.cpp / vLLM / OpenRouter). Inlines asm+ghidra_c+toolkit, calls /chat/completions, extracts C,
iterates against match_one (diff fed back, keep best). Output scores as a 'local'/'glm' arm via
ab_score.py. Env: API_BASE/API_KEY/MODEL. Logic self-tested; HTTP is standard OpenAI format.
2026-06-29 13:05:18 -06:00
Drew T f154822f7b feat(phase-22): cheap-tier A/B experiment harness + findings
ab_match.js (per-arm-model fan-out fork of worker_wave) + ab_score.py (disk-truth
match_one scorer, --measured for real $). Haiku drafters vs Opus on 20 reach1 fns:
proxy 10 vs 15 matches, Haiku ~4.8x more matches/$, parity on <=52-ins band. Whole-binary
gate banked 4 (proxy over-counts; TU-plumbing wall). backlog/fleet refreshed.
2026-06-29 12:52:39 -06:00
Drew T 6d5fe3dfde feat(phase-22): bank 4 fns from cheap-tier A/B experiment (byte-verified, fleet 63.66->63.67)
Whole-binary SHA gate (gate_stage) banked 4 of 15 match_one-proxy matches:
func_80138BE0 func_8012F828 func_8012E9C0 (ov_SC01_077_a) + func_80141100 (main).
The other 11 are self-match-but-gate-rejected (TU declaration plumbing); logged to
the backlog as recovery fuel. ov_SC01_077 stays byte-identical (d19c9580).
2026-06-29 12:51:40 -06:00
Drew T cac25bd74b docs(phase-22): grinder stopped (clean) + ROI audit — 7 banks all-time, 2 bugs logged 2026-06-27 14:31:54 -06:00
Drew T a126d2170d docs(phase-22): correct cookbook §28b-6 — the dedup_propagate registry-skip is independent of concurrent make (R14, per §28c) 2026-06-26 22:25:17 -06:00
Drew T 20037480cf docs(phase-22): log func_801372B0 structural near-miss (giant scheduler-wall) + session checkpoint
- from-scratch giant func_801372B0 (207): structurally cracked at xHigh (206/207 ins,
  logic 100%%) but byte-blocked by the gcc list-scheduler/regalloc last-mile (§27/§17);
  banked the structural draft to backlog as a future permuter head-start
- xHigh finding (Drew's test): giants reach structural match fast — the wall is gcc
  determinism, not reasoning depth; xHigh sufficient for this work
- session total: 16 functions ×134 (2 giants type-lift + 14 close=0), fleet 63.22%->63.66%
2026-06-26 10:01:01 -06:00
Drew T 23ba3cc677 chore(phase-22): refresh worklist after close=0 batch (441 live stubs, fleet 63.66%) 2026-06-26 04:15:54 -06:00
Drew T c1230fa6ea feat(phase-22): T2 close=0 recovery batch — 14 fns ×134 (fleet 63.29%->63.66%)
- R14 corrects cookbook §26 ('close=0 recovery exhausted'): recover_giant + the
  whole-binary gate still banks a ~15-20%% tail. Banked 7 close=0 reach-134 fns
  (func_80156ECC/80147E44/8015ADB0/801661CC/80166054/8012CFA8/8012A62C); dedup_propagate
  --auto-from swept those + 7 pre-existing inline-matched bonus fns ×134 (14 total)
- the other ~33 close=0 are the genuine DEF-side loose-typing / masked-residual wall
- func_80132784 HARD-DEFER (hoist-vs-remat + register-lifetime-reuse not C-expressible)
- §28c distilled: close=0-not-exhausted recipe + the dedup_propagate registry-skip
  recovery (register via append_groups; bytes were already check-all-correct)
- make check-all 136/136 byte-identical (R22); dedup 1619->1633 validated/0 failed;
  0 NON_MATCHING (G4)
2026-06-26 04:14:06 -06:00
Drew T d789d9c242 feat(phase-22): T2 — giant func_80163C2C banked ×134 via Blk16/Buf32 type-lift (fleet 63.25%->63.29%)
- second struct-walled close=0 giant (167 ins): lift Blk16(u32x4)+Buf32(2xBlk16) to
  src/shared/engine_types.h, remove the Blk16 dupes from ov_SC01_077.c + the -O0 split
  ov_SC01_077_a.c (byte-neutral), recover_giant, harvest_verify MATCH, dedup_propagate
  ×134 (+22378 ins byte-weighted)
- struct-walled trio done: func_80156B74 + func_80163C2C banked; func_8014F74C is a
  masked residual (grinder fuel, not type-liftable)
- make check-all 136/136 byte-identical (R22); dedup 1618->1619 validated/0 failed;
  0 NON_MATCHING (G4)
2026-06-26 03:51:11 -06:00