DEDUPED Hot AI repos, turned into use cases Get 5 a day

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.

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.

Share: X LinkedIn Hacker News Email Copy link

Disclaimer

Deduped lists open-source repositories that belong to other people. We do not own, maintain, audit, or vouch for any of them, and a repo appearing here is not an endorsement or a safety check. The use cases, steps, and prompts are written by AI and may be incomplete, outdated, or just wrong. Where a use case is marked "Seen in the wild", we link to public posts where someone described something similar, but we have not verified those posts and the use case itself is still our AI's own write-up. Use all of this at your own risk. Only run code, commands, or agents on systems and accounts you are authorized to use, and read the code and every command before you run it, especially anything that touches credentials, files, or the network. Nothing here is professional, security, legal, or financial advice. All trademarks and project names belong to their respective owners, and their use here does not imply affiliation. Content is provided as is, without warranties of any kind. Found a mistake, a safety problem, or something you want removed? Email [email protected] and we will look at it promptly. Full disclaimer page