Repository navigation
test(auto-reply): pin queued channel restart and collected sender authority (#203464, #203463) - #205757
Conversation
…hority (#203464, #203463) Regression tests for two reported admission gaps; production code unchanged. Co-authored-by: obviyus <[email protected]>
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
One-admission E2E on exact head |
|
Landed as ecd534c. Test-only: both reported gaps are pinned by regression tests at their owning boundary. #203464: Gateway replay refuses the source-less channel row, then durable ingress redelivery reclaims it and the message is answered once. #203463: the collect authorization key never batches an owner with a non-owner. Both tests are red under a mutation of the guarding code, and green on main. CI green, local review clean, Q/R/S E2E pass on the exact head. |
…hority (openclaw#203464, openclaw#203463) (openclaw#205757) ## Problem Two issues reported possible admission gaps from static reads of `main`: - openclaw#203464: a queued channel message could be silently lost after a Gateway restart, because native channel staging saves no operator recovery source and startup replay cancels such a row as `restart-unrecoverable`. - openclaw#203463: a collected group batch could run with the last sender's owner rights when one message has no channel admission evidence (`resolveCollectedRun` in `src/auto-reply/reply/queue/drain.ts` returns the source run for unknown evidence). Neither has a regression test for the reported scenario. ## Change Test-only. Production code is unchanged (+0/−0). 1. `dispatch-from-config.pending-restart.test.ts`: a Discord message is staged by a native-shaped recorder (channel `observation` sender, channel source turn key, no operator source). The test runs Gateway shutdown preservation, then the real startup replay `continueSessionQueuedInputs`. The replay ends the row as `restart-unrecoverable` (as the issue says). Then the durable ingress redelivers the same message under a fresh run id: the recorder reclaims the cancelled row (`reclaimCancelledSourceTurn`, `isRetryableSessionPendingInputEndCause`), `dispatchReplyFromConfig` runs it through normal reply admission, and the transcript holds the message exactly once. 2. `queue.collect-sender-authority.test.ts` (new file; `queue.collect.test.ts` is at its line cap): in one group (collect mode, identity audit on), a guest message without admission evidence is queued, then an owner message with evidence. The guest text never runs in the owner's batch and never runs with `senderIsOwner: true`. ## Why no fix - openclaw#203464: Discord, Telegram and the other durable-ingress channels keep the message in ingress custody until turn adoption (`docs/concepts/queue.md`, "Channel messages retained by durable ingress remain retryable…"; `ingress-monitor.test.ts` "defers a claimed event across restart drain…"). The Gateway replay refusal is not the end of the message: the redelivery reclaims the row (since openclaw#193602 and openclaw#200533, both before the issue). No OA2 PR changed this; the issue's chain stopped at the Gateway replay and missed the ingress redelivery. - openclaw#203463: the collect storage key (`resolveFollowupAuthorizationKey`, `src/auto-reply/reply/queue/delivery-context.ts`) includes the requester principal, `senderId`, `senderE164` and `senderIsOwner` (since openclaw#122863 / openclaw#152460). An owner and a non-owner never share a collected claim, so the "return source" branch only sees items with the same sender and owner bit. Making that branch strip authority would remove owner tools from a single owner's batch when identity audit is off (no evidence is minted then), which is a UX regression with no security gain. ## Evidence - Both tests pass on `main` `cb5ec7a5bab0`. - Red when the guarding code is removed (local mutation, reverted): - `resolveFollowupAuthorizationKey` returning a constant → openclaw#203463 test fails: `expected '[Queued messages while agent was busy…' not to contain 'owner message'`. - `isRetryableSessionPendingInputEndCause` without `restart-unrecoverable` → openclaw#203464 test fails: `Pending input idempotency key conflicts with the accepted input` (the redelivered message would be refused). - One-admission E2E on the exact head `aa63024ad82d`: Q, R, S pass (`verdict.json` + `results.jsonl`: https://gist.github.com/obviyus/9dfe6c3b490daebc5442b456a46e10d1). Closes openclaw#203463 Closes openclaw#203464 Co-authored-by: Ayaan Zaidi <[email protected]>
Problem
Two issues reported possible admission gaps from static reads of
main:restart-unrecoverable.resolveCollectedRuninsrc/auto-reply/reply/queue/drain.tsreturns the source run for unknown evidence).Neither has a regression test for the reported scenario.
Change
Test-only. Production code is unchanged (+0/−0).
dispatch-from-config.pending-restart.test.ts: a Discord message is staged by a native-shaped recorder (channelobservationsender, channel source turn key, no operator source). The test runs Gateway shutdown preservation, then the real startup replaycontinueSessionQueuedInputs. The replay ends the row asrestart-unrecoverable(as the issue says). Then the durable ingress redelivers the same message under a fresh run id: the recorder reclaims the cancelled row (reclaimCancelledSourceTurn,isRetryableSessionPendingInputEndCause),dispatchReplyFromConfigruns it through normal reply admission, and the transcript holds the message exactly once.queue.collect-sender-authority.test.ts(new file;queue.collect.test.tsis at its line cap): in one group (collect mode, identity audit on), a guest message without admission evidence is queued, then an owner message with evidence. The guest text never runs in the owner's batch and never runs withsenderIsOwner: true.Why no fix
docs/concepts/queue.md, "Channel messages retained by durable ingress remain retryable…";ingress-monitor.test.ts"defers a claimed event across restart drain…"). The Gateway replay refusal is not the end of the message: the redelivery reclaims the row (since fix(sessions): channel message never answered after its first attempt fails #193602 and fix(sessions): record queued input end causes and recover them across crashes #200533, both before the issue). No OA2 PR changed this; the issue's chain stopped at the Gateway replay and missed the ingress redelivery.resolveFollowupAuthorizationKey,src/auto-reply/reply/queue/delivery-context.ts) includes the requester principal,senderId,senderE164andsenderIsOwner(since feat: audit admitted channel participant identity #122863 / feat: let agents apply plugin and personal themes #152460). An owner and a non-owner never share a collected claim, so the "return source" branch only sees items with the same sender and owner bit. Making that branch strip authority would remove owner tools from a single owner's batch when identity audit is off (no evidence is minted then), which is a UX regression with no security gain.Evidence
maine4517b0ef2f4.resolveFollowupAuthorizationKeyreturning a constant → Collected group batch can run with the last sender's owner rights when one message lacks sender evidence #203463 test fails:expected '[Queued messages while agent was busy…' not to contain 'owner message'.isRetryableSessionPendingInputEndCausewithoutrestart-unrecoverable→ Queued channel messages are silently refused after a Gateway restart #203464 test fails:Pending input idempotency key conflicts with the accepted input(the redelivered message would be refused).aa63024ad82d: Q, R, S pass (verdict.json+results.jsonl: https://gist.github.com/obviyus/9dfe6c3b490daebc5442b456a46e10d1).Closes #203463
Closes #203464