- MCP
- blame on this site's /mcp
- CLI
- abso blame worker/project/version-log.ts --json
- JSON
- /christopher/abso-core/blame/worker/project/version-log.ts?format=json
347 linesFirst import 74% · capacity 20% · codex-capacity-chair 6%Last change capacity in version 313,
347 lines from 8 changes in 8 versions.
codex-capacity-chair143Add inactive disk projection provider and verified transactional readers (#16)Compare1import { View } from "../../src/engine/index.ts";
init0Start the project2// The version list reads: log (versions newest first, or one file's history), ribbon (who published each version),
3// show (one version's changes), fileAt, compare and viewAt. They read through LogHost; today the host is the project
4// in memory.
codex-capacity-chair143Add inactive disk projection provider and verified transactional readers (#16)Compare6import type { AtomId, Graph, ReadView } from "../../src/engine/index.ts";
8import type { PathIndex } from "./pathindex.ts";
9import { ProjectError } from "./project-error.ts";
10import type { FileChange, LogAnswer, LogEntry, ShowAnswer } from "./project-types.ts";
11import { last, SHARED, type Space } from "./spaces.ts";
capacity243compare's summary: each changed file's size and SHA-256 instead of its texts (abso issue 680; disk-first 2; abso Capacity).
compare 612 to 1224 on abso answers 13.2 MB: the full before and after text of about 3,000 changed files. Read Speed's shape lets the site ask for a summary and fetch a file's texts when it opens it.
- view-changes.ts summariesBetween: the files changesBetween would list, each side as {size, sha256} for text (UTF-8 bytes, SHA-256 of the text), {blob} for a binary file (its hash; the Worker adds its size from the blob store), or null when absent; mode and blob as in the full answer. Each text is read, summed up and let go.
- version-log compare takes summary and answers {from, to, summary: true, files}. ProjectHistory.compare and both engine-project.ts implementations take a fifth argument, summary; http.ts passes ?summary=1. The full answer is unchanged.
On abso adopted fresh: the summary for 612 to 1224 is 174 KB instead of 13.2 MB, with heap after at 38 MB. The time is the same (about 20 s cold): it still lays the files out to hash them. Stored per-version sizes and hashes would remove that; they're proposed with the author totals table.
New test compare-summary: on an in-memory and a writer-backed project, the summary lists the files the full compare does, with sizes and SHA-256s of its texts, blob hashes for a binary file, and no text. Every engine test (292 of 292), every worker/project test (342 of 342); tsc (worker and server) and biome clean.Compare12import { changesBetween, summariesBetween } from "./view-changes.ts";
14/** What the version list reads need from a project. */
15export interface LogHost {
16 readonly graph: Graph;
17 readonly paths: Pick<PathIndex, "knowsFiles" | "versionFiles" | "versionShape">;
18 readonly labels: ReadonlyMap<string, readonly number[]>;
19 shared(): Space;
20 needInit(): void;
21 spaceFor(options: { draft?: string | null; agent?: string }): Space;
22 checkVersion(space: Space, version: number): void;
codex-capacity-chair143Add inactive disk projection provider and verified transactional readers (#16)Compare23 viewAt(space: Space, version: number): ReadView;
24 view(set: ReadonlySet<AtomId>): ReadView;
codex-capacity-chair143Add inactive disk projection provider and verified transactional readers (#16)Compare26 spellingIn(view: ReadView, path: string): string;
codex-capacity-chair143Add inactive disk projection provider and verified transactional readers (#16)Compare28 touchedFiles(ids: Iterable<AtomId>, views: readonly ReadView[]): Set<string>;
31/**
32 * The versions of shared (or of a named draft), newest first: who
33 * published each, why, and which files it touched. `limit` defaults to 50.
34 */
35export function log(
36 host: LogHost,
37 options: {
38 draft?: string | null;
39 agent?: string;
40 limit?: number;
41 path?: string;
42 before?: number;
43 follow?: boolean;
44 } = {},
45): LogAnswer {
46 host.needInit();
47 const space = host.spaceFor(options);
48 const limit = Number.isInteger(options.limit) && options.limit! > 0 ? Math.min(options.limit!, 200) : 50;
49 if (options.path !== undefined) checkReadPath(options.path);
50 if (options.before !== undefined && (!Number.isInteger(options.before) || options.before < 0))
51 throw new ProjectError("bad-request", "before must be a version number");
52 const versions: LogEntry[] = [];
53 // Paging (#41, the website): `before` starts the page below that version; `next` is the `before` for the page after.
54 let v = Math.min(last(space), (options.before ?? last(space) + 1) - 1);
55 // Any spelling reads the stored one (#41, F7). With follow, the history follows moves (F27): before
56 // the version that moved the file in, it's the file it came from.
57 const path = options.path === undefined ? undefined : host.spellingIn(host.viewAt(space, last(space)), options.path);
58 const names = path === undefined ? [] : options.follow ? namesBefore(host, space, path) : [{ path, since: 0 }];
59 const nameAt = (version: number): string => names.find((n) => version >= n.since)?.path ?? path!;
60 // A file's history (#43): only versions whose changes name the file, or a file moves can carry lines from, can have changed it.
61 const sources = path === undefined ? undefined : new Set(names.flatMap((n) => [...moveSources(host.graph, n.path)]));
62 const g = host.graph;
codex-capacity-chair143Add inactive disk projection provider and verified transactional readers (#16)Compare63 const views = new Map<number, ReadView>();
65 if (sources && !host.paths.knowsFiles(space, v)) {
66 const p = space.versions[v]!;
67 if (![...p.atoms, ...(p.dropped ?? [])].some((id) => g.filesOf(id).some((f) => sources.has(f)))) continue;
68 }
capacity254A file's history checks each version's files before building its entry (abso Capacity, issue 664).
log with a path built the full entry of every version it walked (every atom of the version read, to count its changes) and only then checked whether the version changed the file: down to the file's twentieth change that was 367 versions on abso. It now checks the version's files first (the same versionFiles the entry uses, kept by the path index) and builds entries only for the versions it lists. Same answers.
On a fresh abso adoption (my machine): log for issues/src/index.ts, 20 entries, 108 ms first and 17 ms again (was about 0.45 s again). A full run matches 33 of 33 answers. All of worker/project/test pass (349).Compare69 // With a path: only the versions that changed that file (its history), under its name then. Their files first, and
70 // the whole entry (every atom of the version read) only for those (abso Capacity): a file's history read every
71 // version's atoms down to its twentieth change.
72 if (path !== undefined && !host.paths.versionFiles(space, v, views).includes(nameAt(v))) {
73 views.delete(v + 1);
74 continue;
75 }
77 // The walk goes down: a view above this version won't be needed again (#46).
78 views.delete(v + 1);
79 if (path === undefined) versions.push(entry);
capacity254A file's history checks each version's files before building its entry (abso Capacity, issue 664).
log with a path built the full entry of every version it walked (every atom of the version read, to count its changes) and only then checked whether the version changed the file: down to the file's twentieth change that was 367 versions on abso. It now checks the version's files first (the same versionFiles the entry uses, kept by the path index) and builds entries only for the versions it lists. Same answers.
On a fresh abso adoption (my machine): log for issues/src/index.ts, 20 entries, 108 ms first and 17 ms again (was about 0.45 s again). A full run matches 33 of 33 answers. All of worker/project/test pass (349).Compare80 else versions.push(nameAt(v) === path ? entry : { ...entry, path: nameAt(v) });
82 const next = v >= 0 && versions.length > 0 ? versions[versions.length - 1]!.version : undefined;
83 const movedFrom = names.slice(0, -1).map((n, i) => ({ path: names[i + 1]!.path, version: n.since }));
84 return {
85 draft: space.name === SHARED ? null : space.name,
86 version: last(space),
87 versions,
88 ...(next !== undefined ? { next } : {}),
89 ...(path !== undefined ? { path } : {}),
90 ...(movedFrom.length > 0 ? { movedFrom } : {}),
91 };
92}
94/**
95 * A file's names back through moves (#41, F27), newest first: each with the
96 * version from which it had that name. Found from the atoms that moved lines
97 * into it (abso mv), so it never guesses from how alike two files are.
98 */
99function namesBefore(host: LogHost, space: Space, path: string): { path: string; since: number }[] {
100 const g = host.graph;
101 const out: { path: string; since: number }[] = [];
102 let cur = path;
103 let below = last(space) + 1;
104 const movers = g.movers();
105 for (;;) {
106 // The newest version below `below` that moved another file into `cur`.
107 const into = movers
108 .filter((id) => g.filesOf(id).includes(cur))
109 .map((id) => space.publishedIn.get(id))
110 .filter((v): v is number => v !== undefined && v < below)
111 .toSorted((a, b) => b - a);
112 let found: { from: string; version: number } | undefined;
113 for (const version of into) {
114 const move = host.paths.versionShape(space, version).moves.find(([, to]) => to === cur);
115 if (move) {
116 found = { from: move[0], version };
117 break;
118 }
119 }
120 out.push({ path: cur, since: found?.version ?? 0 });
121 if (!found) break;
122 cur = found.from;
123 below = found.version;
124 }
125 return out;
126}
128/**
129 * The files whose lines can be in `path` (#43): itself, and any file a move
130 * shares with one already found. A line is in a file other than the one it
131 * was written in only when a move carried it, or a line before it, there;
132 * that move names both files.
133 */
134function moveSources(g: Graph, path: string): Set<string> {
135 const out = new Set([path]);
136 const movers = g.movers().map((id) => g.filesOf(id));
137 for (let grew = true; grew; ) {
138 grew = false;
139 for (const files of movers) {
140 if (!files.some((f) => out.has(f))) continue;
141 for (const f of files) if (!out.has(f)) out.add(f), (grew = true);
142 }
143 }
144 return out;
145}
147/**
148 * Shared's versions in one small answer, for the website's version ribbon
149 * (#43): `authors[v]` indexes `agents`, which are in order of each agent's
150 * first version. No files, so it costs nothing on a long history.
151 */
152export function ribbon(host: LogHost): { version: number; agents: string[]; authors: number[] } {
153 host.needInit();
154 const shared = host.shared();
155 const agents: string[] = [];
156 const index = new Map<string, number>();
157 const authors = shared.versions.map((p) => {
158 let i = index.get(p.agent);
159 if (i === undefined) index.set(p.agent, (i = agents.push(p.agent) - 1));
160 return i;
161 });
162 return { version: last(shared), agents, authors };
163}
165/** One version of shared (or of a named draft): who, why, and each file it changed, before and after. */
166export function show(
167 host: LogHost,
168 version: number,
169 options: { draft?: string | null; agent?: string } = {},
170): ShowAnswer {
171 host.needInit();
172 const space = host.spaceFor(options);
173 if (!Number.isInteger(version) || version < 0 || version > last(space)) {
174 throw new ProjectError(
175 "bad-request",
176 `there is no version ${String(version)}${space.name === SHARED ? "" : ` of draft ${space.name}`}`,
177 );
178 }
179 const entry = logEntry(host, space, version);
180 const before = version === 0 ? new View(host.graph, []) : host.viewAt(space, version - 1);
181 const after = host.viewAt(space, version);
182 return {
183 ...entry,
184 draft: space.name === SHARED ? null : space.name,
185 diff: changesBetween(before, after, entry.files),
186 };
187}
codex-capacity-chair143Add inactive disk projection provider and verified transactional readers (#16)Compare189function logEntry(host: LogHost, space: Space, version: number, views?: Map<number, ReadView>): LogEntry {
191 let changes = 0;
192 for (const id of p.atoms) {
193 const atom = host.graph.atom(id);
194 const ownLines = atom.inserts.length > 0 || host.graph.deleteCount(id) > 0;
195 if (ownLines) changes++;
196 }
197 const files = host.paths.versionFiles(space, version, views);
198 const change = host.versionChange(space, version);
199 const droppedIn = p.atoms.length > 0 ? space.droppedIn.get(p.atoms[p.atoms.length - 1]!) : undefined;
200 return {
201 version,
202 agent: p.agent,
203 message: p.message,
204 time: p.time,
205 changes,
206 ...(change !== undefined ? { change } : {}),
207 files: [...files],
208 ...(p.droppedVersions ? { drops: [...p.droppedVersions] } : {}),
209 ...(droppedIn !== undefined ? { droppedIn } : {}),
210 ...labelsOn(host, space, version),
211 ...(p.originalMessage !== undefined ? { originalMessage: p.originalMessage } : {}),
212 };
213}
215function labelsOn(host: LogHost, space: Space, version: number): { labels?: string[] } {
216 if (space.name !== SHARED) return {};
217 const names = [...host.labels]
218 .filter(([, vs]) => vs.includes(version))
219 .map(([n]) => n)
220 .toSorted();
221 return names.length > 0 ? { labels: names } : {};
222}
224/** A file as it was at a version of shared (or a named draft): its text, or null when it didn't exist. */
225export function fileAt(
226 host: LogHost,
227 path: string,
228 version: number,
229 options: { draft?: string | null; agent?: string } = {},
230): { path: string; version: number; text: string | null; blob?: string } {
231 host.needInit();
232 checkReadPath(path);
233 const space = host.spaceFor(options);
234 host.checkVersion(space, version);
235 const view = host.viewAt(space, version);
236 // Any spelling reads the stored one (#41, F7).
237 const file = host.spellingIn(view, path);
238 const blob = view.attrs(file).blob;
239 return {
240 path: file,
241 version,
242 text: view.hasFile(file) ? view.text(file) : null,
243 ...(blob !== null ? { blob } : {}),
244 };
245}
capacity313fileExactAt: a file at a version by exactly its spelling, from its own lines, without the version's list of files (for abso's pipelines step)
- version-log.ts fileExactAt(path, version): what fileAt answers for that same spelling, with no spelling lookup and no path list. Existence comes from hasFile's own test on the file itself: kept while empty, a link, a binary, or a visible line. A name nothing ever wrote is one hasAtomsIn read.
- Why: fileAt's hasFile answers from the version's whole list of files (the kept path set, folded from version 0 when nothing nearby is kept), and a spelling it doesn't find reads every known path (filesOf over every atom). abso reads its project files (abso.yml and the like) for each green ready marker on every tick, and that grew with history: 2–5 s a tick on prod.
- Project.fileExactAt; and ProjectHistory.fileExactAt, optional, so abso's pin compiles before its engine passes it through.
- Test: worker/project/test/file-exact-at.test.ts. fileExactAt equals fileAt at every version for nine paths (added, edited, emptied, binary, removed, never written), and another spelling isn't resolved to the stored one.
Checks: tsc clean; Biome clean; core tests (worker/project and src) 767 of 768 passed, 1 skipped, none failed.Compare246
247/**
248 * fileAt for exactly this spelling, from the file's own lines (abso Capacity, 2026-10-17): no spelling lookup and no
249 * list of the version's files. fileAt's hasFile answers from the version's whole path list, folded from version 0
250 * when nothing's kept, and a spelling it doesn't find reads every known path. A name nothing ever wrote is one read.
251 * The pipeline's project files (abso.yml and the like) are read this way on every tick.
252 */
253export function fileExactAt(
254 host: LogHost,
255 path: string,
256 version: number,
257 options: { draft?: string | null; agent?: string } = {},
258): { path: string; version: number; text: string | null; blob?: string } {
259 host.needInit();
260 checkReadPath(path);
261 const space = host.spaceFor(options);
262 host.checkVersion(space, version);
263 if (!host.graph.hasAtomsIn(path)) return { path, version, text: null };
264 const view = host.viewAt(space, version);
265 const attrs = view.attrs(path);
266 // hasFile's own test, without its path list: kept while empty, a link, a binary, or a visible line.
267 const exists = attrs.exists || attrs.link !== null || attrs.blob !== null || view.lines(path).length > 0;
268 return {
269 path,
270 version,
271 text: exists ? view.text(path) : null,
272 ...(attrs.blob !== null ? { blob: attrs.blob } : {}),
273 };
274}
capacity244compare keeps its own answer type; the summary is compareSummary (abso issue 680; abso Capacity).
243 gave compare one answer type for both shapes, full and summary. abso's own callers read compare(...).files as file changes (worker/src/engine-project.ts, scripts/versions-check.ts, test/versions.test.ts), and the union broke their types, which showed when I pinned 243 into abso. Core's own tests didn't catch it.
- version-log.ts: compared() works out the files and both views; compare answers {from, to, files: FileChange[]} as before 243, and compareSummary answers {from, to, summary: true, files}. Project.compareSummary calls it.
- server/src/engine-project.ts: compare(..., summary) calls compareSummary when summary is set. http.ts and ProjectHistory are unchanged from 243 (?summary=1, a fifth argument).
- compare-summary.test.ts calls compareSummary.
Answers are the same as 243's. Every engine test (292 of 292), every worker/project test (342 of 342); tsc (worker and server) and biome clean.Compare276/** The files that may differ between two versions, and both views: compare's and compareSummary's ground. */
277function compared(
279 from: number,
280 to: number,
capacity244compare keeps its own answer type; the summary is compareSummary (abso issue 680; abso Capacity).
243 gave compare one answer type for both shapes, full and summary. abso's own callers read compare(...).files as file changes (worker/src/engine-project.ts, scripts/versions-check.ts, test/versions.test.ts), and the union broke their types, which showed when I pinned 243 into abso. Core's own tests didn't catch it.
- version-log.ts: compared() works out the files and both views; compare answers {from, to, files: FileChange[]} as before 243, and compareSummary answers {from, to, summary: true, files}. Project.compareSummary calls it.
- server/src/engine-project.ts: compare(..., summary) calls compareSummary when summary is set. http.ts and ProjectHistory are unchanged from 243 (?summary=1, a fifth argument).
- compare-summary.test.ts calls compareSummary.
Answers are the same as 243's. Every engine test (292 of 292), every worker/project test (342 of 342); tsc (worker and server) and biome clean.Compare281 options: { draft?: string | null; agent?: string },
282): { before: ReadView; after: ReadView; files: Set<string> } {
284 const space = host.spaceFor(options);
285 host.checkVersion(space, from);
286 host.checkVersion(space, to);
codex-capacity-chair163Integrate reviewed disk-backed operations, queue and bounded read cachesCompare287 const before = host.viewAt(space, from);
288 const after = host.viewAt(space, to);
capacity208Compare on a stored writer takes its candidates from the kept version files of the versions between (abso Capacity): every file that differs between two shared versions changed in one between them. Before, it walked every atom either version's set holds. version-files.test.ts compares both ways, across a drop, against the in-memory project. On game's export, compare from 762 to 1525: 20 s to 5.4 s, same answer.Compare290 // A stored writer keeps each shared version's changed files (version-files.ts, abso Capacity): every file that
291 // differs between two versions changed in one between them, so those lists are the candidates, not every atom
292 // either set holds.
293 if (space.name === SHARED && host.graph.packedFiles) {
294 for (let v = Math.min(from, to) + 1; v <= Math.max(from, to); v++)
295 for (const file of host.paths.versionFiles(space, v)) files.add(file);
capacity244compare keeps its own answer type; the summary is compareSummary (abso issue 680; abso Capacity).
243 gave compare one answer type for both shapes, full and summary. abso's own callers read compare(...).files as file changes (worker/src/engine-project.ts, scripts/versions-check.ts, test/versions.test.ts), and the union broke their types, which showed when I pinned 243 into abso. Core's own tests didn't catch it.
- version-log.ts: compared() works out the files and both views; compare answers {from, to, files: FileChange[]} as before 243, and compareSummary answers {from, to, summary: true, files}. Project.compareSummary calls it.
- server/src/engine-project.ts: compare(..., summary) calls compareSummary when summary is set. http.ts and ProjectHistory are unchanged from 243 (?summary=1, a fifth argument).
- compare-summary.test.ts calls compareSummary.
Answers are the same as 243's. Every engine test (292 of 292), every worker/project test (342 of 342); tsc (worker and server) and biome clean.Compare296 return { before, after, files };
capacity208Compare on a stored writer takes its candidates from the kept version files of the versions between (abso Capacity): every file that differs between two shared versions changed in one between them. Before, it walked every atom either version's set holds. version-files.test.ts compares both ways, across a drop, against the in-memory project. On game's export, compare from 762 to 1525: 20 s to 5.4 s, same answer.Compare297 }
299 const b = host.at(space, to);
300 for (const [x, y] of [
301 [a, b],
302 [b, a],
303 ] as const) {
304 for (const file of host.touchedFiles(
codex-capacity-chair163Integrate reviewed disk-backed operations, queue and bounded read cachesCompare305 (function* () {
306 for (const id of x) if (!y.has(id)) yield id;
307 })(),
308 [before, after],
310 files.add(file);
311 }
capacity244compare keeps its own answer type; the summary is compareSummary (abso issue 680; abso Capacity).
243 gave compare one answer type for both shapes, full and summary. abso's own callers read compare(...).files as file changes (worker/src/engine-project.ts, scripts/versions-check.ts, test/versions.test.ts), and the union broke their types, which showed when I pinned 243 into abso. Core's own tests didn't catch it.
- version-log.ts: compared() works out the files and both views; compare answers {from, to, files: FileChange[]} as before 243, and compareSummary answers {from, to, summary: true, files}. Project.compareSummary calls it.
- server/src/engine-project.ts: compare(..., summary) calls compareSummary when summary is set. http.ts and ProjectHistory are unchanged from 243 (?summary=1, a fifth argument).
- compare-summary.test.ts calls compareSummary.
Answers are the same as 243's. Every engine test (292 of 292), every worker/project test (342 of 342); tsc (worker and server) and biome clean.Compare312 return { before, after, files };
313}
init0Start the project315/** Every file that differs between two versions of shared (or a named draft), before (at `from`) and after (at `to`). */
316export function compare(
capacity244compare keeps its own answer type; the summary is compareSummary (abso issue 680; abso Capacity).
243 gave compare one answer type for both shapes, full and summary. abso's own callers read compare(...).files as file changes (worker/src/engine-project.ts, scripts/versions-check.ts, test/versions.test.ts), and the union broke their types, which showed when I pinned 243 into abso. Core's own tests didn't catch it.
- version-log.ts: compared() works out the files and both views; compare answers {from, to, files: FileChange[]} as before 243, and compareSummary answers {from, to, summary: true, files}. Project.compareSummary calls it.
- server/src/engine-project.ts: compare(..., summary) calls compareSummary when summary is set. http.ts and ProjectHistory are unchanged from 243 (?summary=1, a fifth argument).
- compare-summary.test.ts calls compareSummary.
Answers are the same as 243's. Every engine test (292 of 292), every worker/project test (342 of 342); tsc (worker and server) and biome clean.Compare317 host: LogHost,
318 from: number,
319 to: number,
320 options: { draft?: string | null; agent?: string } = {},
321): { from: number; to: number; files: FileChange[] } {
322 const { before, after, files } = compared(host, from, to, options);
323 return { from, to, files: changesBetween(before, after, files) };
324}
326/** compare's files as each one's size and SHA-256 before and after, not its texts (abso issue 680). */
327export function compareSummary(
328 host: LogHost,
329 from: number,
330 to: number,
331 options: { draft?: string | null; agent?: string } = {},
332): { from: number; to: number; summary: true; files: ReturnType<typeof summariesBetween> } {
333 const { before, after, files } = compared(host, from, to, options);
334 return { from, to, summary: true, files: summariesBetween(before, after, files) };
codex-capacity-chair143Add inactive disk projection provider and verified transactional readers (#16)Compare337/** A version of shared (or of a named draft) as a ReadView, for reading lines (blame at a version). */
338export function viewAt(
339 host: LogHost,
340 version: number,
341 options: { draft?: string | null; agent?: string } = {},
342): ReadView {
344 const space = host.spaceFor(options);
345 host.checkVersion(space, version);
346 return host.viewAt(space, version);
347}