ogar-r2il: CallMask stores its words inline, and gains set-bit iteration - #288
Conversation
Wave W3 of the autoattended integration plan (MedCare-rs docs/INTEGRATION_WAVES_AUTOATTENDED.md). The plan filed this wave under lance-graph; the crate is actually here in OGAR -- drift caught at preflight and corrected rather than followed. CallMask's backing store moves from `Box<[u64]>` to an inline `[u64; MASK_WORDS]`, MASK_WORDS = 3 derived from the largest universe (LaneShape::Pairs = 180 calls, 180.div_ceil(64) == 3) rather than asserted. The mask no longer allocates, and CallMask becomes Copy -- consistent with its siblings R2ILFn / R2ILVocabulary in the same file, and already implied by the pre-existing `shape(&self) -> LaneShape`. `set_indices()` adds lazy ascending set-bit iteration (word scan, trailing_zeros / w &= w - 1); `materialize_indices()` is now its eager collect, so both share one scan and cannot drift apart. One substantive logic change, called out rather than folded in silently: `not()` previously cleared its tail via `.last_mut()`, which was correct ONLY because the boxed slice was sized exactly ceil(len/64). Against a fixed 3-word array the shapes that need fewer words (Triples 120 -> 2, Quads 90 -> 2) carry an always-zero high word that a naive `!w` would flip to all-ones -- phantom call slots. Clearing is now per-word against `len`. The pre-existing `a_complement_never_invents_call_slots` and `the_tail_word_carries_no_phantom_rows` tests cover exactly this, and both stay green. Tests added: an allocation-shape assertion computed from the field layout (not a hardcoded size), and set-bit iteration checked against empty / scattered / full masks for every LaneShape, cross-checked with materialize_indices. No existing assertion weakened or removed. Verified (orchestrator, one debug-0 pass): cargo fmt --check clean, cargo clippy --all-targets --no-deps clean, 17/17 tests green. Does NOT prove: any nanosecond or throughput claim. No benchmark was run; the allocation removal is a structural fact, not a measured speedup. Co-Authored-By: Claude <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
Included review availability: 0 reviews are currently available. Your included PR review attempts over the past 7 days set your current allowance at 3 reviews per hour. 📝 WalkthroughWalkthrough
ChangesCallMask representation and iteration
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to The change is localized to CallMask storage and set-bit iteration, with formatting, lint, and all reported tests passing; no actionable merge-blocking risk remains beyond normal checks and review. Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Comment |
…adder probe Two things, found in one motion: 1. Crate fix: R2ILVocabulary shipped the PUSHES column and an inherent pushes_result but never answered Vocabulary::domain_pushes_result, so ogar_loco::statement_bounds refused every R2IL call as Uncovered -- R2IL bodies were lowerable but not segmentable. The override now delegates to the table; test pair proves an R2IL store idiom segments and a variadic op stays refused. 2. Probe (D-CFW-LADDER, ledger entry appended): witness streams derived from a real FunctionBody with the loco statement as the Markov window and counterfactuals as statement-local semantic edits confined under CallMask/project. Four-rung visibility ladder measured: byte sees all three edit classes; exact areas see both dataflow edits; the register cast sees only midpoint-crossing dataflow edits (its 1-bit orientation is midpoint-granular -- first gate expected more and was falsified); increments are provably blind to every pure reordering. Rule substitution within a locus class reaches no stream tier. Verified against the #288 inline-words CallMask (branch merged with main before landing). 13 lib tests green; probe GREEN G0-G4. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KCGhDYoQBXs3poaR7sFuqp
Wave W3 of the autoattended integration plan.
CallMask's backing store moves fromBox<[u64]>to an inline[u64; MASK_WORDS], withMASK_WORDS = 3derived from the largestuniverse (
LaneShape::Pairs= 180 calls,180.div_ceil(64) == 3) ratherthan asserted. The mask no longer allocates, and
CallMaskbecomesCopy—consistent with its siblings
R2ILFn/R2ILVocabularyin the same file,and already implied by the pre-existing
shape(&self) -> LaneShape.set_indices()adds lazy ascending set-bit iteration (word scan,trailing_zeros/w &= w - 1);materialize_indices()is now its eagercollect, so one scan feeds both exits and they cannot drift apart.The one substantive logic change, called out rather than folded in
not()cleared its tail via.last_mut()— correct only because theboxed slice was sized exactly
ceil(len/64). Against a fixed 3-word arraythe shapes needing fewer words (Triples 120 → 2, Quads 90 → 2) carry an
always-zero high word that a naive
!wflips to all-ones: phantom callslots. Clearing is now per-word against
len.The pre-existing
a_complement_never_invents_call_slotsandthe_tail_word_carries_no_phantom_rowstests cover exactly this hazard, andboth stay green — they are what would have caught the naive version.
Tests
Added: an allocation-shape assertion computed from the field layout (not a
hardcoded size), and set-bit iteration checked against empty / scattered /
full masks for every
LaneShape, cross-checked againstmaterialize_indices. No existing assertion was weakened or removed.Verification
One debug-0 pass by the orchestrator (the worker that wrote the edit ran no
compiler, by contract):
cargo fmt -p ogar-r2il -- --check— cleancargo clippy -p ogar-r2il --all-targets --no-deps— clean (onedouble_must_usefound and fixed; CI runs-D warnings)cargo test -p ogar-r2il— 17/17 greenDoes not prove
Any nanosecond or throughput claim. No benchmark was run. Removing the
allocation is a structural fact, not a measured speedup — a bench would be
its own change.
Note: the wave plan filed this crate under a different repository; it lives
here. The drift was caught at preflight and corrected rather than followed.
Summary by CodeRabbit
New Features
Bug Fixes
Performance