Skip to content

fix(slack): dispatch independently routed threads concurrently - #114552

Merged
steipete merged 7 commits into
mainfrom
codex/fix-slack-thread-ingress-lanes
Aug 26, 2026
Merged

steipete merged 7 commits into
mainfrom
codex/fix-slack-thread-ingress-lanes

Conversation

@steipete

@steipete steipete commented Jul 27, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Independent Slack threads were serialized behind one channel lane, while splitting lanes before routing could corrupt shared sessions and break persisted event replay.

Repair

Keep shipped durable channel lanes intact and release them only after authoritative session routing. Serialize by resolved session ownership while allowing independently owned thread turns to overlap.

Verification

121 owner and sibling tests passed, including real SQLite/Bolt ingress, shared-session serialization, persisted replay, and channel-ID migration. Independent review passed. Authenticated Slack Desktop proof is being requested separately.

@openclaw-barnacle openclaw-barnacle Bot added channel: slack Channel integration: slack size: M maintainer Maintainer-authored PR labels Jul 27, 2026
@steipete
steipete marked this pull request as ready for review July 27, 2026 11:49
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P1 High-priority user-facing bug, regression, or broken workflow. labels Jul 27, 2026
@clawsweeper

clawsweeper Bot commented Jul 27, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge. Reviewed August 26, 2026, 1:38 AM ET / 05:38 UTC.

ClawSweeper review

What this changes

The PR defers Slack ingress scheduling until message routing resolves an OpenClaw session, allowing independently routed threads to overlap while same-session turns stay serialized.

Merge readiness

⛔ Blocked by patch quality or review findings - 7 items remain

Keep open: a routed Slack turn that throws releases its session predecessor before durable retry handling, allowing a later same-session turn to dispatch first. The prior retry-order blocker remains unresolved.

Priority: P1
Reviewed head: a611653fe9085e010d684a2c94a58c9bc4879c11

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The patch has a concrete P1 ordering regression in the retry path despite useful targeted coverage.
Proof confidence 🌊 off-meta tidepool Not applicable: The PR author is a MEMBER, so the external-contributor proof gate does not apply; the supplied visual artifacts were not used as concurrency proof because they do not show the asserted thread behavior.
Patch quality 🧂 unranked krab (1/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The PR author is a MEMBER, so the external-contributor proof gate does not apply; the supplied visual artifacts were not used as concurrency proof because they do not show the asserted thread behavior.
Evidence reviewed 6 items Retry ordering defect: After session routing, an exception calls settleTurn before rethrowing; this releases the session promise before the durable drain applies its retry disposition, so a waiting successor can pass the failed turn.
Session handoff: The message handler awaits onSessionRouted before dispatch, so the affected ordering point is after authoritative route resolution and before agent work.
Durable retry contract: The shared drain releases a failed pre-adoption claim for retry, while deferred Slack claims release their ingress lane; preserving same-session order therefore requires retry-aware session ownership, not only lane fencing.
Findings 1 actionable finding [P1] Retain retry precedence over queued same-session turns
Security None None.

Live Verification

Command: node scripts/run-vitest.mjs extensions/slack/src/monitor/ingress.test.ts

Result: FAIL (failed) — step 1 run node scripts/run-vitest.mjs extensions/slack/src/monitor/ingress.test.ts: previous terminal command was still running after 30 seconds: "node scripts/run-vitest.mjs extensions/slack/src/monitor/ingress.test.ts"

[test] starting test/vitest/vitest.extension-slack.config.ts

 RUN  v4.1.10 /tmp/clawsweeper-live-proof-114552-qHBVvb/target

stdout | extensions/slack/src/monitor/ingress.test.ts › Slack durable ingress › retries transient member failures through Bolt after restart
[INFO]  bolt-app API Call failed due to rate limiting. Will retry in 0 seconds.

stderr | extensions/slack/src/monitor/ingress.test.ts › Slack durable ingress › retries transient member failures through Bolt after restart
[WARN]  bolt-app http request failed A rate limit was exceeded (url: https://slack.test/api/users.info, retry-after: 0)

stderr | extensions/slack/src/monitor/ingress.test.ts › Slack durable ingress › retries transient member failures through Bolt after restart
[ERROR]  bolt-app UnknownError: A request error occurred: A rate limit was exceeded (url: https://slack.test/api/users.info, retry-after: 0)
    at asCodedError (/tmp/clawsweeper-live-proof-114552-qHBVvb/target/node_modules/@slack/bolt/dist/errors.js:46:12)
    at App.handleError (/tmp/clawsweeper-live-proof-114552-qHBVvb/target/node_modules/@slack/bolt/dist/App.js:674:59)
    at App.processEvent (/tmp/clawsweeper-live-proof-114552-qHBVvb/target/node_modules/@slack/bolt/dist/App.js:659:25)
    at Object.deliver (/tmp/clawsweeper-live-proof-114552-qHBVvb/target/extensions/slack/src/monitor/ingress.ts:404:11) {
  code: 'slack_bolt_unknown_error',
  original: SlackSystemEventAuthRetryError: A request error occurred: A rate limit was exceeded (url: https://slack.test/api/users.info, retry-after: 0)
      at decideSlackSystemIngress (/tmp/clawsweeper-live-proof-114552-qHBVvb/target/extensions/slack/src/monitor/auth.ts:561:13)
      at authorizeSlackSystemEventSender (/tmp/clawsweeper-live-proof-114552-qHBVvb/target/extensions/slack/src/monitor/auth.ts:680:20)
      at authorizeAndResolveSlackSystemEventContext (/tmp/clawsweeper-live-proof-114552-qHBVvb/target/extensions/slack/src/monitor/events/system-event-context.t
s:24:16)
      at handleMemberChannelEvent (/tmp/clawsweeper-live-proof-114552-qHBVvb/target/extensions/slack/src/monitor/events/members.ts:46:30)
      at /tmp/clawsweeper-live-proof-114552-qHBVvb/target/extensions/slack/src/monitor/events/members.ts:80:7
      at Array.‹anonymous› (/tmp/clawsweeper-live-proof-114552-qHBVvb/target/node_modules/@slack/bolt/dist/middleware/builtin.js:250:9)
      at Array.onlyEvents (/tmp/clawsweeper-live-proof-114552-qHBVvb/target/node_modules/@slack/bolt/dist/middleware/builtin.js:71:9)
      at async Promise.allSettled (index 0)
      at /tmp/clawsweeper-live-proof-114552-qHBVvb/target/node_modules/@slack/bolt/dist/App.js:646:48
      at App.processEvent (/tmp/clawsweeper-live-proof-114552-qHBVvb/target/node_modules/@slack/bolt/dist/App.js:624:13)
}

 ✓  extension-slack  extensions/slack/src/monitor/ingress.test.ts (19 tests) 5353ms
     ✓ acknowledges a durable event before dispatch starts  307ms
     ✓ keeps a queued same-session event alive past the adoption watchdog  350ms
     ✓ retries transient member failures through Bolt after restart  1251ms
     ✓ retries a claimed relay event until a dispatcher attaches  1377ms

 Test Files  1 passed (1)
      Tests  19 passed (19)
   Start at  05:39:30
   Duration  17.71s (transform 9.68s, setup 66ms, import 11.93s, tests 5.35s, environment 0ms)

[test] passed 1 Vitest shard in 24.06s

Assertions:

  • FAIL expect_output: Test Files

How this fits together

Slack events enter durable ingress, then the Slack message handler resolves the OpenClaw session before dispatch. The new scheduler uses that resolved session to control concurrency while retaining channel-level migration ordering.

flowchart LR
A[Slack event] --> B[Durable ingress]
B --> C[Message handler]
C --> D[Session routing]
D --> E[Session queue]
E --> F[Agent dispatch]
F --> G[Retry or adoption]
B --> H[Channel migration fence]
H --> F
Loading

Before merge

  • Retain retry precedence over queued same-session turns (P1) - If delivery throws after onSessionRouted, this catch resolves the session promise before the drain releases the failed row for retry. A same-session successor already awaiting that promise can dispatch first, and the retry then queues behind it. Preserve the failed claim's session position through retry and cover this failed-first ordering case.
  • Resolve merge risk (P1) - The branch is behind current main, so refresh the retry-order review and exact-head CI against the eventual merge result.
  • Resolve merge risk (P1) - This bug fix adds production lifecycle code (+130 net lines); without a failed-first ordering proof, retry and session-state behavior remains unsafe to merge.
  • Complete next step (P2) - The remaining P1 defect is concrete, but this maintainer-labeled PR should stay in human-owned review rather than enter an automated repair lane.
  • Improve patch quality - Preserve the failed durable claim’s session predecessor across retry.
  • Improve patch quality - Add a failure-first/same-session-successor regression that fails before the repair.
  • Improve patch quality - Refresh the review and CI on the rebased exact head.

Findings

  • [P1] Retain retry precedence over queued same-session turns — extensions/slack/src/monitor/ingress.ts:421-423
Agent review details

Security

None.

PR surface

Source +130, Tests +303. Total +433 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 2 151 21 +130
Tests 2 309 6 +303
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 460 27 +433

Review metrics

Metric Value Why it matters
Production versus test LOC production +151/-21 (net +130); tests +309/-6 (net +303) The production growth implements a new ingress lifecycle scheduler, so ordering coverage must include retry failure as well as successful dispatch.

Merge-risk options

Maintainer options:

  1. Preserve retry precedence (recommended)
    Retain or recreate the failed claim’s session predecessor across its retry and add a failure-first, same-session-successor ordering regression test before merge.

Technical review

Best possible solution:

Keep the predecessor’s session position through retry, releasing it only after terminal adoption or terminal failure, and prove a failed first turn cannot be overtaken by its same-session successor.

Do we have a high-confidence way to reproduce the issue?

Yes—source-reproducible: make a first routed turn throw after session routing, queue a same-session successor, then observe that the successor is released before the first durable row retries. This review did not execute the harness because the checkout is read-only.

Is this the best way to solve the issue?

No; the current catch releases session ownership too early. The scheduler must retain retry precedence for the same durable claim, with a focused failed-first ordering test.

Full review comments:

  • [P1] Retain retry precedence over queued same-session turns — extensions/slack/src/monitor/ingress.ts:421-423
    If delivery throws after onSessionRouted, this catch resolves the session promise before the drain releases the failed row for retry. A same-session successor already awaiting that promise can dispatch first, and the retry then queues behind it. Preserve the failed claim's session position through retry and cover this failed-first ordering case.
    Confidence: 0.98

Overall correctness: patch is incorrect
Overall confidence: 0.98

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against f61ae1193d0c.

Labels

Label justifications:

  • P1: A retryable Slack delivery failure can reorder turns that resolved to the same session.
  • merge-risk: 🚨 message-delivery: The changed durable-ingress scheduler can dispatch a later Slack event before an earlier retried event.
  • merge-risk: 🚨 session-state: The defect breaks the intended serialization guarantee for one resolved agent session.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🌊 off-meta tidepool and patch quality is 🧂 unranked krab.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: The PR author is a MEMBER, so the external-contributor proof gate does not apply; the supplied visual artifacts were not used as concurrency proof because they do not show the asserted thread behavior.

Evidence

What I checked:

  • Retry ordering defect: After session routing, an exception calls settleTurn before rethrowing; this releases the session promise before the durable drain applies its retry disposition, so a waiting successor can pass the failed turn. (extensions/slack/src/monitor/ingress.ts:422, a611653fe908)
  • Session handoff: The message handler awaits onSessionRouted before dispatch, so the affected ordering point is after authoritative route resolution and before agent work. (extensions/slack/src/monitor/message-handler.ts:346, a611653fe908)
  • Durable retry contract: The shared drain releases a failed pre-adoption claim for retry, while deferred Slack claims release their ingress lane; preserving same-session order therefore requires retry-aware session ownership, not only lane fencing. (src/channels/message/ingress-drain.ts:468, a611653fe908)
  • Coverage gap: The added tests cover independent sessions, successful same-session serialization, watchdog handling, and migration fencing, but not a failed-first turn followed by a same-session successor and retry. (extensions/slack/src/monitor/ingress.test.ts:374, a611653fe908)
  • History: Blame attributes the retry-path catch to the current PR head, and the latest commit is specifically a migration-fence follow-up rather than a retry-order repair. (extensions/slack/src/monitor/ingress.ts:422, a611653fe908)
  • Proof artifact review: The prepared screenshot shows Slack's workspace sign-in page and the GIF shows a terminal/desktop notification, not two routed Slack threads or their dispatch order; the supplied video manifest reports ffprobe unavailable.

Likely related people:

  • steipete: Current-main blame for the pre-PR ingress delivery path and the PR-head lifecycle changes both point to Peter Steinberger. (role: recent Slack ingress contributor; confidence: high; commits: 9872419b5916, a611653fe908; files: extensions/slack/src/monitor/ingress.ts, extensions/slack/src/monitor/message-handler.ts)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (13 earlier review cycles; latest 8 shown)
  • reviewed 2026-08-09T06:39:26.891Z sha 17f50d5 :: needs changes before merge. :: [P1] Keep flat room messages in their shared session lane
  • reviewed 2026-08-14T13:13:19.603Z sha 17f50d5 :: found issues before merge. :: [P1] Keep flat room messages in their shared session lane | [P1] Retain the new channel ID in migration lane selection
  • reviewed 2026-08-18T23:34:31.473Z sha 17f50d5 :: found issues before merge. :: [P1] Keep unseeded room messages on their shared lane | [P1] Preserve the channel-ID migration lane
  • reviewed 2026-08-22T18:07:53.624Z sha 17f50d5 :: found issues before merge. :: [P1] Keep unseeded room messages on their shared lane | [P1] Preserve the channel-ID migration lane
  • reviewed 2026-08-25T22:35:11.070Z sha 3e4785f :: found issues before merge. :: [P1] Finalize the claim before waiting on a session predecessor
  • reviewed 2026-08-26T02:07:02.643Z sha 1c40d8a :: needs maintainer review before merge. :: none
  • reviewed 2026-08-26T03:15:27.065Z sha 0e709ce :: found issues before merge. :: [P1] Keep a retrying turn ahead of its session successor
  • reviewed 2026-08-26T03:43:08.640Z sha f2fee98 :: found issues before merge. :: [P1] Keep a retrying turn ahead of its session successor

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Jul 29, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Aug 2, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 9, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 17, 2026
@steipete
steipete force-pushed the codex/fix-slack-thread-ingress-lanes branch from 17f50d5 to c1fe53c Compare August 25, 2026 21:26
@steipete steipete changed the title fix(slack): isolate message ingress by thread fix(slack): dispatch independently routed threads concurrently Aug 25, 2026
@openclaw-mantis

Copy link
Copy Markdown
Contributor

Mantis Slack Desktop Smoke QA

Summary: Mantis ran Slack QA inside a Crabbox Linux VNC desktop, started an OpenClaw Slack gateway in that VM, opened Slack Web in the visible browser, and captured screenshot/video evidence.

Slack desktop/VNC browser

Slack Web desktop screenshot from the Mantis VM

Slack motion preview

Animated Slack desktop preview

Motion-trimmed clips:

Full videos:

Raw QA files: https://artifacts.openclaw.ai/mantis/slack-desktop-smoke/pr-114552/run-32901615102-1/index.json

@clawsweeper clawsweeper Bot removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 26, 2026
@clawsweeper clawsweeper Bot added proof: 🎥 video Contributor real behavior proof includes video or recording evidence. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 26, 2026
@steipete
steipete force-pushed the codex/fix-slack-thread-ingress-lanes branch from 1c40d8a to 0e709ce Compare August 26, 2026 03:09
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. proof: 🎥 video Contributor real behavior proof includes video or recording evidence. labels Aug 26, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 26, 2026
@steipete
steipete force-pushed the codex/fix-slack-thread-ingress-lanes branch from f2fee98 to a611653 Compare August 26, 2026 05:31
@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready exact head a611653: Independent Slack threads serialized unnecessarily, while flawed lane release allowed channel migrations to overtake both active and deferred messages. Preserve independent thread concurrency and same-session FIFO, while holding a separate authoritative channel-lifecycle fence until durable active or deferred turns actually settle. Real Bolt events use SQLite-backed queues safely; active/deferred channel messages always finish before migration, with no stalled watchdog or overtaken session. 205 Slack and shared queue tests including actual Bolt 5 and real SQLite active/deferred migration red-to-green proof; clean full-branch P1 review, strict type/lint checks, and exact full hosted CI gate all pass.

@steipete
steipete merged commit b7b6eed into main Aug 26, 2026
93 checks passed
@steipete
steipete deleted the codex/fix-slack-thread-ingress-lanes branch August 26, 2026 05:48
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 27, 2026
…law#114552)

* fix(slack): dispatch independently routed threads concurrently

* test(slack): satisfy strict thread dispatch fixture types

* fix(slack): preserve queued session ownership through adoption

* test(slack): reuse typed ingress watchdog fixture

* fix(slack): fence channel migrations behind active turns

* test(slack): avoid returning event-loop handles from executor

* fix(slack): hold migration fences through deferred adoption
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: slack Channel integration: slack maintainer Maintainer-authored PR merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: M status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant