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
impl Atomiser
Sourcepub fn new(
curator: Box<dyn Curator>,
keypair: Option<Arc<AgentKeypair>>,
config: AtomiserConfig,
tier: FeatureTier,
) -> Self
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.
Sourcepub fn with_curator_model(self, curator_model: impl Into<String>) -> Self
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.
Sourcepub fn curator_model(&self) -> &str
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.
Sourcepub fn sync_curator_max_retries(&self) -> u32
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.
Sourcepub async fn atomise(
&self,
conn: &Connection,
source_id: &str,
max_atom_tokens: u32,
force: bool,
calling_agent_id: &str,
) -> Result<AtomiseResult, AtomiseError>
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.
Sourcepub fn atomise_sync(
&self,
conn: &Connection,
source_id: &str,
max_atom_tokens: u32,
force: bool,
calling_agent_id: &str,
) -> Result<AtomiseResult, AtomiseError>
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).
Sourcepub 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>
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§
impl !RefUnwindSafe for Atomiser
impl !UnwindSafe for Atomiser
impl Freeze for Atomiser
impl Send for Atomiser
impl Sync for Atomiser
impl Unpin for Atomiser
impl UnsafeUnpin for Atomiser
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
impl<T> ErasedDestructor for Twhere
T: 'static,
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