After a destination commits but the caller loses the response, retrying the entire workflow can repeat a side effect. The sender needs to establish what happened before choosing the next action.
The accompanying Python and SQLite reference follows that boundary: one shared-inbox request is reviewed, saved to a destination and followed by a separate notification. Both the destination and notification service are synthetic local tables. There is no LLM, real connector or customer account.
The useful question is concrete: can recovery find the approved record without creating another one?
Keep business identity across attempts
The reference separates a stable request_id from individual delivery_id values. Two deliveries can describe the same intended action. Reusing either identity with conflicting content is rejected.
That distinction is part of the operation contract, not a property acquired by naming a field “idempotency key.” Amazon's Builders' Library discusses explicit client request identifiers, changed intent and the ambiguity caused by a missing response. A real destination must provide the identity and lookup behaviour the implementation relies on.
Here is the actual API exercised against fresh temporary databases:
from pathlib import Path from tempfile import TemporaryDirectory from workflow_acceptance import SyntheticSystems, Workflow with TemporaryDirectory() as temporary: root = Path(temporary) systems = SyntheticSystems(root / "destination.sqlite") flow = Workflow(root / "workflow.sqlite", systems) flow.receive("req-001", "delivery-a", "sales", "Synthetic pilot enquiry") flow.approve("req-001", 1, "sales", "reviewer-a") assert flow.write("req-001", fault="lost_response")["state"] == "reconcile_required" assert systems.counts()["records"] == 1 assert flow.reconcile("req-001")["state"] == "record_saved" assert flow.notify("req-001", fail=True)["state"] == "notification_failed" assert flow.notify("req-001")["state"] == "complete" flow.close() systems.close() reviewer-a is the synthetic destination assignee alias. The approval method models an explicit review decision. It does not authenticate a reviewer or implement role-based access control.
Read the saved result alongside the sender's state
The demo deliberately commits the destination record and discards its response. At that point the workflow records reconcile_required. It cannot conclude that creation failed, and another write() is rejected.
These two entries are copied from the executed demo's evidence.json. The second follows closing and reopening both SQLite connections:
[ { "case": "committed_response_lost", "request_id": "req-001", "revision": 1, "state": "reconcile_required", "receipt": null, "error": "injected_response_lost", "counts": { "records": 1, "notifications": 0 } }, { "case": "reopened_and_reconciled", "request_id": "req-001", "revision": 1, "state": "record_saved", "receipt": "crm:req-001", "error": null, "counts": { "records": 1, "notifications": 0 } } ] The destination count stays at one. Reconciliation finds the record and compares its revision, payload and mapping with the approved operation before attaching the receipt. An existing record with different values raises a conflict rather than becoming a convenient success result.
The workflow journal and synthetic destination live in separate databases. A saved pending operation remains inspectable after an unexpected stop. One of the automated tests starts a fresh Python process against the persisted files and completes reconciliation and notification there.
Approval belongs to a particular revision and mapping
Approval records the current revision, input digest, destination queue and assignee. The write path checks that the persisted input and approval still match.
Changing an unexecuted request through revise() increments its revision and clears approval. An approval naming the old revision is rejected. The demo's second request exercises that change from a sales mapping to a support mapping before writing.
This matters because a duplicate identifier alone cannot establish equivalent intent. Quietly reusing an approval after input or mapping changes would make recovery look successful while executing a different decision.
The model covers initial creation. It does not implement post-save updates, cancellation or matching different request IDs to the same person. Those require additional business rules and tests.
Separate a known failure from an uncertain outcome
The injected before_write failure happens before the synthetic destination writes anything. The request can remain approved, and the test confirms that no destination record exists.
The injected lost_response fault has a different contract: the destination has already committed. It leaves uncertainty requiring lookup. Treating both cases as an exception to retry would discard the information the workflow needs.
Notification is another boundary. In the demo, a conclusive notification failure leaves one ticket and zero notifications. Recovery keeps that same ticket and creates one synthetic notification. It does not call the record-creation method again.
The local suite also stops after a synthetic notification has committed. It checks that reopening and retrying keeps one notice under the adapter's unique-key contract. A real provider needs its own supported verification and retry policy. A row in this exercise does not establish delivery to a human recipient.
SQLite's transaction documentation describes database commit and rollback boundaries. A transaction in the workflow database does not make a separate destination operation or notification part of the same atomic commit.
Reproduce the checks
The reference ZIP contains workflow_acceptance.py, test_workflow_acceptance.py and a README. Use a Python installation that provides the standard-library sqlite3 module.
From the unpacked directory:
python -m unittest -v test_workflow_acceptance.py python workflow_acceptance.py --demo --directory demo-output The demo requires a new directory so earlier evidence is preserved. It writes workflow.sqlite, destination.sqlite and evidence.json for inspection.
The executed suite passed 15 tests. They include invalid input, conflicting replays, duplicate deliveries, stale or modified approvals, mismatched destination lookup, notification recovery and fresh-process reconciliation. The demo also evaluates five named assertions against its observed results.
Read the assertions with the code. A passing run establishes the included behaviours under this sequential synthetic adapter contract. It doesn't demonstrate a production integration, AI accuracy or safety across competing workers and real provider limits.
Turn the example into acceptance criteria
For an actual implementation, establish the destination's request identity, lookup semantics and retention window before promising safe recovery. Test permitted samples in the real receiving system, including incomplete inputs, repeated deliveries, changed intent and a lost response.
Keep the saved business result separate from execution status and downstream delivery. Record what remains unresolved and which action an operator may take. The StackEndBox workflow acceptance notes connect this reference to scoping that implementation boundary.