DEDUPED Hot AI repos. Real use cases. What people build. Get the Monday 5

How to record task and delivery closures only from real outcomes with Task State Guard

Write terminal task states and delivery states from a Python worker without guessing success.

Short answer: Create and activate a virtual environment, then run python3 -m venv .venv and . .venv/bin/activate; then install the package with python -m pip install task-state-guard; import the API with from task_state_guard import Ledger and open your ledger with ledger = Ledger("./private-state/tasks.sqlite"). All steps.

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

  1. Create and activate a virtual environment, then run python3 -m venv .venv and . .venv/bin/activate.
  2. Install the package with python -m pip install task-state-guard.
  3. Import the API with from task_state_guard import Ledger and open your ledger with ledger = Ledger("./private-state/tasks.sqlite").
  4. Create and start the task with task = ledger.create_task(timeout_seconds=900) and ledger.start_task(task.id).
  5. After the worker confirms success, run ledger.close_task(task.id, "succeeded", code="worker_completed"), then run ledger.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

Cursor, ChatGPT, others

Share: X LinkedIn Hacker News Email Copy link

Third-party repos we don't own. AI-written use cases can be wrong. Disclaimer