pub struct WriterActor { /* private fields */ }Expand description
The writer actor.
Implementations§
Source§impl WriterActor
impl WriterActor
pub fn spawn( conn: Connection, hnsw: Arc<dyn VectorIndex + Send + Sync>, ) -> WriterSpawn
pub fn spawn_with_capacity( conn: Connection, hnsw: Arc<dyn VectorIndex + Send + Sync>, capacity: usize, ) -> WriterSpawn
Sourcepub fn spawn_with_snapshot_dir(
conn: Connection,
hnsw: Arc<dyn VectorIndex + Send + Sync>,
snapshot_dir: PathBuf,
) -> WriterSpawn
pub fn spawn_with_snapshot_dir( conn: Connection, hnsw: Arc<dyn VectorIndex + Send + Sync>, snapshot_dir: PathBuf, ) -> WriterSpawn
Spawn with a snapshot directory wired up. The daemon main calls this
path so WriteCommand::SaveSnapshot can reach disk.
Sourcepub fn spawn_full(
conn: Connection,
hnsw: Arc<dyn VectorIndex + Send + Sync>,
snapshot_dir: PathBuf,
embedder_id: i64,
) -> WriterSpawn
pub fn spawn_full( conn: Connection, hnsw: Arc<dyn VectorIndex + Send + Sync>, snapshot_dir: PathBuf, embedder_id: i64, ) -> WriterSpawn
Spawn with both snapshot dir + cached embedder_id. The daemon
main calls this so every remember also INSERTs into the
embeddings table for durability + future solo reembed.
Sourcepub fn spawn_full_with_embedder(
conn: Connection,
hnsw: Arc<dyn VectorIndex + Send + Sync>,
snapshot_dir: PathBuf,
embedder_id: i64,
embedder: Arc<dyn Embedder>,
) -> WriterSpawn
pub fn spawn_full_with_embedder( conn: Connection, hnsw: Arc<dyn VectorIndex + Send + Sync>, snapshot_dir: PathBuf, embedder_id: i64, embedder: Arc<dyn Embedder>, ) -> WriterSpawn
Spawn with snapshot dir + embedder_id + the active embedder. Use
this from any path that may invoke WriteCommand::Reembed — i.e.
the solo reembed one-shot. Captures Handle::current() to bridge
the async embedder API onto the writer’s blocking thread.
Requires a multi-thread tokio runtime. Panics if called outside
any runtime context. On a current_thread runtime it would NOT
panic, but handle_reembed’s runtime.block_on(embedder.embed(...))
from the writer thread would deadlock — the runtime’s only worker
would be the test’s outer thread, already blocked awaiting the
reembed reply. Production callers run inside #[tokio::main]
(multi-thread by default); tests use rt_multi(N) with N >= 1
worker independent of the test’s calling thread.
Sourcepub fn spawn_full_with_embedder_and_optional_steward(
conn: Connection,
hnsw: Arc<dyn VectorIndex + Send + Sync>,
snapshot_dir: PathBuf,
embedder_id: i64,
embedder: Arc<dyn Embedder>,
steward: Option<Arc<Steward>>,
) -> WriterSpawn
pub fn spawn_full_with_embedder_and_optional_steward( conn: Connection, hnsw: Arc<dyn VectorIndex + Send + Sync>, snapshot_dir: PathBuf, embedder_id: i64, embedder: Arc<dyn Embedder>, steward: Option<Arc<Steward>>, ) -> WriterSpawn
The full surface: snapshot + embedder + steward. Use this from
the solo consolidate one-shot path or from a prod daemon
that ships with a real LlmClient configured. The steward’s
Arc<dyn LlmClient> powers handle_consolidate’s abstraction
step (Y.3.3); without a steward, consolidate runs the
clustering pass only.
Sourcepub fn spawn_full_with_key_and_optional_steward(
conn: Connection,
hnsw: Arc<dyn VectorIndex + Send + Sync>,
snapshot_dir: PathBuf,
embedder_id: i64,
embedder: Arc<dyn Embedder>,
steward: Option<Arc<Steward>>,
key: KeyMaterial,
) -> WriterSpawn
pub fn spawn_full_with_key_and_optional_steward( conn: Connection, hnsw: Arc<dyn VectorIndex + Send + Sync>, snapshot_dir: PathBuf, embedder_id: i64, embedder: Arc<dyn Embedder>, steward: Option<Arc<Steward>>, key: KeyMaterial, ) -> WriterSpawn
Like Self::spawn_full_with_embedder_and_optional_steward but
also captures key so the writer can serve WriteCommand::Backup.
The daemon (and one-shot paths that want HTTP-side backup) use
this variant; pure-test spawn paths can use the no-key variant.
Sourcepub fn spawn_full_with_key_steward_and_runtime(
conn: Connection,
hnsw: Arc<dyn VectorIndex + Send + Sync>,
snapshot_dir: PathBuf,
embedder_id: i64,
embedder: Arc<dyn Embedder>,
steward: Option<Arc<Steward>>,
key: KeyMaterial,
runtime_handle: Handle,
) -> WriterSpawn
pub fn spawn_full_with_key_steward_and_runtime( conn: Connection, hnsw: Arc<dyn VectorIndex + Send + Sync>, snapshot_dir: PathBuf, embedder_id: i64, embedder: Arc<dyn Embedder>, steward: Option<Arc<Steward>>, key: KeyMaterial, runtime_handle: Handle, ) -> WriterSpawn
Variant of Self::spawn_full_with_key_and_optional_steward that
takes an explicit runtime_handle rather than calling
Handle::current(). v0.8.0 P2: TenantHandle::open is sync (the
registry’s lazy-load path is async fn but calls it via
spawn_blocking), so we cannot rely on a current runtime; the
caller passes the handle in.
Sourcepub fn spawn_full_with_redactor(
conn: Connection,
hnsw: Arc<dyn VectorIndex + Send + Sync>,
snapshot_dir: PathBuf,
embedder_id: i64,
embedder: Arc<dyn Embedder>,
steward: Option<Arc<Steward>>,
key: KeyMaterial,
runtime_handle: Handle,
redactor: Arc<RedactionRegistry>,
) -> WriterSpawn
pub fn spawn_full_with_redactor( conn: Connection, hnsw: Arc<dyn VectorIndex + Send + Sync>, snapshot_dir: PathBuf, embedder_id: i64, embedder: Arc<dyn Embedder>, steward: Option<Arc<Steward>>, key: KeyMaterial, runtime_handle: Handle, redactor: Arc<RedactionRegistry>, ) -> WriterSpawn
v0.8.0 P5: variant of Self::spawn_full_with_key_steward_and_runtime
that also threads in a pre-built RedactionRegistry. Used by
TenantHandle::open so the per-data-dir [redaction] config
reaches the writer-actor.
Sourcepub fn spawn_full_with_quota(
conn: Connection,
hnsw: Arc<dyn VectorIndex + Send + Sync>,
snapshot_dir: PathBuf,
embedder_id: i64,
embedder: Arc<dyn Embedder>,
steward: Option<Arc<Steward>>,
key: KeyMaterial,
runtime_handle: Handle,
redactor: Arc<RedactionRegistry>,
quota_bytes: Option<u64>,
db_path: PathBuf,
) -> WriterSpawn
pub fn spawn_full_with_quota( conn: Connection, hnsw: Arc<dyn VectorIndex + Send + Sync>, snapshot_dir: PathBuf, embedder_id: i64, embedder: Arc<dyn Embedder>, steward: Option<Arc<Steward>>, key: KeyMaterial, runtime_handle: Handle, redactor: Arc<RedactionRegistry>, quota_bytes: Option<u64>, db_path: PathBuf, ) -> WriterSpawn
v0.8.1 P3: variant of Self::spawn_full_with_redactor that
also captures the cached per-tenant quota_bytes and db_path
so the writer-actor’s handle_remember / handle_ingest_document
can enforce the quota before INSERT. quota_bytes = None means
unlimited (default for tenants without a quota set); enforcement
short-circuits in one branch.
Sourcepub fn spawn_full_with_quota_and_slot(
conn: Connection,
hnsw: Arc<dyn VectorIndex + Send + Sync>,
snapshot_dir: PathBuf,
embedder_id: i64,
embedder: Arc<dyn Embedder>,
steward: Option<Arc<Steward>>,
key: KeyMaterial,
runtime_handle: Handle,
redactor: Arc<RedactionRegistry>,
quota_bytes: Option<u64>,
db_path: PathBuf,
steward_slot: Arc<AsyncRwLock<Option<Arc<Steward>>>>,
triples_batch_signal: Option<Arc<TriplesBatchSignal>>,
) -> WriterSpawn
pub fn spawn_full_with_quota_and_slot( conn: Connection, hnsw: Arc<dyn VectorIndex + Send + Sync>, snapshot_dir: PathBuf, embedder_id: i64, embedder: Arc<dyn Embedder>, steward: Option<Arc<Steward>>, key: KeyMaterial, runtime_handle: Handle, redactor: Arc<RedactionRegistry>, quota_bytes: Option<u64>, db_path: PathBuf, steward_slot: Arc<AsyncRwLock<Option<Arc<Steward>>>>, triples_batch_signal: Option<Arc<TriplesBatchSignal>>, ) -> WriterSpawn
v0.9.0 P4a: variant of Self::spawn_full_with_quota that also
threads the per-tenant steward_slot so the writer-actor’s
consolidate path can observe late-bound sampling-backed
Stewards (populated by the MCP-initialize hook after writer
spawn). Called from [crate::tenants::handle::TenantHandle:: open] — every other spawn path stays on spawn_full_with_quota
and falls back to self.steward in Self::current_steward.
Per plan §4 P4a: “WriterActor reads tenant.steward_slot() per
command (or per consolidate-tick), falling back to self.steward
if the slot is None.” The slot-read is cheap
(steward_slot.try_read().clone() returns
Option<Arc<Steward>>; the clone is an Arc-bump). For the
sampling backend specifically, self.steward is None at spawn
(the factory builds a no-op); the slot read picks up the
Steward once the MCP session is initialized.
Sourcepub fn spawn_full_with_invalidate(
conn: Connection,
hnsw: Arc<dyn VectorIndex + Send + Sync>,
snapshot_dir: PathBuf,
embedder_id: i64,
embedder: Arc<dyn Embedder>,
steward: Option<Arc<Steward>>,
key: KeyMaterial,
runtime_handle: Handle,
redactor: Arc<RedactionRegistry>,
quota_bytes: Option<u64>,
db_path: PathBuf,
steward_slot: Arc<AsyncRwLock<Option<Arc<Steward>>>>,
triples_batch_signal: Option<Arc<TriplesBatchSignal>>,
invalidate_tx: Sender<InvalidateEvent>,
invalidate_tenant_id: String,
) -> WriterSpawn
pub fn spawn_full_with_invalidate( conn: Connection, hnsw: Arc<dyn VectorIndex + Send + Sync>, snapshot_dir: PathBuf, embedder_id: i64, embedder: Arc<dyn Embedder>, steward: Option<Arc<Steward>>, key: KeyMaterial, runtime_handle: Handle, redactor: Arc<RedactionRegistry>, quota_bytes: Option<u64>, db_path: PathBuf, steward_slot: Arc<AsyncRwLock<Option<Arc<Steward>>>>, triples_batch_signal: Option<Arc<TriplesBatchSignal>>, invalidate_tx: Sender<InvalidateEvent>, invalidate_tenant_id: String, ) -> WriterSpawn
v0.10.0: variant of Self::spawn_full_with_quota_and_slot that
also threads the per-tenant broadcast::Sender<InvalidateEvent>
- the tenant id string so the writer-actor can fan out
post-commit invalidations to
GET /v1/graph/streamSSE subscribers. Called from [crate::tenants::handle::TenantHandle:: open] (the prod entry point); test paths can use any of the older spawn variants and skip invalidation broadcasting.
Invariant (lesson #30): the broadcast send happens AFTER the
writer-actor’s commit returns Ok. Rolled-back writes MUST NOT
produce an event. Implementation lives in each mutation handler’s
dispatch wrapper next to the audit-emit (success path) /
emit_audit_best_effort (failure path) call.
Auto Trait Implementations§
impl !Freeze for WriterActor
impl !RefUnwindSafe for WriterActor
impl Send for WriterActor
impl !Sync for WriterActor
impl Unpin for WriterActor
impl UnsafeUnpin for WriterActor
impl !UnwindSafe for WriterActor
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more