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

Compare

+55 −0 in 2 places
Lines 103–122 at 318 (were 103–108 at 239)
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 239)
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 239 318 worker/project/test/view-cache.test.ts --json
JSON
/christopher/abso-core/compare/239..318?file=worker%2Fproject%2Ftest%2Fview-cache.test.ts&format=json