The view cache holds up to 128 views, still within its byte budget (disk-first 2; abso Capacity). Version 234 of shared· capacity· Oct 15 (2026-10-15 10:18 UTC) · Not checked
where visits every agent's draft view in turn. abso has more agents with drafts than the cache's 32 views, so each visit evicted the view the next call would need, and a kept writer laid every view out again on every call. Testing measured where at 5.5 s warm on abso with 232.
VIEW_COUNT is now 128. The byte budget (VIEW_BUDGET, 24 MB) still bounds what the views hold.
On abso adopted fresh, one kept writer: where's first call takes 3.7 to 4.5 s, then 0.31 to 0.37 s with about 1,700 reads (4.6 to 5.5 s each time at 32 views). 64 views was already enough on abso today; heap after the run is 32 MB either way.
Tests: view-cache's two count tests now use VIEW_COUNT. Named tests: view-cache, where-many-agents, draft-reads-stored, project, membership-cache, files-reads, collision-streaming, authors-stored (42 of 42); tsc and biome clean.
Version 233 · Files at version 234
2 files, 17 lines added, 10 removed.
--- a/worker/project/test/view-cache.test.ts
+++ b/worker/project/test/view-cache.test.ts
@@ -4,7 +4,7 @@
4 4 import { buildBase, Graph, View } from "../../../src/engine/index.ts"; 5 5 import { StableOverlaySet } from "../../../src/engine/state-source.ts"; 6 6 import type { AtomId } from "../../../src/engine/types.ts"; 7 − import { ViewCache } from "../views.ts";
7 + import { VIEW_COUNT, ViewCache } from "../views.ts"; 9 9 const VIEW_BUDGET = 24_000_000; @@ -25,7 +25,7 @@
25 25 assert.equal(cache.view(set), view); 26 26 assert.equal(set.iterations, 1, "cache hit must not construct a full-history key"); 27 27 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"])); 29 29 assert.notEqual(cache.view(set), view, "indexed identities obey the same cache eviction limit"); 30 30 assert.equal(set.iterations, 2); @@ -76,16 +76,16 @@
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", () => { 80 80 withControlledWeights((control) => { 81 81 const cache = new ViewCache(new Graph()); 82 − control.setIncomingWeights(Array(33).fill(0));
82 + control.setIncomingWeights(Array(VIEW_COUNT + 1).fill(0)); 83 83 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}`)); 85 85 assert.equal(get(cache, "key-0"), first); 86 − const last = get(cache, "key-32");
86 + const last = get(cache, `key-${VIEW_COUNT}`); 87 87 assert.equal(get(cache, "key-0"), first); 88 − assert.equal(get(cache, "key-32"), last);
88 + assert.equal(get(cache, `key-${VIEW_COUNT}`), last); 89 89 for (let i = 1; i < retained.length; i++) assert.equal(get(cache, `key-${i + 1}`), retained[i]); 90 90 assert.notEqual(get(cache, "key-1"), retained[0]); --- a/worker/project/views.ts
+++ b/worker/project/views.ts
@@ -12,12 +12,19 @@
13 13 const VIEW_BUDGET = 24_000_000; 16 + * At most this many views (abso Capacity). where visits every agent's draft view in turn: with more agents than views, 17 + * each visit evicted the next one, and a warm where on abso laid every view out again (4.5 s against 0.33 s). The byte 18 + * budget still bounds what they hold. 20 + export const VIEW_COUNT = 128; 15 22 /** Internal opt-in. The owner validates identity and lifetime on every returned reader. */ 16 23 export interface ReadViewProvider { 17 24 keyed(key: string): ReadView; 20 − /** Views by key, most recently used last, held under VIEW_BUDGET bytes and 32 views. */
27 + /** Views by key, most recently used last, held under VIEW_BUDGET bytes and VIEW_COUNT views. */ 21 28 export class ViewCache { 22 29 readonly #graph: Graph; 23 30 readonly #provider?: ReadViewProvider; @@ -34,13 +41,13 @@
35 42 * Keep the cached views under VIEW_BUDGET bytes (the website project, #43, 36 43 * #46): each view holds every line its files ever had, so a few views of a 37 − * large generated file add up. At most 32.
44 + * large generated file add up. At most VIEW_COUNT. 41 48 for (const v of this.#cache.values()) total += v.weight(); 42 49 for (const [key, v] of this.#cache) { 43 − if (total <= VIEW_BUDGET && this.#cache.size <= 32) break;
50 + if (total <= VIEW_BUDGET && this.#cache.size <= VIEW_COUNT) break; 44 51 total -= v.weight(); 45 52 this.#cache.delete(key);