Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

refactor(agent-platform): remove the Slack→PostHog email-match bridge (#64896)

Ben White27fc580fc301
diff --git a/products/agent_platform/services/agent-ingress/src/auth/slack-posthog-bridge.test.ts b/products/agent_platform/services/agent-ingress/src/auth/slack-posthog-bridge.test.ts
deleted file mode 100644
index c099b6c03a37..000000000000
--- a/products/agent_platform/services/agent-ingress/src/auth/slack-posthog-bridge.test.ts
+++ /dev/null
@@ -1,275 +0,0 @@
-/**
- * Unit tests for the Slack → PostHog user bridge. The Slack and PostHog API
- * calls are stubbed; the contract under test is "what does the bridge cache
- * on the AgentUser row given each possible upstream response." The identity
- * store is the real `PgIdentityStore` against the test DB (no in-memory variant).
- */
-
-import { Pool } from 'pg'
-
-import { AgentUser, IntegrationCredentials, IntegrationStore, PgIdentityStore } from '@posthog/agent-shared'
-import { reset } from '@posthog/agent-shared/testing'
-
-import { bridgeSlackToPosthogUser } from './slack-posthog-bridge'
-
-/**
- * Per-test inline IntegrationStore stub. PgIntegrationStore reads from the
- * Django `posthog_integration` table which doesn't live in the agent test
- * DB, so this minimal in-test impl seeds whatever rows a case needs.
- */
-function makeIntegrationStub(
- seed: Array<{ teamId: number; kind: string; integrationId: string; credentials: IntegrationCredentials }> = []
-): IntegrationStore & {
- add: (teamId: number, kind: string, integrationId: string, credentials: IntegrationCredentials) => void
-} {
- const rows = [...seed]
- return {
- add(teamId, kind, integrationId, credentials) {
- const i = rows.findIndex((r) => r.teamId === teamId && r.kind === kind && r.integrationId === integrationId)
- const row = { teamId, kind, integrationId, credentials }
- if (i >= 0) {
- rows[i] = row
- } else {
- rows.push(row)
- }
- },
- async get(teamId, kind, integrationId) {
- return (
- rows.find((r) => r.teamId === teamId && r.kind === kind && r.integrationId === integrationId)
- ?.credentials ?? null
- )
- },
- async list(teamId, kind) {
- return rows
- .filter((r) => r.teamId === teamId && r.kind === kind)
- .map((r) => ({ integration_id: r.integrationId, credentials: r.credentials }))
- },
- async resolveForSpec(teamId, kinds) {
- const out: Record<string, IntegrationCredentials> = {}
- for (const kind of kinds) {
- for (const r of rows.filter((rr) => rr.teamId === teamId && rr.kind === kind)) {
- out[`${kind}:${r.integrationId}`] = r.credentials
- }
- }
- return out
- },
- }
-}
-
-const TEST_DB_URL =
- process.env.AGENT_TEST_DB_URL ?? 'postgres://posthog:posthog@localhost:5432/agent_runtime_queue_test'
-
-let pool: Pool
-
-beforeAll(() => {
- pool = new Pool({ connectionString: TEST_DB_URL })
-})
-
-afterAll(async () => {
- await pool.end()
-})
-
-beforeEach(async () => {
- await reset({ databaseUrl: TEST_DB_URL })
-})
-
-async function seedIdentity(store: PgIdentityStore, agentUser: AgentUser): Promise<void> {
- // Round-trip the row through the public API so tests don't depend on
- // the store's private internals. findOrCreate uses (application_id,
- // principal_kind, principal_id) as the natural key, then we patch
- // metadata + posthog_user_id via the public setters.
- const created = await store.findOrCreate({
- team_id: agentUser.team_id,
- application_id: agentUser.application_id,
- principal_kind: agentUser.principal_kind,
- principal_id: agentUser.principal_id,
- metadata: agentUser.metadata,
- })
- // Hand back the stable id so the caller can use it in the bridge call.
- agentUser.id = created.id
- if (agentUser.posthog_user_id !== undefined) {
- await store.setPosthogUserId(created.id, agentUser.posthog_user_id)
- }
-}
-
-function makeAgentUser(overrides: Partial<AgentUser> = {}): AgentUser {
- return {
- id: 'au-bob',
- team_id: 1,
- application_id: '00000000-0000-4000-8000-00000000aa01',
- principal_kind: 'slack',
- principal_id: 'T01ACME:U-BOB',
- metadata: { workspace: 'T01ACME', slack_user: 'U-BOB' },
- posthog_user_id: undefined,
- created_at: '2026-05-27T00:00:00Z',
- ...overrides,
- }
-}
-
-function fakePosthogDb(emailToUserId: Record<string, number>): import('pg').Pool {
- return {
- // The bridge only calls `.query(sql, params)` and reads `rowCount` +
- // `rows`. A stub matching that minimal surface is enough.
- async query(_sql: string, params: unknown[]) {
- const email = String(params[0] ?? '').toLowerCase()
- const id = Object.entries(emailToUserId).find(([k]) => k.toLowerCase() === email)?.[1]
- if (id === undefined) {
- return { rowCount: 0, rows: [] }
- }
- return { rowCount: 1, rows: [{ id }] }
- },
- } as unknown as import('pg').Pool
-}
-
-describe('bridgeSlackToPosthogUser', () => {
- it('caches the matched posthog_user.id when slack returns an email that exists', async () => {
- const integrations = makeIntegrationStub()
- integrations.add(1, 'slack', 'T01ACME', { kind: 'slack', access_token: 'xoxb-acme' })
- const identities = new PgIdentityStore(pool)
- const agentUser = makeAgentUser()
- await seedIdentity(identities, agentUser)
-
- const userId = await bridgeSlackToPosthogUser(agentUser, 'T01ACME', 'U-BOB', {
- integrations,
- identities,
- posthogDb: fakePosthogDb({ '[email protected]': 42 }),
- fetchSlackEmail: async () => '[email protected]',
- })
-
- expect(userId).toBe(42)
- const cached = await identities.find({
- application_id: '00000000-0000-4000-8000-00000000aa01',
- principal_kind: 'slack',
- principal_id: 'T01ACME:U-BOB',
- })
- expect(cached!.posthog_user_id).toBe(42)
- })
-
- it('caches `null` when slack returns an email with no matching posthog_user', async () => {
- const integrations = makeIntegrationStub()
- integrations.add(1, 'slack', 'T01ACME', { kind: 'slack', access_token: 'xoxb-acme' })
- const identities = new PgIdentityStore(pool)
- const agentUser = makeAgentUser({ id: 'au-external' })
- await seedIdentity(identities, agentUser)
-
- const userId = await bridgeSlackToPosthogUser(agentUser, 'T01ACME', 'U-EXTERNAL', {
- integrations,
- identities,
- posthogDb: fakePosthogDb({}),
- fetchSlackEmail: async () => '[email protected]',
- })
-
- expect(userId).toBeNull()
- const cached = await identities.find({
- application_id: '00000000-0000-4000-8000-00000000aa01',
- principal_kind: 'slack',
- principal_id: 'T01ACME:U-BOB',
- })
- expect(cached!.posthog_user_id).toBeNull()
- })
-
- it('returns the cached posthog_user_id without re-running the lookup', async () => {
- const identities = new PgIdentityStore(pool)
- const agentUser = makeAgentUser({ posthog_user_id: 7 })
- await seedIdentity(identities, agentUser)
-
- let calls = 0
- const userId = await bridgeSlackToPosthogUser(agentUser, 'T01ACME', 'U-BOB', {
- integrations: makeIntegrationStub(),
- identities,
- posthogDb: fakePosthogDb({}),
- fetchSlackEmail: async () => {
- calls++
- },
- })
- expect(userId).toBe(7)
- expect(calls).toBe(0)
- })
-
- it('respects an explicit cached null (no match found previously) without re-asking slack', async () => {
- const identities = new PgIdentityStore(pool)
- const agentUser = makeAgentUser({ posthog_user_id: null })
- await seedIdentity(identities, agentUser)
-
- let calls = 0
- const userId = await bridgeSlackToPosthogUser(agentUser, 'T01ACME', 'U-BOB', {
- integrations: makeIntegrationStub(),
- identities,
- posthogDb: fakePosthogDb({}),
- fetchSlackEmail: async () => {
- calls++
- },
- })
- expect(userId).toBeNull()
- expect(calls).toBe(0)
- })
-
- it('caches `null` when no slack integration is connected (treat as "lookup ran, no match")', async () => {
- const identities = new PgIdentityStore(pool)
- const agentUser = makeAgentUser({ id: 'au-noslack' })
- await seedIdentity(identities, agentUser)
-
- // Empty integration store — no slack token for the team.
- const userId = await bridgeSlackToPosthogUser(agentUser, 'T01ACME', 'U-BOB', {
- integrations: makeIntegrationStub(),
- identities,
- posthogDb: fakePosthogDb({ '[email protected]': 42 }),
- fetchSlackEmail: async () => '[email protected]',
- })
- expect(userId).toBeNull()
- const cached = await identities.find({
- application_id: '00000000-0000-4000-8000-00000000aa01',
- principal_kind: 'slack',
- principal_id: 'T01ACME:U-BOB',
- })
- expect(cached!.posthog_user_id).toBeNull()
- })
-
- it('does NOT cache when the slack lookup throws — next event can retry', async () => {
- const integrations = makeIntegrationStub()
- integrations.add(1, 'slack', 'T01ACME', { kind: 'slack', access_token: 'xoxb-acme' })
- const identities = new PgIdentityStore(pool)
- const agentUser = makeAgentUser({ id: 'au-blip' })
- await seedIdentity(identities, agentUser)
-
- const userId = await bridgeSlackToPosthogUser(agentUser, 'T01ACME', 'U-BOB', {
- integrations,
- identities,
- posthogDb: fakePosthogDb({ '[email protected]': 42 }),
- fetchSlackEmail: async () => {
- throw new Error('slack: 500')
- },
- })
- expect(userId).toBeNull()
- const cached = await identities.find({
- application_id: '00000000-0000-4000-8000-00000000aa01',
- principal_kind: 'slack',
- principal_id: 'T01ACME:U-BOB',
- })
- // Lookup failed transiently. PgIdentityStore initialises
- // `posthog_user_id` to NULL on row create, so we can't distinguish
- // "never looked up" from "looked up, no match" purely on the column
- // value — the contract is that the bridge does NOT explicitly stamp
- // a cache marker when the upstream throws, so the next event can
- // retry. Asserting null here captures the on-disk default.
- expect(cached!.posthog_user_id).toBeNull()
- })
-
- it('matches emails case-insensitively (Slack profile + PostHog stored case may differ)', async () => {
- const integrations = makeIntegrationStub()
- integrations.add(1, 'slack', 'T01ACME', { kind: 'slack', access_token: 'xoxb-acme' })
- const identities = new PgIdentityStore(pool)
- const agentUser = makeAgentUser({ id: 'au-case' })
- await seedIdentity(identities, agentUser)
-
- const userId = await bridgeSlackToPosthogUser(agentUser, 'T01ACME', 'U-BOB', {
- integrations,
- identities,
- posthogDb: fakePosthogDb({ '[email protected]': 99 }),
- fetchSlackEmail: async () => '[email protected]',
- })
- expect(userId).toBe(99)
- })
-})
diff --git a/products/agent_platform/services/agent-ingress/src/auth/slack-posthog-bridge.ts b/products/agent_platform/services/agent-ingress/src/auth/slack-posthog-bridge.ts
deleted file mode 100644
index a9264b6eadd3..000000000000
--- a/products/agent_platform/services/agent-ingress/src/auth/slack-posthog-bridge.ts
+++ /dev/null
@@ -1,134 +0,0 @@
-/**
- * Slack identity → PostHog user bridge.
- *
- * When the ingress sees a never-before-seen Slack user, this helper:
- * 1. Fetches the team's Slack bot token via the integration store.
- * Slack stores one integration per workspace; integration_id IS the
- * workspace_id (e.g. `T01ABC`), so the lookup is direct.
- * 2. Calls `slack.users.info` to fetch the user's profile email.
- * 3. Queries `posthog_user` by lowered email.
- * 4. Caches the result on the AgentUser row via `setPosthogUserId`. A
- * successful match stores the user_id; a deliberate miss (no Slack
- * token, no email, no matching posthog_user) stores `null` so
- * subsequent events skip the remote call.
- *
- * The bridge is called inside the slack-events handler. Slack expects
- * events to be ack'd within 3 seconds — keep the lookup synchronous (so
- * the dispatcher sees the cached value on the immediate next turn) but
- * apply a tight timeout so a Slack/PG hiccup can't block ingress under
- * load.
- *
- * Per-asker authorisation in the dispatcher (#23 step 3) reads
- * `AgentUser.posthog_user_id` to resolve the calling user's
- * OrganizationMembership level.
- */
-
-import type { Pool } from 'pg'
-
-import { AgentUser, HttpClient, HttpFetcher, IdentityStore, IntegrationStore } from '@posthog/agent-shared'
-
-const SLACK_USERS_INFO_URL = 'https://slack.com/api/users.info'
-
-/** Default upper bound on the round-trip. Slack typically responds in <300ms. */
-const DEFAULT_TIMEOUT_MS = 2_000
-
-export interface BridgeSlackUserDeps {
- integrations: IntegrationStore
- identities: IdentityStore
- posthogDb: Pool
- /**
- * Override the Slack API call. Tests inject a stub; prod uses the real
- * `fetch` against `slack.com/api/users.info`.
- */
- fetchSlackEmail?: (token: string, slackUserId: string, signal: AbortSignal) => Promise<string | null>
- /**
- * Outbound HTTP client for the default fetcher. Defaults to a direct
- * HttpClient when omitted — wire from the ingress entrypoint so the
- * Slack lookup dispatches through smokescreen in prod. Ignored when
- * `fetchSlackEmail` is set (tests).
- */
- http?: HttpFetcher
- timeoutMs?: number
-}
-
-/**
- * Bridge a single (workspace, slack_user) pair. Idempotent — if the
- * AgentUser already has a `posthog_user_id` set, returns it unchanged. On
- * lookup failure stamps `null` so the bridge doesn't re-run for the same
- * user on every event. Returns the resolved id (or null).
- */
-export async function bridgeSlackToPosthogUser(
- agentUser: AgentUser,
- workspaceId: string,
- slackUserId: string,
- deps: BridgeSlackUserDeps
-): Promise<number | null> {
- if (agentUser.posthog_user_id !== undefined && agentUser.posthog_user_id !== null) {
- return agentUser.posthog_user_id
- }
- // `posthog_user_id === null` means "lookup already ran, no match." Don't
- // re-run unless someone explicitly invalidates the row.
- if (agentUser.posthog_user_id === null) {
- return null
- }
-
- const timeoutMs = deps.timeoutMs ?? DEFAULT_TIMEOUT_MS
- const ctrl = new AbortController()
- const timer = setTimeout(() => ctrl.abort(), timeoutMs)
- try {
- const credentials = await deps.integrations.get(agentUser.team_id, 'slack', workspaceId)
- if (!credentials?.access_token) {
- await deps.identities.setPosthogUserId(agentUser.id, null)
- return null
- }
- const http = deps.http ?? new HttpClient()
- const fetcher =
- deps.fetchSlackEmail ?? ((token, userId, signal) => defaultFetchSlackEmail(http, token, userId, signal))
- const email = await fetcher(credentials.access_token, slackUserId, ctrl.signal)
- if (!email) {
- await deps.identities.setPosthogUserId(agentUser.id, null)
- return null
- }
- const userId = await lookupPosthogUserByEmail(deps.posthogDb, email)
- await deps.identities.setPosthogUserId(agentUser.id, userId)
- return userId
- } catch {
- // Lookup blew up (timeout, Slack 5xx, PG hiccup). Don't stamp null —
- // the next event gets another chance once whatever broke recovers.
- return null
- } finally {
- clearTimeout(timer)
- }
-}
-
-async function defaultFetchSlackEmail(
- http: HttpFetcher,
- token: string,
- slackUserId: string,
- signal: AbortSignal
-): Promise<string | null> {
- const res = await http.fetch(`${SLACK_USERS_INFO_URL}?user=${encodeURIComponent(slackUserId)}`, {
- method: 'GET',
- headers: { authorization: `Bearer ${token}` },
- signal,
- })
- if (!res.ok) {
- return null
- }
- const body = (await res.json()) as { ok?: boolean; user?: { profile?: { email?: string } } }
- if (!body.ok) {
- return null
- }
- return body.user?.profile?.email ?? null
-}
-
-async function lookupPosthogUserByEmail(pool: Pool, email: string): Promise<number | null> {
- const r = await pool.query<{ id: number }>(
- // posthog_user.email is stored lowercased on signup; compare case-
- // insensitively so a Slack profile with `[email protected]` still
- // matches `[email protected]`.
- `SELECT id FROM posthog_user WHERE lower(email) = lower($1) LIMIT 1`,
- [email]
- )
- return r.rowCount === 0 ? null : r.rows[0].id
-}
diff --git a/products/agent_platform/services/agent-ingress/src/index.ts b/products/agent_platform/services/agent-ingress/src/index.ts
index 8f6954926b5f..f11610bc1f4e 100644
--- a/products/agent_platform/services/agent-ingress/src/index.ts
+++ b/products/agent_platform/services/agent-ingress/src/index.ts
@@ -22,7 +22,6 @@ import {
installProcessHandlers,
PgCredentialBroker,
PgIdentityStore,
- PgIntegrationStore,
PgRevisionStore,
PgSessionQueue,
RedisSessionEventBus,
@@ -41,8 +40,8 @@ async function main(): Promise<void> {
const posthogDb = createAgentPool(config.posthogDbUrl)
const agentDb = createAgentPool(config.agentDbUrl)
- // REDIS_URL (cross-host /listen bus), HTTPS_PROXY (smokescreen — Slack bridge
- // + PostHog introspect), and AGENT_INTERNAL_SIGNING_KEY (preview-token gate +
+ // REDIS_URL (cross-host /listen bus), HTTPS_PROXY (smokescreen — Slack
+ // bot-token calls), and AGENT_INTERNAL_SIGNING_KEY (preview-token gate +
// posthog_internal mode) are all required in prod and enforced at config-load
// (config.ts: dev defaults, fail closed in prod) — no boot guards needed here.
const bus = new RedisSessionEventBus({ url: config.redisUrl })
@@ -50,12 +49,10 @@ async function main(): Promise<void> {
const http = new HttpClient({ proxyUrl: config.httpsProxy })
- // Slack → PostHog user bridge needs the integration store to fetch the
- // workspace bot token for `users.info`. Construction throws if
- // encryption isn't configured — fail-fast at boot rather than first
- // tool call.
+ // Backs the per-agent secret resolver below (Slack signing secret + bot
+ // token from `encrypted_env`). Construction throws if encryption isn't
+ // configured — fail-fast at boot rather than first request.
const encryption = new EncryptedFields(config.encryptionSaltKeys)
- const integrations = new PgIntegrationStore(posthogDb, encryption)
// Per-mode auth verifiers. The introspector validates OAuth + PAT
// bearers against PostHog's `/api/users/@me/` (covers both token
@@ -123,8 +120,6 @@ async function main(): Promise<void> {
publicBaseUrl: config.publicUrl,
slackSigningSecretResolver: secretResolver,
internalSigningKey: config.internalSigningKey,
- integrations,
- posthogDb,
authProvider,
credentialBroker,
http,
diff --git a/products/agent_platform/services/agent-ingress/src/routing/server.ts b/products/agent_platform/services/agent-ingress/src/routing/server.ts
index e7fcd5dd09e6..f0a6e8efc12b 100644
--- a/products/agent_platform/services/agent-ingress/src/routing/server.ts
+++ b/products/agent_platform/services/agent-ingress/src/routing/server.ts
@@ -5,10 +5,9 @@
*/
import express, { Express, Request, Response } from 'express'
-import type { Pool } from 'pg'
import { z } from 'zod'
-import type { IdentityStore, IntegrationStore, SecretResolver } from '@posthog/agent-shared'
+import type { IdentityStore, SecretResolver } from '@posthog/agent-shared'
import { createLogger, RevisionStore, SessionQueue, triggerAuthConfig } from '@posthog/agent-shared'
const log = createLogger('ingress')
@@ -96,19 +95,6 @@ export interface BuildAppOpts {
* unset, the gate is bypassed (dev / harness).
*/
internalSigningKey?: string
- /**
- * Read-only access to PostHog's integration table. Slack trigger uses it
- * to fetch a workspace bot token for the Slack → PostHog user bridge
- * (#23 step 2). Optional — when absent, the bridge is skipped and
- * AgentUser.posthog_user_id stays null.
- */
- integrations?: IntegrationStore | null
- /**
- * Direct access to the posthog DB pool. Slack → PostHog user bridge
- * queries `posthog_user` by email. Optional — required only when
- * `integrations` is also set.
- */
- posthogDb?: Pool | null
/**
* Per-session credential broker. Ingress writes user auth materials
* (OAuth bearer, PAT, JWT) here at /run + /send; the runner reads
@@ -118,8 +104,8 @@ export interface BuildAppOpts {
*/
credentialBroker: import('@posthog/agent-shared').CredentialBroker
/**
- * Outbound HTTP for any trigger's outbound calls (currently only the
- * slack identity bridge). Wired at the ingress entrypoint from
+ * Outbound HTTP for a trigger's outbound calls (the slack trigger's
+ * bot-token Slack calls). Wired at the ingress entrypoint from
* `config.httpsProxy` so the call dispatches through smokescreen in
* prod. Optional — falls back to a direct HttpClient in tests.
*/
@@ -172,8 +158,6 @@ export function buildApp(opts: BuildAppOpts): Express {
authProvider,
signingSecretResolver: opts.slackSigningSecretResolver ?? UNCONFIGURED_SLACK_SIGNING_SECRET_RESOLVER,
identities: opts.identities,
- integrations: opts.integrations ?? null,
- posthogDb: opts.posthogDb ?? null,
broker: opts.credentialBroker,
http: opts.http,
routingMode: opts.routingMode,
diff --git a/products/agent_platform/services/agent-ingress/src/triggers/slack.ts b/products/agent_platform/services/agent-ingress/src/triggers/slack.ts
index 74aafc6a1d45..cec901b88d0e 100644
--- a/products/agent_platform/services/agent-ingress/src/triggers/slack.ts
+++ b/products/agent_platform/services/agent-ingress/src/triggers/slack.ts
@@ -18,7 +18,6 @@ const log = createLogger('slack-trigger')
import { AgentApplication, AgentRevision, SessionPrincipal, SLACK_BOT_TOKEN_KEY } from '@posthog/agent-shared'
-import { bridgeSlackToPosthogUser } from '../auth/slack-posthog-bridge'
import { applyElevationDecline, applyElevationGrant, authorizeGrant } from '../enqueue/acl'
import { enqueueOrResume } from '../enqueue/enqueue'
import { getOwnedSession } from './session-access'
@@ -203,17 +202,6 @@ async function slackEventsHandler(ctx: RouteCtx): Promise<void> {
metadata: { workspace: workspaceId, slack_user: event.user },
})
agentUserId = agentUser.id
- // Slack → PostHog user bridge. Runs the first time we see this
- // AgentUser; cached on the row afterwards. Sync but tight-budgeted so
- // a Slack hiccup can't blow past Slack's 3s event ack window.
- if (deps.integrations && deps.posthogDb) {
- await bridgeSlackToPosthogUser(agentUser, workspaceId, event.user, {
- integrations: deps.integrations,
- identities: deps.identities,
- posthogDb: deps.posthogDb,
- http: deps.http,
- })
- }
}
const slackPrincipal: SessionPrincipal = {
diff --git a/products/agent_platform/services/agent-ingress/src/triggers/types.ts b/products/agent_platform/services/agent-ingress/src/triggers/types.ts
index 680ade4e17f1..c2a25c5cb9a6 100644
--- a/products/agent_platform/services/agent-ingress/src/triggers/types.ts
+++ b/products/agent_platform/services/agent-ingress/src/triggers/types.ts
@@ -18,7 +18,6 @@
*/
import type { Request, Response } from 'express'
-import type { Pool } from 'pg'
import type { z } from 'zod'
import type {
@@ -27,7 +26,6 @@ import type {
CredentialMap,
HttpFetcher,
IdentityStore,
- IntegrationStore,
SecretResolver,
SessionEventBus,
SessionPrincipal,
@@ -54,18 +52,10 @@ export interface TriggerDeps {
*/
broker: CredentialBroker
/**
- * Read-only access to PostHog's integration table. Slack trigger uses it
- * to fetch a workspace bot token for the Slack → PostHog user bridge.
- * Optional — when absent, the bridge is skipped.
- */
- integrations?: IntegrationStore | null
- /** Direct posthog DB pool for the Slack → PostHog user bridge's email lookup. */
- posthogDb?: Pool | null
- /**
- * Outbound HTTP — currently only the slack trigger consumes it (for
- * the identity bridge's Slack `users.info` call). Wired at the
- * ingress entrypoint so the call dispatches through smokescreen in
- * prod alongside every other fetch.
+ * Outbound HTTP — the slack trigger consumes it for its bot-token Slack
+ * calls (ack reaction, owner-only thread replies). Wired at the ingress
+ * entrypoint so the call dispatches through smokescreen in prod alongside
+ * every other fetch.
*/
http?: HttpFetcher
/** Routing mode + URL inputs the MCP connect-info endpoint advertises. */
diff --git a/products/agent_platform/services/agent-shared/src/persistence/identity-store.ts b/products/agent_platform/services/agent-shared/src/persistence/identity-store.ts
index 80959c71c922..58d9356b71cf 100644
--- a/products/agent_platform/services/agent-shared/src/persistence/identity-store.ts
+++ b/products/agent_platform/services/agent-shared/src/persistence/identity-store.ts
@@ -20,11 +20,11 @@ export interface AgentUser {
principal_id: string
metadata?: Record<string, unknown>
/**
- * Cached link to a PostHog `User` row. Populated by the ingress when a
- * Slack identity's email matches a posthog_user.email. Null when no
- * match exists (external Slack member) or the lookup hasn't run yet.
- * The dispatcher's per-asker authorisation check (#23 step 3) reads
- * this to resolve "is the current asker a team admin?"
+ * Link to a PostHog `User` row. The email-match bridge that used to set
+ * this was removed (an unverified Slack email is not a safe authz signal);
+ * it is now set only by an explicit, consented identity link, and is null
+ * until then. The dispatcher's per-asker auth check reads this to resolve
+ * "is the current asker a team admin?".
*/
posthog_user_id?: number | null
created_at: string
@@ -47,10 +47,9 @@ export interface IdentityStore {
/** Lookup by AgentUser uuid. Returns null when the row doesn't exist. */
getById(agentUserId: string): Promise<AgentUser | null>
/**
- * Cache the result of a Slack-user → PostHog-user lookup. Called once per
- * AgentUser the first time the ingress resolves it via slack.users.info.
- * Passing `null` records the lookup as "ran but no match" so repeated
- * misses don't re-hit Slack.
+ * Set (or clear, with `null`) the PostHog user this identity is linked to.
+ * Should only be called by an explicit consented identity link; `null`
+ * clears the link (e.g. on unlink/revoke).
*/
setPosthogUserId(agentUserId: string, posthogUserId: number | null): Promise<void>
}