Skip to content

pipeline: speed budget, draft-PR proposals, small-units worklist - #30

Merged
mahaloz merged 1 commit into
mainfrom
pipeline-extensions
Jun 25, 2026
Merged

mahaloz merged 1 commit into
mainfrom
pipeline-extensions

Conversation

@mahaloz

@mahaloz mahaloz commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Pipeline extensions: speed budget, draft-PR proposals, small-units worklist

Foundation for the multi-day angr→kuna feature loop. Closes two gaps between the existing
pipeline and our standing requirements, plus seeds a high-throughput small-units backlog.
Tooling-only (scripts/pipeline/, tools/pipeline/, docs) — the engine is untouched, and
every change is additive/backward-compatible.

Ext-1 — per-feature speed budget (requirement: speed is critical)

  • NEW scripts/pipeline/timeit.py — times the target function decompiled with the option
    OFF vs ON (median of N runs) and reports delta_pct. The OFF/ON delta cancels the fixed
    subprocess+load cost, so it isolates the option's marginal cost with no engine change.
  • config.py: SPEED_BUDGET_PCT (default +5%), SPEED_REPEAT (default 5).
  • prdemo.py: a speed row in the PR before/after table (omitted for older records).
  • record.json gains speed_off_ms/speed_on_ms/speed_delta_pct/speed_samples/
    speed_budget_pct/speed_within_budget/speed_forced_off.
  • Gate: a clean-ablation (0/675) feature that regresses the target beyond the budget is held
    to default-OFF opt-in instead of shipping default-ON. The gate can only ever push
    default-ON → opt-in — it never re-pins docs/baseline.json.
  • Verified end-to-end: timeit --option stackguard … on the ite-region target →
    off=163.8ms on=162.0ms Δ-1.14% (within budget).

Ext-2 — draft-PR confirmation for large features (requirement #5)

  • state.py: proposals/approved maps + mark_proposal/approve_proposal/claim_approved
    • proposal status + CLI (proposal/approve/claim-approved, list --proposals). Lifecycle:
      fresh → claimed →(small) done(PR) or →(large) proposals(draft PR) →approve→ approved →claim-approved→ claimed(impl, resume branch) → done(un-drafted PR).
  • select.py: skips proposals/approved; merges units.json; --kind small-unit|structural.
  • status.py: "proposals awaiting confirmation" / "approved" sections + --proposals.
  • open_pr.sh: --draft (open as draft, skip the demo) and --undraft (best-effort ready-for-review).
  • worker.sh: IMPL_PROPOSAL=1 RESUME_BRANCH=… resumes an approved proposal's branch; normal
    small-feature flow is byte-for-byte unchanged when unset.
  • worker_prompt.md: a Phase-2 scope fork (decider returns scope: small|large; large → write
    proposal.md, open [PROPOSAL] draft PR, state proposal, STOP), a {{RESUME_PROPOSAL}}
    implementation-mode preamble, the Phase-4 speed step, the Phase-5 speed gate, and Hard rules 6–7.
  • Verified: full proposal/approve/claim-approved CLI round-trip + status --proposals.

Small-units worklist

  • NEW scripts/pipeline/units.py — source-parses angr's peephole_optimizations/ (54) +
    optimization_passes/ (17) into a small-units worklist → docs/pipeline/units.json (71 units,
    4 with real-binary repro targets, the rest synthesize). select.py reads it alongside
    opportunities.json. (Follow-up: a lightweight "synthesize" worker sub-flow to unlock the
    remaining ~67 peephole units that don't yet map to a corpus binary.)

Standing requirements, encoded

  • docs/pipeline.md → new Standing requirements section (the five rules).
  • docs/agents.md (CLAUDE.md/AGENTS.md symlink target) → one-line pointer.

Validation

py_compile + bash -n all clean; pure gate()/_speed_row unit checks; state-machine
round-trip in an isolated state dir; select --kind small-unit picks a comparable unit; a real
timeit decompile. No engine code touched → the three parity gates are unaffected.

🤖 Generated with Claude Code

Tooling-only foundation for the multi-day angr->kuna feature loop. Additive and
backward-compatible; the engine is untouched.

Ext-1 (speed): new scripts/pipeline/timeit.py measures off/on decompile-time delta
(cancels fixed load cost, no engine change); config knobs SPEED_BUDGET_PCT=5 /
SPEED_REPEAT=5; prdemo speed row; record.json speed_* fields; a gate that holds an
over-budget clean-ablation feature to default-OFF opt-in (never re-pins baseline).

Ext-2 (proposals): state.py proposals/approved maps + mark_proposal/approve_proposal/
claim_approved + CLI + proposal status; select.py skips proposals/approved, merges
units.json, adds --kind; status.py proposals sections + --proposals; open_pr.sh
--draft/--undraft; worker.sh IMPL_PROPOSAL/RESUME_BRANCH resume mode; worker_prompt.md
Phase-2 scope fork + {{RESUME_PROPOSAL}} preamble + speed step + speed gate + rules 6-7.

units.py: source-parses angr peephole_optimizations/ + optimization_passes/ into
docs/pipeline/units.json (71 small-units; 4 with real-binary repro).

docs/pipeline.md Standing requirements section + docs/agents.md pointer encode the
five standing rules (1 PR/feature; end-to-end testcase; output-changing => logged +
flaggable; always measure+record speed; large features => draft [PROPOSAL] PR).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01PBrckq3YYAzBLq5k4KpWac
@mahaloz
mahaloz merged commit 079819b into main Jun 25, 2026
@mahaloz
mahaloz deleted the pipeline-extensions branch July 29, 2026 08:01
mahaloz added a commit that referenced this pull request Oct 2, 2026
…ter load

A MULTIEQUAL on the global only joins what reaches it, so the load walks
pass through one. New fixture functions e_calc, e_two, e_long, e_loop and
e_after, stage assertions #23-#30 and the spec prose for the change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012UUBmGqZTcD5N8LxpVsiQt
mahaloz added a commit that referenced this pull request Oct 2, 2026
…ter load

A MULTIEQUAL on the global only joins what reaches it, so the load walks
pass through one. New fixture functions e_calc, e_two, e_long, e_loop and
e_after, stage assertions #23-#30 and the spec prose for the change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012UUBmGqZTcD5N8LxpVsiQt
mahaloz added a commit that referenced this pull request Oct 2, 2026
…ter load

A MULTIEQUAL on the global only joins what reaches it, so the load walks
pass through one. New fixture functions e_calc, e_two, e_long, e_loop and
e_after, stage assertions #23-#30 and the spec prose for the change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012UUBmGqZTcD5N8LxpVsiQt
mahaloz added a commit to borancar/kuna that referenced this pull request Nov 14, 2026
…red through an unplaced pointer

A callee that stores its own stack address through a pointer it loaded (not a
stack slot the walk follows), loads it back and reads past it still dropped a
real argument. Such a store now leaves the extent unstated, like a stack
address parked outside the general registers. The caller's frame pointer is
left out, since the CRT's _NLG_Notify records it in a global in every MSVC
binary; with it the rule would cost real bounds, without it the 62-binary i386
corpus is byte-identical. Stage case CALLEEARGS Noelo-Lab#30 (calleelost_pe_i386
extended, recipe in its header).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
mahaloz added a commit to borancar/kuna that referenced this pull request Nov 14, 2026
…t at [esp+4]

GCC before 4.7 (MinGW) passes a member function's `this` on the stack as a
__cdecl argument, second behind the hidden pointer of a returned class
(`mov ecx,[ebp+0xc]; mov eax,[ecx]; mov [esp+4],ecx; mov [esp],edx;
call [eax+k]`), so ECX held the object only on the way and the call printed
it twice (`(a1,a0,a1,a2,a3,0,a6)` for `(a0,a1,a2,a3,0,a6)`, 36 calls in two
MinGW images). A store of the object at [esp+4], the stack pointer unchanged
up to the call, now keeps the default like the COM interface push. The vcall
fixture gains gccsret (stage Noelo-Lab#30, the custom test).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
mahaloz added a commit that referenced this pull request Nov 24, 2026
[AUTOMATED] Themida decodes a VM-context offset k through a key as
x ^ ((x & ~k) + (~x & k)) with x = key + c, which is k whatever the key
holds. When the key is a merge symbol (one non-pointer variable),
ExprArena::affine_probe's three probe points never accept a constant and
the identity test was not consulted for one variable, so the access went
to an unknown address. The emitter kept it as a load of the cell's memory,
the decompiler's own rules placed that load on the cell, and every store
to the cell had been privatized into a register: the body read the cell's
file contents. newstar_infect_themida passed dat_4651ac - 0x32c to
CopyFileW instead of the frame buffer; just_if_themida lost the store of
&input into the VM register that becomes RDX, so the emulated scanf got
the caller's RDX (plus a .themida global store).

- affine_probe: a one-variable expression the points leave open goes to
  identity_probe, and only a constant answer is taken from it (as for
  several variables). Mirrors angr's
  CFGVMDeobfuscation._ctf_eval_state_one (solver.eval_upto(expr, 2): an
  address with a single solution is that constant).
- Emitter::access_addr: privatization (plan_private, private_vn) uses the
  address the emulation's load/store placed through the probe, not only a
  literal constant, so the two views of a cell cannot mix that way.
- Fixture f_ctx (value in a context cell of .vmp0, read back through a
  key-decoded offset) and stage assertion #30; #20 count 23. Before:
  `return *(ulong *)(((v1 + 0x3350fa94U ^ ...) & 0x18) + 0x4044b0)`;
  after: `return a0 + 1;`. Baseline 5046.
- Debug: KUNA_PUSHAN_LOG_SYM adds each unplaced access's probe result and
  address expression to the KUNA_PUSHAN_LOG_INSNS node dump.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant