Repository navigation
regionstructure Inc 0: close the W7 block-graph adapter (analysis-only) - #68
Merged
Merged
Conversation
Make `KunaRegionIdentifier::compute()` runnable on a REAL `bblocks` CFG by closing the W7 block-graph adapter seam in the angr RegionIdentifier port (`s7_regions/kuna_regionid.rs` + `kuna_regiongraph.rs`), previously stubbed for synthetic nodes only. - Add `build_from_block_graph(&Funcdata)` (Input A): builds the working graph from the decompiler's basic blocks read-only — one `k_block` node per block (carrying the real `BlockId`, keyed on its start address) and one edge per CFG out-edge, entry address = block 0's start. - Implement `ends_with_branchind_or_cbranch` over real ops: each node parks the `FlowBlock::lastOp()->code()` probe (CPUI_BRANCHIND / CPUI_CBRANCH, via `bb_op_tail`) precomputed once per block on a new `KunaRegionNode::branchy` payload; the predicate reads the last chain member's flag. The block CFG is immutable across identification, so the precompute is equivalent to the C++ live probe and deterministic. Synthetic test nodes stay `false` (C++ path). - Route the `region tree/blocks/walk` console commands through the real adapter (replacing the inline synthetic-node construction in `build_region_identifier`). - Extend `tests/stages/kuna-regions.xml` (assertions #6-#8) to pin the region tree built from the real bblocks CFG, including the branchind/cbranch-aware supergraph shape; add 3 `kuna_regionid` unit tests over a real `Funcdata`. ANALYSIS-ONLY: no structuring/emit path touched. `make test` PARITY OK (675/675 byte-identical), `make test-stages` PARITY OK (164/164), rust-test green. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Region-structurer foundation (Inc 0) — analysis-only, no new --option. Main had advanced with #55 (loopbreak_recovery/DIV-10), #57 (gotoreduce), #67 (macho-arm64e); the only conflict was docs/baseline-stages.json (data_footer counts), all other region code (s7_regions/kuna_regiongraph.rs, kuna_regionid.rs, kuna_console.rs) and the kuna-regions.xml assertions merged cleanly. Regenerated assertions.md (45 settables, unchanged) and baseline-stages.json (171/171, incl. the 8 KUNA-REGIONS assertions plus main's gotoreduce/loopbreak/catalog ones). Gates: catalog OK, make test PARITY OK (675/675), make test-stages PARITY OK (171/171). Region unit tests: regionid 6/6, regiongraph 18/18 (incl. new build_from_block_graph_*). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01PBrckq3YYAzBLq5k4KpWac
mahaloz
added a commit
that referenced
this pull request
Jun 25, 2026
Resolve union conflicts with main (which landed #60 switchguardbound + #68/#60 region work). Both opt-in/default-off knobs coexist: - stages.toml: union [[settable]]/[[surface]] -> surface 91->93, settable 45->47 (29 stage-model + 15 analysis + 3 loader); header counts updated. - kuna_stages/tests.rs: surface_count 93, settable_count 47, live_value present-for-23 (switch_guard_bound + tail_call_jumps both field-backed), catalog-json trailing-commas 46. - catalog_bytecompat.rs: fixture_has_all_47_settables; stage_catalog.json fixture auto-unioned (byte-for-byte test green). - xml.rs corpus count 138->139 (83 datatests + 56 stage tests: both the missing-function-call and tee-o2-tail-jumps stage tests present). - kuna-catalog.xml: source_decompiler=angr 12, structure-recovery 7, opt-in-tool 8. - PROGRESS.md: union both session entries. - tailcalljump ElementId stays 4101 (no collision; gotoreduce=4100 on main). Regenerated docs/assertions.md + docs/baseline-stages.json (180/180). Gates: kuna catalog --check OK; make test PARITY OK 675/675; make test-stages PARITY OK 180/180. docs/baseline.json untouched. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01PBrckq3YYAzBLq5k4KpWac
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.
regionstructure Inc 0: close the W7 block-graph adapter (analysis-only)
First increment of the region-structurer foundation (
docs/region-structurer-roadmap.md).Makes the ported angr
RegionIdentifier(s7_regions/kuna_regionid.rs) runnable on areal
bblocksCFG, not just synthetic test nodes. No decompiler output changes —this is the analysis-only adapter the rest of the structurer (Inc 1+) builds on.
What
The W7 seam was stubbed:
build_from_block_graph/ends_with_branchind_or_cbranchonlyserved the synthetic
add_synthetic_block/add_synthetic_edgeAPI. This closes it:KunaRegionIdentifier::build_from_block_graph(&Funcdata)(Input A): constructs theworking graph from the decompiler's basic blocks read-only — one
k_blocknode perbasic block (carrying the real
seams::BlockId, keyed on its start address) and one edgeper CFG out-edge, with the entry address set to block 0's start.
ends_with_branchind_or_cbranchover real ops: each node parks theFlowBlock::lastOp()->code()probe (CPUI_BRANCHIND/CPUI_CBRANCH, viabb_op_tail)precomputed once per block on a new
KunaRegionNode::branchypayload; the predicate readsthe last chain member's flag. The basic-block CFG is immutable across identification, so
the precompute is equivalent to the C++ live probe and deterministic (block iteration
in CFG index order; the tail op is the unique last op under
(addr, ident)ordering).Synthetic test nodes carry no block and stay
false— exactly the C++ synthetic-node path.region tree/blocks/walkconsole commands now drive the real adapter (the inlinesynthetic-node construction in
build_region_identifieris replaced by the new method).Tests / parity
tests/stages/kuna-regions.xml: assertions Render unknown types as real C types (realtypes, DIV-6) #6–Perf/actionpool cursor #8 added — they pin the region treebuilt from the real
bblocksCFG (the branchind/cbranch-aware supergraph keeps theCBRANCH-ending entry, the nested region, and the early-out as three distinct top nodes;
the loop's enclosing acyclic region pairs the cyclic self-loop with its exit block).
kuna_regionidunit tests (build_from_block_graph_*) over a realFuncdatadiamond/chain CFG: tree shape, the supergraph branchind/cbranch behavior, and the
non-empty-graph guard.
Gates
make test→ PARITY OK (675/675, byte-identical — nothing in the structuring/emitpath was touched).
make test-stages→ PARITY OK (164/164; baseline-stages.json bumped by exactly the3 new region assertions, no regressions).
make rust-test→ green.Not wired into
ActionBlockStructure/output — that is Inc 1.🤖 Generated with Claude Code
https://claude.ai/code/session_01PBrckq3YYAzBLq5k4KpWac