Versions 2 to 318
new file, 272 lines
1+// Each version of shared's changed files, worked out as the version lands from what it touched (disk-first 2;
2+// abso Capacity). The log, a path's history and the tree read these lists; working them out from two layouts of every
3+// touched file per version cost game's whole history 460 s to adopt. Here a version costs about its own size:
4+// - a file it touched differs when its visible lines' count or texts changed, or its mode or blob did;
5+// - whether a file exists before and after comes from a running count of each file's visible lines;
6+// - only a version whose added and removed lines have the very same texts, or one with moves, drops or a change to
9+
16+
19+
20+// Author totals (docs/disk-first-2.md, abso Capacity, issue 664): each shared file's lines by author and its text's size
21+// in UTF-8 bytes, as tree with authors counts them, so it reads one value per file instead of laying every file out.
22+// AUTHORS holds each file's totals at the newest version kept; AUTHORS_LOG each file's totals at every version that
23+// changed them, oldest first. Shared only, never a draft (Security on ask 2096). They live in the writer's state, so
24+// whatever clears or replaces that state (a new adoption, a restore, a drop of the project) takes them with it.
28+
29+/** A file's lines by author and its text's size, stored: authors by name, none at zero; null when it has no lines. */
31+
37+
39+
40+/** The newest shared version whose author totals are kept, or undefined when this writer keeps none. */
44+
45+/** A shared file's totals at version `v`, or undefined when they aren't kept that far: lay the file out instead. */
46+export function authorTotalsAt(storage: GraphStateStorage, path: string, v: number): FileTotals | undefined {
65+
75+
77+function normalTotals(authors: ReadonlyMap<string, number>, bytes: number): StoredTotals | null {
78+ const a = [...authors].filter(([, n]) => n !== 0).sort(([x], [y]) => (x < y ? -1 : x > y ? 1 : 0));
81+
83+ * A laid-out file's lines by author, from its visible lines' writers (abso Capacity): each writer's author once, instead
84+ * of making an atom id and a line id for every line (an agent's tree spent 0.4 s on that for its draft's files).
93+ const writers = (view as { visibleWriters?(path: string): readonly number[] }).visibleWriters?.call(view, path);
109+
111+function laidOutTotals(view: ReadView, path: string, authorOf: (id: AtomId) => string): StoredTotals | null {
116+
118+function keepTotals(storage: GraphStateStorage, v: number, path: string, totals: StoredTotals | null): void {
123+ const log = (storage.read(AUTHORS_LOG, path) as [number, StoredTotals | null][] | undefined) ?? [];
126+
127+/** The shared version the running counts describe, or undefined when this writer keeps none. */
131+
142+
148+
149+/** The changed files of shared's version `v`, sorted, and which existed before and after; the running counts moved to `v`. */
166+ // The same moves as the version before: share them, and where lines sit, instead of resolving them again.
169+ // Author totals start with the first version too, and are kept only while every version since has kept them.
181+ // Every touched file's totals from its layout: one whose lines are the same texts by someone else isn't among
184+ for (const path of touched) keepTotals(storage, v, path, laidOutTotals(after, path, authorOf));
197+ // Per file: visible lines added minus removed, and the texts' balance; and, while totals are kept, each author's lines
201+ { net: number; texts: Map<string, number>; lines: number; authors: Map<string, number>; bytes: number }
205+ if (!c) changes.set(path, (c = { net: 0, texts: new Map(), lines: 0, authors: new Map(), bytes: 0 }));
261+ // Different texts in or out: the file's lines changed. The same texts in and out: compare the files.
- MCP
- compare on this site's /mcp
- CLI
- abso diff 2 318 worker/project/version-files.ts --json
- JSON
- /christopher/abso-core/compare/2..318?file=worker%2Fproject%2Fversion-files.ts&format=json