{"file":"worker/project/test/view-cache.test.ts","version":318,"total":187,"from":1,"to":187,"lines":[{"n":1,"text":"import assert from \"node:assert/strict\";","atom":"a940","author":"codex-capacity-policy","version":104},{"n":2,"text":"import { test } from \"node:test\";","atom":"a940","author":"codex-capacity-policy","version":104},{"n":3,"text":"import type { ReadView } from \"../../../src/engine/index.ts\";","atom":"a1362","author":"codex-capacity-chair","version":143},{"n":4,"text":"import { buildBase, Graph, View } from \"../../../src/engine/index.ts\";","atom":"a940","author":"codex-capacity-policy","version":104},{"n":5,"text":"import { StableOverlaySet } from \"../../../src/engine/state-source.ts\";","atom":"a1033","author":"codex-capacity-chair","version":117},{"n":6,"text":"import type { AtomId } from \"../../../src/engine/types.ts\";","atom":"a1033","author":"codex-capacity-chair","version":117},{"n":7,"text":"import { VIEW_COUNT, ViewCache } from \"../views.ts\";","atom":"a2448","author":"capacity","version":234},{"n":8,"text":"","atom":"a940","author":"codex-capacity-policy","version":104},{"n":9,"text":"const VIEW_BUDGET = 24_000_000;","atom":"a940","author":"codex-capacity-policy","version":104},{"n":10,"text":"","atom":"a1033","author":"codex-capacity-chair","version":117},{"n":11,"text":"test(\"indexed view cache keys never enumerate membership and remain bounded by eviction\", () => {","atom":"a1033","author":"codex-capacity-chair","version":117},{"n":12,"text":"\tclass Counted extends StableOverlaySet<AtomId> {","atom":"a1033","author":"codex-capacity-chair","version":117},{"n":13,"text":"\t\titerations = 0;","atom":"a1033","author":"codex-capacity-chair","version":117},{"n":14,"text":"\t\toverride values(): SetIterator<AtomId> {","atom":"a1033","author":"codex-capacity-chair","version":117},{"n":15,"text":"\t\t\tthis.iterations++;","atom":"a1033","author":"codex-capacity-chair","version":117},{"n":16,"text":"\t\t\treturn super.values();","atom":"a1033","author":"codex-capacity-chair","version":117},{"n":17,"text":"\t\t}","atom":"a1033","author":"codex-capacity-chair","version":117},{"n":18,"text":"\t}","atom":"a1033","author":"codex-capacity-chair","version":117},{"n":19,"text":"\tconst graph = new Graph();","atom":"a1033","author":"codex-capacity-chair","version":117},{"n":20,"text":"\tgraph.add(buildBase({ \"a.txt\": \"one\\n\" }, { author: \"test\", message: \"base\" }));","atom":"a1033","author":"codex-capacity-chair","version":117},{"n":21,"text":"\tconst cache = new ViewCache(graph);","atom":"a1033","author":"codex-capacity-chair","version":117},{"n":22,"text":"\tconst set = new Counted([\"a0\"]);","atom":"a1033","author":"codex-capacity-chair","version":117},{"n":23,"text":"\tconst view = cache.view(set);","atom":"a1033","author":"codex-capacity-chair","version":117},{"n":24,"text":"\tassert.equal(set.iterations, 1, \"only View closure validation enumerates membership\");","atom":"a1033","author":"codex-capacity-chair","version":117},{"n":25,"text":"\tassert.equal(cache.view(set), view);","atom":"a1033","author":"codex-capacity-chair","version":117},{"n":26,"text":"\tassert.equal(set.iterations, 1, \"cache hit must not construct a full-history key\");","atom":"a1033","author":"codex-capacity-chair","version":117},{"n":27,"text":"\tassert.equal(view.text(\"a.txt\"), \"one\\n\");","atom":"a1033","author":"codex-capacity-chair","version":117},{"n":28,"text":"\tfor (let i = 0; i < VIEW_COUNT + 1; i++) cache.view(new Counted([\"a0\"]));","atom":"a2448","author":"capacity","version":234},{"n":29,"text":"\tassert.notEqual(cache.view(set), view, \"indexed identities obey the same cache eviction limit\");","atom":"a1033","author":"codex-capacity-chair","version":117},{"n":30,"text":"\tassert.equal(set.iterations, 2);","atom":"a1033","author":"codex-capacity-chair","version":117},{"n":31,"text":"});","atom":"a1033","author":"codex-capacity-chair","version":117},{"n":32,"text":"","atom":"a940","author":"codex-capacity-policy","version":104},{"n":33,"text":"type WeightControls = {","atom":"a940","author":"codex-capacity-policy","version":104},{"n":34,"text":"\tsetIncomingWeights(values: number[]): void;","atom":"a940","author":"codex-capacity-policy","version":104},{"n":35,"text":"\tsetWeight(view: ReadView, weight: number): void;","atom":"a1362","author":"codex-capacity-chair","version":143},{"n":36,"text":"};","atom":"a940","author":"codex-capacity-policy","version":104},{"n":37,"text":"","atom":"a940","author":"codex-capacity-policy","version":104},{"n":38,"text":"function withControlledWeights(run: (controls: WeightControls) => void): void {","atom":"a940","author":"codex-capacity-policy","version":104},{"n":39,"text":"\tconst original = Object.getOwnPropertyDescriptor(View.prototype, \"weight\")!;","atom":"a940","author":"codex-capacity-policy","version":104},{"n":40,"text":"\tconst weights = new WeakMap<ReadView, number>();","atom":"a1362","author":"codex-capacity-chair","version":143},{"n":41,"text":"\tlet newWeights: number[] = [];","atom":"a940","author":"codex-capacity-policy","version":104},{"n":42,"text":"\tObject.defineProperty(View.prototype, \"weight\", {","atom":"a940","author":"codex-capacity-policy","version":104},{"n":43,"text":"\t\tconfigurable: true,","atom":"a940","author":"codex-capacity-policy","version":104},{"n":44,"text":"\t\tvalue(this: ReadView) {","atom":"a1362","author":"codex-capacity-chair","version":143},{"n":45,"text":"\t\t\tif (!weights.has(this)) weights.set(this, newWeights.shift() ?? 0);","atom":"a940","author":"codex-capacity-policy","version":104},{"n":46,"text":"\t\t\treturn weights.get(this)!;","atom":"a940","author":"codex-capacity-policy","version":104},{"n":47,"text":"\t\t},","atom":"a940","author":"codex-capacity-policy","version":104},{"n":48,"text":"\t});","atom":"a940","author":"codex-capacity-policy","version":104},{"n":49,"text":"\tconst controls: WeightControls = {","atom":"a940","author":"codex-capacity-policy","version":104},{"n":50,"text":"\t\tsetWeight: (view, weight) => {","atom":"a940","author":"codex-capacity-policy","version":104},{"n":51,"text":"\t\t\tweights.set(view, weight);","atom":"a940","author":"codex-capacity-policy","version":104},{"n":52,"text":"\t\t},","atom":"a940","author":"codex-capacity-policy","version":104},{"n":53,"text":"\t\tsetIncomingWeights: (values) => {","atom":"a940","author":"codex-capacity-policy","version":104},{"n":54,"text":"\t\t\tnewWeights = [...values];","atom":"a940","author":"codex-capacity-policy","version":104},{"n":55,"text":"\t\t},","atom":"a940","author":"codex-capacity-policy","version":104},{"n":56,"text":"\t};","atom":"a940","author":"codex-capacity-policy","version":104},{"n":57,"text":"\ttry {","atom":"a940","author":"codex-capacity-policy","version":104},{"n":58,"text":"\t\trun(controls);","atom":"a940","author":"codex-capacity-policy","version":104},{"n":59,"text":"\t} finally {","atom":"a940","author":"codex-capacity-policy","version":104},{"n":60,"text":"\t\tObject.defineProperty(View.prototype, \"weight\", original);","atom":"a940","author":"codex-capacity-policy","version":104},{"n":61,"text":"\t}","atom":"a940","author":"codex-capacity-policy","version":104},{"n":62,"text":"}","atom":"a940","author":"codex-capacity-policy","version":104},{"n":63,"text":"","atom":"a940","author":"codex-capacity-policy","version":104},{"n":64,"text":"function get(cache: ViewCache, key: string): ReadView {","atom":"a1362","author":"codex-capacity-chair","version":143},{"n":65,"text":"\treturn cache.keyed(key, () => new Set());","atom":"a940","author":"codex-capacity-policy","version":104},{"n":66,"text":"}","atom":"a940","author":"codex-capacity-policy","version":104},{"n":67,"text":"","atom":"a940","author":"codex-capacity-policy","version":104},{"n":68,"text":"test(\"the incoming view counts toward the retained byte budget\", () => {","atom":"a940","author":"codex-capacity-policy","version":104},{"n":69,"text":"\twithControlledWeights((control) => {","atom":"a940","author":"codex-capacity-policy","version":104},{"n":70,"text":"\t\tconst cache = new ViewCache(new Graph());","atom":"a940","author":"codex-capacity-policy","version":104},{"n":71,"text":"\t\tcontrol.setIncomingWeights([10_000_000, 15_000_001]);","atom":"a940","author":"codex-capacity-policy","version":104},{"n":72,"text":"\t\tconst old = get(cache, \"old\");","atom":"a940","author":"codex-capacity-policy","version":104},{"n":73,"text":"\t\tconst incoming = get(cache, \"incoming\");","atom":"a940","author":"codex-capacity-policy","version":104},{"n":74,"text":"\t\tassert.equal(get(cache, \"incoming\"), incoming);","atom":"a940","author":"codex-capacity-policy","version":104},{"n":75,"text":"\t\tassert.notEqual(get(cache, \"old\"), old);","atom":"a940","author":"codex-capacity-policy","version":104},{"n":76,"text":"\t});","atom":"a940","author":"codex-capacity-policy","version":104},{"n":77,"text":"});","atom":"a940","author":"codex-capacity-policy","version":104},{"n":78,"text":"","atom":"a940","author":"codex-capacity-policy","version":104},{"n":79,"text":"test(\"the cache retains exactly VIEW_COUNT views and evicts the least recently used one\", () => {","atom":"a2448","author":"capacity","version":234},{"n":80,"text":"\twithControlledWeights((control) => {","atom":"a940","author":"codex-capacity-policy","version":104},{"n":81,"text":"\t\tconst cache = new ViewCache(new Graph());","atom":"a940","author":"codex-capacity-policy","version":104},{"n":82,"text":"\t\tcontrol.setIncomingWeights(Array(VIEW_COUNT + 1).fill(0));","atom":"a2448","author":"capacity","version":234},{"n":83,"text":"\t\tconst first = get(cache, \"key-0\");","atom":"a940","author":"codex-capacity-policy","version":104},{"n":84,"text":"\t\tconst retained = Array.from({ length: VIEW_COUNT - 1 }, (_, i) => get(cache, `key-${i + 1}`));","atom":"a2448","author":"capacity","version":234},{"n":85,"text":"\t\tassert.equal(get(cache, \"key-0\"), first);","atom":"a940","author":"codex-capacity-policy","version":104},{"n":86,"text":"\t\tconst last = get(cache, `key-${VIEW_COUNT}`);","atom":"a2448","author":"capacity","version":234},{"n":87,"text":"\t\tassert.equal(get(cache, \"key-0\"), first);","atom":"a940","author":"codex-capacity-policy","version":104},{"n":88,"text":"\t\tassert.equal(get(cache, `key-${VIEW_COUNT}`), last);","atom":"a2448","author":"capacity","version":234},{"n":89,"text":"\t\tfor (let i = 1; i < retained.length; i++) assert.equal(get(cache, `key-${i + 1}`), retained[i]);","atom":"a940","author":"codex-capacity-policy","version":104},{"n":90,"text":"\t\tassert.notEqual(get(cache, \"key-1\"), retained[0]);","atom":"a940","author":"codex-capacity-policy","version":104},{"n":91,"text":"\t});","atom":"a940","author":"codex-capacity-policy","version":104},{"n":92,"text":"});","atom":"a940","author":"codex-capacity-policy","version":104},{"n":93,"text":"","atom":"a940","author":"codex-capacity-policy","version":104},{"n":94,"text":"test(\"a repeated hit reweighs lazy growth and evicts older entries\", () => {","atom":"a940","author":"codex-capacity-policy","version":104},{"n":95,"text":"\twithControlledWeights((control) => {","atom":"a940","author":"codex-capacity-policy","version":104},{"n":96,"text":"\t\tconst cache = new ViewCache(new Graph());","atom":"a940","author":"codex-capacity-policy","version":104},{"n":97,"text":"\t\tcontrol.setIncomingWeights([10_000_000, 10_000_000]);","atom":"a940","author":"codex-capacity-policy","version":104},{"n":98,"text":"\t\tconst growing = get(cache, \"growing\");","atom":"a940","author":"codex-capacity-policy","version":104},{"n":99,"text":"\t\tconst older = get(cache, \"older\");","atom":"a940","author":"codex-capacity-policy","version":104},{"n":100,"text":"\t\tcontrol.setWeight(growing, 16_000_000);","atom":"a940","author":"codex-capacity-policy","version":104},{"n":101,"text":"\t\tassert.equal(get(cache, \"growing\"), growing);","atom":"a940","author":"codex-capacity-policy","version":104},{"n":102,"text":"\t\tassert.notEqual(get(cache, \"older\"), older);","atom":"a940","author":"codex-capacity-policy","version":104},{"n":103,"text":"\t});","atom":"a940","author":"codex-capacity-policy","version":104},{"n":104,"text":"});","atom":"a940","author":"codex-capacity-policy","version":104},{"n":105,"text":"","atom":"a940","author":"codex-capacity-policy","version":104},{"n":106,"text":"test(\"trim reweighs growth with no further hit and evicts until the views fit (abso Capacity)\", () => {","atom":"a2515","author":"capacity","version":247},{"n":107,"text":"\twithControlledWeights((control) => {","atom":"a2515","author":"capacity","version":247},{"n":108,"text":"\t\tconst cache = new ViewCache(new Graph());","atom":"a2515","author":"capacity","version":247},{"n":109,"text":"\t\tcontrol.setIncomingWeights([10_000_000, 10_000_000]);","atom":"a2515","author":"capacity","version":247},{"n":110,"text":"\t\tconst growing = get(cache, \"growing\");","atom":"a2515","author":"capacity","version":247},{"n":111,"text":"\t\tconst newer = get(cache, \"newer\");","atom":"a2515","author":"capacity","version":247},{"n":112,"text":"\t\t// A call lays files out in the older view after the cache last weighed it, and nothing asks for it again.","atom":"a2515","author":"capacity","version":247},{"n":113,"text":"\t\tcontrol.setWeight(growing, 16_000_000);","atom":"a2515","author":"capacity","version":247},{"n":114,"text":"\t\tcache.trim();","atom":"a2515","author":"capacity","version":247},{"n":115,"text":"\t\tassert.equal(get(cache, \"newer\"), newer);","atom":"a2515","author":"capacity","version":247},{"n":116,"text":"\t\tassert.notEqual(get(cache, \"growing\"), growing);","atom":"a2515","author":"capacity","version":247},{"n":117,"text":"\t});","atom":"a2515","author":"capacity","version":247},{"n":118,"text":"});","atom":"a2515","author":"capacity","version":247},{"n":119,"text":"","atom":"a2515","author":"capacity","version":247},{"n":120,"text":"test(\"an oversized view is returned but not retained\", () => {","atom":"a940","author":"codex-capacity-policy","version":104},{"n":121,"text":"\twithControlledWeights((control) => {","atom":"a940","author":"codex-capacity-policy","version":104},{"n":122,"text":"\t\tconst cache = new ViewCache(new Graph());","atom":"a940","author":"codex-capacity-policy","version":104},{"n":123,"text":"\t\tcontrol.setIncomingWeights([VIEW_BUDGET + 1, 0]);","atom":"a940","author":"codex-capacity-policy","version":104},{"n":124,"text":"\t\tconst oversized = get(cache, \"large\");","atom":"a940","author":"codex-capacity-policy","version":104},{"n":125,"text":"\t\tassert.ok(oversized instanceof View);","atom":"a940","author":"codex-capacity-policy","version":104},{"n":126,"text":"\t\tassert.notEqual(get(cache, \"large\"), oversized);","atom":"a940","author":"codex-capacity-policy","version":104},{"n":127,"text":"\t});","atom":"a940","author":"codex-capacity-policy","version":104},{"n":128,"text":"});","atom":"a940","author":"codex-capacity-policy","version":104},{"n":129,"text":"","atom":"a940","author":"codex-capacity-policy","version":104},{"n":130,"text":"test(\"cache eviction preserves real Graph and View layouts\", () => {","atom":"a940","author":"codex-capacity-policy","version":104},{"n":131,"text":"\tconst graph = new Graph();","atom":"a940","author":"codex-capacity-policy","version":104},{"n":132,"text":"\tgraph.add(","atom":"a940","author":"codex-capacity-policy","version":104},{"n":133,"text":"\t\tbuildBase(","atom":"a940","author":"codex-capacity-policy","version":104},{"n":134,"text":"\t\t\t{ \"notes.txt\": \"one\\ntwo\\n\", \"folder/readme.md\": \"cached view\\n\" },","atom":"a940","author":"codex-capacity-policy","version":104},{"n":135,"text":"\t\t\t{ author: \"test\", message: \"view cache\" },","atom":"a940","author":"codex-capacity-policy","version":104},{"n":136,"text":"\t\t),","atom":"a940","author":"codex-capacity-policy","version":104},{"n":137,"text":"\t);","atom":"a940","author":"codex-capacity-policy","version":104},{"n":138,"text":"\tconst set = new Set([\"a0\"]);","atom":"a940","author":"codex-capacity-policy","version":104},{"n":139,"text":"\tconst cache = new ViewCache(graph);","atom":"a940","author":"codex-capacity-policy","version":104},{"n":140,"text":"\tconst cached = cache.view(set);","atom":"a940","author":"codex-capacity-policy","version":104},{"n":141,"text":"\tconst expected = new View(graph, set);","atom":"a940","author":"codex-capacity-policy","version":104},{"n":142,"text":"\tassert.deepEqual(cached.files(), expected.files());","atom":"a940","author":"codex-capacity-policy","version":104},{"n":143,"text":"\tassert.equal(cached.text(\"notes.txt\"), expected.text(\"notes.txt\"));","atom":"a940","author":"codex-capacity-policy","version":104},{"n":144,"text":"\tfor (let i = 0; i < 40; i++) cache.keyed(`other-${i}`, () => set);","atom":"a940","author":"codex-capacity-policy","version":104},{"n":145,"text":"\tassert.deepEqual(cache.view(set).files(), new View(graph, set).files());","atom":"a940","author":"codex-capacity-policy","version":104},{"n":146,"text":"});","atom":"a940","author":"codex-capacity-policy","version":104},{"n":147,"text":"","atom":"a2669","author":"capacity","version":263},{"n":148,"text":"test(\"trim lets go of the least recently used file layouts across views before whole views (abso Capacity)\", () => {","atom":"a2669","author":"capacity","version":263},{"n":149,"text":"\tconst graph = new Graph();","atom":"a2669","author":"capacity","version":263},{"n":150,"text":"\tconst lines = (name: string) => Array.from({ length: 40 }, (_, i) => `${name} line ${i}\\n`).join(\"\");","atom":"a2669","author":"capacity","version":263},{"n":151,"text":"\tgraph.add(","atom":"a2669","author":"capacity","version":263},{"n":152,"text":"\t\tbuildBase({ \"a.txt\": lines(\"a\"), \"b.txt\": lines(\"b\"), \"c.txt\": lines(\"c\") }, { author: \"test\", message: \"base\" }),","atom":"a2669","author":"capacity","version":263},{"n":153,"text":"\t);","atom":"a2669","author":"capacity","version":263},{"n":154,"text":"\tconst set = new Set([\"a0\"]);","atom":"a2669","author":"capacity","version":263},{"n":155,"text":"\t// a.txt in x first, then b.txt in y, then c.txt in x: a.txt is the least recently used.","atom":"a2669","author":"capacity","version":263},{"n":156,"text":"\tconst use = (cache: ViewCache) => {","atom":"a2669","author":"capacity","version":263},{"n":157,"text":"\t\tconst x = cache.keyed(\"x\", () => set);","atom":"a2669","author":"capacity","version":263},{"n":158,"text":"\t\tconst y = cache.keyed(\"y\", () => set);","atom":"a2669","author":"capacity","version":263},{"n":159,"text":"\t\tx.text(\"a.txt\");","atom":"a2669","author":"capacity","version":263},{"n":160,"text":"\t\ty.text(\"b.txt\");","atom":"a2669","author":"capacity","version":263},{"n":161,"text":"\t\tx.text(\"c.txt\");","atom":"a2669","author":"capacity","version":263},{"n":162,"text":"\t\treturn { x: x as View, y: y as View };","atom":"a2669","author":"capacity","version":263},{"n":163,"text":"\t};","atom":"a2669","author":"capacity","version":263},{"n":164,"text":"\tconst probe = use(new ViewCache(graph));","atom":"a2669","author":"capacity","version":263},{"n":165,"text":"\tconst total = probe.x.weight() + probe.y.weight();","atom":"a2669","author":"capacity","version":263},{"n":166,"text":"\tconst cache = new ViewCache(graph, undefined, total - 1);","atom":"a2669","author":"capacity","version":263},{"n":167,"text":"\tconst { x, y } = use(cache);","atom":"a2669","author":"capacity","version":263},{"n":168,"text":"\tcache.trim();","atom":"a2669","author":"capacity","version":263},{"n":169,"text":"\tassert.deepEqual(","atom":"a2669","author":"capacity","version":263},{"n":170,"text":"\t\t[...x.laidOut()].map((f) => f.path),","atom":"a2669","author":"capacity","version":263},{"n":171,"text":"\t\t[\"c.txt\"],","atom":"a2669","author":"capacity","version":263},{"n":172,"text":"\t);","atom":"a2669","author":"capacity","version":263},{"n":173,"text":"\tassert.deepEqual(","atom":"a2669","author":"capacity","version":263},{"n":174,"text":"\t\t[...y.laidOut()].map((f) => f.path),","atom":"a2669","author":"capacity","version":263},{"n":175,"text":"\t\t[\"b.txt\"],","atom":"a2669","author":"capacity","version":263},{"n":176,"text":"\t);","atom":"a2669","author":"capacity","version":263},{"n":177,"text":"\tassert.equal(","atom":"a2669","author":"capacity","version":263},{"n":178,"text":"\t\tcache.keyed(\"x\", () => set),","atom":"a2669","author":"capacity","version":263},{"n":179,"text":"\t\tx,","atom":"a2669","author":"capacity","version":263},{"n":180,"text":"\t\t\"both views are still cached\",","atom":"a2669","author":"capacity","version":263},{"n":181,"text":"\t);","atom":"a2669","author":"capacity","version":263},{"n":182,"text":"\tassert.equal(","atom":"a2669","author":"capacity","version":263},{"n":183,"text":"\t\tcache.keyed(\"y\", () => set),","atom":"a2669","author":"capacity","version":263},{"n":184,"text":"\t\ty,","atom":"a2669","author":"capacity","version":263},{"n":185,"text":"\t);","atom":"a2669","author":"capacity","version":263},{"n":186,"text":"\tassert.equal(x.text(\"a.txt\"), lines(\"a\"), \"a.txt is laid out again, the same\");","atom":"a2669","author":"capacity","version":263},{"n":187,"text":"});","atom":"a2669","author":"capacity","version":263}],"atoms":[{"atom":"a940","author":"codex-capacity-policy","message":"","time":1791764348515,"timeIso":"2026-10-12T00:19:08.515Z","publish":{"draft":null,"version":104,"agent":"codex-capacity-policy","message":"Enforce retained view cache budget on access","time":1791764358789,"timeIso":"2026-10-12T00:19:18.789Z"}},{"atom":"a1033","author":"codex-capacity-chair","message":"","time":1791830650743,"timeIso":"2026-10-12T18:44:10.743Z","publish":{"draft":null,"version":117,"agent":"codex-capacity-chair","message":"Avoid full membership enumeration for indexed view cache keys","time":1791830705289,"timeIso":"2026-10-12T18:45:05.289Z"}},{"atom":"a1362","author":"codex-capacity-chair","message":"","time":1791854964720,"timeIso":"2026-10-13T01:29:24.720Z","publish":{"draft":null,"version":143,"agent":"codex-capacity-chair","message":"Add inactive disk projection provider and verified transactional readers (#16)","time":1791855032023,"timeIso":"2026-10-13T01:30:32.023Z"}},{"atom":"a2448","author":"capacity","message":"","time":1792059512104,"timeIso":"2026-10-15T10:18:32.104Z","publish":{"draft":null,"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"}},{"atom":"a2515","author":"capacity","message":"","time":1792080878721,"timeIso":"2026-10-15T16:14:38.721Z","publish":{"draft":null,"version":247,"agent":"capacity","message":"A kept reader settles after each read; line texts weigh what V8 holds (abso Capacity, issue 664).\n\nWhat a kept reader held on abso, measured per question without the answer itself (heap snapshot after tree with authors, 56.9 MB held): the view cache 38.3 MB against its 24 MB budget, the agents read 6.5 to 7.7 MB, the move skeleton 2.4 MB, the state cache 2.3 MB; the rest is the engine's indexes.\n\n- Project.afterRead: the view cache trimmed to its budget (ViewCache.trim) and the agents the read decoded let go (WriterAgents.release). Views grow while a call lays files out and the cache weighed them only when asked for again; a read-only reader never flushed its agents, so it held every agent's news told.\n- View weight: a laid-out line's text counts a 16-byte header and a byte a character (two outside Latin-1), rounded to 8, as V8 holds it. It counted 8 and two a character, so abso's whole shared layout (22.7 MB held) weighed about 28 MB, over the budget alone: once trimmed, it was laid out again for every question (blame folder 2.5 s became 14.4 s).\n\nFull warm run on the abso export: held heap at most 41.7 MB (was 56.9), 24 to 29 MB between the big reads (was 32 to 37); every answer the same. Status and drafts take about 30 ms more (agents read again); blame folder 1.7 s instead of 2.5 s.\n\nTests: view-cache (trim reweighs growth with no further hit), after-read (new: reads before and after it, and a write after it, against the in-memory project), and the collision, path and compare tests: 21 of 21.","time":1792081233526,"timeIso":"2026-10-15T16:20:33.526Z"}},{"atom":"a2669","author":"capacity","message":"","time":1792096799565,"timeIso":"2026-10-15T20:39:59.565Z","publish":{"draft":null,"version":263,"agent":"capacity","message":"The view cache trims the least recently used file layouts across its views before whole views (abso Capacity, issue 664).\n\nAfter each read, a kept reader's trim (ViewCache.trim, from afterRead) now lets go of file layouts in the order they were last used, across every cached view, until the views fit; a layout several views share (a draft's view borrows its base's) counts once and goes from all of them. Only then does it evict whole views. It evicted whole views before, so a call that laid out two big versions lost one of them entirely. Within a read, the cache trims whole views as before. A forgotten layout is laid out again, the same, when next asked.\n\nOn the abso export, collisions then compare 612 to 1224 asked again (Testing's order): 4.4 s and 17,349 queries, from 7.4 to 9.5 s. Compare alone needs about 25 MB of layouts, more than the 24 MB budget, so about half are laid out again; the rest needs a bigger budget or lighter layouts.\n\nView records each file's last use (a count shared by all views) and can forget one (laidOut, forget); ViewCache takes an optional budget, for tests. Tests: view-cache (new: the least recently used layout goes first, both views stay cached, and the forgotten file reads the same); view's retained-state test still holds. All of src/engine/test (294) and worker/project/test (354) pass.","time":1792096802015,"timeIso":"2026-10-15T20:40:02.015Z"}}]}