Repository navigation
fix(whatsapp): make shutdown drain coverage deterministic - #159115
Conversation
Control both same-window and split-window admission schedules instead of assuming every upsert batch coalesces within 20 ms. Keep exact delivery, read-receipt, durable-claim, and socket-close assertions and release held work even when an assertion fails. The original expectation fails deterministically when the third append crosses the debounce window. Production behavior is unchanged. Related: #151608
|
🦞👀 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 26, 2026, 3:20 PM ET / 19:20 UTC. ClawSweeper reviewWhat this changesThe branch replaces one WhatsApp shutdown test with two controlled timing cases that check delivery, read receipts, queue drain, and socket-close ordering. Merge readiness⛔ Blocked before merge - 2 items remain Keep open. Current main still has the scheduler-dependent assertion, and this focused test repair addresses it. The code review found no actionable defect, but the repository’s repeated-run flake qualification is not yet recorded. Priority: P2 Review scores
Verification
How this fits togetherThe WhatsApp plugin admits incoming socket messages to a durable queue, groups eligible messages in a debounce window, and delivers them to a handler. Listener shutdown drains that work before closing the socket. flowchart LR
A[WhatsApp socket] --> B[Durable admission]
B --> C[Debounce window]
C --> D[Message handler]
D --> E[Read receipts]
E --> F[Socket close]
Before merge
Agent review detailsSecurityNone. PR surfaceTests +74. Total +74 across 1 file. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep an owner-boundary shutdown test that accepts both legal admission schedules while requiring every admitted message and receipt to finish before socket close. Do we have a high-confidence way to reproduce the issue? Yes. Delaying the third durable append beyond the debounce window makes the current-main test’s fixed combined-body expectation invalid; the PR reports that pre-fix failure, and the sequential admission path supports it. I did not execute the test. Is this the best way to solve the issue? Yes. Controlled time and admission gates exercise both schedules through the existing monitor and shutdown boundary without changing production behavior. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 718bf2ccae9f. 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
|
|
Applying the maintainer’s explicit proof scope for this deterministic ordering defect: causal RED/GREEN, final owner and relevant sibling coverage, the original failing order, and required CI replace the blanket 20 standalone / three shard repetitions. Stress repetition remains required if a timing hypothesis is unresolved; none remains for this reproduced batching assumption. The original combined-body assertion fails deterministically when the third durable append is held across the 20 ms debounce boundary. The repaired test explicitly controls both legal schedules and keeps exact body ordering, all three receipt IDs, empty pending/claimed queues, and receipt-before-socket-close assertions. It does not depend on wall-clock scheduling to select a batching outcome. The original 14-file selection passed with 147 tests, the final standalone owner file passed with 18 tests, strict changed checks passed, two independent review passes found no actionable defects, and exact-head CI is green. There is no unresolved timing hypothesis from this failure that additional identical repetitions need to distinguish. No production behavior changed. |
|
Merged via squash.
|
Merge main with the canonical WhatsApp shutdown fixture fix in #159115. The same-upsert messages can cross separate debounce windows during asynchronous admission; delivery and close ordering remain correct. Register queued recap work synchronously with the publication owner so a drain cannot finish before deferred row preparation starts.
…59115) Control both same-window and split-window admission schedules instead of assuming every upsert batch coalesces within 20 ms. Keep exact delivery, read-receipt, durable-claim, and socket-close assertions and release held work even when an assertion fails. The original expectation fails deterministically when the third append crosses the debounce window. Production behavior is unchanged. Related: openclaw#151608
Related: #151608
What Problem This Solves
Fixes a scheduler-dependent WhatsApp shutdown test failure that blocked the database campaign's CI in run 36263315182. This is a focused maintainer-requested unblocker.
User Impact
No runtime behavior changes. Shutdown coverage now verifies every received message and read receipt completes before the socket closes, whether asynchronous admission places two messages in one debounce window or separate windows.
Why This Change Was Made
The old test expected two messages from one upsert to coalesce within a real 20 ms window. Their durable admissions are asynchronous and sequential, so that is not guaranteed. It asserted the second callback's body before waiting for shutdown or the third message, and a failed assertion left the first handler held.
Use a controlled clock and existing queue/admission hooks to exercise both exact schedules. Keep close pending on the first handler, check the expected ordered message bodies, and verify all three read receipts, empty pending/claimed queues, and read-before-socket-close ordering. Always release the held work in cleanup.
Evidence
secondat callback two, while the same-window case givessecond\nthird. The original expectation fails only for the split-window schedule.node scripts/check-changed.mjs -- extensions/whatsapp/src/monitor-inbox.delivery-and-dedupe.test.tspassed, including strict extension-test types, formatting, policy guards, dead-export scans, and lint;git diff --checkpassed.