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

Compare

+62 −7 in 5 places
Lines 4–10 at 318 (were 4–10 at 192)
44import { buildBase, Graph, View } from "../../../src/engine/index.ts";
55import { StableOverlaySet } from "../../../src/engine/state-source.ts";
66import type { AtomId } from "../../../src/engine/types.ts";
7−import { ViewCache } from "../views.ts";
7+import { VIEW_COUNT, ViewCache } from "../views.ts";
88
99const VIEW_BUDGET = 24_000_000;
1010
Lines 25–31 at 318 (were 25–31 at 192)
2525 assert.equal(cache.view(set), view);
2626 assert.equal(set.iterations, 1, "cache hit must not construct a full-history key");
2727 assert.equal(view.text("a.txt"), "one\n");
28− for (let i = 0; i < 33; i++) cache.view(new Counted(["a0"]));
28+ for (let i = 0; i < VIEW_COUNT + 1; i++) cache.view(new Counted(["a0"]));
2929 assert.notEqual(cache.view(set), view, "indexed identities obey the same cache eviction limit");
3030 assert.equal(set.iterations, 2);
3131});
Lines 76–91 at 318 (were 76–91 at 192)
7676 });
7777});
7878
79−test("the cache retains exactly 32 views and evicts the least recently used one", () => {
79+test("the cache retains exactly VIEW_COUNT views and evicts the least recently used one", () => {
8080 withControlledWeights((control) => {
8181 const cache = new ViewCache(new Graph());
82− control.setIncomingWeights(Array(33).fill(0));
82+ control.setIncomingWeights(Array(VIEW_COUNT + 1).fill(0));
8383 const first = get(cache, "key-0");
84− const retained = Array.from({ length: 31 }, (_, i) => get(cache, `key-${i + 1}`));
84+ const retained = Array.from({ length: VIEW_COUNT - 1 }, (_, i) => get(cache, `key-${i + 1}`));
8585 assert.equal(get(cache, "key-0"), first);
86− const last = get(cache, "key-32");
86+ const last = get(cache, `key-${VIEW_COUNT}`);
8787 assert.equal(get(cache, "key-0"), first);
88− assert.equal(get(cache, "key-32"), last);
88+ assert.equal(get(cache, `key-${VIEW_COUNT}`), last);
8989 for (let i = 1; i < retained.length; i++) assert.equal(get(cache, `key-${i + 1}`), retained[i]);
9090 assert.notEqual(get(cache, "key-1"), retained[0]);
9191 });
Lines 103–122 at 318 (were 103–108 at 192)
103103 });
104104});
105105
106+test("trim reweighs growth with no further hit and evicts until the views fit (abso Capacity)", () => {
107+ withControlledWeights((control) => {
108+ const cache = new ViewCache(new Graph());
109+ control.setIncomingWeights([10_000_000, 10_000_000]);
110+ const growing = get(cache, "growing");
111+ const newer = get(cache, "newer");
112+ // A call lays files out in the older view after the cache last weighed it, and nothing asks for it again.
113+ control.setWeight(growing, 16_000_000);
114+ cache.trim();
115+ assert.equal(get(cache, "newer"), newer);
116+ assert.notEqual(get(cache, "growing"), growing);
117+ });
118+});
106120test("an oversized view is returned but not retained", () => {
107121 withControlledWeights((control) => {
108122 const cache = new ViewCache(new Graph());
Lines 144–187 at 318 (were 130–132 at 192)
130144 for (let i = 0; i < 40; i++) cache.keyed(`other-${i}`, () => set);
131145 assert.deepEqual(cache.view(set).files(), new View(graph, set).files());
132146});
148+test("trim lets go of the least recently used file layouts across views before whole views (abso Capacity)", () => {
149+ const graph = new Graph();
150+ const lines = (name: string) => Array.from({ length: 40 }, (_, i) => `${name} line ${i}\n`).join("");
151+ graph.add(
152+ buildBase({ "a.txt": lines("a"), "b.txt": lines("b"), "c.txt": lines("c") }, { author: "test", message: "base" }),
153+ );
154+ const set = new Set(["a0"]);
155+ // a.txt in x first, then b.txt in y, then c.txt in x: a.txt is the least recently used.
156+ const use = (cache: ViewCache) => {
157+ const x = cache.keyed("x", () => set);
158+ const y = cache.keyed("y", () => set);
159+ x.text("a.txt");
160+ y.text("b.txt");
161+ x.text("c.txt");
162+ return { x: x as View, y: y as View };
163+ };
164+ const probe = use(new ViewCache(graph));
165+ const total = probe.x.weight() + probe.y.weight();
166+ const cache = new ViewCache(graph, undefined, total - 1);
167+ const { x, y } = use(cache);
168+ cache.trim();
169+ assert.deepEqual(
170+ [...x.laidOut()].map((f) => f.path),
171+ ["c.txt"],
172+ );
173+ assert.deepEqual(
174+ [...y.laidOut()].map((f) => f.path),
175+ ["b.txt"],
176+ );
177+ assert.equal(
178+ cache.keyed("x", () => set),
179+ x,
180+ "both views are still cached",
181+ );
182+ assert.equal(
183+ cache.keyed("y", () => set),
184+ y,
185+ );
186+ assert.equal(x.text("a.txt"), lines("a"), "a.txt is laid out again, the same");
187+});
MCP
compare on this site's /mcp
CLI
abso diff 192 318 worker/project/test/view-cache.test.ts --json
JSON
/christopher/abso-core/compare/192..318?file=worker%2Fproject%2Ftest%2Fview-cache.test.ts&format=json