Skip to content

regionstructure: default-on (DIV-12) - #85

Merged
mahaloz merged 1 commit into
mainfrom
feat/regionstructure-default-on
Jun 26, 2026
Merged

mahaloz merged 1 commit into
mainfrom
feat/regionstructure-default-on

Conversation

@mahaloz

@mahaloz mahaloz commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

regionstructure: default-on (DIV-12)

Flip regionstructure on by default — the region-driven (angr Phoenix/SAILR) structurer
becomes kuna's primary S8 structuring path, replacing the unconditional Ghidra CollapseStructure.

This is the closeout of the region-structurer foundation (Inc 0–6). kuna's S8 now structures the
CFG by walking the KunaRegionIdentifier region tree and matching the Phoenix/SAILR schemas
(acyclic sequence + ITE + cyclic loops [Inc 3] + acyclic switch-case [Inc 4] + Inc 5 short-circuit
&& / || condition folding). When a function cannot be collapsed to a single structured root
(irreducible / multi-entry loops) it falls back to CollapseStructure, so it is never worse
than upstream. option regionstructure off restores the unconditional Ghidra path.

Parity

The full 675-assertion datatest corpus is byte-identical with the region structurer on vs off
— Inc 5 (#79) closed the last divergence (elseif.xml Else-if #14) via && / || condition
folding, so on now reproduces Ghidra's CollapseStructure output exactly across the whole corpus.

  • make test → PARITY OK 675/675 (no baseline regeneration; docs/baseline.json untouched)
  • make test-stages → PARITY OK 203/203
  • kuna catalog --check → OK

Why default-on if it's byte-identical?

On the reducible datatest corpus the output is identical to Ghidra, but the region structurer is
the foundation the later irreducible/SAILR goto-reduction and region-refinement increments
build on — making it the default now means those passes extend the primary path. It is a
deliberate structure-recovery default (like DIV-10), not a correctness fix.

Changes

  • architecture.rs: region_structure defaults true (struct-literal ctor + resetDefaults);
    carried into the per-function seam in build_arch_handle as before.
  • stages.toml: regionstructure row default = "on"; summary/use_when updated.
  • docs/assertions.md regenerated (catalog default off → on).
  • docs/divergences.md: DIV-12 entry.

🤖 Generated with Claude Code

…rimary structuring path

Flip `regionstructure` on by default: kuna's S8 now structures the CFG by
walking the KunaRegionIdentifier region tree and matching angr Phoenix/SAILR
schemas (acyclic sequence + ITE + cyclic loops [Inc 3] + acyclic switch-case
[Inc 4] + Inc 5 short-circuit && / || condition folding) instead of running
Ghidra's CollapseStructure unconditionally. On an un-collapsible region
(irreducible / multi-entry loops) it falls back to CollapseStructure, so it is
never worse than upstream. `option regionstructure off` restores the
unconditional Ghidra CollapseStructure path.

The full 675-assertion datatest corpus is byte-identical with the region
structurer on vs off (Inc 5 closed the last divergence, elseif.xml Else-if #14,
via && / || folding), so `make test` stays PARITY OK 675/675 with no baseline
regeneration; docs/baseline.json is untouched. This is not a correctness fix —
it is a deliberate structure-recovery default and the foundation the later
irreducible/SAILR goto-reduction increments build on.

- architecture.rs: region_structure defaults true (struct ctor + resetDefaults),
  copied into the per-function seam in build_arch_handle as before.
- stages.toml: regionstructure row default on; summary/use_when updated.
- docs/assertions.md regenerated (catalog default off -> on).
- docs/divergences.md: DIV-12 entry.

make test PARITY OK 675/675; make test-stages PARITY OK 203/203;
kuna catalog --check OK.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@mahaloz
mahaloz merged commit 0e807c3 into main Jun 26, 2026
mahaloz added a commit that referenced this pull request Jun 26, 2026
Finishing fixes on top of the WIP loop-carried-guard jump-table recovery
(option switchsharedcase, default-off opt-in). The feature itself (the S2
JumpBasic::kuna_try_loop_carried_guard_table walk, the arch flag + full
registration, the b2sum stage test) was already committed; these are the
remaining gate fixes:

- Regenerate tests/fixtures/stage_catalog.json (the catalog_bytecompat
  golden). It carried a PRE-EXISTING drift inherited from the PR #85
  regionstructure-default-on merge — the fixture said `default: off` while
  stages.toml said `on` — so full_catalog_matches_cpp_byte_for_byte was
  already red on the branch parent. The regen fixes that drift AND adds the
  new `switchsharedcase` settable row (captured from `stage catalog`, no
  program loaded, no `current` field).
- catalog_bytecompat.rs: bump the settable count 49 -> 50
  (fixture_has_all_50_settables) for the new row.
- docs/PROGRESS.md: session entry (root cause, before/after, default + the
  measured +27% on-vs-off speed, gate results).

Gates: `make test` PARITY OK 675/675 (docs/baseline.json untouched),
`make test-stages` PARITY OK 205/205, `kuna catalog --check` OK,
docs/assertions.md in sync. ElementId switchsharedcase=4103 (unique 4000+).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@mahaloz
mahaloz deleted the feat/regionstructure-default-on branch July 29, 2026 08:01
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