Skip to main content
The Journal & Persistence Layer is the source of truth for all state within the Palyra daemon (palyrad). It provides a unified interface for persisting orchestrator sessions, event logs, cron jobs, workspace documents, and memory items. The system is built on SQLite and emphasizes auditability through cryptographic hash chaining of events.

JournalStore Architecture

The JournalStore is the primary handle for database operations. It manages a rusqlite::Connection and provides methods for transactional updates to the underlying schema.

Key Components

Code Entity Mapping: Persistence Core

The following diagram bridges the high-level persistence concepts to the specific Rust structs and database tables. Sources: crates/palyra-daemon/src/journal.rs#19-71, crates/palyra-daemon/src/config/schema.rs#34-35

Schema & Tables

1. Journal Events (journal_events)

The journal_events table stores the “Tape” of an orchestrator run. It captures every message, tool call, and state transition.

2. Orchestrator Sessions (orchestrator_sessions)

Stores the metadata for long-running agent interactions.

3. Cron Jobs (cron_jobs)

Handles scheduled tasks and recurring agent runs.

4. Workspace Documents (workspace_documents)

Persists the state of the shared file space used by agents during a session.

Data Flow: Event Appending

When the Gateway receives a message or an Orchestrator executes a tool, the data flows through the JournalStore to ensure durability before any response is sent. Sources: crates/palyra-daemon/src/gateway.rs#63-63, crates/palyra-daemon/src/journal.rs#16-17

Memory & Vector Persistence

The journal also handles the persistence of the RAG (Retrieval-Augmented Generation) system.

Migrations & Configuration

The persistence layer includes a migration system to handle schema updates without data loss.
  • Version Tracking: The journal schema version is stored within the database itself.
  • Config Migration: The palyra-daemon uses parse_document_with_migration to upgrade palyra.toml files when new mandatory fields are added crates/palyra-daemon/src/config/load.rs#9-11.
  • Safety: The JournalStore validates the database file path and permissions on startup, ensuring the daemon has write access to its storage root crates/palyra-daemon/src/journal.rs#9-10.
Sources: crates/palyra-daemon/src/journal.rs#1-68, crates/palyra-daemon/src/gateway.rs#56-71, crates/palyra-daemon/src/config/load.rs#31-50, crates/palyra-daemon/src/config/schema.rs#34-37