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
MCP
blame on this site's /mcp
CLI
abso blame worker/project/test/whole.test.ts --json
JSON
/christopher/abso-core/blame/worker/project/test/whole.test.ts?format=json
104 linesFirst import 95% · pinch 4% · rename 1%Last change rename in version 100,

104 lines from 3 changes in 3 versions.

init0Start the project1// Files kept whole (#46, ruled on #43): paths matching
2// avcs.json's "whole", and any text over 1 MB, are stored like binary files:
3// whole versions in the blob store, no line ids, so a large generated file
4// can't fill the project's memory. Once whole, a file stays whole while it
5// exists, so it never flips back and forth.
6
7import assert from "node:assert/strict";
8import { createHash } from "node:crypto";
9import { test } from "node:test";
10import { MemoryStore, Project } from "../project.ts";
12function setup(config: object = { whole: ["test/recordings/**"] }) {
13 const store = new Map<string, string>();
14 const whole = {
15 keep: (text: string) => {
16 const sha = createHash("sha256").update(text, "utf8").digest("hex");
17 store.set(sha, text);
18 return sha;
19 },
20 read: (sha: string) => store.get(sha) ?? null,
21 };
22 const log = new MemoryStore();
23 const project = new Project(log, { hasBlob: (sha) => store.has(sha), whole });
pinch78Biome is silent: about 90 hints cleared. String joins as templates, dotted keys, unused imports, variables and a private method removed, optional chains (one kept boolean with === true), the preset field instead of the deprecated recommended. Two rules off where they don't fit: noExplicitAny in the hook modules, whose engine types come from the host, and noTemplateCurlyInString in tests, which hold source text as data.Compare24 project.init({ "avcs.json": `${JSON.stringify(config)}\n`, "src/a.ts": "export const a = 1;\n" }, 0);
init0Start the project25 for (const a of ["ann", "bob"]) project.sync(a);
26 return { project, store, log, whole };
29const recording = (n: number) =>
pinch78Biome is silent: about 90 hints cleared. String joins as templates, dotted keys, unused imports, variables and a private method removed, optional chains (one kept boolean with === true), the preset field instead of the deprecated recommended. Two rules off where they don't fit: noExplicitAny in the hook modules, whose engine types come from the host, and noTemplateCurlyInString in tests, which hold source text as data.Compare30 `${JSON.stringify({ frames: Array.from({ length: 50 }, (_, i) => i * n) }, null, 2)}\n`;
init0Start the project31
rename100abso publish is now abso push, abso sync is now abso pull (abso 427) Commands, help, flags, messages, MCP tool names and descriptions, hook text, README, SKILL.md and tests say push and pull; "shared" stays the noun ("Pushed version N"). No aliases, no notices. A queued push that was "pulled" is now "turned back", so pull means one thing. push -f/--force/-u/--all/--tags and pull --rebase/--ff-only/--squash refuse with one plain line naming the abso way; push and pull take no remote or branch. Kept as stored: log entry kinds (publish, sync, pulled), HTTP route paths, the pipeline trigger on: publish, the yours (unpublished) marker, npm-publish.Compare32test("a path the project marks whole is stored as a blob, and pushes and pulls like one", () => {
init0Start the project33 const { project, store } = setup();
34 const r = project.record("ann", { "test/recordings/one.json": recording(1) }, 1);
35 assert.deepEqual(r.changed, ["test/recordings/one.json"]);
36 const p = project.publish("ann", "a recording", 2);
37 assert.ok(p.ok);
38 const blob = project.blobs()["test/recordings/one.json"];
39 assert.equal(typeof blob, "string");
40 assert.equal(store.get(blob as string), recording(1));
41 // The graph holds no lines for it: blame has nothing to say, the file text in views is empty.
42 assert.equal(project.files()["test/recordings/one.json"] ?? "", "");
43});
45test("text over 1 MB is kept whole whatever its path; smaller text is tracked by line", () => {
46 const { project } = setup({});
pinch78Biome is silent: about 90 hints cleared. String joins as templates, dotted keys, unused imports, variables and a private method removed, optional chains (one kept boolean with === true), the preset field instead of the deprecated recommended. Two rules off where they don't fit: noExplicitAny in the hook modules, whose engine types come from the host, and noTemplateCurlyInString in tests, which hold source text as data.Compare47 const big = `${"x".repeat(80)}\n`;
init0Start the project48 project.record("ann", { "gen/big.txt": big.repeat(13_000), "src/small.txt": "small\n" }, 1);
49 project.publish("ann", "two files", 2);
50 assert.ok(project.blobs()["gen/big.txt"], "the big one is a blob");
51 assert.equal(project.blobs()["src/small.txt"], undefined);
52 assert.equal(project.files()["src/small.txt"], "small\n");
53});
55test("once whole, a file stays whole even when it shrinks; an Edit of it is out of step so the client sends the file", () => {
56 const { project, store } = setup({});
pinch78Biome is silent: about 90 hints cleared. String joins as templates, dotted keys, unused imports, variables and a private method removed, optional chains (one kept boolean with === true), the preset field instead of the deprecated recommended. Two rules off where they don't fit: noExplicitAny in the hook modules, whose engine types come from the host, and noTemplateCurlyInString in tests, which hold source text as data.Compare57 project.record("ann", { "gen/big.txt": `${"y".repeat(80)}\n`.repeat(13_000) }, 1);
init0Start the project58 project.publish("ann", "big", 2);
59 project.sync("bob");
60 project.record("bob", { "gen/big.txt": "tiny now\n" }, 3);
61 project.publish("bob", "shrink", 4);
62 const sha = project.blobs()["gen/big.txt"]!;
63 assert.equal(store.get(sha), "tiny now\n");
64 assert.deepEqual(project.edit("bob", { file: "gen/big.txt", old: "tiny", new: "small" }, 5), {
65 ok: false,
66 reason: "out of step",
67 });
68 // A Write is recorded whole.
69 assert.equal(project.edit("bob", { file: "gen/big.txt", content: "written\n" }, 6).ok, true);
70 project.publish("bob", "write", 7);
71 assert.equal(store.get(project.blobs()["gen/big.txt"]!), "written\n");
72});
74test("init keeps whole the paths its own avcs.json names; without a store nothing is kept whole", () => {
75 const store = new Map<string, string>();
76 const whole = {
77 keep: (t: string) => {
78 const sha = createHash("sha256").update(t, "utf8").digest("hex");
79 store.set(sha, t);
80 return sha;
81 },
82 read: (s: string) => store.get(s) ?? null,
83 };
84 const project = new Project(new MemoryStore(), { hasBlob: (s) => store.has(s), whole });
85 project.init({ "avcs.json": '{"whole": ["rec/**"]}\n', "rec/a.json": "{}\n", "b.ts": "b\n" }, 0);
86 assert.ok(project.blobs()["rec/a.json"]);
87 const plain = new Project(new MemoryStore());
88 plain.init({ "avcs.json": '{"whole": ["rec/**"]}\n', "rec/a.json": "{}\n" }, 0);
89 assert.equal(plain.files()["rec/a.json"], "{}\n", "no store: tracked by line as before");
90});
92test("a whole project's memory stays small: 20 re-recordings of a 60,000-line file add no lines to the graph", () => {
93 const { project, log } = setup();
94 const big = (n: number) =>
95 JSON.stringify({ frames: Array.from({ length: 20_000 }, (_, i) => ({ i, v: i % 50 === 0 ? n : 0 })) }, null, 2) +
96 "\n";
97 for (let n = 0; n < 20; n++) {
98 project.record(n % 2 ? "ann" : "bob", { "test/recordings/big.json": big(n) }, n + 1);
99 project.publish(n % 2 ? "ann" : "bob", `rec ${n}`, n + 1);
100 project.sync(n % 2 ? "bob" : "ann");
101 }
102 const size = JSON.stringify(log.entries).length;
103 assert.ok(size < 200_000, `log is ${size} characters: only hashes, no lines`);
104});