The best way to control Claude Code, Codex and more from any computer or phone
fix(server): checkpoints capture workspaces with files the server cannot read (#38862)
Julius Marminge committed
Nov 18, 2026 at 20:33 UTC
3a51807da05203bc2dbfbc489f976e3ba0dc609a
2 files changed
+54
-4
apps/server/src/vcs/GitVcsDriver.test.ts
+42
@@ -744,6 +744,48 @@ it.effect("checkpoint capture skips untracked nested repositories without a comm
744
}).pipe(Effect.scoped, Effect.provide(layerGitContract)),
745
);
746
747
+// Root reads mode-000 files, so the permission failure only exists for other users.
748
+it.effect.skipIf(HostProcess.Platform.defaultValue() === "win32" || process.getuid?.() === 0)(
749
+ "checkpoint capture keeps the indexed version of files it cannot read",
750
+ () =>
751
+ Effect.gen(function* () {
752
+ const fileSystem = yield* FileSystem.FileSystem;
753
+ const path = yield* Path.Path;
754
+ const driver = yield* GitVcsDriver.makeVcsDriverShape();
755
+ const cwd = yield* fileSystem.makeTempDirectoryScoped({
756
+ prefix: "t3-checkpoint-unreadable-",
757
+ });
758
+ const { git, checkpointRef } = yield* makeCheckpointFixture(driver, cwd);
759
+ yield* fileSystem.writeFileString(path.join(cwd, "locked.txt"), "committed\n");
760
+ yield* git(["add", "locked.txt"]);
761
+ yield* git(["commit", "-m", "locked"]);
762
+ yield* fileSystem.writeFileString(path.join(cwd, "locked.txt"), "changed\n");
763
+ yield* fileSystem.writeFileString(path.join(cwd, "secret.txt"), "untracked\n");
764
+ yield* fileSystem.writeFileString(path.join(cwd, "untracked.txt"), "new\n");
765
+ yield* Effect.acquireRelease(
766
+ Effect.all([
767
+ fileSystem.chmod(path.join(cwd, "locked.txt"), 0),
768
+ fileSystem.chmod(path.join(cwd, "secret.txt"), 0),
769
+ ]),
770
+ () =>
771
+ Effect.all([
772
+ fileSystem.chmod(path.join(cwd, "locked.txt"), 0o644),
773
+ fileSystem.chmod(path.join(cwd, "secret.txt"), 0o644),
774
+ ]).pipe(Effect.orDie),
775
+ );
776
+
777
+ yield* driver.checkpoints.captureCheckpoint({ cwd, checkpointRef });
778
+
779
+ assert.strictEqual((yield* git(["show", `${checkpointRef}:file.txt`])).stdout, "unstaged\n");
780
+ assert.strictEqual((yield* git(["show", `${checkpointRef}:untracked.txt`])).stdout, "new\n");
781
+ assert.strictEqual(
782
+ (yield* git(["show", `${checkpointRef}:locked.txt`])).stdout,
783
+ "committed\n",
784
+ );
785
+ assert.strictEqual((yield* git(["ls-tree", checkpointRef, "--", "secret.txt"])).stdout, "");
786
+ }).pipe(Effect.scoped, Effect.provide(layerGitContract)),
787
+);
788
+
789
it.effect.skipIf(!symlinksSupported)(
790
"checkpoint capture writes its index into the real git dir when cwd is a symlinked subdirectory",
791
() =>
apps/server/src/vcs/GitVcsDriver.ts
+12
-4
@@ -1408,7 +1408,7 @@ export const makeVcsDriverShape = Effect.fn("makeGitVcsDriverShape")(function* (
1408
? CheckpointUntrackedBlobs.NOTHING
1409
: yield* untrackedBlobs.reuse({ ...untracked, indexConfig });
1410
1411
- const stageFiles = (exclusions: ReadonlyArray<string>) =>
1411
+ const stageFiles = (exclusions: ReadonlyArray<string>, ignoreErrors = false) =>
1412
execute({
1413
operation,
1414
cwd: input.cwd,
@@ -1420,6 +1420,8 @@ export const makeVcsDriverShape = Effect.fn("makeGitVcsDriverShape")(function* (
1420
"-c",
1421
"core.safecrlf=false",
1422
"add",
1423
+ // Unreadable files keep their indexed version and unreadable new files are left out.
1424
+ ...(ignoreErrors ? ["--ignore-errors"] : []),
1425
...(sparseCheckout ? ["--sparse"] : []),
1426
// add -A rejects ignored directories even when they contain tracked files.
1427
workspaceIgnored ? "-u" : "-A",
@@ -1428,7 +1430,14 @@ export const makeVcsDriverShape = Effect.fn("makeGitVcsDriverShape")(function* (
1430
...exclusions,
1431
],
1432
env: commitEnv,
1431
- });
1433
+ }).pipe(
1434
+ // With --ignore-errors, exit 1 only reports the files it skipped.
1435
+ Effect.catchIf(
1436
+ (error) =>
1437
+ ignoreErrors && error._tag === "VcsProcessExitError" && error.exitCode === 1,
1438
+ () => Effect.void,
1439
+ ),
1440
+ );
1441
const stagingAt = yield* Clock.currentTimeMillis;
1442
yield* stageFiles([]).pipe(
1443
Effect.catchTags({
@@ -1477,8 +1486,7 @@ export const makeVcsDriverShape = Effect.fn("makeGitVcsDriverShape")(function* (
1486
exclusions.push(`:(exclude,literal)${entry}`);
1487
}
1488
}
1480
- if (exclusions.length === 0) return yield* error;
1481
- return yield* stageFiles(exclusions);
1489
+ return yield* stageFiles(exclusions, true);
1490
}).pipe(
1491
Effect.timeoutOrElse({
1492
duration: CHECKPOINT_RECOVERY_TIMEOUT,