Skip to content

Commit 4654a3c

Browse files
test(server): takeover tests for #26271 merge wakes
These are the takeover's tests. The PR's two runtime watch tests become one parametrized test covering both paths that ended a merged watch silently on main (the watch's own read, and a link sync that saw the merge first). The close/reopen sequence is dropped: a close already woke on main, and its new wording is covered by the end-message unit test. Per-host merge-commit reads are cut to the GitHub detail decode; the Forgejo test and the GitCafe assertion go. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 75d1d3e commit 4654a3c

3 files changed

Lines changed: 94 additions & 211 deletions

File tree

‎apps/server/src/orchestration-v2/runtimeLayer.test.ts‎

Lines changed: 92 additions & 184 deletions
Original file line numberDiff line numberDiff line change
@@ -2894,197 +2894,105 @@ it.layer(layerTest)("OrchestrationV2LayerLive lifecycle", (it) => {
28942894
);
28952895

28962896
// regression: watched #26248 merged and its agent kept saying it was still watching
2897-
it.effect("wakes once when a watched pull request merges, naming the merge commit", () =>
2898-
Effect.gen(function* () {
2899-
const orchestrator = yield* Orchestrator.OrchestratorV2;
2900-
const threadId = ThreadId.make("runtime-pull-request-watch-merged");
2901-
const projectId = ProjectId.make("pr-watch-merged-project");
2902-
yield* seedProject({
2903-
projectId,
2904-
title: "Watch merged",
2905-
workspaceRoot: "/workspace/watch-merged",
2906-
defaultModelSelection: null,
2907-
createdAt: "2026-10-01T00:00:00.000Z",
2908-
});
2909-
yield* orchestrator.dispatch({
2910-
type: "thread.create",
2911-
createdBy: "user",
2912-
creationSource: "web",
2913-
commandId: CommandId.make("pr-watch-merged-create"),
2914-
threadId,
2915-
projectId,
2916-
title: "Watch merged",
2917-
modelSelection,
2918-
runtimeMode: "full-access",
2919-
interactionMode: "default",
2920-
branch: null,
2921-
worktreePath: null,
2922-
});
2923-
yield* orchestrator.dispatch({
2924-
type: "thread.pull-request.watch",
2925-
commandId: CommandId.make("pr-watch-merged-start"),
2926-
threadId,
2927-
host: "github.com",
2928-
repository: "pingdotgg/t3code",
2929-
number: 15,
2930-
watching: true,
2931-
link: { url: "https://github.com/pingdotgg/t3code/pull/15", source: "agent" },
2932-
});
2933-
const reactor = yield* PullRequestWatchReactor.make.pipe(
2934-
Effect.provide(
2935-
Layer.mergeAll(
2936-
NodeServices.layer,
2937-
Layer.mock(PullRequestService.PullRequestService)({
2938-
detail: () =>
2939-
Effect.succeed({
2940-
...watchedPullRequestDetail({
2941-
projectId,
2942-
number: 15,
2943-
at: "2026-10-02T12:00:00.000Z",
2944-
}),
2945-
state: "merged" as const,
2946-
mergedAt: "2026-10-02T12:00:00.000Z",
2947-
mergeCommitSha: "3b2f958603a51d8c42c4ede02eee7b8cb310b2d9",
2948-
mergedBy: { login: "juliusmarminge", name: null, avatarUrl: null },
2949-
}),
2950-
activity: () =>
2951-
Effect.succeed({
2952-
comments: [],
2953-
commentCount: 0,
2954-
commentsTruncated: false,
2955-
reviewThreads: [],
2956-
commits: [],
2957-
}),
2958-
}),
2959-
),
2960-
),
2961-
);
2962-
yield* reactor.sweep;
2963-
yield* TestClock.adjust("10 minutes");
2964-
yield* reactor.sweep;
2965-
2966-
assert.isUndefined((yield* orchestrator.getThreadShell(threadId))?.pullRequests?.[0]?.watch);
2967-
const wakes = (yield* orchestrator.getThreadRecords(threadId, ["messages"])).messages.filter(
2968-
(message) => message.notification != null,
2969-
);
2970-
assert.deepEqual(
2971-
wakes.map((message) => message.notification?.summary),
2972-
["#15: merged, stopped watching"],
2973-
);
2974-
assert.include(wakes[0]!.text, "merged into main by juliusmarminge as 3b2f958");
2975-
}),
2976-
);
2977-
2978-
it.effect("a pull request closed, reopened, and then merged wakes once for each end", () =>
2979-
Effect.gen(function* () {
2980-
const orchestrator = yield* Orchestrator.OrchestratorV2;
2981-
const threadId = ThreadId.make("runtime-pull-request-watch-reopened");
2982-
const projectId = ProjectId.make("pr-watch-reopened-project");
2983-
yield* seedProject({
2984-
projectId,
2985-
title: "Watch reopened",
2986-
workspaceRoot: "/workspace/watch-reopened",
2987-
defaultModelSelection: null,
2988-
createdAt: "2026-10-01T00:00:00.000Z",
2989-
});
2990-
yield* orchestrator.dispatch({
2991-
type: "thread.create",
2992-
createdBy: "user",
2993-
creationSource: "web",
2994-
commandId: CommandId.make("pr-watch-reopened-create"),
2995-
threadId,
2996-
projectId,
2997-
title: "Watch reopened",
2998-
modelSelection,
2999-
runtimeMode: "full-access",
3000-
interactionMode: "default",
3001-
branch: null,
3002-
worktreePath: null,
3003-
});
3004-
const key = { host: "github.com", repository: "pingdotgg/t3code", number: 16 };
3005-
const watch = (id: string) =>
3006-
orchestrator.dispatch({
2897+
it.effect.each(["the watch's read", "the link's sync"])(
2898+
"wakes once when a watched pull request merges, naming the merge commit: seen by %s",
2899+
(seenBy) =>
2900+
Effect.gen(function* () {
2901+
const orchestrator = yield* Orchestrator.OrchestratorV2;
2902+
const threadId = ThreadId.make("runtime-pull-request-watch-merged");
2903+
const projectId = ProjectId.make("pr-watch-merged-project");
2904+
yield* seedProject({
2905+
projectId,
2906+
title: "Watch merged",
2907+
workspaceRoot: "/workspace/watch-merged",
2908+
defaultModelSelection: null,
2909+
createdAt: "2026-10-01T00:00:00.000Z",
2910+
});
2911+
yield* orchestrator.dispatch({
2912+
type: "thread.create",
2913+
createdBy: "user",
2914+
creationSource: "web",
2915+
commandId: CommandId.make("pr-watch-merged-create"),
2916+
threadId,
2917+
projectId,
2918+
title: "Watch merged",
2919+
modelSelection,
2920+
runtimeMode: "full-access",
2921+
interactionMode: "default",
2922+
branch: null,
2923+
worktreePath: null,
2924+
});
2925+
const key = { host: "github.com", repository: "pingdotgg/t3code", number: 15 };
2926+
yield* orchestrator.dispatch({
30072927
type: "thread.pull-request.watch",
3008-
commandId: CommandId.make(`pr-watch-reopened-${id}`),
2928+
commandId: CommandId.make("pr-watch-merged-start"),
30092929
threadId,
30102930
...key,
30112931
watching: true,
3012-
link: { url: "https://github.com/pingdotgg/t3code/pull/16", source: "agent" },
2932+
link: { url: "https://github.com/pingdotgg/t3code/pull/15", source: "agent" },
30132933
});
3014-
yield* watch("start");
3015-
3016-
let state: PullRequestDetail["state"] = "closed";
3017-
const host = Layer.mergeAll(
3018-
NodeServices.layer,
3019-
Layer.mock(PullRequestService.PullRequestService)({
3020-
detail: () =>
3021-
Effect.sync(() => ({
3022-
...watchedPullRequestDetail({
3023-
projectId,
3024-
number: 16,
3025-
at: "2026-10-02T12:00:00.000Z",
2934+
if (seenBy === "the link's sync") {
2935+
yield* orchestrator.dispatch({
2936+
type: "thread.pull-request-link.sync",
2937+
commandId: CommandId.make("pr-watch-merged-synced"),
2938+
threadId,
2939+
...key,
2940+
snapshot: {
2941+
state: "merged",
2942+
title: "Watched pull request",
2943+
headBranch: "feature",
2944+
baseBranch: "main",
2945+
isDraft: false,
2946+
updatedAt: null,
2947+
syncedAt: "2026-10-02T12:00:00.000Z",
2948+
mergedAt: "2026-10-02T12:00:00.000Z",
2949+
},
2950+
stack: null,
2951+
});
2952+
}
2953+
const reactor = yield* PullRequestWatchReactor.make.pipe(
2954+
Effect.provide(
2955+
Layer.mergeAll(
2956+
NodeServices.layer,
2957+
Layer.mock(PullRequestService.PullRequestService)({
2958+
detail: () =>
2959+
Effect.succeed({
2960+
...watchedPullRequestDetail({
2961+
projectId,
2962+
number: 15,
2963+
at: "2026-10-02T12:00:00.000Z",
2964+
}),
2965+
state: "merged" as const,
2966+
mergedAt: "2026-10-02T12:00:00.000Z",
2967+
mergeCommitSha: "3b2f958603a51d8c42c4ede02eee7b8cb310b2d9",
2968+
mergedBy: { login: "juliusmarminge", name: null, avatarUrl: null },
2969+
}),
2970+
activity: () =>
2971+
Effect.succeed({
2972+
comments: [],
2973+
commentCount: 0,
2974+
commentsTruncated: false,
2975+
reviewThreads: [],
2976+
commits: [],
2977+
}),
30262978
}),
3027-
state,
3028-
checks: [{ name: "lint", status: "pending" as const, description: null, url: null }],
3029-
})),
3030-
activity: () =>
3031-
Effect.succeed({
3032-
comments: [],
3033-
commentCount: 0,
3034-
commentsTruncated: false,
3035-
reviewThreads: [],
3036-
commits: [],
3037-
}),
3038-
}),
3039-
);
3040-
const summaries = Effect.map(
3041-
orchestrator.getThreadRecords(threadId, ["messages"]),
3042-
({ messages }) => messages.flatMap((message) => message.notification?.summary ?? []),
3043-
);
3044-
const watching = Effect.map(
3045-
orchestrator.getThreadShell(threadId),
3046-
(thread) => thread?.pullRequests?.[0]?.watch !== undefined,
3047-
);
3048-
const reactor = yield* PullRequestWatchReactor.make.pipe(Effect.provide(host));
3049-
yield* reactor.sweep;
3050-
assert.deepEqual(yield* summaries, ["#16: closed, stopped watching"]);
3051-
assert.isFalse(yield* watching);
3052-
3053-
// Reopening does not restart the watch; the agent was told to watch again.
3054-
state = "open";
3055-
yield* watch("again");
3056-
yield* TestClock.adjust("10 minutes");
3057-
yield* reactor.sweep;
3058-
assert.isTrue(yield* watching);
3059-
assert.deepEqual(yield* summaries, ["#16: closed, stopped watching"]);
2979+
),
2980+
),
2981+
);
2982+
yield* reactor.sweep;
2983+
yield* TestClock.adjust("10 minutes");
2984+
yield* reactor.sweep;
30602985

3061-
// The link's own sync can see the merge before the watch reads it.
3062-
state = "merged";
3063-
yield* orchestrator.dispatch({
3064-
type: "thread.pull-request-link.sync",
3065-
commandId: CommandId.make("pr-watch-reopened-synced"),
3066-
threadId,
3067-
...key,
3068-
snapshot: {
3069-
state: "merged",
3070-
title: "Watched pull request",
3071-
headBranch: "feature",
3072-
baseBranch: "main",
3073-
isDraft: false,
3074-
updatedAt: null,
3075-
syncedAt: "2026-10-02T12:30:00.000Z",
3076-
mergedAt: "2026-10-02T12:30:00.000Z",
3077-
},
3078-
stack: null,
3079-
});
3080-
yield* TestClock.adjust("10 minutes");
3081-
yield* reactor.sweep;
3082-
assert.deepEqual(yield* summaries, [
3083-
"#16: closed, stopped watching",
3084-
"#16: merged, stopped watching",
3085-
]);
3086-
assert.isFalse(yield* watching);
3087-
}),
2986+
const thread = yield* orchestrator.getThreadShell(threadId);
2987+
assert.isUndefined(thread?.pullRequests?.[0]?.watch);
2988+
const { messages } = yield* orchestrator.getThreadRecords(threadId, ["messages"]);
2989+
const wakes = messages.filter((message) => message.notification != null);
2990+
assert.deepEqual(
2991+
wakes.map((message) => message.notification?.summary),
2992+
["#15: merged, stopped watching"],
2993+
);
2994+
assert.include(wakes[0]!.text, "merged into main by juliusmarminge as 3b2f958");
2995+
}),
30882996
);
30892997

30902998
it.effect("wakes once for a state it reported, across a restart and a new watch", () =>

‎packages/source-control-forgejo/src/server/ForgejoSourceControlProvider.test.ts‎

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ const requiredChecksInput = {
6868
const requiredChecksLayer = (
6969
branch: Effect.Effect<unknown, ForgejoCli.ForgejoCliError>,
7070
statuses = requiredChecksStatuses,
71-
pull: Readonly<Record<string, unknown>> = requiredChecksPullRequest,
7271
) =>
7372
Layer.mock(ForgejoCli.ForgejoCli)({
7473
api: (input) => {
@@ -77,7 +76,7 @@ const requiredChecksLayer = (
7776
encodeJsonEffect(response).pipe(Effect.orDie, Effect.map(processOutput));
7877
switch (path) {
7978
case "repos/acme/web/pulls/7":
80-
return respond(pull);
79+
return respond(requiredChecksPullRequest);
8180
case "repos/acme/web/statuses/head":
8281
return respond(new URLSearchParams(query).get("page") === "1" ? statuses : []);
8382
case "repos/acme/web/branches/release/1.x":
@@ -321,28 +320,6 @@ it.effect.each([
321320
}).pipe(Effect.provide(requiredChecksLayer(Effect.fail(cause))));
322321
});
323322

324-
it.effect("reads a merged pull request's merge commit and who merged it", () =>
325-
Effect.gen(function* () {
326-
const provider = yield* ForgejoPullRequestProvider.make;
327-
const detail = yield* provider.getChangeRequest(requiredChecksInput);
328-
assert.strictEqual(detail.state, "merged");
329-
assert.strictEqual(detail.mergeCommitSha, "394a757942c5c3a9fb3cca31e348849e8c6a6dbe");
330-
assert.deepStrictEqual(detail.mergedBy, { login: "gusted", name: null, avatarUrl: null });
331-
}).pipe(
332-
Effect.provide(
333-
requiredChecksLayer(Effect.succeed({ name: "release/1.x" }), [], {
334-
...requiredChecksPullRequest,
335-
state: "closed",
336-
merged: true,
337-
closed_at: "2026-10-27T00:08:58+01:00",
338-
merged_at: "2026-10-27T00:08:58+01:00",
339-
merge_commit_sha: "394a757942c5c3a9fb3cca31e348849e8c6a6dbe",
340-
merged_by: { login: "gusted" },
341-
}),
342-
),
343-
),
344-
);
345-
346323
it.effect("reads Forgejo jobs that did not run as finished checks", () =>
347324
Effect.gen(function* () {
348325
const provider = yield* ForgejoPullRequestProvider.make;

‎packages/source-control-gitcafe/src/server/GitCafePullRequestProvider.test.ts‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1097,14 +1097,12 @@ describe("GitCafePullRequestProvider", () => {
10971097

10981098
it.effect("reads a pull request GitHub merged as merged before the sync reports it", () => {
10991099
const mergedAt = "2026-09-12T13:00:00Z";
1100-
const mergeCommitOid = "3b2f958603a51d8c42c4ede02eee7b8cb310b2d9";
1101-
const server = detailWith({ providerMerge: { mergedAt, mergeCommitOid } });
1100+
const server = detailWith({ providerMerge: { mergedAt } });
11021101
return Effect.gen(function* () {
11031102
const provider = yield* GitCafePullRequestProvider.make;
11041103
const detail = yield* provider.getChangeRequest(target);
11051104
assert.strictEqual(detail.state, "merged");
11061105
assert.strictEqual(detail.mergedAt, mergedAt);
1107-
assert.strictEqual(detail.mergeCommitSha, mergeCommitOid);
11081106
}).pipe(Effect.provide(server.layer));
11091107
});
11101108

0 commit comments

Comments
 (0)