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.

Check passed
MCP
show on this site's /mcp
CLI
abso show 308 --json
JSON
/christopher/abso-core/versions/308?format=json

Owed news can be worked out a few agents at a time: owedAgents lists who may be owed, and definitionNewsOwed takes only those named (abso 714; Cloud's (b), Capacity)

of shared·capacity··Not checked

  • On prod abso at 6:31 PM CT, one owed-news read over every draft ran as one storage transaction and reset the object. Core 307 cut that read about ninefold; this lets the host bound it outright.
  • owedAgents(owed): every other agent in the space, behind the version, with a draft, in the order definitionNewsOwed takes them. Cheap: no definition rule.
  • definitionNewsOwed(owed, only?): the same news, for only those agents when named. Per agent it's the same work and the same items as before, so the news one agent at a time adds up to the whole.
  • abso's DiskRoute (worker side, with Cloud) lists them once per owed row, then works out and tells up to four a tick, each in its own read and write, keeping the rest on the row.

Checks: core tsc clean; Biome clean; node --test worker/project/test/owed-definition-news (new: owedAgents lists bob and cat, one agent at a time equals the whole, a synced agent drops out), changed-definition, news-lazy, news-cap, news-lines, news-written, news-times, shared-additions, project: 46 of 46 pass.

Version 307 · Files at version 308

3 files, 53 lines added, 6 removed.

--- a/worker/project/news.ts
+++ b/worker/project/news.ts
@@ -424,15 +424,20 @@
424424 * An agent that has synced past the version since is left out (the version is no longer newer for it), and an item
425425 * an agent was already told (from its own edit since, or this run before) is dropped, as queueNews would.
426426 */
427−export function definitionNewsOwed(host: NewsHost, owed: OwedDefinitionNews): { agent: string; items: NewsItem[] }[] {
427+export function definitionNewsOwed(
428+ host: NewsHost,
429+ owed: OwedDefinitionNews,
430+ /** Only these agents (owedAgents' names), so a host can work the news out a few agents at a time (abso 714). */
431+ only?: readonly string[],
432+): { agent: string; items: NewsItem[] }[] {
428433 const space = host.spaceNamed(owed.space);
429434 if (!space || owed.version > last(space) || !space.versions[owed.version]) return [];
430435 const just = new Set(space.versions[owed.version]!.atoms);
431436 const names = new Set(owed.names);
432437 const out: { agent: string; items: NewsItem[] }[] = [];
433438 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;
439+ if (only && !only.includes(agent.name)) continue;
440+ if (!owedTo(host, owed, space, agent)) continue;
436441 const defs = host
437442 .definitionCollisionsAt(agent, host.newerAt(agent, owed.version), names, owed.version)
438443 .filter((d) => just.has(d.by));
@@ -441,3 +446,22 @@
441446 }
442447 return out;
443448}
450+/**
451+ * The agents a publish's owed news may be for, in the order definitionNewsOwed takes them: every other agent in the
452+ * space, behind the version, with a draft. Cheap (no definition rule), so a host can list them once and then work the
453+ * news out a few at a time, each in its own read (abso 714: one read over every draft reset prod abso's object).
454+ */
455+export function owedAgents(host: NewsHost, owed: OwedDefinitionNews): string[] {
456+ const space = host.spaceNamed(owed.space);
457+ if (!space || owed.version > last(space) || !space.versions[owed.version]) return [];
458+ return [...host.agents.values()]
459+ .toSorted((a, b) => (a.name < b.name ? -1 : 1))
460+ .filter((agent) => owedTo(host, owed, space, agent))
461+ .map((agent) => agent.name);
462+}
464+function owedTo(host: NewsHost, owed: OwedDefinitionNews, space: Space, agent: AgentState): boolean {
465+ if (agent.name === owed.publisher || agent.space !== space.name || agent.base >= owed.version) return false;
466+ return host.draft(agent).length > 0;
467+}
--- a/worker/project/project.ts
+++ b/worker/project/project.ts
@@ -106,6 +106,7 @@
106106 definitionNewsOwed as hostedDefinitionNewsOwed,
107107 newsAboutOwnDraft as hostedNewsAboutOwnDraft,
108108 newsForOthers as hostedNewsForOthers,
109+ owedAgents as hostedOwedAgents,
109110 markedItem,
110111 type NewsHost,
111112 type NewsItem,
@@ -1352,11 +1353,16 @@
13521353 return owed;
13531354 }
13541355
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);
1356+ /** What a publish owes, worked out against its version (news.ts definitionNewsOwed), for `only` these agents if given. Reads only. */
1357+ definitionNewsOwed(owed: OwedDefinitionNews, only?: readonly string[]): { agent: string; items: NewsItem[] }[] {
1358+ return hostedDefinitionNewsOwed(this.#newsHost, owed, only);
13581359 }
13591360
1361+ /** The agents a publish's owed news may be for (news.ts owedAgents). Reads only. */
1362+ owedAgents(owed: OwedDefinitionNews): string[] {
1363+ return hostedOwedAgents(this.#newsHost, owed);
1364+ }
13601366 /** Tells each agent its owed items, as queueNews does: what an agent was already told adds nothing. */
13611367 deliverOwedNews(found: readonly { agent: string; items: readonly NewsItem[] }[]): number {
13621368 const entries: Entry[] = [];
--- a/worker/project/test/owed-definition-news.test.ts
+++ b/worker/project/test/owed-definition-news.test.ts
@@ -128,3 +128,20 @@
128128 assert.deepEqual(told.takeOwedDefinitionNews(), []);
129129 assert.equal(definitionNews(told.news("bob").news).length, 1);
130130});
132+test("owedAgents lists who may be owed, and the news one agent at a time adds up to the whole (abso 714)", () => {
133+ const owing = new Project(new MemoryStore());
134+ owing.owesDefinitionNews = true;
135+ drafts(owing);
136+ owing.publish("ann", "parsePattern takes flags", 4);
137+ const [owed] = owing.takeOwedDefinitionNews();
138+ assert.deepEqual(owing.owedAgents(owed!), ["bob", "cat"], "every other agent behind it with a draft");
139+ const whole = owing.definitionNewsOwed(owed!);
140+ assert.equal(whole.length, 1);
141+ assert.deepEqual(
142+ owing.owedAgents(owed!).flatMap((agent) => owing.definitionNewsOwed(owed!, [agent])),
143+ whole,
144+ );
145+ owing.sync("bob");
146+ assert.deepEqual(owing.owedAgents(owed!), ["cat"], "synced past it");
147+});