From 84c820d95916e737f19d7459d35a95e42a5e8332 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Mon, 23 Nov 2026 21:31:53 +0000 Subject: [PATCH 1/5] test(server): interrupted checkpoint captures leave Git LFS temp files behind Repro for #41680: a capture cut off by interruption or its timeout strands the partial file a git-lfs-style clean filter wrote into .git/lfs/tmp. These tests fail on main. Co-Authored-By: Claude Opus 5.5 --- apps/server/src/vcs/GitVcsDriver.test.ts | 80 ++++++++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/apps/server/src/vcs/GitVcsDriver.test.ts b/apps/server/src/vcs/GitVcsDriver.test.ts index c3b5d4143086..2292b5e891ed 100644 --- a/apps/server/src/vcs/GitVcsDriver.test.ts +++ b/apps/server/src/vcs/GitVcsDriver.test.ts @@ -369,6 +369,86 @@ it.effect.each(["interrupt", "timeout", "success"] as const)( }).pipe(Effect.scoped, Effect.provide(layerGitContract)), ); +it.effect.each(["interrupt", "timeout"] as const)( + "checkpoint staging $0 removes the Git LFS temp files its clean filter wrote", + (stop) => + Effect.gen(function* () { + const fs = yield* FileSystem.FileSystem; + const path = yield* Path.Path; + const driver = yield* GitVcsDriver.makeVcsDriverShape(); + const sandbox = yield* fs.makeTempDirectoryScoped({ prefix: "t3-lfs-checkpoint-" }); + const cwd = path.join(sandbox, "repo"); + yield* fs.makeDirectory(cwd); + const { git, checkpointRef } = yield* makeCheckpointFixture(driver, cwd); + yield* driver.checkpoints.captureCheckpoint({ cwd, checkpointRef }); + const lfsTmp = path.join(cwd, ".git/lfs/tmp"); + yield* fs.makeDirectory(lfsTmp, { recursive: true }); + const otherOperation = path.join(lfsTmp, "owned-by-another-git-lfs"); + yield* fs.writeFileString(otherOperation, "another git-lfs process is hashing this"); + + const connected = Promise.withResolvers(); + const sockets = new Set(); + const server = yield* Effect.acquireRelease( + Effect.sync(() => + NodeNet.createServer((socket) => { + sockets.add(socket); + connected.resolve(); + }), + ), + (server) => + Effect.sync(() => { + for (const socket of sockets) socket.destroy(); + server.close(); + }), + ); + yield* Effect.promise( + () => + new Promise((resolve, reject) => { + server.once("error", reject); + server.listen(0, "127.0.0.1", resolve); + }), + ); + const address = server.address(); + assert.isTrue(address !== null && typeof address !== "string"); + if (address === null || typeof address === "string") return; + // Like git-lfs clean: copy the content into .git/lfs/tmp while hashing, and only + // move or remove that copy once hashing finishes. A killed filter strands it. + const filter = path.join(sandbox, "lfs-clean.cjs"); + yield* fs.writeFileString( + filter, + [ + "const fs = require('node:fs');", + "fs.mkdirSync('.git/lfs/tmp', { recursive: true });", + "fs.writeFileSync('.git/lfs/tmp/' + process.pid, Buffer.alloc(1024 * 1024));", + `const s = require('node:net').connect(${address.port}, '127.0.0.1');`, + "s.resume(); process.stdin.resume();", + "s.on('close', () => process.exit(0));", + ].join("\n"), + ); + yield* git(["config", "filter.lfs.clean", `"${process.execPath}" "${filter}"`]); + yield* git(["config", "filter.lfs.required", "true"]); + yield* fs.writeFileString(path.join(cwd, ".gitattributes"), "*.npz filter=lfs\n"); + yield* fs.writeFileString(path.join(cwd, "weights.npz"), "large untracked data\n"); + + const fiber = yield* driver.checkpoints + .captureCheckpoint({ cwd, checkpointRef }) + .pipe(Effect.exit, Effect.forkScoped); + yield* Effect.promise(() => connected.promise); + if (stop === "interrupt") yield* Fiber.interrupt(fiber); + else yield* TestClock.adjust("30 seconds"); + const result = yield* Fiber.await(fiber); + if (stop === "interrupt") + assert.isTrue(Exit.isFailure(result) && Cause.hasInterruptsOnly(result.cause)); + else assert.isTrue(Exit.isSuccess(result) && Exit.isFailure(result.value)); + + assert.deepEqual(yield* fs.readDirectory(lfsTmp), ["owned-by-another-git-lfs"]); + assert.strictEqual( + yield* fs.readFileString(otherOperation), + "another git-lfs process is hashing this", + ); + }).pipe(Effect.scoped, Effect.provide(layerGitContract)), +); + it.effect.each(["failure", "interrupt"] as const)( "checkpoint publication $0 preserves existing refs and permits retry", (stop) => From b0dfeee3ca7fd4329ab92ffced91911d29812d96 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Mon, 23 Nov 2026 21:38:59 +0000 Subject: [PATCH 2/5] fix(server): cut-off checkpoint captures no longer strand Git LFS temp files git-lfs's clean filter copies each file into .git/lfs/tmp while hashing it. When checkpoint staging timed out or was interrupted, that copy was never removed, so repeated failed captures filled the disk. Staging now notes what .git/lfs/tmp held before it ran and, when it does not succeed, removes only the entries that appeared since. Co-Authored-By: Claude Opus 5.5 --- apps/server/src/vcs/GitVcsDriver.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/apps/server/src/vcs/GitVcsDriver.ts b/apps/server/src/vcs/GitVcsDriver.ts index 3ba545caf97a..cb4278f3e7f4 100644 --- a/apps/server/src/vcs/GitVcsDriver.ts +++ b/apps/server/src/vcs/GitVcsDriver.ts @@ -1558,6 +1558,21 @@ export const makeVcsDriverShape = Effect.fn("makeGitVcsDriverShape")(function* ( () => Effect.void, ), ); + // git-lfs's clean filter copies content here while hashing and strands it when killed. + const lfsTmp = path.join(gitCommonDir, "lfs", "tmp"); + const readLfsTmp = fileSystem.readDirectory(lfsTmp).pipe(Effect.orElseSucceed(() => [])); + const lfsTmpBefore = new Set(yield* readLfsTmp); + const removeStrandedLfsTmp = Effect.gen(function* () { + const stranded = (yield* readLfsTmp).filter((name) => !lfsTmpBefore.has(name)); + yield* Effect.forEach( + stranded, + (name) => + fileSystem + .remove(path.join(lfsTmp, name), { recursive: true, force: true }) + .pipe(Effect.ignore), + { discard: true }, + ); + }); const stagingAt = yield* Clock.currentTimeMillis; yield* stageFiles([]).pipe( Effect.catchTags({ @@ -1614,6 +1629,7 @@ export const makeVcsDriverShape = Effect.fn("makeGitVcsDriverShape")(function* ( }), ), }), + Effect.onExit((exit) => (Exit.isSuccess(exit) ? Effect.void : removeStrandedLfsTmp)), ); const stagingMs = (yield* Clock.currentTimeMillis) - stagingAt; From 8370f092e1ad04487a4c2c3de2e0583a7429724f Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Mon, 23 Nov 2026 21:57:32 +0000 Subject: [PATCH 3/5] fix(server): give checkpoint captures their own Git LFS storage Removing whatever appeared in .git/lfs/tmp during a failed capture also deleted temp files of Git LFS operations that started meanwhile, so those failed. Captures now point lfs.storage at a folder inside their private object directory, which is removed with it, so only the capture's own partial copies go. After a successful capture the LFS objects its filter wrote are moved into the repository's LFS storage. Co-Authored-By: Claude Opus 5.5 --- apps/server/src/vcs/GitVcsDriver.test.ts | 59 +++++++++++++++++-- apps/server/src/vcs/GitVcsDriver.ts | 73 ++++++++++++++++++------ 2 files changed, 112 insertions(+), 20 deletions(-) diff --git a/apps/server/src/vcs/GitVcsDriver.test.ts b/apps/server/src/vcs/GitVcsDriver.test.ts index 2292b5e891ed..b8a7ab0c9548 100644 --- a/apps/server/src/vcs/GitVcsDriver.test.ts +++ b/apps/server/src/vcs/GitVcsDriver.test.ts @@ -411,15 +411,16 @@ it.effect.each(["interrupt", "timeout"] as const)( const address = server.address(); assert.isTrue(address !== null && typeof address !== "string"); if (address === null || typeof address === "string") return; - // Like git-lfs clean: copy the content into .git/lfs/tmp while hashing, and only + // Like git-lfs clean: copy the content into /tmp while hashing, and only // move or remove that copy once hashing finishes. A killed filter strands it. const filter = path.join(sandbox, "lfs-clean.cjs"); yield* fs.writeFileString( filter, [ "const fs = require('node:fs');", - "fs.mkdirSync('.git/lfs/tmp', { recursive: true });", - "fs.writeFileSync('.git/lfs/tmp/' + process.pid, Buffer.alloc(1024 * 1024));", + `const storage = require('node:child_process').execSync('git config --default .git/lfs lfs.storage').toString().trim();`, + "fs.mkdirSync(storage + '/tmp', { recursive: true });", + "fs.writeFileSync(storage + '/tmp/' + process.pid, Buffer.alloc(1024 * 1024));", `const s = require('node:net').connect(${address.port}, '127.0.0.1');`, "s.resume(); process.stdin.resume();", "s.on('close', () => process.exit(0));", @@ -434,6 +435,8 @@ it.effect.each(["interrupt", "timeout"] as const)( .captureCheckpoint({ cwd, checkpointRef }) .pipe(Effect.exit, Effect.forkScoped); yield* Effect.promise(() => connected.promise); + const laterOperation = path.join(lfsTmp, "started-during-capture"); + yield* fs.writeFileString(laterOperation, "another git-lfs process started later"); if (stop === "interrupt") yield* Fiber.interrupt(fiber); else yield* TestClock.adjust("30 seconds"); const result = yield* Fiber.await(fiber); @@ -441,7 +444,10 @@ it.effect.each(["interrupt", "timeout"] as const)( assert.isTrue(Exit.isFailure(result) && Cause.hasInterruptsOnly(result.cause)); else assert.isTrue(Exit.isSuccess(result) && Exit.isFailure(result.value)); - assert.deepEqual(yield* fs.readDirectory(lfsTmp), ["owned-by-another-git-lfs"]); + assert.sameMembers(yield* fs.readDirectory(lfsTmp), [ + "owned-by-another-git-lfs", + "started-during-capture", + ]); assert.strictEqual( yield* fs.readFileString(otherOperation), "another git-lfs process is hashing this", @@ -449,6 +455,51 @@ it.effect.each(["interrupt", "timeout"] as const)( }).pipe(Effect.scoped, Effect.provide(layerGitContract)), ); +it.effect("checkpoint staging moves Git LFS objects its clean filter wrote into LFS storage", () => + Effect.gen(function* () { + const fs = yield* FileSystem.FileSystem; + const path = yield* Path.Path; + const driver = yield* GitVcsDriver.makeVcsDriverShape(); + const sandbox = yield* fs.makeTempDirectoryScoped({ prefix: "t3-lfs-checkpoint-" }); + const cwd = path.join(sandbox, "repo"); + yield* fs.makeDirectory(cwd); + const { git, checkpointRef } = yield* makeCheckpointFixture(driver, cwd); + // Like git-lfs clean: hash through /tmp, then move the copy into objects. + const filter = path.join(sandbox, "lfs-clean.cjs"); + yield* fs.writeFileString( + filter, + [ + "const fs = require('node:fs');", + `const storage = require('node:child_process').execSync('git config --default .git/lfs lfs.storage').toString().trim();`, + "const content = fs.readFileSync(0);", + "const oid = require('node:crypto').createHash('sha256').update(content).digest('hex');", + "fs.mkdirSync(storage + '/tmp', { recursive: true });", + "const dir = storage + '/objects/' + oid.slice(0, 2) + '/' + oid.slice(2, 4);", + "fs.mkdirSync(dir, { recursive: true });", + "fs.writeFileSync(storage + '/tmp/' + process.pid, content);", + "fs.renameSync(storage + '/tmp/' + process.pid, dir + '/' + oid);", + "process.stdout.write('oid sha256:' + oid + '\\n');", + ].join("\n"), + ); + yield* git(["config", "filter.lfs.clean", `"${process.execPath}" "${filter}"`]); + yield* git(["config", "filter.lfs.required", "true"]); + yield* fs.writeFileString(path.join(cwd, ".gitattributes"), "*.npz filter=lfs\n"); + yield* fs.writeFileString(path.join(cwd, "weights.npz"), "large untracked data\n"); + + yield* driver.checkpoints.captureCheckpoint({ cwd, checkpointRef }); + + const pointer = yield* git(["show", `${checkpointRef}:weights.npz`]); + const oid = pointer.stdout.trim().slice("oid sha256:".length); + assert.strictEqual( + yield* fs.readFileString( + path.join(cwd, ".git/lfs/objects", oid.slice(0, 2), oid.slice(2, 4), oid), + ), + "large untracked data\n", + ); + assert.isFalse(yield* fs.exists(path.join(cwd, ".git/lfs/tmp"))); + }).pipe(Effect.scoped, Effect.provide(layerGitContract)), +); + it.effect.each(["failure", "interrupt"] as const)( "checkpoint publication $0 preserves existing refs and permits retry", (stop) => diff --git a/apps/server/src/vcs/GitVcsDriver.ts b/apps/server/src/vcs/GitVcsDriver.ts index cb4278f3e7f4..38a22d38462d 100644 --- a/apps/server/src/vcs/GitVcsDriver.ts +++ b/apps/server/src/vcs/GitVcsDriver.ts @@ -1259,6 +1259,60 @@ export const makeVcsDriverShape = Effect.fn("makeGitVcsDriverShape")(function* ( ), ), ); + // git-lfs's clean filter copies each file into /tmp while hashing it and strands + // that copy when killed. Give it storage that is removed with the capture's private objects. + const privateLfs = path.join(privateObjects, "lfs"); + const publishLfsObjects = Effect.gen(function* () { + const source = path.join(privateLfs, "objects"); + const objects = (yield* fileSystem + .readDirectory(source, { recursive: true }) + .pipe(Effect.orElseSucceed(() => []))).filter((entry) => + /^[0-9a-f]{2}[\\/][0-9a-f]{2}[\\/][0-9a-f]{64}$/.test(entry), + ); + if (objects.length === 0) return; + const configured = yield* execute({ + operation, + cwd: input.cwd, + args: ["config", "--get", "lfs.storage"], + allowNonZeroExit: true, + }); + // git-lfs resolves a relative lfs.storage against the common Git directory. + const storage = path.resolve(gitCommonDir, configured.stdout.trim() || "lfs"); + yield* Effect.forEach( + objects, + (entry) => + Effect.gen(function* () { + const from = path.join(source, entry); + const to = path.join(storage, "objects", entry); + if (yield* fileSystem.exists(to)) return; + yield* fileSystem.makeDirectory(path.dirname(to), { recursive: true }); + // Identical oids are interchangeable, so losing a race to another writer is fine. + // lfs.storage may be on another volume, where only a copy can move the object. + const partial = `${to}.${indexId}`; + yield* fileSystem.rename(from, to).pipe( + Effect.catch((cause) => + Effect.flatMap(fileSystem.exists(to), (exists) => + exists + ? Effect.void + : fileSystem.copyFile(from, partial).pipe( + Effect.andThen(fileSystem.rename(partial, to)), + Effect.ensuring( + fileSystem.remove(partial, { force: true }).pipe(Effect.ignore), + ), + Effect.mapError(() => cause), + ), + ), + ), + ); + }), + { concurrency: 16, discard: true }, + ).pipe( + Effect.mapError( + (cause) => + new VcsCheckpointStorageError({ operation, cwd: input.cwd, stage: "publish", cause }), + ), + ); + }); const commitEnv: NodeJS.ProcessEnv = { GIT_INDEX_FILE: tempIndexPath, GIT_OBJECT_DIRECTORY: privateObjects, @@ -1272,6 +1326,8 @@ export const makeVcsDriverShape = Effect.fn("makeGitVcsDriverShape")(function* ( GIT_AUTHOR_EMAIL: "t3code@users.noreply.github.com", GIT_COMMITTER_NAME: "T3 Code", GIT_COMMITTER_EMAIL: "t3code@users.noreply.github.com", + // Any command on the scratch index can run the clean filter, not just add. + ...VcsProcess.gitConfigEnv(hostEnv, "lfs.storage", privateLfs, hostPlatform), }; const cleanupTempIndex = Effect.forEach( @@ -1558,21 +1614,6 @@ export const makeVcsDriverShape = Effect.fn("makeGitVcsDriverShape")(function* ( () => Effect.void, ), ); - // git-lfs's clean filter copies content here while hashing and strands it when killed. - const lfsTmp = path.join(gitCommonDir, "lfs", "tmp"); - const readLfsTmp = fileSystem.readDirectory(lfsTmp).pipe(Effect.orElseSucceed(() => [])); - const lfsTmpBefore = new Set(yield* readLfsTmp); - const removeStrandedLfsTmp = Effect.gen(function* () { - const stranded = (yield* readLfsTmp).filter((name) => !lfsTmpBefore.has(name)); - yield* Effect.forEach( - stranded, - (name) => - fileSystem - .remove(path.join(lfsTmp, name), { recursive: true, force: true }) - .pipe(Effect.ignore), - { discard: true }, - ); - }); const stagingAt = yield* Clock.currentTimeMillis; yield* stageFiles([]).pipe( Effect.catchTags({ @@ -1629,7 +1670,6 @@ export const makeVcsDriverShape = Effect.fn("makeGitVcsDriverShape")(function* ( }), ), }), - Effect.onExit((exit) => (Exit.isSuccess(exit) ? Effect.void : removeStrandedLfsTmp)), ); const stagingMs = (yield* Clock.currentTimeMillis) - stagingAt; @@ -1807,6 +1847,7 @@ export const makeVcsDriverShape = Effect.fn("makeGitVcsDriverShape")(function* ( }); } + yield* publishLfsObjects; // Git writers have exited; bound publication by fanout directory. yield* fileSystem.readDirectory(privateObjects).pipe( Effect.flatMap((directories) => From 84ffcf0e63acbe57fcf2bbda2ddcf2ce5d4b7f6e Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Mon, 23 Nov 2026 22:24:57 +0000 Subject: [PATCH 4/5] test(server): keep the LFS stand-in filter clear of a machine-wide git-lfs A global git-lfs install sets filter.lfs.process, which Git prefers over the tests' filter.lfs.clean stand-in, so on such machines the real git-lfs ran instead and the cut-off tests waited forever. The stand-in now uses its own filter driver name. Co-Authored-By: Claude Opus 5.5 --- apps/server/src/vcs/GitVcsDriver.test.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/apps/server/src/vcs/GitVcsDriver.test.ts b/apps/server/src/vcs/GitVcsDriver.test.ts index b8a7ab0c9548..b65feebc4f6d 100644 --- a/apps/server/src/vcs/GitVcsDriver.test.ts +++ b/apps/server/src/vcs/GitVcsDriver.test.ts @@ -426,9 +426,10 @@ it.effect.each(["interrupt", "timeout"] as const)( "s.on('close', () => process.exit(0));", ].join("\n"), ); - yield* git(["config", "filter.lfs.clean", `"${process.execPath}" "${filter}"`]); - yield* git(["config", "filter.lfs.required", "true"]); - yield* fs.writeFileString(path.join(cwd, ".gitattributes"), "*.npz filter=lfs\n"); + // Not "lfs": a machine-wide git-lfs install sets filter.lfs.process, which wins over clean. + yield* git(["config", "filter.lfs-standin.clean", `"${process.execPath}" "${filter}"`]); + yield* git(["config", "filter.lfs-standin.required", "true"]); + yield* fs.writeFileString(path.join(cwd, ".gitattributes"), "*.npz filter=lfs-standin\n"); yield* fs.writeFileString(path.join(cwd, "weights.npz"), "large untracked data\n"); const fiber = yield* driver.checkpoints @@ -481,9 +482,10 @@ it.effect("checkpoint staging moves Git LFS objects its clean filter wrote into "process.stdout.write('oid sha256:' + oid + '\\n');", ].join("\n"), ); - yield* git(["config", "filter.lfs.clean", `"${process.execPath}" "${filter}"`]); - yield* git(["config", "filter.lfs.required", "true"]); - yield* fs.writeFileString(path.join(cwd, ".gitattributes"), "*.npz filter=lfs\n"); + // Not "lfs": a machine-wide git-lfs install sets filter.lfs.process, which wins over clean. + yield* git(["config", "filter.lfs-standin.clean", `"${process.execPath}" "${filter}"`]); + yield* git(["config", "filter.lfs-standin.required", "true"]); + yield* fs.writeFileString(path.join(cwd, ".gitattributes"), "*.npz filter=lfs-standin\n"); yield* fs.writeFileString(path.join(cwd, "weights.npz"), "large untracked data\n"); yield* driver.checkpoints.captureCheckpoint({ cwd, checkpointRef }); From 56122b01576ec0fd1d06a860aae42d1d8c090ba7 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Mon, 23 Nov 2026 22:59:09 +0000 Subject: [PATCH 5/5] fix(server): a capture that cannot list its LFS objects fails instead of dropping them Only a missing private LFS object folder means the filter wrote nothing. Any other read failure used to look the same, so the checkpoint was published while the private folder holding the only copy was removed. It now fails the capture with a publish storage error. Co-Authored-By: Claude Opus 5.5 --- apps/server/src/vcs/GitVcsDriver.test.ts | 48 ++++++++++++++++++++++++ apps/server/src/vcs/GitVcsDriver.ts | 21 ++++++++--- 2 files changed, 64 insertions(+), 5 deletions(-) diff --git a/apps/server/src/vcs/GitVcsDriver.test.ts b/apps/server/src/vcs/GitVcsDriver.test.ts index 5576c6519299..3e0e89f7c4fa 100644 --- a/apps/server/src/vcs/GitVcsDriver.test.ts +++ b/apps/server/src/vcs/GitVcsDriver.test.ts @@ -502,6 +502,54 @@ it.effect("checkpoint staging moves Git LFS objects its clean filter wrote into }).pipe(Effect.scoped, Effect.provide(layerGitContract)), ); +it.effect("checkpoint capture fails instead of dropping Git LFS objects it cannot list", () => + Effect.gen(function* () { + const fs = yield* FileSystem.FileSystem; + const path = yield* Path.Path; + const driver = yield* GitVcsDriver.makeVcsDriverShape(); + const sandbox = yield* fs.makeTempDirectoryScoped({ prefix: "t3-lfs-checkpoint-" }); + const cwd = path.join(sandbox, "repo"); + yield* fs.makeDirectory(cwd); + const { git, checkpointRef } = yield* makeCheckpointFixture(driver, cwd); + // A file where git-lfs keeps its objects makes the store unreadable without being absent. + const filter = path.join(sandbox, "lfs-clean.cjs"); + yield* fs.writeFileString( + filter, + [ + "const fs = require('node:fs');", + `const storage = require('node:child_process').execSync('git config --default .git/lfs lfs.storage').toString().trim();`, + "fs.readFileSync(0);", + "fs.mkdirSync(storage, { recursive: true });", + "fs.writeFileSync(storage + '/objects', 'not a directory');", + "process.stdout.write('pointer\\n');", + ].join("\n"), + ); + // Not "lfs": a machine-wide git-lfs install sets filter.lfs.process, which wins over clean. + yield* git(["config", "filter.lfs-standin.clean", `"${process.execPath}" "${filter}"`]); + yield* git(["config", "filter.lfs-standin.required", "true"]); + yield* fs.writeFileString(path.join(cwd, ".gitattributes"), "*.npz filter=lfs-standin\n"); + yield* fs.writeFileString(path.join(cwd, "weights.npz"), "large untracked data\n"); + + const result = yield* driver.checkpoints + .captureCheckpoint({ cwd, checkpointRef }) + .pipe(Effect.exit); + + const error = Exit.isFailure(result) ? Cause.findErrorOption(result.cause) : Option.none(); + assert.isTrue( + Option.isSome(error) && + error.value._tag === "VcsCheckpointStorageError" && + error.value.stage === "publish", + ); + const ref = yield* driver.execute({ + operation: "checkpoint-test", + cwd, + args: ["rev-parse", "--verify", "--quiet", checkpointRef], + allowNonZeroExit: true, + }); + assert.strictEqual(ref.exitCode, 1); + }).pipe(Effect.scoped, Effect.provide(layerGitContract)), +); + it.effect.each(["failure", "interrupt"] as const)( "checkpoint publication $0 preserves existing refs and permits retry", (stop) => diff --git a/apps/server/src/vcs/GitVcsDriver.ts b/apps/server/src/vcs/GitVcsDriver.ts index c3f461a990f6..ab32bc7d9e5a 100644 --- a/apps/server/src/vcs/GitVcsDriver.ts +++ b/apps/server/src/vcs/GitVcsDriver.ts @@ -1264,11 +1264,22 @@ export const makeVcsDriverShape = Effect.fn("makeGitVcsDriverShape")(function* ( const privateLfs = path.join(privateObjects, "lfs"); const publishLfsObjects = Effect.gen(function* () { const source = path.join(privateLfs, "objects"); - const objects = (yield* fileSystem - .readDirectory(source, { recursive: true }) - .pipe(Effect.orElseSucceed(() => []))).filter((entry) => - /^[0-9a-f]{2}[\\/][0-9a-f]{2}[\\/][0-9a-f]{64}$/.test(entry), - ); + const objects = (yield* fileSystem.readDirectory(source, { recursive: true }).pipe( + // Absent when no file went through the filter; any other failure must stop publication. + Effect.catchIf( + (cause) => cause.reason._tag === "NotFound", + () => Effect.succeed([]), + ), + Effect.mapError( + (cause) => + new VcsCheckpointStorageError({ + operation, + cwd: input.cwd, + stage: "publish", + cause, + }), + ), + )).filter((entry) => /^[0-9a-f]{2}[\\/][0-9a-f]{2}[\\/][0-9a-f]{64}$/.test(entry)); if (objects.length === 0) return; const configured = yield* execute({ operation,