Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions crates/cognitive-shader-driver/src/attention_mask.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@
//! `AttentionMaskSoA` is `!Send` by design (non-atomic interior mutation).
//! Callers that need cross-thread access must wrap in `tokio::sync::Mutex`.
//!
//! # Registration
//! This file is intentionally NOT registered in `lib.rs`. The main thread
//! adds `pub mod attention_mask;` after the sprint-12 fleet completes.
//! # MailboxId
//! Imports the canonical `MailboxId` alias from
//! `lance_graph_contract::collapse_gate` (also re-exported here for ergonomic
//! `use cognitive_shader_driver::attention_mask::MailboxId` access).

/// Re-export the canonical `MailboxId` alias so this module compiles
/// standalone without an explicit `--extern` flag.
pub type MailboxId = u32;
pub use lance_graph_contract::collapse_gate::MailboxId;

// ── SoA row ──────────────────────────────────────────────────────────────────

Expand Down
19 changes: 19 additions & 0 deletions crates/cognitive-shader-driver/src/attention_mask_actor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,25 @@ pub trait AttentionMaskBackend {
fn is_active(&self, mailbox_id: MailboxId) -> bool;
}

/// Production-backend impl: wires the sibling `attention_mask::AttentionMaskSoA`
/// into the actor without forcing downstream consumers to write a newtype
/// (Rust orphan rules would block them — neither the trait nor the SoA is
/// theirs). Per codex P2 review on PR #388.
impl AttentionMaskBackend for crate::attention_mask::AttentionMaskSoA {
fn touch(&mut self, mailbox_id: MailboxId, w_slot: u8) -> bool {
crate::attention_mask::AttentionMaskSoA::touch(self, mailbox_id, w_slot)
}
fn evict_lru(&mut self) -> Option<MailboxId> {
crate::attention_mask::AttentionMaskSoA::evict_lru(self)
}
fn tick(&mut self) {
crate::attention_mask::AttentionMaskSoA::tick(self)
}
fn is_active(&self, mailbox_id: MailboxId) -> bool {
crate::attention_mask::AttentionMaskSoA::is_active(self, mailbox_id)
}
}

pub struct AttentionMaskActor<B: AttentionMaskBackend> {
inner: B,
pending_evictions: Vec<MailboxId>,
Expand Down
Loading