Skip to content

Commit ca07847

Browse files
committed
test(reply): use a core-local stub provider instead of the bundled Mattermost import
The reconcile-thread regression test deep-imported extensions/mattermost from a core test, which trips the core/extension package boundary (boundary-invariants "keeps core tests off bundled extension deep imports", extension-test-boundary, and check-tsgo-core-boundary pulling extensions/mattermost transitively). Replace it with a core-local channel test plugin that reproduces the same contract: an implicit-threading extractToolSend, a partial extractToolSendResult that reports only { to, threadId? }, and no targetsMatchForReplySuppression matcher. The test now exercises the generic reconciler contract with no extension dependency. It still fails on pristine main and passes with the fix.
1 parent 0cca6bd commit ca07847

1 file changed

Lines changed: 41 additions & 9 deletions

File tree

src/agents/embedded-agent-subscribe.tools.reconcile-thread.test.ts

Lines changed: 41 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,44 @@
11
import { afterEach, describe, expect, it } from "vitest";
2-
import { mattermostPlugin } from "../../extensions/mattermost/src/channel.js";
32
import { getMatchingMessagingToolReplyTargets } from "../auto-reply/reply/reply-payloads-dedupe.js";
43
import { setActivePluginRegistry } from "../plugins/runtime.js";
5-
import { createTestRegistry } from "../test-utils/channel-plugins.js";
4+
import { createChannelTestPluginBase, createTestRegistry } from "../test-utils/channel-plugins.js";
65
import {
76
extractMessagingToolSend,
87
extractMessagingToolSendResult,
98
} from "./embedded-agent-subscribe.tools.js";
109

11-
function registerMattermost(): void {
10+
const PARTIAL_RESULT_PROVIDER = "partialthreadprovider";
11+
12+
function createPartialResultPlugin(): unknown {
13+
return {
14+
...createChannelTestPluginBase({ id: PARTIAL_RESULT_PROVIDER }),
15+
actions: {
16+
extractToolSend: ({ args }: { args: Record<string, unknown> }) =>
17+
args.action === "send" && typeof args.to === "string"
18+
? { to: args.to, threadImplicit: true }
19+
: null,
20+
extractToolSendResult: ({ result }: { result: unknown }) => {
21+
const toolSend = (result as { details?: { toolSend?: Record<string, unknown> } })?.details
22+
?.toolSend;
23+
const to = typeof toolSend?.to === "string" ? toolSend.to : undefined;
24+
if (!to) {
25+
return null;
26+
}
27+
const threadId = typeof toolSend?.threadId === "string" ? toolSend.threadId : undefined;
28+
return { to, ...(threadId ? { threadId } : {}) };
29+
},
30+
},
31+
threading: {
32+
resolveAutoThreadId: ({ toolContext }: { toolContext?: { currentThreadTs?: string } }) =>
33+
toolContext?.currentThreadTs,
34+
},
35+
};
36+
}
37+
38+
function registerPartialResultProvider(): void {
1239
setActivePluginRegistry(
1340
createTestRegistry([
14-
{ pluginId: mattermostPlugin.id, source: "test", plugin: mattermostPlugin },
41+
{ pluginId: PARTIAL_RESULT_PROVIDER, source: "test", plugin: createPartialResultPlugin() },
1542
]),
1643
);
1744
}
@@ -22,11 +49,11 @@ describe("extractMessagingToolSendResult thread evidence", () => {
2249
});
2350

2451
it("preserves implicit thread evidence when the provider result omits it", () => {
25-
registerMattermost();
52+
registerPartialResultProvider();
2653

2754
const pending = extractMessagingToolSend(
2855
"message",
29-
{ action: "send", provider: "mattermost", to: "channel:abc", message: "answer" },
56+
{ action: "send", provider: PARTIAL_RESULT_PROVIDER, to: "channel:abc", message: "answer" },
3057
{
3158
currentChannelId: "channel:abc",
3259
currentMessagingTarget: "channel:abc",
@@ -44,7 +71,7 @@ describe("extractMessagingToolSendResult thread evidence", () => {
4471
expect(confirmed.threadId).toBe("root-1");
4572

4673
const matches = getMatchingMessagingToolReplyTargets({
47-
messageProvider: "mattermost",
74+
messageProvider: PARTIAL_RESULT_PROVIDER,
4875
originatingTo: "channel:abc",
4976
originatingThreadId: "root-1",
5077
messagingToolSentTargets: [confirmed],
@@ -53,10 +80,15 @@ describe("extractMessagingToolSendResult thread evidence", () => {
5380
});
5481

5582
it("lets an explicit provider-reported thread override pending implicit evidence", () => {
56-
registerMattermost();
83+
registerPartialResultProvider();
5784

5885
const confirmed = extractMessagingToolSendResult(
59-
{ tool: "message", provider: "mattermost", to: "channel:abc", threadImplicit: true },
86+
{
87+
tool: "message",
88+
provider: PARTIAL_RESULT_PROVIDER,
89+
to: "channel:abc",
90+
threadImplicit: true,
91+
},
6092
{ details: { toolSend: { to: "channel:abc", threadId: "root-9" } } },
6193
);
6294
expect(confirmed.threadId).toBe("root-9");

0 commit comments

Comments
 (0)