Skip to content

abso-core

Public

abso is version control for agents: the client, the engine and a server you can run on your own Cloudflare account.

Not checked

Versions 277 to 318

Compare

+1023 −85 in 58 places
Lines 68–74 at 318 (were 68–74 at 277)
6868 }
6969 for (const key of claimsOf(atom)) streams.push(g.eachWriterOf(key));
7070 const theirs: AtomId[] = [];
71− for (const id of orderedClaimants(g, streams)) if (against.has(id)) theirs.push(id);
71+ for (const id of orderedClaimants(streams)) if (against.has(id)) theirs.push(id);
7272 out.set(yours, theirs);
7373 }
7474 return out;
Lines 136–142 at 318 (were 136–142 at 277)
136136
137137/** Claim indexes append in canonical seq order. Merge one cursor per current
138138 * atom key, retaining no candidate set proportional to historical claims. */
139−function* orderedClaimants(g: Graph, streams: IterableIterator<AtomId>[]): IterableIterator<AtomId> {
139+function* orderedClaimants(streams: IterableIterator<AtomId>[]): IterableIterator<AtomId> {
140140 try {
141141 type Head = { id: AtomId; seq: number; stream: number };
142142 const heap: Head[] = [];
Lines 152–162 at 318 (were 152–160 at 277)
152152 }
153153 heap[at] = head;
154154 };
155+ // Each claimant's seq from its id, as the graph reads it (abso 738): loading the stored atom for it read a row a
156+ // claimant, most of a warm draft-state's pairing on abso.
155157 const advance = (stream: number) => {
156158 const next = streams[stream]!.next();
157− if (!next.done) push({ id: next.value, seq: g.atom(next.value).seq, stream });
159+ if (!next.done) push({ id: next.value, seq: seqOf(next.value), stream });
158160 };
159161 for (let stream = 0; stream < streams.length; stream++) advance(stream);
160162 let previous = -1;
Lines 192–199 at 318 (were 190–197 at 277)
190192 let a = left.next();
191193 let b = right.next();
192194 while (!a.done && !b.done) {
193− const x = g.atom(a.value).seq;
194− const y = g.atom(b.value).seq;
195+ const x = seqOf(a.value);
196+ const y = seqOf(b.value);
195197 if (x === y && settled.has(a.value)) return true;
196198 if (x <= y) a = left.next();
197199 if (y <= x) b = right.next();
Lines 7–13 at 318 (were 7–13 at 277)
77import { type AtomId, type Graph, joinLines, type LineId, type ReadView } from "../../src/engine/index.ts";
88import { type Origin, touchedFiles } from "./collisions.ts";
99import { type Definition, definitionsIn, importsOf, usedNames } from "./definitions.ts";
10−import { definitionsBytes, type KeptParts, usesBytes } from "./kept-parts.ts";
10+import { definitionsBytes, filesBytes, type KeptParts, usesBytes } from "./kept-parts.ts";
1111import { codeOfLines, declaredIn, holdsNoCode } from "./names.ts";
1212import { definitionText } from "./news.ts";
1313import type { Collision } from "./project.ts";
Lines 37–43 at 318 (were 37–43 at 277)
3737 readonly parent: string;
3838}
3939
40−/** Definitions in the files newer work touched, before it and with it. */
40+/** Definitions in one file newer work touched, before it and with it. */
4141interface Changed {
4242 readonly baseDefs: ReturnType<typeof definitionsIn>;
4343 readonly nowDefs: ReturnType<typeof definitionsIn>;
Lines 52–62 at 318 (were 52–59 at 277)
5252 readonly #replacedCache = new Map<string, ReadonlySet<string>>();
5353 /** A draft's uses, kept while it is asked about with the same views: draft collisions ask once per other agent. */
5454 readonly #usesCache = new WeakMap<ReadonlySet<AtomId>, { view: ReadView; base: ReadView; uses: Uses }>();
55− /** The newer work's definitions before and after, kept while it is asked about with the same views. */
56− readonly #changedCache = new WeakMap<ReadonlySet<AtomId>, { base: ReadView; now: ReadView; defs: Changed }>();
55+ /** The files the newer work touched, kept while it is asked about with the same views. */
56+ readonly #touchedCache = new WeakMap<
57+ ReadonlySet<AtomId>,
58+ { base: ReadView; now: ReadView; files: ReadonlySet<string> }
59+ >();
5760
5861 constructor(graph: Graph, origin: (atom: AtomId, spaceName: string) => Origin) {
5962 this.#graph = graph;
Lines 124–194 at 318 (were 121–157 at 277)
121124 newer: ReadonlySet<AtomId>,
122125 spaceName: string,
123126 kept?: { parts: KeptParts; uses: string; changed: string },
127+ names?: ReadonlySet<string>,
128+ /**
129+ * The files the newer work changed, when the caller knows them without placing its lines (land and draft-state:
130+ * shared's kept version files, abso 738); undefined, or one that answers undefined, and they're worked out here.
131+ */
132+ changedFiles?: () => ReadonlySet<string> | undefined,
124133 ): DefinitionCollision[] {
125134 if (draft.size === 0 || newer.size === 0) return [];
126135 const uses = kept
127136 ? kept.parts.get(`uses ${kept.uses}`, () => this.#usesOf(draft, view, baseView), usesBytes)
128137 : this.#usesFor(draft, view, baseView);
129138 if (uses.size === 0) return [];
130− const nowOf = () => (typeof nowView === "function" ? nowView() : nowView);
131− const { baseDefs, nowDefs } = kept
132− ? kept.parts.get(
133− `changed ${kept.changed}`,
134− () => this.#changed(newer, baseView, nowOf()),
135− (c) => definitionsBytes(c.baseDefs) + definitionsBytes(c.nowDefs),
136− )
137− : this.#changedFor(newer, baseView, nowOf());
138− const out: DefinitionCollision[] = [];
139− for (const [name, where] of [...uses].sort(([a], [b]) => (a < b ? -1 : 1))) {
140− // Which definitions the uses mean: the file each use imports the name
141− // from, or its own file when it defines the name at the top level. A
142− // use with neither (a local, a parameter, a global, a name another
143− // language brings in some other way) means none: the rule only speaks
144− // when it knows which definition a use means.
139+ // Only these names can collide (a publish's news, news.ts): a draft that uses none of them has none, and the
140+ // definitions changed since its base needn't be worked out.
141+ if (names && ![...uses.keys()].some((name) => names.has(name))) return [];
142+ // Which definitions the uses mean: the file each use imports the name
143+ // from, or its own file when it defines the name at the top level. A
144+ // use with neither (a local, a parameter, a global, a name another
145+ // language brings in some other way) means none: the rule only speaks
146+ // when it knows which definition a use means.
147+ const scopes = new Map<string, ReadonlySet<string>>();
148+ for (const [name, where] of uses) {
145149 const scope = new Set<string>();
146150 for (const w of new Set(where.map((x) => x.file))) {
147151 const from = importsOf(view, w).get(name) ?? (definitionsIn(view, [w]).has(name) ? w : undefined);
148152 if (from !== undefined) scope.add(from);
149153 }
150− if (scope.size === 0) continue;
151− const inScope = (d: Definition): boolean => scope.has(d.file);
152− const before = baseDefs.get(name)?.filter(inScope);
153− if (!before?.length) continue; // not defined in what the drafter saw: nothing it relies on
154− const after = (nowDefs.get(name) ?? []).filter(inScope);
154+ if (scope.size > 0) scopes.set(name, scope);
155+ }
156+ if (scopes.size === 0) return [];
157+ const nowOf = () => (typeof nowView === "function" ? nowView() : nowView);
158+ // Only a file the newer work touched can hold a changed definition, and only one a use means can matter: just those
159+ // files are laid out, before and with the newer work (abso 738). Laying out every file the newer work touched cost
160+ // codex-prose-authorship-610's draft-state 494 files a view where its uses reach 7.
161+ const touched =
162+ changedFiles?.() ??
163+ (kept
164+ ? kept.parts.get(`touched ${kept.changed}`, () => this.#touched(newer, baseView, nowOf()), filesBytes)
165+ : this.#touchedFor(newer, baseView, nowOf()));
166+ const changed = new Map<string, Changed>();
167+ const changedIn = (file: string): Changed => {
168+ let c = changed.get(file);
169+ if (!c) {
170+ const make = (): Changed => ({
171+ baseDefs: definitionsIn(baseView, [file]),
172+ nowDefs: definitionsIn(nowOf(), [file]),
173+ });
174+ c = kept
175+ ? kept.parts.get(
176+ `changed ${kept.changed} ${file}`,
177+ make,
178+ (d) => definitionsBytes(d.baseDefs) + definitionsBytes(d.nowDefs),
179+ )
180+ : make();
181+ changed.set(file, c);
182+ }
183+ return c;
184+ };
185+ const out: DefinitionCollision[] = [];
186+ for (const [name, scope] of [...scopes].sort(([a], [b]) => (a < b ? -1 : 1))) {
187+ // In the order the newer work touched its files, as when every touched file was laid out.
188+ const files = [...touched].filter((f) => scope.has(f));
189+ const before = files.flatMap((f) => changedIn(f).baseDefs.get(name) ?? []);
190+ if (!before.length) continue; // not defined in what the drafter saw: nothing it relies on
191+ const after = files.flatMap((f) => changedIn(f).nowDefs.get(name) ?? []);
155192 if (signature(before) === signature(after)) continue;
156193 // Who changed it: newer writers of the new definition's lines, or newer deleters of the old one's.
157194 const by = new Set<AtomId>();
Lines 199–205 at 318 (were 162–167 at 277)
162199 const first = [...by].sort((p, q) => this.#graph.atom(p).seq - this.#graph.atom(q).seq)[0];
163200 if (first === undefined) continue;
164201 const origin = this.#origin(first, spaceName);
202+ const where = uses.get(name)!;
165203 const file = where[0]!.file;
166204 const indexes = where.filter((w) => w.file === file).map((w) => w.index);
167205 const lo = Math.min(...indexes);
Lines 239–257 at 318 (were 201–220 at 277)
201239 return kept.uses;
202240 }
203241
204− /** The newer work's definitions before and after, kept while it is asked about with the same views. */
205− #changedFor(newer: ReadonlySet<AtomId>, baseView: ReadView, now: ReadView): Changed {
206− let changed = this.#changedCache.get(newer);
207− if (!changed || changed.base !== baseView || changed.now !== now) {
208− changed = { base: baseView, now, defs: this.#changed(newer, baseView, now) };
209− this.#changedCache.set(newer, changed);
242+ /** The files the newer work touched, kept while it is asked about with the same views. */
243+ #touchedFor(newer: ReadonlySet<AtomId>, baseView: ReadView, now: ReadView): ReadonlySet<string> {
244+ let kept = this.#touchedCache.get(newer);
245+ if (!kept || kept.base !== baseView || kept.now !== now) {
246+ kept = { base: baseView, now, files: this.#touched(newer, baseView, now) };
247+ this.#touchedCache.set(newer, kept);
210248 }
211− return changed.defs;
249+ return kept.files;
212250 }
213251
214− /** Definitions in the files the newer work touched, before it and with it: only there can one have changed. */
215− #changed(newer: ReadonlySet<AtomId>, baseView: ReadView, now: ReadView): Changed {
216− const touched = touchedFiles(this.#graph, newer, [baseView, now]);
217− return { baseDefs: definitionsIn(baseView, touched), nowDefs: definitionsIn(now, touched) };
252+ /** The files the newer work touched, before it and with it: only there can a definition have changed. */
253+ #touched(newer: ReadonlySet<AtomId>, baseView: ReadView, now: ReadView): ReadonlySet<string> {
254+ return touchedFiles(this.#graph, newer, [baseView, now]);
218255 }
219256
220257 /** The names the draft's lines use and don't declare, less those the lines they replaced already used. */
Lines 62–90 at 318 (were 62–67 at 277)
6262 const g = host.graph;
6363 const mine = new Set(draft);
6464 const text = new MoveLineText(g);
65+ // The draft's own lines first, before laying out any file (abso 714, piece 3): a move needs a written line with
66+ // real content whose text the draft also deleted. An edit that only changes lines has none, and laying out its
67+ // files (12k lines twice for one changed line of worker/src/index.ts) cost the whole publish.
68+ const goneIds = new Set<LineId>();
69+ const goneTexts = new Set<number>();
70+ for (const id of draft)
71+ for (const line of g.deletedLines(id)) {
72+ goneIds.add(line);
73+ goneTexts.add(text.intern(line));
74+ }
75+ if (goneTexts.size === 0) return;
76+ let moved = false;
77+ for (const id of draft) {
78+ for (const line of g.eachInsertedLine(id)) {
79+ const t = text.intern(line);
80+ if (!text.plain[t] && goneTexts.has(t)) {
81+ moved = true;
82+ break;
83+ }
84+ }
85+ if (moved) break;
86+ }
87+ if (!moved) return;
6588 const after = host.agentView(agent);
6689 const before = host.beforeDraft
6790 ? host.beforeDraft(agent, draft)
Lines 104–111 at 318 (were 81–87 at 277)
81104 for (const file of [...touched].toSorted()) {
82105 let cur: Block | undefined;
83106 before.buildLines(file).forEach((l, i) => {
84− if (g.deletersOf(l.id).some((d) => mine.has(d))) {
107+ // Deleted by the draft: one of its atoms' deleted lines, with no lookup of each line's deleters.
108+ if (goneIds.has(l.id)) {
85109 if (!cur) gone.push((cur = { file, start: i, ids: [], texts: [] }));
86110 cur.ids.push(l.id);
87111 cur.texts.push(text.intern(l.id));
Lines 1–8 at 318 (were 1–8 at 277)
11// What draft collisions work out about each draft and each pair of drafts, kept between calls under a hard byte budget
2−// (abso Capacity, issue 664): the names a draft's new lines use, the definitions a draft's changes touch before and
3−// after, and the names a pair of drafts both define in a file. Keys name everything an entry depends on (shared's
4−// version, a draft's base and atoms), and a call drops every entry it didn't use, so a draft that changes, an agent that
5−// leaves and shared moving on all drop theirs at once.
2+// (abso Capacity, issue 664): the names a draft's new lines use, the files a draft's changes touch and the definitions
3+// in each before and after, and the names a pair of drafts both define in a file. Keys name everything an entry depends
4+// on (shared's version, a draft's base and atoms), and a call drops every entry it didn't use, so a draft that changes,
5+// an agent that leaves and shared moving on all drop theirs at once.
66
77import { stringBytes } from "../../src/engine/view.ts";
88import type { Definition } from "./definitions.ts";
Lines 100–109 at 318 (were 100–102 at 277)
100100 n += MAP_ENTRY_BYTES + stringBytes(name) + ARRAY_HEADER_BYTES + where.length * (REFERENCE_BYTES + OBJECT_BYTES);
101101 return n;
102102}
104+/** A set of paths (the files some work touched). */
105+export function filesBytes(files: ReadonlySet<string>): number {
106+ let n = MAP_HEADER_BYTES;
107+ for (const file of files) n += MAP_ENTRY_BYTES + stringBytes(file);
108+ return n;
109+}
Lines 29–36 at 318 (were 29–34 at 277)
2929 pairs(draft: readonly AtomId[], against: ReadonlySet<AtomId>, settled: ReadonlySet<AtomId>): Pair[];
3030 describe(pair: Pair, yoursView: ReadView, theirsView: ReadView, spaceName: string): Collision;
3131 definitionRule(): DefinitionRule;
32+ /** The files a space's versions after `from`, up to `to`, changed, when each one's are kept; else undefined. */
33+ changedSince(space: Space, from: number, to: number): ReadonlySet<string> | undefined;
3234 refuse(
3335 agent: AgentState,
3436 space: Space,
Lines 95–118 at 318 (were 93–103 at 277)
9395 ? host.viewAt(shared, sharedBaseOf(space), changes)
9496 : host.viewAt(space, space.versions.length - 1);
9597 const describeLand = (p: Pair): Collision => host.describe(p, draftView, host.sharedView(), SHARED);
98+ // Where shared changed since the draft's base, from the files each version since kept as it landed (abso 738): working
99+ // it out from the newer atoms placed every line they wrote or deleted, about 30% of a warm draft-state read.
100+ const changed = () => host.changedSince(shared, sharedBaseOf(space), host.version());
96101 const collisions = [
97102 ...host.pairs(changes, newer, union).map(describeLand),
98103 ...host
99104 .definitionRule()
100− .collisions(own, draftView, host.viewAt(shared, sharedBaseOf(space)), host.sharedView(), newer, SHARED)
105+ .collisions(
106+ own,
107+ draftView,
108+ host.viewAt(shared, sharedBaseOf(space)),
109+ host.sharedView(),
110+ newer,
111+ SHARED,
112+ undefined,
113+ undefined,
114+ changed,
115+ )
101116 .map((d) => d.collision),
102117 ];
103118 return { collisions, newer, union };
Lines 248–298 at 318 (were 248–257 at 277)
248248 viewAt(space: Space, version: number): ReadView;
249249 origin(atom: AtomId, spaceName: string): Origin;
250250 collision(agent: AgentState, pair: Pair): Collision;
251− definitionCollisions(agent: AgentState, newer: ReadonlySet<AtomId>): DefinitionCollision[];
251+ /** `names`: only these can collide; a draft that uses none of them has none (newsForOthers). */
252+ definitionCollisions(
253+ agent: AgentState,
254+ newer: ReadonlySet<AtomId>,
255+ names?: ReadonlySet<string>,
256+ ): DefinitionCollision[];
252257 queueNews(agent: AgentState, items: readonly NewsItem[], entries: Entry[]): void;
258+ /** A line for the host's logs (ProjectOptions.logLine). */
259+ logLine?(line: Record<string, string | number>): void;
260+ /**
261+ * Owed news (abso Capacity, 2026-10-15): when this answers true, a publish leaves its definition news for other
262+ * agents to be worked out after its write (definitionNewsOwed) and hands it to owe instead.
263+ */
264+ owesDefinitionNews(): boolean;
265+ owe(owed: OwedDefinitionNews): void;
266+ spaceNamed(name: string): Space | undefined;
267+ /** newerFor as it was at `version` of the agent's space. */
268+ newerAt(agent: AgentState, version: number): ReadonlySet<AtomId>;
269+ /** definitionCollisions against the agent's space at `version`, not its newest. */
270+ definitionCollisionsAt(
271+ agent: AgentState,
272+ newer: ReadonlySet<AtomId>,
273+ names: ReadonlySet<string>,
274+ version: number,
275+ ): DefinitionCollision[];
276+ /** The space's atoms at `version`: setOf as it was then (owed news). */
277+ setAt(space: Space, version: number): ReadonlySet<AtomId>;
278+ /** collision, with theirs described from the agent's space at `version`, not its newest (owed news). */
279+ collisionAt(agent: AgentState, pair: Pair, version: number): Collision;
253280}
254281
282+/**
283+ * A publish's news for other agents, not yet worked out: the version it made, and who made it. `all`: everything the
284+ * publish would have told them (same lines, definitions, moves; abso 714). Without it, as owed before 714, only the
285+ * definition news. `names`: the names its definitions changed, once worked out (owedNewsNames).
286+ */
287+export interface OwedNews {
288+ readonly version: number;
289+ readonly space: string;
290+ readonly publisher: string;
291+ readonly names?: readonly string[];
292+ readonly all?: boolean;
293+}
294+export type OwedDefinitionNews = OwedNews;
255296function lineNews(host: NewsHost, agent: AgentState, pairs: readonly Pair[]): NewsItem[] {
256297 return pairs.map((p) => ({ key: pairKey(p), text: linesText(host.collision(agent, p)) }));
257298}
Lines 312–319 at 318 (were 271–276 at 277)
271312 just: ReadonlySet<AtomId>,
272313 space: Space,
273314 version: number,
315+ /** The space's version the moved lines' files are read at: its newest, or an owed publish's own. */
316+ now = last(space),
274317): NewsItem[] {
275318 const g = host.graph;
276319 const movers = [...just].filter((id) => g.atom(id).moves);
Lines 326–332 at 318 (were 283–289 at 277)
283326 }
284327 }
285328 const was = host.viewAt(space, version - 1);
286− const now = host.viewAt(space, last(space));
329+ const after = host.viewAt(space, now);
287330 const out: NewsItem[] = [];
288331 for (const id of movers) {
289332 const moved = g
Lines 335–341 at 318 (were 292–298 at 277)
292335 .filter((k) => k.kind === "pos" && claimed.has(k.node))
293336 .map((k) => k.node);
294337 if (moved.length === 0) continue;
295− out.push(moveItem(id, host.origin(id, space.name), was.fileOf(moved[0]!), now.fileOf(moved[0]!)));
338+ out.push(moveItem(id, host.origin(id, space.name), was.fileOf(moved[0]!), after.fileOf(moved[0]!)));
296339 }
297340 return out;
298341}
Lines 363–506 at 318 (were 320–348 at 277)
320363 entries: Entry[],
321364): void {
322365 const just = new Set(space.versions[version]!.atoms);
323− let changedDefinitions: boolean | undefined;
324− const compareDefinitions = () => {
325− // Most publishes change no definition; then only the same-lines rule can bring news.
326− const touched = touchedFiles(host.graph, just, [host.viewAt(space, version - 1), host.viewAt(space, last(space))]);
327− const before = definitionsIn(host.viewAt(space, version - 1), touched);
328− const after = definitionsIn(host.viewAt(space, last(space)), touched);
329− return [...new Set([...before.keys(), ...after.keys()])].some(
330− (name) => !before.has(name) || signature(before.get(name)!) !== signature(after.get(name) ?? []),
331− );
332− };
366+ // The names whose definitions this publish changed, worked out once. Most publishes change none; then only the
367+ // same-lines rule can bring news. A definition collision this publish brings (its `by` in `just`) is one of
368+ // these, so a draft that uses none of them has none, and the rule isn't run for it (abso Capacity, prod abso
369+ // 2026-10-15): it compared definitions in every file changed since each agent's base, for every agent with a draft,
370+ // and a publish touching abso's worker/src/index.ts took 48 s of it.
371+ let changedNames: ReadonlySet<string> | undefined;
372+ // For the host's logs (abso 702): a line as the work starts, written before it, and one as it ends, so work that
373+ // outlives its request still shows. No time in them: a Durable Object's clock stands still in synchronous code.
374+ let drafts = 0;
375+ let news = 0;
376+ // Owed (abso 714, Christopher's base fix): on stored tables this news for other agents was most of a publish's one
377+ // write transaction (the same-lines pairs, the definitions, the moves, for every draft: about 10 s for a 30-line
378+ // change to abso's 12k-line index.ts), long enough to time storage out and reset the object (prod abso, 23:32Z
379+ // 2026-10-16). Owing, the publish only notes what it owes, here, once some other agent has a draft; it's worked out
380+ // after the commit, one agent at a time, against this version (newsOwed). Asked only then (news-lazy.test.ts: no
381+ // news work at all otherwise).
382+ let owing: boolean | undefined;
333383 for (const agent of [...host.agents.values()].toSorted((a, b) => (a.name < b.name ? -1 : 1))) {
334384 if (agent === publisher || agent.space !== space.name) continue;
335385 const draft = host.draft(agent);
336386 if (draft.length === 0) continue;
387+ owing ??= host.owesDefinitionNews();
388+ if (owing) {
389+ host.owe({ version, space: space.name, publisher: publisher.name, all: true });
390+ host.logLine?.({ work: "publishNews", step: "owed", space: space.name, version, publisher: publisher.name });
391+ return;
392+ }
393+ if (drafts++ === 0)
394+ host.logLine?.({ work: "publishNews", step: "start", space: space.name, version, publisher: publisher.name });
337395 const lines = pairsIn(host.graph, draft, just, unionOverlay(host.setOf(space), draft));
338− changedDefinitions ??= compareDefinitions();
339− const defs = changedDefinitions
340− ? host.definitionCollisions(agent, host.newerFor(agent)).filter((d) => just.has(d.by))
396+ changedNames ??= changedNamesAt(host, space, version);
397+ const defs =
398+ changedNames.size > 0
399+ ? host.definitionCollisions(agent, host.newerFor(agent), changedNames).filter((d) => just.has(d.by))
400+ : [];
401+ const items = [
402+ ...lineNews(host, agent, lines),
403+ ...definitionNews(defs),
404+ ...moveNews(host, draft, just, space, version),
405+ ];
406+ news += items.length;
407+ host.queueNews(agent, items, entries);
408+ }
409+ if (drafts > 0)
410+ host.logLine?.({
411+ work: "publishNews",
412+ step: "end",
413+ space: space.name,
414+ version,
415+ publisher: publisher.name,
416+ drafts,
417+ changedNames: changedNames?.size ?? 0,
418+ news,
419+ });
420+}
422+/**
423+ * The names whose definitions the publish at `version` changed, in the files it touched: before it against its own
424+ * version. Most publishes change none; then only the same-lines rule can bring news. A definition collision the publish
425+ * brings is one of these, so a draft that uses none of them has none (abso Capacity, prod abso 2026-10-15).
426+ */
427+function changedNamesAt(host: NewsHost, space: Space, version: number): ReadonlySet<string> {
428+ const just = new Set(space.versions[version]!.atoms);
429+ const touched = touchedFiles(host.graph, just, [host.viewAt(space, version - 1), host.viewAt(space, version)]);
430+ const before = definitionsIn(host.viewAt(space, version - 1), touched);
431+ const after = definitionsIn(host.viewAt(space, version), touched);
432+ return new Set(
433+ [...new Set([...before.keys(), ...after.keys()])].filter(
434+ (name) => !before.has(name) || signature(before.get(name)!) !== signature(after.get(name) ?? []),
435+ ),
436+ );
437+}
439+/** owedNews's names, worked out once for a publish (the host keeps them on its row): changedNamesAt its version. */
440+export function owedNewsNames(host: NewsHost, owed: OwedNews): string[] {
441+ const space = host.spaceNamed(owed.space);
442+ if (!space || owed.version > last(space) || !space.versions[owed.version]) return [];
443+ return [...changedNamesAt(host, space, owed.version)].sort();
444+}
446+/**
447+ * The definition news a publish owes, worked out as newsForOthers would have at that version: the same agents, the
448+ * same rule against the space at `owed.version` and the work published up to it, the same words and keys. Reads only.
449+ * An agent that has synced past the version since is left out (the version is no longer newer for it), and an item
450+ * an agent was already told (from its own edit since, or this run before) is dropped, as queueNews would.
451+ */
452+export function newsOwed(
453+ host: NewsHost,
454+ owed: OwedNews,
455+ /** Only these agents (owedAgents' names), so a host can work the news out one agent at a time (abso 714). */
456+ only?: readonly string[],
457+): { agent: string; items: NewsItem[] }[] {
458+ const space = host.spaceNamed(owed.space);
459+ if (!space || owed.version > last(space) || !space.versions[owed.version]) return [];
460+ const just = new Set(space.versions[owed.version]!.atoms);
461+ let names: ReadonlySet<string> | undefined = owed.names ? new Set(owed.names) : undefined;
462+ const out: { agent: string; items: NewsItem[] }[] = [];
463+ for (const agent of [...host.agents.values()].toSorted((a, b) => (a.name < b.name ? -1 : 1))) {
464+ if (only && !only.includes(agent.name)) continue;
465+ if (!owedTo(host, owed, space, agent)) continue;
466+ const draft = host.draft(agent);
467+ names ??= changedNamesAt(host, space, owed.version);
468+ const lines = owed.all
469+ ? pairsIn(host.graph, draft, just, unionOverlay(host.setAt(space, owed.version), draft)).map((p) => ({
470+ key: pairKey(p),
471+ text: linesText(host.collisionAt(agent, p, owed.version)),
472+ }))
341473 : [];
342− host.queueNews(
343− agent,
344− [...lineNews(host, agent, lines), ...definitionNews(defs), ...moveNews(host, draft, just, space, version)],
345− entries,
346− );
474+ const defs =
475+ names.size > 0
476+ ? host
477+ .definitionCollisionsAt(agent, host.newerAt(agent, owed.version), names, owed.version)
478+ .filter((d) => just.has(d.by))
479+ : [];
480+ const moves = owed.all ? moveNews(host, draft, just, space, owed.version, owed.version) : [];
481+ const items = [...lines, ...definitionNews(defs), ...moves].filter((item) => !agent.told.has(item.key));
482+ if (items.length > 0) out.push({ agent: agent.name, items });
347483 }
484+ return out;
348485}
486+/** newsOwed, under the name tonight's owed definition news had (abso 2341e805). */
487+export const definitionNewsOwed = newsOwed;
489+/**
490+ * The agents a publish's owed news may be for, in the order definitionNewsOwed takes them: every other agent in the
491+ * space, behind the version, with a draft. Cheap (no definition rule), so a host can list them once and then work the
492+ * news out a few at a time, each in its own read (abso 714: one read over every draft reset prod abso's object).
493+ */
494+export function owedAgents(host: NewsHost, owed: OwedDefinitionNews): string[] {
495+ const space = host.spaceNamed(owed.space);
496+ if (!space || owed.version > last(space) || !space.versions[owed.version]) return [];
497+ return [...host.agents.values()]
498+ .toSorted((a, b) => (a.name < b.name ? -1 : 1))
499+ .filter((agent) => owedTo(host, owed, space, agent))
500+ .map((agent) => agent.name);
501+}
503+function owedTo(host: NewsHost, owed: OwedDefinitionNews, space: Space, agent: AgentState): boolean {
504+ if (agent.name === owed.publisher || agent.space !== space.name || agent.base >= owed.version) return false;
505+ return host.draft(agent).length > 0;
506+}
Lines 90–110 at 318 (were 90–95 at 277)
9090 return files && [...files].sort();
9191 }
9292
93+ /**
94+ * The files the versions after `from`, up to `to`, changed, from each version's kept row (abso 738): undefined when one
95+ * has none, and the caller works them out from the atoms. Every file whose text differs between the two versions is
96+ * in it, since some version between changed it.
97+ */
98+ keptChangesSince(space: Space, from: number, to: number): ReadonlySet<string> | undefined {
99+ const out = new Set<string>();
100+ for (let v = from + 1; v <= to; v++) {
101+ const files = this.#keptFiles(space, v);
102+ if (!files) return undefined;
103+ for (const f of files) out.add(f);
104+ }
105+ return out;
106+ }
93108 /** keptPaths as a set, kept for the newest version asked: never changed once made, so a view can hold it. */
94109 keptPathSet(space: Space, version: number): ReadonlySet<string> | undefined {
95110 let fold = this.#keptPaths.get(space);
Lines 155–162 at 318 (were 155–160 at 277)
155155 refusals(agent?: string, limit?: number): unknown;
156156 /** A file as it was at a version (#27). */
157157 fileAt(path: string, version: number, draft: string | null, agent?: string): unknown;
158+ /** fileAt for exactly this spelling, without the version's list of files (version-log.ts fileExactAt). */
159+ fileExactAt?(path: string, version: number, draft: string | null): unknown;
158160 /** Every file that differs between two versions (#27). */
159161 compare(from: number, to: number, draft: string | null, agent?: string, summary?: boolean): unknown;
160162 /** Version `version` of shared without the versions in `versions` (without.ts). */
Lines 49–66 at 318 (were 49–54 at 277)
4949}
5050
5151/**
52+ * An agent with nothing of its own sees exactly its base version, so its paths are that version's kept file list
53+ * (pathindex.ts), when there is one: no layout of every known file (abso - Performance, abso 711).
54+ */
55+function viewPaths(host: SnapshotHost, agent: AgentState): string[] {
56+ const kept =
57+ agent.mine.length === 0
58+ ? host.keptPaths?.(host.spaceNamed(agent.space === SHARED ? null : agent.space), agent.base)
59+ : undefined;
60+ return kept ?? host.agentView(agent).paths();
61+}
63+/**
5264 * The paths in an agent's view now (#37): what its folder should hold.
5365 * Reading it changes nothing. Binary files are included.
5466 */
Lines 74–80 at 318 (were 62–68 at 277)
6274 return {
6375 version: agent.base,
6476 draft: agent.space === SHARED ? null : agent.space,
65− files: host.agentView(agent).paths(),
77+ files: viewPaths(host, agent),
6678 };
6779}
6880
Lines 106–112 at 318 (were 94–100 at 277)
94106 agent: agent.name,
95107 version: agent.base,
96108 draft: agent.space === SHARED ? null : agent.space,
97− files: host.agentView(agent).paths(),
109+ files: viewPaths(host, agent),
98110 };
99111}
100112
Lines 583–604 at 318 (were 583–589 at 277)
583583export type Blobs = Record<string, string | null>;
584584
585585/** What the project needs from the store of binary files' bytes. */
586+/** One news item a write gave an agent: its text and time, and its entry's place in the log. */
587+export interface NewsWritten {
588+ readonly agent: string;
589+ readonly text: string;
590+ readonly at: number | null;
591+ /** The news entry's place in the log: later news has a higher one. */
592+ readonly seq: number;
593+}
586595export interface ProjectOptions {
596+ /**
597+ * Told after each write that gave agents news, with each item as the write appended it. It runs inside the write,
598+ * which can still roll back, so a host collects the items and acts on them only once the call has returned. A host
599+ * can then wake a listener for exactly the agents that got news, without reading the log.
600+ */
601+ newsWritten?: (items: readonly NewsWritten[]) => void;
587602 /** Optional derived atom indexing within persistent graph acceptance. */
588603 indexAcceptedAtom?: (atom: Atom, files: readonly string[], storage: GraphStateStorage) => void;
589604 /** Private experimental reader route; never falls back for unsupported membership. */
Lines 639–650 at 318 (were 624–629 at 277)
624639 * recent. Without it, all text stays in memory.
625640 */
626641 entryAt?: (at: number) => Entry;
642+ /**
643+ * One line for the host's logs about long work inside an operation (abso
644+ * 702): written as the work starts and again when it ends, so work that
645+ * outlives its request still shows. Without it, nothing is written.
646+ */
647+ logLine?: (line: Record<string, string | number>) => void;
627648}
628649export interface LogEntry {
629650 version: number;
Lines 105–117 at 318 (were 105–113 at 277)
105105 addressedItem,
106106 newsAboutOwnDraft as hostedNewsAboutOwnDraft,
107107 newsForOthers as hostedNewsForOthers,
108+ newsOwed as hostedNewsOwed,
109+ owedAgents as hostedOwedAgents,
110+ owedNewsNames as hostedOwedNewsNames,
108111 markedItem,
109112 type NewsHost,
110113 type NewsItem,
114+ type OwedDefinitionNews,
111115 reviewItem,
112116 settledItem,
113117} from "./news.ts";
Lines 161–167 at 318 (were 157–162 at 277)
157161 LandAnswer,
158162 MergedLine,
159163 Modes,
164+ NewsWritten,
160165 NoteAnswer,
161166 NoteBody,
162167 NoteRecord,
Lines 222–228 at 318 (were 217–222 at 277)
217222 compare as versionCompare,
218223 compareSummary as versionCompareSummary,
219224 fileAt as versionFileAt,
225+ fileExactAt as versionFileExactAt,
220226 log as versionLog,
221227 ribbon as versionRibbon,
222228 show as versionShow,
Lines 335–351 at 318 (were 329–337 at 277)
329335 * doesn't depend on it.
330336 */
331337 checkerReady = false;
338+ /**
339+ * Owed news (abso Capacity, 2026-10-15): a publish's definition news for other agents is left for after its write
340+ * (takeOwedDefinitionNews, definitionNewsOwed, deliverOwedNews). The disk route sets it; the replay engine doesn't.
341+ */
342+ owesDefinitionNews = false;
343+ #owed: OwedDefinitionNews[] = [];
332344 readonly #now: (() => number) | undefined;
345+ readonly #newsWritten: ((items: readonly NewsWritten[]) => void) | undefined;
333346 readonly #whole: ProjectOptions["whole"];
334347 readonly #shapes: ProjectOptions["shapes"];
348+ readonly #logLine: ProjectOptions["logLine"];
335349 /** For each log position, the newest time up to it (#41): time to position in one search. */
336350 readonly #timeAt: number[] = [];
337351 /** For each version of shared, the log position of the entry that made it (#41). */
Lines 465–474 at 318 (were 451–458 at 277)
451465 }
452466 this.#hasBlob = options.hasBlob ?? (() => false);
453467 this.#now = options.now;
468+ this.#newsWritten = options.newsWritten;
454469 this.#whole = options.whole;
455470 this.#shapes = options.shapes;
471+ this.#logLine = options.logLine;
456472 // For tests (#46): AVCS_TEXT_FROM_LOG=1 runs a project on a MemoryStore with its text read back from the store.
457473 const testing =
458474 (globalThis as { process?: { env?: Record<string, string | undefined> } }).process?.env?.AVCS_TEXT_FROM_LOG ===
Lines 1348–1391 at 318 (were 1332–1337 at 277)
13321348 return hostedAnnouncePerson(this.#announceHost, ...args);
13331349 }
13341350
1351+ /** The definition news the writes since the last call owe other agents, handed over once (news.ts). */
1352+ takeOwedDefinitionNews(): OwedDefinitionNews[] {
1353+ const owed = this.#owed;
1354+ this.#owed = [];
1355+ return owed;
1356+ }
1358+ /** What a publish owes, worked out against its version (news.ts newsOwed), for `only` these agents if given. Reads only. */
1359+ newsOwed(owed: OwedDefinitionNews, only?: readonly string[]): { agent: string; items: NewsItem[] }[] {
1360+ return hostedNewsOwed(this.#newsHost, owed, only);
1361+ }
1363+ /** newsOwed, under the name owed definition news had before abso 714. */
1364+ definitionNewsOwed(owed: OwedDefinitionNews, only?: readonly string[]): { agent: string; items: NewsItem[] }[] {
1365+ return this.newsOwed(owed, only);
1366+ }
1368+ /** The names a publish's definitions changed (news.ts owedNewsNames), worked out once for its owed news. Reads only. */
1369+ owedNewsNames(owed: OwedDefinitionNews): string[] {
1370+ return hostedOwedNewsNames(this.#newsHost, owed);
1371+ }
1373+ /** The agents a publish's owed news may be for (news.ts owedAgents). Reads only. */
1374+ owedAgents(owed: OwedDefinitionNews): string[] {
1375+ return hostedOwedAgents(this.#newsHost, owed);
1376+ }
1378+ /** Tells each agent its owed items, as queueNews does: what an agent was already told adds nothing. */
1379+ deliverOwedNews(found: readonly { agent: string; items: readonly NewsItem[] }[]): number {
1380+ const entries: Entry[] = [];
1381+ for (const { agent: name, items } of found) {
1382+ const agent = this.#agents.get(name);
1383+ if (agent) this.#queueNews(agent, items, entries);
1384+ }
1385+ this.#flush(entries);
1386+ return entries.length;
1387+ }
13351389 /** A seat's earlier chat hears that another chat just used the seat (announce.ts seatNotice). */
13361390 seatNotice(...args: Tail<Parameters<typeof hostedSeatNotice>>): ReturnType<typeof hostedSeatNotice> {
13371391 return hostedSeatNotice(this.#announceHost, ...args);
Lines 1492–1508 at 318 (were 1438–1443 at 277)
14381492 return hostedOverlapNews(this.#overlapHost, ...args);
14391493 }
14401494
1495+ /** The news waiting for an agent, read only: nothing is taken, heard or written. None for an agent it hasn't got. */
1496+ peekNews(agentName: string): { text: string; at: number | null }[] {
1497+ const agent = typeof agentName === "string" ? this.#agents.get(agentName) : undefined;
1498+ return agent ? agent.news.map((text, i) => ({ text, at: agent.newsAt[i] ?? null })) : [];
1499+ }
1501+ /** Whether the project has this agent. Read only. */
1502+ hasAgent(agentName: string): boolean {
1503+ return typeof agentName === "string" && this.#agents.get(agentName) !== undefined;
1504+ }
14411506 /** Hand over the news waiting for an agent (collisions, definitions, moves, announcements), once. */
14421507 news(agentName: string): { news: string[]; items: { text: string; at: number | null }[] } {
14431508 const entries: Entry[] = [];
Lines 1782–1796 at 318 (were 1717–1722 at 277)
17171782 if (this.#pending.length === 0) return;
17181783 const out = this.#pending;
17191784 this.#store.append(out);
1785+ if (this.#newsWritten) {
1786+ const items: NewsWritten[] = [];
1787+ out.forEach((entry, i) => {
1788+ if (entry.type !== "news") return;
1789+ for (const text of entry.text)
1790+ items.push({ agent: entry.agent, text, at: entry.time ?? null, seq: this.#stored + i });
1791+ });
1792+ if (items.length > 0) this.#newsWritten(items);
1793+ }
17201794 this.#persistMutable();
17211795 // A few more agents' old told lists into their buckets at each write, until every row has moved (writer-agents.ts).
17221796 if (this.#agents instanceof WriterAgents) this.#agents.moveOldTold(OLD_TOLD_PER_WRITE);
Lines 2009–2019 at 318 (were 1935–1940 at 277)
19352009 return versionFileAt(this.#logHost, ...args);
19362010 }
19372011
2012+ /** fileAt for exactly this spelling, from the file's own lines: no list of the version's files (version-log.ts). */
2013+ fileExactAt(...args: Tail<Parameters<typeof versionFileExactAt>>): ReturnType<typeof versionFileExactAt> {
2014+ return versionFileExactAt(this.#logHost, ...args);
2015+ }
19382017 /** Every file that differs between two versions of shared (or a named draft) (version-log.ts). */
19392018 compare(...args: Tail<Parameters<typeof versionCompare>>): ReturnType<typeof versionCompare> {
19402019 return versionCompare(this.#logHost, ...args);
Lines 2184–2201 at 318 (were 2105–2112 at 277)
21052184 viewAt: (space, version) => this.#viewAt(space, version),
21062185 origin: (atom, spaceName) => this.#origin(atom, spaceName),
21072186 collision: (agent, pair) => this.#collision(agent, pair),
2108− definitionCollisions: (agent, newer) => this.#definitionCollisions(agent, newer),
2187+ definitionCollisions: (agent, newer, names) => this.#definitionCollisions(agent, newer, names),
21092188 queueNews: (agent, items, entries) => this.#queueNews(agent, items, entries),
2189+ logLine: (line) => this.#logLine?.(line),
2190+ owesDefinitionNews: () => this.owesDefinitionNews,
2191+ owe: (owed) => void this.#owed.push(owed),
2192+ spaceNamed: (name) => (name === SHARED ? this.#shared : this.#spaces.get(name)),
2193+ newerAt: (agent, version) => this.#newerFor(agent, version),
2194+ definitionCollisionsAt: (agent, newer, names, version) =>
2195+ this.#definitionCollisions(agent, newer, names, version),
2196+ setAt: (space, version) => this.#at(space, version),
2197+ collisionAt: (agent, pair, version) =>
2198+ this.#describe(pair, this.#agentView(agent), this.#viewAt(this.#spaceOf(agent), version), agent.space),
21102199 };
21112200 return this.#news;
21122201 }
Lines 2499–2507 at 318 (were 2410–2415 at 277)
24102499 pairs: (draft, against, settled) => this.#pairs(draft, against, settled),
24112500 describe: (pair, yoursView, theirsView, spaceName) => this.#describe(pair, yoursView, theirsView, spaceName),
24122501 definitionRule: () => this.#definitionRule,
2502+ // Only from a stored writer's kept rows, as keptPaths: a project in memory keeps none, and works them out.
2503+ changedSince: (space, from, to) =>
2504+ this.#writerStorage ? this.#paths.keptChangesSince(space, from, to) : undefined,
24132505 refuse: (agent, space, via, time, collisions, entries) =>
24142506 this.#refuse(agent, space, via, time, collisions, entries),
24152507 requireClosed: (tie, union) => this.#requireClosed(tie, union),
Lines 3061–3074 at 318 (were 2969–2981 at 277)
29693061 }
29703062
29713063 /** The space's atoms published after the agent's base, by others. */
2972− #newerFor(agent: AgentState): ReadonlySet<AtomId> {
3064+ /** `upTo`: the work published after the agent's base up to that version only (owed news, news.ts). */
3065+ #newerFor(agent: AgentState, upTo?: number): ReadonlySet<AtomId> {
29733066 const space = this.#spaceOf(agent);
29743067 const base = this.#at(space, agent.base);
2975− const current = this.#setOf(space);
3068+ const current = upTo === undefined ? this.#setOf(space) : this.#at(space, upTo);
29763069 const newer =
29773070 space.name === SHARED && space.membershipVersion
2978− ? new SharedAdditions(space, agent.base, base, current)
3071+ ? new SharedAdditions(space, agent.base, base, current, upTo ?? last(space))
29793072 : differenceSet(current, base);
29803073 return differenceSet(newer, new StableOverlaySet(agent.mine));
29813074 }
Lines 3204–3216 at 318 (were 3111–3117 at 277)
31113204 // The changed-definition rule (#11) -------------------------------------------
31123205
31133206 /** The rule for an agent's draft in its space. */
3114− #definitionCollisions(agent: AgentState, newer: ReadonlySet<AtomId>): DefinitionCollision[] {
3207+ #definitionCollisions(
3208+ agent: AgentState,
3209+ newer: ReadonlySet<AtomId>,
3210+ names?: ReadonlySet<string>,
3211+ /** The space's version to compare against: its newest, or an owed publish's (news.ts). */
3212+ version?: number,
3213+ ): DefinitionCollision[] {
31153214 const draft = new Set(this.#draft(agent));
31163215 if (draft.size === 0 || newer.size === 0) return [];
31173216 const space = this.#spaceOf(agent);
Lines 3218–3236 at 318 (were 3119–3131 at 277)
31193218 const base = agent.mine.some((id) => at.has(id))
31203219 ? this.#view(differenceSet(at, new StableOverlaySet(agent.mine)))
31213220 : this.#viewAt(space, agent.base);
3221+ const to = version ?? last(space);
31223222 return this.#definitionRule.collisions(
31233223 draft,
31243224 this.#agentView(agent),
31253225 base,
3126− this.#viewAt(space, last(space)),
3226+ this.#viewAt(space, to),
31273227 newer,
31283228 space.name,
3229+ undefined,
3230+ names,
3231+ // Where the space changed since the agent's base, from each version's kept files on a stored writer, as land's
3232+ // (abso 714): walking every newer atom for them was 6.5 s of a publish 770 versions behind on abso.
3233+ () => (this.#writerStorage ? this.#paths.keptChangesSince(space, agent.base, to) : undefined),
31293234 );
31303235 }
31313236}
Lines 40–50 at 318 (were 40–45 at 277)
4040 indexVersion?: (version: Published) => void;
4141 /** Version of the selected membership event, independent of later publishes. */
4242 membershipVersion?: (atom: AtomId, version: number) => number | undefined;
43+ /**
44+ * membershipVersion reading the membership pages first, each page once (abso - Performance, 714): for a walk over
45+ * many atoms, such as SharedAdditions. Most atoms have one event, and the page says its version.
46+ */
47+ membershipVersions?: () => (atom: AtomId, version: number) => number | undefined;
4348 readonly name: string;
4449 readonly versions: Published[];
4550 /** Every atom published into this space (for shared, everything in it). */
Lines 63–75 at 318 (were 58–63 at 277)
5863 name,
5964 indexVersion: (version) => indexMembership(storage, prefix, version),
6065 membershipVersion: (atom, version) => membershipEvent(storage, prefix, atom, version)?.version,
66+ membershipVersions: () => {
67+ const pages = new PageReader(storage, prefix);
68+ return (atom, version) => {
69+ const known = pages.versionAt(atom, version);
70+ return known === null ? membershipEvent(storage, prefix, atom, version)?.version : known;
71+ };
72+ },
6173 versions: storedArray(storage, `${prefix}:versions`),
6274 own: new StoredSet(storage, `${prefix}:own`),
6375 publishedIn: new StoredMap(storage, `${prefix}:published`),
Lines 136–154 at 318 (were 124–129 at 277)
124136 }
125137 /** Whether atom is present at version, or undefined when its events must be read. */
126138 presentAt(atom: AtomId, version: number): boolean | undefined {
139+ const code = this.#code(atom);
140+ if (code === undefined || code === MIXED) return undefined;
141+ if (code === NONE) return false;
142+ return version >= code;
143+ }
144+ /** membershipVersion from the page: the version of its only event, or undefined; null when its events must be read. */
145+ versionAt(atom: AtomId, version: number): number | undefined | null {
146+ const code = this.#code(atom);
147+ if (code === undefined || code === MIXED) return null;
148+ if (code === NONE) return undefined;
149+ return version >= code ? code : undefined;
150+ }
151+ #code(atom: AtomId): number | undefined {
127152 this.#kept ??= this.#storage.read(`${this.#prefix}:pages:meta`, "kept") === 1;
128153 if (!this.#kept) return undefined;
129154 const seq = seqOf(atom);
Lines 160–166 at 318 (were 135–144 at 277)
135160 if (this.#pages.size >= 64) this.#pages.delete(this.#pages.keys().next().value!);
136161 this.#pages.set(index, page);
137162 }
138− const code = page[seq % PAGE] ?? NONE;
139− if (code === NONE) return false;
140− if (code === MIXED) return undefined;
141− return version >= code;
163+ return page[seq % PAGE] ?? NONE;
142164 }
143165}
144166
Lines 383–399 at 318 (were 361–370 at 277)
361383 readonly baseVersion: number;
362384 readonly base: ReadonlySet<AtomId>;
363385 readonly current: ReadonlySet<AtomId>;
364− constructor(space: Space, baseVersion: number, base: ReadonlySet<AtomId>, current: ReadonlySet<AtomId>) {
386+ /** `endVersion`: the version `current` is (the newest by default; an earlier one for owed news, news.ts). */
387+ constructor(
388+ space: Space,
389+ baseVersion: number,
390+ base: ReadonlySet<AtomId>,
391+ current: ReadonlySet<AtomId>,
392+ endVersion = last(space),
393+ ) {
365394 super();
366395 if (space.name !== SHARED || !space.membershipVersion) throw Error("shared additions require indexed shared space");
367− this.endVersion = last(space);
396+ this.endVersion = endVersion;
368397 this.space = space;
369398 this.baseVersion = baseVersion;
370399 this.base = base;
Lines 403–412 at 318 (were 374–382 at 277)
374403 return this.current.has(id) && !this.base.has(id);
375404 }
376405 *values(): SetIterator<AtomId> {
406+ const versionOf = this.space.membershipVersions?.() ?? this.space.membershipVersion!;
377407 for (let version = this.baseVersion + 1; version <= this.endVersion; version++) {
378408 for (const id of this.space.versions[version]!.atoms) {
379− if (this.space.membershipVersion!(id, this.endVersion) === version && this.has(id)) yield id;
409+ if (versionOf(id, this.endVersion) === version && this.has(id)) yield id;
380410 }
381411 }
382412 }
Lines 16–25 at 318 (were 16–22 at 277)
1616 */
1717export function clashIn(view: ReadView, touched: Iterable<string>, now: ReadView): string | undefined {
1818 const byKey = new Map<string, string[]>();
19− for (const p of view.knownPaths()) {
19+ // Every path the graph has ever had, sorted, not the view's known paths (abso Capacity, prod abso 2026-10-15): those
20+ // read every atom's file list, over half of a publish on abso. Each use below keeps only paths the view has a file
21+ // at, and a path the view never had has none, so the answers are the same.
22+ for (const p of [...view.graph.knownFiles()].sort()) {
2023 const k = pathKey(p);
2124 const list = byKey.get(k);
2225 if (list) list.push(p);
Lines 73–81 at 318 (were 70–76 at 277)
7073export function spellingOf(view: ReadView, path: string): string {
7174 if (view.hasFile(path)) return path;
7275 const key = pathKey(path);
73− // Known paths first, by key, then only those laid out (#46).
74− const twins = view.knownPaths().filter((p) => pathKey(p) === key && view.hasFile(p));
76+ // Every path the graph has ever had, by key, then only those the view has a file at (#46). Not the view's known paths
77+ // (abso Capacity, 714): those read every atom's membership and file list, 36,360 statements of a record on abso, as
78+ // clashIn found. A path the view never had has no file in it, so the answers are the same.
79+ const twins = [...view.graph.knownFiles()].filter((p) => pathKey(p) === key && view.hasFile(p));
7580 return twins.length === 1 ? twins[0]! : path;
7681}
new file, 55 lines
1+// Moves before laying out files (abso 714, piece 3): expressMoves looks at the draft's own written and deleted lines
2+// first, and lays out no file when none of its written lines with real content has a deleted line's text. moves.test.ts
3+// covers the moves themselves.
4+
5+import assert from "node:assert/strict";
6+import { test } from "node:test";
7+import type { Graph } from "../../../src/engine/index.ts";
8+import { type ExpressMovesHost, expressMoves } from "../express-moves.ts";
9+import type { AgentState } from "../project-types.ts";
11+/** A draft of two atoms: "del" deletes one line, "add" writes the others. Any view laid out throws. */
12+function host(deleted: string, written: string[]): ExpressMovesHost {
13+ const texts = [deleted, ...written];
14+ const graph = {
15+ deletedLines: (id: string) => (id === "del" ? ["line-0"] : []),
16+ *eachInsertedLine(id: string) {
17+ if (id === "add") for (let k = 1; k < texts.length; k++) yield `line-${k}`;
18+ },
19+ lineN: (line: string) => Number(line.slice("line-".length)),
20+ *textChunks(n: number) {
21+ yield texts[n]!;
22+ },
23+ textOf: (n: number) => texts[n]!,
24+ } as unknown as Graph;
25+ const laidOut = (): never => {
26+ throw new Error("laid out");
27+ };
28+ return {
29+ graph,
30+ draft: () => ["del", "add"],
31+ agentView: laidOut,
32+ beforeDraft: laidOut,
33+ view: laidOut,
34+ apply: laidOut,
35+ addDraft: laidOut,
36+ recordFile: laidOut,
37+ };
38+}
40+const agent = { name: "ann" } as AgentState;
42+test("an edit that only changes lines lays out no file", () => {
43+ expressMoves(host(" return pi * r * r;", [" return Math.PI * r * r;"]), agent, 1, []);
44+});
46+test("a deleted text written again with only brackets or blanks in common lays out no file", () => {
47+ expressMoves(host("}", [" const tree = parse(p);", "}", ""]), agent, 1, []);
48+});
50+test("a written line with real content that the draft also deleted goes on to the files", () => {
51+ assert.throws(
52+ () => expressMoves(host(" return pi * r * r;", ["", " return pi * r * r;"]), agent, 1, []),
53+ /laid out/,
54+ );
55+});
new file, 49 lines
1+// fileExactAt (version-log.ts, abso Capacity, 2026-10-17): the same answer as fileAt for exactly that spelling, at
2+// every version, read from the file's own lines without the version's list of files. abso's worker/test/
3+// project-files.test.ts checks it on the disk engine, where the list is what costs.
4+
5+import assert from "node:assert/strict";
6+import { test } from "node:test";
7+import { MemoryStore, Project } from "../project.ts";
8+
9+/** Files added, edited, emptied, made binary and taken out, beside others, over six versions. */
10+function history(): Project {
11+ const p = new Project(new MemoryStore(), { hasBlob: () => true });
12+ p.init({ "README.md": "hi\n", "abso.json": '{ "check": "true" }\n', "src/a.ts": "a\n" }, 0);
13+ p.record("ann", { "abso.yml": "pipelines:\n ci:\n on: [push]\n", "docs/abso.yml": "not this one\n" }, 1);
14+ p.publish("ann", "a pipeline", 2);
15+ p.record("ann", { "abso.json": '{ "check": "false" }\n', "empty.txt": "" }, 3, {}, { "abso.yaml": "b".repeat(64) });
16+ p.publish("ann", "a binary, and an empty file", 4);
17+ p.record("ann", { "abso.yml": null, "avcs.json": "{}\n", "src/a.ts": "" }, 5);
18+ p.publish("ann", "the pipeline gone, a file emptied", 6);
19+ return p;
20+}
22+const PATHS = [
23+ "abso.yml",
24+ "abso.yaml",
25+ "abso.json",
26+ "avcs.json",
27+ "docs/abso.yml",
28+ "empty.txt",
29+ "src/a.ts",
30+ "README.md",
31+ "never.txt",
32+];
34+test("fileExactAt answers what fileAt answers for the same spelling, at every version", () => {
35+ const p = history();
36+ const last = p.version;
37+ assert.ok(last >= 3);
38+ for (let v = 0; v <= last; v++)
39+ for (const path of PATHS) assert.deepEqual(p.fileExactAt(path, v), p.fileAt(path, v), `${path} at ${v}`);
40+});
42+test("a name nothing ever wrote is null, and another spelling is that spelling, not the stored one", () => {
43+ const p = history();
44+ const last = p.version;
45+ assert.deepEqual(p.fileExactAt("never.txt", last), { path: "never.txt", version: last, text: null });
46+ // fileAt reads the stored spelling for any spelling (#41); fileExactAt reads only the one asked.
47+ assert.equal((p.fileAt("ABSO.json", last) as { text: string | null }).text, '{ "check": "false" }\n');
48+ assert.deepEqual(p.fileExactAt("ABSO.json", last), { path: "ABSO.json", version: last, text: null });
49+});
Lines 105–124 at 318 (were 105–107 at 277)
105105 ] as const)
106106 assert.deepEqual(project.pathsAt(version).files, oracle.draftOf(agent)!.view.paths(), `paths at ${version}`);
107107});
109+test("an agent's files on a writer, from its base version's kept list when it has nothing of its own, as the in-memory project says", () => {
110+ // abso - Performance (abso 711): a status for an agent behind shared listed its files by laying out every known file.
111+ const oracle = new Project(new MemoryStore());
112+ const project = writer();
113+ history(oracle);
114+ history(project);
115+ // v0 and v1 are behind shared with nothing of their own, v2 is at shared, and bob, cy, dee and eve have drafts.
116+ for (const agent of ["v0", "v1", "v2", "bob", "cy", "dee", "eve"]) {
117+ assert.deepEqual(project.agentPaths(agent), oracle.agentPaths(agent), agent);
118+ assert.deepEqual(project.pathsOf(agent), oracle.pathsOf(agent), `${agent} for a reader`);
119+ }
120+ assert.deepEqual(project.agentPaths("v0").files, project.pathsAt(0).files);
121+ assert.equal(project.agentPaths("v0").files.includes("src/gone.ts"), true);
122+ assert.equal(project.agentPaths("v1").files.includes("src/gone.ts"), false);
123+ assert.equal(project.agentPaths("eve").files.includes("src/draft-new.ts"), true);
124+});
new file, 60 lines
1+// abso 702: a publish's news for other agents writes a line as it starts and
2+// one as it ends, through ProjectOptions.logLine, so work that outlives its
3+// request still shows in the host's logs.
4+
5+import assert from "node:assert/strict";
6+import { test } from "node:test";
7+import { MemoryStore, Project } from "../project.ts";
8+
9+const START = {
10+ "src/parse.ts": "export function parsePattern(text: string): string {\n return text;\n}\n",
11+ "src/match.ts": 'import { parsePattern } from "./parse.ts";\n\nexport function run(p: string) {\n return p;\n}\n',
12+};
14+function setup(lines: Record<string, string | number>[]) {
15+ const project = new Project(new MemoryStore(), { logLine: (line) => lines.push(line) });
16+ project.init(START, 0);
17+ project.sync("lib");
18+ project.sync("user");
19+ return project;
20+}
22+test("a publish with another agent drafting writes a start line and an end line", () => {
23+ const lines: Record<string, string | number>[] = [];
24+ const project = setup(lines);
25+ project.edit("user", { file: "src/match.ts", old: " return p;\n", new: " return parsePattern(p);\n" }, 1);
26+ project.edit(
27+ "lib",
28+ { file: "src/parse.ts", old: "parsePattern(text: string)", new: "parsePattern(text: string, flags = '')" },
29+ 2,
30+ );
31+ assert.equal(project.publish("lib", "parsePattern takes flags", 3).ok, true);
33+ const news = lines.filter((l) => l.work === "publishNews");
34+ assert.deepEqual(
35+ news.map((l) => l.step),
36+ ["start", "end"],
37+ );
38+ assert.equal(news[0]!.publisher, "lib");
39+ assert.equal(news[1]!.drafts, 1);
40+ assert.equal(news[1]!.changedNames, 1);
41+ assert.equal(news[1]!.news, 1);
42+});
44+test("a publish with nobody else drafting writes nothing", () => {
45+ const lines: Record<string, string | number>[] = [];
46+ const project = setup(lines);
47+ project.edit("lib", { file: "src/parse.ts", old: " return text;\n", new: " return text.trim();\n" }, 1);
48+ assert.equal(project.publish("lib", "trim", 2).ok, true);
49+ assert.deepEqual(lines, []);
50+});
52+test("without a logLine option, a publish still works", () => {
53+ const project = new Project(new MemoryStore());
54+ project.init(START, 0);
55+ project.sync("lib");
56+ project.sync("user");
57+ project.edit("user", { file: "src/match.ts", old: " return p;\n", new: " return parsePattern(p);\n" }, 1);
58+ project.edit("lib", { file: "src/parse.ts", old: " return text;\n", new: " return text.trim();\n" }, 2);
59+ assert.equal(project.publish("lib", "trim", 3).ok, true);
60+});
new file, 56 lines
1+// A host learns each write's news as the write appends it (newsWritten), and can read an agent's waiting news without
2+// taking it (peekNews), so a listener can be woken for exactly the agents that got news and caught up on connect.
3+
4+import assert from "node:assert/strict";
5+import { test } from "node:test";
6+import { MemoryStore, type NewsWritten, Project } from "../project.ts";
7+
8+function setup() {
9+ const store = new MemoryStore();
10+ const written: NewsWritten[][] = [];
11+ const project = new Project(store, { newsWritten: (items) => written.push([...items]) });
12+ project.init({ "a.txt": "a\n" }, 0);
13+ for (const a of ["builder1", "builder2", "builder3"]) project.sync(a);
14+ written.length = 0;
15+ return { project, store, written };
16+}
18+test("a write's news is told once, per item, with its agent, text and place in the log", () => {
19+ const { project, store, written } = setup();
20+ project.announce("builder1", "Ship it", ["builder2", "builder3"], 1);
21+ assert.equal(written.length, 1, "one call for the write");
22+ const items = written[0]!;
23+ assert.deepEqual(
24+ items.map((i) => i.agent),
25+ ["builder2", "builder3"],
26+ );
27+ for (const item of items) {
28+ assert.match(item.text, /Announcement from builder1.*Ship it/);
29+ assert.equal(store.entries[item.seq]?.type, "news", "seq is the entry's place in the log");
30+ }
31+ assert.ok(items[1]!.seq > items[0]!.seq);
32+});
34+test("writes with no news, and taking news (heard), tell nothing", () => {
35+ const { project, written } = setup();
36+ project.announce("builder1", "Ship it", ["builder2"], 1);
37+ written.length = 0;
38+ project.news("builder2");
39+ project.sync("builder3");
40+ assert.deepEqual(written, []);
41+});
43+test("peekNews reads waiting news and takes nothing; hasAgent reads only", () => {
44+ const { project, store } = setup();
45+ project.announce("builder1", "Ship it", ["builder2"], 1);
46+ const length = store.entries.length;
47+ const peeked = project.peekNews("builder2");
48+ assert.equal(peeked.length, 1);
49+ assert.match(peeked[0]!.text, /Ship it/);
50+ assert.deepEqual(project.peekNews("builder2"), peeked, "still there");
51+ assert.deepEqual(project.peekNews("nobody"), [], "no agent: none, and none made");
52+ assert.equal(project.hasAgent("builder2"), true);
53+ assert.equal(project.hasAgent("nobody"), false);
54+ assert.equal(store.entries.length, length, "nothing written");
55+ assert.equal(project.news("builder2").news.length, 1, "the take still finds it");
56+});
new file, 190 lines
1+// Owed news (abso Capacity, 2026-10-15): with owesDefinitionNews set (abso's disk route sets it), a publish leaves its
2+// definition news for other agents for after its write. The same news, against the publish's version; told once; and
3+// the publisher's own answer as before. abso's worker/test/owed-news.test.ts covers the disk route's marker and alarm.
4+
5+import assert from "node:assert/strict";
6+import { test } from "node:test";
7+import { MemoryStore, Project } from "../project.ts";
8+
9+// abso-core's changed-definition.test.ts scenario: parse.ts defines parsePattern, match.ts imports it.
10+const START = {
11+ "src/parse.ts": [
12+ "export function parsePattern(text: string): Node {",
13+ ' return { kind: "lit", text };',
14+ "}",
15+ "",
16+ "export interface Node {",
17+ " kind: string;",
18+ " text: string;",
19+ "}",
20+ ].join("\n"),
21+ "src/match.ts": [
22+ 'import { parsePattern } from "./parse.ts";',
23+ "",
24+ "export function run(p: string) {",
25+ " return p;",
26+ "}",
27+ ].join("\n"),
28+ "README.md": "Uses parsePattern.\n",
29+};
31+/** bob's draft calls parsePattern; ann's draft changes its signature; cat's touches something else. Nothing published. */
32+function drafts(project: Project): void {
33+ project.init(START, 0);
34+ project.sync("bob");
35+ project.sync("ann");
36+ project.sync("cat");
37+ project.edit(
38+ "bob",
39+ { file: "src/match.ts", old: " return p;\n", new: " const tree = parsePattern(p);\n return tree;\n" },
40+ 1,
41+ );
42+ project.edit(
43+ "ann",
44+ {
45+ file: "src/parse.ts",
46+ old: "parsePattern(text: string): Node",
47+ new: "parsePattern(text: string, flags: string): Node",
48+ },
49+ 2,
50+ );
51+ project.edit("cat", { file: "README.md", old: "Uses parsePattern.", new: "Uses parsePattern, twice." }, 3);
52+}
54+const definitionNews = (news: readonly string[]) => news.filter((n) => /definition of parsePattern/.test(n)).sort();
56+test("the news owed is the news a publish would have told, and the publisher's own answer is the same", () => {
57+ const told = new Project(new MemoryStore());
58+ drafts(told);
59+ const toldAnswer = told.publish("ann", "parsePattern takes flags", 4);
60+ const expected = definitionNews(told.news("bob").news);
61+ assert.equal(expected.length, 1, "the scenario has a definition collision");
63+ const owing = new Project(new MemoryStore());
64+ owing.owesDefinitionNews = true;
65+ drafts(owing);
66+ assert.deepEqual(owing.publish("ann", "parsePattern takes flags", 4), toldAnswer, "the publisher's answer");
67+ const owed = owing.takeOwedDefinitionNews();
68+ assert.deepEqual(owed, [{ version: owing.version, space: owed[0]!.space, publisher: "ann", all: true }]);
69+ assert.deepEqual(owing.takeOwedDefinitionNews(), [], "handed over once");
70+ // Not told yet: bob's news holds no definition news until it's delivered.
71+ assert.deepEqual(definitionNews(owing.news("bob").news), []);
72+ const found = owing.definitionNewsOwed(owed[0]!);
73+ assert.deepEqual(
74+ found.map((f) => f.agent),
75+ ["bob"],
76+ );
77+ assert.ok(owing.deliverOwedNews(found) > 0);
78+ assert.deepEqual(definitionNews(owing.news("bob").news), expected);
79+ // Told twice adds nothing, and a run of the read after delivery finds nothing left.
80+ assert.equal(owing.deliverOwedNews(found), 0);
81+ assert.deepEqual(owing.definitionNewsOwed(owed[0]!), []);
82+});
84+test("worked out against the publish's version, though more was published before the news went out", () => {
85+ const told = new Project(new MemoryStore());
86+ drafts(told);
87+ told.publish("ann", "parsePattern takes flags", 4);
88+ const expected = definitionNews(told.news("bob").news);
90+ const owing = new Project(new MemoryStore());
91+ owing.owesDefinitionNews = true;
92+ drafts(owing);
93+ owing.publish("ann", "parsePattern takes flags", 4);
94+ const [first] = owing.takeOwedDefinitionNews();
95+ // Then parsePattern is removed, before the first publish's news is out: against the newest version the news
96+ // would say "removes"; against the first publish's, it says "changes", as told at publish time.
97+ owing.sync("ann");
98+ owing.edit(
99+ "ann",
100+ {
101+ file: "src/parse.ts",
102+ old: 'export function parsePattern(text: string, flags: string): Node {\n return { kind: "lit", text };\n}\n',
103+ new: "",
104+ },
105+ 5,
106+ );
107+ owing.publish("ann", "parsePattern goes", 6);
108+ assert.ok(owing.deliverOwedNews(owing.definitionNewsOwed(first!)) > 0);
109+ assert.deepEqual(definitionNews(owing.news("bob").news), expected, "the first publish's news, as it was");
110+});
112+test("an agent that synced past the version since isn't told it", () => {
113+ const owing = new Project(new MemoryStore());
114+ owing.owesDefinitionNews = true;
115+ drafts(owing);
116+ owing.publish("ann", "parsePattern takes flags", 4);
117+ const [owed] = owing.takeOwedDefinitionNews();
118+ owing.sync("bob");
119+ assert.deepEqual(owing.definitionNewsOwed(owed!), []);
120+});
122+test("the replay engine tells it at publish time, as before", () => {
123+ const told = new Project(new MemoryStore());
124+ drafts(told);
125+ told.publish("ann", "parsePattern takes flags", 4);
126+ assert.deepEqual(told.takeOwedDefinitionNews(), []);
127+ assert.equal(definitionNews(told.news("bob").news).length, 1);
128+});
130+test("owedAgents lists who may be owed, and the news one agent at a time adds up to the whole (abso 714)", () => {
131+ const owing = new Project(new MemoryStore());
132+ owing.owesDefinitionNews = true;
133+ drafts(owing);
134+ owing.publish("ann", "parsePattern takes flags", 4);
135+ const [owed] = owing.takeOwedDefinitionNews();
136+ assert.deepEqual(owing.owedAgents(owed!), ["bob", "cat"], "every other agent behind it with a draft");
137+ const whole = owing.definitionNewsOwed(owed!);
138+ assert.equal(whole.length, 1);
139+ assert.deepEqual(
140+ owing.owedAgents(owed!).flatMap((agent) => owing.definitionNewsOwed(owed!, [agent])),
141+ whole,
142+ );
143+ owing.sync("bob");
144+ assert.deepEqual(owing.owedAgents(owed!), ["cat"], "synced past it");
145+});
147+test("everything a publish tells other agents is owed and told after it, the same news (abso 714)", () => {
148+ // bob's draft calls parsePattern (definition news), dee's changes the line ann's publish changes (same-lines news),
149+ // and cat's touches nothing of it (no news).
150+ const scenario = (project: Project) => {
151+ drafts(project);
152+ project.sync("dee");
153+ project.edit(
154+ "dee",
155+ { file: "src/parse.ts", old: "parsePattern(text: string): Node", new: "parsePattern(input: string): Node" },
156+ 5,
157+ );
158+ };
159+ const told = new Project(new MemoryStore());
160+ scenario(told);
161+ const toldAnswer = told.publish("ann", "parsePattern takes flags", 6);
162+ const expected = Object.fromEntries(["bob", "cat", "dee"].map((a) => [a, told.news(a).news.toSorted()]));
163+ assert.ok(expected.bob!.length > 0 && expected.dee!.length > 0, "the scenario has both kinds of news");
165+ const owing = new Project(new MemoryStore());
166+ owing.owesDefinitionNews = true;
167+ scenario(owing);
168+ assert.deepEqual(owing.publish("ann", "parsePattern takes flags", 6), toldAnswer, "the publisher's answer");
169+ const [owed] = owing.takeOwedDefinitionNews();
170+ assert.equal(owed!.all, true);
171+ for (const a of ["bob", "cat", "dee"])
172+ assert.deepEqual(owing.news(a).news, [], `${a} is told nothing in the publish`);
173+ const names = owing.owedNewsNames(owed!);
174+ assert.deepEqual(names, ["parsePattern"]);
175+ // One agent at a time, as the host works it out.
176+ for (const agent of owing.owedAgents(owed!)) owing.deliverOwedNews(owing.newsOwed({ ...owed!, names }, [agent]));
177+ for (const a of ["bob", "cat", "dee"]) assert.deepEqual(owing.news(a).news.toSorted(), expected[a], a);
178+ // Twice tells nothing more.
179+ assert.deepEqual(owing.newsOwed({ ...owed!, names }), []);
180+});
182+test("a publish that no other draft can collide with owes nothing", () => {
183+ const owing = new Project(new MemoryStore());
184+ owing.owesDefinitionNews = true;
185+ owing.init({ "a.txt": "one\n" }, 0);
186+ owing.sync("ann");
187+ owing.edit("ann", { file: "a.txt", old: "one", new: "two" }, 1);
188+ owing.publish("ann", "alone", 2);
189+ assert.deepEqual(owing.takeOwedDefinitionNews(), []);
190+});
Lines 36–87 at 318 (were 36–38 at 277)
3636 storage.db.close();
3737 }
3838});
40+test("shared additions read each atom's version from the membership pages, and answer as its events do (abso - Performance, 714)", (t) => {
41+ const storage = new SqlState();
42+ try {
43+ const membership = new Membership(storage),
44+ space = membership.shared;
45+ const ids = (from: number, to: number) => Array.from({ length: to - from }, (_, i) => `a${from + i}`);
46+ const add = (atoms: string[], dropped: string[] = []) =>
47+ addVersion(space, { version: space.versions.length, agent: "test", message: "version", time: 0, atoms, dropped });
48+ // Three pages of atoms; a5 and a400 dropped and a5 back, a601 added and dropped: their events are read.
49+ add(ids(0, 300));
50+ add(ids(300, 600));
51+ add([], ["a5", "a400"]);
52+ add(["a5", "a600"]);
53+ add(["a601"]);
54+ add([], ["a601"]);
55+ const last = space.versions.length - 1;
56+ const { membershipVersions: _pages, ...eventsOnly } = space;
57+ const read = storage.read.bind(storage);
58+ let eventReads = 0;
59+ t.mock.method(storage, "read", (collection: string, key: string) => {
60+ if (collection.startsWith('membership:"":events:')) eventReads++;
61+ return read(collection, key);
62+ });
63+ const walk = (s: typeof space) => {
64+ eventReads = 0;
65+ const out: string[][] = [];
66+ for (let from = 0; from < last; from++)
67+ for (let to = from + 1; to <= last; to++)
68+ out.push([...new SharedAdditions(s, from, membership.at(s, from), membership.at(s, to), to)]);
69+ return { out, eventReads };
70+ };
71+ const paged = walk(space);
72+ const events = walk(eventsOnly);
73+ assert.deepEqual(paged.out, events.out);
74+ assert.ok(
75+ paged.eventReads < events.eventReads / 10,
76+ `${paged.eventReads} event reads against ${events.eventReads}`,
77+ );
78+ assert.deepEqual([...new SharedAdditions(space, 1, membership.at(space, 1), membership.at(space, 3), 3)], ["a600"]);
79+ assert.deepEqual(
80+ [...new SharedAdditions(space, 2, membership.at(space, 2), membership.at(space, 3), 3)],
81+ ["a5", "a600"],
82+ );
83+ assert.deepEqual([...new SharedAdditions(space, 3, membership.at(space, 3), membership.at(space, 5), 5)], []);
84+ } finally {
85+ storage.db.close();
86+ }
87+});
Lines 244–278 at 318 (were 244–249 at 277)
244244 };
245245}
246246
247+/**
248+ * fileAt for exactly this spelling, from the file's own lines (abso Capacity, 2026-10-17): no spelling lookup and no
249+ * list of the version's files. fileAt's hasFile answers from the version's whole path list, folded from version 0
250+ * when nothing's kept, and a spelling it doesn't find reads every known path. A name nothing ever wrote is one read.
251+ * The pipeline's project files (abso.yml and the like) are read this way on every tick.
252+ */
253+export function fileExactAt(
254+ host: LogHost,
255+ path: string,
256+ version: number,
257+ options: { draft?: string | null; agent?: string } = {},
258+): { path: string; version: number; text: string | null; blob?: string } {
259+ host.needInit();
260+ checkReadPath(path);
261+ const space = host.spaceFor(options);
262+ host.checkVersion(space, version);
263+ if (!host.graph.hasAtomsIn(path)) return { path, version, text: null };
264+ const view = host.viewAt(space, version);
265+ const attrs = view.attrs(path);
266+ // hasFile's own test, without its path list: kept while empty, a link, a binary, or a visible line.
267+ const exists = attrs.exists || attrs.link !== null || attrs.blob !== null || view.lines(path).length > 0;
268+ return {
269+ path,
270+ version,
271+ text: exists ? view.text(path) : null,
272+ ...(attrs.blob !== null ? { blob: attrs.blob } : {}),
273+ };
274+}
247276/** The files that may differ between two versions, and both views: compare's and compareSummary's ground. */
248277function compared(
249278 host: LogHost,
MCP
compare on this site's /mcp
CLI
abso diff 277 318 worker --json
JSON
/christopher/abso-core/compare/277..318?file=worker&format=json