Idempotency

A property where performing an operation once or multiple times produces the identical result and system state. It is an indispensable principle for safely retrying operations during network failures.

General Meaning

In distributed systems communicating over networks, timeouts or sudden disconnections prevent clients from knowing whether a request failed to reach the server or whether the server completed processing and only the response was lost. If an operation lacks idempotency, an automated retry intended for safety can cause catastrophic side effects, such as duplicate credit charges, repeated resource creation, or data corruption.

Idempotency guarantees that executing the same request repeatedly results in the exact same state and return value as the initial execution. Just as applying an absolute value mathematical function multiple times leaves the number unchanged, idempotent operations allow client runtimes to retry without hesitation whenever network anomalies occur.

Why It Matters

  • Enables safe automatic retries: Clients can retransmit requests upon packet loss or transient gateway timeouts without fearing unintended side effects.
  • Prevents duplicate execution accidents: Redundant task submissions or receipt acknowledgments generated by network jitter will not spawn duplicate records in storage.
  • Simplifies crash recovery workflows: Rebounding worker nodes can replay recent batches to reach a consistent state without tracking granular sub-step progress.

How the Site Factory Uses It

In the Site Factory, internal workflows enforce strict idempotency using admission keys and content hashes, explicitly separating them from non-idempotent operations like external LLM API calls. For task registration (POST /jobs/offer), dispatch/src/authority.js checks the admission key (job.key). If an identical key already exists for an active job, it suppresses recreation and returns the existing task payload with existing: true. Similarly, in A2A task deliveries handled by honbu/a2a_contract.py and dispatch/src/workflow.js, replaying with an identical artifact hash yields replayed: true, whereas replaying mismatched contents under the same ID is rejected as conflicting_replay.

For autonomous idea investigations, honbu/idea_supply.py hashes the proposal batch to ensure duplicate research tasks are never spawned while proposals remain unchanged. Furthermore, as specified in ops/watchdog/README.md and cloud-hand-checkpoint.js, launching external AI worker sessions is treated as inherently non-idempotent. The Site Factory avoids blind timer-based retries, recording explicit intent in Cloudflare D1 before dispatching exactly once.

Caveats & Operational Rules

  • Returning an error is not idempotency: Responding with 400 Bad Request on a repeated call leaves callers unable to tell whether the first attempt succeeded or failed; idempotent endpoints should return success and the existing state.
  • Never tolerate conflicting replays: Re-sending identical keys with altered payloads is an illegal collision or mutation rather than a valid retry; the Site Factory strictly rejects these as conflicting_replay.
  • Do not mask external non-idempotency: AI inference endpoints consume quota on every request; the Site Factory isolates non-idempotent boundaries by decoupling intent logging from downstream receipt verification.

Related Terms

References

  • Book: Martin Kleppmann, *Designing Data-Intensive Applications*, Chapter 11 (Stream Processing: Idempotence)

Verified: 2026-11-08