{"draft":null,"from":45,"to":318,"files":[{"path":"worker/project/project.ts","added":899,"removed":78,"diff":"--- a/worker/project/project.ts\n+++ b/worker/project/project.ts\n@@ -15,18 +15,33 @@\n import {\n \ttype Atom,\n \ttype AtomId,\n-\ttype ConflictKey,\n-\tconflictKeys,\n-\ttype EditInput,\n \tEngineError,\n \tGraph,\n \ttype LineId,\n-\ttype MoveInput,\n-\ttype View,\n+\ttype ReadView,\n+\tView,\n } from \"../../src/engine/index.ts\";\n+import {\n+\tCachedStateStorage,\n+\tdifferenceSet,\n+\ttype GraphStateStorage,\n+\tisClosedSet,\n+\tmarkClosed,\n+\tStableOverlaySet,\n+\tStableSet,\n+\tStableUnionSet,\n+\tStoredMap,\n+\tstoredArray,\n+\tunionOverlay,\n+} from \"../../src/engine/state-source.ts\";\n import { type AddDraftHost, addDraft as hostedAddDraft } from \"./add-draft.ts\";\n import { type AmendHost, amend as hostedAmend } from \"./amend.ts\";\n-import { type AnnounceHost, announce as hostedAnnounce, announcePerson as hostedAnnouncePerson } from \"./announce.ts\";\n+import {\n+\ttype AnnounceHost,\n+\tannounce as hostedAnnounce,\n+\tannouncePerson as hostedAnnouncePerson,\n+\tseatNotice as hostedSeatNotice,\n+} from \"./announce.ts\";\n import { type ApplyEntryHost, applyEntry as hostedApplyEntry } from \"./apply-entry.ts\";\n import {\n \ttype ChangeHost,\n@@ -48,6 +63,7 @@\n \ttype Pair,\n \tpairsIn,\n \tstrandedFiles,\n+\ttouchedBeyond,\n \ttouchedFiles,\n } from \"./collisions.ts\";\n import { type DefinitionCollision, DefinitionRule } from \"./definition-rule.ts\";\n@@ -65,6 +81,7 @@\n } from \"./history.ts\";\n import { ingest as hostedIngest, type IngestHost } from \"./ingest.ts\";\n import { init as hostedInit, type InitHost } from \"./init.ts\";\n+import { KeptParts } from \"./kept-parts.ts\";\n import { label as hostedLabel, type LabelHost } from \"./label.ts\";\n import {\n \tland as hostedLand,\n@@ -88,9 +105,13 @@\n \taddressedItem,\n \tnewsAboutOwnDraft as hostedNewsAboutOwnDraft,\n \tnewsForOthers as hostedNewsForOthers,\n+\tnewsOwed as hostedNewsOwed,\n+\towedAgents as hostedOwedAgents,\n+\towedNewsNames as hostedOwedNewsNames,\n \tmarkedItem,\n \ttype NewsHost,\n \ttype NewsItem,\n+\ttype OwedDefinitionNews,\n \treviewItem,\n \tsettledItem,\n } from \"./news.ts\";\n@@ -98,7 +119,6 @@\n \tcloseNote as hostedCloseNote,\n \tnoteAnswer as hostedNoteAnswer,\n \tnotes as hostedNotes,\n-\tnoteView as hostedNoteView,\n \tstartingNotes as hostedStartingNotes,\n \twriteNote as hostedWriteNote,\n \ttype NoteHost,\n@@ -140,9 +160,8 @@\n \tEntry,\n \tLandAnswer,\n \tMergedLine,\n-\tMeta,\n-\tMode,\n \tModes,\n+\tNewsWritten,\n \tNoteAnswer,\n \tNoteBody,\n \tNoteRecord,\n@@ -155,7 +174,6 @@\n \tRefusal,\n \tSettled,\n \tStarting,\n-\tSwitchAnswer,\n \tTail,\n \tTellRecord,\n } from \"./project-types.ts\";\n@@ -178,15 +196,33 @@\n import { recordFile as hostedRecordFile, type RecordFileHost } from \"./record-file.ts\";\n import { refusals as hostedRefusals, refuse as hostedRefuse, type RefuseHost } from \"./refuse.ts\";\n import { restore as hostedRestore, type RestoreHost } from \"./restore.ts\";\n-import { addVersion, last, Membership, newSpace, type Published, SHARED, type Space, sharedBaseOf } from \"./spaces.ts\";\n+import {\n+\tclosureChangedAt,\n+\tindexClosure,\n+\tlast,\n+\tMembership,\n+\tSHARED,\n+\tSharedAdditions,\n+\ttype Space,\n+\tsharedBaseOf,\n+} from \"./spaces.ts\";\n import { starting as hostedStarting, type StartingHost } from \"./start.ts\";\n import { switchTo as hostedSwitchTo, type SwitchHost } from \"./switch-to.ts\";\n import { sync as hostedSync, type SyncHost } from \"./sync.ts\";\n import { treeHash } from \"./tree.ts\";\n import {\n+\tauthoredVersion,\n+\tauthorTotalsAt,\n+\ttype FileTotals,\n+\tversionFiles as keptVersionFiles,\n+\ttype VersionFilesHost,\n+} from \"./version-files.ts\";\n+import {\n \ttype LogHost,\n \tcompare as versionCompare,\n+\tcompareSummary as versionCompareSummary,\n \tfileAt as versionFileAt,\n+\tfileExactAt as versionFileExactAt,\n \tlog as versionLog,\n \tribbon as versionRibbon,\n \tshow as versionShow,\n@@ -206,6 +242,8 @@\n \twholeRules as hostedWholeRules,\n \ttype WholeHost,\n } from \"./whole-files.ts\";\n+import { without as hostedWithout, type WithoutHost } from \"./without.ts\";\n+import { WriterAgents } from \"./writer-agents.ts\";\n \n export { MemoryStore } from \"./memory-store.ts\";\n export { checkReadPath, pathProblem } from \"./path-rules.ts\";\n@@ -219,12 +257,56 @@\n \n /** A start note lasts this long after the agent's last activity (#44). */\n const NOTE_IDLE = 2 * 60 * 60 * 1000;\n+const WRITER_REOPEN = Symbol(\"verified writer checkpoint\");\n+/**\n+ * The stored writer's read cache (abso Capacity). An agent's diff on typescript-rs touches more rows than the old\n+ * 4,096 held, so it read many of them again: 59,000 reads cold, against 22,000 at this size.\n+ */\n+const WRITER_CACHE_BYTES = 4 * 1_048_576;\n+const WRITER_CACHE_ROWS = 16_384;\n+/** The biggest row the writer cache keeps (abso Capacity): an agent and all the news it was told can be 100 KB. */\n+const WRITER_CACHE_ROW_BYTES = 16_384;\n+/** Old-form agent rows moved to told buckets at each write (abso Capacity): abso's 109 take about 28 writes. */\n+const OLD_TOLD_PER_WRITE = 4;\n+export interface WriterSource {\n+\treadonly generation: number;\n+\treadonly logLength: number;\n+\treadonly sharedVersion: number;\n+}\n+interface WriterAdoption {\n+\tsource: WriterSource;\n+\tnext: number;\n+\tready: boolean;\n+}\n \n+/** A decoded entry is supplied by a host that binds its bytes to canonical authority. */\n+export type WriterAdoptionFrame = { seq: number; json: string } | { seq: number; bytes: number; entry: Entry };\n+function adoptionFrameBytes(frame: WriterAdoptionFrame): number {\n+\treturn \"json\" in frame\n+\t\t? typeof frame.json === \"string\"\n+\t\t\t? new TextEncoder().encode(frame.json).byteLength\n+\t\t\t: NaN\n+\t\t: frame.bytes;\n+}\n+function adoptionFrameEntry(frame: WriterAdoptionFrame): Entry {\n+\treturn \"json\" in frame ? (JSON.parse(frame.json) as Entry) : frame.entry;\n+}\n+\n+/** Where a view and its base place moved lines differently (View.placedDifferently), when both are Views. */\n+function placedBetween(view: ReadView, base: ReadView): ReadonlySet<string> | undefined {\n+\treturn view instanceof View && base instanceof View ? view.placedDifferently(base) : undefined;\n+}\n+\n export class Project {\n \treadonly #store: ProjectStore;\n+\treadonly #writerStorage?: GraphStateStorage;\n \treadonly #graph: Graph;\n \t/** Views laid out from atom sets, cached under a byte budget (views.ts). */\n \treadonly #views: ViewCache;\n+\t/** What draft collisions keep between calls, under its own byte budget (kept-parts.ts). */\n+\t#keptParts: KeptParts | undefined;\n+\t/** Each agent's draft files, under the key they were worked out for (#draftFiles). */\n+\treadonly #draftFilesKept = new Map<string, { key: string; files: Set<string> }>();\n \t/** Each version's files and each path's history (pathindex.ts). */\n \treadonly #paths: PathIndex;\n \t/** For each atom (by seq) that wrote lines, the log position of the entry that recorded it (#46). */\n@@ -253,32 +335,76 @@\n \t * doesn't depend on it.\n \t */\n \tcheckerReady = false;\n+\t/**\n+\t * Owed news (abso Capacity, 2026-10-15): a publish's definition news for other agents is left for after its write\n+\t * (takeOwedDefinitionNews, definitionNewsOwed, deliverOwedNews). The disk route sets it; the replay engine doesn't.\n+\t */\n+\towesDefinitionNews = false;\n+\t#owed: OwedDefinitionNews[] = [];\n \treadonly #now: (() => number) | undefined;\n+\treadonly #newsWritten: ((items: readonly NewsWritten[]) => void) | undefined;\n \treadonly #whole: ProjectOptions[\"whole\"];\n \treadonly #shapes: ProjectOptions[\"shapes\"];\n+\treadonly #logLine: ProjectOptions[\"logLine\"];\n \t/** For each log position, the newest time up to it (#41): time to position in one search. */\n \treadonly #timeAt: number[] = [];\n \t/** For each version of shared, the log position of the entry that made it (#41). */\n \treadonly #versionAt: number[] = [];\n \t/** The newest time any applied entry carries: the clock when none was given. */\n-\t#lastTime = 0;\n+\t#lastTimeMemory = 0;\n+\tget #lastTime(): number {\n+\t\treturn this.#writerStorage\n+\t\t\t? ((this.#writerStorage.read(\"project:meta\", \"lastTime\") as number | undefined) ?? 0)\n+\t\t\t: this.#lastTimeMemory;\n+\t}\n+\tset #lastTime(value: number) {\n+\t\tif (this.#writerStorage) this.#writerStorage.write(\"project:meta\", \"lastTime\", value);\n+\t\telse this.#lastTimeMemory = value;\n+\t}\n \t/** Every change (#44), by id. */\n \treadonly #changes = new Map<number, ChangeRecord>();\n \t/** Each version's change, by \"<draft or ''> <version>\" (#44): what a note on its lines belongs to. */\n \treadonly #versionChange = new Map<string, number>();\n \t/** Every note (#44), by id. */\n \treadonly #notes = new Map<number, NoteRecord>();\n-\t/** Mod versions (X-Avcs-Client) in the order they first sent an edit (#41): the last is taken as the installed one. */\n+\t/** Mod versions (X-Abso-Client) in the order they first sent an edit (#41): the last is taken as the installed one. */\n \t#mods: string[] = [];\n \t/** The merge queue (#39), in order: publishes to shared waiting for their batch's check. */\n \t#queue: QueuedPublish[] = [];\n \t/** The newest note's id (#44). */\n-\t#lastNote = 0;\n-\t#queuedId = 0;\n+\t#lastNoteMemory = 0;\n+\tget #lastNote(): number {\n+\t\treturn this.#writerStorage\n+\t\t\t? ((this.#writerStorage.read(\"project:meta\", \"lastNote\") as number | undefined) ?? 0)\n+\t\t\t: this.#lastNoteMemory;\n+\t}\n+\tset #lastNote(value: number) {\n+\t\tif (this.#writerStorage) this.#writerStorage.write(\"project:meta\", \"lastNote\", value);\n+\t\telse this.#lastNoteMemory = value;\n+\t}\n+\t#queuedIdMemory = 0;\n+\tget #queuedId(): number {\n+\t\treturn this.#writerStorage\n+\t\t\t? ((this.#writerStorage.read(\"project:meta\", \"queuedId\") as number | undefined) ?? 0)\n+\t\t\t: this.#queuedIdMemory;\n+\t}\n+\tset #queuedId(value: number) {\n+\t\tif (this.#writerStorage) this.#writerStorage.write(\"project:meta\", \"queuedId\", value);\n+\t\telse this.#queuedIdMemory = value;\n+\t}\n \t/** Queued ids in the batch being checked now: not in the log, only for refusing an unqueue mid-check. */\n \t#checking = new Set<number>();\n \t/** How many entries the store holds: the log position of the next one (#41, the website's feed and replay). */\n-\t#stored = 0;\n+\t#storedMemory = 0;\n+\tget #stored(): number {\n+\t\treturn this.#writerStorage\n+\t\t\t? ((this.#writerStorage.read(\"project:meta\", \"stored\") as number | undefined) ?? 0)\n+\t\t\t: this.#storedMemory;\n+\t}\n+\tset #stored(value: number) {\n+\t\tif (this.#writerStorage) this.#writerStorage.write(\"project:meta\", \"stored\", value);\n+\t\telse this.#storedMemory = value;\n+\t}\n \t/** Names on the lines a change replaced, by \"<atom> <last replaced line>\" (atoms never change). */\n \t#rule?: DefinitionRule;\n \tget #definitionRule(): DefinitionRule {\n@@ -286,17 +412,63 @@\n \t\treturn this.#rule;\n \t}\n \t/** The newest announcement's id (announcements are news entries keyed \"announce <id>\"). */\n-\t#announced = 0;\n+\t#announcedMemory = 0;\n+\tget #announced(): number {\n+\t\treturn this.#writerStorage\n+\t\t\t? ((this.#writerStorage.read(\"project:meta\", \"announced\") as number | undefined) ?? 0)\n+\t\t\t: this.#announcedMemory;\n+\t}\n+\tset #announced(value: number) {\n+\t\tif (this.#writerStorage) this.#writerStorage.write(\"project:meta\", \"announced\", value);\n+\t\telse this.#announcedMemory = value;\n+\t}\n \t#loading = false;\n \n \treadonly #hasBlob: (sha256: string) => boolean;\n \n-\tconstructor(store: ProjectStore, options: ProjectOptions = {}) {\n+\tconstructor(store: ProjectStore, options: ProjectOptions = {}, checkpoint?: typeof WRITER_REOPEN) {\n+\t\tif (options.indexAcceptedAtom && !options.writerStorage)\n+\t\t\tthrow Error(\"accepted atom indexing requires writer storage\");\n \t\tthis.#store = store;\n+\t\tthis.#writerStorage = options.writerStorage\n+\t\t\t? new CachedStateStorage(options.writerStorage, WRITER_CACHE_BYTES, WRITER_CACHE_ROWS, WRITER_CACHE_ROW_BYTES)\n+\t\t\t: undefined;\n+\t\tif (this.#writerStorage) {\n+\t\t\tconst storage = this.#writerStorage;\n+\t\t\t// A stored Graph cannot be replayed over itself. Check before any\n+\t\t\t// constructor writes so an accidental reopen preserves the namespace.\n+\t\t\tif (\n+\t\t\t\tcheckpoint !== WRITER_REOPEN &&\n+\t\t\t\t((storage.read(\"atoms:meta\", \"length\") as number | undefined) ||\n+\t\t\t\t\t(storage.read('membership:\"\":versions:meta', \"length\") as number | undefined))\n+\t\t\t)\n+\t\t\t\tthrow new Error(\"writer indexes already contain history; Project checkpoint reopen is required\");\n+\t\t\tthis.#membership = new Membership(storage);\n+\t\t\tthis.#atomAt = storedArray(storage, \"project:atom-at\");\n+\t\t\tthis.#timeAt = storedArray(storage, \"project:time-at\");\n+\t\t\tthis.#versionAt = storedArray(storage, \"project:version-at\");\n+\t\t\tthis.#notes = new StoredMap(storage, \"project:notes\");\n+\t\t\tthis.#changes = new StoredMap(storage, \"project:changes\");\n+\t\t\tthis.#labels = new StoredMap(storage, \"project:labels\");\n+\t\t\tthis.#versionChange = new StoredMap(storage, \"project:version-change\");\n+\t\t\tthis.#refusals = storedArray(storage, \"project:refusals\");\n+\t\t\tthis.#agents = new WriterAgents(storage);\n+\t\t\tif (checkpoint === WRITER_REOPEN) {\n+\t\t\t\tthis.#mods = storage.read(\"project:meta\", \"mods\") as string[];\n+\t\t\t\tthis.#queue = storage.read(\"project:meta\", \"queue\") as QueuedPublish[];\n+\t\t\t\tconst tells = storage.read(\"project:meta\", \"tells\") as [\n+\t\t\t\t\tnumber,\n+\t\t\t\t\tOmit<TellRecord, \"heard\"> & { heard: [string, { at: number | undefined } | null][] },\n+\t\t\t\t][];\n+\t\t\t\tthis.#tells = new Map(tells.map(([id, tell]) => [id, { ...tell, heard: new Map(tell.heard) }]));\n+\t\t\t}\n+\t\t}\n \t\tthis.#hasBlob = options.hasBlob ?? (() => false);\n \t\tthis.#now = options.now;\n+\t\tthis.#newsWritten = options.newsWritten;\n \t\tthis.#whole = options.whole;\n \t\tthis.#shapes = options.shapes;\n+\t\tthis.#logLine = options.logLine;\n \t\t// For tests (#46): AVCS_TEXT_FROM_LOG=1 runs a project on a MemoryStore with its text read back from the store.\n \t\tconst testing =\n \t\t\t(globalThis as { process?: { env?: Record<string, string | undefined> } }).process?.env?.AVCS_TEXT_FROM_LOG ===\n@@ -314,10 +486,12 @@\n \t\t\tthrow new Error(`log entry ${at} holds no atom ${seq}`);\n \t\t};\n \t\t// Line text and each atom's deletes and claim keys stay in the log (#46), read back when asked for.\n-\t\tthis.#graph = entryAt\n-\t\t\t? new Graph({ texts: (seq) => stored(seq).inserts.map((r) => r.lines), lists: (seq) => stored(seq) })\n-\t\t\t: new Graph();\n-\t\tthis.#views = new ViewCache(this.#graph);\n+\t\tthis.#graph = this.#writerStorage\n+\t\t\t? new Graph({ storage: this.#writerStorage, indexAcceptedAtom: options.indexAcceptedAtom })\n+\t\t\t: entryAt\n+\t\t\t\t? new Graph({ texts: (seq) => stored(seq).inserts.map((r) => r.lines), lists: (seq) => stored(seq) })\n+\t\t\t\t: new Graph();\n+\t\tthis.#views = new ViewCache(this.#graph, options.readViewProvider);\n \t\tthis.#paths = new PathIndex({\n \t\t\tgraph: this.#graph,\n \t\t\tat: (space, version) => this.#at(space, version),\n@@ -343,15 +517,260 @@\n \t\tfor (const entry of entries) {\n \t\t\tproject.#apply(entry);\n \t\t\tproject.#stored++;\n+\t\t\tproject.#persistMutable();\n \t\t}\n \t\tproject.#loading = false;\n+\t\tproject.#writeCheckpoint();\n \t\treturn project;\n \t}\n \n+\t/** Reopen committed writer indexes. The host supplies the authoritative canonical log length. */\n+\tstatic openWriter(\n+\t\tstore: ProjectStore,\n+\t\tstorage: GraphStateStorage,\n+\t\tlogLength: number,\n+\t\toptions: Omit<ProjectOptions, \"writerStorage\"> = {},\n+\t): Project {\n+\t\tconst adoption = storage.read(\"project:meta\", \"adoption\") as WriterAdoption | undefined;\n+\t\tif (adoption && !adoption.ready) throw new Error(\"writer adoption is incomplete\");\n+\t\treturn Project.#openWriter(store, storage, logLength, options);\n+\t}\n+\n+\tstatic #openWriter(\n+\t\tstore: ProjectStore,\n+\t\tstorage: GraphStateStorage,\n+\t\tlogLength: number,\n+\t\toptions: Omit<ProjectOptions, \"writerStorage\">,\n+\t): Project {\n+\t\tconst checkpoint = storage.read(\"project:meta\", \"checkpoint\") as\n+\t\t\t| { format: number; logLength: number; atoms: number; version: number }\n+\t\t\t| undefined;\n+\t\tconst length = (name: string) => (storage.read(`${name}:meta`, \"length\") as number | undefined) ?? 0;\n+\t\tif (\n+\t\t\t!Number.isSafeInteger(logLength) ||\n+\t\t\tlogLength < 1 ||\n+\t\t\tcheckpoint?.format !== 1 ||\n+\t\t\tcheckpoint.logLength !== logLength ||\n+\t\t\tstorage.read(\"project:meta\", \"stored\") !== logLength ||\n+\t\t\tlength(\"project:time-at\") !== logLength ||\n+\t\t\tlength(\"atoms\") !== checkpoint.atoms ||\n+\t\t\tlength(\"project:atom-at\") !== checkpoint.atoms ||\n+\t\t\tlength('membership:\"\":versions') !== checkpoint.version + 1 ||\n+\t\t\tlength(\"project:version-at\") !== checkpoint.version + 1 ||\n+\t\t\t![\"mods\", \"queue\", \"tells\"].every((key) => Array.isArray(storage.read(\"project:meta\", key)))\n+\t\t)\n+\t\t\tthrow new Error(\"writer checkpoint does not match the canonical log and indexes\");\n+\t\treturn new Project(store, { ...options, writerStorage: storage }, WRITER_REOPEN);\n+\t}\n+\n+\t/** Open a host-verified historical prefix. Its state must be immutable and\n+\t * scoped to canonical authority; adoption readiness describes the live writer,\n+\t * not whether this individual prefix has a complete checkpoint. */\n+\tstatic openHistorical(\n+\t\tstorage: GraphStateStorage,\n+\t\tlogLength: number,\n+\t\tscratch: GraphStateStorage,\n+\t\tassertScope: () => void = () => {\n+\t\t\tstorage.read(\"project:meta\", \"checkpoint\");\n+\t\t},\n+\t\treadViewProvider?: ProjectOptions[\"readViewProvider\"],\n+\t): Project {\n+\t\tconst refuse = (): never => {\n+\t\t\tthrow new Error(\"historical project is read-only\");\n+\t\t};\n+\t\tconst selected = (collection: string) => {\n+\t\t\t// Revalidate the historical scope even when accessing derived scratch.\n+\t\t\tassertScope();\n+\t\t\treturn collection.startsWith(\"projection-scratch:\") ? scratch : storage;\n+\t\t};\n+\t\treturn Project.#openWriter(\n+\t\t\t{ append: refuse },\n+\t\t\t{\n+\t\t\t\tread: (collection, key) => selected(collection).read(collection, key),\n+\t\t\t\tentries: (collection) => selected(collection).entries(collection),\n+\t\t\t\twrite: (collection, key, value) => {\n+\t\t\t\t\tif (selected(collection) !== scratch) refuse();\n+\t\t\t\t\tscratch.write(collection, key, value);\n+\t\t\t\t},\n+\t\t\t\tremove: (collection, key) => {\n+\t\t\t\t\tif (selected(collection) !== scratch) refuse();\n+\t\t\t\t\tscratch.remove(collection, key);\n+\t\t\t\t},\n+\t\t\t\ttransaction: (body) => storage.transaction(() => scratch.transaction(body)),\n+\t\t\t},\n+\t\t\tlogLength,\n+\t\t\t{ readViewProvider },\n+\t\t);\n+\t}\n+\n \t/**\n-\t * Apply more stored entries to a copy loaded for reading (#41, replay):\n-\t * scrubbing forward applies only what's new. Never for the live project.\n+\t * Derive one bounded page from the host's canonical frames. The host reads\n+\t * those frames from its own log and revalidates the source inside this same\n+\t * transaction. Partial adoption cannot be opened for normal operations.\n \t */\n+\tstatic adoptWriterPage(\n+\t\tstorage: GraphStateStorage,\n+\t\tinput: {\n+\t\t\tsource: WriterSource;\n+\t\t\tfrom: number;\n+\t\t\tframes: Iterable<WriterAdoptionFrame>;\n+\t\t\tmaxEntries: number;\n+\t\t\tmaxBytes: number;\n+\t\t\t/** The host supplies disk-backed decoded entries and verified byte counts. */\n+\t\t\tdecodedFrames?: boolean;\n+\t\t\tcurrentSource(): WriterSource;\n+\t\t\t/** Select the host's derived historical revision before applying a frame.\n+\t\t\t * Each selected revision receives a complete Project checkpoint. */\n+\t\t\tbeginRevision?(logLength: number): void;\n+\t\t},\n+\t\toptions: Omit<ProjectOptions, \"writerStorage\"> = {},\n+\t): { next: number; ready: boolean; entries: number; bytes: number } {\n+\t\tconst same = (a: WriterSource, b: WriterSource) =>\n+\t\t\ta.generation === b.generation && a.logLength === b.logLength && a.sharedVersion === b.sharedVersion;\n+\t\tif (\n+\t\t\t![input.source.generation, input.source.logLength, input.source.sharedVersion, input.from].every(\n+\t\t\t\t(n) => Number.isSafeInteger(n) && n >= 0,\n+\t\t\t) ||\n+\t\t\tinput.source.logLength < 1 ||\n+\t\t\t!Number.isSafeInteger(input.maxEntries) ||\n+\t\t\tinput.maxEntries < 1 ||\n+\t\t\tinput.maxEntries > 256 ||\n+\t\t\t!Number.isSafeInteger(input.maxBytes) ||\n+\t\t\tinput.maxBytes < 1 ||\n+\t\t\t(input.maxBytes > 8_000_000 && input.decodedFrames !== true)\n+\t\t)\n+\t\t\tthrow new Error(\"invalid writer adoption bounds or source\");\n+\t\treturn storage.transaction(() => {\n+\t\t\tif (!same(input.currentSource(), input.source))\n+\t\t\t\tthrow new Error(\"canonical source changed before writer adoption\");\n+\t\t\tconst previous = storage.read(\"project:meta\", \"adoption\") as WriterAdoption | undefined;\n+\t\t\tif (\n+\t\t\t\t(previous && (!same(previous.source, input.source) || previous.ready || previous.next !== input.from)) ||\n+\t\t\t\t(!previous && input.from !== 0)\n+\t\t\t)\n+\t\t\t\tthrow new Error(\"writer adoption source or cursor does not match\");\n+\t\t\tconst noAppend: ProjectStore = {\n+\t\t\t\tappend: () => {\n+\t\t\t\t\tthrow new Error(\"adoption must never append canonical history\");\n+\t\t\t\t},\n+\t\t\t};\n+\t\t\tconst project = previous\n+\t\t\t\t? Project.#openWriter(noAppend, storage, input.from, options)\n+\t\t\t\t: new Project(noAppend, { ...options, writerStorage: storage });\n+\t\t\tproject.#loading = true;\n+\t\t\tlet count = 0;\n+\t\t\tlet bytes = 0;\n+\t\t\tfor (const frame of input.frames) {\n+\t\t\t\tif (input.decodedFrames && \"json\" in frame) throw new Error(\"decoded adoption requires decoded frames\");\n+\t\t\t\tconst size = adoptionFrameBytes(frame);\n+\t\t\t\tif (\n+\t\t\t\t\tcount >= input.maxEntries ||\n+\t\t\t\t\tframe.seq !== input.from + count ||\n+\t\t\t\t\tframe.seq >= input.source.logLength ||\n+\t\t\t\t\t!Number.isSafeInteger(size) ||\n+\t\t\t\t\tsize < 1 ||\n+\t\t\t\t\tsize > input.maxBytes - bytes\n+\t\t\t\t)\n+\t\t\t\t\tthrow new Error(\"writer adoption page exceeds bounds or has a noncontiguous frame\");\n+\t\t\t\tbytes += size;\n+\t\t\t\tif (bytes > input.maxBytes) throw new Error(\"writer adoption page exceeds byte bound\");\n+\t\t\t\tinput.beginRevision?.(frame.seq + 1);\n+\t\t\t\tproject.#apply(adoptionFrameEntry(frame));\n+\t\t\t\tproject.#stored++;\n+\t\t\t\tproject.#persistMutable();\n+\t\t\t\tif (input.beginRevision) project.#writeCheckpoint();\n+\t\t\t\tcount++;\n+\t\t\t}\n+\t\t\tif (count === 0) throw new Error(\"writer adoption page must advance\");\n+\t\t\tproject.#loading = false;\n+\t\t\tconst next = input.from + count;\n+\t\t\tconst ready = next === input.source.logLength;\n+\t\t\tif (!same(input.currentSource(), input.source))\n+\t\t\t\tthrow new Error(\"canonical source changed during writer adoption\");\n+\t\t\tif (ready && project.version !== input.source.sharedVersion)\n+\t\t\t\tthrow new Error(\"adopted shared version differs from canonical source\");\n+\t\t\tproject.#writeCheckpoint();\n+\t\t\tstorage.write(\"project:meta\", \"adoption\", { source: input.source, next, ready } satisfies WriterAdoption);\n+\t\t\treturn { next, ready, entries: count, bytes };\n+\t\t});\n+\t}\n+\n+\t/**\n+\t * Extend derived historical indexes from an already checkpointed prefix.\n+\t * The host supplies only new canonical frames inside its commit transaction.\n+\t */\n+\tstatic extendHistoricalPage(\n+\t\tstorage: GraphStateStorage,\n+\t\tinput: {\n+\t\t\tfrom: number;\n+\t\t\tframes: Iterable<WriterAdoptionFrame>;\n+\t\t\tmaxEntries: number;\n+\t\t\tmaxBytes: number;\n+\t\t\t/** The host supplies disk-backed decoded entries and verified byte counts. */\n+\t\t\tdecodedFrames?: boolean;\n+\t\t\tbeginRevision(logLength: number): void;\n+\t\t\t/** Verify both the saved prefix and the new frames against canonical authority. */\n+\t\t\tvalidateAuthority(): void;\n+\t\t},\n+\t): { next: number; entries: number; bytes: number } {\n+\t\tif (\n+\t\t\t!Number.isSafeInteger(input.from) ||\n+\t\t\tinput.from < 1 ||\n+\t\t\t!Number.isSafeInteger(input.maxEntries) ||\n+\t\t\tinput.maxEntries < 1 ||\n+\t\t\tinput.maxEntries > 256 ||\n+\t\t\t!Number.isSafeInteger(input.maxBytes) ||\n+\t\t\tinput.maxBytes < 1 ||\n+\t\t\t(input.maxBytes > 8_000_000 && input.decodedFrames !== true)\n+\t\t)\n+\t\t\tthrow new Error(\"invalid historical extension bounds\");\n+\t\tconst validate = () => {\n+\t\t\tconst result: unknown = input.validateAuthority();\n+\t\t\tif (result && (typeof result === \"object\" || typeof result === \"function\") && \"then\" in result)\n+\t\t\t\tthrow new Error(\"historical authority must be synchronous\");\n+\t\t};\n+\t\treturn storage.transaction(() => {\n+\t\t\tvalidate();\n+\t\t\tconst project = Project.#openWriter(\n+\t\t\t\t{\n+\t\t\t\t\tappend: () => {\n+\t\t\t\t\t\tthrow new Error(\"history derivation cannot append canonical entries\");\n+\t\t\t\t\t},\n+\t\t\t\t},\n+\t\t\t\tstorage,\n+\t\t\t\tinput.from,\n+\t\t\t\t{},\n+\t\t\t);\n+\t\t\tproject.#loading = true;\n+\t\t\tlet entries = 0,\n+\t\t\t\tbytes = 0;\n+\t\t\tfor (const frame of input.frames) {\n+\t\t\t\tif (input.decodedFrames && \"json\" in frame) throw new Error(\"decoded adoption requires decoded frames\");\n+\t\t\t\tconst size = adoptionFrameBytes(frame);\n+\t\t\t\tif (\n+\t\t\t\t\tentries >= input.maxEntries ||\n+\t\t\t\t\tframe.seq !== input.from + entries ||\n+\t\t\t\t\t!Number.isSafeInteger(size) ||\n+\t\t\t\t\tsize < 1 ||\n+\t\t\t\t\tsize > input.maxBytes - bytes\n+\t\t\t\t)\n+\t\t\t\t\tthrow new Error(\"historical extension exceeds bounds or is not contiguous\");\n+\t\t\t\tbytes += size;\n+\t\t\t\tif (bytes > input.maxBytes) throw new Error(\"historical extension exceeds byte bound\");\n+\t\t\t\tinput.beginRevision(frame.seq + 1);\n+\t\t\t\tproject.#apply(adoptionFrameEntry(frame));\n+\t\t\t\tproject.#stored++;\n+\t\t\t\tproject.#persistMutable();\n+\t\t\t\tproject.#writeCheckpoint();\n+\t\t\t\tentries++;\n+\t\t\t}\n+\t\t\tif (!entries) throw new Error(\"historical extension must advance\");\n+\t\t\tvalidate();\n+\t\t\treturn { next: input.from + entries, entries, bytes };\n+\t\t});\n+\t}\n+\n+\t/** Apply more entries to a replay copy. Never for the live project. */\n \tcatchUp(entries: Iterable<Entry>): void {\n \t\tthis.#loading = true;\n \t\ttry {\n@@ -394,8 +813,8 @@\n \t\treturn modesOf(this.#sharedView());\n \t}\n \n-\t/** Shared as a View, for reading lines (blame, why). Don't hold on to it across calls. */\n-\tsharedView(): View {\n+\t/** Shared as a ReadView, for reading lines (blame, why). Don't hold on to it across calls. */\n+\tsharedView(): ReadView {\n \t\treturn this.#sharedView();\n \t}\n \n@@ -404,10 +823,21 @@\n \t\treturn [...this.#agents.keys()].sort();\n \t}\n \n-\t/** An agent's unpublished changes, oldest first, and its view (its space at its base plus its changes). Read only. */\n-\tdraftOf(agentName: string): { atoms: AtomId[]; view: View } | undefined {\n+\t/**\n+\t * An agent's unpublished changes, oldest first, and its view (its space at its base plus its changes). Read only.\n+\t * The view is laid out on first use: where asks every agent, most have no changes, and a big project has more\n+\t * agents than the view cache holds, so building every view cost each call about 0.7 s.\n+\t */\n+\tdraftOf(agentName: string): { atoms: AtomId[]; readonly view: ReadView } | undefined {\n \t\tconst agent = this.#agents.get(agentName);\n-\t\treturn agent && { atoms: this.#draft(agent), view: this.#agentView(agent) };\n+\t\tif (!agent) return undefined;\n+\t\tconst view = () => this.#agentView(agent);\n+\t\treturn {\n+\t\t\tatoms: this.#draft(agent),\n+\t\t\tget view() {\n+\t\t\t\treturn view();\n+\t\t\t},\n+\t\t};\n \t}\n \n \t/** The shared version an atom was published in, or undefined while it's only in a draft. */\n@@ -444,6 +874,12 @@\n \t\treturn p && { agent: p.agent, message: p.message, time: p.time };\n \t}\n \n+\t/** The atoms a version of shared, or of a named draft, added to its space: what was pushed together (blame's trail). */\n+\tversionAtoms(version: number, draft: string | null = null): readonly AtomId[] {\n+\t\tconst space = draft === null ? this.#shared : this.#spaces.get(draft);\n+\t\treturn space?.versions[version]?.atoms ?? [];\n+\t}\n+\n \t/** The graph, for reading (blame, history). Don't add to it. */\n \tget graph(): Graph {\n \t\treturn this.#graph;\n@@ -483,7 +919,7 @@\n \t}\n \n \t/**\n-\t * How the agent's newest edit arrived (#41). The mod sends X-Avcs-Client\n+\t * How the agent's newest edit arrived (#41). The mod sends X-Abso-Client\n \t * avcs-mod/<stamp>; the hook sends abso-cli/<version> (avcs-cli/ before #59) with the chat's\n \t * session; abso record and git pushes send no session. Edits stored before\n \t * the client was recorded have only the session: those count as the mod\n@@ -534,7 +970,7 @@\n \t * last makes it one-way: a file kept whole stays whole while it exists,\n \t * even if it shrinks or the rule changes, so it never flips back and forth.\n \t */\n-\t#isWhole(path: string, length: number, view: View | undefined, rules: readonly string[]): boolean {\n+\t#isWhole(path: string, length: number, view: ReadView | undefined, rules: readonly string[]): boolean {\n \t\treturn hostedIsWhole(this.#wholeHost, path, length, view, rules);\n \t}\n \n@@ -542,7 +978,7 @@\n \t#wholeOut(\n \t\tfiles: Readonly<Record<string, string | null>>,\n \t\tblobs: Readonly<Record<string, string>>,\n-\t\tview: View | undefined,\n+\t\tview: ReadView | undefined,\n \t\tconfig?: string,\n \t): { files: Record<string, string | null>; blobs: Record<string, string> } {\n \t\treturn hostedWholeOut(this.#wholeHost, files, blobs, view, config);\n@@ -671,6 +1107,7 @@\n \n \t/** The project's reviewers per area (#44): avcs.json's `\"review\": [{\"paths\": [...], \"reviewer\": \"...\"}]` in shared. */\n \t#reviewRules(): ReviewRule[] {\n+\t\tif ([\"abso.json\", \"avcs.json\"].every((path) => this.#graph.startCodeOf(path) === undefined)) return [];\n \t\treturn reviewRulesIn(projectFileIn(this.#sharedView())?.text);\n \t}\n \n@@ -738,16 +1175,6 @@\n \t\treturn author ? this.#currentChange(author, this.#now?.() ?? this.#lastTime) : undefined;\n \t}\n \n-\t/**\n-\t * The view a note's lines live in (#44):\n-\t * shared once any were published there; else the named draft they were\n-\t * published into; else their author's draft, where it works now or where it\n-\t * parked it. Undefined when no space holds them any more (a discarded draft).\n-\t */\n-\t#noteView(n: NoteRecord): View | undefined {\n-\t\treturn hostedNoteView(this.#notesHost, n);\n-\t}\n-\n \t#noteAnswer(n: NoteRecord): NoteAnswer {\n \t\treturn hostedNoteAnswer(this.#notesHost, n);\n \t}\n@@ -872,7 +1299,7 @@\n \t */\n \t#mergeIdentical(\n \t\tagent: AgentState,\n-\t\tbefore: View,\n+\t\tbefore: ReadView,\n \t\toldBase: ReadonlySet<AtomId>,\n \t\toldVersion: number,\n \t\ttime: number,\n@@ -921,6 +1348,49 @@\n \t\treturn hostedAnnouncePerson(this.#announceHost, ...args);\n \t}\n \n+\t/** The definition news the writes since the last call owe other agents, handed over once (news.ts). */\n+\ttakeOwedDefinitionNews(): OwedDefinitionNews[] {\n+\t\tconst owed = this.#owed;\n+\t\tthis.#owed = [];\n+\t\treturn owed;\n+\t}\n+\n+\t/** What a publish owes, worked out against its version (news.ts newsOwed), for `only` these agents if given. Reads only. */\n+\tnewsOwed(owed: OwedDefinitionNews, only?: readonly string[]): { agent: string; items: NewsItem[] }[] {\n+\t\treturn hostedNewsOwed(this.#newsHost, owed, only);\n+\t}\n+\n+\t/** newsOwed, under the name owed definition news had before abso 714. */\n+\tdefinitionNewsOwed(owed: OwedDefinitionNews, only?: readonly string[]): { agent: string; items: NewsItem[] }[] {\n+\t\treturn this.newsOwed(owed, only);\n+\t}\n+\n+\t/** The names a publish's definitions changed (news.ts owedNewsNames), worked out once for its owed news. Reads only. */\n+\towedNewsNames(owed: OwedDefinitionNews): string[] {\n+\t\treturn hostedOwedNewsNames(this.#newsHost, owed);\n+\t}\n+\n+\t/** The agents a publish's owed news may be for (news.ts owedAgents). Reads only. */\n+\towedAgents(owed: OwedDefinitionNews): string[] {\n+\t\treturn hostedOwedAgents(this.#newsHost, owed);\n+\t}\n+\n+\t/** Tells each agent its owed items, as queueNews does: what an agent was already told adds nothing. */\n+\tdeliverOwedNews(found: readonly { agent: string; items: readonly NewsItem[] }[]): number {\n+\t\tconst entries: Entry[] = [];\n+\t\tfor (const { agent: name, items } of found) {\n+\t\t\tconst agent = this.#agents.get(name);\n+\t\t\tif (agent) this.#queueNews(agent, items, entries);\n+\t\t}\n+\t\tthis.#flush(entries);\n+\t\treturn entries.length;\n+\t}\n+\n+\t/** A seat's earlier chat hears that another chat just used the seat (announce.ts seatNotice). */\n+\tseatNotice(...args: Tail<Parameters<typeof hostedSeatNotice>>): ReturnType<typeof hostedSeatNotice> {\n+\t\treturn hostedSeatNotice(this.#announceHost, ...args);\n+\t}\n+\n \t/**\n \t * Say what the agent is starting on (#37, #13), before any edit lands:\n \t * `text`, and the files it expects to change if it knows them. Nothing is\n@@ -959,7 +1429,7 @@\n \t}\n \n \t/** The collided changes behind each block whose marker lines `atom` deletes (#11). */\n-\t#markersSettled(agent: AgentState, view: View, atom: Atom): AtomId[] {\n+\t#markersSettled(agent: AgentState, view: ReadView, atom: Atom): AtomId[] {\n \t\treturn hostedMarkersSettled(this.#markerHost, agent, view, atom);\n \t}\n \n@@ -992,9 +1462,20 @@\n \t\t}\n \t}\n \n-\t/** The files the agent's unpublished changes touch, in its own view. */\n-\t#draftFiles(...args: Tail<Parameters<typeof hostedDraftFiles>>): ReturnType<typeof hostedDraftFiles> {\n-\t\treturn hostedDraftFiles(this.#overlapHost, ...args);\n+\t/**\n+\t * The files the agent's unpublished changes touch, in its own view. Kept per agent under what they're\n+\t * made of: its view's key and its draft. Most agents haven't moved since the last\n+\t * status, and the view cache holds fewer views than a big project has agents, so working them out again\n+\t * on every call cost about 0.5 s on abso. A copy goes out, so no caller can change what's kept.\n+\t */\n+\t#draftFiles(agent: AgentState): Set<string> {\n+\t\tconst key = `${this.#agentViewKey(agent)}|${this.#draft(agent).join(\",\")}`;\n+\t\tlet kept = this.#draftFilesKept.get(agent.name);\n+\t\tif (kept?.key !== key) {\n+\t\t\tkept = { key, files: hostedDraftFiles(this.#overlapHost, agent) };\n+\t\t\tthis.#draftFilesKept.set(agent.name, kept);\n+\t\t}\n+\t\treturn new Set(kept.files);\n \t}\n \n \t/** Other agents in the agent's space whose unpublished changes or starting note meet `patterns`. */\n@@ -1011,6 +1492,17 @@\n \t\treturn hostedOverlapNews(this.#overlapHost, ...args);\n \t}\n \n+\t/** The news waiting for an agent, read only: nothing is taken, heard or written. None for an agent it hasn't got. */\n+\tpeekNews(agentName: string): { text: string; at: number | null }[] {\n+\t\tconst agent = typeof agentName === \"string\" ? this.#agents.get(agentName) : undefined;\n+\t\treturn agent ? agent.news.map((text, i) => ({ text, at: agent.newsAt[i] ?? null })) : [];\n+\t}\n+\n+\t/** Whether the project has this agent. Read only. */\n+\thasAgent(agentName: string): boolean {\n+\t\treturn typeof agentName === \"string\" && this.#agents.get(agentName) !== undefined;\n+\t}\n+\n \t/** Hand over the news waiting for an agent (collisions, definitions, moves, announcements), once. */\n \tnews(agentName: string): { news: string[]; items: { text: string; at: number | null }[] } {\n \t\tconst entries: Entry[] = [];\n@@ -1099,7 +1591,7 @@\n \t\tspace: Space,\n \t\tchanges: AtomId[],\n \t\tpick: boolean,\n-\t): { collisions: Collision[]; newer: Set<AtomId>; union: Set<AtomId> } {\n+\t): { collisions: Collision[]; newer: ReadonlySet<AtomId>; union: ReadonlySet<AtomId> } {\n \t\treturn hostedLandCollisions(this.#landHost, space, changes, pick);\n \t}\n \n@@ -1194,7 +1686,7 @@\n \t * the one file ever in the view it matches, for a file since taken out.\n \t * A path that matches two files is answered exactly.\n \t */\n-\tspellingIn(view: View, path: string): string {\n+\tspellingIn(view: ReadView, path: string): string {\n \t\tif (view.hasFile(path)) return path;\n \t\tconst key = pathKey(path);\n \t\tconst live = view.knownPaths().filter((p) => pathKey(p) === key && view.hasFile(p));\n@@ -1221,6 +1713,27 @@\n \t\tconst versionsBefore = this.#spaces.get(SHARED)?.versions.length ?? 0;\n \t\ttry {\n \t\t\tthis.#applyEntry(entry, at, keptTime);\n+\t\t\t// Shared's closure, kept per version on disk (abso Capacity): after the entry, since its atoms join the graph after\n+\t\t\t// its membership.\n+\t\t\tif (this.#writerStorage && (this.#spaces.get(SHARED)?.versions.length ?? 0) > versionsBefore) {\n+\t\t\t\tconst shared = this.#spaces.get(SHARED)!;\n+\t\t\t\tconst storage = this.#writerStorage;\n+\t\t\t\tindexClosure(storage, shared, this.#graph);\n+\t\t\t\t// Each new version's changed files, from what it touched (version-files.ts): kept in the shapes table when\n+\t\t\t\t// the host gives one, so the log, a path's history and the tree never lay versions out to find them.\n+\t\t\t\tconst host: VersionFilesHost = {\n+\t\t\t\t\tstorage,\n+\t\t\t\t\tgraph: this.#graph,\n+\t\t\t\t\tat: (v) => this.#at(shared, v),\n+\t\t\t\t\tviewAt: (v) => this.#viewAt(shared, v),\n+\t\t\t\t\tempty: () => new View(this.#graph, []),\n+\t\t\t\t\tclosureChangedAt: (v) => closureChangedAt(storage, v),\n+\t\t\t\t};\n+\t\t\t\tfor (let v = versionsBefore; v < shared.versions.length; v++) {\n+\t\t\t\t\tconst { files, exists } = keptVersionFiles(host, shared.versions[v]!);\n+\t\t\t\t\tthis.#paths.keep(shared, v, files, v === 0 ? host.empty() : host.viewAt(v - 1), host.viewAt(v), exists);\n+\t\t\t\t}\n+\t\t\t}\n \t\t} finally {\n \t\t\t// Positions by version: where each version of shared was made.\n \t\t\tconst versionsAfter = this.#spaces.get(SHARED)?.versions.length ?? 0;\n@@ -1268,11 +1781,45 @@\n \t#flush(_entries: readonly Entry[]): void {\n \t\tif (this.#pending.length === 0) return;\n \t\tconst out = this.#pending;\n-\t\tthis.#pending = [];\n \t\tthis.#store.append(out);\n+\t\tif (this.#newsWritten) {\n+\t\t\tconst items: NewsWritten[] = [];\n+\t\t\tout.forEach((entry, i) => {\n+\t\t\t\tif (entry.type !== \"news\") return;\n+\t\t\t\tfor (const text of entry.text)\n+\t\t\t\t\titems.push({ agent: entry.agent, text, at: entry.time ?? null, seq: this.#stored + i });\n+\t\t\t});\n+\t\t\tif (items.length > 0) this.#newsWritten(items);\n+\t\t}\n+\t\tthis.#persistMutable();\n+\t\t// A few more agents' old told lists into their buckets at each write, until every row has moved (writer-agents.ts).\n+\t\tif (this.#agents instanceof WriterAgents) this.#agents.moveOldTold(OLD_TOLD_PER_WRITE);\n+\t\tthis.#pending = [];\n \t\tthis.#stored += out.length;\n+\t\tthis.#writeCheckpoint();\n \t}\n \n+\t#writeCheckpoint(): void {\n+\t\tthis.#writerStorage?.write(\"project:meta\", \"checkpoint\", {\n+\t\t\tformat: 1,\n+\t\t\tlogLength: this.#stored,\n+\t\t\tatoms: this.#graph.size,\n+\t\t\tversion: this.version,\n+\t\t});\n+\t}\n+\n+\t#persistMutable(): void {\n+\t\tif (!this.#writerStorage) return;\n+\t\tif (this.#agents instanceof WriterAgents) this.#agents.flush();\n+\t\tthis.#writerStorage.write(\"project:meta\", \"mods\", this.#mods);\n+\t\tthis.#writerStorage.write(\"project:meta\", \"queue\", this.#queue);\n+\t\tthis.#writerStorage.write(\n+\t\t\t\"project:meta\",\n+\t\t\t\"tells\",\n+\t\t\t[...this.#tells].map(([id, tell]) => [id, { ...tell, heard: [...tell.heard] }]),\n+\t\t);\n+\t}\n+\n \t/**\n \t * The agent an entry names. Before every applied entry was stored, a call\n \t * that joined an agent and then threw could leave the join out of the log\n@@ -1340,6 +1887,9 @@\n \t\t\tspaceNamed: (name) => this.#spaceNamed(name),\n \t\t\tcheckVersion: (space, version) => this.#checkVersion(space, version),\n \t\t\tviewAt: (space, version) => this.#viewAt(space, version),\n+\t\t\tkeptPaths: (space, version) => this.#keptPaths(space, version),\n+\t\t\tauthorTotals: (space, version, agent) => this.#authorTotals(space, version, agent as AgentState | undefined),\n+\t\t\tagentTouched: (agent) => this.#agentTouched(agent as AgentState),\n \t\t\tagentView: (agent) => this.#agentView(agent as AgentState),\n \t\t\tspellingIn: (view, asked) => this.spellingIn(view, asked),\n \t\t\tpathsOf: (space) => this.#paths.pathsOf(space),\n@@ -1350,6 +1900,57 @@\n \t\treturn this.#host;\n \t}\n \n+\t/** Shared's file list from kept shapes on a stored writer, where a version's layout reads its files from disk. */\n+\t#keptPaths(space: Space, version: number): string[] | undefined {\n+\t\treturn this.#writerStorage && space.name === SHARED ? this.#paths.keptPaths(space, version) : undefined;\n+\t}\n+\n+\t/**\n+\t * Each file's kept author totals for tree with authors (version-files.ts), on a stored writer and for shared only. An\n+\t * agent's view takes its base's totals for every file its draft doesn't touch, as its layout does (touchedBeyond),\n+\t * and lays out the rest; a draft that moves lines lays out everything.\n+\t */\n+\t#authorTotals(\n+\t\tspace: Space,\n+\t\tversion: number,\n+\t\tagent?: AgentState,\n+\t): ((path: string) => FileTotals | undefined) | undefined {\n+\t\tconst storage = this.#writerStorage;\n+\t\tif (!storage || space.name !== SHARED || authoredVersion(storage) === undefined) return undefined;\n+\t\tif (!agent) return (path) => authorTotalsAt(storage, path, version);\n+\t\tconst except = this.#agentTouched(agent);\n+\t\tif (!except) return undefined;\n+\t\treturn (path) => (except.has(path) ? undefined : authorTotalsAt(storage, path, version));\n+\t}\n+\n+\t/**\n+\t * The files an agent's draft, and whatever it depends on beyond its base, can make differ from its base\n+\t * (touchedBeyond); every other file is the same in both. Undefined when the draft moves lines.\n+\t */\n+\t#agentTouched(agent: AgentState): ReadonlySet<string> | undefined {\n+\t\tif (agent.mine.length === 0) return new Set();\n+\t\tconst base = this.#viewAt(this.#spaceOf(agent), agent.base);\n+\t\tconst view = this.#agentView(agent);\n+\t\treturn touchedBeyond(this.#graph, base.set, agent.mine, [base, view], () => placedBetween(view, base));\n+\t}\n+\n+\t/**\n+\t * Kept author totals for a folder's blame (blame.ts), where blame reads: shared at a version (the newest by default) or\n+\t * an agent's view. A named draft has none. Undefined when none are kept.\n+\t */\n+\tauthorTotalsFor(where: {\n+\t\tversion?: number;\n+\t\tdraft?: string;\n+\t\tagent?: string;\n+\t}): ((path: string) => FileTotals | undefined) | undefined {\n+\t\tif (where.draft !== undefined) return undefined;\n+\t\tif (where.agent !== undefined) {\n+\t\t\tconst agent = this.#agents.get(where.agent);\n+\t\t\treturn agent ? this.#authorTotals(this.#spaceOf(agent), agent.base, agent) : undefined;\n+\t\t}\n+\t\treturn this.#authorTotals(this.#shared, where.version ?? last(this.#shared));\n+\t}\n+\n \t/** One folder at a version (history.ts). */\n \ttree(...args: Tail<Parameters<typeof historyTree>>): ReturnType<typeof historyTree> {\n \t\treturn historyTree(this.#history, ...args);\n@@ -1408,12 +2009,37 @@\n \t\treturn versionFileAt(this.#logHost, ...args);\n \t}\n \n+\t/** fileAt for exactly this spelling, from the file's own lines: no list of the version's files (version-log.ts). */\n+\tfileExactAt(...args: Tail<Parameters<typeof versionFileExactAt>>): ReturnType<typeof versionFileExactAt> {\n+\t\treturn versionFileExactAt(this.#logHost, ...args);\n+\t}\n+\n \t/** Every file that differs between two versions of shared (or a named draft) (version-log.ts). */\n \tcompare(...args: Tail<Parameters<typeof versionCompare>>): ReturnType<typeof versionCompare> {\n \t\treturn versionCompare(this.#logHost, ...args);\n \t}\n \n-\t/** A version of shared (or of a named draft) as a View (version-log.ts). */\n+\t/** compare as each file's size and SHA-256, not its texts (version-log.ts, abso issue 680). */\n+\tcompareSummary(...args: Tail<Parameters<typeof versionCompareSummary>>): ReturnType<typeof versionCompareSummary> {\n+\t\treturn versionCompareSummary(this.#logHost, ...args);\n+\t}\n+\n+\t/** A version of shared without some earlier versions, or the refusal naming what builds on them (without.ts). */\n+\twithout(version: number, versions: readonly number[]): ReturnType<typeof hostedWithout> {\n+\t\tconst host: WithoutHost = {\n+\t\t\tgraph: this.#graph,\n+\t\t\tshared: () => this.#shared,\n+\t\t\tneedInit: () => this.#needInit(),\n+\t\t\tcheckVersion: (space, v) => this.#checkVersion(space, v),\n+\t\t\tviewAt: (space, v) => this.#viewAt(space, v),\n+\t\t\tat: (space, v) => this.#at(space, v),\n+\t\t\tclosed: (set) => this.#closed(set),\n+\t\t\ttouchedFiles: (ids, views) => this.#touchedFiles(ids, views),\n+\t\t};\n+\t\treturn hostedWithout(host, version, versions);\n+\t}\n+\n+\t/** A version of shared (or of a named draft) as a ReadView (version-log.ts). */\n \tviewAt(...args: Tail<Parameters<typeof versionViewAt>>): ReturnType<typeof versionViewAt> {\n \t\treturn versionViewAt(this.#logHost, ...args);\n \t}\n@@ -1431,13 +2057,43 @@\n \t\t\tdefinitionRule: () => this.#definitionRule,\n \t\t\tdraft: (agent) => this.#draft(agent as AgentState),\n \t\t\tagentView: (agent) => this.#agentView(agent as AgentState),\n-\t\t\tview: (set) => this.#view(set),\n-\t\t\tpairs: (draft, against, settled) => this.#pairs(draft, against, settled),\n+\t\t\tdraftsView: (agents) => this.#draftsView(agents as readonly AgentState[]),\n \t\t\ttouchedFiles: (ids, views) => this.#touchedFiles(ids, views),\n+\t\t\t// On a stored writer only, as a reader kept between calls is (abso Capacity).\n+\t\t\tkeptParts: () => (this.#writerStorage ? (this.#keptParts ??= new KeptParts()) : undefined),\n+\t\t\tdraftKey: (agent) => {\n+\t\t\t\tconst a = agent as AgentState;\n+\t\t\t\treturn `${last(this.#shared)} ${a.space}@${a.base} ${this.#draft(a).join(\",\")}`;\n+\t\t\t},\n \t\t};\n \t\treturn this.#draftCollisionHost;\n \t}\n \n+\t/**\n+\t * Shared now with some agents' drafts on top, for draft collisions (abso Capacity). Kept under the drafts' atoms and\n+\t * shared's version, so a second ask with nothing changed lays nothing out again, and laid out as shared is for every\n+\t * file the drafts don't touch, as an agent's view is. One agent based on shared's newest version is its own view.\n+\t */\n+\t#draftsView(agents: readonly AgentState[]): ReadView {\n+\t\tconst shared = this.#shared;\n+\t\tconst version = last(shared);\n+\t\tconst only = agents.length === 1 ? agents[0]! : undefined;\n+\t\tif (only && only.space === SHARED && only.base === version) return this.#agentView(only);\n+\t\tconst drafts = agents.map((agent) => this.#draft(agent));\n+\t\tconst mine = drafts.flat();\n+\t\tconst base = this.#sharedView();\n+\t\tconst view = this.#viewKeyed(`d ${SHARED}@${version}+${drafts.map((d) => d.join(\",\")).join(\"+\")}`, () =>\n+\t\t\tunionOverlay(base.set, mine),\n+\t\t);\n+\t\tif (this.#writerStorage && mine.length > 0 && view instanceof View && base instanceof View) {\n+\t\t\tview.shareMoves(base);\n+\t\t\tview.shareFiles(base, () =>\n+\t\t\t\ttouchedBeyond(this.#graph, base.set, mine, [base, view], () => placedBetween(view, base)),\n+\t\t\t);\n+\t\t}\n+\t\treturn view;\n+\t}\n+\n \t/** Whether agents' unpublished changes would collide, by the publish rule (draft-collisions.ts). */\n \tcollisions(...args: Tail<Parameters<typeof draftCollisions>>): ReturnType<typeof draftCollisions> {\n \t\treturn draftCollisions(this.#draftCollisions, ...args);\n@@ -1452,6 +2108,10 @@\n \t\t\tneedInit: () => this.#needInit(),\n \t\t\tdraft: (agent) => this.#draft(agent as AgentState),\n \t\t\tagentView: (agent) => this.#agentView(agent as AgentState),\n+\t\t\tagentViewWithout: (agent, excluded) => {\n+\t\t\t\tconst state = agent as AgentState;\n+\t\t\t\treturn this.#agentView({ ...state, mine: state.mine.filter((id) => !excluded.has(id)) });\n+\t\t\t},\n \t\t\tview: (set) => this.#view(set),\n \t\t\ttouchedFiles: (ids, views) => this.#touchedFiles(ids, views),\n \t\t};\n@@ -1478,6 +2138,16 @@\n \t\tthis.#movesHost ??= {\n \t\t\tgraph: this.#graph,\n \t\t\tdraft: (agent) => this.#unqueuedDraft(agent),\n+\t\t\tbeforeDraft: (agent, draft) => {\n+\t\t\t\tconst base = this.#at(this.#spaceOf(agent), agent.base);\n+\t\t\t\tif (draft.some((id) => base.has(id)))\n+\t\t\t\t\treturn this.#view(differenceSet(this.#agentView(agent).set, new StableOverlaySet(draft)));\n+\t\t\t\tconst removed = new Set(draft),\n+\t\t\t\t\tkept = agent.mine.filter((id) => !removed.has(id));\n+\t\t\t\treturn kept.length === 0\n+\t\t\t\t\t? this.#viewAt(this.#spaceOf(agent), agent.base)\n+\t\t\t\t\t: this.#viewKeyed(`a ${agent.space}@${agent.base}+${kept.join(\",\")}`, () => unionOverlay(base, kept));\n+\t\t\t},\n \t\t\tagentView: (agent) => this.#agentView(agent),\n \t\t\tview: (set) => this.#view(set),\n \t\t\tapply: (entry) => this.#apply(entry),\n@@ -1514,8 +2184,18 @@\n \t\t\tviewAt: (space, version) => this.#viewAt(space, version),\n \t\t\torigin: (atom, spaceName) => this.#origin(atom, spaceName),\n \t\t\tcollision: (agent, pair) => this.#collision(agent, pair),\n-\t\t\tdefinitionCollisions: (agent, newer) => this.#definitionCollisions(agent, newer),\n+\t\t\tdefinitionCollisions: (agent, newer, names) => this.#definitionCollisions(agent, newer, names),\n \t\t\tqueueNews: (agent, items, entries) => this.#queueNews(agent, items, entries),\n+\t\t\tlogLine: (line) => this.#logLine?.(line),\n+\t\t\towesDefinitionNews: () => this.owesDefinitionNews,\n+\t\t\towe: (owed) => void this.#owed.push(owed),\n+\t\t\tspaceNamed: (name) => (name === SHARED ? this.#shared : this.#spaces.get(name)),\n+\t\t\tnewerAt: (agent, version) => this.#newerFor(agent, version),\n+\t\t\tdefinitionCollisionsAt: (agent, newer, names, version) =>\n+\t\t\t\tthis.#definitionCollisions(agent, newer, names, version),\n+\t\t\tsetAt: (space, version) => this.#at(space, version),\n+\t\t\tcollisionAt: (agent, pair, version) =>\n+\t\t\t\tthis.#describe(pair, this.#agentView(agent), this.#viewAt(this.#spaceOf(agent), version), agent.space),\n \t\t};\n \t\treturn this.#news;\n \t}\n@@ -1527,7 +2207,7 @@\n \t\t\tspaces: this.#spaces,\n \t\t\tversion: () => this.version,\n \t\t\tspaceOf: (agent) => this.#spaceOf(agent),\n-\t\t\tagentSet: (agent) => this.#agentSet(agent),\n+\t\t\tagentSet: (agent) => unionOverlay(this.#at(this.#spaceOf(agent), agent.base), agent.mine),\n \t\t\tdraft: (agent) => this.#draft(agent),\n \t\t\tagentView: (agent) => this.#agentView(agent),\n \t\t\tat: (space, version) => this.#at(space, version),\n@@ -1669,13 +2349,17 @@\n \t\t\tcollision: (agent, pair) => this.#collision(agent, pair),\n \t\t\tdefinitionCollisions: (agent, newer) => this.#definitionCollisions(agent, newer),\n \t\t\tduplicates: (agent) => this.#duplicates(agent),\n-\t\t\trefuse: (agent, space, via, time, collisions, entries) =>\n-\t\t\t\tthis.#refuse(agent, space, via, time, collisions, entries),\n+\t\t\trefuse: (agent, space, via, time, collisions, entries, message) =>\n+\t\t\t\tthis.#refuse(agent, space, via, time, collisions, entries, message),\n \t\t\tmarkerCollisions: (agent) => this.#markerCollisions(agent),\n \t\t\tenqueue: (agent, message, time, draft, resolves, entries) =>\n \t\t\t\tthis.#enqueue(agent, message, time, draft, resolves, entries),\n \t\t\tview: (set) => this.#view(set),\n \t\t\trequireClosed: (tie, union) => this.#requireClosed(tie, union),\n+\t\t\tspaceOverlay: (space, atoms) =>\n+\t\t\t\tthis.#viewKeyed(`a ${space.name}@${last(space)}+${atoms.join(\",\")}`, () =>\n+\t\t\t\t\tunionOverlay(this.#setOf(space), atoms),\n+\t\t\t\t),\n \t\t\tnewerFor: (agent) => this.#newerFor(agent),\n \t\t\tcurrentChange: (agent, time) => this.#currentChange(agent, time),\n \t\t\tapply: (entry) => this.#apply(entry),\n@@ -1694,6 +2378,18 @@\n \t\t\tgraph: this.#graph,\n \t\t\tcheckerReady: () => this.checkerReady,\n \t\t\tsharedView: () => this.#sharedView(),\n+\t\t\tsharedOverlay: (atoms) =>\n+\t\t\t\tthis.#viewKeyed(`a @${last(this.#shared)}+${atoms.join(\",\")}`, () =>\n+\t\t\t\t\tunionOverlay(this.#setOf(this.#shared), atoms),\n+\t\t\t\t),\n+\t\t\tsharedAgentOverlay: (agent, atoms) => {\n+\t\t\t\tconst current = this.#setOf(this.#shared);\n+\t\t\t\tconst added = new Set([...atoms, ...agent.mine]);\n+\t\t\t\t// Retain old-base atoms absent from current shared, without copying shared history.\n+\t\t\t\tif (agent.base !== last(this.#shared))\n+\t\t\t\t\tfor (const id of this.#at(this.#spaceOf(agent), agent.base)) if (!current.has(id)) added.add(id);\n+\t\t\t\treturn this.#viewKeyed(`a @${last(this.#shared)}+${[...added].join(\",\")}`, () => unionOverlay(current, added));\n+\t\t\t},\n \t\t\tqueued: () => this.#queue,\n \t\t\tqueuedId: () => this.#queuedId,\n \t\t\tcheckingHas: (id) => this.#checking.has(id),\n@@ -1712,8 +2408,8 @@\n \t\t\tpairs: (draft, against, settled) => this.#pairs(draft, against, settled),\n \t\t\tdescribe: (pair, yoursView, theirsView, spaceName) => this.#describe(pair, yoursView, theirsView, spaceName),\n \t\t\ttouchedFiles: (ids, views) => this.#touchedFiles(ids, views),\n-\t\t\trefuse: (agent, space, via, time, collisions, entries) =>\n-\t\t\t\tthis.#refuse(agent, space, via, time, collisions, entries),\n+\t\t\trefuse: (agent, space, via, time, collisions, entries, message) =>\n+\t\t\t\tthis.#refuse(agent, space, via, time, collisions, entries, message),\n \t\t\tcurrentChange: (agent, time) => this.#currentChange(agent, time),\n \t\t\tnextAt: () => this.#nextAt,\n \t\t\tapply: (entry) => this.#apply(entry),\n@@ -1780,6 +2476,12 @@\n \t#landers?: LandHost;\n \tget #landHost(): LandHost {\n \t\tthis.#landers ??= {\n+\t\t\tviewAt: (space, version, changes) =>\n+\t\t\t\tchanges?.length\n+\t\t\t\t\t? this.#viewKeyed(`a ${space.name}@${version}+${changes.join(\",\")}`, () =>\n+\t\t\t\t\t\t\tunionOverlay(this.#at(space, version), changes),\n+\t\t\t\t\t\t)\n+\t\t\t\t\t: this.#viewAt(space, version),\n \t\t\tagents: this.#agents,\n \t\t\tgraph: this.#graph,\n \t\t\tspaces: this.#spaces,\n@@ -1797,6 +2499,9 @@\n \t\t\tpairs: (draft, against, settled) => this.#pairs(draft, against, settled),\n \t\t\tdescribe: (pair, yoursView, theirsView, spaceName) => this.#describe(pair, yoursView, theirsView, spaceName),\n \t\t\tdefinitionRule: () => this.#definitionRule,\n+\t\t\t// Only from a stored writer's kept rows, as keptPaths: a project in memory keeps none, and works them out.\n+\t\t\tchangedSince: (space, from, to) =>\n+\t\t\t\tthis.#writerStorage ? this.#paths.keptChangesSince(space, from, to) : undefined,\n \t\t\trefuse: (agent, space, via, time, collisions, entries) =>\n \t\t\t\tthis.#refuse(agent, space, via, time, collisions, entries),\n \t\t\trequireClosed: (tie, union) => this.#requireClosed(tie, union),\n@@ -1843,6 +2548,8 @@\n \t\t\tview: (set) => this.#view(set),\n \t\t\tagentSet: (agent) => this.#agentSet(agent),\n \t\t\tagentView: (agent) => this.#agentView(agent),\n+\t\t\tagentViewWithout: (agent, excluded) =>\n+\t\t\t\tthis.#agentView({ ...agent, mine: agent.mine.filter((id) => !excluded.has(id)) }),\n \t\t\trecordFile: (agent, view, path, text, time, meta, entries, mode, blob, hunks) =>\n \t\t\t\tthis.#recordFile(agent, view, path, text, time, meta, entries, mode, blob, hunks),\n \t\t\tflush: (entries) => this.#flush(entries),\n@@ -1873,6 +2580,12 @@\n \t\t\tagent: (name, entries) => this.#agent(name, entries),\n \t\t\tspaceOf: (agent) => this.#spaceOf(agent),\n \t\t\tagentView: (agent) => this.#agentView(agent),\n+\t\t\tcaptureAgentView: (agent) => {\n+\t\t\t\tconst key = this.#agentViewKey(agent);\n+\t\t\t\tconst original = this.#agentView(agent);\n+\t\t\t\t// Projected readers reopen the immutable key; only the in-memory fallback uses the original set.\n+\t\t\t\treturn () => this.#viewKeyed(key, () => original.set);\n+\t\t\t},\n \t\t\tat: (space, version) => this.#at(space, version),\n \t\t\tdraft: (agent) => this.#draft(agent),\n \t\t\tstrandedFiles: (draft, set) => this.#strandedFiles(draft, set),\n@@ -1939,8 +2652,13 @@\n \tget #checkClashHost(): CheckClashHost {\n \t\tthis.#checkClashes ??= {\n \t\t\tshared: () => this.#shared,\n+\t\t\tsetOf: (space) => this.#setOf(space),\n \t\t\tview: (set) => this.#view(set),\n \t\t\tsharedView: () => this.#sharedView(),\n+\t\t\tsharedOverlay: (atoms) =>\n+\t\t\t\tthis.#viewKeyed(`a @${last(this.#shared)}+${atoms.join(\",\")}`, () =>\n+\t\t\t\t\tunionOverlay(this.#setOf(this.#shared), atoms),\n+\t\t\t\t),\n \t\t\ttouchedFiles: (ids, views) => this.#touchedFiles(ids, views),\n \t\t};\n \t\treturn this.#checkClashes;\n@@ -2028,6 +2746,7 @@\n \t\t\tagents: this.#agents,\n \t\t\tagentView: (agent) => this.#agentView(agent),\n \t\t\tdraft: (agent) => this.#draft(agent),\n+\t\t\tdraftFiles: (agent) => this.#draftFiles(agent),\n \t\t\tliveNote: (agent) => this.#liveNote(agent),\n \t\t\tqueueNews: (agent, items, entries) => this.#queueNews(agent, items, entries),\n \t\t};\n@@ -2152,6 +2871,7 @@\n \t\t\tspaceNamed: (name) => this.#spaceNamed(name),\n \t\t\tcheckVersion: (space, version) => this.#checkVersion(space, version),\n \t\t\tviewAt: (space, version) => this.#viewAt(space, version),\n+\t\t\tkeptPaths: (space, version) => this.#keptPaths(space, version),\n \t\t\tagentView: (agent) => this.#agentView(agent),\n \t\t\tversion: () => this.version,\n \t\t\tprojectFile: () => (this.initialized ? projectFileIn(this.#sharedView()) : undefined),\n@@ -2184,6 +2904,16 @@\n \t\treturn snapshotStatus(this.#snapshot);\n \t}\n \n+\t/** The operation fence needs one actor's heads, not every agent's file projection. */\n+\tactorHead(name: string): { base: number; draftChanges: number; draft: string | null } | undefined {\n+\t\tconst agent = this.#agents.get(name);\n+\t\tif (!agent) return undefined;\n+\t\tconst published = this.#setOf(this.#spaceOf(agent));\n+\t\tlet draftChanges = 0;\n+\t\tfor (const id of agent.mine) if (!published.has(id)) draftChanges++;\n+\t\treturn { base: agent.base, draftChanges, draft: agent.space === SHARED ? null : agent.space };\n+\t}\n+\n \t/** A space's contents at one of its versions. */\n \t#at(space: Space, version: number): ReadonlySet<AtomId> {\n \t\treturn this.#membership.at(space, version);\n@@ -2216,27 +2946,70 @@\n \t\treturn new Set([...this.#at(this.#spaceOf(agent), agent.base), ...agent.mine]);\n \t}\n \n-\t#agentView(agent: AgentState): View {\n-\t\t// Keyed by what the set is made of, not by sorting every atom in it (#46): that cost more than the work.\n-\t\treturn this.#viewKeyed(`a ${agent.space}@${agent.base}+${agent.mine.join(\",\")}`, () => this.#agentSet(agent));\n+\t#agentView(agent: AgentState): ReadView {\n+\t\tconst view = this.#viewKeyed(this.#agentViewKey(agent), () => {\n+\t\t\tconst base = this.#at(this.#spaceOf(agent), agent.base);\n+\t\t\treturn base instanceof StableSet\n+\t\t\t\t? new StableUnionSet(base, new StableOverlaySet(agent.mine))\n+\t\t\t\t: new Set([...base, ...agent.mine]);\n+\t\t});\n+\t\t// A draft that moves nothing resolves its moves as its base does (abso Capacity): take them from the base's view.\n+\t\tif (this.#writerStorage && agent.mine.length > 0 && view instanceof View) {\n+\t\t\tconst base = this.#viewAt(this.#spaceOf(agent), agent.base);\n+\t\t\tif (base instanceof View) {\n+\t\t\t\tview.shareMoves(base);\n+\t\t\t\t// And its layout of every file the draft doesn't touch, when the draft moves nothing (abso Capacity). What the\n+\t\t\t\t// view holds beyond its base is the draft and whatever the draft depends on that the base lacks (the view's\n+\t\t\t\t// set is closed): each of those can change a file, so all of them count.\n+\t\t\t\tconst mine = agent.mine;\n+\t\t\t\tview.shareFiles(base, () =>\n+\t\t\t\t\ttouchedBeyond(this.#graph, base.set, mine, [base, view], () => placedBetween(view, base)),\n+\t\t\t\t);\n+\t\t\t}\n+\t\t}\n+\t\treturn view;\n \t}\n \n+\t/** An agent's view, keyed by what the set is made of, not by sorting every atom in it (#46): that cost more than the work. */\n+\t#agentViewKey(agent: AgentState): string {\n+\t\t// An empty draft is exactly its published base. Share its projection\n+\t\t// with version readers instead of walking the same history twice.\n+\t\tif (agent.mine.length === 0) return `v ${agent.space}@${agent.base}`;\n+\t\treturn `a ${agent.space}@${agent.base}+${agent.mine.join(\",\")}`;\n+\t}\n+\n \t/** A space at a version: published versions never change, so the key is just their names (#46). */\n-\t#viewAt(space: Space, version: number): View {\n-\t\treturn this.#viewKeyed(`v ${space.name}@${version}`, () => this.#at(space, version));\n+\t#viewAt(space: Space, version: number): ReadView {\n+\t\tconst view = this.#viewKeyed(`v ${space.name}@${version}`, () => this.#at(space, version));\n+\t\t// Which files it has from the kept path list (abso Capacity, View.knowPaths), as pathsAt answers.\n+\t\tif (view instanceof View && this.#writerStorage && space.name === SHARED)\n+\t\t\tview.knowPaths(() => this.#paths.keptPathSet(space, version));\n+\t\treturn view;\n \t}\n \n-\t#sharedView(): View {\n+\t#sharedView(): ReadView {\n \t\treturn this.#viewAt(this.#shared, last(this.#shared));\n \t}\n \n+\t/**\n+\t * After each read of a reader kept between calls, one that changed nothing (abso Capacity): the cached views back\n+\t * under their budget, since views grow while a call lays files out and the cache weighs them only when they are\n+\t * asked for again (on abso, a tree with authors left 38 MB of views held against the 24 MB budget), and the agents\n+\t * the read decoded let go, read again from storage by the next call (7 MB on abso, every agent's news told).\n+\t */\n+\tafterRead(): void {\n+\t\tthis.#views.trim();\n+\t\tif (this.#agents instanceof WriterAgents) this.#agents.release();\n+\t}\n+\n \t/** A view of a set, cached by the set's exact contents (views.ts). */\n-\t#view(set: ReadonlySet<AtomId>): View {\n+\t#view(set: ReadonlySet<AtomId>): ReadView {\n+\t\tthis.#views.assertUnkeyedAllowed();\n \t\treturn this.#views.view(this.#closed(set));\n \t}\n \n \t/** A view cached under `key` (views.ts). */\n-\t#viewKeyed(key: string, set: () => ReadonlySet<AtomId>): View {\n+\t#viewKeyed(key: string, set: () => ReadonlySet<AtomId>): ReadView {\n \t\treturn this.#views.keyed(key, () => this.#closed(set()));\n \t}\n \n@@ -2244,7 +3017,36 @@\n \t * A discarded atom that a later publish still depends on stays in the view\n \t * (abso issue 80). A closed set is unchanged.\n \t */\n-\t#closed(set: Iterable<AtomId>): Set<AtomId> {\n+\t#closed(set: Iterable<AtomId>): ReadonlySet<AtomId> {\n+\t\tif (isClosedSet(set)) return set as ReadonlySet<AtomId>;\n+\t\tif (set instanceof StableSet) {\n+\t\t\t// Keep indexed membership external. Only dependencies absent from\n+\t\t\t// that snapshot belong in the operation's closure overlay. Over a stored closed base (abso Capacity),\n+\t\t\t// only the atoms outside it can reach outside it: unions are opened down to their closed parts.\n+\t\t\tconst walk: Iterable<AtomId>[] = [];\n+\t\t\tconst open = (part: ReadonlySet<AtomId>): void => {\n+\t\t\t\tif (isClosedSet(part)) return;\n+\t\t\t\tif (part instanceof StableUnionSet) {\n+\t\t\t\t\topen(part.left);\n+\t\t\t\t\topen(part.right);\n+\t\t\t\t} else walk.push(part);\n+\t\t\t};\n+\t\t\topen(set);\n+\t\t\tconst missing = new Set<AtomId>();\n+\t\t\tconst visit = (id: AtomId) => {\n+\t\t\t\tconst stack = [id];\n+\t\t\t\twhile (stack.length) {\n+\t\t\t\t\tfor (const dependency of this.#graph.atom(stack.pop()!).deps) {\n+\t\t\t\t\t\tif (!set.has(dependency) && !missing.has(dependency)) {\n+\t\t\t\t\t\t\tmissing.add(dependency);\n+\t\t\t\t\t\t\tstack.push(dependency);\n+\t\t\t\t\t\t}\n+\t\t\t\t\t}\n+\t\t\t\t}\n+\t\t\t};\n+\t\t\tfor (const part of walk) for (const id of part) visit(id);\n+\t\t\treturn markClosed(missing.size ? new StableUnionSet(set, new StableOverlaySet(missing)) : set);\n+\t\t}\n \t\treturn this.#graph.closureOf(set);\n \t}\n \n@@ -2254,16 +3056,21 @@\n \t\tif (missing.length > 0)\n \t\t\tthrow new ProjectError(\n \t\t\t\t\"conflict\",\n-\t\t\t\t`this change depends on ${missing.join(\", \")}, which is not in the set being published`,\n+\t\t\t\t`this change depends on ${missing.join(\", \")}, which is not in the set being pushed`,\n \t\t\t);\n \t}\n \n \t/** The space's atoms published after the agent's base, by others. */\n-\t#newerFor(agent: AgentState): Set<AtomId> {\n+\t/** `upTo`: the work published after the agent's base up to that version only (owed news, news.ts). */\n+\t#newerFor(agent: AgentState, upTo?: number): ReadonlySet<AtomId> {\n \t\tconst space = this.#spaceOf(agent);\n \t\tconst base = this.#at(space, agent.base);\n-\t\tconst mine = new Set(agent.mine);\n-\t\treturn new Set([...this.#setOf(space)].filter((id) => !base.has(id) && !mine.has(id)));\n+\t\tconst current = upTo === undefined ? this.#setOf(space) : this.#at(space, upTo);\n+\t\tconst newer =\n+\t\t\tspace.name === SHARED && space.membershipVersion\n+\t\t\t\t? new SharedAdditions(space, agent.base, base, current, upTo ?? last(space))\n+\t\t\t\t: differenceSet(current, base);\n+\t\treturn differenceSet(newer, new StableOverlaySet(agent.mine));\n \t}\n \n \t/** The files whose text in the agent's view differs from `before`, and its open collisions. */\n@@ -2379,7 +3186,7 @@\n \t\t);\n \t}\n \n-\t#describe(pair: Pair, yoursView: View, theirsView: View, spaceName: string): Collision {\n+\t#describe(pair: Pair, yoursView: ReadView, theirsView: ReadView, spaceName: string): Collision {\n \t\treturn describePair(\n \t\t\tthis.#graph,\n \t\t\t(atom, space) => this.#origin(atom, space),\n@@ -2390,26 +3197,40 @@\n \t\t);\n \t}\n \n-\t#touchedFiles(ids: Iterable<AtomId>, views: readonly View[]): Set<string> {\n+\t#touchedFiles(ids: Iterable<AtomId>, views: readonly ReadView[]): Set<string> {\n \t\treturn touchedFiles(this.#graph, ids, views);\n \t}\n \n \t// The changed-definition rule (#11) -------------------------------------------\n \n \t/** The rule for an agent's draft in its space. */\n-\t#definitionCollisions(agent: AgentState, newer: ReadonlySet<AtomId>): DefinitionCollision[] {\n+\t#definitionCollisions(\n+\t\tagent: AgentState,\n+\t\tnewer: ReadonlySet<AtomId>,\n+\t\tnames?: ReadonlySet<string>,\n+\t\t/** The space's version to compare against: its newest, or an owed publish's (news.ts). */\n+\t\tversion?: number,\n+\t): DefinitionCollision[] {\n \t\tconst draft = new Set(this.#draft(agent));\n \t\tif (draft.size === 0 || newer.size === 0) return [];\n \t\tconst space = this.#spaceOf(agent);\n-\t\tconst mine = new Set(agent.mine);\n-\t\tconst base = this.#view(new Set([...this.#at(space, agent.base)].filter((id) => !mine.has(id))));\n+\t\tconst at = this.#at(space, agent.base);\n+\t\tconst base = agent.mine.some((id) => at.has(id))\n+\t\t\t? this.#view(differenceSet(at, new StableOverlaySet(agent.mine)))\n+\t\t\t: this.#viewAt(space, agent.base);\n+\t\tconst to = version ?? last(space);\n \t\treturn this.#definitionRule.collisions(\n \t\t\tdraft,\n \t\t\tthis.#agentView(agent),\n \t\t\tbase,\n-\t\t\tthis.#viewAt(space, last(space)),\n+\t\t\tthis.#viewAt(space, to),\n \t\t\tnewer,\n \t\t\tspace.name,\n+\t\t\tundefined,\n+\t\t\tnames,\n+\t\t\t// Where the space changed since the agent's base, from each version's kept files on a stored writer, as land's\n+\t\t\t// (abso 714): walking every newer atom for them was 6.5 s of a publish 770 versions behind on abso.\n+\t\t\t() => (this.#writerStorage ? this.#paths.keptChangesSince(space, agent.base, to) : undefined),\n \t\t);\n \t}\n }"}],"unmatched":[]}