Version: 0.1.0
Status: Approved by Byzantine Technical Steering Committee
Authors: ZeroLoop Core Engineering Team
ZeroLoop is an ultra-lean, event-sourced, deterministic durable execution state machine. It is designed to replace fragile in-memory while True loops in autonomous AI agent systems with Temporal-grade crash-proof recovery, sub-5ms rehydration, and cryptographic idempotency protection using zero external runtime dependencies.
The transition function
Every state transition, thought, tool dispatch, and step checkpoint is committed as an immutable event
For each event
Where:
-
$\mathcal{J}(\cdot)$ represents canonical sorted JSON serialization (separators=(',', ':'), sort_keys=True). -
$H_{i-1}$ is the cryptographic hash of the immediate predecessor event. - A single mutated byte in any prior event breaks the hash link
$H_k \ne \text{expected}$ , detected instantly byloop.verify_chain().
For any tool invocation
-
Pre-Execution Check: Before invoking any local or remote tool handler, ZeroLoop queries
idempotency_indexwith$K_{\text{idemp}}$ . -
Replay Cache: If
$K_{\text{idemp}}$ exists, the stored output is returned immediately, settingcached=Trueand preventing duplicate execution. - Recovery Invariant: Even under repeated process crashes and restarts, any mutating side-effect (financial transaction, database mutation, external API call) is executed strictly once.
ZeroLoop utilizes SQLite with specific pragmas to guarantee crash resilience:
PRAGMA journal_mode=WAL;
PRAGMA synchronous=NORMAL;
PRAGMA busy_timeout=5000;
PRAGMA foreign_keys=ON;- Write-Ahead Logging (WAL): Allows lock-free concurrent readers to inspect the state machine while a writer commits state events.
- Sub-5ms Rehydration: Loading an existing session reads the latest metadata and checkpoint row directly, achieving rehydration in under 5 milliseconds.
To prevent unbounded journal accumulation, ZeroLoop enforces automated FIFO pruning:
-
Storage Floor: If remaining disk space
$< \text{MIN_DISK_FREE_GB}$ (default 5.0 GB), oldest completed/failed sessions are pruned immediately. -
Storage Ceiling: If directory size
$> \text{MAX_STORAGE_MB}$ (default 250.0 MB), completed/failed sessions are pruned in FIFO order. -
Retention Horizon: Completed/failed sessions older than
$\text{RETENTION_DAYS}$ (default 7 days) are deleted. -
Active Session Protection: Active (
RUNNING) and awaiting-approval (PAUSED) sessions are immune to auto-pruning.