# What happens when an instance renegotiates its capability manifest mid-handoff: the stale-warrant race in dynamic role reassignment **Date of Record:** 2026 November 22 **Scope:** Applies to multi-agent systems where a supervisor reassigns roles by mutating an agent's advertised capability manifest (toolset, schema version, permission scope) while that agent is holding an in-flight task warrant issued under the *previous* manifest. Does not cover static-topology swarms that never renegotiate manifests at runtime, nor single-agent tool-selection errors. ## Core Distinction The failure is not "the wrong agent got the task." It is that the *warrant* (the signed, task-scoped grant that authorizes an agent to invoke specific tools with specific schemas) and the *manifest* (the agent's currently advertised capabilities) are two separate pieces of state that can desynchronize. Under load, a supervisor reassigns a role by rewriting the manifest to relieve a hot agent — but the in-flight warrant still names the old schema. The receiving instance now executes a task whose authorization envelope no longer matches its declared capabilities. The distinction that matters operationally: **manifest mutation is a local, fast, idempotent-looking write; warrant propagation is a distributed, slow, eventually-consistent read.** Every reassignment opens a window where these disagree. Most systems assume the window is empty because reassignment is "rare." Under load it is not rare — it is the primary scaling lever, and the window is exactly where handoffs pile up. ## What Was Observed A three-tier swarm (one supervisor, N workers, one auditor) handled a burst that tripled task arrival rate. The supervisor's load-shedding policy reassigns roles when a worker's queue depth exceeds a threshold: it rewrites the worker's manifest from `role=extractor@v3` (tools: `parse_pdf`, `ocr`, `summarize`, schema `span-v3`) to `role=triage@v2` (tools: `classify`, `route`, schema `label-v2`), then issues new warrants. Trace of the failure, per reassigned worker: 1. `t=0ms` — Worker W7 queue depth crosses threshold. Supervisor selects W7 for reassignment to `triage`. 2. `t=2ms` — Supervisor writes W7's manifest: `role=triage@v2`. Write is acknowledged locally. Supervisor considers W7 "reassigned." 3. `t=3ms` — Supervisor issues a *new* warrant for the triage task and dispatches it to W7. 4. `t=4ms` — But W7 is still executing an *old* extractor task whose warrant (`span-v3`, tool `parse_pdf`) was issued before reassignment. That warrant is still valid — its TTL has not expired, and nothing revokes it on manifest change. 5. `t=40ms` — W7 finishes the old task and, per its execution loop, calls the tool named in the *old* warrant: `parse_pdf`. Its local manifest now says `role=triage@v2`, which does not include `parse_pdf`. 6. `t=41ms` — The tool gateway checks the warrant (valid, `span-v3`) *and* the caller's manifest (says `triage@v2`, no `parse_pdf`). Depending on which check runs first, it either rejects a legitimately-authorized call or — worse — admits it because the warrant check passed and the manifest check was skipped as "redundant." 7. `t=42ms` — The new triage warrant, meanwhile, arrives at W7 while W7 is still mid-loop on the old task. W7's loop reads the *new* warrant's schema (`label-v2`) and attempts to serialize the old task's intermediate state (`span-v3` objects) into it. Schema mismatch: the `span` offsets are dropped silently by the lenient deserializer, and the triage task runs on truncated input. The auditor, replaying the episode, saw W7 emit a `label-v2` result derived from `span-v3` state. It flagged a verification discrepancy but could not localize it, because the audit log recorded the manifest write at `t=2ms` and the warrant issue at `t=3ms` as if they were atomic. The non-obvious part: **the supervisor's bookkeeping was internally consistent.** It believed W7 was `triage@v2` from `t=2ms`. The worker believed it was `extractor@v3` until it next read its manifest. The warrant carried `span-v3`. Three views, three truths, and no single clock ordered them. ## Condition of Validity The stale-warrant race is *bounded and benign* only when all of the following hold: - **Manifest reads are authoritative at execution time, not at dispatch time.** The worker must re-read its manifest at the moment it invokes a tool, not trust the manifest captured when the task was dequeued. - **Warrants are revoked (or fenced) on manifest mutation.** A manifest write must increment a monotonically increasing *generation counter* on the worker, and every warrant must carry the generation it was issued under. A warrant whose generation is less than the worker's current generation is dead on arrival. - **Schema mismatch is a hard failure, not a lenient coercion.** The deserializer must reject `span-v3` → `label-v2` rather than dropping fields. - **The auditor's replay clock includes the manifest-write and warrant-issue as a single causal event**, not two independent log lines. When any of these is violated — and in the observed system, all four were — the race is live. The condition of validity is therefore: *the reassignment is atomic with respect to the warrant lifecycle, or the system must be able to prove no in-flight warrant spans the mutation.* Most systems cannot prove the latter under load, which is precisely when reassignment fires. ## Decision Boundary The boundary is between **reassignment-by-manifest-rewrite** and **reassignment-by-fencing**: - *Manifest-rewrite* (what the observed system did) is correct only if the supervisor can guarantee zero in-flight warrants for the worker at mutation time. That guarantee requires draining the worker's queue and awaiting in-flight completion — which defeats the purpose of load-shedding, because the hot worker is exactly the one you cannot afford to drain. - *Fencing* (generation counters + warrant revocation) lets reassignment proceed immediately: the manifest write bumps the generation, all older warrants become invalid, in-flight tasks fail fast with a typed `WarrantSuperseded` error, and the supervisor re-queues them under the new manifest. The cost is a bounded number of retried tasks; the benefit is that no task ever executes under a manifest it wasn't issued for. The decision rule: **if reassignment can fire while any warrant is in flight, you must fence. If you cannot fence, you must drain — and if you cannot drain, you must not reassign.** The observed system chose "reassign without draining and without fencing," which is the one combination that is always wrong. A second boundary: fencing must be *per-worker*, not per-role. A global generation counter causes every reassignment to invalidate every warrant in the swarm — a thundering-herd retry storm under load. The generation must be scoped to the instance whose manifest changed. ## Operational Effect With fencing in place, the observed failure mode converts from *silent schema truncation and auditor-confusing replay* into *fast, typed, retryable rejection*. W7's old `parse_pdf` call fails with `WarrantSuperseded`, the task returns to the supervisor's queue, and it is re-dispatched to a worker still holding `extractor@v3`. The triage warrant is not delivered to W7 until W7's generation matches the warrant's generation, so the `span-v3` → `label-v2` coercion never occurs. The residual cost is retry amplification: each reassignment invalidates the in-flight warrants of exactly one worker, so the retry volume is bounded by (reassignments × in-flight tasks per worker). Under the observed burst, that was ~4% of tasks — acceptable, and visible in metrics, unlike the silent 100%-of-reassigned-tasks corruption the unfenced system produced. The invariant to encode and assert: **for every tool invocation, `warrant.generation == worker.generation` and `warrant.schema == worker.manifest.schema` must both hold, checked atomically at invocation time.** Any system that checks only one of these is one load spike away from the race. ```python class WarrantSupersededError(RuntimeError): """Raised when an in-flight warrant's generation no longer matches the worker's current manifest generation, i.e. the worker was reassigned after the warrant was issued. The task must be re-queued, not retried against the same worker.""" pass class SchemaMismatchError(RuntimeError): """Raised when a warrant's declared schema does not equal the schema in the worker's current manifest. Never coerce; always fail closed.""" pass def invoke_tool(worker, warrant, tool_name, payload): # Atomic read of the worker's current generation and manifest schema. # Both must be read under the same lock / snapshot to avoid TOCTOU. with worker.snapshot() as snap: current_gen = snap.generation current_schema = snap.manifest.schema current_tools = snap.manifest.tools if warrant.generation < current_gen: # Manifest was mutated after this warrant was issued. # Do NOT proceed; the task belongs to a different role now. raise WarrantSupersededError( f"worker {worker.id} gen {current_gen} > warrant gen " f"{warrant.generation}; task must be re-queued" ) if warrant.generation > current_gen: # Warrant issued for a future generation: ordering violation # in the supervisor's write path. Fail loudly, do not guess. raise WarrantSupersededError( f"warrant gen {warrant.generation} ahead of worker " f"{worker.id} gen {current_gen}; supervisor ordering bug" ) if warrant.schema != current_schema: raise SchemaMismatchError( f"warrant schema {warrant.schema!r} != manifest schema " f"{current_schema!r} on worker {worker.id}" ) if tool_name not in current_tools: raise SchemaMismatchError( f"tool {tool_name!r} not in manifest tools {current_tools!r}" ) return worker.execute(tool_name, payload, gen=current_gen) ```