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

status lists the newest tells and who has heard each: every recipient, with the time its client handed the tell over (or not yet). It's read from the news and heard entries the log already keeps, so nothing new is recorded. Unlike announcements, which lists only what is still undelivered, a tell stays listed once heard, and two tells with the same words stay two. The last 50 are kept. A sync's reset hears no tell. Tests in worker/project/test/tells.test.ts.

of shared·pinch··Not checked

Version 30 · Files at version 31

5 files, 161 lines added, 5 removed.

--- a/worker/project/apply-entry.ts
+++ b/worker/project/apply-entry.ts
@@ -4,7 +4,15 @@
44
55import type { AtomId, Graph } from "../../src/engine/index.ts";
66import { ProjectError } from "./project-error.ts";
7−import type { AgentState, ChangeRecord, Entry, NoteRecord, QueuedPublish, Refusal } from "./project-types.ts";
7+import type {
8+ AgentState,
9+ ChangeRecord,
10+ Entry,
11+ NoteRecord,
12+ QueuedPublish,
13+ Refusal,
14+ TellRecord,
15+} from "./project-types.ts";
816import { SHARED, type Space } from "./spaces.ts";
1018/** What applying one log entry needs from a project. */
@@ -17,6 +25,8 @@
1725 readonly changes: Map<number, ChangeRecord>;
1826 readonly labels: Map<string, number[]>;
1927 readonly refusals: Refusal[];
28+ /** The newest tells, by id in the order sent, at most TELLS_KEPT. */
29+ readonly tells: Map<number, TellRecord>;
2030 uncheck(id: number): void;
2131 stamp(time: number | undefined): void;
2232 applyMembership(entry: Entry, at: number): void;
@@ -173,10 +183,13 @@
173183 const agent = host.agentOf(entry.agent);
174184 agent.news.push(...entry.text);
175185 agent.newsAt.push(...entry.text.map(() => time));
176− for (const p of entry.pairs) {
186+ entry.pairs.forEach((p, i) => {
177187 agent.told.add(p);
178− if (p.startsWith("announce ")) host.setAnnounced(Math.max(host.announced(), Number(p.slice(9)) || 0));
179− }
188+ if (!p.startsWith("announce ")) return;
189+ const id = Number(p.slice(9)) || 0;
190+ host.setAnnounced(Math.max(host.announced(), id));
191+ tellSent(host.tells, id, entry.text[i] ?? entry.text[0] ?? "", agent.name, time);
192+ });
180193 break;
181194 }
182195 case "discard": {
@@ -188,6 +201,10 @@
188201 }
189202 case "heard": {
190203 const agent = host.agentOf(entry.agent);
204+ // A sync's stale heard keeps announcements, so it hears no tell.
205+ if (entry.stale !== true)
206+ for (const tell of host.tells.values())
207+ if (tell.heard.get(agent.name) === null) tell.heard.set(agent.name, { at: time });
191208 const keep = agent.news.map((t) => entry.stale === true && t.startsWith("Announcement from "));
192209 agent.news = agent.news.filter((_, i) => keep[i]);
193210 agent.newsAt = agent.newsAt.filter((_, i) => keep[i]);
@@ -272,3 +289,26 @@
272289 }
273290 }
274291}
293+/** How many tells the project keeps who-heard-what for (status's tells). */
294+export const TELLS_KEPT = 50;
296+/** A tell's news reached one recipient's queue: the tell is kept, the oldest dropped past TELLS_KEPT. */
297+function tellSent(
298+ tells: Map<number, TellRecord>,
299+ id: number,
300+ text: string,
301+ agent: string,
302+ time: number | undefined,
303+): void {
304+ let tell = tells.get(id);
305+ if (tell === undefined) {
306+ tell = { id, text, at: time, heard: new Map() };
307+ tells.set(id, tell);
308+ for (const old of tells.keys()) {
309+ if (tells.size <= TELLS_KEPT) break;
310+ tells.delete(old);
311+ }
312+ }
313+ if (!tell.heard.has(agent)) tell.heard.set(agent, null);
314+}
--- a/worker/project/project-status.ts
+++ b/worker/project/project-status.ts
@@ -4,7 +4,16 @@
44import type { AtomId, View } from "../../src/engine/index.ts";
55import { ProjectError } from "./project-error.ts";
66import { countRefusals, type projectFileIn } from "./project-helpers.ts";
7−import type { AgentState, AgentStatus, EditsVia, Refusal, Starting, StatusAnswer } from "./project-types.ts";
7+import type {
8+ AgentState,
9+ AgentStatus,
10+ EditsVia,
11+ Refusal,
12+ Starting,
13+ StatusAnswer,
14+ TellRecord,
15+ TellStatus,
16+} from "./project-types.ts";
817import { last, SHARED, type Space, sharedBaseOf } from "./spaces.ts";
1019/** What the snapshot reads need from a project. */
@@ -14,6 +23,7 @@
1423 queue(): readonly { readonly agent: string; readonly id: number }[];
1524 readonly refusals: readonly Refusal[];
1625 readonly labels: ReadonlyMap<string, readonly number[]>;
26+ readonly tells: ReadonlyMap<number, TellRecord>;
1727 needInit(): void;
1828 shared(): Space;
1929 draft(agent: AgentState): AtomId[];
@@ -145,6 +155,15 @@
145155 }
146156 }
147157 const announcements = [...waiting].map(([text, names]) => ({ text, waiting: names }));
158+ // Who has heard each of the newest tells, and when (277): the news and heard entries' times.
159+ const tells: TellStatus[] = [...host.tells.values()].toReversed().map((t) => ({
160+ id: t.id,
161+ text: t.text,
162+ at: t.at ?? null,
163+ to: [...t.heard]
164+ .toSorted(([a], [b]) => (a < b ? -1 : 1))
165+ .map(([agent, h]) => ({ agent, heard: h !== null, at: h?.at ?? null })),
166+ }));
148167 // Both project files in shared (224): say which one counts, never quietly.
149168 const file = host.projectFile();
150169 return {
@@ -153,6 +172,7 @@
153172 drafts,
154173 refusals: countRefusals(host.refusals),
155174 announcements,
175+ tells,
156176 ...(file?.ignored ? { projectFile: { used: "abso.json" as const, ignored: file.ignored } } : {}),
157177 };
158178}
--- a/worker/project/project-types.ts
+++ b/worker/project/project-types.ts
@@ -504,6 +504,22 @@
504504 changes: number;
505505 agents: string[];
506506}
507+/**
508+ * One tell as the log has it: the sentence its recipients get, when it was sent, and for each recipient when its
509+ * client handed it over (a heard entry), null until then. A time is undefined for entries from before they had one.
510+ */
511+export interface TellRecord {
512+ readonly id: number;
513+ text: string;
514+ at: number | undefined;
515+ readonly heard: Map<string, { at: number | undefined } | null>;
516+}
517+export interface TellStatus {
518+ id: number;
519+ text: string;
520+ at: number | null;
521+ to: { agent: string; heard: boolean; at: number | null }[];
522+}
507523export type StatusAnswer = {
508524 version: number;
509525 agents: AgentStatus[];
@@ -511,6 +527,8 @@
511527 refusals: RefusalCounts;
512528 /** Announcements some agent hasn't received yet, oldest first. */
513529 announcements: { text: string; waiting: string[] }[];
530+ /** The newest tells (TELLS_KEPT), newest first: each recipient, and when it heard (null: not yet). */
531+ tells: TellStatus[];
514532 /** Only when shared has both abso.json and avcs.json (224): abso.json counts and avcs.json is ignored. */
515533 projectFile?: { used: "abso.json"; ignored: "avcs.json" };
516534};
--- a/worker/project/project.ts
+++ b/worker/project/project.ts
@@ -157,6 +157,7 @@
157157 Starting,
158158 SwitchAnswer,
159159 Tail,
160+ TellRecord,
160161} from "./project-types.ts";
161162import { publish as hostedPublish, publishDraft as hostedPublishDraft, type PublishHost } from "./publish.ts";
162163import { publishOf as hostedPublishOf, type PublishOfHost } from "./publish-of.ts";
@@ -237,6 +238,8 @@
237238 readonly #refusals: Refusal[] = [];
238239 /** Labels on shared's versions: name -> versions, ascending. */
239240 readonly #labels = new Map<string, number[]>();
241+ /** The newest tells and who has heard each (apply-entry.ts). */
242+ readonly #tells = new Map<number, TellRecord>();
240243 /**
241244 * Entries applied but not stored yet, in order. Every applied entry is
242245 * stored at the next flush, even when the call that applied it threw
@@ -1738,6 +1741,7 @@
17381741 changes: this.#changes,
17391742 labels: this.#labels,
17401743 refusals: this.#refusals,
1744+ tells: this.#tells,
17411745 uncheck: (id) => {
17421746 this.#checking.delete(id);
17431747 },
@@ -2137,6 +2141,7 @@
21372141 queue: () => this.#queue,
21382142 refusals: this.#refusals,
21392143 labels: this.#labels,
2144+ tells: this.#tells,
21402145 needInit: () => this.#needInit(),
21412146 shared: () => this.#shared,
21422147 draft: (agent) => this.#draft(agent),
--- /dev/null
+++ b/worker/project/test/tells.test.ts
@@ -0,0 +1,73 @@
1+// Who has heard a tell, and when: status's tells, read from the news and heard
2+// entries the log already keeps, so a page can show each recipient's mark fill.
3+
4+import assert from "node:assert/strict";
5+import { test } from "node:test";
6+import { TELLS_KEPT } from "../apply-entry.ts";
7+import { MemoryStore, Project } from "../project.ts";
8+
9+function setup() {
10+ const store = new MemoryStore();
11+ const project = new Project(store);
12+ project.init({ "a.ts": "x\n" }, 0);
13+ for (const a of ["lead", "b1", "b2"]) project.sync(a);
14+ return { project, store };
15+}
17+test("a tell lists each recipient, and marks one heard when its news is handed over, with the time", () => {
18+ const { project, store } = setup();
19+ const before = Date.now();
20+ const sent = project.announce("lead", "Stand-up soon.", ["b1", "b2"], 1);
21+ let tell = project.status().tells[0]!;
22+ assert.equal(tell.id, sent.id);
23+ assert.equal(tell.text, "Announcement from lead (as claimed): Stand-up soon.");
24+ assert.ok(tell.at !== null && tell.at >= before);
25+ assert.deepEqual(
26+ tell.to.map((t) => [t.agent, t.heard]),
27+ [
28+ ["b1", false],
29+ ["b2", false],
30+ ],
31+ );
32+ assert.deepEqual(project.news("b1").news, ["Announcement from lead (as claimed): Stand-up soon."]);
33+ tell = project.status().tells[0]!;
34+ const b1 = tell.to.find((t) => t.agent === "b1")!;
35+ assert.equal(b1.heard, true);
36+ assert.ok(b1.at !== null && b1.at >= tell.at!);
37+ assert.deepEqual(
38+ tell.to.find((t) => t.agent === "b2"),
39+ { agent: "b2", heard: false, at: null },
40+ );
41+ // Heard tells stay listed (announcements lists only what's undelivered), and the log loads back the same.
42+ assert.deepEqual(project.status().announcements[0]!.waiting, ["b2"]);
43+ assert.deepEqual(Project.load(store.entries, new MemoryStore()).status().tells, project.status().tells);
44+});
46+test("a sync's reset hears no tell, two tells with the same words stay two, and only the newest are kept", () => {
47+ const { project } = setup();
48+ project.announce("lead", "Same words.", ["b1"], 1);
49+ project.announce("lead", "Same words.", ["b1"], 2);
50+ project.sync("b1");
51+ const tells = project.status().tells;
52+ assert.equal(tells.length, 2);
53+ assert.ok(tells[0]!.id > tells[1]!.id, "newest first");
54+ assert.ok(
55+ tells.every((t) => !t.to[0]!.heard),
56+ "a sync keeps announcements, so nothing is heard",
57+ );
58+ for (let i = 0; i < TELLS_KEPT + 3; i++) project.announce("lead", `Tell ${i}.`, ["b2"], 3 + i);
59+ const kept = project.status().tells;
60+ assert.equal(kept.length, TELLS_KEPT);
61+ assert.match(kept[0]!.text, new RegExp(`Tell ${TELLS_KEPT + 2}\.$`));
62+});
64+test("a person's tell is kept like an agent's", () => {
65+ const { project } = setup();
66+ project.announcePerson({ id: "cf-1", name: "Robin" }, "From the website.", ["b2"], 5);
67+ const tell = project.status().tells[0]!;
68+ assert.equal(tell.at, 5);
69+ assert.deepEqual(
70+ tell.to.map((t) => t.agent),
71+ ["b2"],
72+ );
73+});