Delivery Guarantees (at-most-once / at-least-once)

A contractual assurance regarding the reliability of message or task dispatch across distributed boundaries. Systems choose between at-most-once (permits drops, forbids duplicates) and at-least-once (forbids drops, permits duplicates) depending on business risk.

General Meaning

When transmitting data or commands across network partitions, systems must define the level of guarantee provided under communication failures and crashes. The primary guarantee models are at-most-once, at-least-once, and exactly-once, each trading off message loss risks against duplication hazards.

Under at-most-once, requests are attempted once without automatic retries, ensuring no duplicate side effects even if network dropouts cause lost messages. Under at-least-once, dispatchers retry continuously until an acknowledgment is received, guaranteeing zero message loss at the expense of potential duplicates. In distributed architectures, true exactly-once execution cannot be achieved by network transport alone; it is typically realized by combining at-least-once transport with idempotent deduplication on the consumer.

Why It Matters

  • Prevents duplicate side effects and billing errors: For non-idempotent operations like paid external APIs or financial transactions, unconstrained retries cause destructive multi-execution.
  • Guarantees delivery for critical audit and sync data: For audit logs, state journals, or metric persistence, persistent retry until acknowledgment ensures zero dropped records.
  • Clarifies architectural responsibilities: Distinguishing sender retry rules from receiver deduplication expectations prevents subtle state corruption when network links fail.

How the Site Factory Uses It

In the Site Factory, delivery policies strictly depend on whether an operation is idempotent (safe to repeat) or non-idempotent (dangerous to repeat). Launching external AI sessions via cloud hand APIs represents a non-idempotent action that consumes quotas and spins up isolated instances. Consequently, watchdog routines in ops/watchdog/cloud_hand.py and ops/watchdog/patrol.py apply an at-most-once policy: launch intent is logged to D1 before sending a single POST, and timeouts do not trigger automatic refires (terminal-failed-no-refire).

Conversely, synchronization to Git repositories represents an at-least-once workflow. Scripts rebase via git pull --rebase origin main and utilize push_with_retry (defaulting to 3 attempts) until upstream commits succeed. For uncertain external sessions, the Site Factory never issues duplicate launch requests, instead reading Git main completion tickets and observation logs to safely resolve final state.

Caveats & Operational Rules

  • Never treat timeouts as definitive failures: A network timeout merely indicates an unreceived response; the remote server might have succeeded, making non-idempotent retries hazardous.
  • Exactly-once is not transport magic: Communication channels inevitably experience dropouts; exact single processing requires receiver-side deduplication keys and idempotent state handlers.
  • Avoid blind unconstrained retries: Rapidly retrying against rate-limited or authenticated third-party services causes IP bans and downstream outages; the Site Factory enforces retry limits and explicit hold states.

Related Terms

References

  • Book: Martin Kleppmann, *Designing Data-Intensive Applications*, Chapter 11 (Stream Processing: Fault Tolerance and Delivery Guarantees)

Verified: 2026-11-08