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
37 linescapacity 100%Last change capacity in version 237, 1 version changed it

You're reading version 296. The newest is 318, and no version since then changed this file. Go to the newestCompare with 318

1// The files a draft's view can't take from its base (abso Capacity, touchedBeyond): everything the view holds beyond
2// the base counts, not only the draft's own atoms. A view's set is closed under dependencies, so an atom the agent
3// holds can bring in work the base lacks, as a publish's tie does. Core 235 counted the agent's atoms alone and showed
4// such files at the older base (Testing's typescript-rs diff for cloud-ts-01).
5
6import assert from "node:assert/strict";
7import { test } from "node:test";
8import { touchedBeyond, touchedFiles } from "../collisions.ts";
9import { MemoryStore, Project } from "../project.ts";
11test("files changed by work the agent's atoms depend on count, not only the atoms' own", () => {
12 const project = new Project(new MemoryStore());
13 project.init({ "a.txt": "a\n", "b.txt": "b\n" }, 0);
14 project.record("ann", { "b.txt": "b\nmore\n" }, 1);
15 assert.equal(project.publish("ann", "More b", 2).ok, true);
16 const graph = project.graph;
17 const tie = graph.idOfSeq(graph.size - 1);
18 assert.deepEqual([...graph.filesOf(tie)], [], "a tie writes no files itself");
19 const base = project.viewAt(0);
20 const view = project.viewAt(1);
21 // Counted alone, the tie touches nothing, and b.txt would be taken from version 0.
22 assert.deepEqual([...touchedFiles(graph, [tie], [base, view])], []);
23 assert.deepEqual([...(touchedBeyond(graph, base.set, [tie], [base, view]) ?? [])], ["b.txt"]);
24 // Counted from version 1, which holds the change, nothing is beyond it.
25 assert.deepEqual([...(touchedBeyond(graph, view.set, [tie], [view]) ?? [])], []);
26});
28test("nothing is shared when anything beyond the base moves lines", () => {
29 const project = new Project(new MemoryStore());
30 project.init({ "a.txt": "one\ntwo\nthree\n", "b.txt": "b\n" }, 0);
31 project.move("ann", "a.txt", "c.txt", 1);
32 assert.equal(project.publish("ann", "Move a to c", 2).ok, true);
33 const graph = project.graph;
34 const tie = graph.idOfSeq(graph.size - 1);
35 const base = project.viewAt(0);
36 assert.equal(touchedBeyond(graph, base.set, [tie], [base, project.viewAt(1)]), undefined);
37});