Skip to content

fix(slack): expose channel reaction events to thread turns - #122363

Merged
sjf-oa merged 13 commits into
mainfrom
sjf/slack-reaction-parent-events-1
Aug 12, 2026
Merged

sjf-oa merged 13 commits into
mainfrom
sjf/slack-reaction-parent-events-1

Conversation

@sjf-oa

@sjf-oa sjf-oa commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where an eligible Slack reaction event could be hidden from the next mentioned turn when that turn was routed into a Slack thread session.

Message authorship is controlled by the existing reactionNotifications policy; it is not intrinsic to this bug:

Mode Eligible message authors
own (default) Bot-authored messages only
all Any author
allowlist Any author when the reacting user is allowed

All admitted reaction events use the same channel-route queue and were affected by the route-to-thread visibility gap.

Why This Change Was Made

Preserves the base channel route as the owner of channel-scoped system events while dispatching the message to its thread session. Reply admission drains the authorized route queue before the current session queue, preserving thread isolation while exposing pending channel events.

Destructive event draining is deferred until after active-run admission. If admission returns the existing “still shutting down” response without executing a turn, both the route and dispatch queues remain intact for a later turn.

Core carries route ownership through private symbol-backed reply metadata that survives the existing option spreads. Public MsgContext, reply-option, and Plugin SDK contracts remain unchanged. The generic route/dispatch carrier is covered for both Slack and Discord.

This uses the existing route/dispatch separation shared by channel plugins and does not change configuration or defaults.

AI-assisted by Codex.

User Impact

Agents can observe queued Slack reaction-added and reaction-removed events from any message admitted by the configured reaction-notification policy on the next eligible thread-scoped turn instead of returning an empty result. Busy admission no longer consumes those events without an agent turn.

Evidence

  • Before fix: the focused route-to-thread regression failed because the thread prompt contained its own queued message event but not Slack reaction added: :eyes: from the parent route.
  • Before the admission-ordering fix: the busy-return regression failed because the parent route queue was empty after admission returned without running the agent.
  • node scripts/run-vitest.mjs src/auto-reply/reply/get-reply-run.media-only.test.ts -t 'keeps route and dispatch system events queued when busy admission returns' passed (1 test).
  • node scripts/run-vitest.mjs src/auto-reply/reply/get-reply-run.media-only.test.ts -t 'drains system events only after waiting behind an active run' passed (1 test).
  • node scripts/run-vitest.mjs src/auto-reply/reply/get-reply-run.media-only.test.ts -t 'includes route system events in a thread-scoped turn' passed (1 test).
  • node scripts/run-vitest.mjs src/channels/turn/run-channel-turn.pipeline.test.ts -t 'carries .* route system-event ownership privately into dispatch' passed (2 tests: Slack and Discord).
  • node scripts/run-vitest.mjs extensions/slack/src/monitor/message-handler/prepare.test.ts passed (151 tests).
  • Targeted core oxlint passed.
  • oxfmt --check passed on all 7 touched source and test files.
  • git diff --check passed.
  • pnpm plugin-sdk:api:check reports the same pre-existing infra-runtime.json mismatch at both this head and the untouched PR merge-base; their generated contract sets are byte-identical, so this PR adds no Plugin SDK drift.

Anonymized live reproduction

A live test workspace reproduced the bug before the patch using the default own policy; all workspace, channel, app, bot, user, message, thread, tenant, host, and run identifiers have been removed.

Step Result
A bot posted the target message The message was visible and eligible for reaction events under own mode
A tester added and then removed :eyes: Both Slack actions completed
A new eligible mention started a thread-scoped turn The turn did not receive either queued reaction event
Expected behavior The turn should receive the reaction-added event followed by the reaction-removed event

The focused regression models the shared base-route-to-thread-session transition after reaction-policy admission. It failed before the patch and passes with the patch.

@clawsweeper

clawsweeper Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@sjf-oa
sjf-oa marked this pull request as ready for review August 12, 2026 00:56
@openclaw-barnacle openclaw-barnacle Bot added channel: slack Channel integration: slack size: S maintainer Maintainer-authored PR labels Aug 12, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. 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 12, 2026
@clawsweeper

clawsweeper Bot commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: passed. Reviewed August 12, 2026, 3:08 AM ET / 07:08 UTC.

ClawSweeper review

What this changes

Carries route-scoped system events, including eligible Slack reaction notifications, into the next thread-scoped reply turn without exposing new public reply or Plugin SDK fields.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep open for maintainer review. Current main still drains only the thread session’s queue, while this PR privately carries the base route and defers destructive draining until admission succeeds; the route-first ordering has explicit approval in the PR discussion.

Priority: P1
Reviewed head: e58a28d8a6e76a33dc7112954899dbcdc570c671

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch has a coherent owner-boundary fix and focused regression coverage, with the remaining gate being maintainer review of the intentional session-event ordering.
Proof confidence 🌊 off-meta tidepool Not applicable: Repository context identifies this as a member-authored PR, so the external-contributor proof gate does not apply; the body also records a live pre-fix reproduction and focused after-fix regressions.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Repository context identifies this as a member-authored PR, so the external-contributor proof gate does not apply; the body also records a live pre-fix reproduction and focused after-fix regressions.
Evidence reviewed 5 items Reaction events are route-owned: The Slack handler authorizes the event and enqueues its notification using the ingress route session key, so a thread-only drain cannot observe it.
Current main has the visibility gap: Current main assigns the dispatch session as the route session in Slack preparation and drains only that one session during prompt construction.
Private route carrier preserves the public boundary: The branch records the route session only in symbol-backed reply options when route and dispatch sessions differ; normal context and SDK shapes stay unchanged.
Findings None None.
Security None None.

How this fits together

Slack reaction handlers enqueue authorized notifications against a channel route, while incoming threaded messages dispatch to a distinct thread session. The channel-turn pipeline bridges those identities into reply admission, which builds the agent prompt and consumes queued events.

flowchart LR
A[Slack reaction event] --> B[Channel route event queue]
C[Mentioned thread message] --> D[Channel turn assembly]
B --> D
D --> E[Reply admission decision]
E --> F[Route events then thread events]
F --> G[Agent thread response]
Loading

Before merge

  • Resolve merge risk (P1) - This intentionally changes prompt context and consumption order whenever a channel route and dispatch session differ; route-first ordering must remain the approved shared-channel policy.
  • Resolve merge risk (P1) - Production code grows by 48 net lines at a shared session boundary; the growth is justified by carrying an otherwise absent private route-owner fact without widening public context or Plugin SDK contracts.
  • Complete next step (P2) - The existing protected human-review gate should resolve the intentional shared session-event ordering after exact merge-result validation; no narrow automated repair remains.
Agent review details

Security

None.

PR surface

Source +48, Tests +140. Total +188 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 4 61 13 +48
Tests 3 150 10 +140
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 211 23 +188

Review metrics

Metric Value Why it matters
Production versus test LOC production +61/-13 (net +48); tests +150/-10 (net +140) The added private carrier and deferred drain cross the shared channel/reply boundary, while regression coverage exercises route visibility and busy admission.

Merge-risk options

Maintainer options:

  1. Land the approved route-first policy (recommended)
    Accept the intentional shared-channel-before-thread ordering after exact merge-result validation confirms both route visibility and busy-admission retention.

Technical review

Best possible solution:

Keep route ownership private, drain route events before thread-local events only after admission can run, and validate the focused regressions against the clean current-main merge result; no net-neutral alternative is evident because current reply options carry no route-owner fact and public-context propagation would widen contracts.

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

Yes—source-reproducible with high confidence: enqueue an authorized Slack reaction on the base route, then dispatch a mentioned thread turn whose session key differs; current main drains only the thread queue.

Is this the best way to solve the issue?

Yes. The private route carrier preserves existing public contracts, and deferring drains until admission succeeds repairs both route visibility and the busy-return loss without a new configuration surface.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P1: Eligible Slack reaction events can be silently absent from the next thread-scoped agent turn on a supported channel workflow.
  • merge-risk: 🚨 session-state: Merging changes which queued route and thread session events are consumed and injected into an agent turn.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.

Evidence

What I checked:

Likely related people:

  • steipete: Current-main blame attributes both the single-session drain and Slack route assignment to this commit. (role: current source-line author; confidence: high; commits: 0e6f38178a2f; files: src/auto-reply/reply/get-reply-run-admission.ts, extensions/slack/src/monitor/message-handler/prepare.ts)
  • sjf-oa: Authored the current branch’s route/admission changes and documented the approved route-first ordering in the PR discussion. (role: recent session-routing contributor and policy approver; confidence: high; commits: e58a28d8a6e7, 053f835568b4; files: src/channels/turn/lifecycle.ts, src/auto-reply/reply/get-reply-run-admission.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Validate the focused route-visibility and busy-admission regressions on the clean current-main merge result.

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 (8 earlier review cycles)
  • reviewed 2026-08-12T01:10:05.649Z sha 062dd9b :: found issues before merge. :: [P1] Keep the reply-context change behind an approved SDK contract
  • reviewed 2026-08-12T01:18:00.025Z sha 062dd9b :: found issues before merge. :: [P1] Keep the route event key behind an approved SDK contract
  • reviewed 2026-08-12T03:11:25.841Z sha 062dd9b :: needs changes before merge. :: [P1] Keep route event ownership behind the existing core boundary
  • reviewed 2026-08-12T03:57:07.673Z sha fadb88b :: found issues before merge. :: [P1] Defer route-event consumption until admission can run
  • reviewed 2026-08-12T05:05:44.235Z sha e58a28d :: needs maintainer review before merge. :: none
  • reviewed 2026-08-12T05:15:48.085Z sha e58a28d :: needs maintainer review before merge. :: none
  • reviewed 2026-08-12T06:12:35.722Z sha e58a28d :: passed. :: none
  • reviewed 2026-08-12T06:58:02.528Z sha e58a28d :: needs maintainer review before merge. :: none

@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 12, 2026

sjf-oa commented Aug 12, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added 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. labels Aug 12, 2026
@clawsweeper clawsweeper Bot added 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. and removed P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Aug 12, 2026
@clawsweeper clawsweeper Bot added status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and 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 12, 2026
@sjf-oa

sjf-oa commented Aug 12, 2026

Copy link
Copy Markdown
Contributor Author

Maintainer decision for the latest ClawSweeper review: I approve the route-first ordering for this fix. Route-owned reaction events are shared-channel context that predates the thread-local turn, so they should be delivered before thread-owned events in the next eligible turn. The exact-head checks are green.

@clawsweeper re-review

@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Aug 12, 2026
@sjf-oa

sjf-oa commented Aug 12, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper autofix

@clawsweeper

clawsweeper Bot commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper autofix is enabled.

  • Head: e58a28d8a6e7
  • Label: clawsweeper:autofix
  • Action: the existing exact-head review result is being reused.
  • Flow: review this head, repair/rebase only if needed, then re-review the exact repaired head until no actionable findings remain.

This is fix-only; I will not merge this PR.

@sjf-oa sjf-oa added the clawsweeper:autofix Maintainer opted this PR into bounded ClawSweeper-reviewed autofix without merge label Aug 12, 2026
@sjf-oa

sjf-oa commented Aug 12, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. labels Aug 12, 2026
@sjf-oa sjf-oa removed the clawsweeper:autofix Maintainer opted this PR into bounded ClawSweeper-reviewed autofix without merge label Aug 12, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. clawsweeper:autofix Maintainer opted this PR into bounded ClawSweeper-reviewed autofix without merge clawsweeper:human-review Needs maintainer review before ClawSweeper can continue labels Aug 12, 2026
@clawsweeper

clawsweeper Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

🦞✅
ClawSweeper is pausing this repair loop for human review.

Source: clawsweeper[bot]
Reason: - [ ] Resolve merge risk (P1) - Production code grows by 48 net lines at a shared session boundary; it intentionally changes prompt context for every channel turn whose route and dispatch sessions differ, so route-f... (sha=e58a28d8a6e76a33dc7112954899dbcdc570c671)

Why human review is needed:
ClawSweeper found a blocker that should be resolved or accepted by a maintainer before the repair or automerge loop continues.

What the maintainer can do as a next step:
If the maintainer accepts the current risk and wants ClawSweeper to continue merge gates, comment @clawsweeper approve. If more work is needed, resolve the blocker first, then comment @clawsweeper automerge to re-review and continue. If automation should stay paused, leave clawsweeper:human-review in place or comment @clawsweeper stop.

I added clawsweeper:human-review and left the final call with a maintainer.

@clawsweeper clawsweeper Bot removed proof: sufficient ClawSweeper judged the real behavior proof convincing. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 12, 2026
@sjf-oa

sjf-oa commented Aug 12, 2026

Copy link
Copy Markdown
Contributor Author

Land-ready proof

Maintainer acceptance: the route-first shared-channel ordering and the justified +48 production LOC called out by ClawSweeper are accepted for this landing. ClawSweeper has zero findings at e58a28d8a6e76a33dc7112954899dbcdc570c671.

Root cause: Slack reaction notifications are owned by the base channel route, while a mentioned reply can dispatch to a distinct thread session. Reply admission previously drained only the dispatch session, so admitted route events were invisible; it could also drain events before a busy admission returned without an agent turn.

Owner and fix: the shared channel-turn/reply-admission boundary now privately carries the distinct route session and drains route events before dispatch events only after admission succeeds. Public reply, context, configuration, and Plugin SDK contracts are unchanged. Slack and Discord exercise the shared carrier.

Validation:

  • .agents/skills/autoreview/scripts/autoreview --mode branch --base origin/main — clean; no accepted/actionable findings, correctness confidence 0.97.
  • Exact-head CI run 31564708669 — green, including openclaw/ci-gate.
  • OPENCLAW_TESTBOX=1 scripts/pr prepare-run 122363 — passed by reusing exact-head hosted CI; no fresh Testbox run ID was created.
  • scripts/pr merge-verify 122363 — passed required-check, pinned-head, mergeability, and drift verification; native merge-run will repeat it immediately before landing.
  • Focused route visibility, busy-admission retention, active-run ordering, shared Slack/Discord carrier, Slack preparation (151 tests), oxfmt, oxlint, and git diff --check all passed at the exact PR head.

Before/after: the anonymized live pre-fix reproduction showed admitted reaction-added and reaction-removed events missing from the next thread-scoped turn. The focused regressions fail on the pre-fix behavior and pass on this head, including preservation when admission returns busy.

Known gaps and ClawSweeper rank-up disposition:

  • No post-fix live Slack E2E was run.
  • The optional current-main merged-tree rerun was attempted. The tree merged without conflict and overlapping changes were independent hunks, but the local run was invalidated by stale shared node_modules (TypeError: (0 , _diagnostics.configureProviderErrorRedactor) is not a function). A clean remote rerun was unavailable because the Blacksmith CLI was absent and owned Crabbox had no broker login. This optional rank-up move is skipped; exact-head hosted CI, native prepare/merge verification, fresh autoreview, clean merge, and manual overlap inspection remain the landing evidence.

@sjf-oa
sjf-oa merged commit bea0e39 into main Aug 12, 2026
154 checks passed
@sjf-oa

sjf-oa commented Aug 12, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

@sjf-oa
sjf-oa deleted the sjf/slack-reaction-parent-events-1 branch August 12, 2026 17:05
sjf-oa added a commit that referenced this pull request Aug 12, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 13, 2026
…122363)

* test: cover routed Slack system events

* fix: deliver route events to thread turns

* style: format routed event test

* fix: scope parent event routing to Slack

* test: isolate routed event admission proof

* fix(slack): keep reaction route handoff internal

* fix(slack): preserve channel turn public types

* fix(slack): hide reaction route carrier from sdk

* style: keep channel lifecycle within lint budget

* style: trim channel lifecycle carrier setup

* test: preserve route events on busy admission

* fix(reply): defer system event drain until admission

* test: prove deferred system event drain

---------

Co-authored-by: Sarah Fortune <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: slack Channel integration: slack clawsweeper:autofix Maintainer opted this PR into bounded ClawSweeper-reviewed autofix without merge clawsweeper:human-review Needs maintainer review before ClawSweeper can continue maintainer Maintainer-authored PR 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: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants