Skip to content

abso-core

Public

abso is version control for agents: the client, the engine and a server you can run on your own Cloudflare account.

Check passed

Versions 43 to 44

Compare

+67 −1 in 2 places
Lines 46–52 at 44 (were 46–52 at 43)
4646 uncomposedText,
4747} from "../src/core.ts";
4848import { unifiedDiff } from "../src/diff.ts";
49−import { absolute, writeFileAtomic } from "../src/folder.ts";
49+import { absolute, knownPath, unrecorded, writeFileAtomic } from "../src/folder.ts";
5050import { runHook } from "../src/hook.ts";
5151import { tryFolderLock } from "../src/lock.ts";
5252import { boxServer, commandTable, main } from "../src/main.ts";
Lines 3495–3566 at 44 (were 3495–3500 at 43)
34953495 assert.deepEqual(after.json.unrecorded, []);
34963496 });
34973497
3498+ it("status skips reading files it found unchanged before, never trusts one changed too recently, and record still reads every file", async () => {
3499+ const { folders } = await project({ "a.txt": "a\n", "b.txt": "b\n", "c.txt": "c\r\n" }, "alice", "bob");
3500+ const root = folders.alice!;
3501+ const record = join(stateDir(root), "clean.json");
3502+ const old = new Date(Date.now() - 60_000);
3503+ // The file and its known copy a minute old, as after a quiet spell.
3504+ const age = (...rels: string[]) => {
3505+ for (const rel of rels) {
3506+ utimesSync(join(root, rel), old, old);
3507+ utimesSync(knownPath(root, rel), old, old);
3508+ }
3509+ };
3510+ // Changes a file without changing its size or time: only reading it can tell.
3511+ const swap = (rel: string, text: string) => {
3512+ const was = statSync(join(root, rel));
3513+ writeFileSync(join(root, rel), text);
3514+ utimesSync(join(root, rel), was.atime, was.mtime);
3515+ };
3516+ writeFileSync(join(root, "c.txt"), "c\r\n");
3518+ // Files too new to trust are read, and not kept: a swap is still caught. A time a minute ahead stays
3519+ // too new however long the run takes.
3520+ const soon = new Date(Date.now() + 60_000);
3521+ for (const rel of ["a.txt", "b.txt", "c.txt"]) utimesSync(join(root, rel), soon, soon);
3522+ assert.deepEqual((await avcs(root, "status")).json.unrecorded, []);
3523+ swap("a.txt", "A\n");
3524+ assert.deepEqual((await avcs(root, "status")).json.unrecorded, ["a.txt"]);
3525+ swap("a.txt", "a\n");
3527+ // Old files are kept after one status, and the next answers from the record without reading them.
3528+ age("a.txt", "b.txt", "c.txt");
3529+ const first = await avcs(root, "status");
3530+ assert.deepEqual(first.json.unrecorded, []);
3531+ assert.deepEqual(first.json.crlf, ["c.txt"]);
3532+ assert.deepEqual(Object.keys(JSON.parse(readFileSync(record, "utf8")).files).sort(), ["a.txt", "b.txt", "c.txt"]);
3533+ swap("b.txt", "B\n");
3534+ const second = await avcs(root, "status");
3535+ assert.deepEqual(second.json.unrecorded, [], "b.txt was answered from the record");
3536+ assert.deepEqual(second.json.crlf, ["c.txt"]);
3537+ // What record sends is read from every file, whatever the record says.
3538+ assert.deepEqual([...unrecorded(root).files.keys()], ["b.txt"]);
3540+ // A record of an unknown format, or one that doesn't parse, is not used.
3541+ const kept = JSON.parse(readFileSync(record, "utf8"));
3542+ writeFileSync(record, JSON.stringify({ ...kept, format: 2 }));
3543+ assert.deepEqual((await avcs(root, "status")).json.unrecorded, ["b.txt"]);
3544+ writeFileSync(record, "not json");
3545+ assert.deepEqual((await avcs(root, "status")).json.unrecorded, ["b.txt"]);
3547+ // An edit that changes the size or time is read at once.
3548+ swap("b.txt", "b\n");
3549+ age("b.txt");
3550+ assert.deepEqual((await avcs(root, "status")).json.unrecorded, []);
3551+ writeFileSync(join(root, "b.txt"), "bb\n");
3552+ assert.deepEqual((await avcs(root, "status")).json.unrecorded, ["b.txt"]);
3554+ // A sync writes the file and its known copy, so what was kept for them no longer holds.
3555+ writeFileSync(join(root, "b.txt"), "b\n");
3556+ write(folders.bob!, { "a.txt": "a2\n" });
3557+ assert.equal((await avcs(folders.bob!, "publish", "-m", "a2")).exit, 0);
3558+ assert.equal((await avcs(root, "sync")).exit, 0);
3559+ assert.equal(readFileSync(join(root, "a.txt"), "utf8"), "a2\n");
3560+ swap("a.txt", "a3\n");
3561+ assert.deepEqual((await avcs(root, "status")).json.unrecorded, ["a.txt"]);
3562+ });
34983564 it("several files marked against one version get one settle --theirs hint", () => {
34993565 const c = (file: string, version: number) => ({
35003566 kind: "lines" as const,
MCP
compare on this site's /mcp
CLI
abso diff 43 44 client/test/client.test.ts --json
JSON
/christopher/abso-core/compare/43..44?file=client%2Ftest%2Fclient.test.ts&format=json