Skip to content

ogar-r2il: CallMask stores its words inline, and gains set-bit iteration - #288

Merged
AdaWorldAPI merged 1 commit into
mainfrom
claude/medcare-rs-continue-6nhbxn
Aug 31, 2026
Merged

ogar-r2il: CallMask stores its words inline, and gains set-bit iteration#288
AdaWorldAPI merged 1 commit into
mainfrom
claude/medcare-rs-continue-6nhbxn

Conversation

@AdaWorldAPI

@AdaWorldAPI AdaWorldAPI commented Aug 31, 2026

Copy link
Copy Markdown
Owner

Wave W3 of the autoattended integration plan.

CallMask's backing store moves from Box<[u64]> to an inline
[u64; MASK_WORDS], with 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 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 the
boxed slice was sized exactly ceil(len/64). Against a fixed 3-word array
the shapes needing fewer words (Triples 120 → 2, Quads 90 → 2) carry an
always-zero high word that a naive !w flips 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 hazard, and
both 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 against
materialize_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 — clean
  • cargo clippy -p ogar-r2il --all-targets --no-deps — clean (one
    double_must_use found and fixed; CI runs -D warnings)
  • cargo test -p ogar-r2il17/17 green

Does 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

    • Added an iterator for retrieving set lane indices in ascending order.
    • Call masks can now be copied directly.
  • Bug Fixes

    • Mask complementation now correctly clears unused bits across all lane shapes.
  • Performance

    • Improved call-mask storage and bitwise operations using fixed-size inline data.

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>
@coderabbitai

coderabbitai Bot commented Aug 31, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 16e1db71-f4b9-4a93-a76e-11cc98afde48

📥 Commits

Reviewing files that changed from the base of the PR and between d1116c1 and e754208.

📒 Files selected for processing (1)
  • crates/ogar-r2il/src/lib.rs

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.


📝 Walkthrough

Walkthrough

CallMask now uses three inline u64 words and derives Copy. Mask operations preserve valid lane bits. A lazy ascending iterator exposes selected indices, and tests cover storage, copying, iteration, and materialization.

Changes

CallMask representation and iteration

Layer / File(s) Summary
Inline storage and mask operations
crates/ogar-r2il/src/lib.rs
CallMask uses fixed inline words instead of boxed storage. Construction and combination use fixed arrays. Complementation clears unused bits.
Set-index iteration and validation
crates/ogar-r2il/src/lib.rs
set_indices yields selected indices in ascending order. materialize_indices collects from it. Tests cover all lane shapes and mask patterns.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to e7542

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: claude

Poem

A rabbit found three words in line,
And copied masks became quite fine.
Bits hop upward, neat and bright,
Phantom bits stay out of sight.
Tests applaud the ordered flight.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 77.78% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes both primary changes: inline CallMask storage and set-bit iteration.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

Comment @coderabbitai help to get the list of available commands.

@AdaWorldAPI
AdaWorldAPI merged commit cb4bf48 into main Aug 31, 2026
3 checks passed
AdaWorldAPI pushed a commit that referenced this pull request Aug 31, 2026
…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
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