Who it is forA developer whose background worker or agent runtime needs a local record of task results and user-facing delivery.
The problemA finished task does not prove its result reached the user, and a worker can lose track of which states are final.
The outcomeEach task and delivery closes only on confirmed evidence, and repeated identical closes are safely ignored.
What you need first
- CPython 3.11 to 3.14
- A SQLite ledger file on a local filesystem, not a network or mapped drive
- A virtual environment with task-state-guard installed from PyPI
Steps
- Create and activate a virtual environment, then run
python3 -m venv .venvand. .venv/bin/activate. - Install the package with
python -m pip install task-state-guard. - Import the API with
from task_state_guard import Ledgerand open your ledger withledger = Ledger("./private-state/tasks.sqlite"). - Create and start the task with
task = ledger.create_task(timeout_seconds=900)andledger.start_task(task.id). - After the worker confirms success, run
ledger.close_task(task.id, "succeeded", code="worker_completed"), then runledger.set_delivery(task.id, "delivered", code="transport_acknowledged")only after the transport acknowledges receipt. (inferred, check the README)
Prompt for your agent
Using the MaxHu-xuan/task-state-guard repo, write a short Python script that creates a task in <ledger-path>, starts it, and closes it as succeeded only after your worker reports success. Verify that you call set_delivery with delivered only after a real transport acknowledgement, and report the final task and delivery states.
Caveat. The ledger cannot observe external side effects, so the delivered state is only as reliable as the transport acknowledgement your code passes in.
Use this in your AI agent
Ask your agent
Using the Deduped MCP, get the setup steps for MaxHu-xuan/task-state-guard and "Record task and delivery closures only from real outcomes"
Add Deduped to Claude Code once
claude mcp add --transport http deduped https://dedupedai.com/mcp
Every Monday: the 5 hottest repos and exactly how to use them. Free, one email a week, unsubscribe anytime.
Get them freeShare: X LinkedIn Hacker News Email Copy link
Third-party repos we don't own. AI-written use cases can be wrong. Disclaimer