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. Version 31 of shared· pinch· Oct 9 (2026-10-09 10:21 UTC) · 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 @@
5 5 import type { AtomId, Graph } from "../../src/engine/index.ts"; 6 6 import { ProjectError } from "./project-error.ts"; 7 − import type { AgentState, ChangeRecord, Entry, NoteRecord, QueuedPublish, Refusal } from "./project-types.ts";
15 + } from "./project-types.ts"; 8 16 import { SHARED, type Space } from "./spaces.ts"; 10 18 /** What applying one log entry needs from a project. */ @@ -17,6 +25,8 @@
17 25 readonly changes: Map<number, ChangeRecord>; 18 26 readonly labels: Map<string, number[]>; 19 27 readonly refusals: Refusal[]; 28 + /** The newest tells, by id in the order sent, at most TELLS_KEPT. */ 29 + readonly tells: Map<number, TellRecord>; 20 30 uncheck(id: number): void; 21 31 stamp(time: number | undefined): void; 22 32 applyMembership(entry: Entry, at: number): void; @@ -173,10 +183,13 @@
173 183 const agent = host.agentOf(entry.agent); 174 184 agent.news.push(...entry.text); 175 185 agent.newsAt.push(...entry.text.map(() => time)); 176 − for (const p of entry.pairs) {
186 + entry.pairs.forEach((p, i) => { 177 187 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); @@ -188,6 +201,10 @@
190 203 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 }); 191 208 const keep = agent.news.map((t) => entry.stale === true && t.startsWith("Announcement from ")); 192 209 agent.news = agent.news.filter((_, i) => keep[i]); 193 210 agent.newsAt = agent.newsAt.filter((_, i) => keep[i]); @@ -272,3 +289,26 @@
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. */ 298 + tells: Map<number, TellRecord>, 302 + time: number | undefined, 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; 313 + if (!tell.heard.has(agent)) tell.heard.set(agent, null); --- a/worker/project/project-status.ts
+++ b/worker/project/project-status.ts
@@ -4,7 +4,16 @@
4 4 import type { AtomId, View } from "../../src/engine/index.ts"; 5 5 import { ProjectError } from "./project-error.ts"; 6 6 import { countRefusals, type projectFileIn } from "./project-helpers.ts"; 7 − import type { AgentState, AgentStatus, EditsVia, Refusal, Starting, StatusAnswer } from "./project-types.ts";
16 + } from "./project-types.ts"; 8 17 import { last, SHARED, type Space, sharedBaseOf } from "./spaces.ts"; 10 19 /** What the snapshot reads need from a project. */ @@ -14,6 +23,7 @@
14 23 queue(): readonly { readonly agent: string; readonly id: number }[]; 15 24 readonly refusals: readonly Refusal[]; 16 25 readonly labels: ReadonlyMap<string, readonly number[]>; 26 + readonly tells: ReadonlyMap<number, TellRecord>; 19 29 draft(agent: AgentState): AtomId[]; @@ -145,6 +155,15 @@
147 157 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) => ({ 164 + .toSorted(([a], [b]) => (a < b ? -1 : 1)) 165 + .map(([agent, h]) => ({ agent, heard: h !== null, at: h?.at ?? null })), 148 167 // Both project files in shared (224): say which one counts, never quietly. 149 168 const file = host.projectFile(); @@ -153,6 +172,7 @@
154 173 refusals: countRefusals(host.refusals), 156 176 ...(file?.ignored ? { projectFile: { used: "abso.json" as const, ignored: file.ignored } } : {}), --- a/worker/project/project-types.ts
+++ b/worker/project/project-types.ts
@@ -504,6 +504,22 @@
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. 511 + export interface TellRecord { 512 + readonly id: number; 514 + at: number | undefined; 515 + readonly heard: Map<string, { at: number | undefined } | null>; 517 + export interface TellStatus { 521 + to: { agent: string; heard: boolean; at: number | null }[]; 507 523 export type StatusAnswer = { 509 525 agents: AgentStatus[]; @@ -511,6 +527,8 @@
511 527 refusals: RefusalCounts; 512 528 /** Announcements some agent hasn't received yet, oldest first. */ 513 529 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[]; 514 532 /** Only when shared has both abso.json and avcs.json (224): abso.json counts and avcs.json is ignored. */ 515 533 projectFile?: { used: "abso.json"; ignored: "avcs.json" }; --- a/worker/project/project.ts
+++ b/worker/project/project.ts
@@ -157,6 +157,7 @@
160 161 } from "./project-types.ts"; 161 162 import { publish as hostedPublish, publishDraft as hostedPublishDraft, type PublishHost } from "./publish.ts"; 162 163 import { publishOf as hostedPublishOf, type PublishOfHost } from "./publish-of.ts"; @@ -237,6 +238,8 @@
237 238 readonly #refusals: Refusal[] = []; 238 239 /** Labels on shared's versions: name -> versions, ascending. */ 239 240 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>(); 241 244 * Entries applied but not stored yet, in order. Every applied entry is 242 245 * stored at the next flush, even when the call that applied it threw @@ -1738,6 +1741,7 @@
1738 1741 changes: this.#changes, 1739 1742 labels: this.#labels, 1740 1743 refusals: this.#refusals, 1744 + tells: this.#tells, 1741 1745 uncheck: (id) => { 1742 1746 this.#checking.delete(id); @@ -2137,6 +2141,7 @@
2137 2141 queue: () => this.#queue, 2138 2142 refusals: this.#refusals, 2139 2143 labels: this.#labels, 2144 + tells: this.#tells, 2140 2145 needInit: () => this.#needInit(), 2141 2146 shared: () => this.#shared, 2142 2147 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. 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"; 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 }; 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); 26 + tell.to.map((t) => [t.agent, t.heard]), 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!); 38 + tell.to.find((t) => t.agent === "b2"), 39 + { agent: "b2", heard: false, at: null }, 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); 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); 51 + const tells = project.status().tells; 52 + assert.equal(tells.length, 2); 53 + assert.ok(tells[0]!.id > tells[1]!.id, "newest first"); 55 + tells.every((t) => !t.to[0]!.heard), 56 + "a sync keeps announcements, so nothing is heard", 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}\.$`)); 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); 70 + tell.to.map((t) => t.agent),