Lines 2–8 at 318 (were 2–8 at 4)
22// the news when a draft first touches one. Reads and news writes go through 33// OverlapHost; today the host is Project. overlapsOf is the pure match. 5−import { type AtomId, type Graph, isStartNode, type View } from "../../src/engine/index.ts";
5+import { type AtomId, type Graph, isStartNode, type ReadView } from "../../src/engine/index.ts"; 66import { matchesPattern, pathsInText, patternsMeet } from "./globs.ts"; 77import { type NewsItem, overlapItems } from "./news.ts"; 88import type { AgentState, Entry, Overlap, Starting } from "./project-types.ts"; Lines 22–31 at 318 (were 22–29 at 4)
2222export interface OverlapHost { 2323 readonly graph: Graph; 2424 readonly agents: ReadonlyMap<string, AgentState>; 25− agentView(agent: AgentState): View;
25+ agentView(agent: AgentState): ReadView; 2626 draft(agent: AgentState): readonly AtomId[]; 27+ /** draftFiles below, kept per agent by the host. */ 28+ draftFiles(agent: AgentState): Set<string>; 2729 liveNote(agent: AgentState): Starting | undefined; 2830 queueNews(agent: AgentState, items: readonly NewsItem[], entries: Entry[]): void; Lines 36–42 at 318 (were 34–40 at 4)
3638 * Peers with unpublished changes in a file `patterns` match, or a starting 37− * note that can name the same file (#37, Builder 4: notes name files by glob,
39+ * note that can name the same file (#37: notes name files by glob, 3840 * or only in their text). 4042export function overlapsOf(peers: readonly OverlapPeer[], patterns: readonly string[]): Overlap[] { Lines 66–82 at 318 (were 64–74 at 4)
6466/** The files the agent's unpublished changes touch, in its own view. */ 6567export function draftFiles(host: OverlapHost, agent: AgentState): Set<string> { 6668 const files = new Set<string>(); 69+ const draft = host.draft(agent); 70+ // No draft, no view to build: most agents in a big project have nothing unpublished. 71+ if (draft.length === 0) return files; 6772 const view = host.agentView(agent); 68− for (const id of host.draft(agent)) {
73+ // By number where the view can (abso Capacity): a draft deleting a big generated file looked up each line's id. 74+ const byNumber = (view as { fileOfNumber?(n: number): string }).fileOfNumber?.bind(view); 75+ for (const id of draft) { 6976 const atom = host.graph.atom(id); 7077 for (const run of atom.inserts) files.add(isStartNode(run.parent) ? run.file : view.fileOf(run.parent)); 71− for (const line of atom.deletes) files.add(view.fileOf(line));
78+ if (byNumber) for (const n of host.graph.deletedNumbers(id)) files.add(byNumber(n)); 79+ else for (const line of atom.deletes) files.add(view.fileOf(line)); 7280 for (const m of atom.moves ?? []) files.add(view.fileOf(m.line)); Lines 89–95 at 318 (were 81–87 at 4)
8189 .filter((other) => other !== agent && other.space === agent.space) 84− files: draftFiles(host, other),
92+ files: host.draftFiles(other), 8593 changesIn: (file: string) => host.draft(other).filter((id) => host.graph.filesOf(id).includes(file)).length, 8694 note: host.liveNote(other), Lines 98–108 at 318 (were 90–101 at 4)
92100 * News the first time a draft touches a file someone else in its space has 93− * unpublished changes in, or a starting note on (#37, Builder 6 and Writer
94− * 1): one line per file and agent, once per draft. It tells; it never stops
101+ * unpublished changes in, or a starting note on (#37): one line per file and agent, once per draft. It tells; it never stops 97104export function overlapNews(host: OverlapHost, agent: AgentState, before: ReadonlySet<string>, entries: Entry[]): void { 98− const now = draftFiles(host, agent);
105+ const now = host.draftFiles(agent); 99106 const fresh = [...now].filter((f) => !before.has(f)).toSorted(); 100107 if (fresh.length === 0) return; 101108 host.queueNews(agent, overlapItems(host.draft(agent)[0] ?? "", overlaps(host, agent, fresh)), entries);