Skip to main content

Atomiser

Struct Atomiser 

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

The atomisation engine.

Holds the curator (trait object so tests inject a mock), an optional signing keypair (matches the curator pass surface; None means writes land unsigned), the substrate connection (Arc<Mutex<...>>-wrapped at higher levels — the substrate expects a &Connection per call), and the tunables.

Re-uses crate::storage::insert / crate::storage::create_link_signed rather than reaching into the DB directly so the substrate-level hook layer (pre_store / post_store / pre_link / post_link) fires for every atom and every derives_from edge.

Implementations§

Source§

impl Atomiser

Source

pub fn new( curator: Box<dyn Curator>, keypair: Option<Arc<AgentKeypair>>, config: AtomiserConfig, tier: FeatureTier, ) -> Self

Construct an atomiser. curator is the LLM-facing surface (production: curator::LlmCurator; tests: a mock). keypair is the daemon’s Ed25519 identity — when None, links land unsigned (mirror of create_link_signed’s contract). tier is the resolved feature tier; the keyword tier short- circuits atomise calls immediately.

Source

pub fn with_curator_model(self, curator_model: impl Into<String>) -> Self

v0.7.0 (issue #1244) — builder method that stamps the resolved curator model name into the atomiser. Threaded into the atomisation_complete signed-event payload as the curator_model field so downstream auditors see the model that actually ran on this deployment (grok-4.3, claude-opus-4.7, gemma3:4b, etc.), not the pre-#1244 hardcoded "gemma4".

Production wiring sites pass llm_client.model_name() (from crate::llm::OllamaClient). The model id passes through verbatim — no normalisation, no defaulting beyond the "unknown" fallback applied by Self::new.

Source

pub fn curator_model(&self) -> &str

v0.7.0 (issue #1244) — accessor for the resolved curator model. Exposed for the regression test that pins the atomisation_complete payload’s curator_model field reflects the model threaded in at construction.

Source

pub fn sync_curator_max_retries(&self) -> u32

Cluster-F PERF-5 — accessor for the configured Synchronous-mode curator retry budget. Used by the pre_store::auto_atomise.rs hook to honour AtomiserConfig::sync_curator_max_retries (compiled default 1) when the namespace policy has no explicit auto_atomise_max_retries override.

Source

pub async fn atomise( &self, conn: &Connection, source_id: &str, max_atom_tokens: u32, force: bool, calling_agent_id: &str, ) -> Result<AtomiseResult, AtomiseError>

Atomise the memory named by source_id.

max_atom_tokens overrides the per-call token budget; pass 0 to defer to config.default_max_atom_tokens.

force skips the idempotency check (use to re-atomise after a curator-prompt change). Old atoms are retained and atomised_into is updated to the fresh count.

§Errors

See AtomiseError for the closed enum of failure modes.

§Async note

The function is async to match the WT-1-B brief signature even though the substrate body is fully synchronous (sqlite is blocking; tiktoken is blocking; the curator LLM call is blocking-on-HTTP-thread). The async signature exists so callers in tokio-runtime contexts (the MCP server, the autonomy scheduler) can await it without spawning a blocking task themselves.

Source

pub fn atomise_sync( &self, conn: &Connection, source_id: &str, max_atom_tokens: u32, force: bool, calling_agent_id: &str, ) -> Result<AtomiseResult, AtomiseError>

Sync entry-point — body of Self::atomise. Exposed for tests that prefer to call without tokio scaffolding. Uses the configured curator_max_retries (deferred-path default).

Source

pub fn atomise_sync_with_retries( &self, conn: &Connection, source_id: &str, max_atom_tokens: u32, force: bool, calling_agent_id: &str, max_retries: u32, ) -> Result<AtomiseResult, AtomiseError>

Cluster-F PERF-5 — variant of Self::atomise_sync that takes an explicit per-call max_retries override. The Synchronous pre_store path uses this with sync_curator_max_retries (default 1) so the operator’s memory_store envelope is not inflated by the full deferred-path retry budget. Per-namespace override via GovernancePolicy::auto_atomise_max_retries flows through this entry-point.

§Errors

See AtomiseError for the closed enum.

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> ErasedDestructor for T
where T: 'static,

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: Sized + 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: Sized + 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