Repository navigation
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 SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex review: needs real behavior proof before merge. Reviewed September 30, 2026, 10:38 AM ET / 14:38 UTC (Revision 14). ClawSweeper reviewWhat this changesThe branch releases deferred Discord and Mattermost channel ingress lanes, coordinates batching across senders to preserve arrival order, and adds ingress, ordering, and cancellation tests. Merge readiness⛔ Blocked before merge - 4 items remain Current main still holds deferred Discord and Mattermost ingress lanes, so this PR has distinct remaining value. The cancellation recheck is present, but its Mattermost regression does not establish that cancellation occurred during the lane wait, and real Mattermost behavior remains unproven. Priority: P1 Review scores
Verification
How this fits togetherDiscord and Mattermost receive channel posts through durable ingress queues, then pass them to per-sender debouncers and agent reply processing. The change lets another post enter while an earlier post waits to be batched, while coordinating the order in which different senders reach reply processing. flowchart LR
A[Discord or Mattermost post] --> B[Durable ingress queue]
B --> C[Channel lane]
C --> D[Sender batch]
D --> E{Same channel, different batch?}
E -->|Yes| F[Wait for earlier admission]
E -->|No| G[Reply processing]
F --> G
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +256, Tests +471. Total +727 across 10 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep lane release and per-channel admission ordering together, make the cancellation regression wait for an observable cross-key handoff, and capture redacted Mattermost behavior through its real receive path before merge. Do we have a high-confidence way to reproduce the issue? Yes, from source: current main leaves both monitors on the shared drain's hold default, which prevents a second same-channel deferred event from reaching the debouncer before adoption. I did not execute contributor code in this read-only review. Is this the best way to solve the issue? Unclear for merge readiness: channel-local lane release with cross-sender admission ordering fits the existing ingress contract, but the Mattermost cancellation test and real-path proof still need to establish the claimed boundary behavior. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 837a2e3303a2. LabelsLabel changes: No label 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 (13 earlier review cycles; latest 8 shown)
|
575e084 to
a34cd7e
Compare
|
@clawsweeper re-review The
Current state: |
|
@clawsweeper re-review Both findings from the 2026-09-23 21:19 UTC review ( Finding 1 (P1, ordering — lane released at the Finding 2 (P2, cancellation). Regression coverage added: delayed-preparation ordering (earlier batch fires on its timer and is slow inside the flush; the later different-key message must still dispatch after it) for Discord and Mattermost, and deactivate-during-cross-key-wait for Discord. Validated: |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
…rn merge can happen
Both Discord's and Mattermost's durable ingress monitors dispatch into
the reply/turn debouncer and can return "deferred", but neither passed
deferredLaneOccupancy, so the drain default ("hold") applied. The lane is
per-conversation (channel:<id>), so holding it across the debounce wait
blocks every same-lane follow-up from being admitted: the start loop
releases it back to the queue instead of dispatching it, and the lane
frees only at onAdopted — after the flush has already created a turn. No
two same-lane messages can land in one flush, and each pays the debounce
window again.
Pass deferredLaneOccupancy: "release" on both drains, mirroring the
Telegram spooled drain's fix for the identical defect (openclaw#101335) and the
WhatsApp durable-receive fix already on this branch.
Adds a regression test per channel proving a second same-lane message
arriving while the first is still deferred is dispatched immediately
instead of waiting for adoption. Both fail with the flag removed
(expected [ '2001' ] to deeply equal [ '2001', '2002' ]) and pass with
it.
Scope note: releasing the lane does not disarm the claim->adoption stall
watchdog, which stays armed through the deferred phase by design
(armStallWatchdog + onDeferred in src/channels/message/ingress-drain.ts).
An agent turn longer than adoptionStallTimeoutMs therefore still
dead-letters its own deferred claim. That is a separate defect (openclaw#116547)
and this change does not address it.
Refs openclaw#119382
The mock annotated event as { id: string }, but DiscordMessageDispatchData.id
is optional. tsgo caught the mismatch (vitest runtime doesn't type-check).
Use the real DiscordMessageEvent type and assert id is present at the two
call sites, matching prior assertion semantics.
Checked the mattermost sibling test (monitor-ingress.test.ts) for the same
pattern -- its dispatch mocks have no explicit param annotations, so
nothing to fix there.
…im expectation - type the Discord ingress dispatch mock as DiscordMessageEvent (id is optional) - import MattermostIngressLifecycle instead of referencing an undeclared name - the recovery case asserted one claim while the lane was held; releasing the lane on defer lets the same-lane follower be claimed and buffered by the same debounce window, so the buffered handler now holds two claims
…released ingress lanes Discord and Mattermost partition their inbound debounce below the per-channel ingress lane (author + reply target for Discord, thread + sender for Mattermost). Releasing the lane on defer (deferredLaneOccupancy: "release") lets those independent keys admit and flush on their own timers with no cross-key ordering guarantee, so a later sender's message could flush ahead of an earlier sender's still-buffering one in the same channel. Port the WhatsApp cross-sender flush guard (extensions/whatsapp/src/inbound/message-debounce.ts) to both batching owners: track which debounce key currently holds each channel lane's pending batch, and force-flush it before admitting a message under a different key in the same lane. This keeps handoff to the next stage in strict per-channel arrival order. Add regression coverage through the real batching owners for both channels: an interleaved A1/B1/A2 sequence from two senders must dispatch in that exact order. Co-authored-by: Ken (Nexus) <[email protected]>
…g module Moves the collector-admission debounce test and the interleaved A1/B1/A2 conversation-ordering test out of monitor.inbound-system-event.test.ts into a new monitor.inbound-ordering.test-support.ts, following the existing monitor.block-progress.test-support.ts pattern. Coverage is preserved (50/50 tests still pass); no eslint-disable or trimmed assertions. Brings the host file back under the line-cap ratchet's inherited allowance (2519 counted lines). Co-authored-by: Ken (Nexus) <[email protected]>
…, not onFlush start ClawSweeper review of 2026-09-23 found two correctness gaps in the cross-sender flush guard from the previous commit: 1. (P1, ordering) releaseLane ran at the start of onFlush, before the flush's own preparation (preflight/handlePost) had reached admission. A different-key arrival in the same channel lane found no pending marker, skipped the wait, and could reach reply processing while the earlier batch was still preparing -- inverting conversation order. debouncer.flushKey is a no-op once a batch has left the debouncer's own pending-buffer map, so simply delaying the release is not enough: the lane record now carries the flush's admission promise (set once onFlush actually starts it), and a different-key arrival awaits that admission directly when present, falling back to flushKey only while the batch is still purely buffered. 2. (P2, cancellation) after awaiting the cross-key guard, Discord's dispatchMessage did not recheck the entry's abort signal before tracking the lane and enqueueing. Deactivation landing during that await left the new key with no buffer for cancelKey to remove, so the entry would still enqueue after shutdown. Rechecked the signal and bailed out the same way the top-of-function check does. Both fixes are scoped to entries actually holding a lane record (debounceMs > 0); an untracked flush (debounceMs === 0) releases its (no-op) lane synchronously as before, so it never pays the extra admission-promise microtask tick that upstream retry/backoff logic in the durable ingress queue tests is timing-sensitive to. Extended the interleaved-sender regression coverage: - Discord: a different-author arrival now waits on an already-flushing batch's admission (not just its onFlush start), and a lane-waiting message is dropped, not enqueued, when the handler deactivates during that wait. - Mattermost: a different-sender arrival waits on an already-flushing batch's admission the same way. Validation (Node 24.21.0, ASDF_NODEJS_VERSION=24.21.0): pnpm tsgo:extensions clean pnpm lint:extensions (oxlint) 0 warnings, 0 errors extensions/discord/src/monitor/ 109 files, 1382 tests passed extensions/mattermost/src/mattermost/monitor 14 files, 334 tests passed Co-authored-by: Ken (Nexus) <[email protected]>
… wait A different-sender post awaiting the earlier batch's admission resumed after monitor shutdown and still tracked the lane and enqueued. Recheck abortSignal after the wait and cancel the ingress lifecycle, matching the Discord recheck. Adds a deactivate-during-cross-key-wait regression test. Co-authored-by: Ken (Nexus) <[email protected]>
3b235d7 to
fc008d5
Compare
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Closing without merge. The defect stays on record as #162714, which carries the mechanism, the WhatsApp before/after measurement and the Discord branch proof. Why close rather than keep iterating: the remaining blocker is real-instance proof for Mattermost, and I have no Mattermost deployment to produce it from. The WhatsApp half this PR started from shipped via #112001, and we no longer carry a local patch on this path. The branch |
What Problem This Solves
runIngressDrainholds the ingress lane while a dispatch returns"deferred"unless the monitoropts out with
deferredLaneOccupancy: "release"(src/channels/message/ingress-drain.ts:127,default
"hold").WhatsApp, Discord and Mattermost all dispatch into a debouncer that defers while the merge window
is open, and none of them passes the option. Their lanes are per-conversation
(
remoteJid,channel:<id>), so holding the lane across the debounce wait blocks every same-lanefollow-up from being admitted: the start loop hands it back to the queue instead of dispatching it,
and the lane only frees at
onAdopted— after the flush has already created a turn.The consequence is that no two messages in one conversation can ever land in the same debounce
flush. Each message pays the full debounce window and becomes its own turn, which is exactly what
the debouncer exists to prevent.
Telegram had the identical defect and was fixed in #101335
(
extensions/telegram/src/telegram-ingress-drain.ts:459); Slack carries the samedeferredLaneOccupancy: "release"today (extensions/slack/src/monitor/ingress.ts:412). This PRapplies that same one-line opt-out to the three remaining durable ingress monitors.
Fixes #119382
Evidence
Current
main(4229c99), the only non-test call sites of the option:WhatsApp, Discord and Mattermost do not appear — they run on the
"hold"default.Each channel gets a regression test that fails without the flag and passes with it: a second
same-lane message arriving while the first is still deferred must be dispatched immediately instead
of waiting for adoption. With the flag removed, the Discord/Mattermost cases fail with
expected [ '2001' ] to deeply equal [ '2001', '2002' ].Local run on this branch (Node 24.21.0, pnpm 12.3.4):
Scope
Releasing the lane does not disarm the claim→adoption stall watchdog, which stays armed through the
deferred phase by design (
armStallWatchdog+onDeferredinsrc/channels/message/ingress-drain.ts). An agent turn longer thanadoptionStallTimeoutMsstilldead-letters its own deferred claim. That is #116547 and this change does not address it.
After-fix real behaviour proof (production WhatsApp)
The one-line change has been running in production on a self-hosted gateway since
2026-09-07 12:12 UTC, applied to the installed
@openclaw/whatsapp2026.8.1bundle (samevalue, same object literal as this PR passes in
durable-receive.ts). Everything below is realinbound WhatsApp traffic from that gateway — no synthetic queue, no mocked inbox. Message bodies,
phone numbers, group JIDs and sender names are redacted; only timings, event ids (truncated) and
the shape of the resulting turn are shown.
Two data sources, cross-checked:
channel_ingress_events(the durable ingress queue): one row per inbound message, withreceived_atand thecompleted_atwritten when the claim settles at adoption.Before the fix — two messages, two turns
Same conversation lane, unpatched gateway, 2026-09-06:
Two turns, settled ~10 s apart: the second message could not join the first one's debounce window,
which is the defect this PR fixes.
After the fix — same shape of burst, one combined turn
Same gateway, same channel, patched, 2026-09-09:
Both claims settle at the same adoption (1 ms apart) and the transcript holds one turn whose
body is the two messages joined by
\n— exactly thecombinedBodythe WhatsApp debouncer buildsin
extensions/whatsapp/src/inbound/message-debounce.ts:105-135.A second occurrence the same day, wider gap, same outcome:
Population, stated honestly
Scanning every same-lane consecutive inbound pair in that gateway's ingress table whose second
message reached an agent turn: before the patch, no pair produced a single combined turn (the
closest, Δ 2.65 s above, produced two); after the patch, pairs at Δ 2.81 s and Δ 4.80 s produced
one combined turn each, with both claims settled at the same adoption. Bursts whose second message
was ignored by the channel (self-echo, filtered) complete in a few ms and are excluded — they never
become turns either way.
The gateway carries no other local modification to the ingress or debounce path.
Update 2026-09-19 — rebased on
a8046858b9e, scope narrowed to Discord + MattermostWhatsApp is fixed on
main: #112001 (fix(whatsapp): admit debounce candidates independently)added
deferredLaneOccupancy: "release"atextensions/whatsapp/src/inbound/durable-receive.ts:140and rewrote the two durable-receive/monitor-inbox tests this PR touched. The three WhatsApp commits
were therefore dropped in the rebase instead of being carried as a duplicate option key.
What remains is the same one-line change on the two channels still running the
"hold"default:extensions/discord/src/monitor/ingress.tsextensions/mattermost/src/mattermost/monitor-ingress.tsScoped suites on the rebased branch, Node 24.21.0:
The production WhatsApp proof above stands as the behavioural evidence for the mechanism; the
channel it was measured on is now fixed upstream, and Discord and Mattermost share the code path.
Update 2026-09-21 — cross-sender ordering fix (P1)
The 2026-09-20 review's P1 finding is correct: Discord partitions its debounce below the
per-channel ingress lane (author + reply target), Mattermost partitions by thread + sender, and
releasing the lane on defer lets those independent keys admit and flush on their own timers with
no ordering guarantee across keys.
Ported the same cross-sender flush guard WhatsApp already carries
(
extensions/whatsapp/src/inbound/message-debounce.ts:167-176, from #112001) into both remainingbatching owners:
extensions/discord/src/monitor/message-dispatcher.tsextensions/mattermost/src/mattermost/monitor.tsEach tracks, per channel lane, which debounce key currently holds the pending batch, and
force-flushes it (
debouncer.flushKey) before admitting a message under a different key in thesame lane — so handoff to the next stage stays in strict per-channel arrival order even with the
lane released.
Added regression coverage through the real batching owners, not a helper test: an interleaved
A1/B1/A2 sequence from two senders in one channel must dispatch in that exact order.
Full scoped local run, Node 24.21.0:
Update 2026-09-26 — ClawSweeper re-review, hold the lane until admission (not onFlush start)
The 2026-09-23 review found the 2026-09-21 fix released the lane too early:
Finding 1 (P1, ordering).
releaseLaneran at the very start ofonFlush, before theflush's own preparation (preflight/
handlePost) reached admission. StartingonFlushonly meansthe debounce timer elapsed — a timer-fired batch A clears its lane marker and then sits in
preparation. A different-key arrival B in the same channel lane found no marker to wait on,
skipped the guard, and could reach reply processing while A was still preparing.
The obvious fix — just delay the
releaseLanecall — is not enough: once a batch has actuallystarted flushing, its buffer has already left the debouncer's own pending-buffer map, so a later
call to
debouncer.flushKey(pendingLane.batchKey)is a no-op and does not wait for anything.Fixed by storing the flush's own admission promise on the lane record once
onFlushstarts it(
markLaneFlushing), and having a different-key arrival await that admission promise directlywhen it is set, falling back to
debouncer.flushKey(forcing an immediate flush) only while theearlier batch is still purely buffered and hasn't started yet:
The lane is released only once that admission settles (
flush.admission.finally(...)), scoped toentries that actually hold a lane record — an untracked flush (
debounceMs === 0) still releasesits no-op lane synchronously as before, so it never pays an extra microtask tick. That mattered in
practice: an earlier version of this fix unconditionally deferred the release via
.finally()onevery flush, and that alone shifted timing enough to break an unrelated fake-timer retry/backoff
test in
monitor.inbound-system-event.test.ts(a message got dispatched twice). Scoping thedeferred path to lane-tracked entries only removed the perturbation while keeping the fix.
Finding 2 (P2, cancellation). In
extensions/discord/src/monitor/message-dispatcher.ts, afterawait debouncer.flushKey(pendingLane.batchKey)the code tracked the lane and enqueued the entrywithout rechecking
entry.abortSignal. If Discord deactivated while that await was pending, thenew key had no buffer yet for
cancelKeyto remove, so the entry could still enqueue aftershutdown. Rechecked the signal right after the await, before
trackLane/enqueue, and bailed outthe same way the top-of-function check already does (cancel the turn-adoption lifecycle, or return
failed-retryable).Applied both to
extensions/discord/src/monitor/message-dispatcher.tsandextensions/mattermost/src/mattermost/monitor.ts(Finding 1 applies to both batching owners;Finding 2 is Discord-specific, matching the review's own line reference). WhatsApp files
untouched.
New regression coverage:
extensions/discord/src/monitor/message-handler.debounce-reply-target.test.ts— adifferent-author arrival now waits on an already-flushing batch's admission (delayed
preparation, not just onFlush start), and a lane-waiting message is dropped rather than
enqueued when the handler deactivates during that wait.
extensions/mattermost/src/mattermost/monitor.inbound-ordering.test-support.ts— adifferent-sender arrival waits on an already-flushing batch's admission the same way.
Full scoped local run, Node 24.21.0 (
ASDF_NODEJS_VERSION=24.21.0, required forpnpm installunder this repo's
enginesfield):Update 2026-09-30
Clarification 2026-09-30 (rebased head fc008d5)
In the interleave proof above, the parenthesised lists are the prompt history window, not the batch. Each dispatch's current request carries only its own sender's lines: B's dispatch had current request
B1alone, withA1present only inside the quoted<conversation_context>history block. No cross-sender merge happened. The proof ran on 3b235d70041; the branch was then rebased on current main with no change to the ingress code (scoped discord+mattermost monitor tests: 119 files passed).