Lines 2–9 at 318 (were 2–7 at 162)
22// Writes go through QueueHost; today the host is Project. 44import { type AtomId, buildAtom, type Graph, type ReadView } from "../../src/engine/index.ts"; 5+import { unionOverlay } from "../../src/engine/state-source.ts"; 6+import { autoSettledOf } from "./autosettle.ts"; 57import type { Pair } from "./collisions.ts"; 68import { definedTwice } from "./definitions.ts"; 79import { heldMessage, keptOf, lostLines } from "./markers.ts"; Lines 30–37 at 318 (were 28–33 at 162)
2830 readonly graph: Graph; 2931 checkerReady(): boolean; 3032 sharedView(): ReadView; 33+ sharedOverlay?(atoms: readonly AtomId[]): ReadView; 34+ sharedAgentOverlay?(agent: AgentState, atoms: readonly AtomId[]): ReadView; 3135 queued(): readonly QueuedPublish[]; 3337 checkingHas(id: number): boolean; Lines 121–133 at 318 (were 117–127 at 162)
117121 const ahead = queuedAtoms(host, agent.name); 118122 const now = host.setOf(space); 119123 if (ahead.size > 0) { 120− const landed = new Set([...now, ...ahead]);
121− const theirsView = host.view(landed);
122− const yoursView = host.view(new Set([...landed, ...host.agentSet(agent)]));
124+ const landed = unionOverlay(now, ahead); 125+ const theirsView = host.sharedOverlay ? host.sharedOverlay([...ahead]) : host.view(landed); 126+ const yoursView = host.sharedAgentOverlay 127+ ? host.sharedAgentOverlay(agent, [...ahead]) 128+ : host.view(unionOverlay(landed, host.agentSet(agent))); 123129 const queuedBy = (id: AtomId) => host.queued().find((q) => q.changes.includes(id)); 124− const collisions: Collision[] = host.pairs(changes, ahead, new Set([...landed, ...changes])).map((p) => {
130+ const collisions: Collision[] = host.pairs(changes, ahead, unionOverlay(landed, changes)).map((p) => { 125131 const c = host.describe(p, host.agentView(agent), theirsView, agent.space); 126132 const q = queuedBy(p.theirs); 127133 return q ? { ...c, theirs: { ...c.theirs, agent: q.agent, message: q.message, queued: q.id } } : c; Lines 159–179 at 318 (were 153–170 at 162)
153159 if (collisions.length > 0) return host.refuse(agent, space, "publish", time, collisions, entries, message); 155161 const view = host.agentView(agent); 162+ const auto = autoSettledOf(message); 156163 const settled: Settled[] = agent.marked 157164 .filter((r) => r.space === SHARED) 159166 const lines = view.hasFile(r.file) ? view.lines(r.file).map((l) => l.text) : []; 160167 const lost = lostLines(lines, r); 161168 const held = heldMessage(agent, r.file); 169+ const by = auto.get(r.file); 164172 kept: keptOf(lines, r), 165173 theirs: { agent: r.agent, version: r.version }, 166174 ...(lost.length > 0 ? { lost } : {}), 167175 ...(held ? { held } : {}), 176+ ...(by ? { auto: by } : {}), 170179 const id = host.queuedId() + 1; Lines 240–252 at 318 (were 231–237 at 162)
233242 const items = host.queued().slice(0, Math.max(0, n)); 234− const view = host.view(new Set([...host.setOf(host.shared()), ...items.flatMap((q) => q.changes)]));
243+ const changes = items.flatMap((q) => q.changes); 245+ changes.length === 0 247+ : host.sharedOverlay 248+ ? host.sharedOverlay(changes) 249+ : host.view(unionOverlay(host.setOf(host.shared()), changes)); 235250 const files = view.files(); 236251 const modes = modesOf(view); 237252 const blobs = view.blobs(); Lines 265–273 at 318 (were 250–257 at 162)
250265 for (const q of host.queued().slice(0, Math.max(0, n))) { 251266 const agent = host.agentOf(q.agent); 252267 const space = host.shared(); 253− const union = new Set([...host.setOf(space), ...q.changes]);
254− const tie = buildAtom(host.view(union), {
268+ const union = unionOverlay(host.setOf(space), q.changes); 269+ const view = host.sharedOverlay ? host.sharedOverlay(q.changes) : host.view(union); 270+ const tie = buildAtom(view, { 256272 message: q.message,