pub struct PersonaGenerator<'a> { /* private fields */ }Expand description
The persona-generation engine.
Constructed per call (cheap — just holds references). Generation is
idempotent in the sense that calling generate twice writes two
distinct rows with consecutive version numbers; the substrate
never overwrites a persona in place so audit trails stay intact.
Implementations§
Source§impl<'a> PersonaGenerator<'a>
impl<'a> PersonaGenerator<'a>
Sourcepub fn new(
conn: &'a Connection,
llm: &'a dyn AutonomyLlm,
signer: Option<&'a AgentKeypair>,
config: PersonaConfig,
) -> Self
pub fn new( conn: &'a Connection, llm: &'a dyn AutonomyLlm, signer: Option<&'a AgentKeypair>, config: PersonaConfig, ) -> Self
Construct a fresh generator.
Sourcepub fn generate(
&self,
entity_id: &str,
namespace: &str,
) -> Result<Persona, PersonaError>
pub fn generate( &self, entity_id: &str, namespace: &str, ) -> Result<Persona, PersonaError>
Generate a fresh Persona for entity_id in namespace.
§Steps
- Validate
entity_id(non-empty, within identity bounds) andnamespace. - Load up to
config.max_reflection_sourcesReflection-kind memories fromnamespacereferencing the entity. - Refuse with
PersonaError::NoReflectionswhen the pool is empty — a Persona without sources has no audit trail. - Resolve the next
version(max existing + 1, defaulting 1). - Call the curator (
AutonomyLlm::summarize_memories) over the sources to produce the Markdown body. - Insert a
MemoryKind::Personamemory row withentity_id+persona_versionpopulated and metadata carrying thepersonaenvelope. - Write one
derives_frommemory_linkfrom the persona row to each source reflection. - Append a
persona_generatedrow tosigned_events.
§Errors
One of the PersonaError variants. The DB-level errors are
the only ones without a structured payload — every other
variant carries enough context for a clean operator message.
Sourcepub fn generate_cross_namespace(
&self,
entity_id: &str,
target_namespace: &str,
) -> Result<Persona, PersonaError>
pub fn generate_cross_namespace( &self, entity_id: &str, target_namespace: &str, ) -> Result<Persona, PersonaError>
v0.7.0 issue #848 — cross-namespace persona generation.
Equivalent to Self::generate except the source-reflection
scan is broadened to every namespace the substrate stores. The
new persona row lands in target_namespace (callers
typically pass "global" so subsequent
memory_persona(entity_id) reads have a deterministic
landing zone). Use this when an NHI agent has spread its
reflections across multiple namespaces (e.g.
global/policies, ai-memory/v0.7.0-nhi-testing, project
buckets) and needs a single Persona that aggregates the full
identity arc.
§Errors
Same envelope as Self::generate. When zero matching
reflections exist in ANY namespace, the
NoReflections.namespace field is the
CROSS_NAMESPACE_SENTINEL string.
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for PersonaGenerator<'a>
impl<'a> !Send for PersonaGenerator<'a>
impl<'a> !Sync for PersonaGenerator<'a>
impl<'a> !UnwindSafe for PersonaGenerator<'a>
impl<'a> Freeze for PersonaGenerator<'a>
impl<'a> Unpin for PersonaGenerator<'a>
impl<'a> UnsafeUnpin for PersonaGenerator<'a>
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