{"version":114,"agent":"codex-capacity-chair","message":"Reuse published projections for empty actor drafts","time":1791829035326,"timeIso":"2026-10-12T18:17:15.326Z","changes":2,"change":1284,"files":["worker/project/project.ts","worker/project/test/project-writer-storage.test.ts"],"draft":null,"diff":[{"path":"worker/project/project.ts","added":3,"removed":0,"diff":"--- a/worker/project/project.ts\n+++ b/worker/project/project.ts\n@@ -2483,6 +2483,9 @@\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\t// An empty draft is exactly its published base. Share its projection\n+\t\t// with version readers instead of walking the same history twice.\n+\t\tif (agent.mine.length === 0) return `v ${agent.space}@${agent.base}`;\n \t\treturn `a ${agent.space}@${agent.base}+${agent.mine.join(\",\")}`;\n \t}\n "},{"path":"worker/project/test/project-writer-storage.test.ts","added":21,"removed":0,"diff":"--- a/worker/project/test/project-writer-storage.test.ts\n+++ b/worker/project/test/project-writer-storage.test.ts\n@@ -50,6 +50,27 @@\n \tstorage.db.close();\n });\n \n+test(\"empty writer drafts reuse their exact published base projection without conflating newer heads\", () => {\n+\tconst { storage, entries, store } = setup();\n+\tlet project = new Project(store, { writerStorage: storage });\n+\tstorage.transaction(() => project.init({ \"a.txt\": \"one\\n\" }, 0));\n+\tstorage.transaction(() => project.record(\"writer\", { \"a.txt\": \"two\\n\" }, 1));\n+\tstorage.transaction(() => project.publish(\"writer\", \"Two\", 2));\n+\tproject = Project.openWriter(store, storage, entries.length);\n+\tconst base = project.sharedView();\n+\tassert.equal(project.draftOf(\"writer\")!.view, base);\n+\tassert.equal(base.text(\"a.txt\"), \"two\\n\");\n+\tstorage.transaction(() => project.record(\"other\", { \"a.txt\": \"three\\n\" }, 3));\n+\tassert.notEqual(project.draftOf(\"other\")!.view, base);\n+\tstorage.transaction(() => project.publish(\"other\", \"Three\", 4));\n+\tassert.equal(project.sharedView().text(\"a.txt\"), \"three\\n\");\n+\tassert.equal(project.draftOf(\"writer\")!.view, base, \"an unchanged actor stays at its old base\");\n+\tassert.equal(project.draftOf(\"writer\")!.view.text(\"a.txt\"), \"two\\n\");\n+\tassert.notEqual(project.draftOf(\"writer\")!.view, project.sharedView());\n+\tassert.equal(project.draftOf(\"other\")!.view, project.sharedView());\n+\tstorage.db.close();\n+});\n+\n test(\"actual Project record and publish use persistent graph, membership and positional indexes\", (t) => {\n \tt.mock.method(Date, \"now\", () => 100);\n \tconst { storage, entries, store } = setup();"}],"ci":null}