Expand description
CELLSTATE Core - Entity Types
Core domain types and shared logic. All other crates depend on this. Contains domain types, scoring, decay, drift detection, and event-sourcing primitives.
§Type Dictionary
This crate serves as the “type dictionary” for CELLSTATE. All types visible here form the vocabulary of the system:
- Identity: Type-safe ID newtypes (
TenantId,TrajectoryId, etc.),Timestamp,ContentHash - Enums: Status types, entity types, categories. DB enum values use snake_case when
writing; reading accepts legacy PascalCase/mixed-case via
from_db_str(seeenums). - Entities: Core domain entities (Trajectory, Scope, Artifact, Note, Turn)
- Typestate: Compile-time safe Lock, Handoff, Delegation lifecycles
- Events: Event DAG types (EventHeader, DagPosition, EventKind)
- Effects: Error-as-effects pattern (Effect
, ErrorEffect)
Re-exports§
pub use event_sourcing::EventSourced;pub use filter::*;pub use drift::*;pub use sync_pulse::*;pub use agent_state::*;pub use web_mcp::*;pub use scoring::*;pub use decay::*;pub use intent::*;
Modules§
- agent 🔒
- Agent types for multi-agent coordination.
- agent_
state - Agent state derived from event history (NOT stored in DB)
- battle_
intel 🔒 - Battle Intel features: Edges, Evolution, Summarization
- config 🔒
- Configuration types
- context 🔒
- CELLSTATE Context - Context Assembly
- credentials
- Verifiable Credentials for Agent Identity
- decay
- Unified parametric decay module.
- delegation 🔒
- Delegation typestate for compile-time safety of delegation lifecycle.
- drift
- Composite divergence metric for multi-agent drift detection.
- effect 🔒
- Effect system for error-as-effects pattern.
- embedding 🔒
- Embedding vector operations
- entities 🔒
- Core entity structures
- enums 🔒
- Enum types for CELLSTATE entities
- error 🔒
- Error types for CELLSTATE operations
- event 🔒
- Event types for the Event DAG system.
- event_
sourcing - Systematic Event Sourcing
- filter
- Unified filter expressions for search and pack config
- handoff 🔒
- Handoff typestate for compile-time safety of handoff lifecycle.
- health 🔒
- Unified health check types
- identity 🔒
- Identity types for CELLSTATE entities
- intent
- Intent Engineering - Machine-readable organizational purpose
- llm 🔒
- LLM-related primitive types and traits.
- lock 🔒
- Lock typestate for compile-time safety of lock lifecycle.
- models
- Model discovery types.
- prompt_
template - Prompt Template — type-safe system prompt construction.
- redaction
- PII Redaction Types and Verification Registry
- scoring
- Deterministic scoring formula with transparency
- secret 🔒
- Secret wrappers for sensitive string material.
- session 🔒
- Session typestate for compile-time safety of stateful LLM session lifecycle.
- sync_
pulse - Event-driven synchronization pulse for multi-agent coordination.
- web_mcp
- WebMCP - Browser-native agent tool discovery primitives.
Structs§
- Acquired
- Lock is currently held (acquired).
- Action
Id - Type-safe ID for agent action entities.
- Active
- Session is active and accepting deltas.
- Agent
- An agent in the multi-agent system.
- Agent
Action - An action taken by an agent.
- Agent
Beliefs - Collection of an agent’s beliefs.
- Agent
Goal - A goal that an agent is pursuing.
- Agent
Handoff - A handoff from one agent to another.
- AgentId
- Type-safe ID for agent entities.
- Agent
Message - A message between agents.
- Agent
Observation - An observation made by an agent after an action.
- Agent
Plan - A plan to achieve a goal.
- Agent
Working SetEntry - Ephemeral document/KV working memory entry for an agent.
- ApiKey
Id - Type-safe ID for API key entities.
- Artifact
- Artifact - typed output preserved across scopes. Artifacts survive scope closure and can be referenced later.
- Artifact
Id - Type-safe ID for artifact entities.
- Assembly
Decision - Decision made during context assembly for audit trail.
- Belief
- A belief held by an agent.
- Belief
Id - Type-safe ID for agent belief entities.
- Blake3
Verifier - Blake3-based event verifier (default, recommended for performance).
- Causality
- W3C Trace Context compatible distributed tracing.
- Cellstate
Config - Master configuration struct. ALL values are required - no defaults anywhere.
- Checkpoint
- Checkpoint for scope recovery.
- Closed
- Session was closed normally (terminal).
- Conflict
- A conflict between memory items.
- Conflict
Id - Type-safe ID for conflict entities.
- Conflict
Resolution Record - Record of how a conflict was resolved.
- Content
Hash - SHA-256 content hash for deduplication and integrity verification.
- Context
Assembler - Context assembler that builds context windows from packages. Adds sections by priority until budget is exhausted.
- Context
Assembly Defaults - Default values for context assembly operations.
- Context
Outline - Lightweight outline of a context package for progressive disclosure.
- Context
Package - Context package - all inputs for assembly. Similar to ContextPackage in the TypeScript CRM pattern.
- Context
Page Diff - Diff between two context windows after re-paging.
- Context
Section - A section of the assembled context.
- Context
Window - Assembled context window with token budget management.
- Created
- Session has been created but not yet activated.
- DagPosition
- Position of an event in the DAG.
- Delegated
Task - A delegated task from one agent to another.
- Delegation
- A delegation with compile-time state tracking.
- Delegation
Accepted - Delegation was accepted but not yet started.
- Delegation
Completed - Delegation was completed successfully (terminal).
- Delegation
Failed - Delegation failed (terminal).
- Delegation
Id - Type-safe ID for delegation entities.
- Delegation
Record - Internal data storage for a delegation, independent of typestate. This is what gets persisted to the database.
- Delegation
Rejected - Delegation was rejected (terminal).
- Delegation
Result - Result of a completed delegation.
- Domain
Error Context - Domain error with event context for correlation and replay.
- Duration
Ms - Duration in milliseconds for TTL and timeout values.
- Edge
- Edge - graph relationship between entities. Supports both binary edges (A→B) and hyperedges (N-ary relationships).
- EdgeId
- Type-safe ID for edge entities.
- Edge
Participant - Participant in an edge with optional role. Enables both binary edges (2 participants) and hyperedges (N participants).
- Embedding
Vector - Embedding vector with dynamic dimensions. Supports any embedding model dimension (e.g., 384, 768, 1536, 3072).
- Enhanced
Provenance - Enhanced provenance with evidence chains.
- Entity
IdParse Error - Error type for parsing entity IDs from strings.
- Entity
Ref - Reference to an entity by type and ID.
- Enum
Parse Error - Error returned when parsing a DB enum string fails.
- Event
- A complete event with header and payload.
- Event
Builder - Builder for creating events with proper positioning.
- Event
Flags - Flags for event processing hints.
- Event
Header - Event header with all metadata needed for processing.
- EventId
- Type-safe ID for event entities.
- Event
Kind - Event kind encoded as a 16-bit value.
- Evolution
Metrics - Benchmark metrics from an evolution run.
- Evolution
Snapshot - Evolution snapshot for pack config benchmarking. Captures a frozen state of configuration for A/B testing.
- Extracted
Artifact - An artifact extracted from content.
- FlowId
- Type-safe ID for flow entities.
- Flow
Step Id - Type-safe ID for flow step entities.
- GoalId
- Type-safe ID for agent goal entities.
- Graph
Link - Graph link hint for context assembly (from SQL adjacency projection).
- Handoff
- A handoff with compile-time state tracking.
- Handoff
Accepted - Handoff was accepted by the receiving agent.
- Handoff
Completed - Handoff has been completed (terminal).
- Handoff
Id - Type-safe ID for handoff entities.
- Handoff
Record - Internal data storage for a handoff, independent of typestate. This is what gets persisted to the database.
- Hash
Chain - Hash chain for tamper-evident event log.
- Health
Check - Detailed health check result for a component.
- Heuristic
Tokenizer - Heuristic tokenizer using character-to-token ratios.
- InProgress
- Delegation work is in progress.
- Initiated
- Handoff has been initiated, waiting for acceptance.
- Instance
Id - Type-safe ID for API server instance entities.
- Kernel
Config - Kernel configuration for persona and behavior.
- Learning
- A learning extracted from an observation.
- Learning
Id - Type-safe ID for agent learning entities.
- Lock
- A lock with compile-time state tracking.
- LockId
- Type-safe ID for lock entities.
- Lock
Record - Internal data storage for a lock, independent of typestate. This is what gets persisted to the database.
- Memory
Access - Memory access configuration for an agent.
- Memory
Permission - A single memory permission entry.
- Memory
Region Config - Configuration for a memory region.
- Message
Id - Type-safe ID for message entities.
- Note
- Note - long-term cross-trajectory knowledge. Notes persist beyond individual trajectories.
- NoteId
- Type-safe ID for note entities.
- Observation
Id - Type-safe ID for agent observation entities.
- Pack
Config Id - Type-safe ID for pack configuration entities.
- Pending
- Delegation is pending acceptance.
- Plan
Cost - Cost estimate for a plan.
- PlanId
- Type-safe ID for agent plan entities.
- Plan
Step - A single step in a plan.
- Principal
- Principal identity for ownership and security scoping.
- Principal
Id - Type-safe ID for principal entities.
- Provenance
- Provenance information for an artifact.
- Provider
Config - LLM provider configuration.
- Rejected
- Handoff was rejected by the receiving agent (terminal).
- Released
- Lock has been released (for documentation; locks in this state don’t exist at runtime).
- Retry
Config - Retry configuration for LLM operations.
- Retry
Policy - Policy for retrying failed actions.
- Scope
- Scope - partitioned context window within a trajectory. Scopes provide isolation and checkpointing boundaries.
- ScopeId
- Type-safe ID for scope entities.
- Scope
Summary - Summary of a scope for context assembly.
- Secret
String - Sensitive string wrapper with redacted debug/display output.
- Section
Priorities - Section priorities for context assembly.
- Segment
Usage - Segment usage tracking.
- Session
- A stateful LLM session with compile-time state tracking.
- Session
Expired - Session expired due to TTL (terminal).
- Session
Id - Type-safe ID for stateful LLM session entities.
- Session
Markers - Session markers for tracking active context.
- Session
Record - Internal data storage for a session, independent of typestate. This is what gets persisted to the database.
- Sha256
Verifier - SHA-256-based event verifier (for compatibility).
- Snapshot
Id - Type-safe ID for snapshot entities.
- Source
Ref - Reference to a source entity.
- StepId
- Type-safe ID for plan step entities.
- Stored
Delegation - A delegation as stored in the database (status-agnostic).
- Stored
Handoff - A handoff as stored in the database (status-agnostic).
- Stored
Lock - A lock as stored in the database (status-agnostic).
- Stored
Session - A session as stored in the database (status-agnostic).
- Success
Criterion - A measurable criterion for goal success.
- Summarization
Policy - Policy for automatic summarization/abstraction. Defines when and how to generate L1/L2 notes from lower levels.
- Summarization
Policy Id - Type-safe ID for summarization policy entities.
- Summarization
Request Id - Type-safe ID for summarization request entities.
- Summarize
Config - Configuration for summarization requests.
- Team
- A team within a tenant for group-based access control.
- TeamId
- Type-safe ID for team entities.
- Team
Member - A membership record linking a user to a team.
- Tenant
Id - Type-safe ID for tenant entities.
- Token
Budget - Segment-based token budget allocation.
- Token
Budget Builder - Builder for constructing TokenBudget with custom ratios.
- Tool
Execution Id - Type-safe ID for tool execution entities.
- Trajectory
- Trajectory - top-level task container. A trajectory represents a complete task or goal being pursued.
- Trajectory
Id - Type-safe ID for trajectory entities.
- Trajectory
Outcome - Outcome of a completed trajectory.
- Turn
- Turn - ephemeral conversation buffer entry. Turns die with their scope.
- TurnId
- Type-safe ID for turn entities.
- Webhook
Id - Type-safe ID for webhook entities.
- Working
SetId - Type-safe ID for agent working set entities.
Enums§
- Abstraction
Level - Semantic abstraction level for notes (L0 → L1 → L2 hierarchy).
- Action
Status - Status of an action.
- Action
Type - Type of action an agent can take.
- Agent
Error - Agent coordination errors.
- Agent
Status - Status of an agent in the system.
- Agent
Target - Target for a message or delegation: either a specific agent by ID or any agent of a given type.
- Agent
Type - Agent type discriminator for registration and message routing. Extensible via Custom for user-defined agent kinds.
- Artifact
Metadata - Typed metadata for multimodal artifacts.
This enum provides strongly-typed metadata schemas for different artifact types.
It can be serialized to/from the generic
metadataJSONB field. - Artifact
Type - Type of artifact produced during a trajectory.
- Assembly
Action - Action taken during context assembly.
- Backoff
Strategy - Backoff strategy for retries.
- Belief
Source - Source of a belief.
- Belief
Type - Type of belief.
- Cellstate
Error - Master error type for all CELLSTATE errors.
- Circuit
State - Circuit breaker state.
- Compensation
Action - Action to take for compensating a failed operation.
- Config
Error - Configuration errors.
- Conflict
Resolution - Strategy for resolving conflicts.
- Conflict
Status - Status of a conflict.
- Conflict
Type - Type of conflict.
- Context
Persistence - Context persistence mode.
- Context
Segment - Context segment types for budget tracking.
- Delegation
Result Status - Status of a delegation result.
- Delegation
State Error - Errors when transitioning delegation states.
- Delegation
Status - Status of a delegation operation.
- Domain
Error - Domain-level errors that affect business logic.
- Edge
Type - Type of edge relationship between entities.
- Effect
- An effect represents the outcome of an operation.
- Entity
Type - Entity type discriminator for polymorphic references.
- Error
Effect - An error effect that can be persisted and replayed.
- Error
Kind - High-level error categorization for metrics and routing.
- Evidence
Ref - Evidence reference types for provenance tracking.
- Evolution
Phase - Phase of pack config evolution cycle.
- Extraction
Method - Method used to extract an artifact or evidence.
- Field
Type - Field types for schema definitions. Used by pack compiler and runtime validation.
- Goal
Status - Status of an agent goal.
- Goal
Type - Type of goal.
- Handoff
Reason - Reason for a handoff.
- Handoff
State Error - Errors when transitioning handoff states.
- Handoff
Status - Status of a handoff operation.
- Hash
Algorithm - Hash algorithm for event integrity.
- Health
Status - Health status for a service or component.
- Learning
Type - Type of learning.
- LlmError
- LLM provider errors.
- Loaded
Delegation - Enum representing all possible runtime states of a delegation. Use this when you need to handle delegations loaded from the database.
- Loaded
Handoff - Enum representing all possible runtime states of a handoff. Use this when you need to handle handoffs loaded from the database.
- Loaded
Session - Enum representing all possible runtime states of a session. Use this when you need to handle sessions loaded from the database.
- Lock
Mode - Lock mode determining concurrency behavior.
- Lock
State Error - Errors when transitioning lock states.
- Memory
Category - Memory category for hierarchical memory organization.
- Memory
Region - Type of memory region.
- Memory
Type - Memory type for permission scoping (artifact, note, turn, working set).
- Message
Priority - Priority level for messages.
- Message
Type - Type of agent message.
- Note
Type - Type of note (cross-trajectory knowledge).
- Operational
Error - Operational errors that don’t affect business logic.
- Outcome
Status - Outcome status for completed trajectories.
- Permission
Scope - Permission scope for memory access.
- Plan
Status - Status of a plan.
- Principal
Type - Principal type for identity and ownership scoping.
- Provider
Capability - Capabilities a provider can offer.
- Provider
Type - LLM provider type for configuration.
- Resolution
Strategy - Strategy for resolving a conflict.
- Resource
Type - Resource type for lock scoping.
- Routing
Strategy - Strategy for routing requests to providers.
- Section
Type - Type of context section.
- Segment
Budget Error - Error type for segment budget violations.
- Session
State Error - Errors when transitioning session states.
- Session
Status - Status of a stateful LLM session.
- Step
Status - Status of a plan step.
- Storage
Error - Storage layer errors.
- Summarization
Request Status - Status of a summarization request.
- Summarization
Trigger - Trigger condition for auto-summarization policy.
- Summarize
Style - Style of summarization output.
- TTL
- Time-to-live and retention configuration for memory entries. Supports both time-based expiration and count-based limits.
- Team
Role - Role within a team.
- Tool
Execution Status - Status of a tool execution.
- Trajectory
Status - Status of a trajectory (task container).
- Turn
Role - Role of a turn in conversation.
- Upstream
Signal - Signals that can be sent upstream in the DAG (“tram car tracks”).
- Validation
Error - Validation errors.
- Validation
Mode - Validation mode for PCP.
- Vector
Error - Vector operation errors.
- Verification
Status - Verification status for evidence.
- Wait
Condition - Condition that a pending effect is waiting for.
Traits§
- Delegation
State - Marker trait for delegation states.
- Embedding
Provider - Async trait for embedding providers.
- Entity
IdType - Trait for type-safe entity IDs.
- Error
Classifiable - Unified error classification for retry/intervention decisions across all error types.
- Event
Dag - Trait for Event DAG operations.
- Event
DagExt - Extension trait for EventDag with convenience methods.
- Event
Verifier - Trait for cryptographic event verification.
- Handoff
State - Marker trait for handoff states.
- Lock
State - Marker trait for lock states.
- Session
State - Marker trait for session states.
- Summarization
Provider - Async trait for summarization providers.
- Tokenizer
- Trait for counting tokens in text.
Functions§
- compute_
content_ hash - Compute SHA-256 hash of content.
- compute_
lock_ key - Compute a stable i64 key for advisory locks using FNV-1a hash.
- estimate_
tokens - Estimate token count using the configured tokenizer if present.
- estimate_
tokens_ heuristic - Estimate token count using the default heuristic tokenizer.
- register_
global_ tokenizer - Register a global tokenizer used by
estimate_tokens. - truncate_
to_ token_ budget - Truncate text to fit within token budget. Prefers sentence boundaries, falls back to word boundaries.
- validate_
event_ kind - Validate that an event kind is a recognized, defined variant.
Type Aliases§
- Cellstate
Result - Result type alias for CELLSTATE operations.
- RawContent
- Raw binary content for BYTEA storage.
- Timestamp
- Timestamp type using UTC timezone.