Skip to main content

Creed

Struct Creed 

Source
pub struct Creed {
Show 18 fields pub id: CreedId, pub fighter_name: String, pub fighter_id: Option<FighterId>, pub identity: String, pub personality: HashMap<String, f64>, pub directives: Vec<String>, pub self_model: SelfModel, pub learned_behaviors: Vec<LearnedBehavior>, pub interaction_style: InteractionStyle, pub relationships: Vec<Relationship>, pub heartbeat: Vec<HeartbeatTask>, pub delegation_rules: Vec<DelegationRule>, pub preferences: HashMap<String, String>, pub bout_count: u64, pub message_count: u64, pub created_at: DateTime<Utc>, pub updated_at: DateTime<Utc>, pub version: u64,
}
Expand description

The Creed — a fighter’s living identity document.

Every fighter process has a Creed that defines who they are, how they behave, what they’ve learned, and how they see themselves. The Creed is:

  • Injected at spawn: loaded from DB and prepended to the system prompt
  • Persistent across reboots: survives kill/respawn cycles
  • Evolving: updated after interactions based on what the fighter learns
  • Customizable: users can write and modify creeds per-fighter

Fields§

§id: CreedId

Unique creed ID.

§fighter_name: String

The fighter this creed belongs to. Tied to fighter name (not just UUID) so it persists across respawns.

§fighter_id: Option<FighterId>

Optional fighter ID for currently active instance.

§identity: String

The identity section — who this fighter IS. Example: “You are ECHO, a introspective analyst who values precision…”

§personality: HashMap<String, f64>

Personality traits as key-value pairs. Example: {“curiosity”: 0.9, “caution”: 0.3, “humor”: 0.7}

§directives: Vec<String>

Core directives — immutable behavioral rules. Example: [“Always explain your reasoning”, “Never fabricate data”]

§self_model: SelfModel

Self-model — what the fighter understands about its own architecture. Auto-populated with runtime awareness (model name, capabilities, constraints).

§learned_behaviors: Vec<LearnedBehavior>

Learned behaviors — observations the fighter has made about itself. These evolve over time through interaction.

§interaction_style: InteractionStyle

Interaction style preferences.

§relationships: Vec<Relationship>

Relationship memory — how this fighter relates to known entities.

§heartbeat: Vec<HeartbeatTask>

Heartbeat — proactive tasks this fighter checks on its own initiative. The fighter’s autonomous task checklist, evaluated periodically.

§delegation_rules: Vec<DelegationRule>

Delegation rules — how this fighter routes work to other agents. Defines the fighter’s multi-agent collaboration behavior.

§preferences: HashMap<String, String>

Structured preferences (quiet hours, notification style, etc.). Set via self-config tools or learned from interactions.

§bout_count: u64

Total bouts this creed has been active for.

§message_count: u64

Total messages processed under this creed.

§created_at: DateTime<Utc>

When this creed was first created.

§updated_at: DateTime<Utc>

When this creed was last updated.

§version: u64

Version counter — increments on each evolution.

Implementations§

Source§

impl Creed

Source

pub fn new(fighter_name: &str) -> Self

Create a new empty creed for a fighter.

Source

pub fn with_identity(self, identity: &str) -> Self

Create a creed with a full identity and personality.

Source

pub fn with_trait(self, name: &str, value: f64) -> Self

Add a personality trait.

Source

pub fn with_directive(self, directive: &str) -> Self

Add a directive.

Source

pub fn with_self_awareness(self, manifest: &FighterManifest) -> Self

Populate the self-model from a FighterManifest.

Source

pub fn with_heartbeat_task(self, task: &str, cadence: &str) -> Self

Add a heartbeat task — something the fighter proactively checks.

Source

pub fn with_delegation( self, task_type: &str, delegate_to: &str, condition: &str, priority: &str, ) -> Self

Add a delegation rule — how to route work to other agents.

Source

pub fn due_heartbeat_tasks(&self) -> Vec<&HeartbeatTask>

Return references to active heartbeat tasks whose cadence has elapsed.

Cadence rules:

  • "every_bout" — always due (reactive, fires on user message)
  • "on_wake" — due only if last_checked is None (first bout)
  • "hourly" — due if never checked or > 1 hour since last check
  • "daily" — due if never checked or > 24 hours since last check
  • "weekly" — due if never checked or > 7 days since last check
  • "every Xm" / "every Xh" / cron — parsed as duration, due if elapsed
Source

pub fn is_valid_cadence(cadence: &str) -> bool

Check if a cadence string is valid (parseable as a schedule).

Used by the tool executor to validate user-provided cadences beyond the builtin keywords.

Source

pub fn mark_heartbeat_checked(&mut self, task_index: usize)

Mark a heartbeat task as checked: sets last_checked to now and increments execution_count.

Silently does nothing if task_index is out of bounds.

Source

pub fn record_bout(&mut self)

Record that a bout was completed.

Source

pub fn record_messages(&mut self, count: u64)

Record messages processed.

Source

pub fn learn(&mut self, observation: &str, confidence: f64)

Add a learned behavior observation.

Source

pub fn decay_learned_behaviors(&mut self, decay_rate: f64, min_confidence: f64)

Apply time-based confidence decay to learned behaviors. Behaviors that fall below min_confidence are removed.

Source

pub fn prune_learned_behaviors(&mut self, max: usize)

Prune learned behaviors to keep only the top N by confidence.

Source

pub fn render(&self) -> String

Render the creed as a system prompt section to inject.

Source

pub fn render_compact(&self) -> String

Compact creed rendering for token-efficient contexts.

Omits empty sections entirely, uses inline trait format instead of bar graphs, skips delegation rules and architecture notes, and uses shorter headers. Typically 300-800 tokens vs 700-2,500 for full render.

Trait Implementations§

Source§

impl Clone for Creed

Source§

fn clone(&self) -> Creed

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Creed

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Creed

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Creed

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl Freeze for Creed

§

impl RefUnwindSafe for Creed

§

impl Send for Creed

§

impl Sync for Creed

§

impl Unpin for Creed

§

impl UnsafeUnpin for Creed

§

impl UnwindSafe for Creed

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,