{"file":"worker/project/without.ts","version":318,"total":183,"from":1,"to":183,"lines":[{"n":1,"text":"// A version of shared without some earlier versions: the files that version's atoms make when the atoms those","atom":"a2080","author":"candidates","version":186},{"n":2,"text":"// versions added are left out. Shared doesn't change, and nothing is written: it is a read. The atoms keep","atom":"a2080","author":"candidates","version":186},{"n":3,"text":"// their ids and authors; nothing is replayed or renumbered.","atom":"a2080","author":"candidates","version":186},{"n":4,"text":"//","atom":"a2080","author":"candidates","version":186},{"n":5,"text":"// The set left is checked exactly as asked. When a kept version builds on a left-out one, the answer is a","atom":"a2080","author":"candidates","version":186},{"n":6,"text":"// refusal naming that chain, the files and the wider set that would work. It is never widened silently, and","atom":"a2080","author":"candidates","version":186},{"n":7,"text":"// never closed again by a helper that would bring a left-out atom back.","atom":"a2080","author":"candidates","version":186},{"n":8,"text":"","atom":"a2080","author":"candidates","version":186},{"n":9,"text":"import { type AtomId, type Graph, type ReadView, View } from \"../../src/engine/index.ts\";","atom":"a2080","author":"candidates","version":186},{"n":10,"text":"import { ProjectError } from \"./project-error.ts\";","atom":"a2080","author":"candidates","version":186},{"n":11,"text":"import type { FileChange } from \"./project-types.ts\";","atom":"a2080","author":"candidates","version":186},{"n":12,"text":"import type { Space } from \"./spaces.ts\";","atom":"a2087","author":"candidates","version":186},{"n":13,"text":"import { treeHash } from \"./tree.ts\";","atom":"a2080","author":"candidates","version":186},{"n":14,"text":"import { changesBetween, modesOf } from \"./view-changes.ts\";","atom":"a2080","author":"candidates","version":186},{"n":15,"text":"","atom":"a2080","author":"candidates","version":186},{"n":16,"text":"/** What a version without others needs from a project. */","atom":"a2080","author":"candidates","version":186},{"n":17,"text":"export interface WithoutHost {","atom":"a2080","author":"candidates","version":186},{"n":18,"text":"\treadonly graph: Graph;","atom":"a2080","author":"candidates","version":186},{"n":19,"text":"\tshared(): Space;","atom":"a2080","author":"candidates","version":186},{"n":20,"text":"\tneedInit(): void;","atom":"a2080","author":"candidates","version":186},{"n":21,"text":"\tcheckVersion(space: Space, version: number): void;","atom":"a2080","author":"candidates","version":186},{"n":22,"text":"\tviewAt(space: Space, version: number): ReadView;","atom":"a2080","author":"candidates","version":186},{"n":23,"text":"\tat(space: Space, version: number): ReadonlySet<AtomId>;","atom":"a2080","author":"candidates","version":186},{"n":24,"text":"\t/** The set as a view of it reads it: with any discarded atom a publish still depends on. */","atom":"a2080","author":"candidates","version":186},{"n":25,"text":"\tclosed(set: ReadonlySet<AtomId>): ReadonlySet<AtomId>;","atom":"a2080","author":"candidates","version":186},{"n":26,"text":"\ttouchedFiles(ids: Iterable<AtomId>, views: readonly ReadView[]): Set<string>;","atom":"a2080","author":"candidates","version":186},{"n":27,"text":"}","atom":"a2080","author":"candidates","version":186},{"n":28,"text":"","atom":"a2080","author":"candidates","version":186},{"n":29,"text":"/** A version, as the answer names it. */","atom":"a2080","author":"candidates","version":186},{"n":30,"text":"export interface VersionNamed {","atom":"a2080","author":"candidates","version":186},{"n":31,"text":"\tversion: number;","atom":"a2080","author":"candidates","version":186},{"n":32,"text":"\tagent: string;","atom":"a2080","author":"candidates","version":186},{"n":33,"text":"\tmessage: string;","atom":"a2080","author":"candidates","version":186},{"n":34,"text":"}","atom":"a2080","author":"candidates","version":186},{"n":35,"text":"","atom":"a2080","author":"candidates","version":186},{"n":36,"text":"/** A kept version that builds on a left-out one: the versions it builds on, and in which files. */","atom":"a2080","author":"candidates","version":186},{"n":37,"text":"export interface BuildsOn extends VersionNamed {","atom":"a2080","author":"candidates","version":186},{"n":38,"text":"\tneeds: { version: number; files: string[] }[];","atom":"a2080","author":"candidates","version":186},{"n":39,"text":"}","atom":"a2080","author":"candidates","version":186},{"n":40,"text":"","atom":"a2080","author":"candidates","version":186},{"n":41,"text":"export type WithoutAnswer =","atom":"a2080","author":"candidates","version":186},{"n":42,"text":"\t| {","atom":"a2080","author":"candidates","version":186},{"n":43,"text":"\t\t\tok: true;","atom":"a2080","author":"candidates","version":186},{"n":44,"text":"\t\t\tversion: number;","atom":"a2080","author":"candidates","version":186},{"n":45,"text":"\t\t\twithout: VersionNamed[];","atom":"a2080","author":"candidates","version":186},{"n":46,"text":"\t\t\t/** Every file that differs from the version as it is: before, in it; after, without the others. */","atom":"a2080","author":"candidates","version":186},{"n":47,"text":"\t\t\tfiles: FileChange[];","atom":"a2080","author":"candidates","version":186},{"n":48,"text":"\t\t\t/** The tree hash (tree.ts) of every file without them: the same ask always gives the same hash. */","atom":"a2080","author":"candidates","version":186},{"n":49,"text":"\t\t\ttree: string;","atom":"a2080","author":"candidates","version":186},{"n":50,"text":"\t  }","atom":"a2080","author":"candidates","version":186},{"n":51,"text":"\t| {","atom":"a2080","author":"candidates","version":186},{"n":52,"text":"\t\t\tok: false;","atom":"a2080","author":"candidates","version":186},{"n":53,"text":"\t\t\tversion: number;","atom":"a2080","author":"candidates","version":186},{"n":54,"text":"\t\t\twithout: VersionNamed[];","atom":"a2080","author":"candidates","version":186},{"n":55,"text":"\t\t\t/** Kept versions that build on left-out ones, oldest first: each with what it builds on. */","atom":"a2080","author":"candidates","version":186},{"n":56,"text":"\t\t\tdependents: BuildsOn[];","atom":"a2080","author":"candidates","version":186},{"n":57,"text":"\t\t\t/** The versions to leave out for it to work: these and every dependent. A suggestion, never applied. */","atom":"a2080","author":"candidates","version":186},{"n":58,"text":"\t\t\tsuggestion: number[];","atom":"a2080","author":"candidates","version":186},{"n":59,"text":"\t  };","atom":"a2080","author":"candidates","version":186},{"n":60,"text":"","atom":"a2080","author":"candidates","version":186},{"n":61,"text":"/**","atom":"a2080","author":"candidates","version":186},{"n":62,"text":" * Version `version` of shared without the versions in `without`: what its","atom":"a2080","author":"candidates","version":186},{"n":63,"text":" * files are when those versions' atoms are left out. Refused, with the","atom":"a2080","author":"candidates","version":186},{"n":64,"text":" * chain, when a version kept builds on one left out.","atom":"a2080","author":"candidates","version":186},{"n":65,"text":" */","atom":"a2080","author":"candidates","version":186},{"n":66,"text":"export function without(host: WithoutHost, version: number, versions: readonly number[]): WithoutAnswer {","atom":"a2080","author":"candidates","version":186},{"n":67,"text":"\thost.needInit();","atom":"a2080","author":"candidates","version":186},{"n":68,"text":"\tconst shared = host.shared();","atom":"a2080","author":"candidates","version":186},{"n":69,"text":"\tif (!Number.isInteger(version)) throw new ProjectError(\"bad-request\", \"version must be a number\");","atom":"a2080","author":"candidates","version":186},{"n":70,"text":"\thost.checkVersion(shared, version);","atom":"a2080","author":"candidates","version":186},{"n":71,"text":"\tif (!Array.isArray(versions) || versions.length === 0)","atom":"a2080","author":"candidates","version":186},{"n":72,"text":"\t\tthrow new ProjectError(\"bad-request\", \"without needs the versions to leave out\");","atom":"a2080","author":"candidates","version":186},{"n":73,"text":"\tconst g = host.graph;","atom":"a2080","author":"candidates","version":186},{"n":74,"text":"\tconst asked = [...new Set(versions)].toSorted((a, b) => a - b);","atom":"a2080","author":"candidates","version":186},{"n":75,"text":"\tconst base = host.at(shared, version);","atom":"a2080","author":"candidates","version":186},{"n":76,"text":"\tconst out = new Set<AtomId>();","atom":"a2080","author":"candidates","version":186},{"n":77,"text":"\tfor (const v of asked) {","atom":"a2080","author":"candidates","version":186},{"n":78,"text":"\t\tif (!Number.isInteger(v) || v < 1)","atom":"a2080","author":"candidates","version":186},{"n":79,"text":"\t\t\tthrow new ProjectError(","atom":"a2080","author":"candidates","version":186},{"n":80,"text":"\t\t\t\t\"bad-request\",","atom":"a2080","author":"candidates","version":186},{"n":81,"text":"\t\t\t\t`there is no version ${String(v)} to leave out (version 0 is the start, which everything builds on)`,","atom":"a2080","author":"candidates","version":186},{"n":82,"text":"\t\t\t);","atom":"a2080","author":"candidates","version":186},{"n":83,"text":"\t\tif (v > version)","atom":"a2080","author":"candidates","version":186},{"n":84,"text":"\t\t\tthrow new ProjectError(\"bad-request\", `version ${v} comes after version ${version}, so it isn't in it`);","atom":"a2080","author":"candidates","version":186},{"n":85,"text":"\t\tconst p = shared.versions[v]!;","atom":"a2080","author":"candidates","version":186},{"n":86,"text":"\t\tif (p.atoms.length === 0)","atom":"a2080","author":"candidates","version":186},{"n":87,"text":"\t\t\tthrow new ProjectError(","atom":"a2104","author":"candidates","version":186},{"n":88,"text":"\t\t\t\t\"bad-request\",","atom":"a2104","author":"candidates","version":186},{"n":89,"text":"\t\t\t\t`version ${v} added nothing (it is a drop), so there is nothing to leave out`,","atom":"a2104","author":"candidates","version":186},{"n":90,"text":"\t\t\t);","atom":"a2104","author":"candidates","version":186},{"n":91,"text":"\t\tconst left = p.atoms.filter((id) => base.has(id));","atom":"a2080","author":"candidates","version":186},{"n":92,"text":"\t\tif (left.length === 0)","atom":"a2080","author":"candidates","version":186},{"n":93,"text":"\t\t\tthrow new ProjectError(","atom":"a2080","author":"candidates","version":186},{"n":94,"text":"\t\t\t\t\"bad-request\",","atom":"a2080","author":"candidates","version":186},{"n":95,"text":"\t\t\t\t`version ${v} isn't in version ${version}: version ${shared.droppedIn.get(p.atoms[0]!)} dropped it`,","atom":"a2080","author":"candidates","version":186},{"n":96,"text":"\t\t\t);","atom":"a2080","author":"candidates","version":186},{"n":97,"text":"\t\tfor (const id of left) out.add(id);","atom":"a2080","author":"candidates","version":186},{"n":98,"text":"\t}","atom":"a2080","author":"candidates","version":186},{"n":99,"text":"\tconst describe = (v: number): VersionNamed => ({","atom":"a2080","author":"candidates","version":186},{"n":100,"text":"\t\tversion: v,","atom":"a2080","author":"candidates","version":186},{"n":101,"text":"\t\tagent: shared.versions[v]!.agent,","atom":"a2080","author":"candidates","version":186},{"n":102,"text":"\t\tmessage: shared.versions[v]!.message,","atom":"a2080","author":"candidates","version":186},{"n":103,"text":"\t});","atom":"a2080","author":"candidates","version":186},{"n":104,"text":"\tconst kept = new Set<AtomId>();","atom":"a2080","author":"candidates","version":186},{"n":105,"text":"\tfor (const id of host.closed(base)) if (!out.has(id)) kept.add(id);","atom":"a2080","author":"candidates","version":186},{"n":106,"text":"","atom":"a2080","author":"candidates","version":186},{"n":107,"text":"\t// Everything kept that builds on what is left out, and the step that reached it.","atom":"a2080","author":"candidates","version":186},{"n":108,"text":"\tconst gone = new Set(out);","atom":"a2080","author":"candidates","version":186},{"n":109,"text":"\tconst steps: { from: AtomId; to: AtomId }[] = [];","atom":"a2080","author":"candidates","version":186},{"n":110,"text":"\tconst stack = [...out];","atom":"a2080","author":"candidates","version":186},{"n":111,"text":"\twhile (stack.length > 0) {","atom":"a2080","author":"candidates","version":186},{"n":112,"text":"\t\tconst id = stack.pop()!;","atom":"a2080","author":"candidates","version":186},{"n":113,"text":"\t\tfor (const d of g.dependentsOf(id)) {","atom":"a2080","author":"candidates","version":186},{"n":114,"text":"\t\t\tif (!kept.has(d)) continue;","atom":"a2080","author":"candidates","version":186},{"n":115,"text":"\t\t\tsteps.push({ from: d, to: id });","atom":"a2080","author":"candidates","version":186},{"n":116,"text":"\t\t\tif (gone.has(d)) continue;","atom":"a2080","author":"candidates","version":186},{"n":117,"text":"\t\t\tgone.add(d);","atom":"a2080","author":"candidates","version":186},{"n":118,"text":"\t\t\tstack.push(d);","atom":"a2080","author":"candidates","version":186},{"n":119,"text":"\t\t}","atom":"a2080","author":"candidates","version":186},{"n":120,"text":"\t}","atom":"a2080","author":"candidates","version":186},{"n":121,"text":"\tif (gone.size > out.size) {","atom":"a2080","author":"candidates","version":186},{"n":122,"text":"\t\t// A discarded atom a publish still needs has no version of its own: it counts with the version that needs it.","atom":"a2080","author":"candidates","version":186},{"n":123,"text":"\t\tconst versionOf = (id: AtomId): number | undefined => shared.publishedIn.get(id);","atom":"a2080","author":"candidates","version":186},{"n":124,"text":"\t\tconst needs = new Map<number, Map<number, Set<string>>>();","atom":"a2080","author":"candidates","version":186},{"n":125,"text":"\t\tconst resolved = (id: AtomId, seen = new Set<AtomId>()): number[] => {","atom":"a2080","author":"candidates","version":186},{"n":126,"text":"\t\t\tconst v = versionOf(id);","atom":"a2080","author":"candidates","version":186},{"n":127,"text":"\t\t\tif (v !== undefined) return [v];","atom":"a2080","author":"candidates","version":186},{"n":128,"text":"\t\t\tif (seen.has(id)) return [];","atom":"a2080","author":"candidates","version":186},{"n":129,"text":"\t\t\tseen.add(id);","atom":"a2080","author":"candidates","version":186},{"n":130,"text":"\t\t\treturn [...new Set(steps.filter((s) => s.from === id).flatMap((s) => resolved(s.to, seen)))];","atom":"a2080","author":"candidates","version":186},{"n":131,"text":"\t\t};","atom":"a2080","author":"candidates","version":186},{"n":132,"text":"\t\tfor (const { from, to } of steps) {","atom":"a2080","author":"candidates","version":186},{"n":133,"text":"\t\t\tconst dv = versionOf(from);","atom":"a2080","author":"candidates","version":186},{"n":134,"text":"\t\t\tif (dv === undefined) continue;","atom":"a2080","author":"candidates","version":186},{"n":135,"text":"\t\t\tconst files = g.filesOf(from).length > 0 ? g.filesOf(from) : g.filesOf(to);","atom":"a2080","author":"candidates","version":186},{"n":136,"text":"\t\t\tfor (const nv of resolved(to)) {","atom":"a2080","author":"candidates","version":186},{"n":137,"text":"\t\t\t\tif (nv === dv) continue;","atom":"a2080","author":"candidates","version":186},{"n":138,"text":"\t\t\t\tlet of = needs.get(dv);","atom":"a2080","author":"candidates","version":186},{"n":139,"text":"\t\t\t\tif (!of) needs.set(dv, (of = new Map()));","atom":"a2080","author":"candidates","version":186},{"n":140,"text":"\t\t\t\tlet set = of.get(nv);","atom":"a2080","author":"candidates","version":186},{"n":141,"text":"\t\t\t\tif (!set) of.set(nv, (set = new Set()));","atom":"a2080","author":"candidates","version":186},{"n":142,"text":"\t\t\t\tfor (const f of files) set.add(f);","atom":"a2080","author":"candidates","version":186},{"n":143,"text":"\t\t\t}","atom":"a2080","author":"candidates","version":186},{"n":144,"text":"\t\t}","atom":"a2080","author":"candidates","version":186},{"n":145,"text":"\t\tconst dependents = [...needs.keys()]","atom":"a2080","author":"candidates","version":186},{"n":146,"text":"\t\t\t.filter((v) => !asked.includes(v))","atom":"a2080","author":"candidates","version":186},{"n":147,"text":"\t\t\t.toSorted((a, b) => a - b)","atom":"a2080","author":"candidates","version":186},{"n":148,"text":"\t\t\t.map((v) => ({","atom":"a2080","author":"candidates","version":186},{"n":149,"text":"\t\t\t\t...describe(v),","atom":"a2080","author":"candidates","version":186},{"n":150,"text":"\t\t\t\tneeds: [...needs.get(v)!]","atom":"a2080","author":"candidates","version":186},{"n":151,"text":"\t\t\t\t\t.toSorted(([a], [b]) => a - b)","atom":"a2080","author":"candidates","version":186},{"n":152,"text":"\t\t\t\t\t.map(([n, files]) => ({ version: n, files: [...files].toSorted() })),","atom":"a2080","author":"candidates","version":186},{"n":153,"text":"\t\t\t}));","atom":"a2080","author":"candidates","version":186},{"n":154,"text":"\t\treturn {","atom":"a2080","author":"candidates","version":186},{"n":155,"text":"\t\t\tok: false,","atom":"a2080","author":"candidates","version":186},{"n":156,"text":"\t\t\tversion,","atom":"a2080","author":"candidates","version":186},{"n":157,"text":"\t\t\twithout: asked.map(describe),","atom":"a2080","author":"candidates","version":186},{"n":158,"text":"\t\t\tdependents,","atom":"a2080","author":"candidates","version":186},{"n":159,"text":"\t\t\tsuggestion: [...new Set([...asked, ...dependents.map((d) => d.version)])].toSorted((a, b) => a - b),","atom":"a2080","author":"candidates","version":186},{"n":160,"text":"\t\t};","atom":"a2080","author":"candidates","version":186},{"n":161,"text":"\t}","atom":"a2080","author":"candidates","version":186},{"n":162,"text":"","atom":"a2080","author":"candidates","version":186},{"n":163,"text":"\t// The set is checked; the engine's View refuses one that isn't closed, so nothing left out comes back.","atom":"a2080","author":"candidates","version":186},{"n":164,"text":"\tconst before = host.viewAt(shared, version);","atom":"a2080","author":"candidates","version":186},{"n":165,"text":"\tconst after = new View(g, kept);","atom":"a2080","author":"candidates","version":186},{"n":166,"text":"\tconst files = changesBetween(before, after, host.touchedFiles(out, [before, after]));","atom":"a2080","author":"candidates","version":186},{"n":167,"text":"\tconst all = after.paths();","atom":"a2080","author":"candidates","version":186},{"n":168,"text":"\tconst blobs: Record<string, string> = {};","atom":"a2080","author":"candidates","version":186},{"n":169,"text":"\tconst texts: Record<string, string> = {};","atom":"a2080","author":"candidates","version":186},{"n":170,"text":"\tfor (const path of all) {","atom":"a2080","author":"candidates","version":186},{"n":171,"text":"\t\tconst blob = after.attrs(path).blob;","atom":"a2080","author":"candidates","version":186},{"n":172,"text":"\t\tif (blob !== null) blobs[path] = blob;","atom":"a2080","author":"candidates","version":186},{"n":173,"text":"\t\telse texts[path] = after.text(path);","atom":"a2080","author":"candidates","version":186},{"n":174,"text":"\t}","atom":"a2080","author":"candidates","version":186},{"n":175,"text":"\tconst modes = modesOf(after);","atom":"a2080","author":"candidates","version":186},{"n":176,"text":"\treturn {","atom":"a2080","author":"candidates","version":186},{"n":177,"text":"\t\tok: true,","atom":"a2080","author":"candidates","version":186},{"n":178,"text":"\t\tversion,","atom":"a2080","author":"candidates","version":186},{"n":179,"text":"\t\twithout: asked.map(describe),","atom":"a2080","author":"candidates","version":186},{"n":180,"text":"\t\tfiles,","atom":"a2080","author":"candidates","version":186},{"n":181,"text":"\t\ttree: treeHash({ files: texts, blobs, modes }),","atom":"a2080","author":"candidates","version":186},{"n":182,"text":"\t};","atom":"a2080","author":"candidates","version":186},{"n":183,"text":"}","atom":"a2080","author":"candidates","version":186}],"atoms":[{"atom":"a2080","author":"candidates","message":"","time":1792003353704,"timeIso":"2026-10-14T18:42:33.704Z","publish":{"draft":null,"version":186,"agent":"candidates","message":"Read a version of shared without some earlier versions: abso show <N> --without A,B shows what differs and abso export <dir> --version N --without A,B writes the files. The server's GET without?version=&versions= checks the set left exactly as asked: when a version it keeps builds on one left out, it refuses with that chain, the files and the wider set that works, and never widens it. Atoms keep their ids and authors; shared and its log don't change; the same ask gives the same tree hash.","time":1792004002371,"timeIso":"2026-10-14T18:53:22.371Z"}},{"atom":"a2087","author":"candidates","message":"","time":1792003409924,"timeIso":"2026-10-14T18:43:29.924Z","publish":{"draft":null,"version":186,"agent":"candidates","message":"Read a version of shared without some earlier versions: abso show <N> --without A,B shows what differs and abso export <dir> --version N --without A,B writes the files. The server's GET without?version=&versions= checks the set left exactly as asked: when a version it keeps builds on one left out, it refuses with that chain, the files and the wider set that works, and never widens it. Atoms keep their ids and authors; shared and its log don't change; the same ask gives the same tree hash.","time":1792004002371,"timeIso":"2026-10-14T18:53:22.371Z"}},{"atom":"a2104","author":"candidates","message":"","time":1792003808372,"timeIso":"2026-10-14T18:50:08.372Z","publish":{"draft":null,"version":186,"agent":"candidates","message":"Read a version of shared without some earlier versions: abso show <N> --without A,B shows what differs and abso export <dir> --version N --without A,B writes the files. The server's GET without?version=&versions= checks the set left exactly as asked: when a version it keeps builds on one left out, it refuses with that chain, the files and the wider set that works, and never widens it. Atoms keep their ids and authors; shared and its log don't change; the same ask gives the same tree hash.","time":1792004002371,"timeIso":"2026-10-14T18:53:22.371Z"}}]}