Versions 299 to 318
Lines 68–74 at 318 (were 68–74 at 299)
71− for (const id of orderedClaimants(g, streams)) if (against.has(id)) theirs.push(id);
Lines 136–142 at 318 (were 136–142 at 299)
136136
139−function* orderedClaimants(g: Graph, streams: IterableIterator<AtomId>[]): IterableIterator<AtomId> {
Lines 152–162 at 318 (were 152–160 at 299)
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
157− if (!next.done) push({ id: next.value, seq: g.atom(next.value).seq, stream });
Lines 192–199 at 318 (were 190–197 at 299)
193− const x = g.atom(a.value).seq;
194− const y = g.atom(b.value).seq;
Lines 7–13 at 318 (were 7–13 at 299)
77import { type AtomId, type Graph, joinLines, type LineId, type ReadView } from "../../src/engine/index.ts";
10−import { definitionsBytes, type KeptParts, usesBytes } from "./kept-parts.ts";
Lines 37–43 at 318 (were 37–43 at 299)
3939
40−/** Definitions in the files newer work touched, before it and with it. */
Lines 52–62 at 318 (were 52–59 at 299)
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 }>();
5760
Lines 125–135 at 318 (were 122–127 at 299)
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.
Lines 139–194 at 318 (were 131–161 at 299)
131139 // Only these names can collide (a publish's news, news.ts): a draft that uses none of them has none, and the
134− const nowOf = () => (typeof nowView === "function" ? nowView() : nowView);
135− const { baseDefs, nowDefs } = kept
136− ? kept.parts.get(
137− `changed ${kept.changed}`,
138− () => this.#changed(newer, baseView, nowOf()),
139− (c) => definitionsBytes(c.baseDefs) + definitionsBytes(c.nowDefs),
140− )
141− : this.#changedFor(newer, baseView, nowOf());
142− const out: DefinitionCollision[] = [];
143− for (const [name, where] of [...uses].sort(([a], [b]) => (a < b ? -1 : 1))) {
144− // Which definitions the uses mean: the file each use imports the name
145− // from, or its own file when it defines the name at the top level. A
146− // use with neither (a local, a parameter, a global, a name another
147− // language brings in some other way) means none: the rule only speaks
148− // when it knows which definition a use means.
151151 const from = importsOf(view, w).get(name) ?? (definitionsIn(view, [w]).has(name) ? w : undefined);
154− if (scope.size === 0) continue;
155− const inScope = (d: Definition): boolean => scope.has(d.file);
156− const before = baseDefs.get(name)?.filter(inScope);
157− if (!before?.length) continue; // not defined in what the drafter saw: nothing it relies on
158− const after = (nowDefs.get(name) ?? []).filter(inScope);
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
164+ ? kept.parts.get(`touched ${kept.changed}`, () => this.#touched(newer, baseView, nowOf()), filesBytes)
160193 // Who changed it: newer writers of the new definition's lines, or newer deleters of the old one's.
Lines 199–205 at 318 (were 166–171 at 299)
Lines 239–257 at 318 (were 205–224 at 299)
207241
208− /** The newer work's definitions before and after, kept while it is asked about with the same views. */
209− #changedFor(newer: ReadonlySet<AtomId>, baseView: ReadView, now: ReadView): Changed {
210− let changed = this.#changedCache.get(newer);
211− if (!changed || changed.base !== baseView || changed.now !== now) {
212− changed = { base: baseView, now, defs: this.#changed(newer, baseView, now) };
213− this.#changedCache.set(newer, changed);
243+ #touchedFor(newer: ReadonlySet<AtomId>, baseView: ReadView, now: ReadView): ReadonlySet<string> {
215− return changed.defs;
217251
218− /** Definitions in the files the newer work touched, before it and with it: only there can one have changed. */
219− #changed(newer: ReadonlySet<AtomId>, baseView: ReadView, now: ReadView): Changed {
220− const touched = touchedFiles(this.#graph, newer, [baseView, now]);
221− 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. */
223256
224257 /** 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 299)
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
Lines 104–111 at 318 (were 81–87 at 299)
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.
Lines 1–8 at 318 (were 1–8 at 299)
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,
66
Lines 100–109 at 318 (were 100–102 at 299)
100100 n += MAP_ENTRY_BYTES + stringBytes(name) + ARRAY_HEADER_BYTES + where.length * (REFERENCE_BYTES + OBJECT_BYTES);
103+
Lines 29–36 at 318 (were 29–34 at 299)
2929 pairs(draft: readonly AtomId[], against: ReadonlySet<AtomId>, settled: ReadonlySet<AtomId>): Pair[];
32+ /** The files a space's versions after `from`, up to `to`, changed, when each one's are kept; else undefined. */
Lines 95–118 at 318 (were 93–103 at 299)
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− .collisions(own, draftView, host.viewAt(shared, sharedBaseOf(space)), host.sharedView(), newer, SHARED)
Lines 273–297 at 318 (were 273–287 at 299)
278+ /** collision, with theirs described from the agent's space at `version`, not its newest (owed news). */
277281
278−/** A publish's definition news for other agents, not yet worked out: the version it made, and the names it changed. */
279−export interface OwedDefinitionNews {
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).
283− readonly names: readonly string[];
285295
Lines 312–319 at 318 (were 302–307 at 299)
315+ /** The space's version the moved lines' files are read at: its newest, or an owed publish's own. */
Lines 326–332 at 318 (were 314–320 at 299)
317− const now = host.viewAt(space, last(space));
Lines 335–341 at 318 (were 323–329 at 299)
326− 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]!)));
Lines 372–401 at 318 (were 360–396 at 299)
360372 // For the host's logs (abso 702): a line as the work starts, written before it, and one as it ends, so work that
361373 // outlives its request still shows. No time in them: a Durable Object's clock stands still in synchronous code.
363− let files = 0;
365− const compareDefinitions = (): ReadonlySet<string> => {
366− const touched = touchedFiles(host.graph, just, [host.viewAt(space, version - 1), host.viewAt(space, last(space))]);
367− files = touched.size;
368− const before = definitionsIn(host.viewAt(space, version - 1), touched);
369− const after = definitionsIn(host.viewAt(space, last(space)), touched);
370− return new Set(
371− [...new Set([...before.keys(), ...after.keys()])].filter(
372− (name) => !before.has(name) || signature(before.get(name)!) !== signature(after.get(name) ?? []),
373− ),
374− );
375− };
376− // Owed (abso Capacity, 2026-10-15): the definition rule over every other draft was most of a publish's write on
377− // stored tables (5.5 of 7.3 s on abso in the lab, about 45 s in prod, long enough to reset the object). Same lines
378− // and moves are told here as before; the definition news is worked out after the write, against this version.
379− // Asked only once some other agent has a draft (news-lazy.test.ts: no news work at all otherwise).
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− let owed = false;
382383 for (const agent of [...host.agents.values()].toSorted((a, b) => (a.name < b.name ? -1 : 1))) {
390+ host.logLine?.({ work: "publishNews", step: "owed", space: space.name, version, publisher: publisher.name });
387394 host.logLine?.({ work: "publishNews", step: "start", space: space.name, version, publisher: publisher.name });
389− changedNames ??= compareDefinitions();
390− owing ??= host.owesDefinitionNews();
391− if (owing && changedNames.size > 0) owed = true;
393− changedNames.size > 0 && !owing
394399 ? host.definitionCollisions(agent, host.newerFor(agent), changedNames).filter((d) => just.has(d.by))
Lines 414–506 at 318 (were 409–443 at 299)
412− files,
415− owed: owed ? 1 : 0,
417− if (owed)
418− host.owe({ version, space: space.name, publisher: publisher.name, names: [...(changedNames ?? [])].sort() });
420421
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).
429+ const touched = touchedFiles(host.graph, just, [host.viewAt(space, version - 1), host.viewAt(space, version)]);
434+ (name) => !before.has(name) || signature(before.get(name)!) !== signature(after.get(name) ?? []),
438+
439+/** owedNews's names, worked out once for a publish (the host keeps them on its row): changedNamesAt its version. */
445+
422447 * The definition news a publish owes, worked out as newsForOthers would have at that version: the same agents, the
423448 * same rule against the space at `owed.version` and the work published up to it, the same words and keys. Reads only.
424449 * An agent that has synced past the version since is left out (the version is no longer newer for it), and an item
425450 * an agent was already told (from its own edit since, or this run before) is dropped, as queueNews would.
427−export function definitionNewsOwed(host: NewsHost, owed: OwedDefinitionNews): { agent: string; items: NewsItem[] }[] {
455+ /** Only these agents (owedAgents' names), so a host can work the news out one agent at a time (abso 714). */
431− const names = new Set(owed.names);
433463 for (const agent of [...host.agents.values()].toSorted((a, b) => (a.name < b.name ? -1 : 1))) {
434− if (agent.name === owed.publisher || agent.space !== space.name || agent.base >= owed.version) continue;
435− if (host.draft(agent).length === 0) continue;
436− const defs = host
437− .definitionCollisionsAt(agent, host.newerAt(agent, owed.version), names, owed.version)
438− .filter((d) => just.has(d.by));
439− const items = definitionNews(defs).filter((item) => !agent.told.has(item.key));
469+ ? pairsIn(host.graph, draft, just, unionOverlay(host.setAt(space, owed.version), draft)).map((p) => ({
481+ const items = [...lines, ...definitionNews(defs), ...moves].filter((item) => !agent.told.has(item.key));
488+
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).
502+
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;
Lines 90–110 at 318 (were 90–95 at 299)
9292
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
107+
93108 /** keptPaths as a set, kept for the newest version asked: never changed once made, so a view can hold it. */
Lines 155–162 at 318 (were 155–160 at 299)
158+ /** fileAt for exactly this spelling, without the version's list of files (version-log.ts fileExactAt). */
159161 compare(from: number, to: number, draft: string | null, agent?: string, summary?: boolean): unknown;
Lines 49–66 at 318 (were 49–54 at 299)
5050
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).
62+
Lines 74–80 at 318 (were 62–68 at 299)
65− files: host.agentView(agent).paths(),
6880
Lines 106–112 at 318 (were 94–100 at 299)
97− files: host.agentView(agent).paths(),
100112
Lines 103–113 at 318 (were 103–111 at 299)
106− definitionNewsOwed as hostedDefinitionNewsOwed,
Lines 222–228 at 318 (were 220–225 at 299)
Lines 1355–1380 at 318 (were 1352–1362 at 299)
13541357
1355− /** What a publish owes, worked out against its version (news.ts definitionNewsOwed). Reads only. */
1356− definitionNewsOwed(owed: OwedDefinitionNews): { agent: string; items: NewsItem[] }[] {
1357− return hostedDefinitionNewsOwed(this.#newsHost, owed);
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[] }[] {
13591362
1364+ definitionNewsOwed(owed: OwedDefinitionNews, only?: readonly string[]): { agent: string; items: NewsItem[] }[] {
1367+
1368+ /** The names a publish's definitions changed (news.ts owedNewsNames), worked out once for its owed news. Reads only. */
1372+
1377+
13601378 /** Tells each agent its owed items, as queueNews does: what an agent was already told adds nothing. */
Lines 2009–2019 at 318 (were 1991–1996 at 299)
19932011
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> {
2016+
19942017 /** Every file that differs between two versions of shared (or a named draft) (version-log.ts). */
19952018 compare(...args: Tail<Parameters<typeof versionCompare>>): ReturnType<typeof versionCompare> {
Lines 2193–2201 at 318 (were 2170–2175 at 299)
2198+ this.#describe(pair, this.#agentView(agent), this.#viewAt(this.#spaceOf(agent), version), agent.space),
Lines 2499–2507 at 318 (were 2473–2478 at 299)
24742500 describe: (pair, yoursView, theirsView, spaceName) => this.#describe(pair, yoursView, theirsView, spaceName),
2502+ // Only from a stored writer's kept rows, as keptPaths: a project in memory keeps none, and works them out.
Lines 3218–3236 at 318 (were 3189–3203 at 299)
3196− this.#viewAt(space, version ?? last(space)),
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),
Lines 40–50 at 318 (were 40–45 at 299)
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.
Lines 63–75 at 318 (were 58–63 at 299)
6065 membershipVersion: (atom, version) => membershipEvent(storage, prefix, atom, version)?.version,
Lines 136–154 at 318 (were 124–129 at 299)
144+ /** membershipVersion from the page: the version of its only event, or undefined; null when its events must be read. */
Lines 160–166 at 318 (were 135–144 at 299)
138− const code = page[seq % PAGE] ?? NONE;
139− if (code === NONE) return false;
140− if (code === MIXED) return undefined;
141− return version >= code;
144166
Lines 403–412 at 318 (were 381–389 at 299)
386− if (this.space.membershipVersion!(id, this.endVersion) === version && this.has(id)) yield id;
Lines 73–81 at 318 (were 73–79 at 299)
76− // Known paths first, by key, then only those laid out (#46).
77− 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
79+ const twins = [...view.graph.knownFiles()].filter((p) => pathKey(p) === key && view.hasFile(p));
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
4+
10+
11+/** A draft of two atoms: "del" deletes one line, "add" writes the others. Any view laid out throws. */
39+
41+
45+
46+test("a deleted text written again with only brackets or blanks in common lays out no file", () => {
49+
50+test("a written line with real content that the draft also deleted goes on to the files", () => {
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/
4+
8+
13+ p.record("ann", { "abso.yml": "pipelines:\n ci:\n on: [push]\n", "docs/abso.yml": "not this one\n" }, 1);
15+ p.record("ann", { "abso.json": '{ "check": "false" }\n', "empty.txt": "" }, 3, {}, { "abso.yaml": "b".repeat(64) });
21+
33+
39+ for (const path of PATHS) assert.deepEqual(p.fileExactAt(path, v), p.fileAt(path, v), `${path} at ${v}`);
41+
42+test("a name nothing ever wrote is null, and another spelling is that spelling, not the stored one", () => {
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 });
Lines 105–124 at 318 (were 105–107 at 299)
106106 assert.deepEqual(project.pathsAt(version).files, oracle.draftOf(agent)!.view.paths(), `paths at ${version}`);
108+
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.
115+ // v0 and v1 are behind shared with nothing of their own, v2 is at shared, and bob, cy, dee and eve have drafts.
Lines 37–42 at 318 (were 37–43 at 299)
40− assert.equal(news[1]!.files, 1);
Lines 65–71 at 318 (were 65–73 at 299)
6666 assert.deepEqual(owing.publish("ann", "parsePattern takes flags", 4), toldAnswer, "the publisher's answer");
68− assert.deepEqual(owed, [
69− { version: owing.version, space: owed[0]!.space, publisher: "ann", names: ["parsePattern"] },
70− ]);
68+ assert.deepEqual(owed, [{ version: owing.version, space: owed[0]!.space, publisher: "ann", all: true }]);
Lines 126–190 at 318 (were 128–130 at 299)
129+
130+test("owedAgents lists who may be owed, and the news one agent at a time adds up to the whole (abso 714)", () => {
136+ assert.deepEqual(owing.owedAgents(owed!), ["bob", "cat"], "every other agent behind it with a draft");
146+
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),
155+ { file: "src/parse.ts", old: "parsePattern(text: string): Node", new: "parsePattern(input: string): Node" },
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");
164+
168+ assert.deepEqual(owing.publish("ann", "parsePattern takes flags", 6), toldAnswer, "the publisher's answer");
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);
181+
Lines 36–87 at 318 (were 36–38 at 299)
39+
40+test("shared additions read each atom's version from the membership pages, and answer as its events do (abso - Performance, 714)", (t) => {
45+ const ids = (from: number, to: number) => Array.from({ length: to - from }, (_, i) => `a${from + i}`);
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.
78+ assert.deepEqual([...new SharedAdditions(space, 1, membership.at(space, 1), membership.at(space, 3), 3)], ["a600"]);
83+ assert.deepEqual([...new SharedAdditions(space, 3, membership.at(space, 3), membership.at(space, 5), 5)], []);
Lines 244–278 at 318 (were 244–249 at 299)
246246
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.
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;
275+
247276/** The files that may differ between two versions, and both views: compare's and compareSummary's ground. */
- MCP
- compare on this site's /mcp
- CLI
- abso diff 299 318 worker --json
- JSON
- /christopher/abso-core/compare/299..318?file=worker&format=json