- MCP
- blame on this site's /mcp
- CLI
- abso blame worker/project/test/agent-views-shared.test.ts --json
- JSON
- /christopher/abso-core/blame/worker/project/test/agent-views-shared.test.ts?format=json
113 linescapacity 100%Last change capacity in version 237,
113 lines from 2 changes in 2 versions.
capacity235A draft's view takes its base view's layout of every file the draft doesn't touch (disk-first 2; abso Capacity).
An agent's tree, files and folder blame lay out every file in the agent's view, and tree also lays out the base to see which files the draft changed. Each layout read the file's packed history again, though every file the draft doesn't touch lays out exactly as in the draft's base.
- View.shareFiles(from, except): a view lays out a file by taking from's layout of it, unless the file is in except. except is worked out once, when a file is first needed.
- Project.#agentView sets it for a draft's view over its base's when the draft moves nothing (its moves are then the base's, as shareMoves already relies on). The touched files are touchedFiles over the draft's atoms, in both views: the files they write, delete in, set attributes on, and, where moves count, the files their deleted lines and their runs' parents sit in.
On abso adopted fresh, one kept writer: an agent's tree with authors 23.4 s to 12 to 14 s. It's still slow because a whole abso layout is bigger than the views' byte budget, so it isn't kept between calls.
New test agent-views-shared: after a published move of a function into another file, drafts that edit a moved line, delete one, change another file, set an attribute, or move lines themselves each read every file (text, attributes, writers) as the in-memory project does, read twice; it fails when the touched files are taken from where lines were written only. Named tests: every engine test (288 of 288), every worker/project test (338 of 338); typescript-rs, all 27 answers match replay; tsc and biome clean.Compare1// A draft's view takes its base view's layout of every file the draft doesn't touch (abso Capacity, View.shareFiles).
2// On a writer-backed project every agent's view must still read every file as the in-memory project does: a draft
3// that edits lines moved into another file by a published move, one that deletes such a line, one that only sets an
4// attribute, and one that moves lines itself (which shares nothing).
6import assert from "node:assert/strict";
7import { test } from "node:test";
8import { storedArray } from "../../../src/engine/state-source.ts";
9import { SqlState } from "../../../src/engine/test/storage-helper.ts";
10import { MemoryStore, Project } from "../project.ts";
11import type { Entry, ProjectStore } from "../project-types.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 new Project(store, { writerStorage: storage });
22}
24const AREA = "export function area(r: number) {\n const pi = 3.14;\n return pi * r * r;\n}\n";
25const FILES = {
26 "src/shapes.ts": `// shapes\n${AREA}\nexport function other() {\n return 1;\n}\n`,
27 "src/geometry.ts": "// geometry\n",
28 "src/plain.ts": "one\ntwo\nthree\n",
29 "run.sh": "echo hi\n",
30 "README.md": "readme\n",
31};
33function history(project: Project) {
34 let t = 0;
35 project.init(FILES, t);
36 // ann moves area() into geometry.ts and publishes: its lines were written in shapes.ts.
37 project.edit("ann", { file: "src/shapes.ts", old: AREA, new: "" }, ++t);
38 project.edit("ann", { file: "src/geometry.ts", content: `// geometry\n${AREA}` }, ++t);
39 assert.equal(project.publish("ann", "Move area to geometry", ++t).ok, true);
40 for (const agent of ["bob", "cy", "dee", "eve", "fay"]) project.sync(agent);
41 // bob edits a moved line, cy deletes one, dee touches only plain.ts, eve sets an attribute, fay moves lines.
42 project.edit("bob", { file: "src/geometry.ts", old: "3.14", new: "Math.PI" }, ++t);
43 project.edit("cy", { file: "src/geometry.ts", old: " const pi = 3.14;\n", new: "" }, ++t);
44 project.record("dee", { "src/plain.ts": "one\nTWO\nthree\n" }, ++t);
45 project.record("eve", {}, ++t, { "run.sh": { exec: true } });
46 project.edit("fay", { file: "src/plain.ts", old: "one\ntwo\nthree\n", new: "" }, ++t);
47 project.edit("fay", { file: "src/moved.ts", content: "one\ntwo\nthree\n" }, ++t);
48}
50const read = (project: Project, agent: string) => {
51 const view = project.draftOf(agent)!.view;
52 const out: Record<string, unknown> = {};
53 for (const path of view.paths()) out[path] = [view.text(path), view.attrs(path), view.lines(path).map((l) => l.atom)];
54 return out;
55};
57test("every agent's view reads every file as the in-memory project's, with files shared from the base", () => {
58 const oracle = new Project(new MemoryStore());
59 const project = writer();
60 history(oracle);
61 history(project);
62 for (const agent of ["ann", "bob", "cy", "dee", "eve", "fay"]) {
63 // Twice: the second read takes the shared layouts the first one made.
64 assert.deepEqual(read(project, agent), read(oracle, agent), agent);
65 assert.deepEqual(read(project, agent), read(oracle, agent), `${agent} again`);
66 }
67 assert.match(String(read(oracle, "bob")["src/geometry.ts"]), /Math\.PI/);
68 assert.doesNotMatch(String(read(oracle, "cy")["src/geometry.ts"]), /const pi/);
69 assert.deepEqual(project.tree("", { agent: "cy", authors: true }), oracle.tree("", { agent: "cy", authors: true }));
70});
capacity237touchedBeyond, with named tests for 235's wrong draft diff (disk-first 2; abso Capacity).
236 fixed the wrong diff Disk-first Testing found on typescript-rs with 235 (cloud-ts-01's diff showed lib.rs and passes.rs from its older base). This moves that fix into a named function with its own tests, as Agent VCS asked.
- collisions.ts touchedBeyond(graph, below, mine, views): the files a view over below plus mine can lay out differently from below, or undefined when any of it moves lines. It counts mine and whatever mine depends on that below lacks, since a view's set is closed. Project.#agentView's shareFiles uses it.
- touched-beyond.test.ts: a publish's tie writes no files, but it depends on the published change. Counted from version 0 its files include the changed file, which 235's count (the atoms alone) missed. A move beyond the base turns sharing off.
- agent-views-shared.test.ts adds a merge-queue landing with a move, then more drafting in the moved-to file.
Checks: typescript-rs adopted fresh, diff for cloud-ts-01 matches replay (it differs on 235). Every worker/project test (341 of 341) and every engine test; tsc and biome clean.Compare71
72// A push landed through the merge queue whose delete and write of the same text became a move, by an agent whose base
73// stays older than the landing, then more drafting in the moved-to file: the diff and every file read as in memory.
74// (Here the move is among the agent's own atoms, so nothing is shared; touched-beyond.test.ts covers work held only
75// by dependency.)
76function landedWithMoves(project: Project) {
77 let t = 0;
78 project.checkerReady = true;
79 project.init(
80 {
81 "avcs.json": `${JSON.stringify({ queue: true })}\n`,
82 "src/shapes.ts": `// shapes\n${AREA}`,
83 "src/geometry.ts": "// geometry\n",
84 "notes.md": "notes\n",
85 },
86 t,
87 );
88 project.sync("ann");
89 project.sync("bob");
90 const land = (agent: string, message: string) => {
91 const queued = project.publish(agent, message, ++t);
92 assert.ok(queued.ok && "queued" in queued, JSON.stringify(queued));
93 project.queueChecking(queued.queued);
94 project.queueLand(queued.queued, ++t);
95 };
96 project.record("bob", { "notes.md": "notes\nbob\n" }, ++t);
97 land("bob", "Notes");
98 project.edit("ann", { file: "src/shapes.ts", old: AREA, new: "" }, ++t);
99 project.edit("ann", { file: "src/geometry.ts", content: `// geometry\n${AREA}` }, ++t);
100 project.record("ann", { "README.md": "readme\n" }, ++t);
101 land("ann", "Move area, add a readme");
102 project.edit("ann", { file: "src/geometry.ts", old: "3.14", new: "Math.PI" }, ++t);
103 project.edit("ann", { file: "README.md", content: "readme\nmore\n" }, ++t);
104}
106test("a draft's diff takes nothing from its base that its landed work holds by dependency", () => {
107 const oracle = new Project(new MemoryStore());
108 const project = writer();
109 landedWithMoves(oracle);
110 landedWithMoves(project);
111 assert.deepEqual(project.diffOf("ann"), oracle.diffOf("ann"));
112 assert.deepEqual(read(project, "ann"), read(oracle, "ann"));
113});