mirror of
https://github.com/Druthulu/BFM-decomp
synced 2026-09-26 13:33:34 -04:00
897939eb46
- T5b measure-wave over the <=149-ins cheap tier (83 targets, generated §12-robust t5_scaleup.js, Opus xHigh). Drew stopped at ~50 on HTTP-529 overload; processed the 54 landed drafts (0 truncated) as T5b. - 46/54 match_one-MATCH (85%); gate banked 16 clean (main 1, _a 10, _after 5) + family_sweep +1861 siblings/1 fail across 133 overlays (14 exemplars, ~0 tokens). - R22 clean-fleet 136/136 byte-identical; dedup-check 1813/0; 0 NON_MATCHING (G4). - frontier map now 64 exemplars measured (.run/t5_frontier.jsonl). Def-side loose-typing wall confirmed dominant at scale (~30/46 match_one-MATCH gate-rejected -> backlog); fleet-wide caller-decl reconcile = the #1 T7 lever. 8 near-miss -> permuter fuel (T5c). - more T5b batches (29 cheap + 34 giants + 5 _o0) + T5c/T5d -> T6 remain (phase OPEN)
116 lines
25 KiB
JavaScript
116 lines
25 KiB
JavaScript
export const meta = {
|
||
name: 't5-scaleup-wave',
|
||
description: 'Phase-21 worker wave: fan out toolkit-aware drafter agents over a target batch; each writes its best matching C to the drafts dir. The orchestrator runs gate_stage on the dir afterward (byte-gate + propagate + backlog).',
|
||
phases: [
|
||
{ title: 'Draft', detail: 'one xHigh drafter agent per target' },
|
||
],
|
||
}
|
||
|
||
// args = { targets: [{name, addr, nins, class, asm, ghidra_c}], draftDir }
|
||
// Returns { draftDir, n, drafted: [{fn,status,closeness,klass,where_stuck}] }.
|
||
// NOTE: drafting only. The byte-gate / propagate / backlog (gate_stage.py) is run by the
|
||
// ORCHESTRATOR after this returns — it mutates+commits the byte-locked tree and must be
|
||
// serial (one wave at a time), and its build loop can exceed an agent's Bash timeout.
|
||
|
||
const DRAFT_SCHEMA = {
|
||
type: 'object', additionalProperties: false,
|
||
required: ['fn', 'status'],
|
||
properties: {
|
||
fn: { type: 'string' },
|
||
status: { type: 'string', enum: ['match', 'near', 'fail'] },
|
||
closeness: { type: 'integer', description: 'final match_one mismatch count; 0 if MATCH' },
|
||
klass: { type: 'string', description: 'residual class: regalloc-order|schedule|struct|loose-typing|plumbing|other' },
|
||
where_stuck: { type: 'string', description: 'one line: what is still off (for the backlog)' },
|
||
},
|
||
}
|
||
|
||
const ASM_SUBDIR = 'asm/ov_SC01_077/nonmatchings/ov_SC01_077'
|
||
|
||
function drafterPrompt(t, draftDir) {
|
||
const prior = t.prior_stuck
|
||
? `\nPRIOR ATTEMPT got stuck here (closeness ${t.prior_closeness}): "${t.prior_stuck}". This is a CLASS-FOCUSED re-attempt — concentrate on that residual; the cookbook may now have a newly-distilled idiom for it.\n`
|
||
: ''
|
||
const giant = t.class === 'GIANT'
|
||
? `\nGIANT (>150 ins) — READ COOKBOOK §27 (the giant recipe) TOO. Key moves, in order:
|
||
(1) The cached Ghidra-C body structure is usually CORRECT (straight-line + many calls) — start from it.
|
||
(2) ARG-ARITY is the #1 giant blocker: declare each callee to match the ACTUAL call site — count the $a0-$a3
|
||
(+ stack) registers SET before each \`jal\`, NOT a canonical guess. e.g. a helper called with 3 args (a3
|
||
untouched in the asm) -> declare it 3-arg. (The gate reconciles the shared-header canonical later.)
|
||
(3) SIBLING TEMPLATES: grep src/shared/engine_core.h for an already-matched DEFINE_func_* in the same family
|
||
(GPU-packet builder, coord transform) and MIRROR its proven C — e.g. coord strength-reduce
|
||
\`((s32)(D * 10355) << 1) >> 16\`, GPU linked-list pointer \`((u32)addr & 0xFFFFFF) | 0x3000000\`.
|
||
(4) §17-pin the regalloc-SHIFT (whole-hog param->wrong-$s reg), BUT do NOT pin a var whose register the target
|
||
REUSES for a later spill (pinning reserves it -> gcc grabs an EXTRA callee reg). The last-mile residual is
|
||
usually regalloc-COALESCING (one extra callee reg for an accumulator spill) -> get STRUCTURALLY-matched and
|
||
leave the best draft; the gate + permuter grinder finish that mile.\n`
|
||
: ''
|
||
// Region-aware: split-file (_a/_o0) targets carry their own asm subdir in t.asm
|
||
// (asm/ov_SC01_077/nonmatchings/ov_SC01_077_a/<fn>.s). Derive the dir so the match_one
|
||
// self-check finds the right .s; fall back to the main subdir if t.asm is absent.
|
||
const asmSubdir = (t.asm && t.asm.indexOf('/') >= 0) ? t.asm.replace(/\/[^/]+$/, '') : ASM_SUBDIR
|
||
return `Match ONE MIPS function for the Brave Fencer Musashi PS1 matching decompilation (overlay ov_SC01_077).
|
||
GOAL: write C that the pinned compiler (gcc-2.7.2-psx -O2 -G0 -mips1 -mcpu=3000 -mgas -msoft-float -fgnu-linker + maspsx --aspsx-version=2.56 --expand-div) compiles to BYTE-IDENTICAL machine code.
|
||
|
||
TARGET: ${t.name} @ ${t.addr} — ${t.nins} instructions, class hint "${t.class}".${prior}${giant}
|
||
- Target asm (the ground truth): ${t.asm}
|
||
(each line "/* off vaddr w0 w1 */ mnemonic ..." shows the exact encoded instructions.)
|
||
- Ghidra-C reference (types/locals/callee names — NOT byte-accurate, a scaffold): ${t.ghidra_c}
|
||
|
||
THE TOOLKIT (docs/matching-cookbook.md §17–§20 — read those sections for depth; the high-leverage moves):
|
||
- Register-allocation ORDER: if call-crossing locals land in the wrong saved reg vs the target,
|
||
PIN them: \`register s32 v __asm__("$16");\` ($16=$s0,$17=$s1,$18=$s2,…). Add a scheduling barrier
|
||
(a dummy volatile read or reordering) if the schedule is off. THIS is the highest-reach lever.
|
||
- Array-of-struct %lo-fold (§18): for indexed global access, declare \`extern Struct base[];\`
|
||
(sizeof(Struct)==stride) and write \`base[i].field\` — folds %lo into the load/store. Do NOT write
|
||
\`*(T*)(&sym + i*stride)\` (that materializes &sym and adds an instruction).
|
||
- For-loop vs do-while (§17): \`for(init;cond;upd)\` schedules the back-branch into the delay slot
|
||
differently than a do-while; pick the loop form the target's branch layout implies.
|
||
- Statement / for-update order: independent statements emit in source order — reorder to match.
|
||
- Declaration plumbing: don't fret callee extern types — the gate's canon_resident_calls +
|
||
cast_call_sites + sig_unify fix most extern/arity mismatches. Focus on the BODY codegen.
|
||
|
||
PROCESS (you have Bash + Read):
|
||
0. Read the LIVE cookbook docs/matching-cookbook.md §17–20 FIRST (and §27 if this is a GIANT) — it accrues newly-distilled idioms between waves; a quirk you'd otherwise grind on may already be solved there.
|
||
1. Read the target asm and the Ghidra-C.
|
||
2. Write your best C (the function definition + any externs it needs) to: ${draftDir}/${t.name}.c
|
||
(Write ONLY this one draft file. Do NOT edit docs/matching-cookbook.md, src/, config/, or any other tracked
|
||
file — the orchestrator's distill step owns all cookbook updates; a drafter appending to the cookbook injects
|
||
UNVERIFIED near-miss idioms that pollute every future wave. Your deliverable is the draft .c and the return value.)
|
||
START the file with TWO comment lines so the residual class travels with the draft (the gate reads them for the learning flywheel + backlog):
|
||
// @class: <one of: regalloc-order | schedule | remat | struct | iv-combine | loop-guard | loose-typing | plumbing | other>
|
||
// @stuck: <one concrete line on the residual that remains, or "none — MATCH">
|
||
3. Self-check (fast relocation-masked proxy for the byte-gate):
|
||
.venv/bin/python tools/match_one.py ${t.name} --c ${draftDir}/${t.name}.c --asm-subdir ${asmSubdir}
|
||
- "MATCH (N ins)" => byte-identical (relocation-masked). You nailed it. Stop.
|
||
- "N mismatched" => N instructions differ. Apply the toolkit, iterate to reduce N.
|
||
4. Iterate a few times; KEEP THE BEST draft in the file (always leave a file, even if imperfect —
|
||
the whole-binary gate + the permuter grinder may finish it; a close near-miss is logged for a human).
|
||
5. Return: { fn, status (match|near|fail), closeness (final mismatch count), klass, where_stuck }.
|
||
|
||
The whole-binary byte-gate (run later) is the sole arbiter — match_one is a proxy, but a MATCH there
|
||
almost always banks. Be rigorous; never fabricate a MATCH you didn't observe.`
|
||
}
|
||
|
||
|
||
const targets = [{"name": "func_8016F0AC", "addr": "0x8016f0ac", "nins": 14, "class": "tiny", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077_after/func_8016F0AC.s", "ghidra_c": ".run/ghidra_c/func_8016F0AC.c", "instances": 136}, {"name": "func_80178B70", "addr": "0x80178b70", "nins": 18, "class": "tiny", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077_after/func_80178B70.s", "ghidra_c": ".run/ghidra_c/func_80178B70.c", "instances": 134}, {"name": "func_801336E8", "addr": "0x801336e8", "nins": 21, "class": "small", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077_a/func_801336E8.s", "ghidra_c": null, "instances": 134}, {"name": "func_80163408", "addr": "0x80163408", "nins": 21, "class": "small", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077_after/func_80163408.s", "ghidra_c": ".run/ghidra_c/func_80163408.c", "instances": 134}, {"name": "func_801288E8", "addr": "0x801288e8", "nins": 22, "class": "small", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077_a/func_801288E8.s", "ghidra_c": null, "instances": 134}, {"name": "func_80128940", "addr": "0x80128940", "nins": 22, "class": "small", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077_a/func_80128940.s", "ghidra_c": null, "instances": 134}, {"name": "func_80128998", "addr": "0x80128998", "nins": 22, "class": "small", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077_a/func_80128998.s", "ghidra_c": null, "instances": 134}, {"name": "func_80137B80", "addr": "0x80137b80", "nins": 22, "class": "small", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077_a/func_80137B80.s", "ghidra_c": null, "instances": 134}, {"name": "func_80178B18", "addr": "0x80178b18", "nins": 22, "class": "small", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077_after/func_80178B18.s", "ghidra_c": ".run/ghidra_c/func_80178B18.c", "instances": 134}, {"name": "func_8017B8E8", "addr": "0x8017b8e8", "nins": 22, "class": "small", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077_after/func_8017B8E8.s", "ghidra_c": ".run/ghidra_c/func_8017B8E8.c", "instances": 134}, {"name": "func_80182988", "addr": "0x80182988", "nins": 22, "class": "small", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077_after/func_80182988.s", "ghidra_c": ".run/ghidra_c/func_80182988.c", "instances": 3}, {"name": "func_8012ACE0", "addr": "0x8012ace0", "nins": 25, "class": "small", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077_a/func_8012ACE0.s", "ghidra_c": null, "instances": 134}, {"name": "func_80164E40", "addr": "0x80164e40", "nins": 25, "class": "small", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077_after/func_80164E40.s", "ghidra_c": ".run/ghidra_c/func_80164E40.c", "instances": 134}, {"name": "func_80182338", "addr": "0x80182338", "nins": 26, "class": "small", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077_after/func_80182338.s", "ghidra_c": ".run/ghidra_c/func_80182338.c", "instances": 3}, {"name": "func_801312D0", "addr": "0x801312d0", "nins": 28, "class": "small", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077_a/func_801312D0.s", "ghidra_c": ".run/ghidra_c/func_801312D0.c", "instances": 134}, {"name": "func_80136C90", "addr": "0x80136c90", "nins": 28, "class": "small", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077_a/func_80136C90.s", "ghidra_c": ".run/ghidra_c/func_80136C90.c", "instances": 134}, {"name": "func_8018301C", "addr": "0x8018301c", "nins": 28, "class": "small", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077_after/func_8018301C.s", "ghidra_c": ".run/ghidra_c/func_8018301C.c", "instances": 3}, {"name": "func_80165140", "addr": "0x80165140", "nins": 30, "class": "small", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077_after/func_80165140.s", "ghidra_c": ".run/ghidra_c/func_80165140.c", "instances": 134}, {"name": "func_801549F8", "addr": "0x801549f8", "nins": 31, "class": "small", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077_after/func_801549F8.s", "ghidra_c": ".run/ghidra_c/func_801549F8.c", "instances": 134}, {"name": "func_8012DDA4", "addr": "0x8012dda4", "nins": 34, "class": "small", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077_a/func_8012DDA4.s", "ghidra_c": null, "instances": 134}, {"name": "func_8012DE2C", "addr": "0x8012de2c", "nins": 35, "class": "small", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077_a/func_8012DE2C.s", "ghidra_c": null, "instances": 134}, {"name": "func_8016E95C", "addr": "0x8016e95c", "nins": 36, "class": "small", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077_after/func_8016E95C.s", "ghidra_c": ".run/ghidra_c/func_8016E95C.c", "instances": 134}, {"name": "func_801285E4", "addr": "0x801285e4", "nins": 37, "class": "small", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077_a/func_801285E4.s", "ghidra_c": null, "instances": 134}, {"name": "func_80140E6C", "addr": "0x80140e6c", "nins": 37, "class": "small", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077/func_80140E6C.s", "ghidra_c": ".run/ghidra_c/func_80140E6C.c", "instances": 134}, {"name": "func_8016BEA0", "addr": "0x8016bea0", "nins": 37, "class": "small", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077_after/func_8016BEA0.s", "ghidra_c": ".run/ghidra_c/func_8016BEA0.c", "instances": 134}, {"name": "func_80128714", "addr": "0x80128714", "nins": 41, "class": "small", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077_a/func_80128714.s", "ghidra_c": null, "instances": 134}, {"name": "func_8012D664", "addr": "0x8012d664", "nins": 44, "class": "small", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077_a/func_8012D664.s", "ghidra_c": null, "instances": 134}, {"name": "func_8016B4F8", "addr": "0x8016b4f8", "nins": 50, "class": "med", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077_after/func_8016B4F8.s", "ghidra_c": ".run/ghidra_c/func_8016B4F8.c", "instances": 134}, {"name": "func_80137D08", "addr": "0x80137d08", "nins": 51, "class": "med", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077_a/func_80137D08.s", "ghidra_c": null, "instances": 134}, {"name": "func_80158FA4", "addr": "0x80158fa4", "nins": 51, "class": "med", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077_after/func_80158FA4.s", "ghidra_c": ".run/ghidra_c/func_80158FA4.c", "instances": 134}, {"name": "func_8017EF50", "addr": "0x8017ef50", "nins": 53, "class": "med", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077_after/func_8017EF50.s", "ghidra_c": ".run/ghidra_c/func_8017EF50.c", "instances": 3}, {"name": "func_8016BBE0", "addr": "0x8016bbe0", "nins": 56, "class": "med", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077_after/func_8016BBE0.s", "ghidra_c": ".run/ghidra_c/func_8016BBE0.c", "instances": 134}, {"name": "func_8012FCC4", "addr": "0x8012fcc4", "nins": 57, "class": "med", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077_a/func_8012FCC4.s", "ghidra_c": null, "instances": 134}, {"name": "func_80134510", "addr": "0x80134510", "nins": 58, "class": "med", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077_a/func_80134510.s", "ghidra_c": null, "instances": 134}, {"name": "func_8015D01C", "addr": "0x8015d01c", "nins": 58, "class": "med", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077_after/func_8015D01C.s", "ghidra_c": ".run/ghidra_c/func_8015D01C.c", "instances": 134}, {"name": "func_8016D688", "addr": "0x8016d688", "nins": 60, "class": "med", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077_after/func_8016D688.s", "ghidra_c": ".run/ghidra_c/func_8016D688.c", "instances": 134}, {"name": "func_8017B0E4", "addr": "0x8017b0e4", "nins": 61, "class": "med", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077_after/func_8017B0E4.s", "ghidra_c": ".run/ghidra_c/func_8017B0E4.c", "instances": 134}, {"name": "func_801287B8", "addr": "0x801287b8", "nins": 62, "class": "med", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077_a/func_801287B8.s", "ghidra_c": null, "instances": 134}, {"name": "func_80135168", "addr": "0x80135168", "nins": 62, "class": "med", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077_a/func_80135168.s", "ghidra_c": null, "instances": 134}, {"name": "func_8013CF68", "addr": "0x8013cf68", "nins": 63, "class": "med", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077/func_8013CF68.s", "ghidra_c": ".run/ghidra_c/func_8013CF68.c", "instances": 134}, {"name": "func_8013E958", "addr": "0x8013e958", "nins": 63, "class": "med", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077/func_8013E958.s", "ghidra_c": ".run/ghidra_c/func_8013E958.c", "instances": 134}, {"name": "func_80165240", "addr": "0x80165240", "nins": 63, "class": "med", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077_after/func_80165240.s", "ghidra_c": ".run/ghidra_c/func_80165240.c", "instances": 134}, {"name": "func_8017B940", "addr": "0x8017b940", "nins": 63, "class": "med", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077_after/func_8017B940.s", "ghidra_c": ".run/ghidra_c/func_8017B940.c", "instances": 134}, {"name": "func_8017BB34", "addr": "0x8017bb34", "nins": 65, "class": "med", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077_after/func_8017BB34.s", "ghidra_c": ".run/ghidra_c/func_8017BB34.c", "instances": 134}, {"name": "func_8012E364", "addr": "0x8012e364", "nins": 67, "class": "med", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077_a/func_8012E364.s", "ghidra_c": null, "instances": 134}, {"name": "func_80166F58", "addr": "0x80166f58", "nins": 69, "class": "med", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077_after/func_80166F58.s", "ghidra_c": ".run/ghidra_c/func_80166F58.c", "instances": 134}, {"name": "func_8013E83C", "addr": "0x8013e83c", "nins": 71, "class": "med", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077/func_8013E83C.s", "ghidra_c": ".run/ghidra_c/func_8013E83C.c", "instances": 134}, {"name": "func_80156044", "addr": "0x80156044", "nins": 74, "class": "med", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077_after/func_80156044.s", "ghidra_c": ".run/ghidra_c/func_80156044.c", "instances": 134}, {"name": "func_8016BD78", "addr": "0x8016bd78", "nins": 74, "class": "med", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077_after/func_8016BD78.s", "ghidra_c": ".run/ghidra_c/func_8016BD78.c", "instances": 134}, {"name": "func_8016E7C8", "addr": "0x8016e7c8", "nins": 74, "class": "med", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077_after/func_8016E7C8.s", "ghidra_c": ".run/ghidra_c/func_8016E7C8.c", "instances": 134}, {"name": "func_8017B368", "addr": "0x8017b368", "nins": 74, "class": "med", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077_after/func_8017B368.s", "ghidra_c": ".run/ghidra_c/func_8017B368.c", "instances": 134}, {"name": "func_80180F10", "addr": "0x80180f10", "nins": 75, "class": "med", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077_after/func_80180F10.s", "ghidra_c": ".run/ghidra_c/func_80180F10.c", "instances": 3}, {"name": "func_80136A94", "addr": "0x80136a94", "nins": 76, "class": "med", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077_a/func_80136A94.s", "ghidra_c": null, "instances": 134}, {"name": "func_80141A60", "addr": "0x80141a60", "nins": 76, "class": "med", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077/func_80141A60.s", "ghidra_c": ".run/ghidra_c/func_80141A60.c", "instances": 134}, {"name": "func_8017B238", "addr": "0x8017b238", "nins": 76, "class": "med", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077_after/func_8017B238.s", "ghidra_c": ".run/ghidra_c/func_8017B238.c", "instances": 134}, {"name": "func_801457A4", "addr": "0x801457a4", "nins": 79, "class": "med", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077_after/func_801457A4.s", "ghidra_c": ".run/ghidra_c/func_801457A4.c", "instances": 134}, {"name": "func_8016C188", "addr": "0x8016c188", "nins": 79, "class": "med", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077_after/func_8016C188.s", "ghidra_c": ".run/ghidra_c/func_8016C188.c", "instances": 134}, {"name": "func_80164930", "addr": "0x80164930", "nins": 81, "class": "med", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077_after/func_80164930.s", "ghidra_c": ".run/ghidra_c/func_80164930.c", "instances": 134}, {"name": "func_801343C4", "addr": "0x801343c4", "nins": 83, "class": "med", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077_a/func_801343C4.s", "ghidra_c": null, "instances": 134}, {"name": "func_80131170", "addr": "0x80131170", "nins": 88, "class": "med", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077_a/func_80131170.s", "ghidra_c": null, "instances": 134}, {"name": "func_80131B14", "addr": "0x80131b14", "nins": 89, "class": "med", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077_a/func_80131B14.s", "ghidra_c": null, "instances": 134}, {"name": "func_80135004", "addr": "0x80135004", "nins": 89, "class": "med", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077_a/func_80135004.s", "ghidra_c": null, "instances": 134}, {"name": "func_801397B0", "addr": "0x801397b0", "nins": 89, "class": "med", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077_a/func_801397B0.s", "ghidra_c": null, "instances": 134}, {"name": "func_801418F8", "addr": "0x801418f8", "nins": 90, "class": "med", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077/func_801418F8.s", "ghidra_c": ".run/ghidra_c/func_801418F8.c", "instances": 134}, {"name": "func_8013EE10", "addr": "0x8013ee10", "nins": 94, "class": "med", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077/func_8013EE10.s", "ghidra_c": ".run/ghidra_c/func_8013EE10.c", "instances": 134}, {"name": "func_80185428", "addr": "0x80185428", "nins": 94, "class": "med", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077_after/func_80185428.s", "ghidra_c": ".run/ghidra_c/func_80185428.c", "instances": 10}, {"name": "func_8017B614", "addr": "0x8017b614", "nins": 101, "class": "large", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077_after/func_8017B614.s", "ghidra_c": ".run/ghidra_c/func_8017B614.c", "instances": 134}, {"name": "func_801345F8", "addr": "0x801345f8", "nins": 106, "class": "large", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077_a/func_801345F8.s", "ghidra_c": ".run/ghidra_c/func_801345F8.c", "instances": 134}, {"name": "func_80134A74", "addr": "0x80134a74", "nins": 107, "class": "large", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077_a/func_80134A74.s", "ghidra_c": ".run/ghidra_c/func_80134A74.c", "instances": 134}, {"name": "func_8013EF88", "addr": "0x8013ef88", "nins": 108, "class": "large", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077/func_8013EF88.s", "ghidra_c": ".run/ghidra_c/func_8013EF88.c", "instances": 134}, {"name": "func_80168828", "addr": "0x80168828", "nins": 108, "class": "large", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077_after/func_80168828.s", "ghidra_c": ".run/ghidra_c/func_80168828.c", "instances": 134}, {"name": "func_8013D178", "addr": "0x8013d178", "nins": 110, "class": "large", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077/func_8013D178.s", "ghidra_c": ".run/ghidra_c/func_8013D178.c", "instances": 134}, {"name": "func_8017BEF8", "addr": "0x8017bef8", "nins": 113, "class": "large", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077_after/func_8017BEF8.s", "ghidra_c": ".run/ghidra_c/func_8017BEF8.c", "instances": 33}, {"name": "func_8013AD38", "addr": "0x8013ad38", "nins": 122, "class": "large", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077_a/func_8013AD38.s", "ghidra_c": null, "instances": 134}, {"name": "func_8013EB7C", "addr": "0x8013eb7c", "nins": 124, "class": "large", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077/func_8013EB7C.s", "ghidra_c": ".run/ghidra_c/func_8013EB7C.c", "instances": 134}, {"name": "func_8017C710", "addr": "0x8017c710", "nins": 126, "class": "large", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077_after/func_8017C710.s", "ghidra_c": ".run/ghidra_c/func_8017C710.c", "instances": 15}, {"name": "func_80145CEC", "addr": "0x80145cec", "nins": 127, "class": "large", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077_after/func_80145CEC.s", "ghidra_c": ".run/ghidra_c/func_80145CEC.c", "instances": 134}, {"name": "func_80140F00", "addr": "0x80140f00", "nins": 128, "class": "large", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077/func_80140F00.s", "ghidra_c": ".run/ghidra_c/func_80140F00.c", "instances": 134}, {"name": "func_80133AB0", "addr": "0x80133ab0", "nins": 137, "class": "large", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077_a/func_80133AB0.s", "ghidra_c": null, "instances": 134}, {"name": "func_8013D9B0", "addr": "0x8013d9b0", "nins": 141, "class": "large", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077/func_8013D9B0.s", "ghidra_c": ".run/ghidra_c/func_8013D9B0.c", "instances": 134}, {"name": "func_80184F08", "addr": "0x80184f08", "nins": 145, "class": "large", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077_after/func_80184F08.s", "ghidra_c": ".run/ghidra_c/func_80184F08.c", "instances": 17}, {"name": "func_8016D1D8", "addr": "0x8016d1d8", "nins": 148, "class": "large", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077_after/func_8016D1D8.s", "ghidra_c": ".run/ghidra_c/func_8016D1D8.c", "instances": 134}, {"name": "func_8012C890", "addr": "0x8012c890", "nins": 149, "class": "large", "asm": "asm/ov_SC01_077/nonmatchings/ov_SC01_077_a/func_8012C890.s", "ghidra_c": null, "instances": 134}];
|
||
const draftDir = '.run/drafts-t5-scaleup';
|
||
log(`t5-scaleup: ${targets.length} targets -> ${draftDir} (waves of 10, Opus xHigh, retry x2)`);
|
||
phase('Draft');
|
||
function chunk(a,n){const o=[];for(let i=0;i<a.length;i+=n)o.push(a.slice(i,i+n));return o}
|
||
const drafted=[];
|
||
const waves=chunk(targets,10);
|
||
for (let w=0; w<waves.length; w++){
|
||
let pending=waves[w]; const got=new Map();
|
||
for (let attempt=0; attempt<3 && pending.length; attempt++){
|
||
const res=await parallel(pending.map(t=>()=>agent(drafterPrompt(t,draftDir),{label:`draft:${t.name}`,phase:'Draft',schema:DRAFT_SCHEMA,effort:'xhigh'}).then(r=>r?{...r,fn:r.fn||t.name}:null)));
|
||
const next=[]; res.forEach((r,i)=>{ if(r) got.set(pending[i].name,r); else next.push(pending[i]); });
|
||
pending=next;
|
||
log(`wave ${w+1}/${waves.length} attempt ${attempt+1}: ${got.size}/${waves[w].length} ok, ${pending.length} retry`);
|
||
}
|
||
drafted.push(...got.values());
|
||
}
|
||
const matched=drafted.filter(d=>d.status==='match').length;
|
||
const near=drafted.filter(d=>d.status==='near').length;
|
||
log(`t5-scaleup: ${drafted.length}/${targets.length} drafted; match=${matched} near=${near}`);
|
||
return {draftDir, n:drafted.length, matched, near, drafted};
|