SYSTEM 8Discuss a system ↗
DOCS / PAT-PA-002

PAT-PA-002 / SOURCE CONTROLLED

Idempotent shared-mailbox intake pattern

Use this pattern when one email or intake event must produce one authoritative business record even if delivery or execution occurs more than once.

● CONTROLLEDOWNER / SYSTEM 8REVIEW / MONTHLY
01

Scope and assumptions

  • The trigger can deliver the same logical item more than once.
  • The workflow can fail after an external side effect has succeeded.
  • Operators may need a controlled replay path.
  • The destination can enforce a unique key or accept an atomic reservation.
  • The business can nominate the authoritative outcome when historical duplicates exist.
02

Processing contract

STATEMEANINGALLOWED NEXT STEP
ReceivedUnique intake key reservedBegin controlled processing
In progressOne worker owns the active attemptRecord each side effect
CompleteRequired acceptance evidence existsReturn existing result on replay
DuplicateKey already resolved to a business recordDo not recreate; return reference
ReconcileExternal outcome is unknown or contradictoryBusiness-led investigation
03

Key selection

  1. Prefer an upstream business request identifier.
  2. Otherwise use the Internet Message ID with a source/mailbox namespace.
  3. If neither is reliable, generate an intake ID before side effects and persist it at the source boundary.
  4. Retain connector item IDs and a human-readable fingerprint as evidence. Enforce uniqueness through the atomic ledger or destination key.
  5. Enforce uniqueness atomically in the ledger or destination.
04

Ordered implementation

  1. Capture the source key and minimal evidence.
  2. Attempt the unique ledger reservation.
  3. On conflict, return the existing ledger/business record state.
  4. Create or update the business record with the same key.
  5. Record external identifiers immediately after each side effect.
  6. Mark complete only when acceptance checks pass.
  7. Move or archive the message only after completion. The unique key and ledger remain the duplicate controls.
05

Replay and reconciliation

Replay only from ledger rows whose state and completed effects are known. The replay request must identify the original intake key, current business record, completed effects, proposed repeated effects and approving owner. Treat timeout as unknown outcome until the destination is checked. Never use mailbox forwarding as the recovery mechanism.

06

Acceptance tests

  • Simultaneous duplicate deliveries resolve to one record.
  • An action retry after a successful write does not duplicate the write.
  • A manual replay returns the existing result or resumes from the recorded state.
  • Two legitimate same-subject messages remain distinct.
  • Destination throttling leaves visible pending work.
  • A second operator can reconcile and replay from this document.
07

Limits and review

Concurrency control serialises executions. Idempotency also requires an atomic unique key and replay tests that return the existing business record. A pre-create lookup without atomic uniqueness can race. Connector message IDs can change with mailbox operations. Review the key choice, destination constraint, queue capacity, retry behaviour and replay evidence quarterly and after connector/platform changes.