The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 23:30 UTC
fix(server): Git failures no longer record checkpoints as missing (#28957)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Nov 11, 2026 at 11:51 UTC
bff276e786708e2be58c4c6184d4211c08ed80c9
8 files changed
+371
-53
apps/server/src/checkpointing/CheckpointStore.test.ts
+13
@@ -120,6 +120,19 @@ it.layer(layerTest)("CheckpointStore.layer", (it) => {
120
expect(yield* checkpointStore.isGitRepository(nested)).toBe(true);
121
}),
122
);
123
+ it.effect("fails the repository probe that other callers read as no repository", () =>
124
+ Effect.gen(function* () {
125
+ const tmp = yield* makeTmpDir();
126
+ yield* git(tmp, ["init"]);
127
+ yield* writeTextFile(NodePath.join(tmp, ".git", "config"), "invalid config\n");
128
+ const registry = yield* VcsDriverRegistry.VcsDriverRegistry;
129
+ const checkpointStore = yield* CheckpointStore.CheckpointStore;
130
+
131
+ expect(yield* registry.detect({ cwd: tmp })).toBeNull();
132
+ const probe = yield* Effect.flip(checkpointStore.isGitRepository(tmp));
133
+ expect(probe._tag).toBe("VcsProcessExitError");
134
+ }),
135
+ );
136
describe("diffCheckpoints", () => {
137
it.effect("returns full oversized checkpoint diffs without truncation", () =>
138
Effect.gen(function* () {
apps/server/src/checkpointing/CheckpointStore.ts
+8
-4
@@ -85,10 +85,14 @@ export const make = Effect.gen(function* () {
85
return handle.driver.checkpoints satisfies VcsCheckpointOps;
86
});
87
88
- const isGitRepository: CheckpointStore["Service"]["isGitRepository"] = (cwd) =>
89
- vcsRegistry
90
- .detect({ cwd, requestedKind: "git" })
91
- .pipe(Effect.map((repository) => repository !== null));
88
+ // The registry reads an unreadable repository as none; ask Git again so that fails here.
89
+ const isGitRepository: CheckpointStore["Service"]["isGitRepository"] = Effect.fn(
90
+ "CheckpointStore.isGitRepository",
91
+ )(function* (cwd) {
92
+ if ((yield* vcsRegistry.detect({ cwd, requestedKind: "git" })) !== null) return true;
93
+ const git = yield* vcsRegistry.get("git");
94
+ return (yield* git.detectRepository(cwd)) !== null;
95
+ });
96
97
const captureCheckpoint: CheckpointStore["Service"]["captureCheckpoint"] = Effect.fn(
98
"captureCheckpoint",
apps/server/src/orchestration-v2/CheckpointService.test.ts
+60
@@ -7,6 +7,7 @@ import {
7
RunId,
8
ThreadId,
9
type OrchestrationV2CheckpointScope,
10
+ VcsProcessExitError,
11
VcsProcessTimeoutError,
12
VcsUnsupportedOperationError,
13
} from "@t3tools/contracts";
@@ -96,3 +97,62 @@ it.effect(
97
}
98
}),
99
);
100
+
101
+it.effect("records a repository probe failure as an error checkpoint, not a missing one", () =>
102
+ Effect.gen(function* () {
103
+ const scope: OrchestrationV2CheckpointScope = {
104
+ id: CheckpointScopeId.make("checkpoint-scope:probe-failure"),
105
+ threadId: ThreadId.make("thread:probe-failure"),
106
+ runId: RunId.make("run:probe-failure:1"),
107
+ nodeId: NodeId.make("node:probe-failure:1"),
108
+ parentScopeId: null,
109
+ providerThreadId: ProviderThreadId.make("provider-thread:probe-failure"),
110
+ kind: "root_run",
111
+ ordinalWithinParent: 0,
112
+ advancesAppRunCount: true,
113
+ cwd: "/repo/bad-config",
114
+ createdAt: DateTime.makeUnsafe("2026-07-28T00:00:00.000Z"),
115
+ };
116
+ const layerTest = CheckpointService.layer.pipe(
117
+ Layer.provide(
118
+ Layer.mergeAll(
119
+ IdAllocator.layer,
120
+ Layer.mock(CheckpointStore.CheckpointStore)({
121
+ isGitRepository: () =>
122
+ Effect.fail(
123
+ new VcsProcessExitError({
124
+ operation: "GitVcsDriver.detectRepository",
125
+ command: "git",
126
+ cwd: scope.cwd,
127
+ exitCode: 128,
128
+ detail: "fatal: bad config line 1 in file .git/config",
129
+ }),
130
+ ),
131
+ }),
132
+ ),
133
+ ),
134
+ Layer.provideMerge(NodeCrypto.layer),
135
+ );
136
+
137
+ const statuses = yield* Effect.gen(function* () {
138
+ const checkpoints = yield* CheckpointService.CheckpointServiceV2;
139
+ const baseline = yield* checkpoints.materializeBaselineCheckpoint({
140
+ scope,
141
+ ordinalWithinScope: 0,
142
+ nodeId: scope.nodeId,
143
+ capturedAt: scope.createdAt,
144
+ });
145
+ const turn = yield* checkpoints.capture({
146
+ scope,
147
+ ordinalWithinScope: 1,
148
+ runId: scope.runId!,
149
+ nodeId: scope.nodeId!,
150
+ appRunOrdinal: 1,
151
+ capturedAt: scope.createdAt,
152
+ });
153
+ return { baseline: baseline.status, turn: turn.status };
154
+ }).pipe(Effect.provide(layerTest));
155
+
156
+ assert.deepEqual(statuses, { baseline: "error", turn: "error" });
157
+ }),
158
+);
apps/server/src/orchestration-v2/CheckpointService.ts
+39
-24
@@ -247,14 +247,25 @@ export const layer: Layer.Layer<
247
const withWorkspaceLock = <A, E, R>(cwd: string, effect: Effect.Effect<A, E, R>) =>
248
workspaceLocks.withLock(cwd, effect);
249
250
- const isGitCheckpointable = (cwd: string) =>
251
- checkpointStore.isGitRepository(cwd).pipe(Effect.orElseSucceed(() => false));
250
+ // A failed probe is an operational error, not proof that the workspace has no repository.
251
+ const probeRepository = (scope: OrchestrationV2CheckpointScope) =>
252
+ checkpointStore.isGitRepository(scope.cwd).pipe(
253
+ Effect.map((isRepository) =>
254
+ isRepository ? ("repository" as const) : ("missing" as const),
255
+ ),
256
+ Effect.catch((cause) =>
257
+ Effect.logWarning("orchestration V2 checkpoint repository probe failed", {
258
+ scopeId: scope.id,
259
+ cause: String(cause),
260
+ }).pipe(Effect.as("error" as const)),
261
+ ),
262
+ );
263
264
const captureBaseline: CheckpointServiceV2Shape["captureBaseline"] = (input) =>
265
withWorkspaceLock(
266
input.scope.cwd,
267
Effect.gen(function* () {
257
- if (!(yield* isGitCheckpointable(input.scope.cwd))) {
268
+ if (!(yield* checkpointStore.isGitRepository(input.scope.cwd))) {
269
return;
270
}
271
@@ -305,24 +316,26 @@ export const layer: Layer.Layer<
316
scopeId: input.scope.id,
317
ordinalWithinScope: input.ordinalWithinScope,
318
});
308
- const checkpointable =
309
- input.forceMissing !== true && (yield* isGitCheckpointable(input.scope.cwd));
310
- const available = checkpointable
311
- ? yield* checkpointStore
312
- .hasCheckpointRef({
313
- cwd: input.scope.cwd,
314
- checkpointRef,
315
- })
316
- .pipe(
317
- Effect.catch((cause) =>
318
- Effect.logWarning("orchestration V2 baseline ref lookup failed", {
319
- scopeId: input.scope.id,
320
- checkpointRef,
321
- cause: String(cause),
322
- }).pipe(Effect.as(false)),
323
- ),
324
- )
325
- : false;
319
+ const repository =
320
+ input.forceMissing === true ? "missing" : yield* probeRepository(input.scope);
321
+ const status =
322
+ repository === "repository"
323
+ ? yield* checkpointStore
324
+ .hasCheckpointRef({
325
+ cwd: input.scope.cwd,
326
+ checkpointRef,
327
+ })
328
+ .pipe(
329
+ Effect.map((exists) => (exists ? ("ready" as const) : ("missing" as const))),
330
+ Effect.catch((cause) =>
331
+ Effect.logWarning("orchestration V2 baseline ref lookup failed", {
332
+ scopeId: input.scope.id,
333
+ checkpointRef,
334
+ cause: String(cause),
335
+ }).pipe(Effect.as("error" as const)),
336
+ ),
337
+ )
338
+ : repository;
339
return makeCheckpoint({
340
id: checkpointId,
341
scope: input.scope,
@@ -332,7 +345,7 @@ export const layer: Layer.Layer<
345
ordinalWithinScope: input.ordinalWithinScope,
346
appRunOrdinal: null,
347
ref: checkpointRef,
335
- status: available ? "ready" : "missing",
348
+ status,
349
files: [],
350
capturedAt: input.capturedAt,
351
});
@@ -371,7 +384,9 @@ export const layer: Layer.Layer<
384
ordinalWithinScope: Math.max(0, input.ordinalWithinScope - 1),
385
});
386
374
- if (input.forceMissing === true || !(yield* isGitCheckpointable(input.scope.cwd))) {
387
+ const repository =
388
+ input.forceMissing === true ? "missing" : yield* probeRepository(input.scope);
389
+ if (repository !== "repository") {
390
return makeCheckpoint({
391
id: checkpointId,
392
scope: input.scope,
@@ -381,7 +396,7 @@ export const layer: Layer.Layer<
396
ordinalWithinScope: input.ordinalWithinScope,
397
appRunOrdinal: input.appRunOrdinal,
398
ref: checkpointRef,
384
- status: "missing",
399
+ status: repository,
400
files: [],
401
capturedAt: input.capturedAt,
402
});
apps/server/src/vcs/GitVcsDriver.test.ts
+122
@@ -1316,6 +1316,128 @@ it.effect.skipIf(HostProcess.Platform.defaultValue() === "win32")(
1316
}).pipe(Effect.scoped, Effect.provide(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))),
1317
);
1318
1319
+it.effect("GitVcsDriver fails repository probes when git cannot read the repository config", () =>
1320
+ Effect.gen(function* () {
1321
+ const fileSystem = yield* FileSystem.FileSystem;
1322
+ const path = yield* Path.Path;
1323
+ const root = yield* fileSystem.makeTempDirectoryScoped({ prefix: "t3-bad-config-" });
1324
+ // The included file's path appears in Git's message and must not read as "no repository".
1325
+ const includeDir = path.join(root, "not a git repository");
1326
+ yield* fileSystem.makeDirectory(includeDir);
1327
+ yield* fileSystem.writeFileString(path.join(includeDir, "included"), "invalid config\n");
1328
+ const configs = {
1329
+ direct: "invalid config\n",
1330
+ included: `[include]\n\tpath = ${path.join(includeDir, "included")}\n`,
1331
+ };
1332
+ const driver = yield* GitVcsDriver.makeVcsDriverShape();
1333
+ const checkpointRef = CheckpointRef.make("refs/t3/checkpoints/bad-config/0");
1334
+
1335
+ for (const [name, config] of Object.entries(configs)) {
1336
+ const cwd = path.join(root, name);
1337
+ yield* fileSystem.makeDirectory(cwd);
1338
+ yield* runGit(cwd, ["init"]);
1339
+ yield* fileSystem.writeFileString(path.join(cwd, ".git", "config"), config);
1340
+ const outcomes = {
1341
+ isInsideWorkTree: Exit.isFailure(yield* Effect.exit(driver.isInsideWorkTree(cwd))),
1342
+ detectRepository: Exit.isFailure(yield* Effect.exit(driver.detectRepository(cwd))),
1343
+ hasCheckpointRef: Exit.isFailure(
1344
+ yield* Effect.exit(driver.checkpoints.hasCheckpointRef({ cwd, checkpointRef })),
1345
+ ),
1346
+ };
1347
+ assert.deepStrictEqual(
1348
+ outcomes,
1349
+ { isInsideWorkTree: true, detectRepository: true, hasCheckpointRef: true },
1350
+ `a bad ${name} config is an operational failure, not an absent repository or ref`,
1351
+ );
1352
+ }
1353
+ }).pipe(Effect.scoped, Effect.provide(layerGitContract)),
1354
+);
1355
+
1356
+it.effect("GitVcsDriver reports no repository for a deleted cwd or a bare repository", () =>
1357
+ Effect.gen(function* () {
1358
+ const fileSystem = yield* FileSystem.FileSystem;
1359
+ const path = yield* Path.Path;
1360
+ const root = yield* fileSystem.makeTempDirectoryScoped({ prefix: "t3-no-work-tree-" });
1361
+ const bare = path.join(root, "bare.git");
1362
+ yield* fileSystem.makeDirectory(bare);
1363
+ yield* runGit(bare, ["init", "--bare"]);
1364
+ const driver = yield* GitVcsDriver.makeVcsDriverShape();
1365
+
1366
+ for (const cwd of [path.join(root, "deleted"), bare]) {
1367
+ assert.equal(yield* driver.isInsideWorkTree(cwd), false, cwd);
1368
+ assert.equal(yield* driver.detectRepository(cwd), null, cwd);
1369
+ }
1370
+ }).pipe(Effect.scoped, Effect.provide(layerGitContract)),
1371
+);
1372
+
1373
+// Git outputs CI's Git version cannot produce with a real repository.
1374
+const makeStubbedDriver = Effect.fn("test.makeStubbedDriver")(function* (output: {
1375
+ readonly code: number;
1376
+ readonly stdout: string;
1377
+ readonly stderr: string;
1378
+}) {
1379
+ const process = yield* VcsProcess.make.pipe(
1380
+ Effect.provideService(ProcessRunner.ProcessRunner, {
1381
+ run: () =>
1382
+ Effect.succeed({
1383
+ ...output,
1384
+ code: ChildProcessSpawner.ExitCode(output.code),
1385
+ timedOut: false,
1386
+ stdoutTruncated: false,
1387
+ stderrTruncated: false,
1388
+ stdoutInvalidUtf8: false,
1389
+ stderrInvalidUtf8: false,
1390
+ }),
1391
+ }),
1392
+ );
1393
+ return yield* GitVcsDriver.makeVcsDriverShape().pipe(
1394
+ Effect.provideService(VcsProcess.VcsProcess, process),
1395
+ );
1396
+});
1397
+
1398
+it.effect("GitVcsDriver reports no repository when old Git answers false before failing", () =>
1399
+ Effect.gen(function* () {
1400
+ // Git before 2.38 ignores safe.bareRepository, so a bare repo prints "false" and exits 128.
1401
+ const driver = yield* makeStubbedDriver({
1402
+ code: 128,
1403
+ stdout: "false\n",
1404
+ stderr: "fatal: this operation must be run in a work tree\n",
1405
+ });
1406
+
1407
+ assert.equal(yield* driver.detectRepository(globalThis.process.cwd()), null);
1408
+ }).pipe(Effect.provide(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))),
1409
+);
1410
+
1411
+it.effect("GitVcsDriver fails a checkpoint ref lookup when git cannot read its object", () =>
1412
+ Effect.gen(function* () {
1413
+ const driver = yield* makeStubbedDriver({
1414
+ code: 1,
1415
+ stdout: "",
1416
+ stderr: "error: unable to open loose object 0733271782d6: Permission denied\n",
1417
+ });
1418
+ const checkpointRef = CheckpointRef.make("refs/t3/checkpoints/unreadable/0");
1419
+
1420
+ const exit = yield* Effect.exit(
1421
+ driver.checkpoints.hasCheckpointRef({ cwd: globalThis.process.cwd(), checkpointRef }),
1422
+ );
1423
+ assert.isTrue(Exit.isFailure(exit), "an unreadable checkpoint object is not an absent ref");
1424
+ }).pipe(Effect.provide(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))),
1425
+);
1426
+
1427
+it.effect("GitVcsDriver reads an absent checkpoint ref as absent despite a Git warning", () =>
1428
+ Effect.gen(function* () {
1429
+ const fileSystem = yield* FileSystem.FileSystem;
1430
+ const cwd = yield* fileSystem.makeTempDirectoryScoped({ prefix: "t3-git-warning-" });
1431
+ yield* runGit(cwd, ["init"]);
1432
+ // Valid legacy config that makes every Git command print a deprecation warning.
1433
+ yield* runGit(cwd, ["config", "core.fsyncObjectFiles", "true"]);
1434
+ const driver = yield* GitVcsDriver.makeVcsDriverShape();
1435
+ const checkpointRef = CheckpointRef.make("refs/t3/checkpoints/absent/0");
1436
+
1437
+ assert.isFalse(yield* driver.checkpoints.hasCheckpointRef({ cwd, checkpointRef }));
1438
+ }).pipe(Effect.scoped, Effect.provide(layerGitContract)),
1439
+);
1440
+
1441
const gitCommandCount = (operation: string, outcome: string) =>
1442
Metric.value(
1443
Metric.withAttributes(gitCommandsTotal, [
apps/server/src/vcs/GitVcsDriver.ts
+69
-24
@@ -546,6 +546,13 @@ function parseGitRemoteVerboseOutput(
546
return remotes;
547
}
548
549
+// Trace output and deprecation warnings can precede Git's own message, so check every line.
550
+const hasStderrLine = (stderr: string, prefixes: ReadonlyArray<string>) =>
551
+ stderr.split("\n").some((line) => prefixes.some((prefix) => line.startsWith(prefix)));
552
+
553
+/** Operation of the error raised when Git cannot say whether a cwd is a work tree. */
554
+export const WORK_TREE_PROBE_OPERATION = "GitVcsDriver.probeWorkTree";
555
+
556
const gitCommand = Effect.fn("GitVcsDriver.gitCommand")(
557
(
558
process: VcsProcess.VcsProcess["Service"],
@@ -588,21 +595,50 @@ export const makeVcsDriverShape = Effect.fn("makeGitVcsDriverShape")(function* (
595
const vcsProcess = yield* VcsProcess.VcsProcess;
596
const random = yield* SecureRandom.SecureRandom;
597
const hostPlatform = yield* HostProcess.Platform;
598
+ // Returns stdout, or null when there is no work tree. A non-repository exits 128 like a broken
599
+ // one, so only Git's message (pinned to the C locale) or a missing cwd tells them apart.
600
+ const probeWorkTree = Effect.fn("GitVcsDriver.probeWorkTree")(function* (
601
+ operation: string,
602
+ cwd: string,
603
+ args: ReadonlyArray<string>,
604
+ maxOutputBytes: number,
605
+ ) {
606
+ const result = yield* gitCommand(vcsProcess, operation, cwd, args, {
607
+ env: { LC_ALL: "C" },
608
+ allowNonZeroExit: true,
609
+ timeoutMs: 5_000,
610
+ maxOutputBytes,
611
+ }).pipe(Effect.catchIf(isMissingExecutable, () => Effect.succeed(null)));
612
+ if (result === null) return null;
613
+ if (result.exitCode === 0) return result.stdout;
614
+ // Git before 2.38 answers "false" for a bare repo, then fails on --show-toplevel.
615
+ // Match line prefixes only: a path inside a diagnostic may contain the same words.
616
+ if (
617
+ result.stdout.startsWith("false") ||
618
+ hasStderrLine(result.stderr, [
619
+ "fatal: not a git repository",
620
+ "fatal: cannot use bare repository",
621
+ ]) ||
622
+ !(yield* fileSystem.exists(cwd).pipe(Effect.orElseSucceed(() => true)))
623
+ ) {
624
+ return null;
625
+ }
626
+ return yield* new VcsProcessExitError({
627
+ operation: WORK_TREE_PROBE_OPERATION,
628
+ command: "git rev-parse",
629
+ cwd,
630
+ exitCode: result.exitCode,
631
+ detail: result.stderr.trim() || "git rev-parse failed",
632
+ });
633
+ });
634
+
635
const isInsideWorkTree: VcsDriver.VcsDriver["Service"]["isInsideWorkTree"] = (cwd) =>
592
- gitCommand(
593
- vcsProcess,
636
+ probeWorkTree(
637
"GitVcsDriver.isInsideWorkTree",
638
cwd,
639
["rev-parse", "--is-inside-work-tree"],
597
- {
598
- allowNonZeroExit: true,
599
- timeoutMs: 5_000,
600
- maxOutputBytes: 4_096,
601
- },
602
- ).pipe(
603
- Effect.map((result) => result.exitCode === 0 && result.stdout.trim() === "true"),
604
- Effect.catchIf(isMissingExecutable, () => Effect.succeed(false)),
605
- );
640
+ 4_096,
641
+ ).pipe(Effect.map((stdout) => stdout?.trim() === "true"));
642
643
const execute: VcsDriver.VcsDriver["Service"]["execute"] = (input) =>
644
gitCommand(vcsProcess, input.operation, input.cwd, input.args, {
@@ -621,19 +657,14 @@ export const makeVcsDriverShape = Effect.fn("makeGitVcsDriverShape")(function* (
657
"detectRepository",
658
)(function* (cwd) {
659
// One spawn answers all three; outside a work tree it exits non-zero or prints "false".
624
- const result = yield* gitCommand(
625
- vcsProcess,
660
+ const stdout = yield* probeWorkTree(
661
"GitVcsDriver.detectRepository",
662
cwd,
663
["rev-parse", "--is-inside-work-tree", "--show-toplevel", "--git-common-dir"],
629
- {
630
- allowNonZeroExit: true,
631
- timeoutMs: 5_000,
632
- maxOutputBytes: 16_384,
633
- },
634
- ).pipe(Effect.catchIf(isMissingExecutable, () => Effect.succeed(null)));
635
- if (result === null || result.exitCode !== 0) return null;
636
- const lines = result.stdout.replace(/\r?\n$/u, "").split(/\r?\n/u);
664
+ 16_384,
665
+ );
666
+ if (stdout === null) return null;
667
+ const lines = stdout.replace(/\r?\n$/u, "").split(/\r?\n/u);
668
if (lines[0]?.trim() !== "true") return null;
669
// A newline inside a path breaks the line framing; ask for each path on its own.
670
if (lines.length !== 3) {
@@ -832,14 +863,28 @@ export const makeVcsDriverShape = Effect.fn("makeGitVcsDriverShape")(function* (
863
operation: "GitVcsDriver.checkpoints.resolveCheckpointCommit",
864
cwd,
865
args: ["rev-parse", "--verify", "--quiet", `${checkpointRef}^{commit}`],
866
+ env: { LC_ALL: "C" },
867
allowNonZeroExit: true,
868
}).pipe(
837
- Effect.map((result) => {
869
+ Effect.flatMap((result) => {
870
+ // --quiet reports an absent ref as exit 1 with no error; an unreadable object also exits 1
871
+ // but reports an error line.
872
+ if (result.exitCode === 1 && !hasStderrLine(result.stderr, ["error:", "fatal:"])) {
873
+ return Effect.succeed(null);
874
+ }
875
if (result.exitCode !== 0) {
839
- return null;
876
+ return Effect.fail(
877
+ new VcsProcessExitError({
878
+ operation: "GitVcsDriver.checkpoints.resolveCheckpointCommit",
879
+ command: "git rev-parse",
880
+ cwd,
881
+ exitCode: result.exitCode,
882
+ detail: result.stderr.trim() || "git rev-parse failed",
883
+ }),
884
+ );
885
}
886
const commit = result.stdout.trim();
842
- return commit.length > 0 ? commit : null;
887
+ return Effect.succeed(commit.length > 0 ? commit : null);
888
}),
889
);
890
apps/server/src/vcs/VcsDriverRegistry.test.ts
+50
@@ -6,6 +6,7 @@ import * as FileSystem from "effect/FileSystem";
6
import * as Layer from "effect/Layer";
7
import * as Path from "effect/Path";
8
import { ChildProcessSpawner } from "effect/process";
9
+import { VcsProcessExitError } from "@t3tools/contracts";
10
11
import * as VcsProcess from "./VcsProcess.ts";
12
import * as VcsProjectConfig from "./VcsProjectConfig.ts";
@@ -128,4 +129,53 @@ describe("VcsDriverRegistry", () => {
129
}).pipe(Effect.provide(makeDiskBackedLayer(repoDir, calls)));
130
}).pipe(Effect.provide(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))),
131
);
132
+ const makeFailingLayer = (detectOutput: VcsProcess.VcsProcessOutput) =>
133
+ Layer.effect(VcsDriverRegistry.VcsDriverRegistry, VcsDriverRegistry.make).pipe(
134
+ Layer.provide(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer)),
135
+ Layer.provide(
136
+ Layer.mock(VcsProjectConfig.VcsProjectConfig)({
137
+ resolveKind: (input) => Effect.succeed(input.requestedKind ?? "auto"),
138
+ }),
139
+ ),
140
+ Layer.provide(
141
+ Layer.mock(VcsProcess.VcsProcess)({
142
+ run: (input) =>
143
+ normalizeGitArgs(input.args).join(" ") === DETECT_COMMAND
144
+ ? Effect.succeed(detectOutput)
145
+ : Effect.fail(
146
+ new VcsProcessExitError({
147
+ operation: input.operation,
148
+ command: "git",
149
+ cwd: input.cwd,
150
+ exitCode: 128,
151
+ detail: "fatal: bad config line 1 in file .git/config",
152
+ }),
153
+ ),
154
+ }),
155
+ ),
156
+ );
157
+
158
+ it.effect("reads only a failed work-tree probe as no repository", () =>
159
+ Effect.gen(function* () {
160
+ const probeFailure = yield* VcsDriverRegistry.VcsDriverRegistry.pipe(
161
+ Effect.flatMap((registry) => registry.detect({ cwd: "/repo" })),
162
+ Effect.provide(
163
+ makeFailingLayer({
164
+ ...processOutput(""),
165
+ exitCode: ChildProcessSpawner.ExitCode(128),
166
+ stderr: "fatal: bad config line 1 in file .git/config",
167
+ }),
168
+ ),
169
+ );
170
+ assert.equal(probeFailure, null);
171
+
172
+ // A newline in the root path makes detection ask for it again, and main surfaced that failure.
173
+ const fallbackFailure = yield* VcsDriverRegistry.VcsDriverRegistry.pipe(
174
+ Effect.flatMap((registry) => registry.detect({ cwd: "/repo" })),
175
+ Effect.provide(makeFailingLayer(processOutput("true\n/re\npo\n.git\n"))),
176
+ Effect.flip,
177
+ );
178
+ assert.equal(fallbackFailure._tag, "VcsProcessExitError");
179
+ }),
180
+ );
181
});
apps/server/src/vcs/VcsDriverRegistry.ts
+10
-1
@@ -85,7 +85,16 @@ export const make = Effect.gen(function* () {
85
driver: VcsDriver.VcsDriver["Service"],
86
cwd: string,
87
) {
88
- const repository = yield* driver.detectRepository(cwd);
88
+ // Status, review and source control show a repository Git cannot read as none at all.
89
+ // Checkpoints need the failure, so CheckpointStore asks the driver directly.
90
+ const repository = yield* driver.detectRepository(cwd).pipe(
91
+ Effect.catchTags({
92
+ VcsProcessExitError: (error) =>
93
+ error.operation === GitVcsDriver.WORK_TREE_PROBE_OPERATION
94
+ ? Effect.succeed(null)
95
+ : Effect.fail(error),
96
+ }),
97
+ );
98
if (!repository) {
99
return null;
100
}