Skip to main content
The Journal Store and Memory System constitute the primary persistence and retrieval layer for the Palyra daemon. It manages an append-only log of events, maintains a searchable vector memory for long-term context, and handles scheduled operations via a cron subsystem. All persistence is backed by SQLite, utilizing a hash-chain integrity model to ensure the auditability of the system log.

JournalStore and SQLite Persistence

The JournalStore is the central coordinator for all database operations. It manages a SQLite connection (typically via rusqlite) and provides an abstraction for interacting with specialized tables like journal_events, memory_items, and orchestrator_sessions.

Append-Only Journal Log

The journal_events table serves as an immutable, append-only ledger of every significant action taken by the daemon crates/palyra-daemon/src/journal.rs#63-71.
  • Integrity Hash Chain: Every event contains a hash field. This hash is calculated by combining the event’s payload with the hash of the previous event crates/palyra-daemon/src/gateway.rs#114-115. This creates a cryptographic chain that prevents tampering with historical logs.
  • Event Types: The log captures model provider interactions, tool executions, approval decisions, and session state transitions.
  • Redaction: To protect sensitive information (API keys, passwords), the journaler automatically redacts values associated with keys like secret, token, or api_key before persisting them to the database crates/palyra-daemon/src/journal.rs#29-45.

Data Flow: Journal Append

  1. A subsystem (e.g., GatewayRuntimeState) issues a JournalAppendRequest crates/palyra-daemon/src/gateway.rs#63-71.
  2. The JournalStore retrieves the hash of the most recent event.
  3. A new SHA-256 hash is computed for the current entry.
  4. The entry is inserted into the journal_events table within a transaction.
Journal Integrity and Persistence Flow Sources: crates/palyra-daemon/src/journal.rs#12-17, crates/palyra-daemon/src/gateway.rs#63-71, crates/palyra-daemon/src/gateway.rs#114-115 The Memory System provides long-term semantic storage for agents. It allows the daemon to “remember” facts across different sessions by embedding text into vector space.

Memory Items

A MemoryItem represents a discrete unit of knowledge crates/palyra-daemon/src/journal.rs#64-66.

MemoryEmbeddingProvider

The MemoryEmbeddingProvider trait defines how text is converted into vectors crates/palyra-daemon/src/journal.rs#64-68.
  • HashMemoryEmbeddingProvider: A default implementation that uses a deterministic hashing algorithm to generate embeddings, suitable for basic similarity without external LLM dependencies crates/palyra-daemon/src/journal.rs#71-100.
  • Vector Search: Retrieval uses a MemorySearchRequest which specifies a query string and a top_k limit (max 64) crates/palyra-daemon/src/gateway.rs#116-117. The system performs a similarity search against the memory_items table.

Auto-Inject and Maintenance

Vector Memory Retrieval Path Sources: crates/palyra-daemon/src/journal.rs#64-68, crates/palyra-daemon/src/journal.rs#71-100, crates/palyra-daemon/src/gateway.rs#116-117, crates/palyra-daemon/src/gateway/runtime.rs#72-82

Cron and Scheduled Routines

The Cron system allows for the execution of recurring tasks (“Routines”).

CronJob Configuration

A CronJobRecord defines the schedule and the prompt to be executed crates/palyra-daemon/src/journal.rs#232-248.

Execution Lifecycle

  1. The CronServiceImpl monitors the next_run_at_unix_ms for all enabled jobs crates/palyra-daemon/src/gateway.rs#41-44.
  2. When a job is due, a CronRunRecord is created with status Accepted crates/palyra-daemon/src/journal.rs#185-192.
  3. The task is dispatched via the GatewayService loopback.
  4. Upon completion, the CronRunFinalizeRequest updates the status to Succeeded or Failed and schedules the next run crates/palyra-daemon/src/journal.rs#61-63.
Sources: crates/palyra-daemon/src/journal.rs#104-108, crates/palyra-daemon/src/journal.rs#132-136, crates/palyra-daemon/src/journal.rs#185-192, crates/palyra-daemon/src/journal.rs#232-248

Summary of Constraints and Limits

The system enforces several hard limits to ensure stability and prevent resource exhaustion:
ConstraintValueSource
Max Recent Events100crates/palyra-daemon/src/gateway.rs#89
Max Memory Item Size16 KBcrates/palyra-daemon/src/gateway.rs#118
Max Memory Search Top K64crates/palyra-daemon/src/gateway.rs#117
Max Cron Job Name128 Bytescrates/palyra-daemon/src/gateway.rs#104
Max Cron Prompt Size16 KBcrates/palyra-daemon/src/gateway.rs#105
Journal Write Latency Budget25 mscrates/palyra-daemon/src/gateway.rs#92
Sources: crates/palyra-daemon/src/gateway.rs#89-118