Skip to content

feat(knowledge): crawl Slack per member on Sim Search through each person's own Slack user token - #7421

Open
waleedlatif1 wants to merge 3 commits into
stagingfrom
feat/slack-member-search
Open

feat(knowledge): crawl Slack per member on Sim Search through each person's own Slack user token#7421
waleedlatif1 wants to merge 3 commits into
stagingfrom
feat/slack-member-search

Conversation

@waleedlatif1

@waleedlatif1 waleedlatif1 commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Slack joins the per-member Sources on Sim Search. Credential Group enrollment already issues each person their own Slack user token through the workspace's custom Slack app, and conversations.list under that token returns exactly the public channels and the private channels they belong to, so the existing members engine crawls Slack the same way it crawls Gmail and Google Chat: each member's listing is their access, and the reader token s:slack:<team>:<user> is derived from the same credential row on both sides. No new access mode, no bot crawl, no membership walk, no email matching.
  • Slack's 2025 rate-limit change to conversations.history exempts internal customer-built apps, which is what a Credential Group's custom bot is, so a per-member crawl runs at full Tier 3 speed.
  • The Slack connector now lists channels as deferred stubs: the transcript is fetched in getDocument, once per channel per run however many members list it, and hydrates five at a time under the shared 12 MiB text ceiling. With no channel configured it lists every readable channel through the cursor, which is what a members-mode crawl does (the channel selection is the listing cap). A channel listing carries no signal of new messages, so the stub hash is run-scoped and the real hash getDocument computes decides whether anything is re-indexed: an unchanged channel costs one history page and no embedding.
  • Each channel document opens with a header naming the channel, its topic and its purpose, so an empty channel is a live document rather than a deletion, and the message count reports only the messages the transcript holds. The hash prefix moves to slack-v3 so channels indexed before the header and ceiling re-index once.
  • The shared text accumulator now takes which end survives when a document reaches the ceiling. A mail thread keeps what came first, because its root message is the context; a chat transcript keeps what came last, so the newest messages are the ones people search for. Google Chat moves to the same rule, and both keep their pinned header with a note where text was left out.
  • Members-mode scope validation goes through the Credential Group provider adapter instead of the managed OAuth policy registry, which had no Slack entry. The standard OAuth adapter's scope comparison now reads the provider's policy alone, so validating a saved option no longer needs the OAuth client configured.
  • First connect from Sim Search cannot create a Slack Credential Group, since the option authorizes through the workspace's own Slack app that only an admin can configure in Settings: it adopts the one ready Slack option, and otherwise says what to set up. Options that are not configured yet are never adopted, for any provider.

Type of Change

  • New feature

Testing

  • New Slack connector suite: deferred stubs without history reads, all-channel listing with cursor paging and the public and private channel types, one stub per channel across members of a run, a new stub each run, the header and slack-v3 hash on hydration, an empty channel kept live, null only for a channel Slack no longer knows.
  • Text accumulator: keeping the last records drops the oldest to fit, keeps the pinned header, refuses only a record too large on its own, and joins plainly when everything fits.
  • Members-mode binding validation: a Slack option passes through the Slack scope policy, a channel selection is refused as a cap, a missing history scope is refused.
  • Provisioning: adopts the one ready Slack option, points at Settings when none is ready, leaves two for the admin, and still creates a group for a standard OAuth provider.
  • The cross-connector permission-scoped listing test now includes Slack and checks every connector's read scopes against its Credential Group adapter.
  • Slack's conversations.history reference confirms user tokens read public channels they are not in, which the all-channel listing relies on.
  • Type-check, lint, check:audits (45 audits), and the knowledge, credential-group, connector, and search suites (2,832 tests) pass.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercel Bot commented Sep 2, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Sep 2, 2026 10:52pm UTC

Request Review

@greptile-apps

greptile-apps Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds per-member Slack crawling through each member’s Slack user token and changes Slack channel hydration to deferred, run-scoped stubs. It also generalizes bounded transcript handling so Slack and Google Chat preserve their newest messages under the text ceiling.

  • Adds permission-scoped Slack channel listing with cursor pagination.
  • Defers Slack transcript hydration until getDocument and adds channel metadata headers.
  • Extends BoundedLines with pinned headers and first/last retention policies.
  • Routes member scope validation through credential-group provider adapters.
  • Reuses ready Slack credential-group options during member provisioning.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
apps/sim/connectors/slack/slack.ts Adds all-channel pagination, deferred stubs, metadata-backed hydration, and newest-message transcript retention without an eligible blocking defect.
apps/sim/connectors/utils.ts Adds pinned records and configurable first/last retention to the bounded text accumulator; the previous newest-message truncation issue is resolved.
apps/sim/connectors/google-chat/google-chat.ts Migrates Google Chat formatting to retain newest messages while preserving its header.
apps/sim/lib/knowledge/connectors/member-access.ts Validates connector scopes through the credential-group provider adapter to support Slack.
apps/sim/lib/knowledge/connectors/member-provisioning.ts Adopts a uniquely configured Slack option and preserves automatic provisioning for standard OAuth providers.

Sequence Diagram

sequenceDiagram
  participant Sync as Member sync
  participant Connector as Slack connector
  participant Slack as Slack API
  participant Index as Knowledge index
  Sync->>Connector: listDocuments(member token, cursor)
  Connector->>Slack: conversations.list
  Slack-->>Connector: Readable public/private channels
  Connector-->>Sync: Deferred channel stubs
  Sync->>Connector: getDocument(channel ID)
  Connector->>Slack: conversations.info
  Connector->>Slack: conversations.history
  Slack-->>Connector: Channel metadata and messages
  Connector-->>Sync: Bounded newest-message transcript and real hash
  Sync->>Index: Re-index only when real hash changed
Loading

Reviews (3): Last reviewed commit: "fix(slack): fold the channel header into..." | Re-trigger Greptile

Comment thread apps/sim/connectors/slack/slack.ts Outdated

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 9 files

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread apps/sim/connectors/slack/slack.ts Outdated
Comment thread apps/sim/connectors/slack/slack.ts Outdated
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 12 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Re-trigger cubic

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 12 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Re-trigger cubic

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