{
 "schema_version": 1,
 "generated": "2026-10-20",
 "id": "maxhu-xuan-task-state-guard--record-real-task-and-delivery-outcomes",
 "repo": "MaxHu-xuan/task-state-guard",
 "repo_url": "https://github.com/MaxHu-xuan/task-state-guard",
 "repo_slug": "maxhu-xuan-task-state-guard",
 "title": "Record task and delivery closures only from real outcomes",
 "page_title": "How to record task and delivery closures only from real outcomes with Task State Guard",
 "summary": "Write terminal task states and delivery states from a Python worker without guessing success.",
 "who": "A developer whose background worker or agent runtime needs a local record of task results and user-facing delivery.",
 "problem": "A finished task does not prove its result reached the user, and a worker can lose track of which states are final.",
 "outcome": "Each task and delivery closes only on confirmed evidence, and repeated identical closes are safely ignored.",
 "steps": [
  "Create and activate a virtual environment, then run `python3 -m venv .venv` and `. .venv/bin/activate`.",
  "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\")`.",
  "Create and start the task with `task = ledger.create_task(timeout_seconds=900)` and `ledger.start_task(task.id)`.",
  "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)"
 ],
 "agent_prompt": "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.",
 "agents": [
  "any"
 ],
 "difficulty": "Intermediate",
 "time": "30 minutes",
 "basis": "readme",
 "caveat": "The ledger cannot observe external side effects, so the delivered state is only as reliable as the transport acknowledgement your code passes in.",
 "category": "Software and DevOps",
 "tags": [
  "Software and DevOps"
 ],
 "lang": "python",
 "requirements": [
  "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"
 ],
 "risk": "none",
 "seen_in_the_wild": false,
 "mentioned_publicly": false,
 "risks": [],
 "best": false,
 "score": 0.9,
 "evidence": [],
 "url": "https://dedupedai.com/use-cases/maxhu-xuan-task-state-guard/record-real-task-and-delivery-outcomes/",
 "md": "https://dedupedai.com/use-cases/maxhu-xuan-task-state-guard/record-real-task-and-delivery-outcomes/index.md",
 "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 hello@dedupedai.com and we will look at it promptly.",
 "api": "https://dedupedai.com/api/v1/usecases/maxhu-xuan-task-state-guard--record-real-task-and-delivery-outcomes.json",
 "api_version": "v1"
}
