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

Versions 2 to 318

Compare

+73 −14 in 9 places
Lines 3–19 at 318 (were 3–10 at 2)
33// which space) is applied first, in spaces.ts.
44
55import type { AtomId, Graph } from "../../src/engine/index.ts";
6+import { capNews, outlastsSync } from "./news.ts";
67import { ProjectError } from "./project-error.ts";
7−import type { AgentState, ChangeRecord, Entry, NoteRecord, QueuedPublish, Refusal } from "./project-types.ts";
8+import type {
9+ AgentState,
10+ ChangeRecord,
11+ Entry,
12+ NoteRecord,
13+ QueuedPublish,
14+ Refusal,
15+ TellRecord,
16+} from "./project-types.ts";
817import { SHARED, type Space } from "./spaces.ts";
1019/** What applying one log entry needs from a project. */
Lines 26–33 at 318 (were 17–22 at 2)
1726 readonly changes: Map<number, ChangeRecord>;
1827 readonly labels: Map<string, number[]>;
1928 readonly refusals: Refusal[];
29+ /** The newest tells, by id in the order sent, at most TELLS_KEPT. */
30+ readonly tells: Map<number, TellRecord>;
2031 uncheck(id: number): void;
2132 stamp(time: number | undefined): void;
2233 applyMembership(entry: Entry, at: number): void;
Lines 113–119 at 318 (were 102–107 at 2)
102113 }
103114 host.joinChange(agent, entry, at, space.name === SHARED ? null : space.name);
104115 agent.marked = agent.marked.filter((r) => r.space !== (entry.space ?? SHARED));
116+ delete agent.held;
105117 if (entry.queued !== undefined) host.setQueued(host.queued().filter((q) => q.id !== entry.queued));
106118 break;
107119 }
Lines 143–163 at 318 (were 131–142 at 2)
131143 const { type: _, ...note } = entry;
132144 host.notes.set(entry.id, { ...note, lines: [...entry.lines], at });
133145 host.setLastNote(Math.max(host.lastNote(), entry.id));
134− if (entry.change !== undefined && host.changes.has(entry.change)) host.changes.get(entry.change)!.last = at;
146+ if (entry.change !== undefined) {
147+ const change = host.changes.get(entry.change);
148+ if (change) {
149+ change.last = at;
150+ host.changes.set(entry.change, change);
151+ }
152+ }
135153 break;
136154 }
137155 case "note-closed": {
138156 const note = host.notes.get(entry.id);
139− if (note) note.closed = { agent: entry.agent, how: entry.how, time: entry.time };
157+ if (note) {
158+ note.closed = { agent: entry.agent, how: entry.how, time: entry.time };
159+ host.notes.set(entry.id, note);
160+ }
140161 break;
141162 }
142163 case "pulled":
Lines 194–207 at 318 (were 173–182 at 2)
173194 const agent = host.agentOf(entry.agent);
174195 agent.news.push(...entry.text);
175196 agent.newsAt.push(...entry.text.map(() => time));
176− for (const p of entry.pairs) {
197+ entry.pairs.forEach((p, i) => {
177198 agent.told.add(p);
178− if (p.startsWith("announce ")) host.setAnnounced(Math.max(host.announced(), Number(p.slice(9)) || 0));
179− }
199+ if (!p.startsWith("announce ")) return;
200+ const id = Number(p.slice(9)) || 0;
201+ host.setAnnounced(Math.max(host.announced(), id));
202+ tellSent(host.tells, id, entry.text[i] ?? entry.text[0] ?? "", agent.name, time);
203+ });
204+ capNews(agent);
180205 break;
181206 }
182207 case "discard": {
Lines 213–223 at 318 (were 188–194 at 2)
188213 }
189214 case "heard": {
190215 const agent = host.agentOf(entry.agent);
191− const keep = agent.news.map((t) => entry.stale === true && t.startsWith("Announcement from "));
216+ // A sync's stale heard keeps announcements and settles' news (outlastsSync), so it hears no tell.
217+ if (entry.stale !== true)
218+ for (const tell of host.tells.values())
219+ if (tell.heard.get(agent.name) === null) tell.heard.set(agent.name, { at: time });
220+ const keep = agent.news.map((t) => entry.stale === true && outlastsSync(t));
192221 agent.news = agent.news.filter((_, i) => keep[i]);
193222 agent.newsAt = agent.newsAt.filter((_, i) => keep[i]);
194223 break;
Lines 246–274 at 318 (were 217–238 at 2)
217246 via: entry.via,
218247 time: entry.time,
219248 collisions: entry.collisions.map((c) => ({ ...c })),
249+ ...(entry.message ? { message: entry.message } : {}),
220250 });
221251 {
222252 // On the change the agent was working on, when there is one (#44).
223253 const agent = host.agentOf(entry.agent);
224254 host.active(agent, entry.time);
225255 const id = host.currentChange(agent, entry.time);
256+ const refusal = {
257+ at,
258+ time: entry.time,
259+ kinds: [...new Set(entry.collisions.map((c) => c.kind))].sort(),
260+ files: [...new Set(entry.collisions.map((c) => c.file))].sort(),
261+ ...(entry.message ? { message: entry.message } : {}),
262+ };
226263 if (id !== undefined) {
227264 const rec = host.changeRecord(id, agent, entry.time);
228− rec.refusals.push({
229− at,
230− time: entry.time,
231− kinds: [...new Set(entry.collisions.map((c) => c.kind))].sort(),
232− files: [...new Set(entry.collisions.map((c) => c.file))].sort(),
233− });
265+ rec.refusals.push({ ...refusal, files: [...refusal.files], kinds: [...refusal.kinds] });
234266 rec.last = at;
267+ host.changes.set(id, rec);
235268 }
269+ // Kept until it pushes: the settle tells the held push's reason, and its change lists the refusal.
270+ if (entry.via === "publish")
271+ agent.held = [...(agent.held ?? []), { ...refusal, ...(id !== undefined ? { change: id } : {}) }];
236272 }
237273 break;
238274 case "switch": {
Lines 299–305 at 318 (were 263–269 at 2)
263299 default: {
264300 // A kind this engine doesn't know was written by a newer one. Skipping
265301 // it would show, and then build on, a project without that entry, so
266− // the load stops instead (AVCS - Git Lessons, report 8.3).
302+ // the load stops instead.
267303 const kind = (entry as { type?: unknown }).type;
268304 throw new ProjectError(
269305 "unknown-entry",
Lines 308–333 at 318 (were 272–274 at 2)
272308 }
273309 }
274310}
312+/** How many tells the project keeps who-heard-what for (status's tells). */
313+export const TELLS_KEPT = 50;
315+/** A tell's news reached one recipient's queue: the tell is kept, the oldest dropped past TELLS_KEPT. */
316+function tellSent(
317+ tells: Map<number, TellRecord>,
318+ id: number,
319+ text: string,
320+ agent: string,
321+ time: number | undefined,
322+): void {
323+ let tell = tells.get(id);
324+ if (tell === undefined) {
325+ tell = { id, text, at: time, heard: new Map() };
326+ tells.set(id, tell);
327+ for (const old of tells.keys()) {
328+ if (tells.size <= TELLS_KEPT) break;
329+ tells.delete(old);
330+ }
331+ }
332+ if (!tell.heard.has(agent)) tell.heard.set(agent, null);
333+}
MCP
compare on this site's /mcp
CLI
abso diff 2 318 worker/project/apply-entry.ts --json
JSON
/christopher/abso-core/compare/2..318?file=worker%2Fproject%2Fapply-entry.ts&format=json