MaxHu-xuan/task-state-guard
An embedded SQLite ledger for reconciling stale task and delivery states
Automated SPDX check for reference only — not legal advice. Disclaimer
GitHub Star History
Full-history star trajectory from GitHub official history. Switch ranges or hover any point for exact counts.
Evidence-Backed Technical Brief
AI Deep ReviewArchitecture & Core Mechanics
TaskStateGuard is a Python SDK and CLI around an embedded SQLite ledger, not an agent execution runtime. The Ledger API records lifecycle transitions; the CLI gives operators a separate path to reconcile stale records and check health. Tasks move through queued and running and can close from either state as succeeded, failed, timed_out, or cancelled. Terminal writes are immutable: repeating the same outcome is idempotent, but conflicting outcomes are rejected.
Delivery remains pending until the task is terminal and delivery can be closed. A delivery-required task needs a real transport acknowledgement to become delivered; an internal task with no direct delivery obligation can close only as not_applicable. Runtime code uses only the Python standard library, with no network or telemetry path. There are no framework-specific adapters, so the integrating runtime owns the mapping from worker events and transport acknowledgements to ledger writes.
Key Capabilities & Differentiators
Reconciliation evaluates deadlines and active grace periods to mark stale tasks timed_out while leaving fresh tasks alone. Once the delivery grace expires for a terminal task, unreconciled user-facing delivery can close as failed, while delivery for an internal task closes as not_applicable. reconcile --dry-run uses the same rules as apply and reports aggregate counts without modifying tasks, events, or the database.
doctor checks SQLite quick_check, foreign keys, the exact schema, state semantics, finite timestamps, parent-child relations, and expected event chains. It reports aggregate counts and exits with status 1 on inconsistency. The ledger has no supported fields for prompts, messages, task bodies, or model output, but ordinary status commands can expose UUIDs and timestamps. Optional SHA-256 payload fingerprints are correlatable and may be guessable for low-entropy inputs.
Trade-offs & Limitations
Compared with a task queue or workflow engine, this narrower design is useful when an existing runtime already executes jobs but cannot reliably distinguish stale work from completed work, or completion from delivery. Its idempotency applies to recorded state, not to external side effects. It does not resume computation, schedule retries, or guarantee exactly-once execution or delivery. If the host already has reliable execution and delivery records with auditable reconciliation, a second ledger may add more integration work than value.
A dry run is a point-in-time assessment, not a lock or reservation: concurrent workers and elapsed time can change what a later apply will do. Reconciliation runs only when invoked. The database must live on a local filesystem with stable file identity and SQLite-compatible locking, not a network or mapped drive. Processes under the same OS identity are trusted, so file permissions do not isolate mutually untrusted workers sharing that identity.
Hardware & Deployment Guide
Run it locally on CPython 3.11–3.14, as a CLI in an isolated virtual environment or as a library embedded in the host application. Install from PyPI once the release is available there, or use python -m pip install . from a verified checkout. The v0.1.0 release is alpha. The checkout includes a synthetic preview/apply/recheck/doctor demo that is not packaged in the wheel. On Linux and macOS, the tool checks ownership and modes and tightens database sidecars to 0600. On Windows, pre-create a private service-account directory and explicitly opt in with allow_external_acl=True or --allow-external-acl before the subcommand; neither verifies the DACL.
CLI preview requires an existing WAL-mode ledger that already meets permission requirements. For a cleanly closed database without WAL/SHM sidecars, the read-only path verifies two consistent reads of the main file and deserializes a private copy in memory, up to 64 MiB. It fails closed if the file changes during the read or deserialization is unavailable. A safe schema v1 ledger can be previewed without migration; normal apply migrates to v2 by default. Use Ledger(path, read_only=True) when construction itself must also be read-only.
delivered.reconcile --dry-run reports aggregate impact without writing the database, tightening file permissions, or migrating schema.doctor checks SQLite integrity, exact schema, foreign keys, state semantics, timestamps, parent-child relations, and event chains.Agent runtimes and background workers that already own execution and delivery but need a local, auditable way to close stale records after restarts or timeouts.
You need scheduling, automatic retries, checkpoint resumption, exactly-once guarantees, or a ledger shared across hosts.
Quick Start & Installation
python3 -m venv .venv . .venv/bin/activate python -m pip install task-state-guard
Comparison vs. Top Agents & Frameworks Alternatives
Full comparison →| Repository | Stars | 7d Trend | Stack | License | Core Positioning |
|---|---|---|---|---|---|
| task-state-guard ★ | 982 | — | Python | Apache-2.0 | An embedded SQLite ledger for reconciling stale task and delivery states |
| browser-use | 122.7k | +477 | Python | MIT | Python REPL and CDP for adaptive browser automation |
| langgraph | 45.8k | +293 | Python | MIT | Python graph orchestration for stateful, resumable agents and workflows |
| langchain | 150.4k | +290 | Python | MIT | Modular Python framework for building agents across model providers |
AI Context Briefing (for Claude / Cursor / Windsurf)
Standardized architecture summary & quickstart commands ready to paste into coding agents.
curl -sL https://repoforai.com/repo/MaxHu-xuan/task-state-guard.md
Active README embeds unlock Hot-Tier 6h Telemetry Refresh automatically (zero pay-to-rank).
Frequently Asked Questions about task-state-guard
Where does TaskStateGuard fit into an existing worker?
Ledger, then record the terminal outcome when the worker has evidence for it. Mark delivery as delivered only after the transport acknowledges it. Invoke reconciliation separately at startup or during operations; the library does not run a background watcher.What hardware does it need, and what should we size for?
Can we embed it in a commercial, self-hosted product?
Should we add it alongside a workflow engine or use the engine alone?
Upstream README & Documentation
This profile focuses on independent engineering analysis and live telemetry. Read the full upstream README, changelog, and examples directly on GitHub.
Top 10 Breakout Open-Source AI Repos, Every Thursday
Signal-only digest of fast-growing AI repos, SPDX license alerts, and architecture picks. Zero spam.
Zero spam · 1-click unsubscribe · Privacy Policy