Skip to content

Commit 0bc2833

Browse files
committed
fix(sprint-12/wave-F): codex P2 — AttentionMaskBackend impl for AttentionMaskSoA + canonical MailboxId import
Codex P2 review on PR #388 flagged that `AttentionMaskActor` is public but `AttentionMaskSoA` (the only production backend in the crate) doesn't implement `AttentionMaskBackend`. Downstream consumers can't add the impl themselves because they own neither the trait nor the SoA (Rust orphan rules), so `AttentionMaskActor::new(AttentionMaskSoA::new(...))` would force them to wrap in a local newtype. Fix #1 — production-backend impl in attention_mask_actor.rs Added `impl AttentionMaskBackend for crate::attention_mask::AttentionMaskSoA` with the four trait methods delegating to the existing inherent methods on AttentionMaskSoA. Now downstream consumers can wire the two directly: `AttentionMaskActor::new(AttentionMaskSoA::new(4))` works out of the box. Fix #2 — collapses CSI-10 from the W-Meta-Opus honest review The W-F2 worker had defined a local `pub type MailboxId = u32` in attention_mask.rs (Opus CSI-10 entry: "W-F2 used local MailboxId shadow alias"). Switched to `pub use lance_graph_contract::collapse_gate::MailboxId;` — same underlying u32 so all method signatures stay compatible, but now both attention_mask.rs and attention_mask_actor.rs reference the SAME canonical type and the trait impl in fix #1 can be added without type-mismatch concerns. Test status: 14/14 attention_mask + attention_mask_actor tests pass. Clean compile (modulo 2 pre-existing unused_mut warnings unrelated to this change). Branch rebased on main (post PR #385 merge) to pick up the ndarray hpc-extras feature flag that W-C1 added; this resolves the blake3 unresolved-crate compile failure that hit cognitive-shader-driver prior to rebase. https://claude.ai/code/session_01UwJuKqP828qyX1VkLgGJFS
1 parent 77f2d26 commit 0bc2833

2 files changed

Lines changed: 24 additions & 6 deletions

File tree

crates/cognitive-shader-driver/src/attention_mask.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,12 @@
88
//! `AttentionMaskSoA` is `!Send` by design (non-atomic interior mutation).
99
//! Callers that need cross-thread access must wrap in `tokio::sync::Mutex`.
1010
//!
11-
//! # Registration
12-
//! This file is intentionally NOT registered in `lib.rs`. The main thread
13-
//! adds `pub mod attention_mask;` after the sprint-12 fleet completes.
11+
//! # MailboxId
12+
//! Imports the canonical `MailboxId` alias from
13+
//! `lance_graph_contract::collapse_gate` (also re-exported here for ergonomic
14+
//! `use cognitive_shader_driver::attention_mask::MailboxId` access).
1415
15-
/// Re-export the canonical `MailboxId` alias so this module compiles
16-
/// standalone without an explicit `--extern` flag.
17-
pub type MailboxId = u32;
16+
pub use lance_graph_contract::collapse_gate::MailboxId;
1817

1918
// ── SoA row ──────────────────────────────────────────────────────────────────
2019

crates/cognitive-shader-driver/src/attention_mask_actor.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,25 @@ pub trait AttentionMaskBackend {
3333
fn is_active(&self, mailbox_id: MailboxId) -> bool;
3434
}
3535

36+
/// Production-backend impl: wires the sibling `attention_mask::AttentionMaskSoA`
37+
/// into the actor without forcing downstream consumers to write a newtype
38+
/// (Rust orphan rules would block them — neither the trait nor the SoA is
39+
/// theirs). Per codex P2 review on PR #388.
40+
impl AttentionMaskBackend for crate::attention_mask::AttentionMaskSoA {
41+
fn touch(&mut self, mailbox_id: MailboxId, w_slot: u8) -> bool {
42+
crate::attention_mask::AttentionMaskSoA::touch(self, mailbox_id, w_slot)
43+
}
44+
fn evict_lru(&mut self) -> Option<MailboxId> {
45+
crate::attention_mask::AttentionMaskSoA::evict_lru(self)
46+
}
47+
fn tick(&mut self) {
48+
crate::attention_mask::AttentionMaskSoA::tick(self)
49+
}
50+
fn is_active(&self, mailbox_id: MailboxId) -> bool {
51+
crate::attention_mask::AttentionMaskSoA::is_active(self, mailbox_id)
52+
}
53+
}
54+
3655
pub struct AttentionMaskActor<B: AttentionMaskBackend> {
3756
inner: B,
3857
pending_evictions: Vec<MailboxId>,

0 commit comments

Comments
 (0)