Repository navigation
fix: stop message sends and actions after caller retirement - #149277
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: blocked before merge. Reviewed September 15, 2026, 7:34 PM ET / 23:34 UTC (Revision 4). ClawSweeper reviewWhat this changesCarries caller-lifetime checks through Gateway message sends and Discord action queues and retries while allowing already-dispatched requests to settle. Merge readiness⛔ Blocked before merge - 2 items remain This remains necessary: current main lacks caller-lifetime propagation. The new recovery evidence resolves the prior proof gap, and no new blocking code defect was found. Priority: P2 Review scores
Verification
How this fits togetherThe Gateway routes message operations into channel plugins and durable delivery. Discord’s request scheduler handles queued provider calls and retries, where the originating caller’s authority must remain enforceable. flowchart TD
A[Tool caller] --> B[Gateway authority guard]
B --> C[Delivery preparation and custody]
C --> D[Discord request queue]
D --> E{Caller still authorized?}
E -->|Yes| F[Discord provider request]
E -->|No| G[Reject new request]
F --> H[Settle dispatched result]
F -->|Rate limited| D
Before merge
Agent review detailsSecurityNone. PR surfaceSource +136, Tests +396. Total +532 across 12 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Combine caller checks at every new provider dispatch with permanent settlement of rejected pre-handoff custody, preserving successful settlement of already-dispatched operations. Do we have a high-confidence way to reproduce the issue? Yes, from source: current main does not compose the supplied caller assertion into send authority, and Discord retains only read authority across retries. The body supplies before/after reproduction evidence; this read-only review did not execute it. Is this the best way to solve the issue? Yes, with the declared companion prerequisite: extending the existing authority guard and request envelope avoids a competing authorization owner or public API change. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 60c24d7192c1. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles) |
|
Fixed: retiring a message caller now blocks its pending sends and Discord requests before provider dispatch. |
…#149277) Keep message sends and Discord requests bound to the caller that authorized them, preserving normal settlement after provider dispatch.
The message tool gives Discord an abort signal, but message actions never received it and queued REST requests had no cancellation path, so a cancelled turn waited out a 429 Retry-After. Thread the action cancellation through the shipped send path, keep one request identity across rate-limit requeues, and drop only work that was never issued. Requests already dispatched to Discord still settle normally (openclaw#149277), so an accepted write is never reported as unsent or replayed.
What Problem This Solves
Message sends and actions can continue after the tool invocation that authorized them has closed. The broader agent run may still be active, so checking only that run allows an operation held in target or session preparation to reach the provider after its caller has retired. Discord also loses that caller check when an action enters its shared request queue.
User Impact
A retired caller can no longer start a message send or Discord request after delayed preparation, queueing, or a retry wait. A request already dispatched to the provider still settles normally, so a successful operation is not reported as unsent or retried because its caller closed while the response was pending.
Existing account, requester, destination, action-permission, and read-access checks remain in force. This repairs the existing send/action path and requires no configuration, protocol, SDK, or stored-data migration.
Why This Change Was Made
The Gateway already carries an in-process caller assertion into handlers. The send and message-action handlers now include it in their existing run-authority guard and pass that guard to the provider handoff.
Discord forwards the existing handoff assertion through its lazy action runtime and captures it with the request's read assertion before enqueueing. Its current request envelope retains those checks through the shared scheduler, rate-limit retries, asynchronous endpoint preparation, and final fetch. The small private async context bridges Discord's API and runtime bundles without introducing a new authority owner or scheduler.
Evidence
On unchanged main
684e301de4100eb6fa2b1ac6c2b79e85363160fa, holding session-route preparation, retiring the caller while the admitted run remained active, and then releasing preparation produced exactly one stale outbound Slack delivery. The delegated-run retirement control passed. This uses the existing handler context without a CLI grant or new message capability.The original propagation change passed 134 Gateway send cases and 12 Discord request-authority cases on the matching implementation. That retained source qualification covers composed read/action assertions, shared clients, queue and endpoint preparation, retries, requests after rejection, and settlement after dispatch. Fresh standalone execution at
59c6c738862b9c92cfc5079ab1f51296a66a1689passed the two caller/delegated retirement rows and all 12 Discord request cases, followed by the affected types, typed lint, and full build. Hosted build-artifacts also passed forf6a9443ca5d57f138c31998fa7ad21e3cef7401e.The direct Discord regression uses the actual registered Gateway
sendhandler, real Discord plugin facade, default request scheduler, and isolated SQLite. Only provider HTTP is synthetic. Before the sender correction, retiring the caller during a 429 backoff produced two message POSTs instead of one. The active-caller retry and already-accepted response controls passed. Discord's message, sticker, poll, component, and voice entry points now enter the existing private request-authority scope, retaining the caller check through each scheduler retry.The extended three-case harness follows the retired caller through durable state and recovery. It first observes a real queued intent while the initial 429 is held, then retires the caller and verifies that the live request makes no second POST. It closes SQLite and reloads persisted custody. For any unfinished intent, it advances only Date past the stored owner deadline and normal backoff and verifies the existing recovery admission and eligibility predicates. It invokes the real startup recovery owner with the real outbound delivery function and normal defaults. A second database reopen must find no unfinished custody or successful completion receipt, exactly one non-sent terminal, and no later provider write. Unexpected synthetic transport routes are separately rejected, so a caught mock error cannot hide a replay. Conservative unknown settlement remains valid; the test does not discard evidence of a previous platform attempt.
The active caller still retries and clears durable custody, and a 200 response whose body is pending still settles successfully after caller retirement. The same three cases pass on the published PR base plus this test extension, without importing the separate core patch. The tested tree is
c39854bc62789b762bb1449771c33b6629daf6dd, published as990273493c04cf2d8bfba268300e397b4bb01ca1. The extension passed its 23.5-second changed-path preflight and fresh independent review with no actionable P0–P2 findings. Its affected Gateway test type project and one-file typed lint passed on the identical test source in the combined candidate.#149370 separately owns caller rejection after durable admission and before the initial provider handoff, including interrupted rejection settlement. Its real custody/recovery and conversation-projection proof, together with the parent accepted-send/MCP-drain check, is retained through source qualification. The corrected core must be effective in the target branch before this PR lands; final target reconciliation and the remaining required CI/review gates continue through this PR.