Repository navigation
fix(channels): retain ingress claims through settlement - #158637
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 26, 2026, 7:37 AM ET / 11:37 UTC (Revision 10). ClawSweeper reviewWhat this changesThe branch makes channel ingress monitors retain claims while completion, release, or failure writes settle, and adds lifecycle tests and documentation. Merge readiness⛔ Blocked before merge - 6 items remain Keep open. Current main lacks this settlement-custody change, and both blockers from the prior review remain on the reviewed head. The reported existing-claim upgrade proof is also outstanding. Priority: P2 Review scores
Verification
How this fits togetherChannel ingress monitors take accepted events from a durable queue, claim them, and hand them to channel delivery. Settlement writes determine when a claim can be released or recovered by another drain. flowchart LR
A[Channel event] --> B[Durable queue]
B --> C[Ingress monitor]
D[Channel stop] --> C
C --> E[Claim and delivery]
E --> F[Settlement write]
F --> G{Write finished?}
G -- Yes --> H[Release ownership]
G -- Pending --> C
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +68, Tests +290, Docs +5. Total +363 across 9 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Give a stalled settlement a bounded stop outcome that fences any late write before claim recovery, expose joined disposal only for retained drains, and verify an existing claim across update. Do we have a high-confidence way to reproduce the issue? Yes. Current main retires the drain before joining settlement, and the PR reports a failing baseline peer-recovery control. The introduced never-settling-write path is clear from source, but I did not execute it locally. Is this the best way to solve the issue? No. Retaining custody through a completed write addresses the reported race, but stop also needs a safe outcome for a write that never finishes, and the SDK type must reflect the selected mode. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against a53efa5e7251. LabelsLabel changes: No label changes. Label justifications:
EvidenceAcceptance criteria:
What 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 (9 earlier review cycles; latest 8 shown)
|
50deda4 to
94c54f0
Compare
c5cfec6 to
e363f2f
Compare
|
Merged via squash.
|
## What Problem This Solves Telegram webhook tests observe handler entry before durable queue settlement and remove database fixtures before asynchronous cleanup finishes. ## User Impact No user-visible behavior changes. This test preparation needs no migration, configuration change, or operator action. Existing Gateway webhook paths, signatures, acknowledgements, and replay behavior are preserved. ## Why This Change Was Made Await the actual ingress monitor's idle/settlement boundaries, reuse shared temporary-state cleanup, and join the SQLite worker cleanup. Keep the Gateway-owned webhook fixture and HTTP lifecycle introduced by the HTTP ingress stack. Production +0/-0/net 0; tests +76/-49/net +27; docs +0/-0/net 0. No test cases were removed. Across all six fixture preparations, consolidation reduces test growth from +546 to +415 (+517 to +386 when including the earlier Telegram cleanup). ## Evidence Provider: blacksmith-testbox; lease `tbx_01m3f53n667mcj031n55vm5tj8` ([run](https://github.com/openclaw/openclaw/actions/runs/36251856365)). After frozen install, `pnpm test extensions/telegram/src/webhook.test.ts --maxWorkers=1` passed 110 tests in 14.60s; `pnpm test extensions/telegram/src/telegram-ingress-drain.test.ts --maxWorkers=1` passed 32 tests in 10.01s. The command retained remote logs and exit receipts and exited 0. An earlier streaming command ended 255 after worker compilation without a test completion receipt; no active test process or kernel OOM message was observed. The cause remains unproven, and that attempt is not counted as a pass. Deslop and independent Codex P0–P2 review are clean; the review included the unchanged Gateway fixture. The rebase onto `be46e6966c2b52c6cde06abf965c44f9a175a47f` is patch-identical. Maintainer-authorized exact-head auto-merge remains subject to required hosted CI. Signed-SMS SIGKILL/replay proof follows the final atomic broker cutover on merged main. Legacy Telegram spool import and startup profiling remain documented follow-ups. ## Stack Landed: #157687 → #158203 → #158233 → #158288 → #158412 → #158477 → #158628 → #158637 → #158860 → #158887 → #158896 → #158928 → #158933 → #158980 → #158987. Slice 16 is polling fixtures; this is slice 17 (webhook fixtures); slice 18 completes the broker cutover and worker-access inventory.
## What Problem This Solves Telegram polling tests replace process clocks and timers that the SQLite workers also need, so they cannot reliably exercise worker-backed ingress. ## User Impact No user-visible change. This is preparation for routing the existing ingress queue through the shared-state broker. Updates require no migration, configuration change, or operator action; transport, acknowledgement, dedupe, and recovery semantics stay unchanged. ## Why This Change Was Made Scope the watchdog clock to Telegram liveness, reuse the runtime worker launcher arguments in direct worker fixtures, await committed completions, and join database cleanup. The test-only `test-env` export is excluded from the published package; no production SDK contract changes. Production +1/-0/net +1 (test-only SDK export); tests/support +168/-133/net +35; docs +4/-0/net +4. Across the six fixture preparations, consolidation reduces the original +546 test lines to +415; including the earlier Telegram cleanup, +517 becomes +386. Behavioral cases remain covered. ## Evidence Provider: blacksmith-testbox. On lease `tbx_01m3ezq966mgn19mz1ds1ym28x` ([run](https://github.com/openclaw/openclaw/actions/runs/36246522577)), `pnpm test extensions/telegram/src/polling-session.test.ts --maxWorkers=1` passed 40 tests in 67.31s; worker/runtime/deadline siblings passed 16 tests in 7.43s. On lease `tbx_01m3f53n667mcj031n55vm5tj8` ([run](https://github.com/openclaw/openclaw/actions/runs/36251856365)), frozen install, `pnpm tsgo:extensions:test` (85.25s), `pnpm plugin-sdk:api:diff --base 84d71bf --head HEAD` (255.30s), `pnpm plugin-sdk:check-exports` (0.16s), and `pnpm check:docs` (49.62s) passed. SDK diff has no entrypoint or exported-signature change; reachable inferred declarations differ in optional-undefined readonly/property ordering. An earlier SSH command ended 255 without a completion receipt; its type phase is not counted as passing. The fresh run retained per-command logs and exit receipts. Deslop and Codex P0–P2 review are clean. Rebase onto `be46e6966c2b52c6cde06abf965c44f9a175a47f` is patch-identical. Required hosted CI gates exact-head auto-merge, authorized by the maintainer. The final signed-SMS SIGKILL/replay proof runs after the atomic broker cutover lands. Legacy Telegram spool import and startup profiling remain documented follow-ups. ## Stack Landed: #157687 → #158203 → #158233 → #158288 → #158412 → #158477 → #158628 → #158637 → #158860 → #158887 → #158896 → #158928 → #158933 → #158980 → #158987. This is slice 16 (polling fixtures); slice 17 (webhook fixtures) and slice 18 (atomic broker cutover and inventory) follow.
…9073) ## What Problem This Solves The shared channel ingress queue still performs operational reads and writes synchronously on the Gateway thread, despite exposing an asynchronous API. ## User Impact Inbound persistence and replay use the existing shared-state SQLite broker. Admission returns only after commit; claim fencing, per-account ordering, dedupe, retention, and accepted-write settlement remain intact. Operational listings observe earlier committed writes and still create a missing database for ordinary read-write queues. Explicit read-only inspection remains noncreating. Update behavior: no schema, stored-byte, config, port, webhook path, signature, dedupe-window, or retention change; no migration or operator action. The maintainer approved the worker-access change and the broker-ordered listing adjustment. Legacy pre-May-31 Telegram spool import and Telegram startup profiling remain documented follow-ups, as directed. ## Why This Change Was Made All twelve mutations and the operational listings cut over together to preserve one FIFO owner. Diagnostic failed-health, pressure, and account discovery already use read-only workers. Channel parsing and lane policy stay on the host; the worker verifies the prepared ordered snapshot before applying a claim or recovery decision. Custom claim clocks are sampled at transaction admission. Accepted commits settle even if caller authority later revokes. The drain consumes one coherent pending/claimed snapshot. `listUnsettled` is optional for existing external queue implementations through the next SDK major. `purge` accepts an optional cancellation signal, and Telegram passes its existing signal. Runtime construction binds live plugin authority to every operation, replacing the purge-only wrapper. The existing table and database version are unchanged. Deletes the main-thread queue SQL path and superseded runtime wrapper. The final write cutover is intentionally larger than the fixture slices because mixing native and broker mutations would break admission ordering. Earlier slices removed Telegram directory helpers and consolidated shared fixture scaffolding. Production +964/-942/net +22; tests and test support +837/-315/net +522; docs +41/-18/net +23; tooling +3/-0/net +3. The runtime growth preserves authority and settlement across a worker boundary. All earlier slices plus this candidate total production net +446; test fixture consolidation reduced the original +517 growth to +386 before the final routing/regression coverage. ## Evidence Provider: blacksmith-testbox. Lease `tbx_01m3f53n667mcj031n55vm5tj8` ([run](https://github.com/openclaw/openclaw/actions/runs/36251856365)), frozen install, `pnpm tsgo:core` (41.13s), `pnpm tsgo:extensions:test` (78.55s), and inventory generation/check passed. Nine focused owner files passed 144 tests. Single-worker wall cost per file: queue 33.02s; claim ownership 9.28s; readonly access 8.07s; pruning 7.20s; drain lanes 8.50s; monitor 9.44s; plugin-state runtime 14.12s; registry runtime-config 11.08s; Telegram monitor 15.15s. The two changed tooling files passed 381 tests in a combined 192.99s single-worker wall. The additional 72-file per-config run used `pnpm test <explicit routed ingress paths> --maxWorkers=1`: 128 core tests and 855 extension tests passed, with two fixture failures over 518.11s. LINE and MS Teams waited for a `listPending` spy that the coherent snapshot intentionally replaces. Both fixtures now capture the real monitor and await its pump, preserving the eight-delivery cap and queued-row assertions. Lease `tbx_01m3faw6necd61h11wcf6se4hs` ([run](https://github.com/openclaw/openclaw/actions/runs/36257798905)) proved the corrections: `pnpm test extensions/line/src/webhook-spool.test.ts --maxWorkers=1` passed 14 tests in 31.09s; `pnpm test extensions/msteams/src/msteams-ingress.test.ts --maxWorkers=1` passed 15 in 18.32s. Extension types (79.74s), runtime import cycles (9.38s; zero), Madge cycles (26.36s; zero), SDK exports (0.22s), and docs sanity (54.79s) passed. The existing pruning case with padded protected IDs passed (five tests, 8.46s). Negative controls failed for the intended reasons: removing normalization deleted a protected row; raising either channel's cap to nine caused nine deliveries where eight were required. The production controls were restored and checked. Worker routing is covered by actual queue operations with calling-thread SQLite primitives refusing execution. Regression probes also cover missing database creation, committed-then-list inside an older ambient snapshot, live authority after awaited policy, custom-clock transaction grants, post-grant settlement, and coherent lane inspection. No weaker guards or assertions were substituted. Deslop is clean. Codex P0–P2 review is clean after supplying the full unchanged worker kernel: two earlier allegations were disproven by existing normalization and corrupt-row filtering, with direct tests. The final review used a byte-verified capture of the full 35-file diff and the broker/kernel context. Rebase onto `4ab72dd0d2c2cc335569da0603f7778f276a1717` was patch-identical. The maintainer authorized GitHub exact-head auto-merge; required CI remains the gate. Fresh proof on published source head `b828403ef8f309ffda1e4859f6eca3268fdc66cb` (same lease): queue/claim/readonly regression suites passed 47 tests in 38.51s; regenerated inventory and its check passed (545 source files, 2543 primitive calls). `pnpm plugin-sdk:api:diff --base 4ab72dd --head b828403` passed in 242.79s; exports passed in 0.17s. The SDK acknowledgement digest is `e2cba13f`. No entrypoints were added or removed; the additive queue contract is intentional and documented. Final head `0b24c42b9242b07e1a7c60147b4cba5f46d5bd91` only refreshes two generated source-line references. Merged-main signed-SMS SIGKILL/replay proof is the remaining post-merge task and will be recorded in this PR. ## Stack Landed: #157687 → #158203 → #158233 → #158288 → #158412 → #158477 → #158628 → #158637 → #158860 → #158887 → #158896 → #158928 → #158933 → #158980 → #158987 → #159006 → #159008. This is the final atomic broker cutover and inventory slice. Signed-SMS crash/replay proof follows on merged main.
…9008) ## What Problem This Solves Telegram webhook tests observe handler entry before durable queue settlement and remove database fixtures before asynchronous cleanup finishes. ## User Impact No user-visible behavior changes. This test preparation needs no migration, configuration change, or operator action. Existing Gateway webhook paths, signatures, acknowledgements, and replay behavior are preserved. ## Why This Change Was Made Await the actual ingress monitor's idle/settlement boundaries, reuse shared temporary-state cleanup, and join the SQLite worker cleanup. Keep the Gateway-owned webhook fixture and HTTP lifecycle introduced by the HTTP ingress stack. Production +0/-0/net 0; tests +76/-49/net +27; docs +0/-0/net 0. No test cases were removed. Across all six fixture preparations, consolidation reduces test growth from +546 to +415 (+517 to +386 when including the earlier Telegram cleanup). ## Evidence Provider: blacksmith-testbox; lease `tbx_01m3f53n667mcj031n55vm5tj8` ([run](https://github.com/openclaw/openclaw/actions/runs/36251856365)). After frozen install, `pnpm test extensions/telegram/src/webhook.test.ts --maxWorkers=1` passed 110 tests in 14.60s; `pnpm test extensions/telegram/src/telegram-ingress-drain.test.ts --maxWorkers=1` passed 32 tests in 10.01s. The command retained remote logs and exit receipts and exited 0. An earlier streaming command ended 255 after worker compilation without a test completion receipt; no active test process or kernel OOM message was observed. The cause remains unproven, and that attempt is not counted as a pass. Deslop and independent Codex P0–P2 review are clean; the review included the unchanged Gateway fixture. The rebase onto `2c67755c29899c9deba29d3baaa902ec5d0d6efd` is patch-identical. Maintainer-authorized exact-head auto-merge remains subject to required hosted CI. Signed-SMS SIGKILL/replay proof follows the final atomic broker cutover on merged main. Legacy Telegram spool import and startup profiling remain documented follow-ups. ## Stack Landed: openclaw#157687 → openclaw#158203 → openclaw#158233 → openclaw#158288 → openclaw#158412 → openclaw#158477 → openclaw#158628 → openclaw#158637 → openclaw#158860 → openclaw#158887 → openclaw#158896 → openclaw#158928 → openclaw#158933 → openclaw#158980 → openclaw#158987. Slice 16 is polling fixtures; this is slice 17 (webhook fixtures); slice 18 completes the broker cutover and worker-access inventory.
## What Problem This Solves Telegram polling tests replace process clocks and timers that the SQLite workers also need, so they cannot reliably exercise worker-backed ingress. ## User Impact No user-visible change. This is preparation for routing the existing ingress queue through the shared-state broker. Updates require no migration, configuration change, or operator action; transport, acknowledgement, dedupe, and recovery semantics stay unchanged. ## Why This Change Was Made Scope the watchdog clock to Telegram liveness, reuse the runtime worker launcher arguments in direct worker fixtures, await committed completions, and join database cleanup. The test-only `test-env` export is excluded from the published package; no production SDK contract changes. Production +1/-0/net +1 (test-only SDK export); tests/support +168/-133/net +35; docs +4/-0/net +4. Across the six fixture preparations, consolidation reduces the original +546 test lines to +415; including the earlier Telegram cleanup, +517 becomes +386. Behavioral cases remain covered. ## Evidence Provider: blacksmith-testbox. On lease `tbx_01m3ezq966mgn19mz1ds1ym28x` ([run](https://github.com/openclaw/openclaw/actions/runs/36246522577)), `pnpm test extensions/telegram/src/polling-session.test.ts --maxWorkers=1` passed 40 tests in 67.31s; worker/runtime/deadline siblings passed 16 tests in 7.43s. On lease `tbx_01m3f53n667mcj031n55vm5tj8` ([run](https://github.com/openclaw/openclaw/actions/runs/36251856365)), frozen install, `pnpm tsgo:extensions:test` (85.25s), `pnpm plugin-sdk:api:diff --base 8816746 --head HEAD` (255.30s), `pnpm plugin-sdk:check-exports` (0.16s), and `pnpm check:docs` (49.62s) passed. SDK diff has no entrypoint or exported-signature change; reachable inferred declarations differ in optional-undefined readonly/property ordering. An earlier SSH command ended 255 without a completion receipt; its type phase is not counted as passing. The fresh run retained per-command logs and exit receipts. Deslop and Codex P0–P2 review are clean. Rebase onto `2c67755c29899c9deba29d3baaa902ec5d0d6efd` is patch-identical. Required hosted CI gates exact-head auto-merge, authorized by the maintainer. The final signed-SMS SIGKILL/replay proof runs after the atomic broker cutover lands. Legacy Telegram spool import and startup profiling remain documented follow-ups. ## Stack Landed: openclaw#157687 → openclaw#158203 → openclaw#158233 → openclaw#158288 → openclaw#158412 → openclaw#158477 → openclaw#158628 → openclaw#158637 → openclaw#158860 → openclaw#158887 → openclaw#158896 → openclaw#158928 → openclaw#158933 → openclaw#158980 → openclaw#158987. This is slice 16 (polling fixtures); slice 17 (webhook fixtures) and slice 18 (atomic broker cutover and inventory) follow.
…nclaw#159073) ## What Problem This Solves The shared channel ingress queue still performs operational reads and writes synchronously on the Gateway thread, despite exposing an asynchronous API. ## User Impact Inbound persistence and replay use the existing shared-state SQLite broker. Admission returns only after commit; claim fencing, per-account ordering, dedupe, retention, and accepted-write settlement remain intact. Operational listings observe earlier committed writes and still create a missing database for ordinary read-write queues. Explicit read-only inspection remains noncreating. Update behavior: no schema, stored-byte, config, port, webhook path, signature, dedupe-window, or retention change; no migration or operator action. The maintainer approved the worker-access change and the broker-ordered listing adjustment. Legacy pre-May-31 Telegram spool import and Telegram startup profiling remain documented follow-ups, as directed. ## Why This Change Was Made All twelve mutations and the operational listings cut over together to preserve one FIFO owner. Diagnostic failed-health, pressure, and account discovery already use read-only workers. Channel parsing and lane policy stay on the host; the worker verifies the prepared ordered snapshot before applying a claim or recovery decision. Custom claim clocks are sampled at transaction admission. Accepted commits settle even if caller authority later revokes. The drain consumes one coherent pending/claimed snapshot. `listUnsettled` is optional for existing external queue implementations through the next SDK major. `purge` accepts an optional cancellation signal, and Telegram passes its existing signal. Runtime construction binds live plugin authority to every operation, replacing the purge-only wrapper. The existing table and database version are unchanged. Deletes the main-thread queue SQL path and superseded runtime wrapper. The final write cutover is intentionally larger than the fixture slices because mixing native and broker mutations would break admission ordering. Earlier slices removed Telegram directory helpers and consolidated shared fixture scaffolding. Production +964/-942/net +22; tests and test support +837/-315/net +522; docs +41/-18/net +23; tooling +3/-0/net +3. The runtime growth preserves authority and settlement across a worker boundary. All earlier slices plus this candidate total production net +446; test fixture consolidation reduced the original +517 growth to +386 before the final routing/regression coverage. ## Evidence Provider: blacksmith-testbox. Lease `tbx_01m3f53n667mcj031n55vm5tj8` ([run](https://github.com/openclaw/openclaw/actions/runs/36251856365)), frozen install, `pnpm tsgo:core` (41.13s), `pnpm tsgo:extensions:test` (78.55s), and inventory generation/check passed. Nine focused owner files passed 144 tests. Single-worker wall cost per file: queue 33.02s; claim ownership 9.28s; readonly access 8.07s; pruning 7.20s; drain lanes 8.50s; monitor 9.44s; plugin-state runtime 14.12s; registry runtime-config 11.08s; Telegram monitor 15.15s. The two changed tooling files passed 381 tests in a combined 192.99s single-worker wall. The additional 72-file per-config run used `pnpm test <explicit routed ingress paths> --maxWorkers=1`: 128 core tests and 855 extension tests passed, with two fixture failures over 518.11s. LINE and MS Teams waited for a `listPending` spy that the coherent snapshot intentionally replaces. Both fixtures now capture the real monitor and await its pump, preserving the eight-delivery cap and queued-row assertions. Lease `tbx_01m3faw6necd61h11wcf6se4hs` ([run](https://github.com/openclaw/openclaw/actions/runs/36257798905)) proved the corrections: `pnpm test extensions/line/src/webhook-spool.test.ts --maxWorkers=1` passed 14 tests in 31.09s; `pnpm test extensions/msteams/src/msteams-ingress.test.ts --maxWorkers=1` passed 15 in 18.32s. Extension types (79.74s), runtime import cycles (9.38s; zero), Madge cycles (26.36s; zero), SDK exports (0.22s), and docs sanity (54.79s) passed. The existing pruning case with padded protected IDs passed (five tests, 8.46s). Negative controls failed for the intended reasons: removing normalization deleted a protected row; raising either channel's cap to nine caused nine deliveries where eight were required. The production controls were restored and checked. Worker routing is covered by actual queue operations with calling-thread SQLite primitives refusing execution. Regression probes also cover missing database creation, committed-then-list inside an older ambient snapshot, live authority after awaited policy, custom-clock transaction grants, post-grant settlement, and coherent lane inspection. No weaker guards or assertions were substituted. Deslop is clean. Codex P0–P2 review is clean after supplying the full unchanged worker kernel: two earlier allegations were disproven by existing normalization and corrupt-row filtering, with direct tests. The final review used a byte-verified capture of the full 35-file diff and the broker/kernel context. Rebase onto `94580ed1416cbe69b173b6ca85a1b1ab2001d55a` was patch-identical. The maintainer authorized GitHub exact-head auto-merge; required CI remains the gate. Fresh proof on published source head `b828403ef8f309ffda1e4859f6eca3268fdc66cb` (same lease): queue/claim/readonly regression suites passed 47 tests in 38.51s; regenerated inventory and its check passed (545 source files, 2543 primitive calls). `pnpm plugin-sdk:api:diff --base 94580ed --head b828403` passed in 242.79s; exports passed in 0.17s. The SDK acknowledgement digest is `e2cba13f`. No entrypoints were added or removed; the additive queue contract is intentional and documented. Final head `0b24c42b9242b07e1a7c60147b4cba5f46d5bd91` only refreshes two generated source-line references. Merged-main signed-SMS SIGKILL/replay proof is the remaining post-merge task and will be recorded in this PR. ## Stack Landed: openclaw#157687 → openclaw#158203 → openclaw#158233 → openclaw#158288 → openclaw#158412 → openclaw#158477 → openclaw#158628 → openclaw#158637 → openclaw#158860 → openclaw#158887 → openclaw#158896 → openclaw#158928 → openclaw#158933 → openclaw#158980 → openclaw#158987 → openclaw#159006 → openclaw#159008. This is the final atomic broker cutover and inventory slice. Signed-SMS crash/replay proof follows on merged main.
Carries openclaw#132409 ("fix(channels): preserve messages stalled before adoption", open; issue openclaw#127229, P1 message loss) onto the 9.6 carry. Applied as diff(9a4114b..217ef6a), the PR's own base to its Sept 10 head, by 3-way merge onto 1d5d6c8. Why that head and not the Sept 27 merge head cc8f0d0: the 9.6 tag's ingress files equal main of 2026-09-22 (814a7e7). cc8f0d0 merges main of 09-27 and integrates the PR with openclaw#158637's claim custody through settlement, which the tag does not have; applied here it conflicts in 4 production files. 217ef6a predates openclaw#158637, applies with one import conflict, and has a green hosted CI run (34543782080). The 09-27 head adds an abort-aware quiescence wait and idle-wake accessors that only openclaw#158637's retained owner and main's reworked monitor use. On this tree the owner is deregistered at abort, so a replacement drain recovers the claim at once; settleStalledClaim checks isStopped() only between attempts, so an attempt already waiting for quiescence still makes its one release write after stop, and the claim token fences that write. What it fixes on the bots: a second update from the same chat waits in grammY sequentialize behind a deferred handler with no heartbeat. At the 300 s adoption watchdog the drain released it for retry while the first callback was still blocked; the retry met the in-process update tracker as a duplicate, returned no outcome, and the row was completed without a recorded processing outcome (rh-bot, updates 735980139 and 735980143, 2026-09-29). Now the stalled claim keeps its lease and heartbeat until the old dispatch and deferred bookkeeping quiesce, then settles the retry; a separate stall-settlement wake repumps the monitor; Telegram's tracker records an owner-aborted deferred update as incomplete. Conflict resolution: - ingress-monitor.ts: import-only; the fork's split imports kept, the wake scheduler import added. - ingress-drain.watchdog.test.ts: main's two tests added after 09-08 kept; in the PR's rewritten "rearms a live deferred wait" test the tag's 1_666 ms heartbeat-cadence assertion is kept (cc8f0d0 dropped it). - polling-session.test.ts: the PR's hunk for "requeues buffered spooled claims when deferred processing times out" is not applied. At the tag the deferred participant settles itself on owner abort (openclaw#150080), so the claim is released at the stall without a manual settle; main later deleted the test (openclaw#155040). ingress-drain.ts equals 217ef6a plus exactly the tag's own 09-08..09-22 drift; drain-state, drain-wake, drain.test, zalouser and mattermost tests are byte-identical to 217ef6a. Original implementation by PollyBot13, with the maintainer fixup in 217ef6a; see openclaw#132409. Drop this commit when an upstream equivalent reaches the fork's base tag.
What Problem This Solves
An ingress monitor can retire claim ownership during shutdown while an accepted completion, release or failure write is still pending, allowing a replacement drain to race that settlement.
User Impact
Shutdown joins already-started settlement writes before releasing claim ownership. If a write fails while the drain still owns the claim, shutdown reports the error and retains custody. Callback grace remains bounded, and standalone drains retain their existing abort/recovery behavior.
Existing databases, config, payloads, dedupe, retention and recovery policy stay unchanged. Updates require no migration or operator action. The maintainer approved the storage execution and settlement work in this stack.
Why This Change Was Made
Register settlement before calling the write, retain the monitor-owned drain through settlement, and remove finished deliveries before failure handling awaits a write. Reuse the existing drain and monitor lifecycle; add no competing queue or shutdown owner. Deferred handoffs remain tracked even when adoption begins before delivery returns.
The exported drain function gains a backward-compatible optional retention argument and a joined-disposal overload. All existing calls retain their previous default. Monitors use the new path immediately. No schema or config changes are introduced.
This lifecycle change stays together because retirement, settlement tracking and joined disposal enforce one custody contract. The larger diff includes formatter-required indentation around the existing monitor options and shared fixture extraction; it does not add a second implementation.
Evidence
Provider blacksmith-testbox. On lease
tbx_01m3dm1w1m9666jbqnv23f7wy2, run 36207351729, the old monitor fails the peer-recovery negative control in 26.32s: a peer starts while the first owner's settlement remains pending.Changed test costs with
pnpm test <file> --maxWorkers=1:ingress-drain.ownership.test.ts24.67s,ingress-monitor.shutdown.test.ts7.78s,ingress-drain.test.ts10.26s,ingress-monitor.test.ts9.82s (36 tests). New shutdown tests use controlled promises and fake clocks. The old stop-before-settlement assertion is replaced by commit-before-stop and peer-fencing proof; callback-grace coverage remains. Docs lint passed in 10.95s.On lease
tbx_01m3dttmd432sdrxr0qyf12er2, run 36213749329, the exact reviewed tree was reconstructed and the real commit hook passed unchanged. SDK export check passes. API diff passes in 346.38s, digesta950e2b3: no entrypoints or exports added/removed; the two drain exports reflect the compatible signature addition, plus 126 reachable declaration hashes. Deslop is clean; two Codex P0–P2 reviews are clean, including the final test replacement. Enforcedopenclaw/ci-gatereplaces separate Testboxcheck-changed. Final signed-SMS SIGKILL/replay proof runs after the last slice on merged main.After rebasing onto the preceding kernel slice, the source range-diff is identical. The four owner test files pass together in 25.39s on lease
tbx_01m3dttmd432sdrxr0qyf12er2; doc formatting passes.Refreshed Proof and Resolved CI
The maintainer approved the operational-listing adjustment: listings that feed queue decisions will use the shared write broker FIFO. Health and account diagnostics retain the read-only worker. This settlement-custody slice remains patch-identical after rebasing onto the refreshed preceding slice; the discovered listing regressions belong to the final cutover.
At head
94c54f0f42767616f1b44aaf794ce4412a453ef6, blacksmith-testbox leasetbx_01m3e808a30trnen7savfd7qj3, run 36225250659, verified source hashes and frozen dependencies, then ran:pnpm test src/channels/message/ingress-drain.ownership.test.ts src/channels/message/ingress-monitor.shutdown.test.ts src/channels/message/ingress-drain.test.ts src/channels/message/ingress-monitor.test.ts --maxWorkers=1: 76 tests passed / 28.83s. Per-file costs from the identical reviewed patch remain above.pnpm plugin-sdk:api:diff --base d8e13e140666fc649acd5da6df1ae1d3efea9343 --head HEAD: passed in 300.29s, digest3e07ab50, no entrypoints or exports added/removed. The compatible retention argument and joined-disposal overload remain the named API changes.pnpm plugin-sdk:check-exportsandgit diff --check: passed.Fresh Codex P0–P2 review is clean; deslop found no changes needed. Main includes the UI import repair
da8149b8ba7d88d76dbe7979986e307a4542e6f0. Its formerly failing type stripe passes all five graphs on the preceding rebased slice in 132.17s. The workspace quota-scan repaira9760fd99f9700efc4f228a02d7680eb25c4b569is also included and its boundary test passes in 12.29s. No files in either unrelated owner were changed here.This PR has no prior native merge submission. Final signed-SMS SIGKILL/replay proof remains scheduled against merged main after the final slice; legacy Telegram import and startup profiling remain documented follow-ups.
CI Interaction Repaired
The refreshed candidate exposed a monitor idle race in the existing Slack malformed-row replay test. After a claim settled, its handler could leave active state while an existing drain wake still owned the next pump.
waitForIdle()could return in that interval. It now joins that wake and requires no replacement wake before reporting idle; channel assertions and timers are unchanged.On the same Testbox lease, the original CI Slack group reproduced 1 failure / 3,136 tests in 142.88s; the focused file reproduced it in 26.09s. Clean main
67adcce7e3043601354eacea4444d3361ee729c4passed all three focused cases in 27.74s. With the owner fix, the focused file passes in 22.77s, all 76 core owner tests pass in 12.53s, and the original 174-file / 3,136-test group passes in 125.60s. The comparison uses the original two-worker CI configuration and ordering. No failure was hidden by a retry or weaker assertion.The full review found the working-tree fix sound; its sole remaining finding was the unstaged index still holding the old code. The fix is staged and its final Codex correction review is clean. The native remote commit hook passed against the exact tested tree; the fix is published at
c5cfec6b77ca86bbd707a9f061444d58a540a59f. The SDK signatures are unchanged by this implementation-only correction.Stack
443a0676b929c3843956295190c53178b80e7419.Production +330/−225 (net +105); tests +356/−103 (net +253); docs +5/−0 (net +5). The prescribed production filter includes the existing test-harness file. No meaningful coverage is removed to reduce this number.
Stack closeout: all 18 slices are merged.
#157687 → #158203 → #158233 → #158288 → #158412 → #158477 → #158628 → #158637 → #158860 → #158887 → #158896 → #158928 → #158933 → #158980 → #158987 → #159006 → #159008 → #159073
Final merged-main signed-SMS SIGKILL/replay proof passed on
f0b78f55d6d5acfb052a4512d97088b408a0c28d.Current Head Proof
After the kernel slice merged, this PR was rebased onto
eaf8d916f7f; both commits are patch-identical by range-diff. Published head ise363f2f9f25bbebc44cf88423eb95b25b806f1be. No source change was made to hide the unexplained AppSDK failure below.On blacksmith-testbox lease
tbx_01m3ekzp2je1jm0fnkypbj18sg, run 36235757385, an isolated checkout verified that exact head and installed frozen dependencies:pnpm test src/channels/message/ingress-drain.ownership.test.ts src/channels/message/ingress-monitor.shutdown.test.ts src/channels/message/ingress-drain.test.ts src/channels/message/ingress-monitor.test.ts --maxWorkers=1: 76 passed / 24.96s.pnpm test extensions/slack/src/monitor/ingress.relay.test.ts --maxWorkers=1: 3 passed / 13.52s.pnpm plugin-sdk:api:diff --base eaf8d916f7f --head HEAD: passed in 259.06s, digest38182645; the same two compatible drain signatures and six reachable declarations changed. SDK exports andgit diff --checkpass.The prior per-file test costs remain applicable to the identical patch. Deslop needs no edits; the existing clean Codex reviews cover both unchanged commits. CI run
36238279284is attached to this exact head. The earlier failure remains recorded below; a recurrence requires further owner investigation.Current CI Investigation
Exact-head CI run
36230059592atc5cfec6b77ca86bbd707a9f061444d58a540a59fstopped after the AppSDK composed-resources test reportedAgentDatabaseRegistryChangedError. The relevant registry, artifact-read, and fixture sources are unchanged by this PR. That alone does not establish that the failure is unrelated.On blacksmith-testbox lease
tbx_01m3eet19r9pn73v0a6c1twhcp, run 36231222685, the original ordered 42-file infra, 59-file Gateway, and 27-file state groups were replayed throughnode --import tsx scripts/ci-run-node-test-shard.mtswith the original plan and two-worker policy. Clean main0042f8a570d48f01e7f4f667e3e4833caa68d80apassed in 407.99s; the exact failed candidate passed in 387.41s. These passing replays are reproduction results, not a claimed fix.A temporary observation-only registry trace on clean main captured one recoverable discovery invalidation during
artifacts.list: registration admission for the custom AppSDK session store replaced the same-path registry generation. That 27-file group still passed all 96 tests / 149.89s. The trace was removed after the run. The original hosted failure remains unexplained; no registry guard, assertion, retry, or timeout was weakened, and hosted CI has not been rerun merely to obtain green.