Owed news: a publish can leave its definition news for other agents for after its write (abso Capacity; prod abso's publishes reset its object, 2026-10-15) Version 295 of shared· capacity· Oct 16 (2026-10-16 04:40 UTC) · Not checked
With Project.owesDefinitionNews set, newsForOthers still tells same-lines and move news in the publish, but leaves the definition rule over other agents' drafts out. It records an OwedDefinitionNews {version, space, publisher, names} instead; takeOwedDefinitionNews hands it to the host once. definitionNewsOwed(owed) works that news out later, as it would have been told at the publish: the rule runs against the space at that version, with the work published up to that version only (#newerFor and SharedAdditions take an end version). It reads only. An agent that has synced past the version since is left out. deliverOwedNews(found) tells it through queueNews, so a key an agent was already told adds nothing. Default off: the replay engine and every existing caller behave as before. abso's disk route turns it on, keeps the marker in the publish's own transaction, and delivers from the alarm. Why: on abso's stored tables, the definition rule over ~40 drafts was 5.5 of a 1437-shaped publish's 7.3 s in the lab, about 45 s of one storage transaction in prod. That reset abso's object at 11:08 PM CT. With the rule owed, the publish's write is 18,622 statements instead of 105,252. On prod since 11:35 PM CT as a patch (abso 2341e805), with Agent VCS's yes. This brings core level with it; abso's pin follows. Keeps Observability's publishNews log lines (abso 702), and adds owed: 1 or 0 to the end line. Checks: tsc clean. node --test in worker/project/test, 41 of 41 pass: changed-definition, collision-streaming, collisions-kept-views, news-cap, news-lazy, news-lines, news-times, news-written, owed-definition-news (new: the same news, against the publish's version even after a later publish removes the name, synced agents left out, the replay engine unchanged), project-writer-storage, writer-adoption.
Version 294 · Files at version 295
4 files, 229 lines added, 7 removed.
--- a/worker/project/news.ts
+++ b/worker/project/news.ts
@@ -257,8 +257,32 @@
257 257 queueNews(agent: AgentState, items: readonly NewsItem[], entries: Entry[]): void; 258 258 /** A line for the host's logs (ProjectOptions.logLine). */ 259 259 logLine?(line: Record<string, string | number>): void; 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. 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( 272 + newer: ReadonlySet<AtomId>, 273 + names: ReadonlySet<string>, 275 + ): DefinitionCollision[]; 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 { 280 + readonly version: number; 281 + readonly space: string; 282 + readonly publisher: string; 283 + readonly names: readonly string[]; 262 286 function lineNews(host: NewsHost, agent: AgentState, pairs: readonly Pair[]): NewsItem[] { 263 287 return pairs.map((p) => ({ key: pairKey(p), text: linesText(host.collision(agent, p)) })); @@ -349,6 +373,12 @@
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). 380 + let owing: boolean | undefined; 352 382 for (const agent of [...host.agents.values()].toSorted((a, b) => (a.name < b.name ? -1 : 1))) { 353 383 if (agent === publisher || agent.space !== space.name) continue; 354 384 const draft = host.draft(agent); @@ -357,8 +387,10 @@
357 387 host.logLine?.({ work: "publishNews", step: "start", space: space.name, version, publisher: publisher.name }); 358 388 const lines = pairsIn(host.graph, draft, just, unionOverlay(host.setOf(space), draft)); 359 389 changedNames ??= compareDefinitions(); 390 + owing ??= host.owesDefinitionNews(); 391 + if (owing && changedNames.size > 0) owed = true; 361 − changedNames.size > 0
393 + changedNames.size > 0 && !owing 362 394 ? host.definitionCollisions(agent, host.newerFor(agent), changedNames).filter((d) => just.has(d.by)) @@ -380,5 +412,32 @@
381 413 changedNames: changedNames?.size ?? 0, 418 + host.owe({ version, space: space.name, publisher: publisher.name, names: [...(changedNames ?? [])].sort() }); 422 + * The definition news a publish owes, worked out as newsForOthers would have at that version: the same agents, the 423 + * same rule against the space at `owed.version` and the work published up to it, the same words and keys. Reads only. 424 + * An agent that has synced past the version since is left out (the version is no longer newer for it), and an item 425 + * 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[] }[] { 428 + const space = host.spaceNamed(owed.space); 429 + if (!space || owed.version > last(space) || !space.versions[owed.version]) return []; 430 + const just = new Set(space.versions[owed.version]!.atoms); 431 + const names = new Set(owed.names); 432 + const out: { agent: string; items: NewsItem[] }[] = []; 433 + 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; 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)); 440 + if (items.length > 0) out.push({ agent: agent.name, items }); --- a/worker/project/project.ts
+++ b/worker/project/project.ts
@@ -105,9 +105,11 @@
106 106 newsAboutOwnDraft as hostedNewsAboutOwnDraft, 107 107 newsForOthers as hostedNewsForOthers, 108 + definitionNewsOwed as hostedDefinitionNewsOwed, 112 + type OwedDefinitionNews, 113 115 } from "./news.ts"; @@ -330,6 +332,12 @@
330 332 * doesn't depend on it. 332 334 checkerReady = false; 336 + * Owed news (abso Capacity, 2026-10-15): a publish's definition news for other agents is left for after its write 337 + * (takeOwedDefinitionNews, definitionNewsOwed, deliverOwedNews). The disk route sets it; the replay engine doesn't. 339 + owesDefinitionNews = false; 340 + #owed: OwedDefinitionNews[] = []; 333 341 readonly #now: (() => number) | undefined; 334 342 readonly #newsWritten: ((items: readonly NewsWritten[]) => void) | undefined; 335 343 readonly #whole: ProjectOptions["whole"]; @@ -1337,6 +1345,29 @@
1337 1345 return hostedAnnouncePerson(this.#announceHost, ...args); 1348 + /** The definition news the writes since the last call owe other agents, handed over once (news.ts). */ 1349 + takeOwedDefinitionNews(): OwedDefinitionNews[] { 1350 + const owed = this.#owed; 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); 1360 + /** Tells each agent its owed items, as queueNews does: what an agent was already told adds nothing. */ 1361 + deliverOwedNews(found: readonly { agent: string; items: readonly NewsItem[] }[]): number { 1362 + const entries: Entry[] = []; 1363 + for (const { agent: name, items } of found) { 1364 + const agent = this.#agents.get(name); 1365 + if (agent) this.#queueNews(agent, items, entries); 1367 + this.#flush(entries); 1368 + return entries.length; 1340 1371 /** A seat's earlier chat hears that another chat just used the seat (announce.ts seatNotice). */ 1341 1372 seatNotice(...args: Tail<Parameters<typeof hostedSeatNotice>>): ReturnType<typeof hostedSeatNotice> { 1342 1373 return hostedSeatNotice(this.#announceHost, ...args); @@ -2133,6 +2164,12 @@
2133 2164 definitionCollisions: (agent, newer, names) => this.#definitionCollisions(agent, newer, names), 2134 2165 queueNews: (agent, items, entries) => this.#queueNews(agent, items, entries), 2135 2166 logLine: (line) => this.#logLine?.(line), 2167 + owesDefinitionNews: () => this.owesDefinitionNews, 2168 + owe: (owed) => void this.#owed.push(owed), 2169 + spaceNamed: (name) => (name === SHARED ? this.#shared : this.#spaces.get(name)), 2170 + newerAt: (agent, version) => this.#newerFor(agent, version), 2171 + definitionCollisionsAt: (agent, newer, names, version) => 2172 + this.#definitionCollisions(agent, newer, names, version), 2137 2174 return this.#news; @@ -2995,13 +3032,14 @@
2997 3034 /** The space's atoms published after the agent's base, by others. */ 2998 − #newerFor(agent: AgentState): ReadonlySet<AtomId> {
3035 + /** `upTo`: the work published after the agent's base up to that version only (owed news, news.ts). */ 3036 + #newerFor(agent: AgentState, upTo?: number): ReadonlySet<AtomId> { 2999 3037 const space = this.#spaceOf(agent); 3000 3038 const base = this.#at(space, agent.base); 3001 − const current = this.#setOf(space);
3039 + const current = upTo === undefined ? this.#setOf(space) : this.#at(space, upTo); 3003 3041 space.name === SHARED && space.membershipVersion 3004 − ? new SharedAdditions(space, agent.base, base, current)
3042 + ? new SharedAdditions(space, agent.base, base, current, upTo ?? last(space)) 3005 3043 : differenceSet(current, base); 3006 3044 return differenceSet(newer, new StableOverlaySet(agent.mine)); @@ -3141,6 +3179,8 @@
3141 3179 agent: AgentState, 3142 3180 newer: ReadonlySet<AtomId>, 3143 3181 names?: ReadonlySet<string>, 3182 + /** The space's version to compare against: its newest, or an owed publish's (news.ts). */ 3144 3184 ): DefinitionCollision[] { 3145 3185 const draft = new Set(this.#draft(agent)); 3146 3186 if (draft.size === 0 || newer.size === 0) return []; @@ -3153,7 +3193,7 @@
3154 3194 this.#agentView(agent), 3156 − this.#viewAt(space, last(space)),
3196 + this.#viewAt(space, version ?? last(space)), --- a/worker/project/spaces.ts
+++ b/worker/project/spaces.ts
@@ -361,10 +361,17 @@
361 361 readonly baseVersion: number; 362 362 readonly base: ReadonlySet<AtomId>; 363 363 readonly current: ReadonlySet<AtomId>; 364 − constructor(space: Space, baseVersion: number, base: ReadonlySet<AtomId>, current: ReadonlySet<AtomId>) {
364 + /** `endVersion`: the version `current` is (the newest by default; an earlier one for owed news, news.ts). */ 367 + baseVersion: number, 368 + base: ReadonlySet<AtomId>, 369 + current: ReadonlySet<AtomId>, 370 + endVersion = last(space), 366 373 if (space.name !== SHARED || !space.membershipVersion) throw Error("shared additions require indexed shared space"); 367 − this.endVersion = last(space);
374 + this.endVersion = endVersion; 368 375 this.space = space; 369 376 this.baseVersion = baseVersion; --- /dev/null
+++ b/worker/project/test/owed-definition-news.test.ts
@@ -0,0 +1,116 @@
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. 5 + import assert from "node:assert/strict"; 6 + import { test } from "node:test"; 7 + import { MemoryStore, Project } from "../project.ts"; 9 + // abso-core's changed-definition.test.ts scenario: parse.ts defines parsePattern, match.ts imports it. 12 + "export function parsePattern(text: string): Node {", 13 + ' return { kind: "lit", text };', 16 + "export interface Node {", 21 + "src/match.ts": ['import { parsePattern } from "./parse.ts";', "", "export function run(p: string) {", " return p;", "}"].join( 24 + "README.md": "Uses parsePattern.\n", 27 + /** bob's draft calls parsePattern; ann's draft changes its signature; cat's touches something else. Nothing published. */ 28 + function drafts(project: Project): void { 29 + project.init(START, 0); 33 + project.edit("bob", { file: "src/match.ts", old: " return p;\n", new: " const tree = parsePattern(p);\n return tree;\n" }, 1); 36 + { file: "src/parse.ts", old: "parsePattern(text: string): Node", new: "parsePattern(text: string, flags: string): Node" }, 39 + project.edit("cat", { file: "README.md", old: "Uses parsePattern.", new: "Uses parsePattern, twice." }, 3); 42 + const definitionNews = (news: readonly string[]) => news.filter((n) => /definition of parsePattern/.test(n)).sort(); 44 + test("the news owed is the news a publish would have told, and the publisher's own answer is the same", () => { 45 + const told = new Project(new MemoryStore()); 47 + const toldAnswer = told.publish("ann", "parsePattern takes flags", 4); 48 + const expected = definitionNews(told.news("bob").news); 49 + assert.equal(expected.length, 1, "the scenario has a definition collision"); 51 + const owing = new Project(new MemoryStore()); 52 + owing.owesDefinitionNews = true; 54 + assert.deepEqual(owing.publish("ann", "parsePattern takes flags", 4), toldAnswer, "the publisher's answer"); 55 + const owed = owing.takeOwedDefinitionNews(); 56 + assert.deepEqual(owed, [{ version: owing.version, space: owed[0]!.space, publisher: "ann", names: ["parsePattern"] }]); 57 + assert.deepEqual(owing.takeOwedDefinitionNews(), [], "handed over once"); 58 + // Not told yet: bob's news holds no definition news until it's delivered. 59 + assert.deepEqual(definitionNews(owing.news("bob").news), []); 60 + const found = owing.definitionNewsOwed(owed[0]!); 62 + found.map((f) => f.agent), 65 + assert.ok(owing.deliverOwedNews(found) > 0); 66 + assert.deepEqual(definitionNews(owing.news("bob").news), expected); 67 + // Told twice adds nothing, and a run of the read after delivery finds nothing left. 68 + assert.equal(owing.deliverOwedNews(found), 0); 69 + assert.deepEqual(owing.definitionNewsOwed(owed[0]!), []); 72 + test("worked out against the publish's version, though more was published before the news went out", () => { 73 + const told = new Project(new MemoryStore()); 75 + told.publish("ann", "parsePattern takes flags", 4); 76 + const expected = definitionNews(told.news("bob").news); 78 + const owing = new Project(new MemoryStore()); 79 + owing.owesDefinitionNews = true; 81 + owing.publish("ann", "parsePattern takes flags", 4); 82 + const [first] = owing.takeOwedDefinitionNews(); 83 + // Then parsePattern is removed, before the first publish's news is out: against the newest version the news 84 + // would say "removes"; against the first publish's, it says "changes", as told at publish time. 89 + file: "src/parse.ts", 90 + old: 'export function parsePattern(text: string, flags: string): Node {\n return { kind: "lit", text };\n}\n', 95 + owing.publish("ann", "parsePattern goes", 6); 96 + assert.ok(owing.deliverOwedNews(owing.definitionNewsOwed(first!)) > 0); 97 + assert.deepEqual(definitionNews(owing.news("bob").news), expected, "the first publish's news, as it was"); 100 + test("an agent that synced past the version since isn't told it", () => { 101 + const owing = new Project(new MemoryStore()); 102 + owing.owesDefinitionNews = true; 104 + owing.publish("ann", "parsePattern takes flags", 4); 105 + const [owed] = owing.takeOwedDefinitionNews(); 107 + assert.deepEqual(owing.definitionNewsOwed(owed!), []); 110 + test("the replay engine tells it at publish time, as before", () => { 111 + const told = new Project(new MemoryStore()); 113 + told.publish("ann", "parsePattern takes flags", 4); 114 + assert.deepEqual(told.takeOwedDefinitionNews(), []); 115 + assert.equal(definitionNews(told.news("bob").news).length, 1);