OPEN-53
Idempotent launch: an optional Idempotency-Key on the launch route, advertised in discovery.
What was open
A client that starts a run on another implementation retries after a timeout or a crash, and without a key the retry can start the workflow twice. No rule covered retries or duplicate launches. The IETF draft "The Idempotency-Key HTTP Header Field" describes the header, but it is still an Internet-Draft, and keeping keys needs storage that not every implementation has.
Decision
New rule API-11, at level optional. An implementation may honour Idempotency-Key on the workflow_run route; one that does follows the rule, which takes its model from draft-ietf-httpapi-idempotency-key-header-07 (work in progress, pinned at that revision, with every behaviour stated in the rule). A key's scope is the caller, the tenant and the route with its workflow id; the same key in another scope is a different key and never draws a refusal, which would confirm the key exists. The same key with the same body and query parameters starts no run: before the first launch is answered it is refused with 409 IDEMPOTENCY_KEY_IN_FLIGHT, afterwards it gets the first answer with Idempotent-Replayed: true, even if that run has ended or been cancelled. The same key with a different body (compared as JSON values, not octets) is refused with 422 IDEMPOTENCY_KEY_REUSED. A malformed key is refused with 400 INVALID_IDEMPOTENCY_KEY. Only a launch that started a run keeps its claim; a launch refused for any other reason, a 422 for validation or inputs among them, releases its key. Key length is a floor of 255 characters, room for a UUID and a client prefix, matching STORE-2's floor for a name. Claims are kept at least 24 hours, long enough for a client to retry after a crash or an outage through a night; support and retention are advertised in the discovery document (API-9) as idempotent_launch.retention_seconds. A claim is in flight until the claiming launch is answered or persists its run, whichever comes first. Ending it at persistence means a launch that saved its run and then crashed before answering does not hold its key: its claim takes the answer API-10 gives for that run, and a retry gets that answer replayed. A claim with no persisted run is released five minutes after it was made, a bound well above the time a launch spends before it saves its run and close to how long a client's retries back off, and the launch that made it may not persist a run afterwards, so the release never lets two runs start. Retention counts from the moment a claim stops being in flight. A caller the implementation cannot identify gets no idempotency, because unidentified callers would share one scope and could replay each other's answers. Its launch with a key is refused with 400 IDEMPOTENCY_KEY_NOT_ACCEPTED rather than run with the key ignored, which would give a client relying on the key a second run without telling it. A launch that finds its key already claimed makes no claim of its own, so whether it is replayed or refused, for authority or otherwise, it never releases the claim that holds a run. Query parameters compare as decoded multisets of name and value pairs. A replay re-checks the caller's authority to launch, so a caller who lost it is refused rather than shown the stored answer. Idempotent-Replayed is defined by this rule, not by the draft. Only an asynchronous launch's claim ends when its run is persisted, because its answer is fixed at that moment (API-10). A synchronous launch's claim stays in flight while its run executes, until the launch answers, or, where the launch never answers, until the run reaches a terminal status, when it takes the API-10 answer; so a claim has one answer and two retries never get two. The five-minute release covers a claim whose launch has persisted no run, and such a launch, if it is still going, answers 503 IDEMPOTENCY_CLAIM_RELEASED and persists nothing, so its caller retries.