From 89ef37d7e0cac5664601ff58b99d70ef12d1612b Mon Sep 17 00:00:00 2001 From: Dotta <34892728+cryppadotta@users.noreply.github.com> Date: Thu, 15 Oct 2026 16:28:19 -0500 Subject: [PATCH] fix(slack): accept linear DM receipt destinations (#16494) Accept the pinned Slack SDK linear DM address for receipt add/remove while preserving channel, source message, credential and timeout checks. SDK regressions, 106 affected tests, repository typecheck/build, full CI/E2E, Superagent, legacy Snyk and exact-head Apex 5/5 passed. Co-Authored-By: Paperclip --- maps/agent-access-map/chat-channels.md | 7 ++++++ maps/feature-map/chat-channels.md | 5 ++++ .../src/services/chat-slack-receipts.test.ts | 25 +++++++++++++++++++ server/src/services/chat-slack-receipts.ts | 2 +- 4 files changed, 38 insertions(+), 1 deletion(-) diff --git a/maps/agent-access-map/chat-channels.md b/maps/agent-access-map/chat-channels.md index df9e94958ea..d6c50529ea1 100644 --- a/maps/agent-access-map/chat-channels.md +++ b/maps/agent-access-map/chat-channels.md @@ -115,6 +115,13 @@ apply. Top-level DM replies retain their linear conversation destination. Source [queued run policy](../../server/src/services/durable-chat-wakeup.ts). Live Slack verification of this exemption remains separate from provider-fixture coverage. +Controller-owned receipt reactions accept the SDK's empty thread timestamp for +linear DMs. Channel IDs and source message timestamps remain validated. This +does not add an agent tool or change sender, task, or credential authorization. +The pinned SDK transport regression is covered in +[receipt tests](../../server/src/services/chat-slack-receipts.test.ts); live +acknowledgement speed needs a separate provider test. + New conversations resolve typed project/workspace defaults from their endpoint and destination under the task-creation transaction. Defaults do not authorize private sources: admission checks the linked user's authority and assigned agent. diff --git a/maps/feature-map/chat-channels.md b/maps/feature-map/chat-channels.md index 1a5854af390..c304e629052 100644 --- a/maps/feature-map/chat-channels.md +++ b/maps/feature-map/chat-channels.md @@ -48,6 +48,11 @@ top-level replies to top-level DMs. Channel messages and thread replies still require a mention when that setting is enabled. Disable direct messages and confirm a plain DM is rejected. Use a private channel for threaded conversations. +During a top-level DM run, verify that the bot adds eyes to the source message +and removes them when the final reply arrives. The pinned Slack SDK encodes a +linear DM with an empty thread timestamp; receipt transport accepts that address +while still validating the channel and the source message timestamp. + ### `endpoint-management` Automated: [channel integration](../../server/src/__tests__/chat-channels.integration.test.ts) covers shared endpoint/delivery behavior; live credential repair and provider ownership remain manual checks. diff --git a/server/src/services/chat-slack-receipts.test.ts b/server/src/services/chat-slack-receipts.test.ts index 312ad02c5fe..213f61b0a53 100644 --- a/server/src/services/chat-slack-receipts.test.ts +++ b/server/src/services/chat-slack-receipts.test.ts @@ -1,4 +1,5 @@ import { createServer } from "node:http"; +import { createSlackAdapter } from "@chat-adapter/slack"; import { describe, expect, it, vi } from "vitest"; import { classifyChatPublicationError } from "./chat-publication-errors.js"; import { @@ -16,6 +17,27 @@ const mutation: SlackReceiptMutation = { const token = "xoxb-synthetic-never-live"; describe("bounded Slack receipt transport", () => { + it.each(["add", "remove"] as const)( + "accepts the pinned SDK's top-level DM address for %s", + async (operation) => { + const adapter = createSlackAdapter({ botToken: token, signingSecret: "synthetic" }); + const threadId = adapter.encodeThreadId({ channel: "D123", threadTs: "" }); + expect(threadId).toBe("slack:D123:"); + const fetch = vi.fn(async () => Response.json({ ok: true })); + await applySlackReceiptReaction( + { ...mutation, operation, threadId, botToken: token }, + fetch, + ); + expect(fetch).toHaveBeenCalledOnce(); + const [, init] = fetch.mock.calls[0] as unknown as [string, RequestInit]; + expect(JSON.parse(String(init.body))).toEqual({ + channel: "D123", + timestamp: mutation.messageId, + name: "eyes", + }); + }, + ); + it.each(["add", "remove"] as const)( "sends only the exact %s receipt and validates API success", async (operation) => { @@ -109,6 +131,9 @@ describe("bounded Slack receipt transport", () => { it.each([ { threadId: "slack:C123:1740000001.1:extra" }, { threadId: "slack:evil.example:1740000001.1" }, + { threadId: "slack:D123::" }, + { threadId: "slack:D123:undefined" }, + { threadId: "slack:D123:not-a-timestamp" }, { messageId: "1740000002.2&token=secret" }, { reaction: "not-eyes" }, { operation: "delete" }, diff --git a/server/src/services/chat-slack-receipts.ts b/server/src/services/chat-slack-receipts.ts index 4bf6bbaa303..4a8e25e50c0 100644 --- a/server/src/services/chat-slack-receipts.ts +++ b/server/src/services/chat-slack-receipts.ts @@ -59,7 +59,7 @@ export async function applySlackReceiptReaction( !/^[CDG][A-Z0-9]+$/.test(parts[1] ?? "") || parts.length < 2 || parts.length > 3 || - (parts[2] !== undefined && !/^\d{1,12}\.\d{1,6}$/.test(parts[2])) || + (parts[2] !== undefined && parts[2] !== "" && !/^\d{1,12}\.\d{1,6}$/.test(parts[2])) || !/^\d{1,12}\.\d{1,6}$/.test(input.messageId) || !["add", "remove"].includes(input.operation) || input.reaction !== "eyes" ||