Lines 2–8 at 318 (were 2–8 at 42)
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 42)
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 66–82 at 318 (were 64–74 at 42)
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 42)
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 102–108 at 318 (were 94–100 at 42)
96104export function overlapNews(host: OverlapHost, agent: AgentState, before: ReadonlySet<string>, entries: Entry[]): void { 97− const now = draftFiles(host, agent);
105+ const now = host.draftFiles(agent); 98106 const fresh = [...now].filter((f) => !before.has(f)).toSorted(); 99107 if (fresh.length === 0) return; 100108 host.queueNews(agent, overlapItems(host.draft(agent)[0] ?? "", overlaps(host, agent, fresh)), entries);