GeezerVison is showing github.com — fix(server): checkpoints skip a project folder its parent repo ignores by JonasFocus · Pull Request #14892 · pingdotgg/t3code
fix(server): checkpoints skip a project folder its parent repo ignores
#14892
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and
privacy statement . We’ll occasionally send you account related emails.
Already on GitHub?
Sign in
to your account
Uh oh!
There was an error while loading. Please reload this page.
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter
Filter by extension
.ts
(4)
All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Hide whitespace
Diff view
Hide whitespace
There are no files selected for viewing
Original file line number
Diff line number
Diff line change
Expand Up
@@ -7,6 +7,7 @@ import {
ThreadId,
type OrchestrationV2CheckpointScope,
VcsProcessTimeoutError,
VcsUnsupportedOperationError,
} from "@t3tools/contracts";
import * as DateTime from "effect/DateTime";
import * as Effect from "effect/Effect";
Expand Down
Expand Up
@@ -101,3 +102,53 @@ it.effect.each([false, true, "interrupt"] as const)(
}).pipe(Effect.provide(testLayer));
},
);
it.effect("marks a checkpoint missing when the workspace cannot be checkpointed", () => {
const scope: OrchestrationV2CheckpointScope = {
id: CheckpointScopeId.make("checkpoint-scope:unsupported"),
threadId: ThreadId.make("thread:unsupported"),
runId: RunId.make("run:unsupported:1"),
nodeId: NodeId.make("node:unsupported:1"),
parentScopeId: null,
providerThreadId: ProviderThreadId.make("provider-thread:unsupported"),
kind: "root_run",
ordinalWithinParent: 0,
advancesAppRunCount: true,
cwd: "/repo/ignored",
createdAt: DateTime.makeUnsafe("2026-07-28T00:00:00.000Z"),
};
const testLayer = CheckpointService.layer.pipe(
Layer.provide(
Layer.mergeAll(
IdAllocator.layer,
Layer.mock(CheckpointStore.CheckpointStore)({
isGitRepository: () => Effect.succeed(true),
hasCheckpointRef: () => Effect.succeed(false),
captureCheckpoint: () =>
Effect.fail(
new VcsUnsupportedOperationError({
operation: "test.capture",
kind: "git",
detail: "The workspace directory is ignored by its Git repository.",
}),
),
}),
),
),
);
return Effect.gen(function* () {
const checkpoints = yield* CheckpointService.CheckpointServiceV2;
yield* checkpoints.captureBaseline({ scope, ordinalWithinScope: 0 });
const checkpoint = yield* checkpoints.capture({
scope,
ordinalWithinScope: 1,
runId: scope.runId!,
nodeId: scope.nodeId!,
appRunOrdinal: 1,
capturedAt: scope.createdAt,
});
assert.equal(checkpoint.status, "missing");
}).pipe(Effect.provide(testLayer));
});
Original file line number
Diff line number
Diff line change
Expand Up
@@ -298,10 +298,12 @@ export const layer: Layer.Layer<
return;
}
yield* checkpointStore.captureCheckpoint({
cwd: input.scope.cwd,
checkpointRef,
});
yield* checkpointStore
.captureCheckpoint({
cwd: input.scope.cwd,
checkpointRef,
})
.pipe(Effect.catchTag("VcsUnsupportedOperationError", () => Effect.void));
}),
).pipe(
Effect.mapError(
Expand Down
Expand Up
@@ -408,23 +410,26 @@ export const layer: Layer.Layer<
});
}
const captured = yield* checkpointStore
const captureStatus = yield* checkpointStore
.captureCheckpoint({
cwd: input.scope.cwd,
checkpointRef,
})
.pipe(
Effect.as(true),
Effect.as("ready" as const),
Effect.catchTag("VcsUnsupportedOperationError", () =>
Effect.succeed("missing" as const),
),
Effect.catch((cause) =>
Effect.logWarning("orchestration V2 checkpoint capture failed", {
scopeId: input.scope.id,
checkpointRef,
cause: String(cause),
}).pipe(Effect.as(false )),
}).pipe(Effect.as("error" as const )),
),
);
if (!captured ) {
if (captureStatus !== "ready" ) {
return makeCheckpoint({
id: checkpointId,
scope: input.scope,
Expand All
@@ -434,7 +439,7 @@ export const layer: Layer.Layer<
ordinalWithinScope: input.ordinalWithinScope,
appRunOrdinal: input.appRunOrdinal,
ref: checkpointRef,
status: "error" ,
status: captureStatus ,
files: [],
capturedAt: input.capturedAt,
});
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -245,6 +245,98 @@ it.effect("checkpoint capture refuses a truncated nested repository listing", ()
}).pipe(Effect.scoped, Effect.provide(GitContractLayer)),
);
it.effect("checkpoint capture skips a workspace its parent repository ignores", () =>
Effect.gen(function* () {
const fileSystem = yield* FileSystem.FileSystem;
const path = yield* Path.Path;
const liveProcess = yield* VcsProcess.VcsProcess;
const parent = yield* fileSystem.makeTempDirectoryScoped({ prefix: "t3-checkpoint-ignored-" });
let stageAttempts = 0;
const driver = yield* GitVcsDriver.makeVcsDriverShape().pipe(
Effect.provideService(VcsProcess.VcsProcess, {
run: (input) => {
if (input.args.includes("add")) stageAttempts++;
return liveProcess.run(input);
},
}),
);
const git = (args: ReadonlyArray<string>) =>
driver.execute({ operation: "checkpoint-test", cwd: parent, args });
yield* git(["init"]);
yield* git(["config", "user.name", "Test"]);
yield* git(["config", "user.email", "[email protected] "]);
yield* fileSystem.writeFileString(
path.join(parent, ".gitignore"),
"*\n!.gitignore\n!keep/\n!keep/**\n",
);
yield* fileSystem.makeDirectory(path.join(parent, "keep"));
yield* fileSystem.writeFileString(path.join(parent, "keep", "file.txt"), "v1\n");
yield* fileSystem.makeDirectory(path.join(parent, "ignored"));
yield* fileSystem.writeFileString(path.join(parent, "ignored", "file.txt"), "secret\n");
yield* git(["add", "."]);
yield* git(["commit", "-m", "initial"]);
stageAttempts = 0;
const ignoredRef = CheckpointRef.make("refs/t3/checkpoints/ignored");
const ignored = yield* Effect.result(
driver.checkpoints.captureCheckpoint({
cwd: path.join(parent, "ignored"),
checkpointRef: ignoredRef,
}),
);
assert.strictEqual(ignored._tag, "Failure");
if (ignored._tag === "Failure") {
assert.strictEqual(ignored.failure._tag, "VcsUnsupportedOperationError");
}
assert.strictEqual(stageAttempts, 0);
assert.isFalse(
yield* driver.checkpoints.hasCheckpointRef({ cwd: parent, checkpointRef: ignoredRef }),
);
const keepRef = CheckpointRef.make("refs/t3/checkpoints/keep");
yield* fileSystem.writeFileString(path.join(parent, "keep", "file.txt"), "v2\n");
yield* driver.checkpoints.captureCheckpoint({
cwd: path.join(parent, "keep"),
checkpointRef: keepRef,
});
assert.strictEqual((yield* git(["show", `${keepRef}:keep/file.txt`])).stdout, "v2\n");
}).pipe(Effect.scoped, Effect.provide(GitContractLayer)),
);
it.effect("checkpoint capture stages tracked edits in a directory ignored later", () =>
Effect.gen(function* () {
const fileSystem = yield* FileSystem.FileSystem;
const path = yield* Path.Path;
const driver = yield* GitVcsDriver.makeVcsDriverShape();
const parent = yield* fileSystem.makeTempDirectoryScoped({
prefix: "t3-checkpoint-ignored-later-",
});
const git = (args: ReadonlyArray<string>) =>
driver.execute({ operation: "checkpoint-test", cwd: parent, args });
yield* git(["init"]);
yield* git(["config", "user.name", "Test"]);
yield* git(["config", "user.email", "[email protected] "]);
const cwd = path.join(parent, "sub");
yield* fileSystem.makeDirectory(cwd);
yield* fileSystem.writeFileString(path.join(cwd, "tracked.txt"), "v1\n");
yield* git(["add", "."]);
yield* git(["commit", "-m", "initial"]);
yield* fileSystem.writeFileString(path.join(parent, ".gitignore"), "sub/\n");
yield* fileSystem.writeFileString(path.join(cwd, "tracked.txt"), "v2\n");
yield* fileSystem.writeFileString(path.join(cwd, "new.txt"), "ignored\n");
const checkpointRef = CheckpointRef.make("refs/t3/checkpoints/ignored-later");
yield* driver.checkpoints.captureCheckpoint({ cwd, checkpointRef });
assert.strictEqual(
(yield* git(["ls-tree", "-r", "--name-only", checkpointRef, "--", "sub"])).stdout,
"sub/tracked.txt\n",
);
assert.strictEqual((yield* git(["show", `${checkpointRef}:sub/tracked.txt`])).stdout, "v2\n");
}).pipe(Effect.scoped, Effect.provide(GitContractLayer)),
);
it.effect("checkpoint recovery refuses excessive candidates before probing", () =>
Effect.gen(function* () {
const fs = yield* FileSystem.FileSystem;
Expand Down
Expand Up
@@ -1214,7 +1306,8 @@ it.effect("GitVcsDriver flushes checkpoint objects and refs to disk before publi
? ".git\n"
: "";
return {
exitCode: ChildProcessSpawner.ExitCode(0),
// Like real Git, check-ignore exits 1 when the workspace is not ignored.
exitCode: ChildProcessSpawner.ExitCode(input.args.includes("check-ignore") ? 1 : 0),
stdout,
stderr: "",
stdoutTruncated: false,
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -13,6 +13,7 @@ import { ChildProcessSpawner } from "effect/unstable/process";
import {
GitCommandError,
VcsProcessExitError,
VcsUnsupportedOperationError,
type VcsSwitchRefInput,
type VcsSwitchRefResult,
type VcsCreateRefInput,
Expand Down
Expand Up
@@ -803,6 +804,21 @@ export const makeVcsDriverShape = Effect.fn("makeGitVcsDriverShape")(function* (
"-c",
"sparse.expectFilesOutsideOfPatterns=false",
];
// Git refuses to stage a directory its parent repository ignores, and forcing the add
// would capture the caches and secrets those rules exclude.
const ignored = yield* execute({
operation,
cwd: input.cwd,
args: ["check-ignore", "-q", "--", "."],
allowNonZeroExit: true,
});
if (ignored.exitCode === 0) {
return yield* new VcsUnsupportedOperationError({
operation,
kind: "git",
detail: "The workspace directory is ignored by its Git repository.",
});
}
const gitCommonDir = yield* resolveGitCommonDir(input.cwd);
const tempIndexPath = path.join(
gitCommonDir,
Expand Down
Expand Up
@@ -950,7 +966,7 @@ export const makeVcsDriverShape = Effect.fn("makeGitVcsDriverShape")(function* (
}
}
const stageFiles = (exclusions: ReadonlyArray<string>) =>
const stageFiles = (exclusions: ReadonlyArray<string>, mode: "-A" | "-u" = "-A" ) =>
execute({
operation,
cwd: input.cwd,
Expand All
@@ -960,7 +976,7 @@ export const makeVcsDriverShape = Effect.fn("makeGitVcsDriverShape")(function* (
...durableWrite,
"add",
...(sparseCheckout ? ["--sparse"] : []),
"-A" ,
mode ,
"--",
".",
...exclusions,
Expand All
@@ -981,9 +997,13 @@ export const makeVcsDriverShape = Effect.fn("makeGitVcsDriverShape")(function* (
maxOutputBytes: WORKSPACE_FILES_MAX_OUTPUT_BYTES,
});
if (untracked.stdoutTruncated) return yield* error;
const candidates = splitNullSeparatedGitStdoutPaths(untracked).filter((entry) =>
entry.endsWith("/"),
);
const untrackedPaths = splitNullSeparatedGitStdoutPaths(untracked);
// A tracked directory ignored later fails `add -A` by name. With nothing
// untracked to capture, `add -u` stages exactly what `add -A` would.
if (untrackedPaths.length === 0 && error.retryable !== true) {
return yield* stageFiles([], "-u").pipe(Effect.mapError(() => error));
}
const candidates = untrackedPaths.filter((entry) => entry.endsWith("/"));
// Refuse excessive recovery work before probing any nested repositories.
if (candidates.length > CHECKPOINT_RECOVERY_MAX_CANDIDATES) return yield* error;
// Discover each child's repository instead of inheriting the server's Git bindings.
Expand Down
Loading
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.