Architecture
Roles
Agent Mode (Server)
The agent-side Chronicle is the master. It:- Listens for sandbox connections on a Unix socket or WebSocket
- Pushes file notifications to connected sandboxes
- Accepts write-back requests from sandboxes
- Serves content via CAS for large files
- Runs with
--replicationflag
Sandbox Mode (Client)
The sandbox-side Chronicle is a replica. It:- Connects to the agent’s replication socket
- Receives file change notifications
- Applies changes to its local filesystem
- Journals local writes and sends them back to the agent
- Runs with
--connector--ws-connectflag
Replication Flow
Agent → Sandbox (Push)
Sandbox → Agent (Write-back)
Conflict Resolution
Write-back uses causal dependency tracking:- Each sandbox write records the last master iteration it has seen (
master_rowid_seen) - On reconciliation, if the master has advanced past that point for the same file, the write is rejected
- The sandbox can retry after catching up to the latest state
Catchup and Resync
If a sandbox detects a gap in sequence numbers (via heartbeat comparison):- Sandbox sends
CatchupRequest { since_sequence } - Agent replays missed notifications from that sequence
- If the gap is too large, agent sends
FullResyncRequired - Sandbox performs a full reconciliation from scratch