Lines 3–19 at 318 (were 3–10 at 2)
33// which space) is applied first, in spaces.ts. 55import type { AtomId, Graph } from "../../src/engine/index.ts"; 6+import { capNews, outlastsSync } from "./news.ts"; 67import { ProjectError } from "./project-error.ts"; 7−import type { AgentState, ChangeRecord, Entry, NoteRecord, QueuedPublish, Refusal } from "./project-types.ts";
16+} from "./project-types.ts"; 817import { SHARED, type Space } from "./spaces.ts"; 1019/** What applying one log entry needs from a project. */ Lines 26–33 at 318 (were 17–22 at 2)
1726 readonly changes: Map<number, ChangeRecord>; 1827 readonly labels: Map<string, number[]>; 1928 readonly refusals: Refusal[]; 29+ /** The newest tells, by id in the order sent, at most TELLS_KEPT. */ 30+ readonly tells: Map<number, TellRecord>; 2031 uncheck(id: number): void; 2132 stamp(time: number | undefined): void; 2233 applyMembership(entry: Entry, at: number): void; Lines 113–119 at 318 (were 102–107 at 2)
103114 host.joinChange(agent, entry, at, space.name === SHARED ? null : space.name); 104115 agent.marked = agent.marked.filter((r) => r.space !== (entry.space ?? SHARED)); 105117 if (entry.queued !== undefined) host.setQueued(host.queued().filter((q) => q.id !== entry.queued)); Lines 143–163 at 318 (were 131–142 at 2)
131143 const { type: _, ...note } = entry; 132144 host.notes.set(entry.id, { ...note, lines: [...entry.lines], at }); 133145 host.setLastNote(Math.max(host.lastNote(), entry.id)); 134− if (entry.change !== undefined && host.changes.has(entry.change)) host.changes.get(entry.change)!.last = at;
146+ if (entry.change !== undefined) { 147+ const change = host.changes.get(entry.change); 150+ host.changes.set(entry.change, change); 137155 case "note-closed": { 138156 const note = host.notes.get(entry.id); 139− if (note) note.closed = { agent: entry.agent, how: entry.how, time: entry.time };
158+ note.closed = { agent: entry.agent, how: entry.how, time: entry.time }; 159+ host.notes.set(entry.id, note); Lines 194–207 at 318 (were 173–182 at 2)
173194 const agent = host.agentOf(entry.agent); 174195 agent.news.push(...entry.text); 175196 agent.newsAt.push(...entry.text.map(() => time)); 176− for (const p of entry.pairs) {
197+ entry.pairs.forEach((p, i) => { 177198 agent.told.add(p); 178− if (p.startsWith("announce ")) host.setAnnounced(Math.max(host.announced(), Number(p.slice(9)) || 0));
179− }
199+ if (!p.startsWith("announce ")) return; 200+ const id = Number(p.slice(9)) || 0; 201+ host.setAnnounced(Math.max(host.announced(), id)); 202+ tellSent(host.tells, id, entry.text[i] ?? entry.text[0] ?? "", agent.name, time); Lines 213–223 at 318 (were 188–194 at 2)
190215 const agent = host.agentOf(entry.agent); 191− const keep = agent.news.map((t) => entry.stale === true && t.startsWith("Announcement from "));
216+ // A sync's stale heard keeps announcements and settles' news (outlastsSync), so it hears no tell. 217+ if (entry.stale !== true) 218+ for (const tell of host.tells.values()) 219+ if (tell.heard.get(agent.name) === null) tell.heard.set(agent.name, { at: time }); 220+ const keep = agent.news.map((t) => entry.stale === true && outlastsSync(t)); 192221 agent.news = agent.news.filter((_, i) => keep[i]); 193222 agent.newsAt = agent.newsAt.filter((_, i) => keep[i]); Lines 246–274 at 318 (were 217–238 at 2)
219248 collisions: entry.collisions.map((c) => ({ ...c })), 249+ ...(entry.message ? { message: entry.message } : {}), 222252 // On the change the agent was working on, when there is one (#44). 223253 const agent = host.agentOf(entry.agent); 224254 host.active(agent, entry.time); 225255 const id = host.currentChange(agent, entry.time); 259+ kinds: [...new Set(entry.collisions.map((c) => c.kind))].sort(), 260+ files: [...new Set(entry.collisions.map((c) => c.file))].sort(), 261+ ...(entry.message ? { message: entry.message } : {}), 226263 if (id !== undefined) { 227264 const rec = host.changeRecord(id, agent, entry.time); 228− rec.refusals.push({
229− at,
230− time: entry.time,
231− kinds: [...new Set(entry.collisions.map((c) => c.kind))].sort(),
232− files: [...new Set(entry.collisions.map((c) => c.file))].sort(),
233− });
265+ rec.refusals.push({ ...refusal, files: [...refusal.files], kinds: [...refusal.kinds] }); 267+ host.changes.set(id, rec); 269+ // Kept until it pushes: the settle tells the held push's reason, and its change lists the refusal. 270+ if (entry.via === "publish") 271+ agent.held = [...(agent.held ?? []), { ...refusal, ...(id !== undefined ? { change: id } : {}) }]; Lines 299–305 at 318 (were 263–269 at 2)
264300 // A kind this engine doesn't know was written by a newer one. Skipping 265301 // it would show, and then build on, a project without that entry, so 266− // the load stops instead (AVCS - Git Lessons, report 8.3).
302+ // the load stops instead. 267303 const kind = (entry as { type?: unknown }).type; 268304 throw new ProjectError( Lines 308–333 at 318 (were 272–274 at 2)
312+/** How many tells the project keeps who-heard-what for (status's tells). */ 313+export const TELLS_KEPT = 50; 315+/** A tell's news reached one recipient's queue: the tell is kept, the oldest dropped past TELLS_KEPT. */ 317+ tells: Map<number, TellRecord>, 321+ time: number | undefined, 323+ let tell = tells.get(id); 324+ if (tell === undefined) { 325+ tell = { id, text, at: time, heard: new Map() }; 326+ tells.set(id, tell); 327+ for (const old of tells.keys()) { 328+ if (tells.size <= TELLS_KEPT) break; 332+ if (!tell.heard.has(agent)) tell.heard.set(agent, null);