Skip to main content

WriterActor

Struct WriterActor 

Source
pub struct WriterActor { /* private fields */ }
Expand description

The writer actor.

Implementations§

Source§

impl WriterActor

Source

pub fn spawn( conn: Connection, hnsw: Arc<dyn VectorIndex + Send + Sync>, ) -> WriterSpawn

Source

pub fn spawn_with_capacity( conn: Connection, hnsw: Arc<dyn VectorIndex + Send + Sync>, capacity: usize, ) -> WriterSpawn

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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/stream SSE 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§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more