Skip to content

Commit 2e9ef44

Browse files
committed
test(server): preserve delegated pr watch visibility coverage
1 parent c66fd0d commit 2e9ef44

3 files changed

Lines changed: 95 additions & 2 deletions

File tree

‎apps/server/src/mcp/McpHttpServer.test.ts‎

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,6 +1070,95 @@ it.effect("hides tools for links and refuses another environment while the beta
10701070
).pipe(Effect.provide(NodeHttpServer.layerTest)),
10711071
);
10721072

1073+
it.effect("lists pull request watch tools for parents and delegated children", () =>
1074+
Effect.scoped(
1075+
Effect.gen(function* () {
1076+
const scopeFor = (
1077+
token: string,
1078+
subagent: boolean,
1079+
): McpInvocationContext.McpThreadInvocationScope => ({
1080+
environmentId,
1081+
requestNamespace: token,
1082+
thread: {
1083+
threadId: ThreadId.make(`thread-${token}`),
1084+
providerSessionId: token,
1085+
providerInstanceId: ProviderInstanceId.make("codex"),
1086+
subagent,
1087+
},
1088+
client: undefined,
1089+
capabilities: new Set(["pull-requests"]),
1090+
issuedAt: 1,
1091+
});
1092+
const scopes = new Map([
1093+
["parentToken", scopeFor("parentToken", false)],
1094+
["childToken", scopeFor("childToken", true)],
1095+
]);
1096+
const serverLayer = McpHttpServer.layerPullRequestsToolkit.pipe(
1097+
Layer.provideMerge(
1098+
McpHttpServer.layerMcpTransport.pipe(Layer.provide(ServerSettings.layerTest())),
1099+
),
1100+
Layer.provide(
1101+
Layer.mock(McpSessionRegistry.McpSessionRegistry)({
1102+
resolve: (token) => Effect.succeed(scopes.get(token)),
1103+
}),
1104+
),
1105+
Layer.provide(
1106+
Layer.mergeAll(
1107+
McpToolAccessTestkit.liveThreadsLayer,
1108+
Layer.mock(ProjectService.ProjectService)({}),
1109+
Layer.mock(PullRequestReviewGuideService.PullRequestReviewGuideService)({}),
1110+
Layer.mock(Orchestrator.OrchestratorV2)({}),
1111+
Layer.mock(ProjectionStore.ProjectionStoreV2)({}),
1112+
NodeServices.layer,
1113+
),
1114+
),
1115+
);
1116+
yield* HttpRouter.serve(serverLayer, { disableListenLog: true, disableLogger: true }).pipe(
1117+
Layer.build,
1118+
);
1119+
const httpClient = yield* HttpClient.HttpClient;
1120+
const listedTools = (token: string) =>
1121+
Effect.gen(function* () {
1122+
const headers = {
1123+
accept: "application/json, text/event-stream",
1124+
authorization: `Bearer ${token}`,
1125+
};
1126+
const initialize = yield* httpClient.post("/mcp", {
1127+
headers,
1128+
body: HttpBody.text(
1129+
`{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"probe","version":"1.0.0"}}}`,
1130+
"application/json",
1131+
),
1132+
});
1133+
const listed = yield* httpClient.post("/mcp", {
1134+
headers: {
1135+
...headers,
1136+
"mcp-session-id": initialize.headers["mcp-session-id"]!,
1137+
"mcp-protocol-version": "2025-06-18",
1138+
},
1139+
body: HttpBody.text(
1140+
`{"jsonrpc":"2.0","id":2,"method":"tools/list","params":{}}`,
1141+
"application/json",
1142+
),
1143+
});
1144+
const body = (yield* listed.json) as {
1145+
readonly result: { readonly tools: ReadonlyArray<{ readonly name: string }> };
1146+
};
1147+
return body.result.tools.map((tool) => tool.name);
1148+
});
1149+
1150+
const parentTools = yield* listedTools("parentToken");
1151+
const childTools = yield* listedTools("childToken");
1152+
expect(parentTools).toEqual(
1153+
expect.arrayContaining(["link_pull_request", "watch_pull_request", "unwatch_pull_request"]),
1154+
);
1155+
expect(childTools).toContain("link_pull_request");
1156+
expect(childTools).toContain("watch_pull_request");
1157+
expect(childTools).toContain("unwatch_pull_request");
1158+
}),
1159+
).pipe(Effect.provide(NodeHttpServer.layerTest)),
1160+
);
1161+
10731162
it.effect(
10741163
"narrows an OAuth client's modes to the T3-Mode-Limit it sends, and never widens them",
10751164
() =>
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"claudeSystemAppendBytes": 5129,
3-
"codexAdditionalContextBytes": 6859,
2+
"claudeSystemAppendBytes": 5123,
3+
"codexAdditionalContextBytes": 6853,
44
"mcpToolListJsonBytes": 46007
55
}

‎evals/mcp-tool-use/run.test.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,10 @@ it("rebuilds the template from this checkout and sends a child T3's task prompt"
255255
const deferred = system[2]?.split("Load them first:\n")[1]?.split("\n\n")[0]?.split("\n") ?? [];
256256
assert.includeMembers(deferred, ["Monitor", "mcp__t3-code__delegate_task"]);
257257
assert.notInclude(deferred, "mcp__t3-code__retired_tool");
258+
assert.includeMembers(deferred, [
259+
"mcp__t3-code__watch_pull_request",
260+
"mcp__t3-code__unwatch_pull_request",
261+
]);
258262
const reminders = buildMessages(makeSample(childCase, base))[0]?.content.map((b) => b.text);
259263
assert.equal(reminders?.[0], "<system-reminder>\n# currentDate\n</system-reminder>");
260264
assert.include(reminders?.[1], "Current branch: fix/date-format");

0 commit comments

Comments
 (0)