Skip to content

r2il: the round-trip reconstruction oracle (PR2 gate deliverable) - #103

Merged
AdaWorldAPI merged 4 commits into
mainfrom
claude/r2il-pr2-oracle
Aug 18, 2026
Merged

r2il: the round-trip reconstruction oracle (PR2 gate deliverable)#103
AdaWorldAPI merged 4 commits into
mainfrom
claude/r2il-pr2-oracle

Conversation

@AdaWorldAPI

Copy link
Copy Markdown
Owner

What

The PR2 gate deliverable from .claude/plans/r2il-behavioral-ir-v1.md §14:
R2IL → routes → semantic-equivalent R2IL, with SPO explicitly NOT the
oracle. Follows #101 (sink trait) and #102 (v2 schemas + readers).

Designed through a 5+3 council (5 research savants → consolidate → 3 brutal
reviewers → fix → ratify), whose spec is committed alongside the code at
.claude/plans/r2il-roundtrip-oracle-spec-v1.md — v1, draft v2 and ratified v3
are three separate commits on this branch, and §7 is the full change ledger
including the losing findings.

The headline result

Zero reconstruction mismatches across 35,946 matched op sites in four
binaries.
Full numbers: .claude/harvest/r2il/ORACLE-RESULT.md.

Two caveats that the doc, the module docs, and the example's own output all
carry rather than bury:

  1. That result is under the oracle's permissive_convention and proves the
    reconstruction MECHANISM.
    The shipped minimal_pass_one measures
    matched = 0 — it has zero convention rows, so no operand melts and it
    round-trips through accounting, not matching. The example always prints
    both columns so the two claims can never be conflated.
  2. The large orphan count is a linear-sweep chunking artifact, measured not
    assumed.
    Only ~50% of a chunk's blocks are reachable from its entry
    (1835/3427 on stress_test), so CFG::from_blocks drops the rest and their
    ops produce no facts at all. The arithmetic confirms it exactly:
    8053 matched + 6105 orphans = 14158 = that binary's ops_total from the §12
    profile. The in-repo fixtures, which use coherent CFGs, report zero orphans.

What landed

  • src/oracle.rsOpSkeleton (the typed equivalence target),
    reconstruct (groups Op rows by prov.op_site, operands by shared
    prov.inst, completeness judged against the op row's own payload),
    judge (a true 4-way partition with defined precedence: matched /
    mismatched / ledger_accounted / orphan, plus an ssa_only_residuals channel
    for residuals with no op site), GapAttribute + gaps_of, and
    permissive_convention.
  • facet::unproject is CONSUMED, not rebuilt — the council's code-truth
    savant found it already ships with the exact property tests the first draft
    proposed adding, so §3.1 collapsed from "build it" to "use it".
  • The attribute-gap channel — twelve R2ILOp variants carry semantic state
    beyond their varnode projection; matched ops of those variants emit a typed
    AttributeGap instead of passing silently. Opens plan item O6:
    memory_space dominates (3586), subpiece_offset is small (113), and three
    kinds are unmeasured on this corpus (no atomics) — recorded as absence of
    evidence, not evidence of absence.
  • examples/r2il_roundtrip_oracle.rs (feature lift) + docs: the result
    artifact, a guide §1 row, a README entry, and plan items O6/O6a.

Not in this slice

No schema change, no FlatFact field (the 88-byte pin holds), no
furnace/ore/slag semantics touched. Still open for PR2: codebook wiring
(ogar_codebook), and the optional SPO projection of semantic facts.

Test plan

  • cargo test — 61 tests (40 lib + 12 fixtures + 9 new oracle), all green
  • cargo clippy --all-targets -- -D warnings and --features lift — clean
  • cargo fmt --check — clean
  • uv run --only-group dev prek run --files <changed> — clean
  • Real-corpus run over the same four binaries as the §12 profile
  • Three disable-runs verified load-bearing: removing the skeleton
    comparison drives both mismatch tests red; removing the operand
    completeness check drives the minimal-convention test red; silencing the
    gap channel drives the Load/Fence test red
  • The artifact-mediated test requires the from-disk verdict to EQUAL the
    in-memory one, proving r2il: fix lossy v1 sink artifacts, add facts/residuals reader #102's v2 schemas are reconstruction-sufficient

🤖 Generated with Claude Code


Generated by Claude Code

claude added 4 commits August 18, 2026 12:38
Phase-0 artifact of the 5+3 council convened on the PR2 gate deliverable
(R2IL -> routes -> semantic-equivalent R2IL; SPO explicitly NOT the
oracle). Frozen decisions with citations, verified input inventory, the
committed resolution (facet::unproject, OpSkeleton equivalence,
reconstruct/judge, permissive measurement convention, artifact-mediated
arm), non-goals, pre-registered gates, and per-savant question sets.
Draft v2 (post-savant consolidation) and the ratified v3 will amend this
file in later commits on this branch.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AGVLyRZNEKKBSfBDJfbY3V
Phase-2 consolidation (before any reviewer): facet::unproject and
CustomSpaceTable::raw_of already ship with the exact property tests v1
proposed, so 3.1 collapses to consuming them; the attribute-gap
enumeration is corrected to the verified 12 variants / 5 kinds (adds
Subpiece offset, PtrAdd/PtrSub element_size, Fence's empty skeleton);
GapAttribute gains ResidualReason-style ALL/as_str/totality discipline;
judge's universe is pinned to source op sites with an ssa_only_residuals
channel for block-anchored residuals; the permissive-vs-shipped framing
becomes normative; gate 5's file list gains Cargo.toml, README, and plan
item O6. Full change ledger in section 7, losing findings recorded.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AGVLyRZNEKKBSfBDJfbY3V
Zero BLOCK across the three reviews. Applied: the judge partition is now
a true 4-way (matched / mismatched / ledger_accounted / orphan) with
precedence, and ReconstructionMiss routing is explicit; the minimal-
convention gate's matched>=1 conjunct was proven unsatisfiable (all 7
classified opcodes carry >=1 operand, none melts under zero rows) and is
restated as matched==0 exact; gate-5's facet.rs line now matches 3.1's
zero-code-diff commitment; ledger row 10 is self-contained. Rows 15-18
record the review round.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AGVLyRZNEKKBSfBDJfbY3V
Implements the plan's section-14 deliverable per the 5+3 council-ratified
spec: R2IL -> routes -> semantic-equivalent R2IL, compared on TYPED r2il
values (OpSkeleton over Varnode), never a triple projection -- SPO is
explicitly not the oracle, and success is semantic parity, never textual
or binary equality.

src/oracle.rs:
- OpSkeleton: opcode + output + inputs, the projection the fact rows
  actually carry. Varnode's own manual PartialEq (space/offset/size) is
  the comparison; facet::unproject is CONSUMED, not rebuilt (it already
  ships with the exact property tests, including the custom-space and
  64-bit-offset cases).
- reconstruct: groups Op rows by prov.op_site, attaches operand rows by
  shared prov.inst ordered by their own payload index, and judges
  completeness against the op row's OWN payload; every miss is reported,
  never skipped.
- judge: a true 4-way partition over source op sites with defined
  precedence -- matched / mismatched (checked BEFORE the ledger, so a
  mismatch is never excused by a coincident residual) / ledger_accounted
  / orphan. Residuals with no op site (phi inputs, CallDefine, the Edge
  no-facet case) are counted as ssa_only_residuals rather than dropped.
- GapAttribute + gaps_of: the twelve R2ILOp variants carrying semantic
  state beyond the varnode projection are MEASURED, not silently passed.
  Carries ResidualReason's no-catch-all discipline (ALL, as_str, and a
  totality test over all twelve).
- permissive_convention: the oracle's measurement config, pure data
  through existing constructors -- never a new smelt arm.

Measured on the real corpus (.claude/harvest/r2il/ORACLE-RESULT.md):
ZERO reconstruction mismatches across 35,946 matched op sites in four
binaries. Two caveats the doc and the example both carry rather than
bury: that result is under the permissive convention and proves the
MECHANISM (the shipped minimal_pass_one measures matched = 0 -- it
round-trips through accounting, not matching, and both columns are
always printed); and the large orphan count is a linear-sweep chunking
artifact, measured as only ~50% of a chunk's blocks reaching the CFG,
not a reconstruction defect. The gap census opens plan item O6:
memory_space dominates at 3586, subpiece_offset is 113, and three gap
kinds are unmeasured on this corpus (no atomics) -- absence of evidence,
recorded as such.

No schema change, no FlatFact field, no furnace/ore/slag semantics
touched; the artifact-mediated test proves the existing v2 TSV schemas
are reconstruction-sufficient by requiring the from-disk verdict to
EQUAL the in-memory one.

Three disable-runs verified load-bearing: removing the skeleton
comparison drives both mismatch tests red; removing the operand
completeness check drives the minimal-convention test red; silencing the
gap channel drives the Load/Fence test red.
@cursor

cursor Bot commented Aug 18, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_9fa8a30f-0b1f-4c81-88b6-b4272ecbc672)

@AdaWorldAPI
AdaWorldAPI marked this pull request as ready for review August 18, 2026 13:20
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@AdaWorldAPI
AdaWorldAPI merged commit 8281d7d into main Aug 18, 2026
31 of 33 checks passed
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.

2 participants