- MCP
- blame on this site's /mcp
- CLI
- abso blame worker/project/test/compare-summary.test.ts --json
- JSON
- /christopher/abso-core/blame/worker/project/test/compare-summary.test.ts?format=json
72 linescapacity 100%Last change capacity in version 244,
72 lines from 3 changes in 2 versions.
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.Compare1// compare's summary (abso issue 680): every file a full compare lists, with its size in UTF-8 bytes and SHA-256 before
2// and after instead of its texts, or its blob's hash for a binary file. The same on a writer-backed project as in
3// memory.
5import assert from "node:assert/strict";
6import { createHash } from "node:crypto";
7import { test } from "node:test";
8import { storedArray } from "../../../src/engine/state-source.ts";
9import { SqlState } from "../../../src/engine/test/storage-helper.ts";
10import { MemoryStore, Project } from "../project.ts";
11import type { Entry, ProjectStore } from "../project-types.ts";
13const A = "a".repeat(64);
14const B = "b".repeat(64);
15const held = (sha: string) => sha === A || sha === B;
17function writer() {
18 const storage = new SqlState();
19 const entries = storedArray<Entry>(storage, "canonical-log");
20 const store: ProjectStore = {
21 append(batch) {
22 for (const entry of batch) entries.push(entry);
23 },
24 };
25 return new Project(store, { writerStorage: storage, hasBlob: held });
26}
28function history(project: Project) {
29 project.init(
30 { "keep.txt": "same\n", "edit.txt": "one\n", "gone.txt": "bye\n", "run.sh": "echo\n" },
31 0,
32 {},
33 { "logo.png": A },
34 );
35 project.record(
36 "ann",
37 { "edit.txt": "one\nzwei ü\n", "gone.txt": null, "new.txt": "hello\n" },
38 1,
39 { "run.sh": { exec: true } },
40 { "logo.png": B },
41 );
42 assert.equal(project.publish("ann", "Changes", 2).ok, true);
43}
45const sha = (text: string) => createHash("sha256").update(text, "utf8").digest("hex");
47test("compare's summary lists what compare does, as sizes and SHA-256s", () => {
48 for (const project of [new Project(new MemoryStore(), { hasBlob: held }), writer()]) {
49 history(project);
50 const full = project.compare(0, 1);
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.Compare51 const summary = project.compareSummary(0, 1);
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.Compare52 if ("summary" in full || !("summary" in summary)) throw Error("compare answered the wrong shape");
53 assert.deepEqual(
54 summary.files.map((f) => f.path),
55 full.files.map((f) => f.path),
56 );
57 for (const f of full.files) {
58 const s: (typeof summary.files)[number] = summary.files.find((x) => x.path === f.path)!;
59 const sum = (text: string | null, blob: string | null | undefined) =>
60 text === null ? null : blob ? { blob } : { size: Buffer.byteLength(text, "utf8"), sha256: sha(text) };
61 assert.deepEqual(s.before, sum(f.before, f.blob?.before ?? null), `${f.path} before`);
62 assert.deepEqual(s.after, sum(f.after, f.blob?.after ?? null), `${f.path} after`);
63 assert.deepEqual(s.mode, f.mode);
64 assert.deepEqual(s.blob, f.blob);
65 }
66 const edited = summary.files.find((f) => f.path === "edit.txt")!;
67 assert.deepEqual(edited.after, { size: Buffer.byteLength("one\nzwei ü\n", "utf8"), sha256: sha("one\nzwei ü\n") });
68 assert.equal(summary.files.find((f) => f.path === "gone.txt")!.after, null);
69 assert.deepEqual(summary.files.find((f) => f.path === "logo.png")!.after, { blob: B });
70 assert.ok(!JSON.stringify(summary).includes("zwei"), "no texts");
71 }
72});