Issue 6: status no longer builds every agent's view. On abso's log (13,148 entries, 48 agents) status went from about 330 ms to 1 ms median (30 ms max) in Node. Version 55 of shared· engine· Oct 9 (2026-10-09 23:29 UTC) · Not checked
markedCollisions skips the view when the agent has no marked files (most have none). This was most of the cost. draftFiles skips the view when the draft is empty, and Project keeps each agent's draft files under their view key plus the draft, so they're worked out again only when either moves. Overlaps and overlap news use the kept ones too. New test (draft-files-kept): status from a warm project equals a cold load after every step, in shared and with two agents in one named draft (Pinch's case). A weaker key fails it. Version 54 · Files at version 55
4 files, 107 lines added, 9 removed.
--- a/worker/project/markers.ts
+++ b/worker/project/markers.ts
@@ -287,9 +287,12 @@
288 288 /** The blocks of markers still in the agent's files, as collisions (#11): listed by sync and status. */ 289 289 export function markedCollisions(host: MarkerHost, agent: AgentState): Collision[] { 290 + const files = markedFiles(agent); 291 + // No marked files, no view to build (abso-core issue 6): most agents have none. 292 + if (files.length === 0) return []; 290 293 const view = host.agentView(agent); 291 294 const out: Collision[] = []; 292 − for (const file of markedFiles(agent)) {
295 + for (const file of files) { 293 296 if (!view.hasFile(file)) continue; 294 297 for (const b of blocksIn(view.lines(file).map((l) => l.text))) out.push(blockCollision(file, b)); --- a/worker/project/overlaps.ts
+++ b/worker/project/overlaps.ts
@@ -24,6 +24,8 @@
24 24 readonly agents: ReadonlyMap<string, AgentState>; 25 25 agentView(agent: AgentState): View; 26 26 draft(agent: AgentState): readonly AtomId[]; 27 + /** draftFiles below, kept per agent by the host. */ 28 + draftFiles(agent: AgentState): Set<string>; 27 29 liveNote(agent: AgentState): Starting | undefined; 28 30 queueNews(agent: AgentState, items: readonly NewsItem[], entries: Entry[]): void; @@ -64,8 +66,11 @@
64 66 /** The files the agent's unpublished changes touch, in its own view. */ 65 67 export function draftFiles(host: OverlapHost, agent: AgentState): Set<string> { 66 68 const files = new Set<string>(); 69 + const draft = host.draft(agent); 70 + // No draft, no view to build: most agents in a big project have nothing unpublished. 71 + if (draft.length === 0) return files; 67 72 const view = host.agentView(agent); 68 − for (const id of host.draft(agent)) {
73 + for (const id of draft) { 69 74 const atom = host.graph.atom(id); 70 75 for (const run of atom.inserts) files.add(isStartNode(run.parent) ? run.file : view.fileOf(run.parent)); 71 76 for (const line of atom.deletes) files.add(view.fileOf(line)); @@ -81,7 +86,7 @@
81 86 .filter((other) => other !== agent && other.space === agent.space) 84 − files: draftFiles(host, other),
89 + files: host.draftFiles(other), 85 90 changesIn: (file: string) => host.draft(other).filter((id) => host.graph.filesOf(id).includes(file)).length, 86 91 note: host.liveNote(other), @@ -94,7 +99,7 @@
96 101 export function overlapNews(host: OverlapHost, agent: AgentState, before: ReadonlySet<string>, entries: Entry[]): void { 97 − const now = draftFiles(host, agent);
102 + const now = host.draftFiles(agent); 98 103 const fresh = [...now].filter((f) => !before.has(f)).toSorted(); 99 104 if (fresh.length === 0) return; 100 105 host.queueNews(agent, overlapItems(host.draft(agent)[0] ?? "", overlaps(host, agent, fresh)), entries); --- a/worker/project/project.ts
+++ b/worker/project/project.ts
@@ -225,6 +225,8 @@
225 225 readonly #graph: Graph; 226 226 /** Views laid out from atom sets, cached under a byte budget (views.ts). */ 227 227 readonly #views: ViewCache; 228 + /** Each agent's draft files, under the key they were worked out for (#draftFiles). */ 229 + readonly #draftFilesKept = new Map<string, { key: string; files: Set<string> }>(); 228 230 /** Each version's files and each path's history (pathindex.ts). */ 229 231 readonly #paths: PathIndex; 230 232 /** For each atom (by seq) that wrote lines, the log position of the entry that recorded it (#46). */ @@ -992,9 +994,20 @@
995 − /** The files the agent's unpublished changes touch, in its own view. */
996 − #draftFiles(...args: Tail<Parameters<typeof hostedDraftFiles>>): ReturnType<typeof hostedDraftFiles> {
997 − return hostedDraftFiles(this.#overlapHost, ...args);
998 + * The files the agent's unpublished changes touch, in its own view. Kept per agent under what they're 999 + * made of (abso-core issue 6): its view's key and its draft. Most agents haven't moved since the last 1000 + * status, and the view cache holds fewer views than a big project has agents, so working them out again 1001 + * on every call cost about 0.5 s on abso. A copy goes out, so no caller can change what's kept. 1003 + #draftFiles(agent: AgentState): Set<string> { 1004 + const key = `${this.#agentViewKey(agent)}|${this.#draft(agent).join(",")}`; 1005 + let kept = this.#draftFilesKept.get(agent.name); 1006 + if (kept?.key !== key) { 1007 + kept = { key, files: hostedDraftFiles(this.#overlapHost, agent) }; 1008 + this.#draftFilesKept.set(agent.name, kept); 1010 + return new Set(kept.files); 1000 1013 /** Other agents in the agent's space whose unpublished changes or starting note meet `patterns`. */ @@ -2028,6 +2041,7 @@
2028 2041 agents: this.#agents, 2029 2042 agentView: (agent) => this.#agentView(agent), 2030 2043 draft: (agent) => this.#draft(agent), 2044 + draftFiles: (agent) => this.#draftFiles(agent), 2031 2045 liveNote: (agent) => this.#liveNote(agent), 2032 2046 queueNews: (agent, items, entries) => this.#queueNews(agent, items, entries), @@ -2217,10 +2231,14 @@
2219 2233 #agentView(agent: AgentState): View { 2220 − // Keyed by what the set is made of, not by sorting every atom in it (#46): that cost more than the work.
2221 − return this.#viewKeyed(`a ${agent.space}@${agent.base}+${agent.mine.join(",")}`, () => this.#agentSet(agent));
2234 + return this.#viewKeyed(this.#agentViewKey(agent), () => this.#agentSet(agent)); 2237 + /** An agent's view, keyed by what the set is made of, not by sorting every atom in it (#46): that cost more than the work. */ 2238 + #agentViewKey(agent: AgentState): string { 2239 + return `a ${agent.space}@${agent.base}+${agent.mine.join(",")}`; 2224 2242 /** A space at a version: published versions never change, so the key is just their names (#46). */ 2225 2243 #viewAt(space: Space, version: number): View { 2226 2244 return this.#viewKeyed(`v ${space.name}@${version}`, () => this.#at(space, version)); --- /dev/null
+++ b/worker/project/test/draft-files-kept.test.ts
@@ -0,0 +1,72 @@
1 + // Each agent's draft files are kept between calls (abso-core issue 6). Status 2 + // must answer as a project that works them out cold does, after every kind of 3 + // step, in shared and in a named draft. 5 + import assert from "node:assert/strict"; 6 + import { test } from "node:test"; 7 + import { MemoryStore, Project } from "../project.ts"; 10 + "core.ts": "export function step(x: number) {\n return x + 1;\n}\n\nexport const version = 1;\n", 11 + "notes.md": "one\ntwo\nthree\n", 15 + const store = new MemoryStore(); 16 + const project = new Project(store); 17 + project.init(START, 0); 18 + for (const a of ["ann", "bob", "cat"]) project.sync(a); 19 + // Warm: every agent's draft files are kept from here on. 21 + return { project, store }; 24 + /** Status from the warm project, checked against the same log loaded cold. */ 25 + function same(project: Project, store: MemoryStore, step: string) { 26 + const warm = project.status(); 27 + assert.deepEqual(warm, Project.load(store.entries, new MemoryStore()).status(), `after ${step}`); 31 + const filesOf = (status: ReturnType<Project["status"]>, agent: string) => 32 + status.agents.find((a) => a.agent === agent)!.files; 34 + test("status answers the same warm and cold through records, publishes and syncs in shared", () => { 35 + const { project, store } = setup(); 36 + project.edit("ann", { file: "core.ts", old: " return x + 1;", new: " return x + 2;" }, 1); 37 + assert.deepEqual(filesOf(same(project, store, "ann's edit"), "ann"), ["core.ts"]); 38 + project.edit("ann", { file: "notes.md", old: "two\n", new: "two!\n" }, 2); 39 + assert.deepEqual(filesOf(same(project, store, "ann's second edit"), "ann"), ["core.ts", "notes.md"]); 40 + project.edit("bob", { file: "notes.md", old: "three\n", new: "three!\n" }, 3); 41 + same(project, store, "bob's edit"); 42 + project.publish("ann", "Ann's two", 4); 43 + assert.deepEqual(filesOf(same(project, store, "ann's publish"), "ann"), []); 45 + assert.deepEqual(filesOf(same(project, store, "bob's sync"), "bob"), ["notes.md"]); 46 + project.record("cat", { "new.ts": "export {};\n" }, 5); 47 + assert.deepEqual(filesOf(same(project, store, "cat's new file"), "cat"), ["new.ts"]); 48 + project.publish("cat", "Cat's file", 6); 49 + same(project, store, "cat's publish"); 52 + test("two agents in one named draft: one publishes, and the other's status still matches a cold load", () => { 53 + const { project, store } = setup(); 54 + project.switchTo("ann", "rw", 1); 55 + project.switchTo("bob", "rw", 2); 56 + same(project, store, "both switch"); 57 + project.edit("ann", { file: "core.ts", old: " return x + 1;", new: " return x * 2;" }, 3); 58 + project.edit("bob", { file: "notes.md", old: "one\n", new: "one (rw)\n" }, 4); 59 + const before = same(project, store, "both edit in rw"); 60 + assert.deepEqual(filesOf(before, "bob"), ["notes.md"]); 61 + project.publish("ann", "Double", 5); 62 + const after = same(project, store, "ann publishes into rw"); 63 + assert.deepEqual(filesOf(after, "ann"), []); 65 + assert.deepEqual(filesOf(same(project, store, "bob syncs in rw"), "bob"), ["notes.md"]); 66 + project.publish("bob", "Note", 6); 67 + assert.deepEqual(filesOf(same(project, store, "bob publishes into rw"), "bob"), []); 68 + project.land("ann", "Land rw", 7); 69 + same(project, store, "rw lands"); 70 + project.switchTo("ann", "shared", 8); 71 + same(project, store, "ann back in shared");