@devries-cameron20 / t3code-1 / commits / 6d266ea683
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(server): checkpoints skip a project folder its parent repo ignores (#14892)

Co-authored-by: Julius Marminge <julius0216@outlook.com>

Jonas B. committed Oct 19, 2026 at 19:28 UTC 6d266ea683ecc46c17aed5d68a093221be093862
4 files changed +252 -10
apps/server/src/orchestration-v2/CheckpointService.test.ts
+78
@@ -8,6 +8,7 @@ import {
8 ThreadId,
9 type OrchestrationV2CheckpointScope,
10 VcsProcessTimeoutError,
11 + VcsUnsupportedOperationError,
12 } from "@t3tools/contracts";
13 import * as DateTime from "effect/DateTime";
14 import * as Effect from "effect/Effect";
@@ -103,3 +104,80 @@ it.effect.each([false, true, "interrupt"] as const)(
104 }).pipe(Effect.provide(layerTest));
105 },
106 );
107 +
108 +it.effect(
109 + "skips unsupported baseline and turn checkpoints without swallowing capture failures",
110 + () =>
111 + Effect.gen(function* () {
112 + const scope: OrchestrationV2CheckpointScope = {
113 + id: CheckpointScopeId.make("checkpoint-scope:capture-failure"),
114 + threadId: ThreadId.make("thread:capture-failure"),
115 + runId: RunId.make("run:capture-failure:1"),
116 + nodeId: NodeId.make("node:capture-failure:1"),
117 + parentScopeId: null,
118 + providerThreadId: ProviderThreadId.make("provider-thread:capture-failure"),
119 + kind: "root_run",
120 + ordinalWithinParent: 0,
121 + advancesAppRunCount: true,
122 + cwd: "/repo/ignored",
123 + createdAt: DateTime.makeUnsafe("2026-07-28T00:00:00.000Z"),
124 + };
125 + for (const captureError of [
126 + new VcsProcessTimeoutError({
127 + operation: "test.capture",
128 + command: "git",
129 + cwd: scope.cwd,
130 + timeoutMs: 30000,
131 + }),
132 + new VcsUnsupportedOperationError({
133 + operation: "test.capture",
134 + kind: "git",
135 + detail: "The workspace directory is ignored by its Git repository.",
136 + }),
137 + ]) {
138 + const layerTest = CheckpointService.layer.pipe(
139 + Layer.provide(
140 + Layer.mergeAll(
141 + IdAllocator.layer,
142 + Layer.mock(CheckpointStore.CheckpointStore)({
143 + isGitRepository: () => Effect.succeed(true),
144 + hasCheckpointRef: () => Effect.succeed(false),
145 + captureCheckpoint: () => Effect.fail(captureError),
146 + }),
147 + ),
148 + ),
149 + Layer.provideMerge(NodeCrypto.layer),
150 + );
151 + yield* Effect.gen(function* () {
152 + const checkpoints = yield* CheckpointService.CheckpointServiceV2;
153 + const baseline = yield* Effect.result(
154 + checkpoints.captureBaseline({ scope, ordinalWithinScope: 0 }),
155 + );
156 + const checkpoint = yield* checkpoints.capture({
157 + scope,
158 + ordinalWithinScope: 1,
159 + runId: scope.runId!,
160 + nodeId: scope.nodeId!,
161 + appRunOrdinal: 1,
162 + capturedAt: scope.createdAt,
163 + });
164 +
165 + assert.deepEqual(
166 + { baseline: baseline._tag, turn: checkpoint.status, files: checkpoint.files },
167 + captureError._tag === "VcsUnsupportedOperationError"
168 + ? { baseline: "Success", turn: "missing", files: [] }
169 + : { baseline: "Failure", turn: "error", files: [] },
170 + );
171 + if (baseline._tag === "Failure") {
172 + assert.strictEqual(baseline.failure.cause, captureError);
173 + } else {
174 + const materialized = yield* checkpoints.materializeBaselineCheckpoint({
175 + scope,
176 + ordinalWithinScope: 0,
177 + });
178 + assert.strictEqual(materialized.status, "missing");
179 + }
180 + }).pipe(Effect.provide(layerTest));
181 + }
182 + }),
183 +);
apps/server/src/orchestration-v2/CheckpointService.ts
+18 -9
@@ -284,10 +284,16 @@ export const layer: Layer.Layer<
284 return;
285 }
286
287 - yield* checkpointStore.captureCheckpoint({
288 - cwd: input.scope.cwd,
289 - checkpointRef,
290 - });
287 + yield* checkpointStore
288 + .captureCheckpoint({
289 + cwd: input.scope.cwd,
290 + checkpointRef,
291 + })
292 + .pipe(
293 + Effect.catchTags({
294 + VcsUnsupportedOperationError: () => Effect.void,
295 + }),
296 + );
297 }),
298 ).pipe(
299 Effect.mapError(
@@ -394,23 +400,26 @@ export const layer: Layer.Layer<
400 });
401 }
402
397 - const captured = yield* checkpointStore
403 + const captureStatus = yield* checkpointStore
404 .captureCheckpoint({
405 cwd: input.scope.cwd,
406 checkpointRef,
407 })
408 .pipe(
403 - Effect.as(true),
409 + Effect.as("ready" as const),
410 + Effect.catchTags({
411 + VcsUnsupportedOperationError: () => Effect.succeed("missing" as const),
412 + }),
413 Effect.catch((cause) =>
414 Effect.logWarning("orchestration V2 checkpoint capture failed", {
415 scopeId: input.scope.id,
416 checkpointRef,
417 cause: String(cause),
409 - }).pipe(Effect.as(false)),
418 + }).pipe(Effect.as("error" as const)),
419 ),
420 );
421
413 - if (!captured) {
422 + if (captureStatus !== "ready") {
423 return makeCheckpoint({
424 id: checkpointId,
425 scope: input.scope,
@@ -420,7 +429,7 @@ export const layer: Layer.Layer<
429 ordinalWithinScope: input.ordinalWithinScope,
430 appRunOrdinal: input.appRunOrdinal,
431 ref: checkpointRef,
423 - status: "error",
432 + status: captureStatus,
433 files: [],
434 capturedAt: input.capturedAt,
435 });
apps/server/src/vcs/GitVcsDriver.test.ts
+95
@@ -264,6 +264,9 @@ it.effect("checkpoint capture still fails when a clean filter rejects a file", (
264 );
265
266 assert.strictEqual(result._tag, "Failure");
267 + if (result._tag === "Failure") {
268 + assert.strictEqual(result.failure._tag, "VcsProcessExitError");
269 + }
270 assert.deepEqual(yield* fileSystem.readFile(path.join(cwd, ".git", "index")), originalIndex);
271 assert.isFalse(yield* driver.checkpoints.hasCheckpointRef({ cwd, checkpointRef }));
272 }).pipe(Effect.scoped, Effect.provide(layerGitContract)),
@@ -299,6 +302,98 @@ it.effect("checkpoint capture refuses a truncated nested repository listing", ()
302 }).pipe(Effect.scoped, Effect.provide(layerGitContract)),
303 );
304
305 +it.effect("checkpoint capture skips an ignored project while keeping its allowed sibling", () =>
306 + Effect.gen(function* () {
307 + const fs = yield* FileSystem.FileSystem;
308 + const path = yield* Path.Path;
309 + const driver = yield* GitVcsDriver.makeVcsDriverShape();
310 + const parent = yield* fs.makeTempDirectoryScoped({ prefix: "t3-checkpoint-ignored-" });
311 + const { git } = yield* makeCheckpointFixture(driver, parent);
312 + yield* fs.writeFileString(
313 + path.join(parent, ".gitignore"),
314 + "*\n!.gitignore\n!file.txt\n!keep/\n!keep/**\n",
315 + );
316 + const ignoredCwd = path.join(parent, "ignored");
317 + const keepCwd = path.join(parent, "keep");
318 + yield* fs.makeDirectory(ignoredCwd);
319 + yield* fs.makeDirectory(keepCwd);
320 + yield* fs.writeFileString(path.join(ignoredCwd, "secret.txt"), "private\n");
321 + yield* fs.writeFileString(path.join(keepCwd, "new.txt"), "new\n");
322 + const originalIndex = yield* fs.readFile(path.join(parent, ".git", "index"));
323 + const ignoredRef = CheckpointRef.make("refs/t3/checkpoints/ignored");
324 + const keepRef = CheckpointRef.make("refs/t3/checkpoints/keep");
325 +
326 + const ignored = yield* Effect.result(
327 + driver.checkpoints.captureCheckpoint({ cwd: ignoredCwd, checkpointRef: ignoredRef }),
328 + );
329 + yield* driver.checkpoints.captureCheckpoint({ cwd: keepCwd, checkpointRef: keepRef });
330 +
331 + assert.strictEqual((yield* git(["show", `${keepRef}:keep/new.txt`])).stdout, "new\n");
332 + assert.strictEqual((yield* git(["ls-tree", "-r", keepRef, "--", "ignored"])).stdout, "");
333 + assert.isFalse(
334 + yield* driver.checkpoints.hasCheckpointRef({ cwd: parent, checkpointRef: ignoredRef }),
335 + );
336 + assert.deepEqual(yield* fs.readFile(path.join(parent, ".git", "index")), originalIndex);
337 + assert.strictEqual(ignored._tag, "Failure");
338 + if (ignored._tag === "Failure") {
339 + assert.strictEqual(ignored.failure._tag, "VcsUnsupportedOperationError");
340 + }
341 + }).pipe(Effect.scoped, Effect.provide(layerGitContract)),
342 +);
343 +
344 +it.effect.each([
345 + { tracking: "committed-only", committed: ["committed.txt"], staged: [] },
346 + { tracking: "staged-only", committed: [], staged: ["staged.txt"] },
347 + { tracking: "mixed", committed: ["committed.txt"], staged: ["staged.txt"] },
348 +])(
349 + "checkpoint capture keeps $tracking tracked edits but excludes new files in a project ignored later",
350 + ({ committed, staged }) =>
351 + Effect.gen(function* () {
352 + const fs = yield* FileSystem.FileSystem;
353 + const path = yield* Path.Path;
354 + const driver = yield* GitVcsDriver.makeVcsDriverShape();
355 + const parent = yield* fs.makeTempDirectoryScoped({ prefix: "t3-checkpoint-ignored-later-" });
356 + const { git, checkpointRef } = yield* makeCheckpointFixture(driver, parent);
357 + const cwd = path.join(parent, "sub");
358 + yield* fs.makeDirectory(cwd);
359 + for (const file of committed) {
360 + yield* fs.writeFileString(path.join(cwd, file), "committed\n");
361 + yield* git(["add", `sub/${file}`]);
362 + }
363 + if (committed.length > 0) {
364 + yield* git(["commit", "-m", "track project"]);
365 + }
366 + for (const file of staged) {
367 + yield* fs.writeFileString(path.join(cwd, file), "staged\n");
368 + yield* git(["add", `sub/${file}`]);
369 + }
370 + const tracked = [...committed, ...staged];
371 + yield* fs.writeFileString(path.join(parent, ".gitignore"), "sub/\n");
372 + for (const file of tracked) {
373 + yield* fs.writeFileString(path.join(cwd, file), `${file} working\n`);
374 + }
375 + yield* fs.writeFileString(path.join(cwd, "secret.txt"), "private\n");
376 + const originalIndex = yield* fs.readFile(path.join(parent, ".git", "index"));
377 +
378 + const captured = yield* Effect.result(
379 + driver.checkpoints.captureCheckpoint({ cwd, checkpointRef }),
380 + );
381 +
382 + assert.deepEqual(yield* fs.readFile(path.join(parent, ".git", "index")), originalIndex);
383 + if (captured._tag === "Failure") return yield* captured.failure;
384 + assert.strictEqual(
385 + (yield* git(["ls-tree", "-r", "--name-only", checkpointRef, "--", "sub"])).stdout,
386 + tracked.map((file) => `sub/${file}\n`).join(""),
387 + );
388 + for (const file of tracked) {
389 + assert.strictEqual(
390 + (yield* git(["show", `${checkpointRef}:sub/${file}`])).stdout,
391 + `${file} working\n`,
392 + );
393 + }
394 + }).pipe(Effect.scoped, Effect.provide(layerGitContract)),
395 +);
396 +
397 it.effect("checkpoint recovery refuses excessive candidates before probing", () =>
398 Effect.gen(function* () {
399 const fs = yield* FileSystem.FileSystem;
apps/server/src/vcs/GitVcsDriver.ts
+61 -1
@@ -13,6 +13,7 @@ import { ChildProcessSpawner } from "effect/process";
13 import {
14 GitCommandError,
15 VcsProcessExitError,
16 + VcsUnsupportedOperationError,
17 type VcsSwitchRefInput,
18 type VcsSwitchRefResult,
19 type VcsCreateRefInput,
@@ -965,6 +966,64 @@ export const makeVcsDriverShape = Effect.fn("makeGitVcsDriverShape")(function* (
966 }
967 }
968
969 + const workspaceIgnored = (yield* filterIgnoredPaths(input.cwd, ["."])).length === 0;
970 + if (workspaceIgnored) {
971 + // HEAD omits staged-only paths. Seed just this workspace's additions, keeping
972 + // unrelated staged changes and the scratch index's sparse flags untouched.
973 + const additions = yield* execute({
974 + operation,
975 + cwd: input.cwd,
976 + args: [
977 + "-c",
978 + "core.quotePath=true",
979 + "diff",
980 + "--cached",
981 + "--raw",
982 + "--no-abbrev",
983 + "--no-renames",
984 + "--no-relative",
985 + "--ignore-submodules=none",
986 + "--no-color",
987 + "--no-ext-diff",
988 + "--no-textconv",
989 + "--ita-visible-in-index",
990 + "--diff-filter=A",
991 + "--",
992 + ".",
993 + ],
994 + maxOutputBytes: WORKSPACE_FILES_MAX_OUTPUT_BYTES,
995 + outputMode: "error",
996 + });
997 + if (additions.stdout.length > 0) {
998 + // Git's quoted paths round-trip through index-info, including non-UTF-8 names.
999 + yield* execute({
1000 + operation,
1001 + cwd: input.cwd,
1002 + args: [...indexConfig, "-c", "index.sparse=false", "update-index", "--index-info"],
1003 + stdin: additions.stdout.replace(
1004 + /^:000000 ([0-7]{6}) 0+ ([0-9a-f]+) A\t/gm,
1005 + "$1 $2\t",
1006 + ),
1007 + env: commitEnv,
1008 + });
1009 + }
1010 + const tracked = yield* execute({
1011 + operation,
1012 + cwd: input.cwd,
1013 + args: [...indexConfig, "ls-files", "--cached", "-z", "--", "."],
1014 + env: commitEnv,
1015 + maxOutputBytes: 1,
1016 + outputMode: "truncate",
1017 + });
1018 + if (tracked.stdout.length === 0) {
1019 + return yield* new VcsUnsupportedOperationError({
1020 + operation,
1021 + kind: "git",
1022 + detail: "The workspace directory is ignored by its Git repository.",
1023 + });
1024 + }
1025 + }
1026 +
1027 const stageFiles = (exclusions: ReadonlyArray<string>) =>
1028 execute({
1029 operation,
@@ -975,7 +1034,8 @@ export const makeVcsDriverShape = Effect.fn("makeGitVcsDriverShape")(function* (
1034 ...longPaths,
1035 "add",
1036 ...(sparseCheckout ? ["--sparse"] : []),
978 - "-A",
1037 + // add -A rejects ignored directories even when they contain tracked files.
1038 + workspaceIgnored ? "-u" : "-A",
1039 "--",
1040 ".",
1041 ...exclusions,