Skip to content

Harden Slack team chat bridge delivery - #540

Open
wflanagan wants to merge 1 commit into
elie222:cursor/supersede-pr-536-slack-bridge-09defrom
omalab:wflanagan/harden-pr-538
Open

Harden Slack team chat bridge delivery#540
wflanagan wants to merge 1 commit into
elie222:cursor/supersede-pr-536-slack-bridge-09defrom
omalab:wflanagan/harden-pr-538

Conversation

@wflanagan

Copy link
Copy Markdown

Why

Greptile flagged recoverability/security issues on #538 before it goes to production. This ports the targeted hardening patch onto the #538 branch.

What changed

  • Pins Slack Socket Mode events to the authorized Slack workspace from auth.test, with optional SLACK_WORKSPACE_ID validation.
  • Adds provider-neutral send idempotency keys and maps them to Slack client_msg_id values.
  • Reserves external-message delivery before Slack sends so retries are explicit and idempotent.
  • Promotes elected ambient messages from observed to received before marking the rest ignored, avoiding a crash window that could discard the trigger.
  • Adds regression coverage for workspace rejection, outbound idempotency, delivery reservation, and ambient trigger promotion.

Tested

  • pnpm exec biome check .env.example apps/api/src/team-chat-bridge.ts apps/api/src/team-chat-bridge.test.ts packages/adapter-kit/src/types.ts packages/adapters/src/slack-team-chat.ts packages/adapters/src/slack-team-chat.test.ts
  • pnpm check
  • pnpm exec vitest run apps/api/src/team-chat-bridge.test.ts packages/adapters/src/slack-team-chat.test.ts apps/api/src/env.test.ts packages/contracts/src/index.test.ts

@vercel

vercel Bot commented Sep 3, 2026

Copy link
Copy Markdown

@wflanagan is attempting to deploy a commit to the Inbox Zero Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Sep 3, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: 953609b9-ad43-49db-9769-6d4c7090da6e

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR hardens the Slack team-chat bridge’s workspace isolation and retry behavior.

  • Validates inbound Socket Mode events against the workspace authorized by auth.test.
  • Adds stable outbound idempotency keys mapped to Slack client_msg_id.
  • Introduces atomic delivery reservation and stale-reservation recovery.
  • Promotes elected ambient triggers before ignoring the remaining batch messages.
  • Adds regression coverage for the new workspace, delivery, and ambient-message behavior.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
apps/api/src/team-chat-bridge.ts Adds atomic delivery reservation, stale-delivery recovery, stable send keys, and crash-safe ambient-trigger promotion; the previously reported reservation reacquisition issue is fixed.
packages/adapters/src/slack-team-chat.ts Pins inbound events to the authenticated workspace and maps stable send keys to per-chunk Slack client message IDs.
packages/adapter-kit/src/types.ts Extends provider-neutral team-chat sends with an optional stable idempotency key.
apps/api/src/team-chat-bridge.test.ts Adds regression coverage for trigger promotion and prevention of immediate reacquisition of reserved deliveries.
packages/adapters/src/slack-team-chat.test.ts Covers cross-workspace rejection, workspace configuration parsing, and per-chunk outbound idempotency IDs.

Sequence Diagram

sequenceDiagram
  participant Bridge as TeamChatBridge
  participant DB as Prisma
  participant Slack as Slack API
  Bridge->>DB: Reserve running message as delivering
  DB-->>Bridge: Reservation acquired
  Bridge->>Slack: chat.postMessage(client_msg_id)
  Slack-->>Bridge: Message timestamp
  Bridge->>DB: Mark delivered and persist handle
  Note over Bridge,DB: Expired reservations return to running
  Bridge->>Slack: Retry with the same client_msg_id
  Slack-->>Bridge: Deduplicated result
Loading

Reviews (2): Last reviewed commit: "fix: harden Slack team chat bridge" | Re-trigger Greptile

Comment thread apps/api/src/team-chat-bridge.ts Outdated
@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown

Playwright screenshots

Feature frames for this PR:

Open screenshot gallery · Dashboard · CI run

Updated for commit 6ca8792.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant