{"draft":null,"from":97,"to":318,"files":[{"path":"worker/project/queue.ts","added":39,"removed":20,"diff":"--- a/worker/project/queue.ts\n+++ b/worker/project/queue.ts\n@@ -1,10 +1,12 @@\n // The merge queue: publishes to shared waiting for their batch's check.\n // Writes go through QueueHost; today the host is Project.\n \n-import { type AtomId, buildAtom, type Graph, type View } from \"../../src/engine/index.ts\";\n+import { type AtomId, buildAtom, type Graph, type ReadView } from \"../../src/engine/index.ts\";\n+import { unionOverlay } from \"../../src/engine/state-source.ts\";\n+import { autoSettledOf } from \"./autosettle.ts\";\n import type { Pair } from \"./collisions.ts\";\n import { definedTwice } from \"./definitions.ts\";\n-import { keptOf, lostLines } from \"./markers.ts\";\n+import { heldMessage, keptOf, lostLines } from \"./markers.ts\";\n import { clip } from \"./news.ts\";\n import { ProjectError } from \"./project-error.ts\";\n import { projectFileIn } from \"./project-helpers.ts\";\n@@ -27,7 +29,9 @@\n export interface QueueHost {\n \treadonly graph: Graph;\n \tcheckerReady(): boolean;\n-\tsharedView(): View;\n+\tsharedView(): ReadView;\n+\tsharedOverlay?(atoms: readonly AtomId[]): ReadView;\n+\tsharedAgentOverlay?(agent: AgentState, atoms: readonly AtomId[]): ReadView;\n \tqueued(): readonly QueuedPublish[];\n \tqueuedId(): number;\n \tcheckingHas(id: number): boolean;\n@@ -36,12 +40,12 @@\n \tneedInit(): void;\n \tshared(): Space;\n \tsetOf(space: Space): ReadonlySet<AtomId>;\n-\tview(set: ReadonlySet<AtomId>): View;\n+\tview(set: ReadonlySet<AtomId>): ReadView;\n \tagentSet(agent: AgentState): Set<AtomId>;\n-\tagentView(agent: AgentState): View;\n+\tagentView(agent: AgentState): ReadView;\n \tpairs(draft: readonly AtomId[], against: ReadonlySet<AtomId>, settled: ReadonlySet<AtomId>): Pair[];\n-\tdescribe(pair: Pair, yoursView: View, theirsView: View, spaceName: string): Collision;\n-\ttouchedFiles(ids: Iterable<AtomId>, views: readonly View[]): Set<string>;\n+\tdescribe(pair: Pair, yoursView: ReadView, theirsView: ReadView, spaceName: string): Collision;\n+\ttouchedFiles(ids: Iterable<AtomId>, views: readonly ReadView[]): Set<string>;\n \trefuse(\n \t\tagent: AgentState,\n \t\tspace: Space,\n@@ -49,6 +53,7 @@\n \t\ttime: number,\n \t\tcollisions: Collision[],\n \t\tentries: Entry[],\n+\t\tmessage?: string,\n \t): { ok: false; collisions: Collision[] };\n \tcurrentChange(agent: AgentState, time: number): number | undefined;\n \tnextAt(): number;\n@@ -80,7 +85,7 @@\n \tif (queueOn(host))\n \t\tthrow new ProjectError(\n \t\t\t\"conflict\",\n-\t\t\t`${what} doesn't go through the merge queue yet; switch to shared, take the changes into your draft, and publish`,\n+\t\t\t`${what} doesn't go through the merge queue yet; switch to shared, take the changes into your draft, and push`,\n \t\t);\n }\n \n@@ -116,11 +121,13 @@\n \tconst ahead = queuedAtoms(host, agent.name);\n \tconst now = host.setOf(space);\n \tif (ahead.size > 0) {\n-\t\tconst landed = new Set([...now, ...ahead]);\n-\t\tconst theirsView = host.view(landed);\n-\t\tconst yoursView = host.view(new Set([...landed, ...host.agentSet(agent)]));\n+\t\tconst landed = unionOverlay(now, ahead);\n+\t\tconst theirsView = host.sharedOverlay ? host.sharedOverlay([...ahead]) : host.view(landed);\n+\t\tconst yoursView = host.sharedAgentOverlay\n+\t\t\t? host.sharedAgentOverlay(agent, [...ahead])\n+\t\t\t: host.view(unionOverlay(landed, host.agentSet(agent)));\n \t\tconst queuedBy = (id: AtomId) => host.queued().find((q) => q.changes.includes(id));\n-\t\tconst collisions: Collision[] = host.pairs(changes, ahead, new Set([...landed, ...changes])).map((p) => {\n+\t\tconst collisions: Collision[] = host.pairs(changes, ahead, unionOverlay(landed, changes)).map((p) => {\n \t\t\tconst c = host.describe(p, host.agentView(agent), theirsView, agent.space);\n \t\t\tconst q = queuedBy(p.theirs);\n \t\t\treturn q ? { ...c, theirs: { ...c.theirs, agent: q.agent, message: q.message, queued: q.id } } : c;\n@@ -149,19 +156,24 @@\n \t\t\t\t});\n \t\t\t}\n \t\t}\n-\t\tif (collisions.length > 0) return host.refuse(agent, space, \"publish\", time, collisions, entries);\n+\t\tif (collisions.length > 0) return host.refuse(agent, space, \"publish\", time, collisions, entries, message);\n \t}\n \tconst view = host.agentView(agent);\n+\tconst auto = autoSettledOf(message);\n \tconst settled: Settled[] = agent.marked\n \t\t.filter((r) => r.space === SHARED)\n \t\t.map((r) => {\n \t\t\tconst lines = view.hasFile(r.file) ? view.lines(r.file).map((l) => l.text) : [];\n \t\t\tconst lost = lostLines(lines, r);\n+\t\t\tconst held = heldMessage(agent, r.file);\n+\t\t\tconst by = auto.get(r.file);\n \t\t\treturn {\n \t\t\t\tfile: r.file,\n \t\t\t\tkept: keptOf(lines, r),\n \t\t\t\ttheirs: { agent: r.agent, version: r.version },\n \t\t\t\t...(lost.length > 0 ? { lost } : {}),\n+\t\t\t\t...(held ? { held } : {}),\n+\t\t\t\t...(by ? { auto: by } : {}),\n \t\t\t};\n \t\t});\n \tconst id = host.queuedId() + 1;\n@@ -228,7 +240,13 @@\n } {\n \thost.needInit();\n \tconst items = host.queued().slice(0, Math.max(0, n));\n-\tconst view = host.view(new Set([...host.setOf(host.shared()), ...items.flatMap((q) => q.changes)]));\n+\tconst changes = items.flatMap((q) => q.changes);\n+\tconst view =\n+\t\tchanges.length === 0\n+\t\t\t? host.sharedView()\n+\t\t\t: host.sharedOverlay\n+\t\t\t\t? host.sharedOverlay(changes)\n+\t\t\t\t: host.view(unionOverlay(host.setOf(host.shared()), changes));\n \tconst files = view.files();\n \tconst modes = modesOf(view);\n \tconst blobs = view.blobs();\n@@ -247,8 +265,9 @@\n \t\tfor (const q of host.queued().slice(0, Math.max(0, n))) {\n \t\t\tconst agent = host.agentOf(q.agent);\n \t\t\tconst space = host.shared();\n-\t\t\tconst union = new Set([...host.setOf(space), ...q.changes]);\n-\t\t\tconst tie = buildAtom(host.view(union), {\n+\t\t\tconst union = unionOverlay(host.setOf(space), q.changes);\n+\t\t\tconst view = host.sharedOverlay ? host.sharedOverlay(q.changes) : host.view(union);\n+\t\t\tconst tie = buildAtom(view, {\n \t\t\t\tauthor: q.agent,\n \t\t\t\tmessage: q.message,\n \t\t\t\ttime,\n@@ -280,7 +299,7 @@\n \t\t\thost.reviewNews(agent, version, entries);\n \t\t\thost.queueNews(\n \t\t\t\tagent,\n-\t\t\t\t[{ key: `landed ${q.id}`, text: `Your queued publish \"${clip(q.message)}\" landed as version ${version}.` }],\n+\t\t\t\t[{ key: `landed ${q.id}`, text: `Your queued push \"${clip(q.message)}\" landed as version ${version}.` }],\n \t\t\t\tentries,\n \t\t\t);\n \t\t\tout.push({ id: q.id, version });\n@@ -324,13 +343,13 @@\n \t\t\t\t\t? `the project's check failed on it on top of version ${last(host.shared())}${tail ? `:\\n${tail}` : \"\"}`\n \t\t\t\t\t: why === \"withdrawn\"\n \t\t\t\t\t\t? \"you withdrew it\"\n-\t\t\t\t\t\t: `it builds on queued publish ${id}, which was pulled`;\n+\t\t\t\t\t\t: `it builds on queued push ${id}, which was turned back`;\n \t\t\thost.queueNews(\n \t\t\t\thost.agentOf(q.agent),\n \t\t\t\t[\n \t\t\t\t\t{\n \t\t\t\t\t\tkey: `pulled ${q.id}`,\n-\t\t\t\t\t\ttext: `Your queued publish \"${clip(q.message)}\" was pulled: ${said}. Its changes are still in your draft.`,\n+\t\t\t\t\t\ttext: `Your queued push \"${clip(q.message)}\" was turned back: ${said}. Its changes are still in your draft.`,\n \t\t\t\t\t},\n \t\t\t\t],\n \t\t\t\tentries,\n@@ -350,7 +369,7 @@\n \tif (busy)\n \t\tthrow new ProjectError(\n \t\t\t\"conflict\",\n-\t\t\t`queued publish ${busy.id} is being checked; it lands or is pulled in about a minute (abso drop takes it back after it lands)`,\n+\t\t\t`queued push ${busy.id} is being checked; it lands or is turned back in about a minute (abso drop takes it back after it lands)`,\n \t\t);\n \tconst pulled: number[] = [];\n \tfor (const q of mine)"}],"unmatched":[]}