The best way to control Claude Code, Codex and more from any computer or phone
fix(server): baseline existing pull request checks when watching (#23522)
Co-authored-by: maria-rcks <maria@kuuro.net> Co-authored-by: Julius Marminge <julius0216@outlook.com>
Vaibhav Pathak committed
Nov 13, 2026 at 04:20 UTC
072254ddd31dfc01b8ae9336a82d7439125e9ac0
6 files changed
+275
-40
apps/server/src/orchestration-v2/Orchestrator.ts
+3
@@ -4709,6 +4709,9 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
4709
passedChecks: existing.endedWatch.passedChecks,
4710
conflicting: existing.endedWatch.conflicting,
4711
}),
4712
+ awaitingBaseline: existing.endedWatch
4713
+ ? existing.endedWatch.awaitingBaseline
4714
+ : "all",
4715
...(existing.endedWatch?.owedChecks !== undefined && {
4716
owedChecks: existing.endedWatch.owedChecks,
4717
}),
apps/server/src/orchestration-v2/PullRequestWatchReactor.ts
+1
@@ -203,6 +203,7 @@ function watchesEqual(left: ThreadPullRequestWatch, right: ThreadPullRequestWatc
203
left.remarkIds.join("\n") === right.remarkIds.join("\n") &&
204
left.conflicting === right.conflicting &&
205
left.wakes === right.wakes &&
206
+ left.awaitingBaseline === right.awaitingBaseline &&
207
left.checksAwaitedSince === right.checksAwaitedSince
208
);
209
}
apps/server/src/orchestration-v2/pullRequestWatch.test.ts
+207
-2
@@ -81,6 +81,203 @@ const remark = (
81
const noRemarks: ReadonlyArray<PullRequestComment> = [];
82
83
describe("evaluatePullRequestWatch", () => {
84
+ it.each([false, true])("baselines already-passed checks (required: %s)", (required) => {
85
+ const green = detail({ checks: [{ ...check("test", "success"), required }] });
86
+ const baseline = evaluatePullRequestWatch(watch({ awaitingBaseline: "all" }), green, noRemarks);
87
+ assert.deepEqual(baseline.changes, []);
88
+ assert.equal(baseline.next.headSha, green.headSha);
89
+ assert.isTrue(baseline.next.passed);
90
+ assert.deepEqual(baseline.next.passedChecks, ["test"]);
91
+ assert.isFalse(baseline.exhausted);
92
+ assert.deepEqual(evaluatePullRequestWatch(baseline.next, green, noRemarks).changes, []);
93
+
94
+ const pending = evaluatePullRequestWatch(
95
+ baseline.next,
96
+ detail({ checks: [{ ...check("test", "pending"), required }] }),
97
+ noRemarks,
98
+ );
99
+ assert.deepEqual(pending.changes, []);
100
+ const failed = evaluatePullRequestWatch(
101
+ pending.next,
102
+ detail({ checks: [{ ...check("test", "failure"), required }] }),
103
+ noRemarks,
104
+ );
105
+ assert.equal(failed.changes[0]?.kind, "checks-failed");
106
+ const passed = evaluatePullRequestWatch(failed.next, green, noRemarks);
107
+ assert.deepEqual(passed.changes, [{ kind: "checks-passed", count: 1, required }]);
108
+ assert.deepEqual(
109
+ evaluatePullRequestWatch(passed.next, { ...green, headSha: "bbbbbbbbbb" }, noRemarks).changes,
110
+ [{ kind: "checks-passed", count: 1, required }],
111
+ );
112
+ });
113
+
114
+ it("baselines existing failures and conflicts, then reports new ones", () => {
115
+ const broken = detail({
116
+ checks: [check("lint", "failure"), check("test", "pending")],
117
+ mergeability: "conflicting",
118
+ });
119
+ const baseline = evaluatePullRequestWatch(
120
+ watch({ awaitingBaseline: "all" }),
121
+ broken,
122
+ noRemarks,
123
+ );
124
+ assert.deepEqual(baseline.changes, []);
125
+ assert.deepEqual(baseline.next.failedChecks, ["lint"]);
126
+ assert.isFalse(baseline.next.passed);
127
+ assert.isTrue(baseline.next.conflicting);
128
+ assert.deepEqual(evaluatePullRequestWatch(baseline.next, broken, noRemarks).changes, []);
129
+
130
+ const failed = evaluatePullRequestWatch(
131
+ baseline.next,
132
+ { ...broken, checks: [check("lint", "failure"), check("test", "failure")] },
133
+ noRemarks,
134
+ );
135
+ assert.deepEqual(failed.changes, [
136
+ { kind: "checks-failed", failed: [check("test", "failure")] },
137
+ ]);
138
+ const clean = evaluatePullRequestWatch(failed.next, detail(), noRemarks);
139
+ assert.deepEqual(clean.changes, []);
140
+ assert.deepEqual(evaluatePullRequestWatch(clean.next, broken, noRemarks).changes, [
141
+ { kind: "checks-failed", failed: [check("lint", "failure")] },
142
+ { kind: "conflicting" },
143
+ ]);
144
+ });
145
+
146
+ it("baselines checks already awaiting approval", () => {
147
+ const gated = detail({ checks: [{ ...check("CI", "action-required"), url: run(1) }] });
148
+ const baseline = evaluatePullRequestWatch(watch({ awaitingBaseline: "all" }), gated, noRemarks);
149
+ assert.deepEqual(baseline.changes, []);
150
+ assert.deepEqual(evaluatePullRequestWatch(baseline.next, gated, noRemarks).changes, []);
151
+ });
152
+
153
+ it("reports remarks after the watch started while baselining checks and conflicts", () => {
154
+ const green = detail({
155
+ checks: [check("test", "success")],
156
+ mergeability: "conflicting",
157
+ });
158
+ const comments = [
159
+ remark("reviewer", "2026-10-02T11:00:00Z"),
160
+ remark("reviewer", "2026-10-02T12:06:00Z"),
161
+ ];
162
+ const baseline = evaluatePullRequestWatch(watch({ awaitingBaseline: "all" }), green, comments);
163
+ assert.deepEqual(baseline.changes, [{ kind: "remarks", remarks: [comments[1]!] }]);
164
+ assert.isTrue(baseline.next.passed);
165
+ assert.isTrue(baseline.next.conflicting);
166
+ assert.equal(baseline.next.wakes, 1);
167
+ assert.deepEqual(evaluatePullRequestWatch(baseline.next, green, comments).changes, []);
168
+ });
169
+
170
+ it("reports a failure once the head SHA appears after a baseline without one", () => {
171
+ const waiting = evaluatePullRequestWatch(
172
+ watch({ awaitingBaseline: "all" }),
173
+ detail({ headSha: undefined, checks: [check("test", "pending")] }),
174
+ noRemarks,
175
+ );
176
+ assert.deepEqual(waiting.changes, []);
177
+ const failed = evaluatePullRequestWatch(
178
+ waiting.next,
179
+ detail({ checks: [check("test", "failure")] }),
180
+ noRemarks,
181
+ );
182
+ assert.deepEqual(failed.changes, [
183
+ { kind: "checks-failed", failed: [check("test", "failure")] },
184
+ ]);
185
+ });
186
+
187
+ it("keeps a baseline taken without a head SHA once the SHA appears", () => {
188
+ const green = detail({ checks: [check("test", "success")] });
189
+ const baseline = evaluatePullRequestWatch(
190
+ watch({ awaitingBaseline: "all" }),
191
+ { ...green, headSha: undefined },
192
+ noRemarks,
193
+ );
194
+ const known = evaluatePullRequestWatch(baseline.next, green, noRemarks);
195
+ assert.deepEqual(known.changes, []);
196
+ assert.equal(known.next.headSha, green.headSha);
197
+ const unknown = evaluatePullRequestWatch(
198
+ known.next,
199
+ { ...green, headSha: undefined },
200
+ noRemarks,
201
+ );
202
+ assert.equal(unknown.next.headSha, green.headSha);
203
+ assert.deepEqual(
204
+ evaluatePullRequestWatch(unknown.next, { ...green, headSha: "bbbbbbbbbb" }, noRemarks)
205
+ .changes,
206
+ [{ kind: "checks-passed", count: 1, required: false }],
207
+ );
208
+ });
209
+
210
+ it.each(["success", "failure"] as const)(
211
+ "reports %s on checks that appear after a first read without any",
212
+ (status) => {
213
+ const empty = evaluatePullRequestWatch(
214
+ watch({ awaitingBaseline: "all" }),
215
+ detail({ checks: [] }),
216
+ noRemarks,
217
+ );
218
+ assert.deepEqual(empty.changes, []);
219
+ assert.isUndefined(empty.next.awaitingBaseline);
220
+ assert.deepEqual(
221
+ evaluatePullRequestWatch(empty.next, detail({ checks: [check("test", status)] }), noRemarks)
222
+ .changes,
223
+ status === "success"
224
+ ? [{ kind: "checks-passed", count: 1, required: false }]
225
+ : [{ kind: "checks-failed", failed: [check("test", "failure")] }],
226
+ );
227
+ },
228
+ );
229
+
230
+ it("keeps the check baseline through a read whose approval lookup failed", () => {
231
+ const bot = check("bot", "success");
232
+ const unavailable = { ...check("Workflow approval status", "pending"), placeholder: true };
233
+ const partial = evaluatePullRequestWatch(
234
+ watch({ awaitingBaseline: "all" }),
235
+ detail({ checks: [bot, unavailable] }),
236
+ noRemarks,
237
+ );
238
+ assert.deepEqual(partial.changes, []);
239
+ assert.equal(partial.next.awaitingBaseline, "checks");
240
+ const approval = { ...check("CI", "action-required"), url: run(1) };
241
+ for (const checks of [[bot], [bot, approval]]) {
242
+ assert.deepEqual(
243
+ evaluatePullRequestWatch(partial.next, detail({ checks }), noRemarks).changes,
244
+ [],
245
+ );
246
+ }
247
+ });
248
+
249
+ it("reports pending advisory checks finishing after a required-check baseline", () => {
250
+ const initial = detail({
251
+ checks: [{ ...check("test", "success"), required: true }, check("bot", "pending")],
252
+ });
253
+ const baseline = evaluatePullRequestWatch(
254
+ watch({ awaitingBaseline: "all" }),
255
+ initial,
256
+ noRemarks,
257
+ );
258
+ assert.deepEqual(baseline.changes, []);
259
+ const settled = evaluatePullRequestWatch(
260
+ baseline.next,
261
+ {
262
+ ...initial,
263
+ checks: [initial.checks[0]!, check("bot", "success")],
264
+ },
265
+ noRemarks,
266
+ );
267
+ assert.deepEqual(settled.changes, [{ kind: "checks-passed", count: 2, required: false }]);
268
+ assert.deepEqual(
269
+ evaluatePullRequestWatch(
270
+ settled.next,
271
+ {
272
+ ...initial,
273
+ checks: [initial.checks[0]!, check("bot", "success")],
274
+ },
275
+ noRemarks,
276
+ ).changes,
277
+ [],
278
+ );
279
+ });
280
+
281
it("waits for workflow approval once, through reads that miss it, until the run finishes", () => {
282
const bot = check("bot", "success");
283
const approval = { ...check("CI", "action-required"), url: run(1) };
@@ -571,14 +768,22 @@ describe("evaluatePullRequestWatch", () => {
768
const unknown = detail({
769
checks: [{ ...check("Workflow approval status", "action-required"), placeholder: true }],
770
});
574
- assert.deepEqual(anHourLater(watch(), unknown).flat(), []);
575
- const unread = evaluate(watch(), unknown, noRemarks, 0);
771
+ const fresh = watch({ awaitingBaseline: "all" });
772
+ assert.deepEqual(anHourLater(fresh, unknown).flat(), []);
773
+ const unread = evaluate(fresh, unknown, noRemarks, 0);
774
assert.deepEqual(
775
evaluate(unread.next, detail({ checks: [] }), noRemarks, 60 * 60_000).changes,
776
[{ kind: "no-checks", minutes: 60 }],
777
);
778
});
779
780
+ it("starts the no-checks clock while a fresh watch awaits its baseline", () => {
781
+ assert.deepEqual(
782
+ anHourLater(watch({ awaitingBaseline: "all" }), detail({ checks: [] })).flat(),
783
+ ["no-checks"],
784
+ );
785
+ });
786
+
787
it("never reports missing checks on a host where an empty list says nothing", () => {
788
const silent = detail({ capabilities: capabilities(false), checks: [] });
789
assert.isTrue(anHourLater(watch(), silent).every((kinds) => kinds.length === 0));
apps/server/src/orchestration-v2/pullRequestWatch.ts
+20
-9
@@ -45,9 +45,10 @@ export function evaluatePullRequestWatch(
45
now: number,
46
): PullRequestWatchReport {
47
const changes: Array<PullRequestWatchChange> = [];
48
- // Azure DevOps omits the head when its iteration read fails; that is not a push.
48
+ // A read without a head says nothing about pushes, so it keeps the last known one.
49
const headSha = detail.headSha ?? watch.headSha;
50
- const headMoved = headSha !== watch.headSha;
50
+ const headMoved = watch.headSha !== null && headSha !== watch.headSha;
51
+ const checksBaseline = watch.awaitingBaseline !== undefined && !headMoved;
52
53
// Hosts can return no checks on read failure; preserve prior state.
54
let failedChecks = headMoved ? [] : watch.failedChecks;
@@ -63,9 +64,11 @@ export function evaluatePullRequestWatch(
64
const awaiting = checks.filter((check) => check.status === "action-required");
65
if (checks.length > 0) {
66
const newlyFailed = failed.filter((check) => !failedChecks.includes(check.name));
66
- if (newlyFailed.length > 0) changes.push({ kind: "checks-failed", failed: newlyFailed });
67
+ if (!checksBaseline && newlyFailed.length > 0) {
68
+ changes.push({ kind: "checks-failed", failed: newlyFailed });
69
+ }
70
if (!approvalAnnounced && awaiting.length > 0) {
68
- changes.push({ kind: "checks-awaiting-approval", checks: awaiting });
71
+ if (!checksBaseline) changes.push({ kind: "checks-awaiting-approval", checks: awaiting });
72
approvalAnnounced = true;
73
}
74
failedChecks = failed.map((check) => check.name);
@@ -125,7 +128,9 @@ export function evaluatePullRequestWatch(
128
checks.every((check) => check.status !== "pending");
129
owedChecks = owed;
130
if (passedNow && (!passed || gateGrew)) {
128
- changes.push({ kind: "checks-passed", count: gate.length, required: required.length > 0 });
131
+ if (!checksBaseline) {
132
+ changes.push({ kind: "checks-passed", count: gate.length, required: required.length > 0 });
133
+ }
134
owedChecks =
135
required.length > 0
136
? checks
@@ -146,9 +151,10 @@ export function evaluatePullRequestWatch(
151
// repository runs no checks at all, nothing waits.
152
let checksAwaitedSince = watch.checksAwaitedSince;
153
if (detail.capabilities.checksAlwaysReport === true) {
149
- const awaitedBefore = headMoved
150
- ? DateTime.formatIso(DateTime.makeUnsafe(now))
151
- : (watch.checksAwaitedSince ?? null);
154
+ const awaitedBefore =
155
+ headMoved || watch.awaitingBaseline === "all"
156
+ ? DateTime.formatIso(DateTime.makeUnsafe(now))
157
+ : (watch.checksAwaitedSince ?? null);
158
checksAwaitedSince = checks.length > 0 ? null : awaitedBefore;
159
const awaitedMs = checksAwaitedSince === null ? 0 : now - Date.parse(checksAwaitedSince);
160
if (!unread && awaitedMs >= PULL_REQUEST_WATCH_NO_CHECKS_MS) {
@@ -179,7 +185,7 @@ export function evaluatePullRequestWatch(
185
186
// Like a failed check, a conflict a push did not resolve is news for the new head.
187
const toldConflict = !headMoved && watch.conflicting;
182
- if (detail.mergeability === "conflicting" && !toldConflict) {
188
+ if (watch.awaitingBaseline !== "all" && detail.mergeability === "conflicting" && !toldConflict) {
189
changes.push({ kind: "conflicting" });
190
}
191
// "unknown" is a host still computing after a push; only a clean answer clears a conflict.
@@ -204,6 +210,11 @@ export function evaluatePullRequestWatch(
210
remarkIds,
211
conflicting,
212
wakes,
213
+ // Only a read that cannot be trusted to show the checks leaves the baseline to the next one.
214
+ ...(checksBaseline &&
215
+ (unread || (detail.headSha === undefined && checks.length === 0)) && {
216
+ awaitingBaseline: "checks" as const,
217
+ }),
218
checksAwaitedSince,
219
},
220
exhausted: commentsOnly && wakes >= PULL_REQUEST_WATCH_WAKE_LIMIT,
apps/server/src/orchestration-v2/runtimeLayer.test.ts
+39
-29
@@ -4020,9 +4020,10 @@ it.layer(layerTest)("OrchestrationV2LayerLive lifecycle", (it) => {
4020
}),
4021
);
4022
4023
- it.effect("wakes once for a state it reported, across a restart and a new watch", () =>
4023
+ it.effect("baselines a new watch across restarts and reports later changes", () =>
4024
Effect.gen(function* () {
4025
const orchestrator = yield* Orchestrator.OrchestratorV2;
4026
+ const worker = yield* EffectWorker.OrchestrationEffectWorkerV2;
4027
const threadId = ThreadId.make("runtime-pull-request-watch-told");
4028
const projectId = ProjectId.make("pr-watch-told-project");
4029
yield* seedProject({
@@ -4097,22 +4098,38 @@ it.layer(layerTest)("OrchestrationV2LayerLive lifecycle", (it) => {
4098
4099
const reactor = yield* PullRequestWatchReactor.make.pipe(Effect.provide(host));
4100
yield* reactor.sweep;
4101
+ yield* worker.drain();
4102
+ assert.deepEqual(yield* summaries, []);
4103
+ const baseline = (yield* orchestrator.getThreadShell(threadId))?.pullRequests?.[0]?.watch;
4104
+ assert.equal(baseline?.headSha, headSha);
4105
+ assert.isTrue(baseline?.passed);
4106
+ assert.deepEqual(baseline?.passedChecks, ["lint", "test"]);
4107
yield* TestClock.adjust("10 minutes");
4108
yield* reactor.sweep;
4102
- assert.deepEqual(yield* summaries, ["#12: checks passed"]);
4109
+ yield* worker.drain();
4110
+ assert.deepEqual(yield* summaries, []);
4111
4112
const restarted = yield* PullRequestWatchReactor.make.pipe(Effect.provide(host));
4113
yield* restarted.sweep;
4114
+ yield* worker.drain();
4115
+ assert.deepEqual(yield* summaries, []);
4116
+
4117
+ headSha = "bbbbbbbbbb";
4118
+ yield* TestClock.adjust("10 minutes");
4119
+ yield* restarted.sweep;
4120
+ yield* worker.drain();
4121
assert.deepEqual(yield* summaries, ["#12: checks passed"]);
4122
4123
yield* watch(false, "stop");
4124
yield* watch(true, "again");
4125
yield* restarted.sweep;
4126
+ yield* worker.drain();
4127
assert.deepEqual(yield* summaries, ["#12: checks passed"]);
4128
4113
- headSha = "bbbbbbbbbb";
4129
+ headSha = "cccccccccc";
4130
yield* TestClock.adjust("10 minutes");
4131
yield* restarted.sweep;
4132
+ yield* worker.drain();
4133
assert.deepEqual(yield* summaries, ["#12: checks passed", "#12: checks passed"]);
4134
yield* watch(false, "end");
4135
}),
@@ -4176,22 +4193,21 @@ it.layer(layerTest)("OrchestrationV2LayerLive lifecycle", (it) => {
4193
dispatchMode: { type: "start_immediately" },
4194
});
4195
}
4196
+ let status: "pending" | "failure" = "pending";
4197
const host = Layer.mergeAll(
4198
NodeServices.layer,
4199
NodeCrypto.layer,
4200
Layer.mock(PullRequestService.PullRequestService)({
4201
detail: (input) =>
4184
- Effect.succeed({
4202
+ Effect.sync(() => ({
4203
...watchedPullRequestDetail({
4204
projectId,
4205
number: input.number,
4206
at: "2026-10-02T12:00:00.000Z",
4207
}),
4208
headSha: `head${input.number}`,
4191
- checks: [
4192
- { name: "test", status: "failure", description: null, url: null, required: true },
4193
- ],
4194
- }),
4209
+ checks: [{ name: "test", status, description: null, url: null, required: true }],
4210
+ })),
4211
activity: () =>
4212
Effect.succeed({
4213
comments: [],
@@ -4205,6 +4221,8 @@ it.layer(layerTest)("OrchestrationV2LayerLive lifecycle", (it) => {
4221
4222
const reactor = yield* PullRequestWatchReactor.make.pipe(Effect.provide(host));
4223
yield* reactor.sweep;
4224
+ status = "failure";
4225
+ yield* reactor.sweep;
4226
const { messages } = yield* orchestrator.getThreadRecords(threadId, ["messages"]);
4227
const wakes = messages.filter((message) => message.notification !== undefined);
4228
const stamps = wakes.map(({ notification }) =>
@@ -4289,7 +4307,6 @@ it.layer(layerTest)("OrchestrationV2LayerLive lifecycle", (it) => {
4307
4308
let remainingStatus: "pending" | "action-required" | "success" = initialStatus;
4309
const approval = initialStatus === "action-required";
4292
- const firstSummary = approval ? "#12: checks await approval" : "#12: checks passed";
4310
const runUrl = "https://github.com/pingdotgg/t3code/actions/runs/123";
4311
const host = Layer.mergeAll(
4312
NodeServices.layer,
@@ -4332,7 +4349,7 @@ it.layer(layerTest)("OrchestrationV2LayerLive lifecycle", (it) => {
4349
yield* TestClock.adjust("10 minutes");
4350
yield* reactor.sweep;
4351
yield* worker.drain();
4335
- assert.deepEqual(yield* summaries, [firstSummary]);
4352
+ assert.deepEqual(yield* summaries, []);
4353
4354
assert.deepEqual(
4355
(yield* orchestrator.getThreadShell(threadId))?.pullRequests?.[0]?.watch?.[
@@ -4344,14 +4361,14 @@ it.layer(layerTest)("OrchestrationV2LayerLive lifecycle", (it) => {
4361
const restarted = yield* PullRequestWatchReactor.make.pipe(Effect.provide(host));
4362
yield* restarted.sweep;
4363
yield* worker.drain();
4347
- assert.deepEqual(yield* summaries, [firstSummary]);
4364
+ assert.deepEqual(yield* summaries, []);
4365
4366
// A new watch on the same pull request knows what the last one told.
4367
yield* watch(false, "stop");
4368
yield* watch(true, "again");
4369
yield* restarted.sweep;
4370
yield* worker.drain();
4354
- assert.deepEqual(yield* summaries, [firstSummary]);
4371
+ assert.deepEqual(yield* summaries, []);
4372
4373
assert.deepEqual(
4374
(yield* orchestrator.getThreadShell(threadId))?.pullRequests?.[0]?.watch?.[
@@ -4363,11 +4380,11 @@ it.layer(layerTest)("OrchestrationV2LayerLive lifecycle", (it) => {
4380
yield* TestClock.adjust("10 minutes");
4381
yield* restarted.sweep;
4382
yield* worker.drain();
4366
- assert.deepEqual(yield* summaries, [firstSummary, "#12: checks passed"]);
4383
+ assert.deepEqual(yield* summaries, ["#12: checks passed"]);
4384
yield* TestClock.adjust("10 minutes");
4385
yield* restarted.sweep;
4386
yield* worker.drain();
4370
- assert.deepEqual(yield* summaries, [firstSummary, "#12: checks passed"]);
4387
+ assert.deepEqual(yield* summaries, ["#12: checks passed"]);
4388
assert.deepEqual(
4389
(yield* orchestrator.getThreadShell(threadId))?.pullRequests?.[0]?.watch?.owedChecks,
4390
[],
@@ -5174,10 +5191,7 @@ it.layer(layerTest)("OrchestrationV2LayerLive lifecycle", (it) => {
5191
assert.deepEqual(held?.remarkIds, initialWatch?.remarkIds);
5192
assert.deepEqual(held?.failedChecks, ["lint"]);
5193
const { messages } = yield* orchestrator.getThreadRecords(threadId, ["messages"]);
5177
- assert.deepEqual(
5178
- messages.map((message) => message.notification?.summary),
5179
- ["#7: checks failed"],
5180
- );
5194
+ assert.deepEqual(messages, []);
5195
yield* TestClock.adjust("1 millis");
5196
recovering = true;
5197
}
@@ -5191,9 +5205,7 @@ it.layer(layerTest)("OrchestrationV2LayerLive lifecycle", (it) => {
5205
messages.flatMap((message) =>
5206
message.notification === undefined ? [] : [message.notification.summary],
5207
),
5194
- incomplete
5195
- ? ["#7: checks failed", "#7: new comments"]
5196
- : ["#7: checks failed, new comments"],
5208
+ ["#7: new comments"],
5209
);
5210
if (mode !== "single page") {
5211
const wake = messages.at(-1);
@@ -5206,7 +5218,7 @@ it.layer(layerTest)("OrchestrationV2LayerLive lifecycle", (it) => {
5218
assert.deepEqual(watch?.remarkIds, [remark.id]);
5219
assert.deepEqual(
5220
{ headSha: watch?.headSha, failedChecks: watch?.failedChecks, wakes: watch?.wakes },
5209
- { headSha: "abc1234def", failedChecks: ["lint"], wakes: incomplete ? 1 : 0 },
5221
+ { headSha: "abc1234def", failedChecks: ["lint"], wakes: 1 },
5222
);
5223
}),
5224
);
@@ -5601,12 +5613,10 @@ it.layer(layerTest)("OrchestrationV2LayerLive lifecycle", (it) => {
5613
});
5614
}
5615
const at = "2026-10-02T12:00:00.000Z";
5604
- const texts = (number: number) =>
5616
+ const readHead = (number: number) =>
5617
orchestrator
5606
- .getThreadRecords(ThreadId.make(`runtime-pull-request-watch-pipeline-${number}`), [
5607
- "messages",
5608
- ])
5609
- .pipe(Effect.map(({ messages }) => messages.map((message) => message.text).join("\n")));
5618
+ .getThreadShell(ThreadId.make(`runtime-pull-request-watch-pipeline-${number}`))
5619
+ .pipe(Effect.map((thread) => thread?.pullRequests?.[0]?.watch?.headSha));
5620
// #21's host answers only after #22 has been read, so waiting on every fingerprint first
5621
// never finishes.
5622
const read22 = yield* Deferred.make<void>();
@@ -5634,8 +5644,8 @@ it.layer(layerTest)("OrchestrationV2LayerLive lifecycle", (it) => {
5644
);
5645
const reactor = yield* PullRequestWatchReactor.make.pipe(Effect.provide(host));
5646
yield* reactor.sweep;
5637
- assert.include(yield* texts(21), "#21");
5638
- assert.include(yield* texts(22), "#22");
5647
+ assert.equal(yield* readHead(21), "abc1234def");
5648
+ assert.equal(yield* readHead(22), "abc1234def");
5649
}),
5650
);
5651
packages/contracts/src/threadPullRequest.ts
+5
@@ -99,6 +99,11 @@ export const ThreadPullRequestWatch = Schema.Struct({
99
conflicting: Schema.Boolean,
100
/** Consecutive comment-only wakes; limited to prevent bot loops. */
101
wakes: NonNegativeInt,
102
+ /**
103
+ * What is already on the pull request is recorded, not reported: conflicts on the first read, and
104
+ * checks on the first read that can be trusted to show them (one with a head and a full check read).
105
+ */
106
+ awaitingBaseline: Schema.optional(Schema.Literals(["all", "checks"])),
107
/**
108
* When the head was first read without any check, until a check shows up or the agent is told
109
* none did. Null once either happened; absent on watches saved before it existed.