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
code on this site's /mcp
CLI
none: the JSON below is the answer
JSON
/christopher/abso-core/files/worker/project/test/tells.test.ts?version=78&format=json
73 linespinch 100%Last change pinch in version 78, 2 versions changed it

You're reading version 78. The newest is 318, and 1 version since then changed this file. Go to the newestCompare with 318

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
4import assert from "node:assert/strict";
5import { test } from "node:test";
6import { TELLS_KEPT } from "../apply-entry.ts";
7import { MemoryStore, Project } from "../project.ts";
8
9function 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 };
17test("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});
46test("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});
64test("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});