Skip to main content
The Journal and Persistence subsystem is responsible for the immutable recording of system events, the state management of agentic runs, and the long-term storage of knowledge through the Memory subsystem. It utilizes a SQLite-backed append-only audit log with tamper-evident hash chaining to ensure the integrity of the agent’s history.

JournalStore & SQLite Backend

The JournalStore is the central authority for persistence in the Palyra daemon crates/palyra-daemon/src/journal.rs#63-71. It manages a SQLite database (defaulting to data/journal.sqlite3) that stores everything from orchestrator tapes to cron job definitions and memory items crates/palyra-daemon/src/config/schema.rs#34-34.

Data Architecture

The system uses a single SQLite connection, typically wrapped in an Arc<Mutex<JournalStore>> to coordinate access across asynchronous tasks crates/palyra-daemon/src/journal.rs#5-5.
EntityPurposeKey Code Reference
JournalEventGeneric audit log for system-wide events.JournalEventRecord crates/palyra-daemon/src/journal.rs#63-63
Orchestrator TapeAppend-only log of a specific Run’s execution steps.OrchestratorTapeRecord crates/palyra-daemon/src/journal.rs#69-69
Memory ItemVectorized knowledge entries for RAG.MemoryItemCreateRequest crates/palyra-daemon/src/journal.rs#64-64
Cron JobsScheduled task definitions and run history.CronJobRecord crates/palyra-daemon/src/journal.rs#61-61
Sources: crates/palyra-daemon/src/journal.rs#1-71, crates/palyra-daemon/src/config/schema.rs#34-37

Tamper-Evident Hash Chaining

To ensure the integrity of the audit log, Palyra implements a hash-chaining mechanism. Every event appended to the journal includes a hash_chain value, which is a SHA-256 digest of the current event’s content concatenated with the hash_chain of the previous entry crates/palyra-daemon/src/gateway.rs#31-31.

Implementation Logic

  1. Seed: The chain starts with a constant seed 0000...0000 crates/palyra-daemon/src/gateway.rs#114-115.
  2. Append: When JournalAppendRequest is processed, the daemon calculates the next hash.
  3. Verification: The palyra doctor CLI command can verify the chain to detect unauthorized database modifications.
Sources: crates/palyra-daemon/src/gateway.rs#31-31, crates/palyra-daemon/src/gateway.rs#114-115, crates/palyra-daemon/src/journal.rs#63-63

Orchestrator Tape

The “Tape” is a specialized subset of the journal that tracks the lifecycle of a single Run. It acts as the “source of truth” for the RunStateMachine crates/palyra-daemon/src/gateway.rs#77-77.

Tape Event Types

The tape records granular transitions, including:

Data Flow: Gateway to Tape

The following diagram illustrates how incoming messages from the GatewayService are persisted into the JournalStore. Diagram: Inbound Message Persistence Flow Sources: crates/palyra-daemon/src/gateway.rs#40-82, crates/palyra-daemon/src/journal.rs#63-71

Memory Subsystem

The Memory subsystem provides both lexical (text) and vector (semantic) search capabilities. It is designed for “Learning” where the agent can store information for future recall.

Vector Search & Embeddings

Palyra supports multiple embedding providers via the MemoryEmbeddingProvider trait crates/palyra-daemon/src/journal.rs#64-68.

Memory Maintenance & Retention

A background loop managed by the Cron service handles memory health crates/palyra-daemon/src/cron.rs#56-58: Diagram: Memory Indexing and Retrieval Sources: crates/palyra-daemon/src/journal.rs#64-100, crates/palyra-daemon/src/cron.rs#56-58, crates/palyra-daemon/src/config/schema.rs#26-31

Persistence Configuration

Persistence behavior is governed by the StorageConfig and JournalConfig sections in palyra.toml.
ParameterDefaultDescription
journal_db_pathdata/journal.sqlite3Path to the SQLite database file crates/palyra-daemon/src/config/schema.rs#34-34.
hash_chain_enabledtrueEnables tamper-evident logging crates/palyra-daemon/src/config/schema.rs#35-35.
max_journal_payload_bytes256 KiBMaximum size for a single journal entry payload crates/palyra-daemon/src/config/schema.rs#36-36.
memory.retention.ttl_days30Retention period for memory items crates/palyra-daemon/src/config/schema.rs#28-28.
Sources: crates/palyra-daemon/src/config/schema.rs#26-37, crates/palyra-common/src/daemon_config_schema.rs#183-205