Skip to content

fix(slack): route Enterprise Grid messages by workspace - #120087

Merged
sjf-oa merged 36 commits into
mainfrom
sjf/enterprise-grid-workspace-aware-slack
Aug 8, 2026
Merged

sjf-oa merged 36 commits into
mainfrom
sjf/enterprise-grid-workspace-aware-slack

Conversation

@sjf-oa

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

Copy link
Copy Markdown
Contributor

What Problem This Solves

Slack Enterprise Grid events identify the workspace that owns each conversation, but reusable message destinations did not retain that workspace. A later live, queued, or scheduled message therefore could not safely select the matching team-scoped Slack client.

Design

  • Keep workspace identity inside Slack's existing destination string: team:T123:channel:C123 or team:T123:user:U123.
  • Qualify reusable inbound destinations for validated Enterprise Grid events while keeping the immediate listener reply on its validated physical channel and client.
  • Teach Slack target parsing, session routing, outbound admission, client caching, and unknown-send reconciliation to consume the same qualified destination.
  • Create detached Web API clients with Slack's teamId option and partition cached clients by workspace.
  • Allow bare current-conversation targets to use trusted listener-owned workspace context while keeping cross-conversation and ambiguous routing fail-closed.
  • Preserve current behavior for ordinary Slack installations and reject workspace-qualified destinations there.

The destination remains opaque outside the Slack extension, so this adds no generic OpenClaw channel or queue parameter.

Scope

  • Workspace-aware inbound routing, reusable destinations, direct and queued delivery, and unknown-send reconciliation.
  • Workspace-scoped Slack runtime writes: send, edit, delete, upload, react, pin, and unpin.
  • Workspace-scoped Slack runtime reads: messages, reactions, pins, member info, emoji, and file download.
  • Thread participation and follow-up delivery without requiring a repeated bot mention.

Validation

  • Full Slack extension suite passed under Node 24.
  • Slack extension production and test TypeScript checks passed.
  • Slack extension lint and changed-file formatting checks passed.
  • Targeted Grid routing regressions passed inside the final locally built gateway image.
  • The final native ARM64 gateway image was run locally with Enterprise Grid enabled and tested end to end in two distinct Grid workspaces.
  • Bare workspace-less targets passed send/edit/delete, reaction, pin/unpin, all supported read actions, and deterministic upload/download round trips in both workspaces.
  • Thread follow-ups without another bot mention passed in both workspaces.
  • Uploaded files were downloaded through the native Slack runtime and matched the source byte size and SHA-256 in both workspaces; local cleanup also passed.

AI-assisted: yes. The workspace-routing and fail-closed boundaries were reviewed by a maintainer.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation channel: slack Channel integration: slack gateway Gateway runtime agents Agent runtime and tooling size: L maintainer Maintainer-authored PR labels Aug 7, 2026
@clawsweeper clawsweeper Bot added 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 7, 2026
@sjf-oa
sjf-oa force-pushed the sjf/enterprise-grid-workspace-aware-slack branch from 45e594c to 4ab1c3e Compare August 7, 2026 00:40
@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. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. 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. labels Aug 7, 2026
@clawsweeper

clawsweeper Bot commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge. Reviewed August 8, 2026, 2:43 PM ET / 18:43 UTC.

ClawSweeper review

What this changes

This PR carries Enterprise Grid workspace identity through Slack destinations, sessions, API clients, and deferred delivery so later operations use the correct workspace.

Merge readiness

⚠️ Ready for maintainer review - 5 items remain

Keep open: the Enterprise Grid action expansion exposes default-enabled operations whose required OAuth scopes are absent from both Enterprise manifests, while the updated docs say those operations remain unavailable.

Priority: P2
Reviewed head: fda6def58c0dc5bc4464c094b17d3920bda769d9
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The workspace-routing approach is substantial and coherent, but the unresolved Enterprise OAuth and capability contract blocks merge readiness.
Proof confidence 🌊 off-meta tidepool Not applicable: Repository metadata identifies this as a maintainer-authored PR, so the external-contributor proof gate does not apply; the linked image artifact was unavailable for independent inspection.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Repository metadata identifies this as a maintainer-authored PR, so the external-contributor proof gate does not apply; the linked image artifact was unavailable for independent inspection.
Evidence reviewed 6 items Current main does not implement this feature: Current main rejects direct Enterprise Grid delivery, so the PR remains necessary rather than superseded.
Default action exposure: The PR removes the Enterprise-wide action rejection; unset action configuration defaults to enabled, exposing reaction reads, pins, and emoji listing.
Enterprise manifest mismatch: Both Enterprise manifests include reactions:write but omit im:write, pins:read, pins:write, reactions:read, and emoji:read; the expanded runtime reaches the corresponding actions and DM-opening path.
Findings 1 actionable finding [P1] Align Enterprise action scopes with the enabled operations
Security None None.

How this fits together

The Slack plugin converts inbound events into reusable destinations and later uses them for messages and Slack actions. Enterprise Grid needs the workspace retained so a queued or direct operation selects the correct team-scoped Slack client.

flowchart LR
  A[Enterprise Grid event] --> B[Qualified Slack destination]
  B --> C[Session and delivery routing]
  C --> D[Workspace-scoped Slack client]
  D --> E[Messages and actions]
  E --> F[Slack workspace]
Loading

Decision needed

Question Recommendation
Should Enterprise Grid support the full newly exposed Slack action set, or retain the documented upload-and-reaction-only subset? Support the full scoped action set: Add the required OAuth scopes and reauthorization guidance to both Enterprise manifests, then document and test pins, reaction reads, emoji reads, and DM resolution.

Why: The branch, its PR body, and the edited documentation describe incompatible supported-action contracts, and that choice determines the manifest, upgrade path, and gates.

Before merge

  • Align Enterprise action scopes with the enabled operations (P1) - Removing the Enterprise action rejection leaves pins, reaction reads, emoji listing, and DM-resolution paths enabled by default, but both Enterprise manifests omit im:write, pins:read, pins:write, reactions:read, and emoji:read; the edited docs also say most of these actions remain unavailable. Existing org installs will hit missing_scope until the manifests, reauthorization guidance, capability text, and intended runtime gates agree.
  • Resolve merge risk (P1) - Existing Enterprise Grid installations created from either documented manifest will receive Slack missing_scope errors for newly exposed pin, reaction-read, emoji-read, or DM-opening paths until an org admin reauthorizes with the required scopes.
  • Resolve merge risk (P1) - Workspace-qualified destinations change delivery and session routing; exact-head validation should cover fresh installs and an existing Enterprise installation after reauthorization.
  • Resolve merge risk (P1) - The @slack/web-api v8.0.0 source contract for team scoping could not be independently inspected because the package is absent locally and network DNS is unavailable.

Findings

  • [P1] Align Enterprise action scopes with the enabled operations — extensions/slack/src/action-runtime.ts:552-570
Agent review details

Security

None.

PR surface

Source +290, Tests +968, Docs +7. Total +1265 across 40 files.

View PR surface stats
Area Files Added Removed Net
Source 18 611 321 +290
Tests 21 1105 137 +968
Docs 1 15 8 +7
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 40 1731 466 +1265

Review metrics

Metric Value Why it matters
Production versus test delta production +626/-329, tests +1105/-137 The substantial production growth is justified by keeping workspace identity inside the Slack plugin, but it increases the need for a coherent supported-action and upgrade contract.

Stored data model

Persistent data-model change detected: persistent cache schema: extensions/slack/src/channel-type.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Align manifests and action contract (recommended)
    Before merge, update both Enterprise manifests and reauthorization guidance for the intended action set, then correct the capability text and add upgrade coverage.
  2. Retain the documented V1 limits
    Keep only the documented Enterprise actions enabled and restore runtime gates for every omitted-scope operation.
  3. Pause for Grid support policy
    Pause this PR if maintainers do not want the added OAuth surface or support commitment for Enterprise action tools.

Technical review

Best possible solution:

Choose the intended Enterprise Grid action set; if the full set is intended, add im:write, pins:read, pins:write, reactions:read, and emoji:read to both manifests, give existing org installs reauthorization guidance, align capability text, and prove fresh and upgraded two-workspace runs.

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

Yes, from source: Enterprise accounts default-enable the newly reachable actions while both Enterprise manifests omit their required scopes. A redacted live Enterprise run is still needed to demonstrate the after-reauthorization upgrade path.

Is this the best way to solve the issue?

Unclear: carrying workspace identity in Slack-owned destinations is the right owner boundary, but the PR must first settle and consistently implement its supported Enterprise action contract.

Full review comments:

  • [P1] Align Enterprise action scopes with the enabled operations — extensions/slack/src/action-runtime.ts:552-570
    Removing the Enterprise action rejection leaves pins, reaction reads, emoji listing, and DM-resolution paths enabled by default, but both Enterprise manifests omit im:write, pins:read, pins:write, reactions:read, and emoji:read; the edited docs also say most of these actions remain unavailable. Existing org installs will hit missing_scope until the manifests, reauthorization guidance, capability text, and intended runtime gates agree.
    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 5e66d9ee6676.

Labels

Label changes:

  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.

Label justifications:

  • P2: This is a bounded Enterprise Grid feature expansion with limited installation scope but meaningful operator impact.
  • merge-risk: 🚨 compatibility: Existing org installations need newly documented scopes and reauthorization before newly enabled operations work.
  • merge-risk: 🚨 message-delivery: The PR changes reusable Slack destinations and the client selected for deferred delivery.
  • merge-risk: 🚨 session-state: Workspace-qualified destinations now flow through session and route identity.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: Repository metadata identifies this as a maintainer-authored PR, so the external-contributor proof gate does not apply; the linked image artifact was unavailable for independent inspection.

Evidence

What I checked:

Likely related people:

  • kevinlin-openai: Authored the original Enterprise Grid support commit and is the strongest history route for its supported-operation policy. (role: introduced Enterprise Grid behavior; confidence: high; commits: 245b91b83de0; files: extensions/slack/src/monitor/enterprise-install.ts, docs/channels/slack.md)
  • wonfong: Available shallow current-main blame attributes nearby Slack routing code to this recent commit; earlier ownership is obscured by shallow history. (role: recent adjacent source contributor; confidence: low; commits: 9fdc266f6468; files: extensions/slack/src/action-runtime.ts, extensions/slack/src/send.ts)

Rank-up moves

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

  • Choose the supported Enterprise action set.
  • Align both Enterprise manifests, reauthorization guidance, and capability text with that decision.
  • Provide exact-head fresh-install and reauthorized-upgrade evidence across two Grid workspaces.

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 (9 earlier review cycles; latest 8 shown)
  • reviewed 2026-08-07T03:33:59.191Z sha 4ab1c3e :: needs changes before merge. :: [P1] Ignore ambient team IDs on standard Slack sends | [P1] Do not scope ordinary Slack actions as Enterprise Grid | [P1] Keep implicit threads inside the active workspace | [P1] Carry workspace scope through ACP replies | [P2] Propagate workspace scope from reset-hook replies
  • reviewed 2026-08-07T06:35:59.792Z sha f790c16 :: found issues before merge. :: [P1] Preserve the origin workspace for ACP replies | [P2] Propagate workspace scope from reset-hook replies | [P1] Expose workspaceId for unscoped Enterprise discovery
  • reviewed 2026-08-07T08:40:47.599Z sha f790c16 :: found issues before merge. :: [P1] Preserve workspace scope for ACP replies | [P2] Preserve workspace scope for reset-hook replies | [P1] Expose workspaceId for cross-channel Enterprise actions
  • reviewed 2026-08-07T11:54:32.602Z sha f790c16 :: found issues before merge. :: [P1] Preserve gateway idempotency keys | [P1] Retain the initial durable-delivery producer claim | [P1] Carry workspace scope into ACP replies | [P2] Carry workspace scope into reset-hook replies
  • reviewed 2026-08-07T23:41:54.479Z sha 73f65805c46b8fed450e40cec66ba9ef43a9af43 :: found issues before merge. :: [P1] Preserve workspace scope in outbound session routes | [P2] Document the Enterprise Grid manifest upgrade
  • reviewed 2026-08-08T00:40:20.454Z sha 2dc31b277be62198b0141ce0cb4f755b57f3c8e1 :: needs real behavior proof before merge. :: [P1] Propagate Grid scope to pairing replies | [P2] Update Enterprise Grid delivery documentation
  • reviewed 2026-08-08T01:43:11.891Z sha 827e495 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-08T10:39:40.942Z sha c7a9ceb :: found issues before merge. :: [P1] Declare the scopes required by enabled Grid actions

@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 7, 2026
@openclaw-barnacle openclaw-barnacle Bot closed this Aug 7, 2026
@openclaw-barnacle openclaw-barnacle Bot reopened this Aug 7, 2026
@openclaw-barnacle openclaw-barnacle Bot closed this Aug 7, 2026
@openclaw-barnacle openclaw-barnacle Bot reopened this Aug 7, 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 7, 2026
@sjf-oa
sjf-oa force-pushed the sjf/enterprise-grid-workspace-aware-slack branch from f790c16 to 1ac8cbe Compare August 7, 2026 23:03
@openclaw-barnacle openclaw-barnacle Bot added size: XL and removed gateway Gateway runtime agents Agent runtime and tooling size: L labels Aug 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: slack Channel integration: slack docs Improvements or additions to documentation maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. 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. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XL 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.

2 participants