Versions 302 to 318
Lines 154–164 at 318 (were 154–159 at 302)
157+ // Checked before any call: a name like ".." would otherwise go out as part of the request's path.
160+ `project names are letters, digits, dot, dash and underscore (got ${JSON.stringify(project)})`,
157162 if (bool(args, "public") && bool(args, "private")) throw new UsageError("--public or --private, not both");
159164 // A box signed in here, and no other credential asked for: the project is made as the person who approved the box,
Lines 79–85 at 318 (were 79–85 at 302)
82−import { handoffText, patFromFile, siteFor, webHandoff } from "./web-session.ts";
8383
Lines 218–243 at 318 (were 218–236 at 302)
221− "abso login [--no-browser] [--no-ask] [--projects <name,name>] [--role <reader|writer|owner>] [--days <1-90>] | abso login --web [--pat-file <file>] [--site <url>]",
221+ "abso login [--no-browser] [--no-ask] [--projects <name,name>] [--role <reader|writer|owner>] [--days <1-90>] | abso login --web [--pat-file <file> [--site http://localhost:<port>]]",
223− "Sign this box in once: it opens the approve page in your browser with the code filled in, prints the link and the code too, and waits while a person approves the code on the website, choosing the projects, the highest role and how long. Then abso join in any of those projects gives each agent its own key, with no approval. The box's sign-in is kept in your user folder, never in a project folder, and is never printed. No browser opens with --no-browser or ABSO_NO_BROWSER, over SSH, under CI, or on Linux without a display. In an agent's folder on the same server, it also asks a person in that project to approve it (the person who approved the agent's box, else the project's owners), as an abso ask, so nobody has to relay the code; the box can then be granted that project at no more than the agent's own role. --no-ask shows the code only. --web, on staging only, signs a browser in to the website instead: it prints a link that works once, within a minute, and signs whichever browser opens it in as the person who approved this box (or, with --pat-file, the test account whose PAT that file holds). The box's sign-in, the PAT and the session never appear; agents never sign in to the website on prod.",
223+ "Sign this box in once: it opens the approve page in your browser with the code filled in, prints the link and the code too, and waits while a person approves the code on the website, choosing the projects, the highest role and how long. Then abso join in any of those projects gives each agent its own key, with no approval. The box's sign-in is kept in your user folder, never in a project folder, and is never printed. No browser opens with --no-browser or ABSO_NO_BROWSER, over SSH, under CI, or on Linux without a display. In an agent's folder on the same server, it also asks a person in that project to approve it (the person who approved the agent's box, else the project's owners), as an abso ask, so nobody has to relay the code; the box can then be granted that project at no more than the agent's own role. --no-ask shows the code only. --web, on staging only, signs a browser in to the website instead: it prints a link that works once, within a minute, and signs whichever browser opens it in as the person who approved this box, but only to the projects the box was granted and at most as a writer, until the box is revoked or ends (or, with --pat-file, as the test account whose PAT that file holds, at most as a writer). It writes issues, replies, answers, groups and announcements, and changes no members, roles, visibility, keys, boxes or settings. The box's sign-in, the PAT and the session never appear. It goes only to the staging website beside this folder's staging server; any other server, prod included, is refused and nothing is sent. --site, with --pat-file only, points it at a website on this machine (http://localhost or 127.0.0.1).",
227− const site = siteFor(server, str(args, "site"));
229− const record = patFile === undefined ? readBox(server) : undefined;
230− if (patFile === undefined && (record === undefined || record.expiresAt <= Date.now()))
231− throw new UsageError(`this box isn't signed in to ${server}: abso login first, or --pat-file <file>`);
232− const handoff = await webHandoff(site, patFile === undefined ? record!.credential : patFromFile(patFile));
233− return { text: handoffText(handoff, site), json: { ...handoff } };
236+ throw new UsageError(`this box isn't signed in to ${server}: abso login first, or --pat-file <file>`);
Lines 21–71 at 318 (were 21–50 at 302)
2323
24−/** The website a server's handoff goes to: --site as given (https only), else the staging site beside it. */
25−export function siteFor(server: string, site?: string): string {
26− if (site !== undefined) {
27− let url: URL;
28− try {
29− url = new URL(site);
30− } catch {
31− throw new UsageError(
32− `--site takes the website's address, like https://abso-website-staging.chrisazy.workers.dev`,
33− );
34− }
35− if (url.protocol !== "https:" && url.hostname !== "localhost" && url.hostname !== "127.0.0.1")
36− throw new UsageError("--site has to be https, or this machine");
37− return url.origin;
38− }
25+ * The website a handoff's credential goes to (Security condition 6, Code Review): the staging website beside the folder's own
26+ * staging server, from the fixed list above, and never an origin from a flag. A server that isn't on the list is refused,
27+ * prod included. --site is only for a test account's PAT on this machine (http://localhost or 127.0.0.1); a box's sign-in
43− `abso login --web is for staging: ${origin} has no staging website beside it that abso knows, and agents never sign in to the website on prod. --site names one.`,
35+ `abso login --web is for staging: ${origin} has no staging website beside it that abso knows, and agents never sign in to the website on prod. Nothing was sent.`,
45− return known;
39+ throw new UsageError(`--site isn't taken with a box's sign-in, which goes only to ${known}. Nothing was sent.`);
46+ if (url === null || url.protocol !== "http:" || (url.hostname !== "localhost" && url.hostname !== "127.0.0.1"))
48+ "--site, with --pat-file, names this machine only (http://localhost:<port> or http://127.0.0.1:<port>). Nothing was sent.",
4752
54+ * abso login --web: where the credential would go is settled before it is read, so a refusal reads and sends nothing
55+ * (Security). `credential` reads the box's sign-in or the PAT only once the website is one it may go to.
68+
Lines 128–141 at 318 (were 107–117 at 302)
109130
110−/** What abso login --web says: the one link, how long it works, and who it signs in as. */
111−export function handoffText(h: Handoff, site: string, now = Date.now()): string {
131+/** What abso login --web says: the one link, how long it works, who it signs in as, and what it reaches (Security). */
135+ ? "only to the projects this box was granted, at most as a writer, until the box is revoked or ends"
114− `Open this link in your browser within ${seconds} seconds. It signs that browser in to ${site} as ${h.name}, until ${h.sessionEnds}, and works once:`,
138+ `Open this link in your browser within ${seconds} seconds. It signs that browser in to ${site} as ${h.name}, until ${h.sessionEnds}, and works once. It reaches ${reach}:`,
Lines 4–10 at 318 (were 4–10 at 302)
44
7−import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
7+import { existsSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
Lines 145–158 at 318 (were 145–153 at 302)
145145 it("a project's name can't start with a dot, so its folder stays inside the store", async () => {
148− const r = await run(dir, "init", "--local", "--project", "..", "--agent", "a");
149− assert.notEqual(r.exit, 0);
153158
Lines 5–57 at 318 (were 5–24 at 302)
8−import { handoffText, patFromFile, siteFor, webHandoff } from "../src/web-session.ts";
99
1315
14−test("the website is the staging one beside the server, or --site; prod has none, since agents never sign in there", () => {
15− assert.equal(siteFor("https://abso-staging.chrisazy.workers.dev"), SITE);
16− assert.equal(siteFor("https://avcs-staging.chrisazy.workers.dev/"), SITE);
17− assert.throws(() => siteFor("https://api.abso.dev"), /for staging.*never sign in to the website on prod/);
18− assert.equal(siteFor("https://api.abso.dev", "http://localhost:8871/x"), "http://localhost:8871");
19− assert.throws(() => siteFor("https://api.abso.dev", "http://elsewhere.example"), /https/);
16+test("the credential goes only to the staging website beside the folder's staging server (Security condition 6)", () => {
24+ assert.throws(() => siteFor("https://api.abso.dev", "http://localhost:8871", "pat"), /for staging/);
27+ assert.throws(() => siteFor(STAGING, "http://localhost:8871", "box"), /isn't taken with a box's sign-in/);
31+ for (const elsewhere of ["https://anywhere.example", SITE, "https://localhost:8871", "not a url"])
2134
37+ const fetcher = (async (url: string) => (sent.push(url), Response.json({}))) as unknown as typeof fetch;
47+ await assert.rejects(webLogin({ ...asked, credential, fetcher }), /Nothing was sent/, JSON.stringify(asked));
51+ await webLogin({ server: STAGING, site: undefined, kind: "pat", credential: () => PAT, fetcher }).catch(() => {});
54+
2255test("the credential goes in Authorization only, and the answer is the one link and who it signs in as", async () => {
Lines 66–76 at 318 (were 33–41 at 302)
3568 assert.deepEqual(seen, [{ url: `${SITE}/login/handoff`, authorization: `Bearer ${BOX}`, body: null }]);
36− const text = handoffText(h, SITE, NOW);
Lines 1524–1562 at 318 (were 1524–1566 at 302)
1527− const floor = this.#lamportAt(this.#seq(target));
1528− if (this.#storage) {
1529− return this.withProjectionScratch((scratch) => {
1530− let length = 0;
1531− const push = (id: AtomId): void => {
1532− if (scratch.read("seen", id)) return;
1533− scratch.write("seen", id, true);
1534− scratch.write("stack", String(length++), id);
1535− };
1536− for (const id of from) {
1537− if (id === target) return true;
1538− if (this.#lamportAt(this.#seq(id)) > floor) push(id);
1539− }
1540− while (length > 0) {
1541− const key = String(--length);
1542− const current = scratch.read("stack", key) as AtomId;
1543− scratch.remove("stack", key);
1544− if (this.#lamportAt(this.#seq(current)) <= floor) continue;
1545− for (const dependency of this.atom(current).deps) {
1546− if (dependency === target) return true;
1547− push(dependency);
1548− }
1549− }
1550− return false;
1551− });
1529+
1531+ * Which of `targets` are reachable along deps from any of `from` (themselves included), in one walk: it never
1532+ * descends below the lowest target's lamport, and stops once every target is found (abso 714, piece 4: record
1534+ * The walk's seen marks and stack are in memory, by atom number: one byte and four bytes an atom at most, so about
1535+ * 62 KB on abso's 12,454 atoms and 50 MB at 10 million, under a Worker's 128 MB. They were scratch rows in storage
1536+ * (abso-core 139, bounding memory with the graph), which cost a read and a write per atom visited: on abso's Oct 14
1553− const seen = new Set<AtomId>();
1554− const stack = [...from];
1555− while (stack.length > 0) {
1556− const cur = stack.pop()!;
1557− if (cur === target) return true;
1558− if (seen.has(cur)) continue;
1559− seen.add(cur);
1560− if (this.#lamportAt(this.#seq(cur)) <= floor) continue;
1561− for (const d of this.atom(cur).deps) if (!seen.has(d)) stack.push(d);
1562− }
1563− return false;
15651561
Lines 1606–1633 at 318 (were 1610–1632 at 302)
16101606 for (const r of atom.reasons) if (!this.has(r.to)) bad(`reason points at unknown atom ${r.to}`);
16111607
1613− // writers directly, so this is usually one lookup per writer.
1614− const memoryBelow = scratch ? undefined : new Map<AtomId, boolean>();
1615− const below = {
1616− get: (key: AtomId) => (scratch ? (scratch.read("below", key) as boolean | undefined) : memoryBelow!.get(key)),
1617− set: (key: AtomId, value: boolean) => {
1618− if (scratch) scratch.write("below", key, value);
1619− else memoryBelow!.set(key, value);
1620− },
1621− };
1622− const inClosure = (writer: AtomId): boolean => {
1623− let hit = below.get(writer);
1624− if (hit === undefined) {
1625− hit = deps.has(writer) || this.#reaches(atom.deps, writer);
1626− below.set(writer, hit);
1621+ if (parsed.kind === "line" || ((parsed.kind === "gap" || parsed.kind === "pos") && !isStartNode(parsed.node)))
1628− return hit;
1629− };
Lines 10–16 at 318 (were 10–16 at 302)
1111
13−import { isStartNode, lineId, seqOf } from "./keys.ts";
Lines 1095–1108 at 318 (were 1095–1101 at 302)
10961096
1098− for (const n of this.#file(path).vis) yield () => this.graph.textChunks(n);
1098+ // The texts the packed layout already holds, read a page at a time (abso Capacity, 714): a record's diff read each
1099+ // line's own row, 11,873 statements for abso's index.ts. Only a line too long to pack is read in chunks.
11001107
Lines 1112–1118 at 318 (were 1105–1111 at 302)
1108− atom: graph.idOfSeq(graph.writerSeqOf(n)),
11111118
Lines 1126–1137 at 318 (were 1119–1130 at 302)
1122− id: visWriter && visK ? lineId(graph.idOfSeq(visWriter[i]!), visK[i]!) : graph.lineIdOf(n),
1127− atom: graph.idOfSeq(visWriter ? visWriter[i]! : graph.writerSeqOf(n)),
Lines 1143–1156 at 318 (were 1136–1147 at 302)
1146+ // Writer seqs come from the graph's own layout, so they're named with atomId, not checked by idOfSeq (abso 738):
1147+ // on a stored graph its check read the atom count once a line, about 0.9 s of a warm draft-state on abso.
1142− id: visWriter && visK ? lineId(graph.idOfSeq(visWriter[i]!), visK[i]!) : graph.lineIdOf(n),
1144− atom: graph.idOfSeq(visWriter ? visWriter[i]! : graph.writerSeqOf(n)),
Lines 1172–1184 at 318 (were 1163–1175 at 302)
1166− id: seqWriter && seqK ? lineId(graph.idOfSeq(writer), seqK[i]!) : graph.lineIdOf(n),
1171− atom: graph.idOfSeq(writer),
1172− deletedBy: by ? by.map((s) => graph.idOfSeq(s)) : NONE,
Lines 68–74 at 318 (were 68–74 at 302)
71− for (const id of orderedClaimants(g, streams)) if (against.has(id)) theirs.push(id);
Lines 136–142 at 318 (were 136–142 at 302)
136136
139−function* orderedClaimants(g: Graph, streams: IterableIterator<AtomId>[]): IterableIterator<AtomId> {
Lines 152–162 at 318 (were 152–160 at 302)
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 302)
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 302)
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 302)
3939
40−/** Definitions in the files newer work touched, before it and with it. */
Lines 52–62 at 318 (were 52–59 at 302)
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 302)
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 302)
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 302)
Lines 239–257 at 318 (were 205–224 at 302)
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 302)
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 302)
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 302)
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 302)
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 302)
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 302)
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 302)
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 302)
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 302)
317− const now = host.viewAt(space, last(space));
Lines 335–341 at 318 (were 323–329 at 302)
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 302)
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 302)
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 302)
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 302)
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 302)
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 302)
65− files: host.agentView(agent).paths(),
6880
Lines 106–112 at 318 (were 94–100 at 302)
97− files: host.agentView(agent).paths(),
100112
Lines 103–113 at 318 (were 103–111 at 302)
106− definitionNewsOwed as hostedDefinitionNewsOwed,
Lines 222–228 at 318 (were 220–225 at 302)
Lines 1355–1380 at 318 (were 1352–1362 at 302)
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 302)
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 302)
2198+ this.#describe(pair, this.#agentView(agent), this.#viewAt(this.#spaceOf(agent), version), agent.space),
Lines 2499–2507 at 318 (were 2473–2478 at 302)
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 302)
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 302)
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 302)
6065 membershipVersion: (atom, version) => membershipEvent(storage, prefix, atom, version)?.version,
Lines 136–154 at 318 (were 124–129 at 302)
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 302)
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 302)
386− if (this.space.membershipVersion!(id, this.endVersion) === version && this.has(id)) yield id;
Lines 73–81 at 318 (were 73–79 at 302)
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 302)
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 302)
40− assert.equal(news[1]!.files, 1);
Lines 65–71 at 318 (were 65–73 at 302)
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 302)
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 302)
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 302)
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 302 318 --json
- JSON
- /christopher/abso-core/compare/302..318?format=json