Skip to content

feat(decompiler): cooperative analysis budget tracker (#35-3a)#231

Merged
CryptoJones merged 2 commits into
masterfrom
feat/rec35-3a-budget-tracker
Jun 1, 2026
Merged

feat(decompiler): cooperative analysis budget tracker (#35-3a)#231
CryptoJones merged 2 commits into
masterfrom
feat/rec35-3a-budget-tracker

Conversation

@CryptoJones
Copy link
Copy Markdown
Owner

Closes #230.

Next slice of Rec 35 (bounded decompilation) after the #35-2 request schema. Adds DecompileBudgetTracker (cpp/budget.hh): a dependency-free, header-only, single-thread tracker the analysis loop will consult at each yield point.

What it does

  • Tracks soft/hard wall-clock, accumulated pcode-ops, and per-pass fixed-point iterations against the five caps from DECOMPILER_BUDGETS.md (defaults mirror the v1 request schema).
  • Never interrupts: a reached cap is recorded as a BudgetExhaustion class pinned to the pass that first ran out, leaving the caller to checkpoint and return a partial result. Async cancel in C++ analysis is UB we deliberately avoid.
  • Injectable millisecond clock so wall-clock paths are tested deterministically without sleeping.

Scope

Inert, mirroring how the #34-4 codec landed before being wired: caps are plain values (not the FlatBuffers DecompileBudgetV1), so the mechanism is decoupled from the IPC schema and no production pass consults it yet. Wiring the checks into flow_analysis/data_flow is the behaviour-changing follow-up (#35-3b).

Test plan

  • decomp_test_dbg unittests — 314/314 incl. 9 new budget_* cases (within-budget, soft/hard wall-clock with hard outranking soft, pcode-op cap, per-pass iteration cap, per-pass reset, sticky diagnostic pass, reset(), literal zero-cap).
  • Functional datatests 677/677; ghidra_dbg builds; sleigh compile.
  • :Decompiler:ip — both new files resolve from their license header, no manifest entry needed.

Proudly Made in Nebraska. Go Big Red! 🌽 https://xkcd.com/2347/

CryptoJones and others added 2 commits June 1, 2026 03:13
Rec 35 (bounded decompilation), next slice after the #35-2 request schema.
Adds DecompileBudgetTracker (cpp/budget.hh): a dependency-free, header-only,
single-thread tracker the analysis loop will consult at each yield point
(pass entry/exit, every N iterations).

It tracks soft/hard wall-clock, accumulated pcode-ops, and per-pass
fixed-point iterations against the five caps from DECOMPILER_BUDGETS.md
(defaults mirror the v1 request schema). It never interrupts: when a cap is
reached it records which BudgetExhaustion class tripped, pinned to the pass
that first ran out of budget, leaving the caller to checkpoint and return a
partial result. Async cancellation in C++ analysis is undefined behaviour we
deliberately do not take on.

The millisecond clock source is injectable, so the wall-clock paths are
unit-tested deterministically without sleeping (unittests/testbudget.cc, 9
cases: within-budget, soft/hard wall-clock with hard outranking soft,
pcode-op cap, per-pass iteration cap, per-pass reset, sticky diagnostic
pass, reset(), and literal zero-cap semantics).

Inert as of this PR, mirroring how the #34-4 codec landed before being
wired: caps are taken as plain values rather than the FlatBuffers
DecompileBudgetV1, so the mechanism is decoupled from the IPC schema, and no
production pass consults it yet. Wiring the yield-point checks into
flow_analysis and data_flow is the behaviour-changing follow-up (#35-3b).

Both new files carry the GHIDRA license header, so the :Decompiler:ip audit
resolves them without a certification.manifest entry.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The Rec 31 cppRaiiAudit gate has a completeness check: every C++ file
under src/decompile/cpp must be listed in either PROTECTED_FILES or
EXCLUDED_FILES. The new budget.hh (#35-3a) was in neither, so the
`audits` job's :cppRaiiAudit step failed CI with "1 ungated decompiler
C++ file(s)".

budget.hh has zero raw `new` sites (it is entirely value- and
std-typed), so it lands in PROTECTED_FILES with no line-range
exclusions ([]), the same bucket as the other already-clean headers.

This gate is not run by scripts/local-precheck.sh (C++ build/test only),
which is why the local prechecks were green; running `gradle cppRaiiAudit`
locally now reports 229 protected file(s) clean.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@CryptoJones CryptoJones merged commit 602cc1f into master Jun 1, 2026
16 checks passed
@CryptoJones CryptoJones deleted the feat/rec35-3a-budget-tracker branch June 1, 2026 10:29
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.

Rec 35 (#35-3a): cooperative analysis budget tracker

1 participant