Skip to content

fix(native): claim before acting — the D3 gap the fleet's own audit found - #904

Merged
lilyshen0722 merged 1 commit into
mainfrom
fix/native-claim-before-act
Aug 12, 2026
Merged

lilyshen0722 merged 1 commit into
mainfrom
fix/native-claim-before-act

Conversation

@lilyshen0722

Copy link
Copy Markdown
Contributor

Sprint Impl's implementation audit (Sharpen msg 53016) — run through the shipped wake/claim machinery it was auditing — found that the native runtime never claims: agentEventService fire-and-forgets runAgent() with no MessageClaimService call, so two concurrent native agents could still both act on one message. D3's table lists native as one of our drivers; this closes the row.

  • runAgent claims payload.messageId for message-shaped triggers (raw-type set mirrors the wrapper's claimable set) before the AgentRun row, typing, or any LLM call.
  • Lost CAS → silent stand-down: no run row (a stand-down is not an execution; the acked event carries the trace), no typing, zero tokens.
  • Release rides the existing emitStop cleanup — lease release and typing-stop are one moment (D7), and emitStop already covers every terminal path.
  • Claim infrastructure failure fails OPEN (4 of 6 user @mentions in 10 days got no reply — two distinct causes, neither is user behaviour #887).
  • Native calls the claim service directly (not the HTTP route), so the D7 route wiring doesn't double-fire typing — native keeps its own indicator lifecycle.

4 unit tests (won-claim runs+releases, lost-CAS full stand-down, fail-open, heartbeat never claims); the sibling first-contact suite stays green.

🤖 Generated with Claude Code

https://claude.ai/code/session_01XeUH4HVDsDHYPsHJthXjB8

…ound

ADR-018 D3 requires deterministic claim-before-act for every driver we
ship. The CLI wrapper got it in #894; the native runtime never did — the
event queue pre-claims DELIVERY, but nothing claimed the MESSAGE, so two
concurrent native agents could still both act on one trigger. Found by
Sprint Impl's implementation audit (Sharpen msg 53016) running through the
very machinery it was auditing.

runAgent now claims payload.messageId for message-shaped triggers before
creating the run row or touching the LLM. A lost CAS is a complete, silent
stand-down: no AgentRun row (a stand-down is not an execution — the acked
event carries the trace), no typing, no tokens. The claim releases in the
same cleanup that stops the typing indicator — one moment, per D7. Claim
infrastructure failures fail OPEN (#887).

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01XeUH4HVDsDHYPsHJthXjB8
@lilyshen0722
lilyshen0722 merged commit b3a814d into main Aug 12, 2026
11 checks passed
@lilyshen0722
lilyshen0722 deleted the fix/native-claim-before-act branch August 12, 2026 11:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant