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

CheckpointStore.test.ts

564 lines22.8 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 const checkpointStore = yield* CheckpointStore.CheckpointStore;
163 const threadId = ThreadId.make("thread-checkpoint-store-noprefix");
164 const fromCheckpointRef = checkpointRefForThreadTurn(threadId, 0);
165 const toCheckpointRef = checkpointRefForThreadTurn(threadId, 1);
166​
167 yield* writeTextFile(NodePath.join(tmp, "README.md"), "# test\n\nbefore\n");
168 yield* checkpointStore.captureCheckpoint({
169 cwd: tmp,
170 checkpointRef: fromCheckpointRef,
171 });
172 yield* writeTextFile(NodePath.join(tmp, "README.md"), "# test\n\nafter\n");
173 yield* checkpointStore.captureCheckpoint({
174 cwd: tmp,
175 checkpointRef: toCheckpointRef,
176 });
177​
178 const diff = yield* checkpointStore.diffCheckpoints({
179 cwd: tmp,
180 fromCheckpointRef,
181 toCheckpointRef,
182 ignoreWhitespace: false,
183 });
184​
185 expect(diff).toContain("diff --git a/README.md b/README.md");
186 expect(diff).toContain(" # test\n \n-before\n+after\n");
187 }),
188 );
189​
190 it.effect("can hide indentation churn when changes wrap existing lines", () =>
191 Effect.gen(function* () {
192 const tmp = yield* makeTmpDir();
193 yield* initRepoWithCommit(tmp);
194 const checkpointStore = yield* CheckpointStore.CheckpointStore;
195 const threadId = ThreadId.make("thread-checkpoint-store-whitespace");
196 const fromCheckpointRef = checkpointRefForThreadTurn(threadId, 0);
197 const toCheckpointRef = checkpointRefForThreadTurn(threadId, 1);
198​
199 const componentPath = NodePath.join(tmp, "Component.tsx");
200 yield* writeTextFile(
201 componentPath,
202 [
203 "export function View() {",
204 " return (",
205 " <section>",
206 " <h1>Title</h1>",
207 " <p>Body</p>",
208 " </section>",
209 " );",
210 "}",
211 "",
212 ].join("\n"),
213 );
214 yield* checkpointStore.captureCheckpoint({
215 cwd: tmp,
216 checkpointRef: fromCheckpointRef,
217 });
218 yield* writeTextFile(
219 componentPath,
220 [
221 "export function View() {",
222 " return (",
223 " <section>",
224 " {isReady ? (",
225 " <div>",
226 " <h1>Title</h1>",
227 " <p>Body</p>",
228 " </div>",
229 " ) : null}",
230 " </section>",
231 " );",
232 "}",
233 "",
234 ].join("\n"),
235 );
236 yield* checkpointStore.captureCheckpoint({
237 cwd: tmp,
238 checkpointRef: toCheckpointRef,
239 });
240​
241 const normalDiff = yield* checkpointStore.diffCheckpoints({
242 cwd: tmp,
243 fromCheckpointRef,
244 toCheckpointRef,
245 ignoreWhitespace: false,
246 });
247 const whitespaceIgnoredDiff = yield* checkpointStore.diffCheckpoints({
248 cwd: tmp,
249 fromCheckpointRef,
250 toCheckpointRef,
251 ignoreWhitespace: true,
252 });
253​
254 expect(normalDiff).toContain("diff --git");
255 expect(normalDiff).toContain("- <h1>Title</h1>");
256 expect(normalDiff).toContain("+ <h1>Title</h1>");
257 expect(whitespaceIgnoredDiff).toContain("diff --git");
258 expect(whitespaceIgnoredDiff).toContain("+ {isReady ? (");
259 expect(whitespaceIgnoredDiff).toContain("+ <div>");
260 expect(whitespaceIgnoredDiff).not.toContain("- <h1>Title</h1>");
261 expect(whitespaceIgnoredDiff).not.toContain("+ <h1>Title</h1>");
262​
263 for (const ignoreWhitespace of [false, true]) {
264 const numstat = yield* checkpointStore.diffCheckpoints({
265 cwd: tmp,
266 fromCheckpointRef,
267 toCheckpointRef,
268 ignoreWhitespace,
269 format: "numstat",
270 });
271 expect(parseTurnDiffFilesFromNumstat(numstat)).toEqual([
272 {
273 path: "Component.tsx",
274 additions: ignoreWhitespace ? 4 : 6,
275 deletions: ignoreWhitespace ? 0 : 2,
276 },
277 ]);
278 }
279 }),
280 );
281 });
282​
283 describe("checkpoint file summaries", () => {
284 it.effect("counts changes whose full patch exceeds the output limit", () =>
285 Effect.gen(function* () {
286 const tmp = yield* makeTmpDir();
287 yield* initRepoWithCommit(tmp);
288 const checkpointStore = yield* CheckpointStore.CheckpointStore;
289 const threadId = ThreadId.make("large-checkpoint-summary");
290 const fromCheckpointRef = checkpointRefForThreadTurn(threadId, 0);
291 const toCheckpointRef = checkpointRefForThreadTurn(threadId, 1);
292 const filePath = NodePath.join(tmp, "README.md");
293 const lineCount = 20_000;
294 yield* writeTextFile(filePath, `${"before".repeat(50)}\n`.repeat(lineCount));
295 yield* checkpointStore.captureCheckpoint({ cwd: tmp, checkpointRef: fromCheckpointRef });
296 yield* writeTextFile(filePath, `${"after".repeat(60)}\n`.repeat(lineCount));
297 yield* checkpointStore.captureCheckpoint({ cwd: tmp, checkpointRef: toCheckpointRef });
298​
299 const numstat = yield* checkpointStore.diffCheckpoints({
300 cwd: tmp,
301 fromCheckpointRef,
302 toCheckpointRef,
303 ignoreWhitespace: false,
304 format: "numstat",
305 });
306​
307 expect(parseTurnDiffFilesFromNumstat(numstat)).toEqual([
308 { path: "README.md", additions: lineCount, deletions: lineCount },
309 ]);
310 expect(numstat.length).toBeLessThan(100);
311 }),
312 );
313​
314 it.effect("preserves file paths and turn ranges without changing the user index", () =>
315 Effect.gen(function* () {
316 const tmp = yield* makeTmpDir();
317 yield* initRepoWithCommit(tmp);
318 yield* git(tmp, ["config", "diff.renames", "copies"]);
319 const fileSystem = yield* FileSystem.FileSystem;
320 const checkpointStore = yield* CheckpointStore.CheckpointStore;
321 const threadId = ThreadId.make("checkpoint-summary-paths");
322 const baseline = checkpointRefForThreadTurn(threadId, 0);
323 const firstTurn = checkpointRefForThreadTurn(threadId, 1);
324 const secondTurn = checkpointRefForThreadTurn(threadId, 2);
325 const copiedText = Array.from({ length: 20 }, (_, index) => `copy line ${index}\n`).join(
326 "",
327 );
328 const platform = yield* HostProcess.Platform;
329 const renamedPath = platform === "win32" ? "renamed café.txt" : "renamed\tcafé\nname.txt";
330 const addedPath = platform === "win32" ? "new café.txt" : "new\tfile\n名.txt";
331 for (const [path, contents] of Object.entries({
332 "copy-source.txt": copiedText,
333 "deleted.txt": "delete me\n",
334 "rename-old.txt": "before\nkeep one\nkeep two\nkeep three\n",
335 "binary.bin": "\0before",
336 })) {
337 yield* writeTextFile(NodePath.join(tmp, path), contents);
338 }
339 yield* checkpointStore.captureCheckpoint({ cwd: tmp, checkpointRef: baseline });
340​
341 yield* fileSystem.rename(
342 NodePath.join(tmp, "rename-old.txt"),
343 NodePath.join(tmp, renamedPath),
344 );
345 yield* fileSystem.remove(NodePath.join(tmp, "deleted.txt"));
346 for (const [path, contents] of Object.entries({
347 "copy-source.txt": `${copiedText}one more\n`,
348 "copied.txt": copiedText,
349 [renamedPath]: "after\nkeep one\nkeep two\nkeep three\n",
350 "binary.bin": "\0after",
351 "empty.txt": "",
352 [addedPath]: "first\nsecond\n",
353 })) {
354 yield* writeTextFile(NodePath.join(tmp, path), contents);
355 }
356 yield* checkpointStore.captureCheckpoint({ cwd: tmp, checkpointRef: firstTurn });
357 const userIndex = yield* fileSystem.readFile(NodePath.join(tmp, ".git/index"));
358 const input = {
359 cwd: tmp,
360 fromCheckpointRef: baseline,
361 toCheckpointRef: firstTurn,
362 ignoreWhitespace: false,
363 format: "numstat" as const,
364 };
365 const firstSummary = parseTurnDiffFilesFromNumstat(
366 yield* checkpointStore.diffCheckpoints(input),
367 );
368 const expectedFiles = [
369 { path: "binary.bin", additions: 0, deletions: 0 },
370 { path: "copied.txt", previousPath: "copy-source.txt", additions: 0, deletions: 0 },
371 { path: "copy-source.txt", additions: 1, deletions: 0 },
372 { path: "deleted.txt", additions: 0, deletions: 1 },
373 { path: "empty.txt", additions: 0, deletions: 0 },
374 { path: addedPath, additions: 2, deletions: 0 },
375 { path: renamedPath, previousPath: "rename-old.txt", additions: 1, deletions: 1 },
376 ].toSorted((left, right) => left.path.localeCompare(right.path));
377 expect(firstSummary).toEqual(expectedFiles);
378​
379 yield* fileSystem.remove(NodePath.join(tmp, "empty.txt"));
380 yield* writeTextFile(NodePath.join(tmp, "copy-source.txt"), "replacement\n");
381 yield* checkpointStore.captureCheckpoint({ cwd: tmp, checkpointRef: secondTurn });
382 const secondSummary = parseTurnDiffFilesFromNumstat(
383 yield* checkpointStore.diffCheckpoints({
384 ...input,
385 fromCheckpointRef: firstTurn,
386 toCheckpointRef: secondTurn,
387 }),
388 );
389 expect(secondSummary).toEqual([
390 { path: "copy-source.txt", additions: 1, deletions: 21 },
391 { path: "empty.txt", additions: 0, deletions: 0 },
392 ]);
393​
394 const inclusiveSummary = parseTurnDiffFilesFromNumstat(
395 yield* checkpointStore.diffCheckpoints({ ...input, toCheckpointRef: secondTurn }),
396 );
397 expect(inclusiveSummary).toEqual(
398 expectedFiles
399 .filter((file) => file.path !== "empty.txt")
400 .map((file) =>
401 file.path === "copy-source.txt" ? { ...file, additions: 1, deletions: 20 } : file,
402 ),
403 );
404 expect(
405 yield* checkpointStore.diffCheckpoints({ ...input, toCheckpointRef: baseline }),
406 ).toBe("");
407 expect(yield* fileSystem.readFile(NodePath.join(tmp, ".git/index"))).toEqual(userIndex);
408 }),
409 );
410​
411 it.effect("uses HEAD for a missing baseline only when requested", () =>
412 Effect.gen(function* () {
413 const tmp = yield* makeTmpDir();
414 yield* initRepoWithCommit(tmp);
415 const checkpointStore = yield* CheckpointStore.CheckpointStore;
416 const threadId = ThreadId.make("checkpoint-summary-fallback");
417 const fromCheckpointRef = checkpointRefForThreadTurn(threadId, 0);
418 const toCheckpointRef = checkpointRefForThreadTurn(threadId, 1);
419 yield* writeTextFile(NodePath.join(tmp, "README.md"), "changed\n");
420 yield* checkpointStore.captureCheckpoint({ cwd: tmp, checkpointRef: toCheckpointRef });
421 const input = {
422 cwd: tmp,
423 fromCheckpointRef,
424 toCheckpointRef,
425 ignoreWhitespace: false,
426 format: "numstat" as const,
427 };
428​
429 const error = yield* Effect.flip(checkpointStore.diffCheckpoints(input));
430 expect(error._tag).toBe("VcsProcessExitError");
431 const numstat = yield* checkpointStore.diffCheckpoints({
432 ...input,
433 fallbackFromToHead: true,
434 });
435 expect(parseTurnDiffFilesFromNumstat(numstat)).toEqual([
436 { path: "README.md", additions: 1, deletions: 1 },
437 ]);
438 }),
439 );
440 it.effect("reads repository paths from a subdirectory workspace under diff.relative", () =>
441 Effect.gen(function* () {
442 const tmp = yield* makeTmpDir();
443 yield* initRepoWithCommit(tmp);
444 yield* git(tmp, ["config", "diff.relative", "true"]);
445 const fileSystem = yield* FileSystem.FileSystem;
446 const cwd = NodePath.join(tmp, "app");
447 yield* fileSystem.makeDirectory(cwd);
448 const checkpointStore = yield* CheckpointStore.CheckpointStore;
449 const threadId = ThreadId.make("checkpoint-file-paths-subdirectory");
450 const refs = {
451 cwd,
452 fromCheckpointRef: checkpointRefForThreadTurn(threadId, 0),
453 toCheckpointRef: checkpointRefForThreadTurn(threadId, 1),
454 };
455 yield* checkpointStore.captureCheckpoint({ cwd, checkpointRef: refs.fromCheckpointRef });
456 yield* writeTextFile(NodePath.join(cwd, "kept.txt"), "kept\n");
457 yield* git(cwd, ["add", "kept.txt"]);
458 yield* git(cwd, ["commit", "-m", "kept"]);
459 yield* writeTextFile(NodePath.join(tmp, "README.md"), "# hidden\n");
460 yield* checkpointStore.captureCheckpoint({ cwd, checkpointRef: refs.toCheckpointRef });
461​
462 const patch = yield* checkpointStore.diffCheckpoints({
463 ...refs,
464 ignoreWhitespace: false,
465 filePaths: ["app/kept.txt"],
466 });
467 expect(patch).toContain("+++ b/app/kept.txt");
468 expect(patch).toContain("+kept");
469 expect(patch).not.toContain("hidden");
470 expect(yield* checkpointStore.listAuthoredPaths(refs)).toEqual(new Set(["app/kept.txt"]));
471 }),
472 );
473 });
474​
475 describe("listAuthoredPaths", () => {
476 it.effect("leaves out paths that only a merged upstream changed", () =>
477 Effect.gen(function* () {
478 const tmp = yield* makeTmpDir();
479 yield* initRepoWithCommit(tmp);
480 const checkpointStore = yield* CheckpointStore.CheckpointStore;
481 const threadId = ThreadId.make("checkpoint-authored-paths");
482 const refs = {
483 cwd: tmp,
484 fromCheckpointRef: checkpointRefForThreadTurn(threadId, 0),
485 toCheckpointRef: checkpointRefForThreadTurn(threadId, 1),
486 };
487 const commitBeforeTurn = (file: string, contents: string) =>
488 Effect.gen(function* () {
489 yield* writeTextFile(NodePath.join(tmp, file), contents);
490 yield* git(tmp, ["add", "."]);
491 yield* git(tmp, ["commit", "-m", file], { committedAt: "2020-01-01T00:00:00Z" });
492 });
493​
494 yield* git(tmp, ["checkout", "-b", "upstream"]);
495 yield* commitBeforeTurn("upstream.txt", "upstream\n");
496 yield* commitBeforeTurn("shared.txt", "upstream\n");
497 yield* git(tmp, ["checkout", "-"]);
498 yield* commitBeforeTurn("shared.txt", "ours\n");
499 yield* checkpointStore.captureCheckpoint({
500 cwd: tmp,
501 checkpointRef: refs.fromCheckpointRef,
502 });
503​
504 yield* checkpointStore.captureCheckpoint({ cwd: tmp, checkpointRef: refs.toCheckpointRef });
505 expect(yield* checkpointStore.listAuthoredPaths(refs)).toBeNull();
506​
507 yield* git(tmp, ["merge", "upstream", "--no-edit"], { allowNonZeroExit: true });
508 yield* writeTextFile(NodePath.join(tmp, "shared.txt"), "upstream\n");
509 yield* git(tmp, ["commit", "-am", "merge upstream"]);
510 yield* writeTextFile(NodePath.join(tmp, "README.md"), "# edited\n");
511 yield* checkpointStore.captureCheckpoint({ cwd: tmp, checkpointRef: refs.toCheckpointRef });
512​
513 const numstat = yield* checkpointStore.diffCheckpoints({
514 ...refs,
515 ignoreWhitespace: false,
516 format: "numstat",
517 });
518 expect(parseTurnDiffFilesFromNumstat(numstat).map((file) => file.path)).toEqual([
519 "README.md",
520 "shared.txt",
521 "upstream.txt",
522 ]);
523 expect(yield* checkpointStore.listAuthoredPaths(refs)).toEqual(
524 new Set(["README.md", "shared.txt"]),
525 );
526 }),
527 );
528​
529 it.effect("keeps paths from signed commits under log.showSignature", () =>
530 Effect.gen(function* () {
531 const tmp = yield* makeTmpDir();
532 yield* initRepoWithCommit(tmp);
533 const signingKey = NodePath.join(yield* makeTmpDir("checkpoint-signing-key-"), "key");
534 yield* (yield* VcsProcess.VcsProcess).run({
535 operation: "CheckpointStore.test.sshKeygen",
536 command: "ssh-keygen",
537 cwd: tmp,
538 args: ["-q", "-t", "ed25519", "-N", "", "-f", signingKey],
539 timeoutMs: 10_000,
540 });
541 yield* git(tmp, ["config", "gpg.format", "ssh"]);
542 yield* git(tmp, ["config", "user.signingkey", `${signingKey}.pub`]);
543 yield* git(tmp, ["config", "log.showSignature", "true"]);
544 const checkpointStore = yield* CheckpointStore.CheckpointStore;
545 const threadId = ThreadId.make("checkpoint-authored-paths-signed");
546 const refs = {
547 cwd: tmp,
548 fromCheckpointRef: checkpointRefForThreadTurn(threadId, 0),
549 toCheckpointRef: checkpointRefForThreadTurn(threadId, 1),
550 };
551 yield* checkpointStore.captureCheckpoint({
552 cwd: tmp,
553 checkpointRef: refs.fromCheckpointRef,
554 });
555 yield* writeTextFile(NodePath.join(tmp, "kept.txt"), "kept\n");
556 yield* git(tmp, ["add", "kept.txt"]);
557 yield* git(tmp, ["commit", "-S", "-m", "kept"]);
558 yield* checkpointStore.captureCheckpoint({ cwd: tmp, checkpointRef: refs.toCheckpointRef });
559​
560 expect(yield* checkpointStore.listAuthoredPaths(refs)).toEqual(new Set(["kept.txt"]));
561 }),
562 );
563 });
564});