Repository navigation
[AUTOMATED] fix(cli): kuna decompile reports the console's real failure reason, for the load AND the analysis commit (DIV-90) - #341
Merged
Conversation
…IV-90) [AUTOMATED] `kuna decompile` is the only surface that drives `decomp_dbg` as a subprocess, so it holds no error object and has to recover what failed from the transcript. `kuna-cli/src/decompile.rs (check_errors)` threw that away twice over. 1. GH-337 — the binary-load failure. The arm matched the trigger line `Could not create architecture` and answered `could not build an architecture for <binary> (unsupported/!recognized binary)` no matter what had actually happened, while the three in-process surfaces formatted the escaped `LowlevelError`. Sometimes that is an actively wrong diagnosis: `--sleighpath /nonexistent` masked `No sleigh specification for x86:LE:64:default`, a specs problem reported as a problem with the user's binary. It also made DIV-88's `symbolnamerepair` symptom — the exact string `docs/options.md` publishes as the flip trigger — unmatchable from this surface. `IfcLoadFile`'s error arm prints `{e.explain()}` and then the trigger on the next line, both to stdout, so `arch_failure_reason` reads the preceding line and the four surfaces now converge byte for byte. The generic wording survives only as the fallback for a transcript that printed no reason (the command echo is not a reason). 2. GH-339's silent half — the analysis commit. A failed `read symbols` is an `Execution error:` the console prints while keeping the session alive, so `print C` still rendered C, the out-file was non-empty, and `kuna decompile` printed quietly degraded output and exited 0 — while `functions`, `decompile-all` and `decompile-project` exited 1 with `read symbols (analysis commit) failed: <reason>`. The commit is not transactional and is unretryable, so a partial commit is a failed load, not a degraded one; exit 0 there is indistinguishable from a binary that simply has no symbols. `read_symbols_failure` attributes each console diagnostic to the command echo above it and reports a `read symbols` failure with the in-process surfaces' message and exit code. Driver tier, the DIV-89/#336 precedent: no option, no stages XML, no catalog counts. `scripts/decompile.py (_check_errors)`, the Python library shim that mirrors this function for `scripts/pipeline/`, carries both recoveries so the two drivers do not disagree again (new `AnalysisCommitError`, a `DecompileError` subclass every pipeline caller already catches). Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_011KpG7qK6BDFZyPnyo4r1c1
mahaloz
added a commit
that referenced
this pull request
Aug 27, 2026
[AUTOMATED] DIV-90/91/92 were claimed by #341/#342/#344 while this branch was in flight; the row and every reference move to DIV-93. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_011KpG7qK6BDFZyPnyo4r1c1
mahaloz
added a commit
that referenced
this pull request
Aug 27, 2026
…e aggressive preset (DIV-93) (#345) * feat(modes): the four ARM entry-discovery options join the aggressive preset (DIV-90) cortexmvectors (#248), ptrentry (#255), tailcallentry (#259) and poolentry (#278) all shipped default-OFF and sat on the UNEVALUATED list in modes.rs, so they were absent from AGGRESSIVE_OVERRIDES. `auto` resolves to `aggressive` under 500 KiB, and the preset is what the whole-binary surfaces actually run, so all four were INERT on every default path -- the DIV-64 itaniumrtti trap, four times over. The default path's stripped-ARM entry recall had not moved since they merged. They are flipped jointly because they compose, which is exactly what the UNEVALUATED comment demanded before any flip. Measured over the 110 stripped non-x86-64 decbench twins against their unstripped twins' symbol tables (50,724 ground-truth function starts), --mode aggressive: arm entries exact midbody recall added added_exact lost_exact base 55006 44957 8333 88.63% - - - cortexm 55142 45093 8333 88.90% 136 136 0 ptr 56594 46522 8333 91.72% 1588 1565 0 tail 55655 45602 8337 89.90% 649 645 0 pool 53956 45122 7116 88.96% 167 165 0 all4 56188 47330 7117 93.31% 2402 2373 0 Recall and precision improve together: +2,373 real entries (98.8% of everything added is a real function start) while mid-body false entries FALL 8,333 -> 7,117. No ground-truth entry is lost by any arm -- poolentry's 1,217 removals contain zero ground-truth addresses. 0 of 110 binaries lose recall. Restricted to the 105 binaries `auto` actually sends to `aggressive` (< 500 KiB), the default-path number is 90.92% -> 96.06%. The 5 images at/over the threshold resolve to `reliable` and are disclosed in the DIV row rather than papered over. Non-ARM inertness is measured: identical entry sets over 90 x86-64 twins and the 12 i386 PE images in the ARM corpus, byte-identical emitted C over 8 x86-64 binaries. Speed, interleaved min-of-4: decompile-all cf2.elf -5.8% (a speedup), nuttx +3.5%, x86-64 controls at noise; discovery-only `kuna functions` +6.2%, which is more work for more output on the one surface that only does discovery. The 0/675 ablation is proven, not asserted: a throwaway build with all four forced ON as engine defaults -- strictly stronger than preset membership, which the XML harness never applies -- still reports 675/675 and 538/538 PARITY OK. Also lands PR #239's two doc corrections, repointed at the shipped feature docs rather than at its unshipped-proposal directory: the recall-measurement.md mechanism/noise correction and the missing-ghidra-analyses.md OperandReferenceAnalyzer row (its "function creation is subsumed by entry-disc" claim is what ptrentry disproved). [AUTOMATED] Generated by Claude Code. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_011KpG7qK6BDFZyPnyo4r1c1 * docs(decbench): retire the two round-ledger claims DIV-90 falsifies features-round4.md Rank 6 was a filed, still-open recommendation to flip `tailcallentry` into the preset ("aggressive does not carry it"); DIV-90 does exactly that, so it is marked SHIPPED with the sweep it asked for. features.md still called step 3 "in flight" and did not know about step 5 (`poolentry`, #278). [AUTOMATED] Generated by Claude Code. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_011KpG7qK6BDFZyPnyo4r1c1 * docs: state the ARM restriction precisely -- poolentry has no arch gate cortexmvectors/ptrentry/tailcallentry each early-return on `object::Architecture::Arm`; poolentry does not, and is ARM-only in EFFECT because it keys on PC-relative literal pools. The measured inertness is the same either way (identical entry sets on 90 x86-64 twins and 12 i386 PE images), but "all four are ARM-gated" overstated the mechanism for one of them. [AUTOMATED] Generated by Claude Code. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_011KpG7qK6BDFZyPnyo4r1c1 * docs(history): add the leave-one-out direction to the DIV-90 evidence Dropping each option from the combination loses 27 / 1427 / 645 / 136 ground-truth entries respectively, and dropping poolentry is the only one that also raises mid-body false entries (7117 -> 8337). No option is redundant given the others. [AUTOMATED] Generated by Claude Code. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_011KpG7qK6BDFZyPnyo4r1c1 * docs: renumber the ARM-preset divergence to DIV-93 [AUTOMATED] DIV-90/91/92 were claimed by #341/#342/#344 while this branch was in flight; the row and every reference move to DIV-93. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_011KpG7qK6BDFZyPnyo4r1c1 --------- Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #337. Also fixes the silent half of #339 — the driver half. #339's engine half (the
st_sizeclamp and the twotypecacheindex panics it reaches) ships in the siblingfix/symbolsizeclampPR; this PR touches onlykuna-cli.kuna decompileis the one surface that drivesdecomp_dbgas a subprocess, so it holds no errorobject and has to recover what failed from the console transcript.
kuna-cli/src/decompile.rs (check_errors)threw that away twice over. The other three surfaces load in-process and format thereal
LowlevelError(decompile_all.rs (load_program)). This makes the fourth agree — byte forbyte, message and exit code.
Driver tier, the DIV-89/#336 precedent: no option, no
tests/stagesXML, no catalog counts.1. The architecture error (#337)
The arm matched the trigger line
Could not create architectureand answered a fixed stringregardless of what happened:
That is not merely less informative.
--sleighpath /nonexistentmaskedNo sleigh specification for x86:LE:64:default— a specs problem reported as a problem with the user's binary, which sendsthem at the file instead of their install. And it made DIV-88's
symbolnamerepairsymptom(
could not build an architecture for <binary>: Non-global scope has empty name, the exact stringdocs/options.mdpublishes as the flip trigger) unmatchable from the surface an agent is most likelydriving. The DIV-88 row names this defect verbatim as "a separate driver-tier defect this row does
not fix".
The transcript always carried the reason:
IfcLoadFile's error arm prints{e.explain()}and thenthe trigger on the next line, both to stdout.
arch_failure_reasonreads the preceding line andformats it in
load_program's wording, so the four surfaces converge on one string. The generic(unsupported/!recognized binary)text survives only as the fallback for a transcript thatprinted no reason at all (a
[decomp]>-prefixed predecessor is the command echo, not a reason).After:
2. The analysis-commit failure (#339's silent half)
A failed
read symbolsis anExecution error:the console prints while keeping the sessionalive, so
print Cstill rendered C, the out-file was non-empty, and:read_symbols_failureattributes each console diagnostic to the command echo above it and reports aread symbolsfailure verbatim, in the in-process surfaces' wording.Hard error or stderr warning? — hard error (exit 1, no C)
Both forms would let an agent notice. Three things decide it the other way:
commit_analysis_outputmutates the architecturein place, arm by arm, so an abort leaves the early arms applied and abandons library prototypes,
cppsig/DWARF prototypes, ARM/MIPS context paints, tracked register values, call-fixups, DWARF
stack locals and line comments — and it is unretryable (
std::mem::takealready drained both thepending stash and
loader_data_objects). Nothing about which arms survived is visible in the C.The three in-process surfaces refuse to emit anything for exactly that reason; printing that C
under a warning would keep this one surface disagreeing with them about what the run was.
told apart from a binary with no symbols. A message on stderr is lost by any caller that captures
stdout only; the status code is the part that cannot be dropped.
scripts/decbench/{triage,rescore,optsweep,showcase,mine}.pyandscripts/pipeline/status.pyshell out to
kuna decompile-all, neverkuna decompile— that surface already exits 1here, so their behavior is unchanged. (
optsweep.py:146even treats a non-zero exit withnon-empty stdout as
ok, and it is ondecompile-allanyway.)scripts/pipeline/{compare,prdemo,timeit}.pyandreference/kuna_adapter.pygo through thePython
scripts/decompile.pyshim, not thekunabinary; all four catch the basekdecompile.DecompileError, so the newAnalysisCommitErrorsubclass is already handled.tests/datatests+tests/stagesrundecomp_test_dbg; they never reachkuna-cli, and bothcorpora are symbol-less bytechunks that cannot commit analysis at all.
integrations/webdriveskuna_wasm, whoselib.rs:380already fails loudly with thisexact message (the 5th surface, untouched and already in agreement);
integrations/ghidradrives
kuna_ghidra, its own binary.grep -rn "unsupported/!recognized"finds two producers (this file + the Python shim) andzero consumers; the three CLI skip-helpers (
decompile_all_cli.rs (is_specs_skip),decompile_project_cli.rs,ctypes_per_arch.rs) key on the unchangedcould not build an architectureprefix and are untouched.scripts/decompile.pyIt is the Python library shim
scripts/pipeline/still imports, and its_check_errorsmirrored themasked arm line for line. Both recoveries are ported there, plus a new
AnalysisCommitError(DecompileError)(exported fromscripts/__init__.py), so fixing only the Rustside does not leave the two drivers disagreeing again.
Tests
decompile.rs, over transcripts captured from realdecomp_dbgruns: reason present (empty scope / missing.sla/ junk file), reason absent(fallback), a
[decomp]>-prefixed predecessor (fallback, not a bogus reason), theread symbolsfailure, a diagnostic belonging to another command (not misattributed), and a clean transcript.
decompile_cli.rs (every_surface_reports_the_same_load_failure):drives the actual engine over the checked-in
kuna-analysis/tests/fixtures/hostile_scope_x86_64with
--option symbolnamerepair offand asserts all four surfaces produce the same string andexit 1. This is the part that would catch a console-side print reorder; the stub tests would not.
Its skip predicate is deliberately narrower than
decompile_all_cli.rs (is_specs_skip), whichtreats any
could not build an architectureas a missing-.slaskip and would have swallowedthe very assertion.
preserved generic fallback. The commit-failure test is stubbed on purpose: the sibling engine fix
removes the
st_sizerepro, and the driver must keep reporting any commit failure after it lands.Measurements
kuna decompileinvocations (stdout, stderr and exitcode compared) across
tests/bug-repro/{grep,sort,faillog,libselinux.so.1},fauxware,/usr/bin/ls,/usr/bin/id— pre-change binary vs post-change. Expected by construction (bothrecoveries only fire on failure paths), and stated as such rather than as evidence of anything
else. The real evidence is the failing-path A/B above.
grep/main— -2.15 % (0.5286 s ->0.5173 s), i.e. noise. Only two line scans of a transcript already in memory were added.
driven by
decomp_test_dbg, which never reacheskuna-cli.Known limits (stated, not fixed)
own dispatch differs from the in-process loader's: 200 bytes of junk gets
syntax errorfromdecompile(the<binaryimage>XML branch) versusnot in recognized object file format: Unknown file magicfromfunctions. That is a pre-existingbootstrap_from_filevsbootstrap_from_objectdivergence, not a
check_errorsone; the reported text is still strictly more than the fixed string.read symbols, as decided.--option nosuchoption onstill exits 0 ondecompileand 1on
functions— anoption-command diagnostic, one line of the same helper away, left for its ownchange rather than smuggled in here.
Renumber the row and its four in-tree references (
docs/history.md,docs/cli.md,docs/spec/00-overview.md×2) on rebase.🤖 Generated with Claude Code
https://claude.ai/code/session_011KpG7qK6BDFZyPnyo4r1c1