Serialize reservations
SQLite BEGIN IMMEDIATE, WAL mode and a busy timeout make concurrent reserve attempts converge on one durable receipt.
CASE STUDY / SIDE-EFFECT RELIABILITY
A dependency-free SQLite ledger for the moment before an automation performs an irreversible external effect: should this attempt execute, skip, retry, or stop as a conflict?
THE PROBLEM
A payment request, webhook consumer, notification sender or file export can succeed remotely and still return a local timeout. Blindly replaying the same operation may create a duplicate charge, message, record or delivery. Retry logic therefore needs durable memory of what was attempted and what already completed.
The ledger decides whether a caller may execute. It never performs the side effect itself, never silently retries failed work, and never stores a raw payload when the caller uses file fingerprinting.
A new idempotency key and fingerprint create a reserved receipt with attempt 1.
A competing process sees the existing reservation instead of performing the same external action again.
Once the receipt is marked successful, future attempts remain a skip rather than becoming a fresh execution.
The same key with a different fingerprint is treated as a semantic conflict and exits with code 3.
A failure is not automatically replayed. The default is to stop and preserve the existing receipt state.
Only --allow-failed-retry reopens a failed receipt and increments the attempt number.
SQLite BEGIN IMMEDIATE, WAL mode and a busy timeout make concurrent reserve attempts converge on one durable receipt.
--payload-file stores a SHA-256 fingerprint rather than the raw payload, reducing accidental retention of customer or secret data.
Normal decisions return 0, invalid input returns 2, and idempotency-key fingerprint conflicts return 3 for orchestration or CI.
The caller performs the actual payment, message, write or webhook action only after an EXECUTE or explicitly approved RETRY decision.
Coverage includes in-flight duplicates, completed duplicates, fingerprint conflicts, failed-retry gating, missing receipts and CLI exit behavior.
A two-connection test asserts that the same key cannot produce two EXECUTE decisions.
GitHub Actions runs the suite on Python 3.10, 3.12 and 3.13 so the public repository carries reproducible compatibility evidence.
Use provider event IDs or business keys to prevent repeated handling when delivery is retried.
Wrap email sends, record creation, file writes and other non-idempotent tools with a durable decision boundary.
Persist the last known state so a restarted worker can distinguish completed, in-flight, failed and conflicting attempts.
I can add an idempotency and receipt boundary around webhook, API, AI-agent or automation side effects without hiding the retry decision.