Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

CheckpointStore.test.ts

571 lines23.1 KB

1// @effect-diagnostics nodeBuiltinImport:off
2import * as NodePath from "node:path";
3​
4import * as NodeCrypto from "@effect/platform-node/NodeCrypto";
5import * as NodeServices from "@effect/platform-node/NodeServices";
6import { it } from "@effect/vitest";
7import { CheckpointRef, ThreadId, type VcsError } from "@t3tools/contracts";
8import * as HostProcess from "@t3tools/shared/HostProcess";
9import * as Effect from "effect/Effect";
10import * as FileSystem from "effect/FileSystem";
11import * as Layer from "effect/Layer";
12import * as PlatformError from "effect/PlatformError";
13import * as Scope from "effect/Scope";
14import { describe, expect } from "vite-plus/test";
15​
16import * as Base64Url from "effect/encoding/Base64Url";
17import { parseTurnDiffFilesFromNumstat } from "./Diffs.ts";
18import * as CheckpointStore from "./CheckpointStore.ts";
19import * as VcsDriverRegistry from "../vcs/VcsDriverRegistry.ts";
20import * as VcsProcess from "../vcs/VcsProcess.ts";
21import * as ServerConfig from "../config.ts";
22​
23function checkpointRefForThreadTurn(threadId: ThreadId, turnCount: number): CheckpointRef {
24 return CheckpointRef.make(`refs/t3/checkpoints/${Base64Url.encode(threadId)}/turn/${turnCount}`);
26​
27const layerServerConfig = ServerConfig.ServerConfig.layerTest(process.cwd(), {
28 prefix: "t3-checkpoint-store-test-",
29});
30const layerVcsProcessTest = VcsProcess.layer.pipe(
31 Layer.provide(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer)),
32);
33const layerVcsDriverTest = VcsDriverRegistry.layer.pipe(Layer.provide(layerVcsProcessTest));
34const layerCheckpointStoreTest = CheckpointStore.layer.pipe(
35 Layer.provideMerge(layerVcsDriverTest),
36 Layer.provideMerge(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer)),
37);
38const layerTest = layerCheckpointStoreTest.pipe(
39 Layer.provideMerge(layerVcsProcessTest),
40 Layer.provideMerge(layerVcsDriverTest),
41 Layer.provideMerge(layerServerConfig),
42 Layer.provideMerge(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer)),
43);
44​
45function makeTmpDir(
46 prefix = "checkpoint-store-test-",
47): Effect.Effect<string, PlatformError.PlatformError, FileSystem.FileSystem | Scope.Scope> {
48 return Effect.gen(function* () {
49 const fileSystem = yield* FileSystem.FileSystem;
50 return yield* fileSystem.makeTempDirectoryScoped({ prefix });
51 });
53​
54function writeTextFile(
55 filePath: string,
56 contents: string,
57): Effect.Effect<void, PlatformError.PlatformError, FileSystem.FileSystem> {
58 return Effect.gen(function* () {
59 const fileSystem = yield* FileSystem.FileSystem;
60 yield* fileSystem.writeFileString(filePath, contents);
61 });
63​
64function git(
65 cwd: string,
66 args: ReadonlyArray<string>,
67 options: { readonly committedAt?: string; readonly allowNonZeroExit?: boolean } = {},
68): Effect.Effect<string, VcsError, VcsProcess.VcsProcess> {
69 return Effect.gen(function* () {
70 const vcsProcess = yield* VcsProcess.VcsProcess;
71 const result = yield* vcsProcess.run({
72 operation: "CheckpointStore.test.git",
73 command: "git",
74 cwd,
75 args,
76 timeoutMs: 10_000,
77 ...(options.committedAt === undefined
78 ? {}
79 : { env: { ...process.env, GIT_COMMITTER_DATE: options.committedAt } }),
80 ...(options.allowNonZeroExit === undefined
81 ? {}
82 : { allowNonZeroExit: options.allowNonZeroExit }),
83 });
84 return result.stdout.trim();
85 });
87​
88function initRepoWithCommit(
89 cwd: string,
90): Effect.Effect<
91 void,
92 VcsError | PlatformError.PlatformError,
93 VcsProcess.VcsProcess | FileSystem.FileSystem
94> {
95 return Effect.gen(function* () {
96 yield* git(cwd, ["init"]);
97 yield* git(cwd, ["config", "user.email", "test@test.com"]);
98 yield* git(cwd, ["config", "user.name", "Test"]);
99 yield* writeTextFile(NodePath.join(cwd, "README.md"), "# test\n");
100 yield* git(cwd, ["add", "."]);
101 yield* git(cwd, ["commit", "-m", "initial commit"]);
102 });
104​
105function buildLargeText(lineCount = 5_000): string {
106 return Array.from({ length: lineCount }, (_, index) => `line ${String(index).padStart(5, "0")}`)
107 .join("\n")
108 .concat("\n");
110​
111it.layer(layerTest)("CheckpointStore.layer", (it) => {
112 it.effect("detects a nested workspace without its own .git entry", () =>
113 Effect.gen(function* () {
114 const tmp = yield* makeTmpDir();
115 yield* initRepoWithCommit(tmp);
116 const fileSystem = yield* FileSystem.FileSystem;
117 const nested = NodePath.join(tmp, "packages", "nested");
118 yield* fileSystem.makeDirectory(nested, { recursive: true });
119 const checkpointStore = yield* CheckpointStore.CheckpointStore;
120 expect(yield* checkpointStore.isGitRepository(nested)).toBe(true);
121 }),
122 );
123 describe("diffCheckpoints", () => {
124 it.effect("returns full oversized checkpoint diffs without truncation", () =>
125 Effect.gen(function* () {
126 const tmp = yield* makeTmpDir();
127 yield* initRepoWithCommit(tmp);
128 const checkpointStore = yield* CheckpointStore.CheckpointStore;
129 const threadId = ThreadId.make("thread-checkpoint-store");
130 const fromCheckpointRef = checkpointRefForThreadTurn(threadId, 0);
131 const toCheckpointRef = checkpointRefForThreadTurn(threadId, 1);
132​
133 yield* checkpointStore.captureCheckpoint({
134 cwd: tmp,
135 checkpointRef: fromCheckpointRef,
136 });
137 yield* writeTextFile(NodePath.join(tmp, "README.md"), buildLargeText());
138 yield* checkpointStore.captureCheckpoint({
139 cwd: tmp,
140 checkpointRef: toCheckpointRef,
141 });
142​
143 const diff = yield* checkpointStore.diffCheckpoints({
144 cwd: tmp,
145 fromCheckpointRef,
146 toCheckpointRef,
147 ignoreWhitespace: true,
148 });
149​
150 expect(diff).toContain("diff --git");
151 expect(diff).not.toContain("[truncated]");
152 expect(diff).toContain("+line 04999");
153 }),
154 );
155​
156 it.effect("keeps the patch format clients parse when the repository changes it", () =>
157 Effect.gen(function* () {
158 const tmp = yield* makeTmpDir();
159 yield* initRepoWithCommit(tmp);
160 yield* git(tmp, ["config", "diff.noprefix", "true"]);
161 yield* git(tmp, ["config", "diff.suppressBlankEmpty", "true"]);
162 yield* git(tmp, ["config", "diff.submodule", "log"]);
163 const sub = NodePath.join(tmp, "sub");
164 yield* git(tmp, ["init", "sub"]);
165 yield* initRepoWithCommit(sub);
166 const checkpointStore = yield* CheckpointStore.CheckpointStore;
167 const threadId = ThreadId.make("thread-checkpoint-store-noprefix");
168 const fromCheckpointRef = checkpointRefForThreadTurn(threadId, 0);
169 const toCheckpointRef = checkpointRefForThreadTurn(threadId, 1);
170​
171 yield* writeTextFile(NodePath.join(tmp, "README.md"), "# test\n\nbefore\n");
172 yield* checkpointStore.captureCheckpoint({
173 cwd: tmp,
174 checkpointRef: fromCheckpointRef,
175 });
176 yield* writeTextFile(NodePath.join(tmp, "README.md"), "# test\n\nafter\n");
177 yield* git(sub, ["commit", "--allow-empty", "-m", "moved"]);
178 yield* checkpointStore.captureCheckpoint({
179 cwd: tmp,
180 checkpointRef: toCheckpointRef,
181 });
182​
183 const diff = yield* checkpointStore.diffCheckpoints({
184 cwd: tmp,
185 fromCheckpointRef,
186 toCheckpointRef,
187 ignoreWhitespace: false,
188 });
189​
190 expect(diff).toContain("diff --git a/README.md b/README.md");
191 expect(diff).toContain(" # test\n \n-before\n+after\n");
192 expect(diff).toContain("diff --git a/sub b/sub");
193 expect(diff).toContain("+Subproject commit ");
194 }),
195 );
196​
197 it.effect("can hide indentation churn when changes wrap existing lines", () =>
198 Effect.gen(function* () {
199 const tmp = yield* makeTmpDir();
200 yield* initRepoWithCommit(tmp);
201 const checkpointStore = yield* CheckpointStore.CheckpointStore;
202 const threadId = ThreadId.make("thread-checkpoint-store-whitespace");
203 const fromCheckpointRef = checkpointRefForThreadTurn(threadId, 0);
204 const toCheckpointRef = checkpointRefForThreadTurn(threadId, 1);
205​
206 const componentPath = NodePath.join(tmp, "Component.tsx");
207 yield* writeTextFile(
208 componentPath,
209 [
210 "export function View() {",
211 " return (",
212 " <section>",
213 " <h1>Title</h1>",
214 " <p>Body</p>",
215 " </section>",
216 " );",
217 "}",
218 "",
219 ].join("\n"),
220 );
221 yield* checkpointStore.captureCheckpoint({
222 cwd: tmp,
223 checkpointRef: fromCheckpointRef,
224 });
225 yield* writeTextFile(
226 componentPath,
227 [
228 "export function View() {",
229 " return (",
230 " <section>",
231 " {isReady ? (",
232 " <div>",
233 " <h1>Title</h1>",
234 " <p>Body</p>",
235 " </div>",
236 " ) : null}",
237 " </section>",
238 " );",
239 "}",
240 "",
241 ].join("\n"),
242 );
243 yield* checkpointStore.captureCheckpoint({
244 cwd: tmp,
245 checkpointRef: toCheckpointRef,
246 });
247​
248 const normalDiff = yield* checkpointStore.diffCheckpoints({
249 cwd: tmp,
250 fromCheckpointRef,
251 toCheckpointRef,
252 ignoreWhitespace: false,
253 });
254 const whitespaceIgnoredDiff = yield* checkpointStore.diffCheckpoints({
255 cwd: tmp,
256 fromCheckpointRef,
257 toCheckpointRef,
258 ignoreWhitespace: true,
259 });
260​
261 expect(normalDiff).toContain("diff --git");
262 expect(normalDiff).toContain("- <h1>Title</h1>");
263 expect(normalDiff).toContain("+ <h1>Title</h1>");
264 expect(whitespaceIgnoredDiff).toContain("diff --git");
265 expect(whitespaceIgnoredDiff).toContain("+ {isReady ? (");
266 expect(whitespaceIgnoredDiff).toContain("+ <div>");
267 expect(whitespaceIgnoredDiff).not.toContain("- <h1>Title</h1>");
268 expect(whitespaceIgnoredDiff).not.toContain("+ <h1>Title</h1>");
269​
270 for (const ignoreWhitespace of [false, true]) {
271 const numstat = yield* checkpointStore.diffCheckpoints({
272 cwd: tmp,
273 fromCheckpointRef,
274 toCheckpointRef,
275 ignoreWhitespace,
276 format: "numstat",
277 });
278 expect(parseTurnDiffFilesFromNumstat(numstat)).toEqual([
279 {
280 path: "Component.tsx",
281 additions: ignoreWhitespace ? 4 : 6,
282 deletions: ignoreWhitespace ? 0 : 2,
283 },
284 ]);
285 }
286 }),
287 );
288 });
289​
290 describe("checkpoint file summaries", () => {
291 it.effect("counts changes whose full patch exceeds the output limit", () =>
292 Effect.gen(function* () {
293 const tmp = yield* makeTmpDir();
294 yield* initRepoWithCommit(tmp);
295 const checkpointStore = yield* CheckpointStore.CheckpointStore;
296 const threadId = ThreadId.make("large-checkpoint-summary");
297 const fromCheckpointRef = checkpointRefForThreadTurn(threadId, 0);
298 const toCheckpointRef = checkpointRefForThreadTurn(threadId, 1);
299 const filePath = NodePath.join(tmp, "README.md");
300 const lineCount = 20_000;
301 yield* writeTextFile(filePath, `${"before".repeat(50)}\n`.repeat(lineCount));
302 yield* checkpointStore.captureCheckpoint({ cwd: tmp, checkpointRef: fromCheckpointRef });
303 yield* writeTextFile(filePath, `${"after".repeat(60)}\n`.repeat(lineCount));
304 yield* checkpointStore.captureCheckpoint({ cwd: tmp, checkpointRef: toCheckpointRef });
305​
306 const numstat = yield* checkpointStore.diffCheckpoints({
307 cwd: tmp,
308 fromCheckpointRef,
309 toCheckpointRef,
310 ignoreWhitespace: false,
311 format: "numstat",
312 });
313​
314 expect(parseTurnDiffFilesFromNumstat(numstat)).toEqual([
315 { path: "README.md", additions: lineCount, deletions: lineCount },
316 ]);
317 expect(numstat.length).toBeLessThan(100);
318 }),
319 );
320​
321 it.effect("preserves file paths and turn ranges without changing the user index", () =>
322 Effect.gen(function* () {
323 const tmp = yield* makeTmpDir();
324 yield* initRepoWithCommit(tmp);
325 yield* git(tmp, ["config", "diff.renames", "copies"]);
326 const fileSystem = yield* FileSystem.FileSystem;
327 const checkpointStore = yield* CheckpointStore.CheckpointStore;
328 const threadId = ThreadId.make("checkpoint-summary-paths");
329 const baseline = checkpointRefForThreadTurn(threadId, 0);
330 const firstTurn = checkpointRefForThreadTurn(threadId, 1);
331 const secondTurn = checkpointRefForThreadTurn(threadId, 2);
332 const copiedText = Array.from({ length: 20 }, (_, index) => `copy line ${index}\n`).join(
333 "",
334 );
335 const platform = yield* HostProcess.Platform;
336 const renamedPath = platform === "win32" ? "renamed café.txt" : "renamed\tcafé\nname.txt";
337 const addedPath = platform === "win32" ? "new café.txt" : "new\tfile\n名.txt";
338 for (const [path, contents] of Object.entries({
339 "copy-source.txt": copiedText,
340 "deleted.txt": "delete me\n",
341 "rename-old.txt": "before\nkeep one\nkeep two\nkeep three\n",
342 "binary.bin": "\0before",
343 })) {
344 yield* writeTextFile(NodePath.join(tmp, path), contents);
345 }
346 yield* checkpointStore.captureCheckpoint({ cwd: tmp, checkpointRef: baseline });
347​
348 yield* fileSystem.rename(
349 NodePath.join(tmp, "rename-old.txt"),
350 NodePath.join(tmp, renamedPath),
351 );
352 yield* fileSystem.remove(NodePath.join(tmp, "deleted.txt"));
353 for (const [path, contents] of Object.entries({
354 "copy-source.txt": `${copiedText}one more\n`,
355 "copied.txt": copiedText,
356 [renamedPath]: "after\nkeep one\nkeep two\nkeep three\n",
357 "binary.bin": "\0after",
358 "empty.txt": "",
359 [addedPath]: "first\nsecond\n",
360 })) {
361 yield* writeTextFile(NodePath.join(tmp, path), contents);
362 }
363 yield* checkpointStore.captureCheckpoint({ cwd: tmp, checkpointRef: firstTurn });
364 const userIndex = yield* fileSystem.readFile(NodePath.join(tmp, ".git/index"));
365 const input = {
366 cwd: tmp,
367 fromCheckpointRef: baseline,
368 toCheckpointRef: firstTurn,
369 ignoreWhitespace: false,
370 format: "numstat" as const,
371 };
372 const firstSummary = parseTurnDiffFilesFromNumstat(
373 yield* checkpointStore.diffCheckpoints(input),
374 );
375 const expectedFiles = [
376 { path: "binary.bin", additions: 0, deletions: 0 },
377 { path: "copied.txt", previousPath: "copy-source.txt", additions: 0, deletions: 0 },
378 { path: "copy-source.txt", additions: 1, deletions: 0 },
379 { path: "deleted.txt", additions: 0, deletions: 1 },
380 { path: "empty.txt", additions: 0, deletions: 0 },
381 { path: addedPath, additions: 2, deletions: 0 },
382 { path: renamedPath, previousPath: "rename-old.txt", additions: 1, deletions: 1 },
383 ].toSorted((left, right) => left.path.localeCompare(right.path));
384 expect(firstSummary).toEqual(expectedFiles);
385​
386 yield* fileSystem.remove(NodePath.join(tmp, "empty.txt"));
387 yield* writeTextFile(NodePath.join(tmp, "copy-source.txt"), "replacement\n");
388 yield* checkpointStore.captureCheckpoint({ cwd: tmp, checkpointRef: secondTurn });
389 const secondSummary = parseTurnDiffFilesFromNumstat(
390 yield* checkpointStore.diffCheckpoints({
391 ...input,
392 fromCheckpointRef: firstTurn,
393 toCheckpointRef: secondTurn,
394 }),
395 );
396 expect(secondSummary).toEqual([
397 { path: "copy-source.txt", additions: 1, deletions: 21 },
398 { path: "empty.txt", additions: 0, deletions: 0 },
399 ]);
400​
401 const inclusiveSummary = parseTurnDiffFilesFromNumstat(
402 yield* checkpointStore.diffCheckpoints({ ...input, toCheckpointRef: secondTurn }),
403 );
404 expect(inclusiveSummary).toEqual(
405 expectedFiles
406 .filter((file) => file.path !== "empty.txt")
407 .map((file) =>
408 file.path === "copy-source.txt" ? { ...file, additions: 1, deletions: 20 } : file,
409 ),
410 );
411 expect(
412 yield* checkpointStore.diffCheckpoints({ ...input, toCheckpointRef: baseline }),
413 ).toBe("");
414 expect(yield* fileSystem.readFile(NodePath.join(tmp, ".git/index"))).toEqual(userIndex);
415 }),
416 );
417​
418 it.effect("uses HEAD for a missing baseline only when requested", () =>
419 Effect.gen(function* () {
420 const tmp = yield* makeTmpDir();
421 yield* initRepoWithCommit(tmp);
422 const checkpointStore = yield* CheckpointStore.CheckpointStore;
423 const threadId = ThreadId.make("checkpoint-summary-fallback");
424 const fromCheckpointRef = checkpointRefForThreadTurn(threadId, 0);
425 const toCheckpointRef = checkpointRefForThreadTurn(threadId, 1);
426 yield* writeTextFile(NodePath.join(tmp, "README.md"), "changed\n");
427 yield* checkpointStore.captureCheckpoint({ cwd: tmp, checkpointRef: toCheckpointRef });
428 const input = {
429 cwd: tmp,
430 fromCheckpointRef,
431 toCheckpointRef,
432 ignoreWhitespace: false,
433 format: "numstat" as const,
434 };
435​
436 const error = yield* Effect.flip(checkpointStore.diffCheckpoints(input));
437 expect(error._tag).toBe("VcsProcessExitError");
438 const numstat = yield* checkpointStore.diffCheckpoints({
439 ...input,
440 fallbackFromToHead: true,
441 });
442 expect(parseTurnDiffFilesFromNumstat(numstat)).toEqual([
443 { path: "README.md", additions: 1, deletions: 1 },
444 ]);
445 }),
446 );
447 it.effect("reads repository paths from a subdirectory workspace under diff.relative", () =>
448 Effect.gen(function* () {
449 const tmp = yield* makeTmpDir();
450 yield* initRepoWithCommit(tmp);
451 yield* git(tmp, ["config", "diff.relative", "true"]);
452 const fileSystem = yield* FileSystem.FileSystem;
453 const cwd = NodePath.join(tmp, "app");
454 yield* fileSystem.makeDirectory(cwd);
455 const checkpointStore = yield* CheckpointStore.CheckpointStore;
456 const threadId = ThreadId.make("checkpoint-file-paths-subdirectory");
457 const refs = {
458 cwd,
459 fromCheckpointRef: checkpointRefForThreadTurn(threadId, 0),
460 toCheckpointRef: checkpointRefForThreadTurn(threadId, 1),
461 };
462 yield* checkpointStore.captureCheckpoint({ cwd, checkpointRef: refs.fromCheckpointRef });
463 yield* writeTextFile(NodePath.join(cwd, "kept.txt"), "kept\n");
464 yield* git(cwd, ["add", "kept.txt"]);
465 yield* git(cwd, ["commit", "-m", "kept"]);
466 yield* writeTextFile(NodePath.join(tmp, "README.md"), "# hidden\n");
467 yield* checkpointStore.captureCheckpoint({ cwd, checkpointRef: refs.toCheckpointRef });
468​
469 const patch = yield* checkpointStore.diffCheckpoints({
470 ...refs,
471 ignoreWhitespace: false,
472 filePaths: ["app/kept.txt"],
473 });
474 expect(patch).toContain("+++ b/app/kept.txt");
475 expect(patch).toContain("+kept");
476 expect(patch).not.toContain("hidden");
477 expect(yield* checkpointStore.listAuthoredPaths(refs)).toEqual(new Set(["app/kept.txt"]));
478 }),
479 );
480 });
481​
482 describe("listAuthoredPaths", () => {
483 it.effect("leaves out paths that only a merged upstream changed", () =>
484 Effect.gen(function* () {
485 const tmp = yield* makeTmpDir();
486 yield* initRepoWithCommit(tmp);
487 const checkpointStore = yield* CheckpointStore.CheckpointStore;
488 const threadId = ThreadId.make("checkpoint-authored-paths");
489 const refs = {
490 cwd: tmp,
491 fromCheckpointRef: checkpointRefForThreadTurn(threadId, 0),
492 toCheckpointRef: checkpointRefForThreadTurn(threadId, 1),
493 };
494 const commitBeforeTurn = (file: string, contents: string) =>
495 Effect.gen(function* () {
496 yield* writeTextFile(NodePath.join(tmp, file), contents);
497 yield* git(tmp, ["add", "."]);
498 yield* git(tmp, ["commit", "-m", file], { committedAt: "2020-01-01T00:00:00Z" });
499 });
500​
501 yield* git(tmp, ["checkout", "-b", "upstream"]);
502 yield* commitBeforeTurn("upstream.txt", "upstream\n");
503 yield* commitBeforeTurn("shared.txt", "upstream\n");
504 yield* git(tmp, ["checkout", "-"]);
505 yield* commitBeforeTurn("shared.txt", "ours\n");
506 yield* checkpointStore.captureCheckpoint({
507 cwd: tmp,
508 checkpointRef: refs.fromCheckpointRef,
509 });
510​
511 yield* checkpointStore.captureCheckpoint({ cwd: tmp, checkpointRef: refs.toCheckpointRef });
512 expect(yield* checkpointStore.listAuthoredPaths(refs)).toBeNull();
513​
514 yield* git(tmp, ["merge", "upstream", "--no-edit"], { allowNonZeroExit: true });
515 yield* writeTextFile(NodePath.join(tmp, "shared.txt"), "upstream\n");
516 yield* git(tmp, ["commit", "-am", "merge upstream"]);
517 yield* writeTextFile(NodePath.join(tmp, "README.md"), "# edited\n");
518 yield* checkpointStore.captureCheckpoint({ cwd: tmp, checkpointRef: refs.toCheckpointRef });
519​
520 const numstat = yield* checkpointStore.diffCheckpoints({
521 ...refs,
522 ignoreWhitespace: false,
523 format: "numstat",
524 });
525 expect(parseTurnDiffFilesFromNumstat(numstat).map((file) => file.path)).toEqual([
526 "README.md",
527 "shared.txt",
528 "upstream.txt",
529 ]);
530 expect(yield* checkpointStore.listAuthoredPaths(refs)).toEqual(
531 new Set(["README.md", "shared.txt"]),
532 );
533 }),
534 );
535​
536 it.effect("keeps paths from signed commits under log.showSignature", () =>
537 Effect.gen(function* () {
538 const tmp = yield* makeTmpDir();
539 yield* initRepoWithCommit(tmp);
540 const signingKey = NodePath.join(yield* makeTmpDir("checkpoint-signing-key-"), "key");
541 yield* (yield* VcsProcess.VcsProcess).run({
542 operation: "CheckpointStore.test.sshKeygen",
543 command: "ssh-keygen",
544 cwd: tmp,
545 args: ["-q", "-t", "ed25519", "-N", "", "-f", signingKey],
546 timeoutMs: 10_000,
547 });
548 yield* git(tmp, ["config", "gpg.format", "ssh"]);
549 yield* git(tmp, ["config", "user.signingkey", `${signingKey}.pub`]);
550 yield* git(tmp, ["config", "log.showSignature", "true"]);
551 const checkpointStore = yield* CheckpointStore.CheckpointStore;
552 const threadId = ThreadId.make("checkpoint-authored-paths-signed");
553 const refs = {
554 cwd: tmp,
555 fromCheckpointRef: checkpointRefForThreadTurn(threadId, 0),
556 toCheckpointRef: checkpointRefForThreadTurn(threadId, 1),
557 };
558 yield* checkpointStore.captureCheckpoint({
559 cwd: tmp,
560 checkpointRef: refs.fromCheckpointRef,
561 });
562 yield* writeTextFile(NodePath.join(tmp, "kept.txt"), "kept\n");
563 yield* git(tmp, ["add", "kept.txt"]);
564 yield* git(tmp, ["commit", "-S", "-m", "kept"]);
565 yield* checkpointStore.captureCheckpoint({ cwd: tmp, checkpointRef: refs.toCheckpointRef });
566​
567 expect(yield* checkpointStore.listAuthoredPaths(refs)).toEqual(new Set(["kept.txt"]));
568 }),
569 );
570 });
571});