Skip to content

Commit 5d0db35

Browse files
fix(server): a failed repository probe fails stale checkpoint cleanup
Stale ref cleanup now passes only when neither workspace is a repository, not when the repository probe itself fails. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 9a0e276 commit 5d0db35

2 files changed

Lines changed: 46 additions & 2 deletions

File tree

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

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,49 @@ import { checkpointRestoreRefusal } from "./CheckpointRestoreSafety.ts";
2525
import * as CheckpointService from "./CheckpointService.ts";
2626
import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator";
2727

28+
it.effect("fails stale ref cleanup when the repository probe fails", () => {
29+
const probeError = new VcsProcessTimeoutError({
30+
operation: "test.detect",
31+
command: "git",
32+
cwd: "/repo/a",
33+
timeoutMs: 30000,
34+
});
35+
const layerTest = CheckpointService.layer.pipe(
36+
Layer.provide(
37+
Layer.mergeAll(
38+
IdAllocator.layer,
39+
Layer.mock(CheckpointStore.CheckpointStore)({
40+
isGitRepository: () => Effect.fail(probeError),
41+
}),
42+
),
43+
),
44+
Layer.provideMerge(NodeCrypto.layer),
45+
);
46+
return Effect.gen(function* () {
47+
const checkpoints = yield* CheckpointService.CheckpointServiceV2;
48+
const result = yield* Effect.result(
49+
checkpoints.deleteStaleRefs({
50+
scope: {
51+
id: CheckpointScopeId.make("checkpoint-scope:probe-failure"),
52+
threadId: ThreadId.make("thread:probe-failure"),
53+
runId: RunId.make("run:probe-failure:1"),
54+
nodeId: NodeId.make("node:probe-failure:1"),
55+
parentScopeId: null,
56+
providerThreadId: null,
57+
kind: "root_run",
58+
ordinalWithinParent: 0,
59+
advancesAppRunCount: true,
60+
cwd: "/repo/a",
61+
createdAt: DateTime.makeUnsafe("2026-07-28T00:00:00.000Z"),
62+
},
63+
checkpoints: [],
64+
fallbackCwd: "/repo/b",
65+
}),
66+
);
67+
assert.strictEqual(result._tag, "Failure");
68+
}).pipe(Effect.provide(layerTest));
69+
});
70+
2871
it.effect(
2972
"skips unsupported baseline and turn checkpoints without swallowing capture failures",
3073
() =>

‎apps/server/src/orchestration-v2/CheckpointService.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -556,9 +556,10 @@ export const layer: Layer.Layer<
556556
)(
557557
function* (input) {
558558
// A recreated workspace gets the same scope id, so a surviving stale ref would become its baseline.
559-
const cwd = (yield* isGitCheckpointable(input.scope.cwd))
559+
// A probe failure fails cleanup instead of passing for a removed workspace.
560+
const cwd = (yield* checkpointStore.isGitRepository(input.scope.cwd))
560561
? input.scope.cwd
561-
: (yield* isGitCheckpointable(input.fallbackCwd))
562+
: (yield* checkpointStore.isGitRepository(input.fallbackCwd))
562563
? input.fallbackCwd
563564
: null;
564565
if (cwd === null) {

0 commit comments

Comments
 (0)