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 286 --json
JSON
/christopher/abso-core/versions/286?format=json

Log a line as a publish's news for other agents starts and ends (abso 702), through a new logLine option; nothing is written until a host passes it

of shared·df-routing··Not checked

Version 285 · Files at version 286

4 files, 95 lines added, 5 removed.

--- a/worker/project/news.ts
+++ b/worker/project/news.ts
@@ -255,6 +255,8 @@
255255 names?: ReadonlySet<string>,
256256 ): DefinitionCollision[];
257257 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;
258260}
259261
260262function lineNews(host: NewsHost, agent: AgentState, pairs: readonly Pair[]): NewsItem[] {
@@ -331,8 +333,14 @@
331333 // 2026-10-15): it compared definitions in every file changed since each agent's base, for every agent with a draft,
332334 // and a publish touching abso's worker/src/index.ts took 48 s of it.
333335 let changedNames: ReadonlySet<string> | undefined;
336+ // For the host's logs (abso 702): a line as the work starts, written before it, and one as it ends, so work that
337+ // outlives its request still shows. No time in them: a Durable Object's clock stands still in synchronous code.
338+ let drafts = 0;
339+ let files = 0;
340+ let news = 0;
334341 const compareDefinitions = (): ReadonlySet<string> => {
335342 const touched = touchedFiles(host.graph, just, [host.viewAt(space, version - 1), host.viewAt(space, last(space))]);
343+ files = touched.size;
336344 const before = definitionsIn(host.viewAt(space, version - 1), touched);
337345 const after = definitionsIn(host.viewAt(space, last(space)), touched);
338346 return new Set(
@@ -345,16 +353,28 @@
345353 if (agent === publisher || agent.space !== space.name) continue;
346354 const draft = host.draft(agent);
347355 if (draft.length === 0) continue;
356+ if (drafts++ === 0)
357+ host.logLine?.({ work: "publishNews", step: "start", space: space.name, version, publisher: publisher.name });
348358 const lines = pairsIn(host.graph, draft, just, unionOverlay(host.setOf(space), draft));
349359 changedNames ??= compareDefinitions();
350360 const defs =
351361 changedNames.size > 0
352362 ? host.definitionCollisions(agent, host.newerFor(agent), changedNames).filter((d) => just.has(d.by))
353363 : [];
354− host.queueNews(
355− agent,
356− [...lineNews(host, agent, lines), ...definitionNews(defs), ...moveNews(host, draft, just, space, version)],
357− entries,
358− );
364+ const items = [...lineNews(host, agent, lines), ...definitionNews(defs), ...moveNews(host, draft, just, space, version)];
365+ news += items.length;
366+ host.queueNews(agent, items, entries);
359367 }
368+ if (drafts > 0)
369+ host.logLine?.({
370+ work: "publishNews",
371+ step: "end",
372+ space: space.name,
373+ version,
374+ publisher: publisher.name,
375+ drafts,
376+ files,
377+ changedNames: changedNames?.size ?? 0,
378+ news,
379+ });
360380}
--- a/worker/project/project-types.ts
+++ b/worker/project/project-types.ts
@@ -624,6 +624,12 @@
624624 * recent. Without it, all text stays in memory.
625625 */
626626 entryAt?: (at: number) => Entry;
627+ /**
628+ * One line for the host's logs about long work inside an operation (abso
629+ * 702): written as the work starts and again when it ends, so work that
630+ * outlives its request still shows. Without it, nothing is written.
631+ */
632+ logLine?: (line: Record<string, string | number>) => void;
627633}
628634export interface LogEntry {
629635 version: number;
--- a/worker/project/project.ts
+++ b/worker/project/project.ts
@@ -332,6 +332,7 @@
332332 readonly #now: (() => number) | undefined;
333333 readonly #whole: ProjectOptions["whole"];
334334 readonly #shapes: ProjectOptions["shapes"];
335+ readonly #logLine: ProjectOptions["logLine"];
335336 /** For each log position, the newest time up to it (#41): time to position in one search. */
336337 readonly #timeAt: number[] = [];
337338 /** For each version of shared, the log position of the entry that made it (#41). */
@@ -453,6 +454,7 @@
453454 this.#now = options.now;
454455 this.#whole = options.whole;
455456 this.#shapes = options.shapes;
457+ this.#logLine = options.logLine;
456458 // For tests (#46): AVCS_TEXT_FROM_LOG=1 runs a project on a MemoryStore with its text read back from the store.
457459 const testing =
458460 (globalThis as { process?: { env?: Record<string, string | undefined> } }).process?.env?.AVCS_TEXT_FROM_LOG ===
@@ -2107,6 +2109,7 @@
21072109 collision: (agent, pair) => this.#collision(agent, pair),
21082110 definitionCollisions: (agent, newer, names) => this.#definitionCollisions(agent, newer, names),
21092111 queueNews: (agent, items, entries) => this.#queueNews(agent, items, entries),
2112+ logLine: (line) => this.#logLine?.(line),
21102113 };
21112114 return this.#news;
21122115 }
--- /dev/null
+++ b/worker/project/test/news-lines.test.ts
@@ -0,0 +1,61 @@
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]!.files, 1);
41+ assert.equal(news[1]!.changedNames, 1);
42+ assert.equal(news[1]!.news, 1);
43+});
45+test("a publish with nobody else drafting writes nothing", () => {
46+ const lines: Record<string, string | number>[] = [];
47+ const project = setup(lines);
48+ project.edit("lib", { file: "src/parse.ts", old: " return text;\n", new: " return text.trim();\n" }, 1);
49+ assert.equal(project.publish("lib", "trim", 2).ok, true);
50+ assert.deepEqual(lines, []);
51+});
53+test("without a logLine option, a publish still works", () => {
54+ const project = new Project(new MemoryStore());
55+ project.init(START, 0);
56+ project.sync("lib");
57+ project.sync("user");
58+ project.edit("user", { file: "src/match.ts", old: " return p;\n", new: " return parsePattern(p);\n" }, 1);
59+ project.edit("lib", { file: "src/parse.ts", old: " return text;\n", new: " return text.trim();\n" }, 2);
60+ assert.equal(project.publish("lib", "trim", 3).ok, true);
61+});