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/version-files.test.ts --json
JSON
/christopher/abso-core/blame/worker/project/test/version-files.test.ts?format=json
69 linescapacity 100%Last change capacity in version 217,

69 lines from 4 changes in 4 versions.

capacity207Each shared version's changed files kept as it lands (disk-first 2; abso Capacity, version-files.ts). A version's files are decided from what it touched: visible lines in and out per file, their texts' balance, a running count of each file's visible lines for made and taken out, and mode and blob; a version with moves, drops or a closure change, or whose lines in and out have the same texts, is laid out as before. Views of consecutive versions share resolved moves and where lines sit (View.shareMoves). PathIndex.keep records them, into the shapes table when the host gives one. version-files.test.ts checks log, path logs and every show against the in-memory project through edits, new and removed files, same text put back, a move and a drop. On game's export all 27 harness answers now match Project.load: the log 70 ms (was over 30 s), a path's history 0.56 s (was over 30 s), the tree 3.1-3.4 s (was over 30 s); adoption about 85 s; heap 14.4 MB at most.Compare1// Each version's changed files kept as it lands (abso Capacity, version-files.ts): a writer-backed project's log,
capacity208Compare on a stored writer takes its candidates from the kept version files of the versions between (abso Capacity): every file that differs between two shared versions changed in one between them. Before, it walked every atom either version's set holds. version-files.test.ts compares both ways, across a drop, against the in-memory project. On game's export, compare from 762 to 1525: 20 s to 5.4 s, same answer.Compare2// path histories, shows and compares match the in-memory project's through edits, new and removed files, a line
3// taken out and put back with the same text, moves and a drop.
capacity207Each shared version's changed files kept as it lands (disk-first 2; abso Capacity, version-files.ts). A version's files are decided from what it touched: visible lines in and out per file, their texts' balance, a running count of each file's visible lines for made and taken out, and mode and blob; a version with moves, drops or a closure change, or whose lines in and out have the same texts, is laid out as before. Views of consecutive versions share resolved moves and where lines sit (View.shareMoves). PathIndex.keep records them, into the shapes table when the host gives one. version-files.test.ts checks log, path logs and every show against the in-memory project through edits, new and removed files, same text put back, a move and a drop. On game's export all 27 harness answers now match Project.load: the log 70 ms (was over 30 s), a path's history 0.56 s (was over 30 s), the tree 3.1-3.4 s (was over 30 s); adoption about 85 s; heap 14.4 MB at most.Compare4
5import assert from "node:assert/strict";
6import { test } from "node:test";
7import { storedArray } from "../../../src/engine/state-source.ts";
8import { SqlState } from "../../../src/engine/test/storage-helper.ts";
9import { MemoryStore, Project } from "../project.ts";
10import type { Entry, ProjectStore } from "../project-types.ts";
11import { countedVersion } from "../version-files.ts";
13function writer() {
14 const storage = new SqlState();
15 const entries = storedArray<Entry>(storage, "canonical-log");
16 const store: ProjectStore = {
17 append(batch) {
18 for (const entry of batch) entries.push(entry);
19 },
20 };
21 return { storage, project: new Project(store, { writerStorage: storage }) };
24function history(project: Project) {
25 let t = 0;
26 const publish = (agent: string, files: Record<string, string | null>, message: string) => {
27 project.record(agent, files, ++t);
28 assert.equal(project.publish(agent, message, ++t).ok, true, message);
29 };
30 project.init({ "a.txt": "one\ntwo\nthree\n", "b.txt": "bee\n", "gone.txt": "soon\n" }, t);
31 publish("ann", { "a.txt": "one\nTWO\nthree\n" }, "Edit a");
32 publish("ann", { "c.txt": "new file\n" }, "Make c");
33 publish("ann", { "gone.txt": null }, "Remove gone");
34 publish("ann", { "b.txt": "" }, "Empty b");
35 publish("ann", { "b.txt": "bee\n" }, "Same text back in b");
36 project.move("ann", "c.txt", "d.txt", ++t);
37 assert.equal(project.publish("ann", "Move c to d", ++t).ok, true);
38 publish("bob", { "d.txt": "new file\nmore\n" }, "Edit d");
39 publish("cy", { "e.txt": "e\n" }, "Make e");
40 const dropped = project.drop("cy", [project.version], "Drop e", ++t);
41 assert.equal(dropped.ok, true);
42 publish("bob", { "a.txt": "one\nTWO\nthree\nfour\n" }, "Last");
45test("kept version files match the in-memory project's log, paths and shows", () => {
46 const oracle = new Project(new MemoryStore());
47 const { storage, project } = writer();
48 history(oracle);
49 history(project);
50 assert.equal(countedVersion(storage), oracle.version);
51 assert.deepEqual(project.log({ limit: 100 }), oracle.log({ limit: 100 }));
52 for (const path of ["a.txt", "b.txt", "c.txt", "d.txt", "e.txt", "gone.txt"])
53 assert.deepEqual(project.log({ limit: 100, path }), oracle.log({ limit: 100, path }), path);
54 for (let v = 0; v <= oracle.version; v++) assert.deepEqual(project.show(v), oracle.show(v), `version ${v}`);
capacity216Moves picked as walks reach them, and shared's file list from kept shapes (disk-first 2; abso Capacity), for abso's status, drafts and file list. - view.ts: a view picks a moved line's relocation only when a walk to find a line's file reaches that line. That is #relocations' own pick, right whenever the walk goes on to a file's start, since only lines on a loop have their relocation set aside; a walk that comes back to a line it passed resolves every move as before. shareMoves now takes the other view's moves only when this view first needs all of them, such as for a layout, so a view that only finds a few lines' files never resolves them. weight() counts the picks. - pathindex.ts keptPaths: shared's files at a version, folded from version 0 over each version's kept files made and taken out, with no file laid out. Only on a stored writer, and only when every version up to it has a kept row that describes it; otherwise the version is laid out as before. pathsAt uses it. On abso's export (81,855 entries, 1,224 versions), one opened project, answers matching Project.load: - status: 104 s to 5.8 s (under the profiler) - drafts: over 60 s to 5.7 s - files at head: over 60 s to 1.2 s - files at 612: 54 s to 0.3 s version-files.test.ts now also checks the file list at every version against the in-memory project. 124 of 124 related tests pass; tsc clean.Compare55 // The file list at each version, folded from the kept shapes' files made and taken out: newest first, then from 0.
56 assert.deepEqual(project.pathsAt(oracle.version), oracle.pathsAt(oracle.version));
57 for (let v = 0; v <= oracle.version; v++) assert.deepEqual(project.pathsAt(v), oracle.pathsAt(v), `paths at ${v}`);
capacity217tree lists a version's files from the kept shapes, as pathsAt does since 216 (disk-first 2; abso Capacity). The tree at a version laid out every file only to list them. Not for an agent's tree, whose view has its draft on top. On abso's export the tree at head went from over 60 s to 225 ms (replay takes 41 s), and the tree at 612 takes 156 ms, both matching Project.load. version-files.test.ts now also checks the tree at every version against the in-memory project. Named tests: version-files, files-reads, project, draft-reads-stored, named-drafts (38 of 38); tsc clean.Compare58 for (let v = 0; v <= oracle.version; v++)
59 assert.deepEqual(project.tree("", { version: v }), oracle.tree("", { version: v }), `tree at ${v}`);
capacity208Compare on a stored writer takes its candidates from the kept version files of the versions between (abso Capacity): every file that differs between two shared versions changed in one between them. Before, it walked every atom either version's set holds. version-files.test.ts compares both ways, across a drop, against the in-memory project. On game's export, compare from 762 to 1525: 20 s to 5.4 s, same answer.Compare60 // A compare reads the kept lists for the versions between (version-log.ts): both ways, and across the drop.
61 for (const [from, to] of [
62 [0, oracle.version],
63 [oracle.version, 0],
64 [2, 7],
65 [5, 9],
66 [3, 3],
67 ] as const)
68 assert.deepEqual(project.compare(from, to), oracle.compare(from, to), `compare ${from} to ${to}`);
capacity207Each shared version's changed files kept as it lands (disk-first 2; abso Capacity, version-files.ts). A version's files are decided from what it touched: visible lines in and out per file, their texts' balance, a running count of each file's visible lines for made and taken out, and mode and blob; a version with moves, drops or a closure change, or whose lines in and out have the same texts, is laid out as before. Views of consecutive versions share resolved moves and where lines sit (View.shareMoves). PathIndex.keep records them, into the shapes table when the host gives one. version-files.test.ts checks log, path logs and every show against the in-memory project through edits, new and removed files, same text put back, a move and a drop. On game's export all 27 harness answers now match Project.load: the log 70 ms (was over 30 s), a path's history 0.56 s (was over 30 s), the tree 3.1-3.4 s (was over 30 s); adoption about 85 s; heap 14.4 MB at most.Compare69});