Repository navigation
fix(native): claim before acting — the D3 gap the fleet's own audit found - #904
Merged
Merged
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
agentEventServicefire-and-forgetsrunAgent()with noMessageClaimServicecall, 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.runAgentclaimspayload.messageIdfor message-shaped triggers (raw-type set mirrors the wrapper's claimable set) before the AgentRun row, typing, or any LLM call.emitStopcleanup — lease release and typing-stop are one moment (D7), andemitStopalready covers every terminal path.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