{"version":55,"agent":"engine","message":"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.\n\n- markedCollisions skips the view when the agent has no marked files (most have none). This was most of the cost.\n- 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.\n- 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.","time":1791588583121,"timeIso":"2026-10-09T23:29:43.121Z","changes":5,"change":662,"files":["worker/project/markers.ts","worker/project/overlaps.ts","worker/project/project.ts","worker/project/test/draft-files-kept.test.ts"],"draft":null,"diff":[{"path":"worker/project/markers.ts","added":4,"removed":1,"diff":"--- a/worker/project/markers.ts\n+++ b/worker/project/markers.ts\n@@ -287,9 +287,12 @@\n \n /** The blocks of markers still in the agent's files, as collisions (#11): listed by sync and status. */\n export function markedCollisions(host: MarkerHost, agent: AgentState): Collision[] {\n+\tconst files = markedFiles(agent);\n+\t// No marked files, no view to build (abso-core issue 6): most agents have none.\n+\tif (files.length === 0) return [];\n \tconst view = host.agentView(agent);\n \tconst out: Collision[] = [];\n-\tfor (const file of markedFiles(agent)) {\n+\tfor (const file of files) {\n \t\tif (!view.hasFile(file)) continue;\n \t\tfor (const b of blocksIn(view.lines(file).map((l) => l.text))) out.push(blockCollision(file, b));\n \t}"},{"path":"worker/project/overlaps.ts","added":8,"removed":3,"diff":"--- a/worker/project/overlaps.ts\n+++ b/worker/project/overlaps.ts\n@@ -24,6 +24,8 @@\n \treadonly agents: ReadonlyMap<string, AgentState>;\n \tagentView(agent: AgentState): View;\n \tdraft(agent: AgentState): readonly AtomId[];\n+\t/** draftFiles below, kept per agent by the host. */\n+\tdraftFiles(agent: AgentState): Set<string>;\n \tliveNote(agent: AgentState): Starting | undefined;\n \tqueueNews(agent: AgentState, items: readonly NewsItem[], entries: Entry[]): void;\n }\n@@ -64,8 +66,11 @@\n /** The files the agent's unpublished changes touch, in its own view. */\n export function draftFiles(host: OverlapHost, agent: AgentState): Set<string> {\n \tconst files = new Set<string>();\n+\tconst draft = host.draft(agent);\n+\t// No draft, no view to build: most agents in a big project have nothing unpublished.\n+\tif (draft.length === 0) return files;\n \tconst view = host.agentView(agent);\n-\tfor (const id of host.draft(agent)) {\n+\tfor (const id of draft) {\n \t\tconst atom = host.graph.atom(id);\n \t\tfor (const run of atom.inserts) files.add(isStartNode(run.parent) ? run.file : view.fileOf(run.parent));\n \t\tfor (const line of atom.deletes) files.add(view.fileOf(line));\n@@ -81,7 +86,7 @@\n \t\t.filter((other) => other !== agent && other.space === agent.space)\n \t\t.map((other) => ({\n \t\t\tname: other.name,\n-\t\t\tfiles: draftFiles(host, other),\n+\t\t\tfiles: host.draftFiles(other),\n \t\t\tchangesIn: (file: string) => host.draft(other).filter((id) => host.graph.filesOf(id).includes(file)).length,\n \t\t\tnote: host.liveNote(other),\n \t\t}));\n@@ -94,7 +99,7 @@\n  * the edit.\n  */\n export function overlapNews(host: OverlapHost, agent: AgentState, before: ReadonlySet<string>, entries: Entry[]): void {\n-\tconst now = draftFiles(host, agent);\n+\tconst now = host.draftFiles(agent);\n \tconst fresh = [...now].filter((f) => !before.has(f)).toSorted();\n \tif (fresh.length === 0) return;\n \thost.queueNews(agent, overlapItems(host.draft(agent)[0] ?? \"\", overlaps(host, agent, fresh)), entries);"},{"path":"worker/project/project.ts","added":23,"removed":5,"diff":"--- a/worker/project/project.ts\n+++ b/worker/project/project.ts\n@@ -225,6 +225,8 @@\n \treadonly #graph: Graph;\n \t/** Views laid out from atom sets, cached under a byte budget (views.ts). */\n \treadonly #views: ViewCache;\n+\t/** Each agent's draft files, under the key they were worked out for (#draftFiles). */\n+\treadonly #draftFilesKept = new Map<string, { key: string; files: Set<string> }>();\n \t/** Each version's files and each path's history (pathindex.ts). */\n \treadonly #paths: PathIndex;\n \t/** For each atom (by seq) that wrote lines, the log position of the entry that recorded it (#46). */\n@@ -992,9 +994,20 @@\n \t\t}\n \t}\n \n-\t/** The files the agent's unpublished changes touch, in its own view. */\n-\t#draftFiles(...args: Tail<Parameters<typeof hostedDraftFiles>>): ReturnType<typeof hostedDraftFiles> {\n-\t\treturn hostedDraftFiles(this.#overlapHost, ...args);\n+\t/**\n+\t * The files the agent's unpublished changes touch, in its own view. Kept per agent under what they're\n+\t * made of (abso-core issue 6): its view's key and its draft. Most agents haven't moved since the last\n+\t * status, and the view cache holds fewer views than a big project has agents, so working them out again\n+\t * on every call cost about 0.5 s on abso. A copy goes out, so no caller can change what's kept.\n+\t */\n+\t#draftFiles(agent: AgentState): Set<string> {\n+\t\tconst key = `${this.#agentViewKey(agent)}|${this.#draft(agent).join(\",\")}`;\n+\t\tlet kept = this.#draftFilesKept.get(agent.name);\n+\t\tif (kept?.key !== key) {\n+\t\t\tkept = { key, files: hostedDraftFiles(this.#overlapHost, agent) };\n+\t\t\tthis.#draftFilesKept.set(agent.name, kept);\n+\t\t}\n+\t\treturn new Set(kept.files);\n \t}\n \n \t/** Other agents in the agent's space whose unpublished changes or starting note meet `patterns`. */\n@@ -2028,6 +2041,7 @@\n \t\t\tagents: this.#agents,\n \t\t\tagentView: (agent) => this.#agentView(agent),\n \t\t\tdraft: (agent) => this.#draft(agent),\n+\t\t\tdraftFiles: (agent) => this.#draftFiles(agent),\n \t\t\tliveNote: (agent) => this.#liveNote(agent),\n \t\t\tqueueNews: (agent, items, entries) => this.#queueNews(agent, items, entries),\n \t\t};\n@@ -2217,10 +2231,14 @@\n \t}\n \n \t#agentView(agent: AgentState): View {\n-\t\t// Keyed by what the set is made of, not by sorting every atom in it (#46): that cost more than the work.\n-\t\treturn this.#viewKeyed(`a ${agent.space}@${agent.base}+${agent.mine.join(\",\")}`, () => this.#agentSet(agent));\n+\t\treturn this.#viewKeyed(this.#agentViewKey(agent), () => this.#agentSet(agent));\n \t}\n \n+\t/** 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. */\n+\t#agentViewKey(agent: AgentState): string {\n+\t\treturn `a ${agent.space}@${agent.base}+${agent.mine.join(\",\")}`;\n+\t}\n+\n \t/** A space at a version: published versions never change, so the key is just their names (#46). */\n \t#viewAt(space: Space, version: number): View {\n \t\treturn this.#viewKeyed(`v ${space.name}@${version}`, () => this.#at(space, version));"},{"path":"worker/project/test/draft-files-kept.test.ts","added":72,"removed":0,"diff":"--- /dev/null\n+++ b/worker/project/test/draft-files-kept.test.ts\n@@ -0,0 +1,72 @@\n+// Each agent's draft files are kept between calls (abso-core issue 6). Status\n+// must answer as a project that works them out cold does, after every kind of\n+// step, in shared and in a named draft.\n+\n+import assert from \"node:assert/strict\";\n+import { test } from \"node:test\";\n+import { MemoryStore, Project } from \"../project.ts\";\n+\n+const START = {\n+\t\"core.ts\": \"export function step(x: number) {\\n  return x + 1;\\n}\\n\\nexport const version = 1;\\n\",\n+\t\"notes.md\": \"one\\ntwo\\nthree\\n\",\n+};\n+\n+function setup() {\n+\tconst store = new MemoryStore();\n+\tconst project = new Project(store);\n+\tproject.init(START, 0);\n+\tfor (const a of [\"ann\", \"bob\", \"cat\"]) project.sync(a);\n+\t// Warm: every agent's draft files are kept from here on.\n+\tproject.status();\n+\treturn { project, store };\n+}\n+\n+/** Status from the warm project, checked against the same log loaded cold. */\n+function same(project: Project, store: MemoryStore, step: string) {\n+\tconst warm = project.status();\n+\tassert.deepEqual(warm, Project.load(store.entries, new MemoryStore()).status(), `after ${step}`);\n+\treturn warm;\n+}\n+\n+const filesOf = (status: ReturnType<Project[\"status\"]>, agent: string) =>\n+\tstatus.agents.find((a) => a.agent === agent)!.files;\n+\n+test(\"status answers the same warm and cold through records, publishes and syncs in shared\", () => {\n+\tconst { project, store } = setup();\n+\tproject.edit(\"ann\", { file: \"core.ts\", old: \"  return x + 1;\", new: \"  return x + 2;\" }, 1);\n+\tassert.deepEqual(filesOf(same(project, store, \"ann's edit\"), \"ann\"), [\"core.ts\"]);\n+\tproject.edit(\"ann\", { file: \"notes.md\", old: \"two\\n\", new: \"two!\\n\" }, 2);\n+\tassert.deepEqual(filesOf(same(project, store, \"ann's second edit\"), \"ann\"), [\"core.ts\", \"notes.md\"]);\n+\tproject.edit(\"bob\", { file: \"notes.md\", old: \"three\\n\", new: \"three!\\n\" }, 3);\n+\tsame(project, store, \"bob's edit\");\n+\tproject.publish(\"ann\", \"Ann's two\", 4);\n+\tassert.deepEqual(filesOf(same(project, store, \"ann's publish\"), \"ann\"), []);\n+\tproject.sync(\"bob\");\n+\tassert.deepEqual(filesOf(same(project, store, \"bob's sync\"), \"bob\"), [\"notes.md\"]);\n+\tproject.record(\"cat\", { \"new.ts\": \"export {};\\n\" }, 5);\n+\tassert.deepEqual(filesOf(same(project, store, \"cat's new file\"), \"cat\"), [\"new.ts\"]);\n+\tproject.publish(\"cat\", \"Cat's file\", 6);\n+\tsame(project, store, \"cat's publish\");\n+});\n+\n+test(\"two agents in one named draft: one publishes, and the other's status still matches a cold load\", () => {\n+\tconst { project, store } = setup();\n+\tproject.switchTo(\"ann\", \"rw\", 1);\n+\tproject.switchTo(\"bob\", \"rw\", 2);\n+\tsame(project, store, \"both switch\");\n+\tproject.edit(\"ann\", { file: \"core.ts\", old: \"  return x + 1;\", new: \"  return x * 2;\" }, 3);\n+\tproject.edit(\"bob\", { file: \"notes.md\", old: \"one\\n\", new: \"one (rw)\\n\" }, 4);\n+\tconst before = same(project, store, \"both edit in rw\");\n+\tassert.deepEqual(filesOf(before, \"bob\"), [\"notes.md\"]);\n+\tproject.publish(\"ann\", \"Double\", 5);\n+\tconst after = same(project, store, \"ann publishes into rw\");\n+\tassert.deepEqual(filesOf(after, \"ann\"), []);\n+\tproject.sync(\"bob\");\n+\tassert.deepEqual(filesOf(same(project, store, \"bob syncs in rw\"), \"bob\"), [\"notes.md\"]);\n+\tproject.publish(\"bob\", \"Note\", 6);\n+\tassert.deepEqual(filesOf(same(project, store, \"bob publishes into rw\"), \"bob\"), []);\n+\tproject.land(\"ann\", \"Land rw\", 7);\n+\tsame(project, store, \"rw lands\");\n+\tproject.switchTo(\"ann\", \"shared\", 8);\n+\tsame(project, store, \"ann back in shared\");\n+});"}],"ci":null}