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 138 to 318

Compare

+56 −7 in 5 places
Lines 5–53 at 318 (were 5–10 at 138)
55import { lines, Repo } from "./helpers.ts";
66import { SqlState } from "./storage-helper.ts";
77
8+test("counter writes avoid rereads while respecting failed writes, rollback and cache bounds", () => {
9+ const source = new SqlState();
10+ try {
11+ const cache = new CachedStateStorage(source, 512, 2);
12+ const before = source.reads;
13+ for (let n = 0; n < 100; n++) {
14+ cache.write("counter", "next", n);
15+ assert.equal(cache.read("counter", "next"), n);
16+ assert.ok(cache.retainedBytes <= 512);
17+ assert.ok(cache.retainedEntries <= 2);
18+ }
19+ assert.equal(source.reads, before);
20+ source.failWrite = source.writes + 1;
21+ assert.throws(() => cache.write("counter", "next", 100), /injected/);
22+ assert.equal(cache.read("counter", "next"), 99);
23+ source.failWrite = Infinity;
24+ assert.throws(
25+ () =>
26+ cache.transaction(() => {
27+ cache.write("counter", "next", 101);
28+ assert.equal(cache.read("counter", "next"), 101);
29+ throw Error("counter rollback");
30+ }),
31+ /counter rollback/,
32+ );
33+ assert.equal(cache.retainedEntries, 0);
34+ assert.equal(cache.read("counter", "next"), 99);
35+ for (let n = 0; n < 20; n++) cache.write("counter", String(n), n);
36+ assert.ok(cache.retainedBytes <= 512);
37+ assert.ok(cache.retainedEntries <= 2);
38+ assert.equal(cache.read("counter", "0"), 0);
39+ const disabled = new CachedStateStorage(source, 0, 0);
40+ disabled.write("counter", "next", 102);
41+ assert.equal(disabled.retainedEntries, 0);
42+ assert.equal(disabled.read("counter", "next"), 102);
43+ cache.write("counter", "negative-zero", -0);
44+ assert.equal(Object.is(cache.read("counter", "negative-zero"), source.read("counter", "negative-zero")), true);
45+ } finally {
46+ source.db.close();
47+ }
48+});
50+// The line-by-line layout, which a graph adopted before packed file history still uses (packFiles: false).
851test("current visibility stops at the first included deletion while history retains every deleter", () => {
952 class ObservedStorage extends SqlState {
1053 pageReads = 0;
Lines 60–66 at 318 (were 17–23 at 138)
1760 try {
1861 const oracle = Repo.init({ "a.txt": "gone\nlive\n" });
1962 const deletion = oracle.draft({ edits: [{ file: "a.txt", old: "gone\n", new: "" }] });
20− const graph = new Graph({ storage });
63+ const graph = new Graph({ storage, packFiles: false });
2164 graph.add(oracle.graph.atom("a0"));
2265 const ids = ["a0"];
2366 for (let seq = 1; seq <= 514; seq++) {
Lines 69–75 at 318 (were 26–32 at 138)
2669 oracle.graph.add(atom);
2770 ids.push(atom.id);
2871 }
29− const reopened = new Graph({ storage });
72+ const reopened = new Graph({ storage, packFiles: false });
3073 const membership = new StableOverlaySet(ids);
3174 const view = new View(reopened, membership);
3275 storage.pageReads = 0;
Lines 480–488 at 318 (were 437–445 at 138)
437480 }
438481 const before = oracle.view().text("a.txt");
439482 oracle.edit({ edits: [{ file: "a.txt", old: before, new: "live\n" }] });
440− const graph = new Graph({ storage });
483+ const graph = new Graph({ storage, packFiles: false });
441484 for (const id of oracle.shared) graph.add(oracle.graph.atom(id));
442− const reopened = new Graph({ storage });
485+ const reopened = new Graph({ storage, packFiles: false });
443486 reopened.eachChildN = () => {
444487 throw Error("unordered child collection forbidden");
445488 };
Lines 541–560 at 318 (were 498–511 at 138)
498541 const storage = new SqlState();
499542 try {
500543 const oracle = Repo.init({ "a.txt": "one\n" });
501− const graph = new Graph({ storage });
544+ const graph = new Graph({ storage, packFiles: false });
502545 graph.add(oracle.graph.atom("a0"));
503546 storage.remove("ordered-children", "format");
504− assert.throws(() => new View(new Graph({ storage }), new StableOverlaySet(["a0"])).text("a.txt"), /fresh adoption/);
505547 assert.throws(
506− () => new Graph({ storage }).add(oracle.draft({ edits: [{ file: "a.txt", old: "one", new: "two" }] })),
548+ () => new View(new Graph({ storage, packFiles: false }), new StableOverlaySet(["a0"])).text("a.txt"),
507549 /fresh adoption/,
508550 );
551+ assert.throws(
552+ () =>
553+ new Graph({ storage, packFiles: false }).add(
554+ oracle.draft({ edits: [{ file: "a.txt", old: "one", new: "two" }] }),
555+ ),
556+ /fresh adoption/,
557+ );
509558 storage.write("ordered-children", "format", 2);
510559 const parent = graph.startCodeOf("a.txt")!;
511560 storage.remove("ordered-children", JSON.stringify([String(parent), "meta"]));
MCP
compare on this site's /mcp
CLI
abso diff 138 318 src/engine/test/state-source.test.ts --json
JSON
/christopher/abso-core/compare/138..318?file=src%2Fengine%2Ftest%2Fstate-source.test.ts&format=json