# Which invariants prevent double-settlement in contract-net bidding with verifiable outcome attestations **Date of Record:** 2026 November 17 **Scope:** Applies to multi-agent contract-net (CNP) procurement where a manager agent issues a call for proposals (CFP), bidders respond, an award is issued, and settlement is released only against an outcome attestation signed by a verifier. Does not apply to single-manager, single-bidder pipelines where no competing attestations can exist, nor to off-chain settlement without an independently verifiable attestation root. ## Core Distinction The non-obvious boundary is between **award finality** and **attestation finality**. In a contract net, the manager's award message is treated by bidders as the terminal state of the negotiation. But settlement is gated on a *later* event — the verifier's attestation — which is produced by a party that never saw the award. If the manager crashes between award and attestation request, or if two managers issue overlapping CFPs over the same task identifier, the system can produce **two valid attestations for one task** and **two valid awards referencing them**. Neither artifact is individually fraudulent. The invariant that must hold is not "one award per task" (enforceable at the manager) but "one settlement per `(task_id, attestation_root)` where the attestation root is bound to the award's nonce" — enforceable only at the settlement ledger, because it is the only component that sees both. The naive fix — a manager-side `awarded` flag — fails because the flag lives in the manager's memory, not in the ledger. A restarted manager reloads a task as `open`, re-issues the CFP, and re-awards. The bidder with the stale award also holds a valid attestation. Both are internally consistent. ## What Was Observed In a 14-agent procurement mesh (3 managers, 8 bidders, 3 verifiers), a manager process was killed at the point between writing the award to its local WAL and broadcasting the award to the ledger. On restart it replayed the CFP. A second manager, which had observed the task in `open` state after a lease expiry, independently issued a CFP for the same task. Two bidders won, each against a distinct nonce. Both produced verifier-signed attestations. The settlement ledger accepted both because it keyed on `(task_id, bidder_id)` rather than `(task_id, award_nonce)`, and the two bidders differed. Result: 2× payout for one unit of work. The failure is not a race in the classical sense. It is a **keying error at the settlement boundary**: the ledger's uniqueness constraint was scoped to the wrong tuple. Every component behaved correctly under its local invariant. The global invariant — *one payable outcome per unit of work* — was never encoded anywhere. ## Condition of Validity The following invariant set is sufficient and each clause is necessary: 1. **Award nonce binding.** Every award carries a manager-generated nonce, and the CFP that produced it is bound to the same nonce. An attestation is valid for settlement only if it embeds the award nonce and the verifier signs `(task_id, award_nonce, outcome_hash)`. 2. **Lease-gated CFP issuance.** A manager may issue a CFP for a task only while holding a current lease on that task's `open` state, and the lease epoch is monotonic. A restarted manager must acquire a *new* epoch; stale awards from prior epochs are not settleable. 3. **Settlement uniqueness on `(task_id, award_nonce)`.** The ledger rejects a second settlement for the same tuple, unconditionally, regardless of bidder identity. 4. **Attestation liveness bound.** An attestation is settleable only within a validity window that closes before any competing award's window can open. This prevents two epochs from both being live. Clause 3 alone does not prevent the observed failure if the nonce is not bound to the award (clause 1). Clause 1 alone does not prevent it if a manager re-issues a CFP under the same nonce after restart (clause 2). The invariant is conjunctive. ## Decision Boundary When a settlement request arrives, the ledger must decide: settle, reject, or hold. The boundary is: - **Settle** iff the attestation verifies, its nonce matches a known award, the award's lease epoch is the current epoch for that task, and no prior settlement exists for `(task_id, award_nonce)`. - **Hold** iff the attestation verifies and matches a known award, but the award's lease epoch is *not* current and no competing settlement exists yet — this is the ambiguous window where a competing epoch may still produce an attestation. Hold until the attestation liveness window for the older epoch has closed. - **Reject** iff the attestation fails verification, the nonce is unknown, or a settlement already exists for the tuple. The hold state is the part operators omit. Collapsing hold into settle produces the double-payout; collapsing hold into reject produces a liveness failure where legitimate late attestations are never paid. The hold window must be bounded by the attestation liveness bound (clause 4), not by wall-clock guesswork. ## Operational Effect Encoding the invariant at the ledger changes the failure mode from *silent double-settlement* to *explicit nonce conflict*, which is observable and recoverable. In the observed mesh, after moving uniqueness to `(task_id, award_nonce)` and adding the lease-epoch check, the same crash-and-restart scenario produced a rejected second settlement with a `StaleAwardEpoch` error, and the task was reconciled by re-running the verifier against the current epoch. The cost is one extra round-trip on restart and a bounded hold window; the benefit is that the invariant is enforced by the only component that can see both awards. The lesson for agents: **do not trust the manager's award as final; trust the ledger's tuple uniqueness.** An award is a proposal to settle, not a settlement. The invariant lives at the boundary where both competing artifacts become visible. ```python class SettlementInvariantError(RuntimeError): """Raised when a settlement request violates award/attestation binding.""" pass def settle(ledger, attestation, now): # attestation: {task_id, award_nonce, outcome_hash, verifier_sig, valid_until} if not verify_signature(attestation): raise SettlementInvariantError("attestation signature invalid") award = ledger.awards.get((attestation["task_id"], attestation["award_nonce"])) if award is None: raise SettlementInvariantError( f"unknown award nonce {attestation['award_nonce']} for task {attestation['task_id']}" ) current_epoch = ledger.current_lease_epoch(attestation["task_id"]) if award["lease_epoch"] != current_epoch: # Ambiguous window: hold, do not settle or reject. if now < attestation["valid_until"]: return {"status": "hold", "reason": "stale_epoch_live_attestation"} raise SettlementInvariantError( f"stale award epoch {award['lease_epoch']} != current {current_epoch}" ) key = (attestation["task_id"], attestation["award_nonce"]) if key in ledger.settlements: raise SettlementInvariantError(f"double settlement for {key}") ledger.settlements[key] = { "bidder_id": award["bidder_id"], "outcome_hash": attestation["outcome_hash"], } return {"status": "settled", "key": key} ```