Skip to content

r2il: PR 2 first slice — §12 corpus profile (resolves O1) + RefinedTruthSink - #101

Merged
AdaWorldAPI merged 2 commits into
mainfrom
claude/r2il-pr2-route-v3-projection
Aug 18, 2026
Merged

r2il: PR 2 first slice — §12 corpus profile (resolves O1) + RefinedTruthSink#101
AdaWorldAPI merged 2 commits into
mainfrom
claude/r2il-pr2-route-v3-projection

Conversation

@AdaWorldAPI

Copy link
Copy Markdown
Owner

Summary

A scoped first increment of PR 2 from .claude/plans/r2il-behavioral-ir-v1.md ("route → V3 projection + DTO hooks, gated on PR 1 numbers"). PR 2 has no type-level implementation spec the way PR 1 did (that plan's impl-spec doc is entirely PR-1-scoped) — writing that full spec, and then the round-trip reconstruction oracle + DTO/codebook wiring + optional SPO projection it calls for, is real remaining work sized similarly to PR 1 (which needed a 10-worker Sonnet fleet). This PR ships what's genuinely well-scoped and measurement-gated today, and is explicit about what it doesn't attempt.

1. §12 corpus profile — resolves O1

Task tracking had "run corpus profile + record §12 numbers" marked done with no artifact anywhere in the repo. Actually ran it:

cargo run --example r2il_corpus_profile --features lift --release

Across all 4 corpus binaries (130193 sampled ops total): 100.00% fit the dst+src0+src1 inline shape, 0.00% needed Vec routing — on every single binary, no exceptions. Full breakdown (per-binary op/CFG stats, facet-overflow check, furnace conservation cross-check, and the honest caveats — CallOther arity unmeasured, phi/Multiequal fan-in reaching 7 at the CFG level though never sampled as an Op row here) in .claude/harvest/r2il/CORPUS-PROFILE-RESULT.md.

This also let me correct a stale flag in STAGED-CODEGEN-GUIDE.md: FlatFact's existing a/b: u64 payload slots (already shipped in PR 1, 88 bytes, Copy, no Vec) were flagged "NOT stable, may be re-carved in PR 2." The measurement says otherwise — the shape needs no re-carving. What's still open is the per-kind meaning of those slots and the persistence byte encoding, both real PR 2 scope.

2. RefinedTruthSink — the sink trait

The plan's SUBSTRATE RULING calls for a trait behind which offline / lance-graph SoA / S3 are implementations, chosen at the call site. furnace/ore/slag already carry zero persistence assumption (verified — no file/network/env touch in any of the three modules), so this is additive.

  • OfflineSink — real, tested. Writes facts/residuals/report as #version/#schema-headed TSV (same additive-export convention every other R2IL artifact already uses); read_report round-trips.
  • S3Config::from_lookup/from_env — credential plumbing only (AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY/AWS_ENDPOINT_URL_S3/AWS_REGION, all-or-nothing, empty treated as unset). The actual signed PUT is not implemented — flagged explicitly in the module docs rather than faked.
  • lance-graph SoA backend: intentionally absent from this crate. ruff_r2il takes no lance-graph dependency to define the trait; a lance-graph-side crate implements it against its own SoA (matches facet.rs's own PR-3 deferral — the real classid mint lives there).

Incidental finding, fixed

ruff/clippy.toml's disallowed-methods list is directory-scoped, not Cargo-workspace-scoped — it reaches this workspace-excluded crate despite every reason string saying "in ty crates" (ruff_r2il has no ty::System trait to route through). #[expect]'d at the two call sites (std::fs::create_dir_all, std::env::var) with that reasoning, per this repo's own AGENTS.md preference for #[expect] over #[allow].

Not in this slice (explicit, not silently dropped)

  • The DTO/codebook wiring the plan calls for beyond what facet.rs already has.
  • The round-trip reconstruction oracle (R2IL → routes → semantic-equivalent R2IL).
  • Optional SPO projection of semantic facts (calls/objects only).
  • A facts/residuals reader — only read_report exists; reconstructing FlatFact/ResidualLedger rows (incl. VarnodeFacet from its 3 columns) is real remaining scope.

Test plan

  • cargo test in ruff_r2il — 46/46 pass (34 unit + 12 lossless-fixture), including 3 new sink::tests (disable-run-verified: the credential-refusal test drops exactly one env key at a time and confirms the whole config is refused, not just checks the all-present case)
  • cargo clippy --all-targets -- -D warnings — clean
  • cargo fmt --check — clean
  • cargo doc --no-deps — zero new warnings (4 pre-existing warnings in furnace.rs/ore.rs, untouched by this change)
  • uvx prek run --from-ref origin/main --to-ref HEAD — clean

Draft: this is a genuine first slice, not the full PR 2. Marking ready once the maintainer confirms scope, or folding in the remaining pieces as follow-up commits on this branch.


Generated by Claude Code

claude added 2 commits August 18, 2026 09:48
Task #2 was marked complete without a recorded artifact — TRIAGE-RESULT.md
only carries PR 1's pass-1 harvest triage (B1-B3), not the §12 layout
profile the plan's O1 open item asks for. Ran it for real:

  cargo run --example r2il_corpus_profile --features lift --release

Across all 4 corpus binaries (stress_test, stress_test_opt, /bin/ls,
/usr/bin/env; 130193 sampled ops total): 100.00% fit the dst+src0+src1
inline shape, 0.00% need Vec routing, on every single binary. This
resolves O1 and settles §11's layout question for PR 2: inline, not
descriptor/hybrid, for this corpus family — with the caveats spelled
out in the file (CallOther arity unmeasured — no samples in this
corpus; O3's facet-overflow question stays open, absence of overflow
here is not proof of absence in general).

Full breakdown (per-binary op/CFG stats, facet projection, furnace
conservation cross-check) in CORPUS-PROFILE-RESULT.md.
Scoped increment of PR 2 ("route -> V3 projection + DTO hooks", plan
r2il-behavioral-ir-v1.md). The plan's SUBSTRATE RULING calls for a sink
trait behind which offline / lance-graph SoA / S3 are implementations,
chosen at the call site, never baked into the furnace — furnace/ore/slag
already carry no persistence assumption (verified: neither module touches
a file, the network, or an env var).

Ships:
- `RefinedTruthSink` trait — the seam. `ruff_r2il` takes NO lance-graph
  dependency to define it; a lance-graph-side crate implements it against
  its own SoA (facet.rs's own PR-3 deferral: the real classid mint lives
  there, not here).
- `OfflineSink` — backend 1, real and tested. Writes facts/residuals/report
  as `#version`/`#schema`-headed TSV per STAGED-CODEGEN-GUIDE.md §4's own
  additive-export rule; `read_report` round-trips.
- `S3Config::from_lookup`/`from_env` — backend 3's credential plumbing only
  (`AWS_ACCESS_KEY_ID`/`AWS_SECRET_ACCESS_KEY`/`AWS_ENDPOINT_URL_S3`/
  `AWS_REGION`, all-or-nothing, empty treated as unset). The actual signed
  PUT is explicitly NOT implemented — real scope for its own pass, not
  faked here. `from_lookup` exists so the refuse-on-partial-credentials
  test never mutates real env state (this crate forbids unsafe_code, and
  `std::env::set_var`/`remove_var` require it).
- Backend 2 (lance-graph zero-copy SoA): intentionally absent from this
  crate, per the trait's own design — see above.

Also: recorded the §12 corpus profile (O1) — 100.00% of 130193 sampled
ops across 4 binaries fit the dst+src0+src1 inline shape, 0.00% needed
Vec routing. Updated STAGED-CODEGEN-GUIDE.md's stale "NOT stable" flag on
FlatFact's a/b payload slots with that evidence: the existing shape needs
no re-carving for PR 2's layout choice (only the PER-KIND MEANING and
persistence encoding remain open).

Incidental finding, fixed: ruff/clippy.toml's disallowed-methods list is
directory-scoped, not Cargo-workspace-scoped, so it reaches this
workspace-EXCLUDED crate despite its reasons saying "in ty crates" —
ruff_r2il has no ty::System trait to route through. #[expect]'d at the
two call sites with that reasoning.

Not in this slice (real remaining PR 2 scope, not attempted): DTO/
codebook wiring beyond what facet.rs already has, the round-trip
reconstruction oracle, optional SPO projection of semantic facts, a
facts/residuals reader (only read_report exists).

Gates: 46/46 tests pass (34 unit + 12 lossless-fixture), clippy -D
warnings clean, fmt clean, cargo doc introduces zero new warnings (the
4 existing warnings are pre-existing, in furnace.rs/ore.rs, untouched
by this change).
@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_09fc4d52-57eb-4319-822f-6ea5fbc8c042)

@AdaWorldAPI
AdaWorldAPI marked this pull request as ready for review August 18, 2026 11:33
@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 b0e3480 into main Aug 18, 2026
31 of 34 checks passed
@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_5aa3c587-61e1-4ad2-994c-c7c9974cf720)

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