{"version":234,"agent":"capacity","message":"The view cache holds up to 128 views, still within its byte budget (disk-first 2; abso Capacity).\n\nwhere 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.\n\nVIEW_COUNT is now 128. The byte budget (VIEW_BUDGET, 24 MB) still bounds what the views hold.\n\nOn 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.\n\nTests: 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.","time":1792059512445,"timeIso":"2026-10-15T10:18:32.445Z","changes":2,"change":3674,"files":["worker/project/test/view-cache.test.ts","worker/project/views.ts"],"draft":null,"diff":[{"path":"worker/project/test/view-cache.test.ts","added":7,"removed":7,"diff":"--- a/worker/project/test/view-cache.test.ts\n+++ b/worker/project/test/view-cache.test.ts\n@@ -4,7 +4,7 @@\n import { buildBase, Graph, View } from \"../../../src/engine/index.ts\";\n import { StableOverlaySet } from \"../../../src/engine/state-source.ts\";\n import type { AtomId } from \"../../../src/engine/types.ts\";\n-import { ViewCache } from \"../views.ts\";\n+import { VIEW_COUNT, ViewCache } from \"../views.ts\";\n \n const VIEW_BUDGET = 24_000_000;\n \n@@ -25,7 +25,7 @@\n \tassert.equal(cache.view(set), view);\n \tassert.equal(set.iterations, 1, \"cache hit must not construct a full-history key\");\n \tassert.equal(view.text(\"a.txt\"), \"one\\n\");\n-\tfor (let i = 0; i < 33; i++) cache.view(new Counted([\"a0\"]));\n+\tfor (let i = 0; i < VIEW_COUNT + 1; i++) cache.view(new Counted([\"a0\"]));\n \tassert.notEqual(cache.view(set), view, \"indexed identities obey the same cache eviction limit\");\n \tassert.equal(set.iterations, 2);\n });\n@@ -76,16 +76,16 @@\n \t});\n });\n \n-test(\"the cache retains exactly 32 views and evicts the least recently used one\", () => {\n+test(\"the cache retains exactly VIEW_COUNT views and evicts the least recently used one\", () => {\n \twithControlledWeights((control) => {\n \t\tconst cache = new ViewCache(new Graph());\n-\t\tcontrol.setIncomingWeights(Array(33).fill(0));\n+\t\tcontrol.setIncomingWeights(Array(VIEW_COUNT + 1).fill(0));\n \t\tconst first = get(cache, \"key-0\");\n-\t\tconst retained = Array.from({ length: 31 }, (_, i) => get(cache, `key-${i + 1}`));\n+\t\tconst retained = Array.from({ length: VIEW_COUNT - 1 }, (_, i) => get(cache, `key-${i + 1}`));\n \t\tassert.equal(get(cache, \"key-0\"), first);\n-\t\tconst last = get(cache, \"key-32\");\n+\t\tconst last = get(cache, `key-${VIEW_COUNT}`);\n \t\tassert.equal(get(cache, \"key-0\"), first);\n-\t\tassert.equal(get(cache, \"key-32\"), last);\n+\t\tassert.equal(get(cache, `key-${VIEW_COUNT}`), last);\n \t\tfor (let i = 1; i < retained.length; i++) assert.equal(get(cache, `key-${i + 1}`), retained[i]);\n \t\tassert.notEqual(get(cache, \"key-1\"), retained[0]);\n \t});"},{"path":"worker/project/views.ts","added":10,"removed":3,"diff":"--- a/worker/project/views.ts\n+++ b/worker/project/views.ts\n@@ -12,12 +12,19 @@\n  */\n const VIEW_BUDGET = 24_000_000;\n \n+/**\n+ * At most this many views (abso Capacity). where visits every agent's draft view in turn: with more agents than views,\n+ * 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\n+ * budget still bounds what they hold.\n+ */\n+export const VIEW_COUNT = 128;\n+\n /** Internal opt-in. The owner validates identity and lifetime on every returned reader. */\n export interface ReadViewProvider {\n \tkeyed(key: string): ReadView;\n }\n \n-/** Views by key, most recently used last, held under VIEW_BUDGET bytes and 32 views. */\n+/** Views by key, most recently used last, held under VIEW_BUDGET bytes and VIEW_COUNT views. */\n export class ViewCache {\n \treadonly #graph: Graph;\n \treadonly #provider?: ReadViewProvider;\n@@ -34,13 +41,13 @@\n \t/**\n \t * Keep the cached views under VIEW_BUDGET bytes (the website project, #43,\n \t * #46): each view holds every line its files ever had, so a few views of a\n-\t * large generated file add up. At most 32.\n+\t * large generated file add up. At most VIEW_COUNT.\n \t */\n \t#trim(): void {\n \t\tlet total = 0;\n \t\tfor (const v of this.#cache.values()) total += v.weight();\n \t\tfor (const [key, v] of this.#cache) {\n-\t\t\tif (total <= VIEW_BUDGET && this.#cache.size <= 32) break;\n+\t\t\tif (total <= VIEW_BUDGET && this.#cache.size <= VIEW_COUNT) break;\n \t\t\ttotal -= v.weight();\n \t\t\tthis.#cache.delete(key);\n \t\t}"}],"ci":null}