Repository navigation
[AUTOMATED] feat(p8): returndup default-ON, superseding the DIV-18 revert (DIV-54) - #246
Merged
Merged
Conversation
…vert (DIV-54) `returndup` (angr SAILR gotoless ReturnDuplicatorHigh, p8_structure/kuna_returndup.rs) becomes a shipped default again. WHY THE OLD NUMBER IS STALE. DIV-18 first made it a default and it was reverted on 2026-07-05 after decbench measured -976 aggregate GED-perfect across 21,768 firings. That measurement described the UNSELECTIVE pass, which also split `return <variable>` epilogues. #137 then ported angr's `_should_duplicate_dst` const-return gate (`Funcdata::returndup_is_const_ret`), which declines every share whose return value is not a literal / COPY chain / phi-of-constants and drops ~40-60% of firings -- exactly the over-eager class the -976 was counting. The revert's justification no longer describes the code, so the option is re-measured from scratch here rather than reinstated on the old evidence. THE NEW MEASUREMENT. Isolating decbench A/B, same binary in both arms, 536 slices / 52,862 scored functions: ON 804,689 aggregate GED / 18,036 GED-perfect versus OFF 812,445 / 17,619 -- +417 perfect and -7,756 GED, 608 perfects created against 191 destroyed (3.2:1). The 46,005 functions the pass never fires on score identically in both arms. Net-positive in all nine partitions tested causally; the one net-negative cell (a split that de-structures a loop) had a gate built and scored at +2 perfect / -209 GED and was not kept. Analysis: docs/decbench/returndup-regression-triage.md. ABLATION. The raw flip moves 16 datatest assertions across 9 upstream files. Those files take a per-test `option returndup off` (the standing convention, as DIV-14/17/ 23/25/51 did) and the gate is then 675/675 PARITY OK with NO baseline re-pin. A 10th datatest (condconst.xml) takes the opt-out for the w10 byte-parity oracle that drives it. Stages: 356/356 PARITY OK with the same opt-out on 5 two-pass isolation tests, and no baseline re-record. SPEED. Interleaved A/B on one binary, `decompile-all --mode reliable`, medians: update-passwd +1.74%, coreutils factor +0.74%, coreutils ls +1.14%, gzip -O0 +2.66%, gzip -O2 -1.18%, coreutils sort -O2 +0.02% -- worst case +2.96%, inside the +5% budget. (The blocked `scripts.pipeline.timeit` form is unusable on this host: it reported ls::main at +57.3% where the interleaved measurement gives +2.45%.) `--mode aggressive` deliberately keeps naming the option so the preset re-enables it after an explicit `--option returndup off`; modes-aggressive.xml pins that. Also records the worktree spec-resolution trap in docs/agents.md: KUNA_SPECS/ SLEIGHHOME do not reach the cargo workspace suite, which resolves specs as <repo>/specs. Gates: make test PARITY OK 675/675; make test-stages PARITY OK 356/356; make rust-test green; make check-spec OK; kuna catalog --check OK. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_011RXVU58TKJxb518oViChwo
mahaloz
added a commit
that referenced
this pull request
Aug 11, 2026
…ections it forced Round 4 targeted the slice the campaign had not attacked: the O0 cases where IDA's GED is 0 and kuna's is not. This lands the reusable parts only -- the instrument, the analysis, and the two documentation errors the round proved. The per-case triage records are deliberately not committed. ## The instrument `scripts/decbench/optsweep.py` -- a bidirectional corpus-scale A/B for any single option flip. `rescore` prices ONE mined case, which is the wrong unit for anything that changes a default: the mining pipeline only ever produces one direction of evidence, mining losses and never pricing the wins the same change destroys. At O0 the net deficit against IDA is 129 functions while every candidate cluster is 300-430 wide, so a change that flips 400 each way moves the scoreboard by zero and nothing upstream of this tool would show it. It reports both directions of movement by name, the summed GED delta per population, a per-project and per-architecture breakdown, and the standing-requirement-8 changed set, with three harness controls built in: functions the pass never fires on must score identically in both arms, banner-only diffs must score identically, and the ON arm must reproduce the published column. A run that fails any of them is not a measurement. Cross-validated against the ad-hoc harness that produced the returndup measurement: 157 of 157 functions agree in both arms on O0 zlib. ## Correction 1: the scored column is `aggressive`, not `reliable` `docs/decbench-loop.md` has been telling every triage agent that the benchmark injected `option listing on`, the equivalent of `--mode reliable`. It does not. `decbench/decompilers/raw/kuna_raw.py`'s `_build_command` builds `kuna decompile-all <bin> --json --max-fn-seconds 120`, appends `--mode` only when `DECBENCH_KUNA_MODE` is set, and appends `--option` only from `config.extra_options`, which is empty. So the benchmark ran `--mode auto` = aggressive on 768 of 803 binaries. An aggressive-only regression is therefore INSIDE the published number, and any triage that assumes `reliable` mis-attributes it. ## Correction 2: DIV-54's evidence never saw O0 `docs/decbench/returndup-o0-measurement.md` is the A/B that PR #246 did not run. #246 flipped `returndup` default-ON on 52,862 functions at O2 and O2-noinline; its table has two rows and neither is O0. Re-run over all three levels, 85,195 scored functions: O0 -192 GED-perfect, O2 +362, O2-noinline +470, total +640. Keep the default -- flipping back buys 192 at O0 and sells 832. But one structural sub-shape carries essentially all the O0 harm and almost none of the O2 benefit: the split that permanently blocks `rule_block_or` from folding a short-circuit chain (-665 at O0, +15 and +20 at the optimized levels). That is the gate PR #285 implements. ## The grounding `docs/decbench/round4-grounding.md` locates the gap before triaging anything. O0 is the only optimisation level where IDA holds more perfect functions than kuna; at O2 and O2-noinline kuna's lower percentage is a denominator effect, since it is scored on 2,343 more functions and holds more perfect at both. Total perfect: kuna 33,146, IDA 32,838. `docs/decbench/features-round4.md` is the ranked menu with its killed list. Zero symptoms fell to the adversarial pass, and four of six filed root causes were materially overturned -- continuing the campaign's most reliable finding exactly. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01C8UQbPqALzdUQ3cLLjUeKH
mahaloz
added a commit
that referenced
this pull request
Aug 11, 2026
…ections it forced (#279) Round 4 targeted the slice the campaign had not attacked: the O0 cases where IDA's GED is 0 and kuna's is not. This lands the reusable parts only -- the instrument, the analysis, and the two documentation errors the round proved. The per-case triage records are deliberately not committed. ## The instrument `scripts/decbench/optsweep.py` -- a bidirectional corpus-scale A/B for any single option flip. `rescore` prices ONE mined case, which is the wrong unit for anything that changes a default: the mining pipeline only ever produces one direction of evidence, mining losses and never pricing the wins the same change destroys. At O0 the net deficit against IDA is 129 functions while every candidate cluster is 300-430 wide, so a change that flips 400 each way moves the scoreboard by zero and nothing upstream of this tool would show it. It reports both directions of movement by name, the summed GED delta per population, a per-project and per-architecture breakdown, and the standing-requirement-8 changed set, with three harness controls built in: functions the pass never fires on must score identically in both arms, banner-only diffs must score identically, and the ON arm must reproduce the published column. A run that fails any of them is not a measurement. Cross-validated against the ad-hoc harness that produced the returndup measurement: 157 of 157 functions agree in both arms on O0 zlib. ## Correction 1: the scored column is `aggressive`, not `reliable` `docs/decbench-loop.md` has been telling every triage agent that the benchmark injected `option listing on`, the equivalent of `--mode reliable`. It does not. `decbench/decompilers/raw/kuna_raw.py`'s `_build_command` builds `kuna decompile-all <bin> --json --max-fn-seconds 120`, appends `--mode` only when `DECBENCH_KUNA_MODE` is set, and appends `--option` only from `config.extra_options`, which is empty. So the benchmark ran `--mode auto` = aggressive on 768 of 803 binaries. An aggressive-only regression is therefore INSIDE the published number, and any triage that assumes `reliable` mis-attributes it. ## Correction 2: DIV-54's evidence never saw O0 `docs/decbench/returndup-o0-measurement.md` is the A/B that PR #246 did not run. #246 flipped `returndup` default-ON on 52,862 functions at O2 and O2-noinline; its table has two rows and neither is O0. Re-run over all three levels, 85,195 scored functions: O0 -192 GED-perfect, O2 +362, O2-noinline +470, total +640. Keep the default -- flipping back buys 192 at O0 and sells 832. But one structural sub-shape carries essentially all the O0 harm and almost none of the O2 benefit: the split that permanently blocks `rule_block_or` from folding a short-circuit chain (-665 at O0, +15 and +20 at the optimized levels). That is the gate PR #285 implements. ## The grounding `docs/decbench/round4-grounding.md` locates the gap before triaging anything. O0 is the only optimisation level where IDA holds more perfect functions than kuna; at O2 and O2-noinline kuna's lower percentage is a denominator effect, since it is scored on 2,343 more functions and holds more perfect at both. Total perfect: kuna 33,146, IDA 32,838. `docs/decbench/features-round4.md` is the ranked menu with its killed list. Zero symptoms fell to the adversarial pass, and four of six filed root causes were materially overturned -- continuing the campaign's most reliable finding exactly. Claude-Session: https://claude.ai/code/session_01C8UQbPqALzdUQ3cLLjUeKH 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.
Flips
returndup(angr SAILR gotolessReturnDuplicatorHigh,p8_structure/kuna_returndup.rs) from default-OFF to default-ON as DIV-54.The history — and why the old number does not apply
This option has shipped as a default once before and was pulled back.
returndupa default.ReturnDuplicatorHigh._should_duplicate_dstconst-return gate asFuncdata::returndup_is_const_ret(substrate/funcdata_block.rs).The −976 was measured on the unselective pass, which also split
return <variable>epilogues. The const-return gate declines every share whose returnvalue is not a literal / COPY chain / phi-of-constants and drops ~40–60% of firings —
precisely the over-eager class the −976 was counting. So this PR does not reinstate the
default on the old evidence; the option is re-measured from scratch.
The A/B
Isolating ablation, the same binary in both arms (
decompile-all --json --max-fn-seconds 120, once as shipped and once with--option returndup off), 536slices / 52,862 scored functions, scored with decbench's own
GEDMetric:+417 GED-perfect and −7,756 aggregate GED. 608 perfects created against 191
destroyed (3.2 : 1); 3,676 functions improved against 2,079 worsened. Harness
controls: the 46,005 functions the pass never fires on score identically in both
arms, and the published
kuna_update-passwd.creproduces byte for byte.Nine partitions were tested causally — split count, void vs value return, distinct
return values, return count, contains-a-
switch, all-returns-identical, body size,project, opt level — and every cell is net-positive. The single net-negative
subpopulation is a split that de-structures a loop (321 firings, −257 GED); a gate for
it was built and scored at +2 perfect / −209 GED and was not kept. Full
analysis:
docs/decbench/returndup-regression-triage.md(#245).The ablation — and a correction to #245
make test: 675/675, PARITY OK,docs/baseline.jsonuntouched.docs/decbench/returndup-regression-triage.mdclaimed the raw flip gave "675/675 —zero assertion movement". Re-measured here on current
main, that is wrong: theraw flip moves 16 assertions across 9 upstream datatest files. This PR corrects that
claim in the triage doc.
Every one of the 16 is an upstream test pinning the merged shared-epilogue rendering
that this option exists to split — e.g.
condexesub:675/675 is therefore reached the way every prior default flip in this repo reached
it — a per-test
option returndup offon the files whose rendering it changes(DIV-14: "0/675 via per-test opt-outs in 12 files"; likewise DIV-17, DIV-23, DIV-25,
DIV-51) — with no baseline re-pin.
make test-stagesis 356/356 PARITY OK withno baseline re-record either.
Speed — inside the +5% budget
Interleaved A/B on one binary (
--option returndup off|on, alternating within eachpair and flipping the within-pair order every other pair),
decompile-all --mode reliable, medians:update-passwd-O0factor-O0ls-O0sort-O2Worst case +2.96% (gzip -O0 at 5 pairs; +2.66% at 9). Per-function, interleaved,
medians of 9:
lsmain 247.8 → 253.9 ms (+2.45%),factorfactor 111.9 → 112.1 ms(+0.17%),
update-passwdxmalloc 103.0 → 103.4 ms (+0.34%), gzip main 519.8 → 376.8 ms(−27.5%).
python -m scripts.pipeline.timeitis not usable on this host. It times all-OFFthen all-ON in blocks, and the box runs concurrent build agents, so the block boundary
picks up load drift: it reported
factor::factorat −33.9% and, on a re-run minuteslater, −0.5%; and
ls::mainat +57.3%, where the interleaved measurement of thesame function gives +2.45%. Its output is recorded in the DIV row for the record,
but the interleaved numbers above are the measurement.
Tests that needed a per-test opt-out
Datatests (10) — each pins an upstream merged-epilogue rendering:
ccmp,orcompare,condexesub,copytrim,condconst2,bitfields2,partialunion,statuscmp,union_datatype(the 9 whose own assertions move), pluscondconst— whose assertions do not move, but which drives theverify_w10_merge_clusterw10 byte-parity oracle (condconst_copymust staybyte-identical to the C++ render).
Stage tests (5) — two-pass isolation tests where returndup is now a second variable
between the passes:
gh6904-ppc-e500-concat44,gh9203-condexe-loopcopy,ghangr-1after909-doit-73591e,ghangr-earlyreturn,ghangr-ite-region-converter-missing-5db28e.Already explicit, prose updated only:
ghangr-returndup(pass 1 already set theoption off "to guard against a future default-on sweep") and
modes-aggressive.Rust tests:
architecture/tests.rs—apply_mode_reliable_is_a_no_opnow assertsthe shipped default survives the no-op preset, and the aggressive test drops
returndupfrom its off-by-default precondition list.--mode aggressivekeeps naming the optionAGGRESSIVE_OVERRIDESdeliberately keeps("returndup", "on")even though it is now adefault: the preset owns the option, so an earlier
--option returndup offon thesame command line is re-enabled by the preset, and the preset's contract ("every
recovery pass on") does not silently change if a default drifts back.
tests/stages/modes-aggressive.xmlnow pins exactly that — pass 1 sets the option offexplicitly,
mode reliable(an empty override list) leaves it off,mode aggressiverestores it. The assertion name is unchanged so the stages baseline needs no re-record.
Also folded in
docs/agents.mdgains the worktree spec-resolution trap:KUNA_SPECS/SLEIGHHOMEdonot reach the cargo workspace suite, which resolves specs as
<repo>/specsrelativeto its own crate — so ~22 targets fail with "Could not find .sla file" in a worktree
unless the main tree's built
.slafiles are symlinked in first. This has now cost twoagents time.
Gates
make testdocs/baseline.jsonunchangedmake test-stagesdocs/baseline-stages.jsonunchangedmake rust-testmake check-speckuna catalog --checkDocs
docs/history.md— DIV-54 row; the DIV-18 row is annotated SUPERSEDED, not deleted.docs/spec/08-structuring.md— thereturndupsection is rewritten from "shipped,then reverted (history)" to the shipped-default description, carrying the full
shipped → reverted → re-shipped record and the loop-cell result.
docs/options.md+tests/fixtures/phase_catalog.jsonregenerated;phases.tomluse_when/summaryrewritten for the flip (required for atransform-tier default).docs/modes.md— theaggressivecaveat and the option list.docs/decbench/returndup-regression-triage.md— conclusions 2 and 3 corrected.🤖 Generated with Claude Code
https://claude.ai/code/session_011RXVU58TKJxb518oViChwo