{"file":"worker/project/version-log.ts","version":318,"total":347,"from":1,"to":347,"lines":[{"n":1,"text":"import { View } from \"../../src/engine/index.ts\";","atom":"a1363","author":"codex-capacity-chair","version":143},{"n":2,"text":"// The version list reads: log (versions newest first, or one file's history), ribbon (who published each version),","atom":"a0","author":"init","version":0},{"n":3,"text":"// show (one version's changes), fileAt, compare and viewAt. They read through LogHost; today the host is the project","atom":"a0","author":"init","version":0},{"n":4,"text":"// in memory.","atom":"a0","author":"init","version":0},{"n":5,"text":"","atom":"a0","author":"init","version":0},{"n":6,"text":"import type { AtomId, Graph, ReadView } from \"../../src/engine/index.ts\";","atom":"a1363","author":"codex-capacity-chair","version":143},{"n":7,"text":"import { checkReadPath } from \"./path-rules.ts\";","atom":"a0","author":"init","version":0},{"n":8,"text":"import type { PathIndex } from \"./pathindex.ts\";","atom":"a0","author":"init","version":0},{"n":9,"text":"import { ProjectError } from \"./project-error.ts\";","atom":"a0","author":"init","version":0},{"n":10,"text":"import type { FileChange, LogAnswer, LogEntry, ShowAnswer } from \"./project-types.ts\";","atom":"a0","author":"init","version":0},{"n":11,"text":"import { last, SHARED, type Space } from \"./spaces.ts\";","atom":"a0","author":"init","version":0},{"n":12,"text":"import { changesBetween, summariesBetween } from \"./view-changes.ts\";","atom":"a2487","author":"capacity","version":243},{"n":13,"text":"","atom":"a0","author":"init","version":0},{"n":14,"text":"/** What the version list reads need from a project. */","atom":"a0","author":"init","version":0},{"n":15,"text":"export interface LogHost {","atom":"a0","author":"init","version":0},{"n":16,"text":"\treadonly graph: Graph;","atom":"a0","author":"init","version":0},{"n":17,"text":"\treadonly paths: Pick<PathIndex, \"knowsFiles\" | \"versionFiles\" | \"versionShape\">;","atom":"a0","author":"init","version":0},{"n":18,"text":"\treadonly labels: ReadonlyMap<string, readonly number[]>;","atom":"a0","author":"init","version":0},{"n":19,"text":"\tshared(): Space;","atom":"a0","author":"init","version":0},{"n":20,"text":"\tneedInit(): void;","atom":"a0","author":"init","version":0},{"n":21,"text":"\tspaceFor(options: { draft?: string | null; agent?: string }): Space;","atom":"a0","author":"init","version":0},{"n":22,"text":"\tcheckVersion(space: Space, version: number): void;","atom":"a0","author":"init","version":0},{"n":23,"text":"\tviewAt(space: Space, version: number): ReadView;","atom":"a1363","author":"codex-capacity-chair","version":143},{"n":24,"text":"\tview(set: ReadonlySet<AtomId>): ReadView;","atom":"a1363","author":"codex-capacity-chair","version":143},{"n":25,"text":"\tat(space: Space, version: number): ReadonlySet<AtomId>;","atom":"a0","author":"init","version":0},{"n":26,"text":"\tspellingIn(view: ReadView, path: string): string;","atom":"a1363","author":"codex-capacity-chair","version":143},{"n":27,"text":"\tversionChange(space: Space, version: number): number | undefined;","atom":"a0","author":"init","version":0},{"n":28,"text":"\ttouchedFiles(ids: Iterable<AtomId>, views: readonly ReadView[]): Set<string>;","atom":"a1363","author":"codex-capacity-chair","version":143},{"n":29,"text":"}","atom":"a0","author":"init","version":0},{"n":30,"text":"","atom":"a0","author":"init","version":0},{"n":31,"text":"/**","atom":"a0","author":"init","version":0},{"n":32,"text":" * The versions of shared (or of a named draft), newest first: who","atom":"a0","author":"init","version":0},{"n":33,"text":" * published each, why, and which files it touched. `limit` defaults to 50.","atom":"a0","author":"init","version":0},{"n":34,"text":" */","atom":"a0","author":"init","version":0},{"n":35,"text":"export function log(","atom":"a0","author":"init","version":0},{"n":36,"text":"\thost: LogHost,","atom":"a0","author":"init","version":0},{"n":37,"text":"\toptions: {","atom":"a0","author":"init","version":0},{"n":38,"text":"\t\tdraft?: string | null;","atom":"a0","author":"init","version":0},{"n":39,"text":"\t\tagent?: string;","atom":"a0","author":"init","version":0},{"n":40,"text":"\t\tlimit?: number;","atom":"a0","author":"init","version":0},{"n":41,"text":"\t\tpath?: string;","atom":"a0","author":"init","version":0},{"n":42,"text":"\t\tbefore?: number;","atom":"a0","author":"init","version":0},{"n":43,"text":"\t\tfollow?: boolean;","atom":"a0","author":"init","version":0},{"n":44,"text":"\t} = {},","atom":"a0","author":"init","version":0},{"n":45,"text":"): LogAnswer {","atom":"a0","author":"init","version":0},{"n":46,"text":"\thost.needInit();","atom":"a0","author":"init","version":0},{"n":47,"text":"\tconst space = host.spaceFor(options);","atom":"a0","author":"init","version":0},{"n":48,"text":"\tconst limit = Number.isInteger(options.limit) && options.limit! > 0 ? Math.min(options.limit!, 200) : 50;","atom":"a0","author":"init","version":0},{"n":49,"text":"\tif (options.path !== undefined) checkReadPath(options.path);","atom":"a0","author":"init","version":0},{"n":50,"text":"\tif (options.before !== undefined && (!Number.isInteger(options.before) || options.before < 0))","atom":"a0","author":"init","version":0},{"n":51,"text":"\t\tthrow new ProjectError(\"bad-request\", \"before must be a version number\");","atom":"a0","author":"init","version":0},{"n":52,"text":"\tconst versions: LogEntry[] = [];","atom":"a0","author":"init","version":0},{"n":53,"text":"\t// Paging (#41, the website): `before` starts the page below that version; `next` is the `before` for the page after.","atom":"a0","author":"init","version":0},{"n":54,"text":"\tlet v = Math.min(last(space), (options.before ?? last(space) + 1) - 1);","atom":"a0","author":"init","version":0},{"n":55,"text":"\t// Any spelling reads the stored one (#41, F7). With follow, the history follows moves (F27): before","atom":"a0","author":"init","version":0},{"n":56,"text":"\t// the version that moved the file in, it's the file it came from.","atom":"a0","author":"init","version":0},{"n":57,"text":"\tconst path = options.path === undefined ? undefined : host.spellingIn(host.viewAt(space, last(space)), options.path);","atom":"a0","author":"init","version":0},{"n":58,"text":"\tconst names = path === undefined ? [] : options.follow ? namesBefore(host, space, path) : [{ path, since: 0 }];","atom":"a0","author":"init","version":0},{"n":59,"text":"\tconst nameAt = (version: number): string => names.find((n) => version >= n.since)?.path ?? path!;","atom":"a0","author":"init","version":0},{"n":60,"text":"\t// A file's history (#43): only versions whose changes name the file, or a file moves can carry lines from, can have changed it.","atom":"a0","author":"init","version":0},{"n":61,"text":"\tconst sources = path === undefined ? undefined : new Set(names.flatMap((n) => [...moveSources(host.graph, n.path)]));","atom":"a0","author":"init","version":0},{"n":62,"text":"\tconst g = host.graph;","atom":"a0","author":"init","version":0},{"n":63,"text":"\tconst views = new Map<number, ReadView>();","atom":"a1363","author":"codex-capacity-chair","version":143},{"n":64,"text":"\tfor (; v >= 0 && versions.length < limit; v--) {","atom":"a0","author":"init","version":0},{"n":65,"text":"\t\tif (sources && !host.paths.knowsFiles(space, v)) {","atom":"a0","author":"init","version":0},{"n":66,"text":"\t\t\tconst p = space.versions[v]!;","atom":"a0","author":"init","version":0},{"n":67,"text":"\t\t\tif (![...p.atoms, ...(p.dropped ?? [])].some((id) => g.filesOf(id).some((f) => sources.has(f)))) continue;","atom":"a0","author":"init","version":0},{"n":68,"text":"\t\t}","atom":"a0","author":"init","version":0},{"n":69,"text":"\t\t// With a path: only the versions that changed that file (its history), under its name then. Their files first, and","atom":"a2600","author":"capacity","version":254},{"n":70,"text":"\t\t// the whole entry (every atom of the version read) only for those (abso Capacity): a file's history read every","atom":"a2600","author":"capacity","version":254},{"n":71,"text":"\t\t// version's atoms down to its twentieth change.","atom":"a2600","author":"capacity","version":254},{"n":72,"text":"\t\tif (path !== undefined && !host.paths.versionFiles(space, v, views).includes(nameAt(v))) {","atom":"a2600","author":"capacity","version":254},{"n":73,"text":"\t\t\tviews.delete(v + 1);","atom":"a2600","author":"capacity","version":254},{"n":74,"text":"\t\t\tcontinue;","atom":"a2600","author":"capacity","version":254},{"n":75,"text":"\t\t}","atom":"a2600","author":"capacity","version":254},{"n":76,"text":"\t\tconst entry = logEntry(host, space, v, views);","atom":"a0","author":"init","version":0},{"n":77,"text":"\t\t// The walk goes down: a view above this version won't be needed again (#46).","atom":"a0","author":"init","version":0},{"n":78,"text":"\t\tviews.delete(v + 1);","atom":"a0","author":"init","version":0},{"n":79,"text":"\t\tif (path === undefined) versions.push(entry);","atom":"a0","author":"init","version":0},{"n":80,"text":"\t\telse versions.push(nameAt(v) === path ? entry : { ...entry, path: nameAt(v) });","atom":"a2600","author":"capacity","version":254},{"n":81,"text":"\t}","atom":"a0","author":"init","version":0},{"n":82,"text":"\tconst next = v >= 0 && versions.length > 0 ? versions[versions.length - 1]!.version : undefined;","atom":"a0","author":"init","version":0},{"n":83,"text":"\tconst movedFrom = names.slice(0, -1).map((n, i) => ({ path: names[i + 1]!.path, version: n.since }));","atom":"a0","author":"init","version":0},{"n":84,"text":"\treturn {","atom":"a0","author":"init","version":0},{"n":85,"text":"\t\tdraft: space.name === SHARED ? null : space.name,","atom":"a0","author":"init","version":0},{"n":86,"text":"\t\tversion: last(space),","atom":"a0","author":"init","version":0},{"n":87,"text":"\t\tversions,","atom":"a0","author":"init","version":0},{"n":88,"text":"\t\t...(next !== undefined ? { next } : {}),","atom":"a0","author":"init","version":0},{"n":89,"text":"\t\t...(path !== undefined ? { path } : {}),","atom":"a0","author":"init","version":0},{"n":90,"text":"\t\t...(movedFrom.length > 0 ? { movedFrom } : {}),","atom":"a0","author":"init","version":0},{"n":91,"text":"\t};","atom":"a0","author":"init","version":0},{"n":92,"text":"}","atom":"a0","author":"init","version":0},{"n":93,"text":"","atom":"a0","author":"init","version":0},{"n":94,"text":"/**","atom":"a0","author":"init","version":0},{"n":95,"text":" * A file's names back through moves (#41, F27), newest first: each with the","atom":"a0","author":"init","version":0},{"n":96,"text":" * version from which it had that name. Found from the atoms that moved lines","atom":"a0","author":"init","version":0},{"n":97,"text":" * into it (abso mv), so it never guesses from how alike two files are.","atom":"a0","author":"init","version":0},{"n":98,"text":" */","atom":"a0","author":"init","version":0},{"n":99,"text":"function namesBefore(host: LogHost, space: Space, path: string): { path: string; since: number }[] {","atom":"a0","author":"init","version":0},{"n":100,"text":"\tconst g = host.graph;","atom":"a0","author":"init","version":0},{"n":101,"text":"\tconst out: { path: string; since: number }[] = [];","atom":"a0","author":"init","version":0},{"n":102,"text":"\tlet cur = path;","atom":"a0","author":"init","version":0},{"n":103,"text":"\tlet below = last(space) + 1;","atom":"a0","author":"init","version":0},{"n":104,"text":"\tconst movers = g.movers();","atom":"a0","author":"init","version":0},{"n":105,"text":"\tfor (;;) {","atom":"a0","author":"init","version":0},{"n":106,"text":"\t\t// The newest version below `below` that moved another file into `cur`.","atom":"a0","author":"init","version":0},{"n":107,"text":"\t\tconst into = movers","atom":"a0","author":"init","version":0},{"n":108,"text":"\t\t\t.filter((id) => g.filesOf(id).includes(cur))","atom":"a0","author":"init","version":0},{"n":109,"text":"\t\t\t.map((id) => space.publishedIn.get(id))","atom":"a0","author":"init","version":0},{"n":110,"text":"\t\t\t.filter((v): v is number => v !== undefined && v < below)","atom":"a0","author":"init","version":0},{"n":111,"text":"\t\t\t.toSorted((a, b) => b - a);","atom":"a0","author":"init","version":0},{"n":112,"text":"\t\tlet found: { from: string; version: number } | undefined;","atom":"a0","author":"init","version":0},{"n":113,"text":"\t\tfor (const version of into) {","atom":"a0","author":"init","version":0},{"n":114,"text":"\t\t\tconst move = host.paths.versionShape(space, version).moves.find(([, to]) => to === cur);","atom":"a0","author":"init","version":0},{"n":115,"text":"\t\t\tif (move) {","atom":"a0","author":"init","version":0},{"n":116,"text":"\t\t\t\tfound = { from: move[0], version };","atom":"a0","author":"init","version":0},{"n":117,"text":"\t\t\t\tbreak;","atom":"a0","author":"init","version":0},{"n":118,"text":"\t\t\t}","atom":"a0","author":"init","version":0},{"n":119,"text":"\t\t}","atom":"a0","author":"init","version":0},{"n":120,"text":"\t\tout.push({ path: cur, since: found?.version ?? 0 });","atom":"a0","author":"init","version":0},{"n":121,"text":"\t\tif (!found) break;","atom":"a0","author":"init","version":0},{"n":122,"text":"\t\tcur = found.from;","atom":"a0","author":"init","version":0},{"n":123,"text":"\t\tbelow = found.version;","atom":"a0","author":"init","version":0},{"n":124,"text":"\t}","atom":"a0","author":"init","version":0},{"n":125,"text":"\treturn out;","atom":"a0","author":"init","version":0},{"n":126,"text":"}","atom":"a0","author":"init","version":0},{"n":127,"text":"","atom":"a0","author":"init","version":0},{"n":128,"text":"/**","atom":"a0","author":"init","version":0},{"n":129,"text":" * The files whose lines can be in `path` (#43): itself, and any file a move","atom":"a0","author":"init","version":0},{"n":130,"text":" * shares with one already found. A line is in a file other than the one it","atom":"a0","author":"init","version":0},{"n":131,"text":" * was written in only when a move carried it, or a line before it, there;","atom":"a0","author":"init","version":0},{"n":132,"text":" * that move names both files.","atom":"a0","author":"init","version":0},{"n":133,"text":" */","atom":"a0","author":"init","version":0},{"n":134,"text":"function moveSources(g: Graph, path: string): Set<string> {","atom":"a0","author":"init","version":0},{"n":135,"text":"\tconst out = new Set([path]);","atom":"a0","author":"init","version":0},{"n":136,"text":"\tconst movers = g.movers().map((id) => g.filesOf(id));","atom":"a0","author":"init","version":0},{"n":137,"text":"\tfor (let grew = true; grew; ) {","atom":"a0","author":"init","version":0},{"n":138,"text":"\t\tgrew = false;","atom":"a0","author":"init","version":0},{"n":139,"text":"\t\tfor (const files of movers) {","atom":"a0","author":"init","version":0},{"n":140,"text":"\t\t\tif (!files.some((f) => out.has(f))) continue;","atom":"a0","author":"init","version":0},{"n":141,"text":"\t\t\tfor (const f of files) if (!out.has(f)) out.add(f), (grew = true);","atom":"a0","author":"init","version":0},{"n":142,"text":"\t\t}","atom":"a0","author":"init","version":0},{"n":143,"text":"\t}","atom":"a0","author":"init","version":0},{"n":144,"text":"\treturn out;","atom":"a0","author":"init","version":0},{"n":145,"text":"}","atom":"a0","author":"init","version":0},{"n":146,"text":"","atom":"a0","author":"init","version":0},{"n":147,"text":"/**","atom":"a0","author":"init","version":0},{"n":148,"text":" * Shared's versions in one small answer, for the website's version ribbon","atom":"a0","author":"init","version":0},{"n":149,"text":" * (#43): `authors[v]` indexes `agents`, which are in order of each agent's","atom":"a0","author":"init","version":0},{"n":150,"text":" * first version. No files, so it costs nothing on a long history.","atom":"a0","author":"init","version":0},{"n":151,"text":" */","atom":"a0","author":"init","version":0},{"n":152,"text":"export function ribbon(host: LogHost): { version: number; agents: string[]; authors: number[] } {","atom":"a0","author":"init","version":0},{"n":153,"text":"\thost.needInit();","atom":"a0","author":"init","version":0},{"n":154,"text":"\tconst shared = host.shared();","atom":"a0","author":"init","version":0},{"n":155,"text":"\tconst agents: string[] = [];","atom":"a0","author":"init","version":0},{"n":156,"text":"\tconst index = new Map<string, number>();","atom":"a0","author":"init","version":0},{"n":157,"text":"\tconst authors = shared.versions.map((p) => {","atom":"a0","author":"init","version":0},{"n":158,"text":"\t\tlet i = index.get(p.agent);","atom":"a0","author":"init","version":0},{"n":159,"text":"\t\tif (i === undefined) index.set(p.agent, (i = agents.push(p.agent) - 1));","atom":"a0","author":"init","version":0},{"n":160,"text":"\t\treturn i;","atom":"a0","author":"init","version":0},{"n":161,"text":"\t});","atom":"a0","author":"init","version":0},{"n":162,"text":"\treturn { version: last(shared), agents, authors };","atom":"a0","author":"init","version":0},{"n":163,"text":"}","atom":"a0","author":"init","version":0},{"n":164,"text":"","atom":"a0","author":"init","version":0},{"n":165,"text":"/** One version of shared (or of a named draft): who, why, and each file it changed, before and after. */","atom":"a0","author":"init","version":0},{"n":166,"text":"export function show(","atom":"a0","author":"init","version":0},{"n":167,"text":"\thost: LogHost,","atom":"a0","author":"init","version":0},{"n":168,"text":"\tversion: number,","atom":"a0","author":"init","version":0},{"n":169,"text":"\toptions: { draft?: string | null; agent?: string } = {},","atom":"a0","author":"init","version":0},{"n":170,"text":"): ShowAnswer {","atom":"a0","author":"init","version":0},{"n":171,"text":"\thost.needInit();","atom":"a0","author":"init","version":0},{"n":172,"text":"\tconst space = host.spaceFor(options);","atom":"a0","author":"init","version":0},{"n":173,"text":"\tif (!Number.isInteger(version) || version < 0 || version > last(space)) {","atom":"a0","author":"init","version":0},{"n":174,"text":"\t\tthrow new ProjectError(","atom":"a0","author":"init","version":0},{"n":175,"text":"\t\t\t\"bad-request\",","atom":"a0","author":"init","version":0},{"n":176,"text":"\t\t\t`there is no version ${String(version)}${space.name === SHARED ? \"\" : ` of draft ${space.name}`}`,","atom":"a0","author":"init","version":0},{"n":177,"text":"\t\t);","atom":"a0","author":"init","version":0},{"n":178,"text":"\t}","atom":"a0","author":"init","version":0},{"n":179,"text":"\tconst entry = logEntry(host, space, version);","atom":"a0","author":"init","version":0},{"n":180,"text":"\tconst before = version === 0 ? new View(host.graph, []) : host.viewAt(space, version - 1);","atom":"a0","author":"init","version":0},{"n":181,"text":"\tconst after = host.viewAt(space, version);","atom":"a0","author":"init","version":0},{"n":182,"text":"\treturn {","atom":"a0","author":"init","version":0},{"n":183,"text":"\t\t...entry,","atom":"a0","author":"init","version":0},{"n":184,"text":"\t\tdraft: space.name === SHARED ? null : space.name,","atom":"a0","author":"init","version":0},{"n":185,"text":"\t\tdiff: changesBetween(before, after, entry.files),","atom":"a0","author":"init","version":0},{"n":186,"text":"\t};","atom":"a0","author":"init","version":0},{"n":187,"text":"}","atom":"a0","author":"init","version":0},{"n":188,"text":"","atom":"a0","author":"init","version":0},{"n":189,"text":"function logEntry(host: LogHost, space: Space, version: number, views?: Map<number, ReadView>): LogEntry {","atom":"a1363","author":"codex-capacity-chair","version":143},{"n":190,"text":"\tconst p = space.versions[version]!;","atom":"a0","author":"init","version":0},{"n":191,"text":"\tlet changes = 0;","atom":"a0","author":"init","version":0},{"n":192,"text":"\tfor (const id of p.atoms) {","atom":"a0","author":"init","version":0},{"n":193,"text":"\t\tconst atom = host.graph.atom(id);","atom":"a0","author":"init","version":0},{"n":194,"text":"\t\tconst ownLines = atom.inserts.length > 0 || host.graph.deleteCount(id) > 0;","atom":"a0","author":"init","version":0},{"n":195,"text":"\t\tif (ownLines) changes++;","atom":"a0","author":"init","version":0},{"n":196,"text":"\t}","atom":"a0","author":"init","version":0},{"n":197,"text":"\tconst files = host.paths.versionFiles(space, version, views);","atom":"a0","author":"init","version":0},{"n":198,"text":"\tconst change = host.versionChange(space, version);","atom":"a0","author":"init","version":0},{"n":199,"text":"\tconst droppedIn = p.atoms.length > 0 ? space.droppedIn.get(p.atoms[p.atoms.length - 1]!) : undefined;","atom":"a0","author":"init","version":0},{"n":200,"text":"\treturn {","atom":"a0","author":"init","version":0},{"n":201,"text":"\t\tversion,","atom":"a0","author":"init","version":0},{"n":202,"text":"\t\tagent: p.agent,","atom":"a0","author":"init","version":0},{"n":203,"text":"\t\tmessage: p.message,","atom":"a0","author":"init","version":0},{"n":204,"text":"\t\ttime: p.time,","atom":"a0","author":"init","version":0},{"n":205,"text":"\t\tchanges,","atom":"a0","author":"init","version":0},{"n":206,"text":"\t\t...(change !== undefined ? { change } : {}),","atom":"a0","author":"init","version":0},{"n":207,"text":"\t\tfiles: [...files],","atom":"a0","author":"init","version":0},{"n":208,"text":"\t\t...(p.droppedVersions ? { drops: [...p.droppedVersions] } : {}),","atom":"a0","author":"init","version":0},{"n":209,"text":"\t\t...(droppedIn !== undefined ? { droppedIn } : {}),","atom":"a0","author":"init","version":0},{"n":210,"text":"\t\t...labelsOn(host, space, version),","atom":"a0","author":"init","version":0},{"n":211,"text":"\t\t...(p.originalMessage !== undefined ? { originalMessage: p.originalMessage } : {}),","atom":"a0","author":"init","version":0},{"n":212,"text":"\t};","atom":"a0","author":"init","version":0},{"n":213,"text":"}","atom":"a0","author":"init","version":0},{"n":214,"text":"","atom":"a0","author":"init","version":0},{"n":215,"text":"function labelsOn(host: LogHost, space: Space, version: number): { labels?: string[] } {","atom":"a0","author":"init","version":0},{"n":216,"text":"\tif (space.name !== SHARED) return {};","atom":"a0","author":"init","version":0},{"n":217,"text":"\tconst names = [...host.labels]","atom":"a0","author":"init","version":0},{"n":218,"text":"\t\t.filter(([, vs]) => vs.includes(version))","atom":"a0","author":"init","version":0},{"n":219,"text":"\t\t.map(([n]) => n)","atom":"a0","author":"init","version":0},{"n":220,"text":"\t\t.toSorted();","atom":"a0","author":"init","version":0},{"n":221,"text":"\treturn names.length > 0 ? { labels: names } : {};","atom":"a0","author":"init","version":0},{"n":222,"text":"}","atom":"a0","author":"init","version":0},{"n":223,"text":"","atom":"a0","author":"init","version":0},{"n":224,"text":"/** A file as it was at a version of shared (or a named draft): its text, or null when it didn't exist. */","atom":"a0","author":"init","version":0},{"n":225,"text":"export function fileAt(","atom":"a0","author":"init","version":0},{"n":226,"text":"\thost: LogHost,","atom":"a0","author":"init","version":0},{"n":227,"text":"\tpath: string,","atom":"a0","author":"init","version":0},{"n":228,"text":"\tversion: number,","atom":"a0","author":"init","version":0},{"n":229,"text":"\toptions: { draft?: string | null; agent?: string } = {},","atom":"a0","author":"init","version":0},{"n":230,"text":"): { path: string; version: number; text: string | null; blob?: string } {","atom":"a0","author":"init","version":0},{"n":231,"text":"\thost.needInit();","atom":"a0","author":"init","version":0},{"n":232,"text":"\tcheckReadPath(path);","atom":"a0","author":"init","version":0},{"n":233,"text":"\tconst space = host.spaceFor(options);","atom":"a0","author":"init","version":0},{"n":234,"text":"\thost.checkVersion(space, version);","atom":"a0","author":"init","version":0},{"n":235,"text":"\tconst view = host.viewAt(space, version);","atom":"a0","author":"init","version":0},{"n":236,"text":"\t// Any spelling reads the stored one (#41, F7).","atom":"a0","author":"init","version":0},{"n":237,"text":"\tconst file = host.spellingIn(view, path);","atom":"a0","author":"init","version":0},{"n":238,"text":"\tconst blob = view.attrs(file).blob;","atom":"a0","author":"init","version":0},{"n":239,"text":"\treturn {","atom":"a0","author":"init","version":0},{"n":240,"text":"\t\tpath: file,","atom":"a0","author":"init","version":0},{"n":241,"text":"\t\tversion,","atom":"a0","author":"init","version":0},{"n":242,"text":"\t\ttext: view.hasFile(file) ? view.text(file) : null,","atom":"a0","author":"init","version":0},{"n":243,"text":"\t\t...(blob !== null ? { blob } : {}),","atom":"a0","author":"init","version":0},{"n":244,"text":"\t};","atom":"a0","author":"init","version":0},{"n":245,"text":"}","atom":"a0","author":"init","version":0},{"n":246,"text":"","atom":"a2987","author":"capacity","version":313},{"n":247,"text":"/**","atom":"a2987","author":"capacity","version":313},{"n":248,"text":" * fileAt for exactly this spelling, from the file's own lines (abso Capacity, 2026-10-17): no spelling lookup and no","atom":"a2987","author":"capacity","version":313},{"n":249,"text":" * list of the version's files. fileAt's hasFile answers from the version's whole path list, folded from version 0","atom":"a2987","author":"capacity","version":313},{"n":250,"text":" * when nothing's kept, and a spelling it doesn't find reads every known path. A name nothing ever wrote is one read.","atom":"a2987","author":"capacity","version":313},{"n":251,"text":" * The pipeline's project files (abso.yml and the like) are read this way on every tick.","atom":"a2987","author":"capacity","version":313},{"n":252,"text":" */","atom":"a2987","author":"capacity","version":313},{"n":253,"text":"export function fileExactAt(","atom":"a2987","author":"capacity","version":313},{"n":254,"text":"\thost: LogHost,","atom":"a2987","author":"capacity","version":313},{"n":255,"text":"\tpath: string,","atom":"a2987","author":"capacity","version":313},{"n":256,"text":"\tversion: number,","atom":"a2987","author":"capacity","version":313},{"n":257,"text":"\toptions: { draft?: string | null; agent?: string } = {},","atom":"a2987","author":"capacity","version":313},{"n":258,"text":"): { path: string; version: number; text: string | null; blob?: string } {","atom":"a2987","author":"capacity","version":313},{"n":259,"text":"\thost.needInit();","atom":"a2987","author":"capacity","version":313},{"n":260,"text":"\tcheckReadPath(path);","atom":"a2987","author":"capacity","version":313},{"n":261,"text":"\tconst space = host.spaceFor(options);","atom":"a2987","author":"capacity","version":313},{"n":262,"text":"\thost.checkVersion(space, version);","atom":"a2987","author":"capacity","version":313},{"n":263,"text":"\tif (!host.graph.hasAtomsIn(path)) return { path, version, text: null };","atom":"a2987","author":"capacity","version":313},{"n":264,"text":"\tconst view = host.viewAt(space, version);","atom":"a2987","author":"capacity","version":313},{"n":265,"text":"\tconst attrs = view.attrs(path);","atom":"a2987","author":"capacity","version":313},{"n":266,"text":"\t// hasFile's own test, without its path list: kept while empty, a link, a binary, or a visible line.","atom":"a2987","author":"capacity","version":313},{"n":267,"text":"\tconst exists = attrs.exists || attrs.link !== null || attrs.blob !== null || view.lines(path).length > 0;","atom":"a2987","author":"capacity","version":313},{"n":268,"text":"\treturn {","atom":"a2987","author":"capacity","version":313},{"n":269,"text":"\t\tpath,","atom":"a2987","author":"capacity","version":313},{"n":270,"text":"\t\tversion,","atom":"a2987","author":"capacity","version":313},{"n":271,"text":"\t\ttext: exists ? view.text(path) : null,","atom":"a2987","author":"capacity","version":313},{"n":272,"text":"\t\t...(attrs.blob !== null ? { blob: attrs.blob } : {}),","atom":"a2987","author":"capacity","version":313},{"n":273,"text":"\t};","atom":"a2987","author":"capacity","version":313},{"n":274,"text":"}","atom":"a2987","author":"capacity","version":313},{"n":275,"text":"","atom":"a0","author":"init","version":0},{"n":276,"text":"/** The files that may differ between two versions, and both views: compare's and compareSummary's ground. */","atom":"a2495","author":"capacity","version":244},{"n":277,"text":"function compared(","atom":"a2495","author":"capacity","version":244},{"n":278,"text":"\thost: LogHost,","atom":"a0","author":"init","version":0},{"n":279,"text":"\tfrom: number,","atom":"a0","author":"init","version":0},{"n":280,"text":"\tto: number,","atom":"a0","author":"init","version":0},{"n":281,"text":"\toptions: { draft?: string | null; agent?: string },","atom":"a2495","author":"capacity","version":244},{"n":282,"text":"): { before: ReadView; after: ReadView; files: Set<string> } {","atom":"a2495","author":"capacity","version":244},{"n":283,"text":"\thost.needInit();","atom":"a0","author":"init","version":0},{"n":284,"text":"\tconst space = host.spaceFor(options);","atom":"a0","author":"init","version":0},{"n":285,"text":"\thost.checkVersion(space, from);","atom":"a0","author":"init","version":0},{"n":286,"text":"\thost.checkVersion(space, to);","atom":"a0","author":"init","version":0},{"n":287,"text":"\tconst before = host.viewAt(space, from);","atom":"a1785","author":"codex-capacity-chair","version":163},{"n":288,"text":"\tconst after = host.viewAt(space, to);","atom":"a1785","author":"codex-capacity-chair","version":163},{"n":289,"text":"\tconst files = new Set<string>();","atom":"a0","author":"init","version":0},{"n":290,"text":"\t// A stored writer keeps each shared version's changed files (version-files.ts, abso Capacity): every file that","atom":"a2331","author":"capacity","version":208},{"n":291,"text":"\t// differs between two versions changed in one between them, so those lists are the candidates, not every atom","atom":"a2331","author":"capacity","version":208},{"n":292,"text":"\t// either set holds.","atom":"a2331","author":"capacity","version":208},{"n":293,"text":"\tif (space.name === SHARED && host.graph.packedFiles) {","atom":"a2331","author":"capacity","version":208},{"n":294,"text":"\t\tfor (let v = Math.min(from, to) + 1; v <= Math.max(from, to); v++)","atom":"a2331","author":"capacity","version":208},{"n":295,"text":"\t\t\tfor (const file of host.paths.versionFiles(space, v)) files.add(file);","atom":"a2331","author":"capacity","version":208},{"n":296,"text":"\t\treturn { before, after, files };","atom":"a2495","author":"capacity","version":244},{"n":297,"text":"\t}","atom":"a2331","author":"capacity","version":208},{"n":298,"text":"\tconst a = host.at(space, from);","atom":"a0","author":"init","version":0},{"n":299,"text":"\tconst b = host.at(space, to);","atom":"a0","author":"init","version":0},{"n":300,"text":"\tfor (const [x, y] of [","atom":"a0","author":"init","version":0},{"n":301,"text":"\t\t[a, b],","atom":"a0","author":"init","version":0},{"n":302,"text":"\t\t[b, a],","atom":"a0","author":"init","version":0},{"n":303,"text":"\t] as const) {","atom":"a0","author":"init","version":0},{"n":304,"text":"\t\tfor (const file of host.touchedFiles(","atom":"a0","author":"init","version":0},{"n":305,"text":"\t\t\t(function* () {","atom":"a1785","author":"codex-capacity-chair","version":163},{"n":306,"text":"\t\t\t\tfor (const id of x) if (!y.has(id)) yield id;","atom":"a1785","author":"codex-capacity-chair","version":163},{"n":307,"text":"\t\t\t})(),","atom":"a1785","author":"codex-capacity-chair","version":163},{"n":308,"text":"\t\t\t[before, after],","atom":"a1785","author":"codex-capacity-chair","version":163},{"n":309,"text":"\t\t))","atom":"a0","author":"init","version":0},{"n":310,"text":"\t\t\tfiles.add(file);","atom":"a0","author":"init","version":0},{"n":311,"text":"\t}","atom":"a0","author":"init","version":0},{"n":312,"text":"\treturn { before, after, files };","atom":"a2495","author":"capacity","version":244},{"n":313,"text":"}","atom":"a2495","author":"capacity","version":244},{"n":314,"text":"","atom":"a2495","author":"capacity","version":244},{"n":315,"text":"/** Every file that differs between two versions of shared (or a named draft), before (at `from`) and after (at `to`). */","atom":"a0","author":"init","version":0},{"n":316,"text":"export function compare(","atom":"a0","author":"init","version":0},{"n":317,"text":"\thost: LogHost,","atom":"a2495","author":"capacity","version":244},{"n":318,"text":"\tfrom: number,","atom":"a2495","author":"capacity","version":244},{"n":319,"text":"\tto: number,","atom":"a2495","author":"capacity","version":244},{"n":320,"text":"\toptions: { draft?: string | null; agent?: string } = {},","atom":"a2495","author":"capacity","version":244},{"n":321,"text":"): { from: number; to: number; files: FileChange[] } {","atom":"a2495","author":"capacity","version":244},{"n":322,"text":"\tconst { before, after, files } = compared(host, from, to, options);","atom":"a2495","author":"capacity","version":244},{"n":323,"text":"\treturn { from, to, files: changesBetween(before, after, files) };","atom":"a2495","author":"capacity","version":244},{"n":324,"text":"}","atom":"a2495","author":"capacity","version":244},{"n":325,"text":"","atom":"a2495","author":"capacity","version":244},{"n":326,"text":"/** compare's files as each one's size and SHA-256 before and after, not its texts (abso issue 680). */","atom":"a2495","author":"capacity","version":244},{"n":327,"text":"export function compareSummary(","atom":"a2495","author":"capacity","version":244},{"n":328,"text":"\thost: LogHost,","atom":"a2495","author":"capacity","version":244},{"n":329,"text":"\tfrom: number,","atom":"a2495","author":"capacity","version":244},{"n":330,"text":"\tto: number,","atom":"a2495","author":"capacity","version":244},{"n":331,"text":"\toptions: { draft?: string | null; agent?: string } = {},","atom":"a2495","author":"capacity","version":244},{"n":332,"text":"): { from: number; to: number; summary: true; files: ReturnType<typeof summariesBetween> } {","atom":"a2495","author":"capacity","version":244},{"n":333,"text":"\tconst { before, after, files } = compared(host, from, to, options);","atom":"a2495","author":"capacity","version":244},{"n":334,"text":"\treturn { from, to, summary: true, files: summariesBetween(before, after, files) };","atom":"a2495","author":"capacity","version":244},{"n":335,"text":"}","atom":"a0","author":"init","version":0},{"n":336,"text":"","atom":"a0","author":"init","version":0},{"n":337,"text":"/** A version of shared (or of a named draft) as a ReadView, for reading lines (blame at a version). */","atom":"a1363","author":"codex-capacity-chair","version":143},{"n":338,"text":"export function viewAt(","atom":"a1363","author":"codex-capacity-chair","version":143},{"n":339,"text":"\thost: LogHost,","atom":"a1363","author":"codex-capacity-chair","version":143},{"n":340,"text":"\tversion: number,","atom":"a1363","author":"codex-capacity-chair","version":143},{"n":341,"text":"\toptions: { draft?: string | null; agent?: string } = {},","atom":"a1363","author":"codex-capacity-chair","version":143},{"n":342,"text":"): ReadView {","atom":"a1363","author":"codex-capacity-chair","version":143},{"n":343,"text":"\thost.needInit();","atom":"a0","author":"init","version":0},{"n":344,"text":"\tconst space = host.spaceFor(options);","atom":"a0","author":"init","version":0},{"n":345,"text":"\thost.checkVersion(space, version);","atom":"a0","author":"init","version":0},{"n":346,"text":"\treturn host.viewAt(space, version);","atom":"a0","author":"init","version":0},{"n":347,"text":"}","atom":"a0","author":"init","version":0}],"atoms":[{"atom":"a0","author":"init","message":"Start the project","time":1791506895507,"timeIso":"2026-10-09T00:48:15.507Z","publish":{"draft":null,"version":0,"agent":"init","message":"Start the project","time":1791506895507,"timeIso":"2026-10-09T00:48:15.507Z"}},{"atom":"a1363","author":"codex-capacity-chair","message":"","time":1791854964720,"timeIso":"2026-10-13T01:29:24.720Z","publish":{"draft":null,"version":143,"agent":"codex-capacity-chair","message":"Add inactive disk projection provider and verified transactional readers (#16)","time":1791855032023,"timeIso":"2026-10-13T01:30:32.023Z"}},{"atom":"a1785","author":"codex-capacity-chair","message":"","time":1791948048631,"timeIso":"2026-10-14T03:20:48.631Z","publish":{"draft":null,"version":163,"agent":"codex-capacity-chair","message":"Integrate reviewed disk-backed operations, queue and bounded read caches","time":1791949753900,"timeIso":"2026-10-14T03:49:13.900Z"}},{"atom":"a2331","author":"capacity","message":"","time":1792033800215,"timeIso":"2026-10-15T03:10:00.215Z","publish":{"draft":null,"version":208,"agent":"capacity","message":"Compare 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.","time":1792033800215,"timeIso":"2026-10-15T03:10:00.215Z"}},{"atom":"a2487","author":"capacity","message":"","time":1792072853745,"timeIso":"2026-10-15T14:00:53.745Z","publish":{"draft":null,"version":243,"agent":"capacity","message":"compare's summary: each changed file's size and SHA-256 instead of its texts (abso issue 680; disk-first 2; abso Capacity).\n\ncompare 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.\n\n- 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.\n- 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.\n\nOn 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.\n\nNew 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.","time":1792072854373,"timeIso":"2026-10-15T14:00:54.373Z"}},{"atom":"a2495","author":"capacity","message":"","time":1792079189805,"timeIso":"2026-10-15T15:46:29.805Z","publish":{"draft":null,"version":244,"agent":"capacity","message":"compare keeps its own answer type; the summary is compareSummary (abso issue 680; abso Capacity).\n\n243 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.\n\n- 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.\n- 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).\n- compare-summary.test.ts calls compareSummary.\n\nAnswers 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.","time":1792079189805,"timeIso":"2026-10-15T15:46:29.805Z"}},{"atom":"a2600","author":"capacity","message":"","time":1792090092833,"timeIso":"2026-10-15T18:48:12.833Z","publish":{"draft":null,"version":254,"agent":"capacity","message":"A file's history checks each version's files before building its entry (abso Capacity, issue 664).\n\nlog 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.\n\nOn 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).","time":1792090215195,"timeIso":"2026-10-15T18:50:15.195Z"}},{"atom":"a2987","author":"capacity","message":"","time":1792204350594,"timeIso":"2026-10-17T02:32:30.594Z","publish":{"draft":null,"version":313,"agent":"capacity","message":"fileExactAt: 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)\n\n- 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.\n- 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.\n- Project.fileExactAt; and ProjectHistory.fileExactAt, optional, so abso's pin compiles before its engine passes it through.\n- 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.\n\nChecks: tsc clean; Biome clean; core tests (worker/project and src) 767 of 768 passed, 1 skipped, none failed.","time":1792205845200,"timeIso":"2026-10-17T02:57:25.200Z"}}]}