A lightweight SQLite-backed task lifecycle ledger for agents, schedulers, workers, and other long-running workflows.
It focuses on a small but practical core:
- append-only status events
- validated task-state transitions
- single terminal-state enforcement
- task snapshot maintenance
- delivery dedupe / cooldown checks
- stale-task queries for watchdogs and heartbeats
A lot of workflow systems need more than simple logs. They need a place to answer questions like:
- What is the current state of task
X? - Did this task already reach a terminal state?
- Is this worker still running or has it gone stale?
- Should I suppress duplicate delivery for this status update?
This project packages that pattern into a small, framework-agnostic module.
src/sqlite_task_ledger/ledger.py— core ledger implementationschema/status_schema.sql— SQLite schemaexamples/basic_usage.py— minimal end-to-end usagetests/test_ledger_smoke.py— basic smoke test
- AI/agent task tracking
- scheduler job state tracking
- long-running workflow status reporting
- watchdog / heartbeat recovery
- message dedupe and cooldown handling
from pathlib import Path
from sqlite_task_ledger import Ledger, StatusEvent
ledger = Ledger("status_ledger.db")
ledger.init_schema(Path("schema/status_schema.sql").read_text())
ledger.write_event(StatusEvent(
state="RECEIVED",
actor="worker-1",
source="demo",
req="task_001",
))
ledger.write_event(StatusEvent(
state="RUNNING",
actor="worker-1",
source="demo",
req="task_001",
stage="collecting inputs",
))The project intentionally separates:
- event history (
task_events) - latest snapshot (
task_state_snapshot) - delivery records (
delivery_log)
That makes it easy to support both:
- append-only audit history
- fast “what is the current state?” lookups
This public version does not include any product-specific adapters, chat routing logic, or environment-bound constants.
MIT