Moves picked as walks reach them, and shared's file list from kept shapes (disk-first 2; abso Capacity), for abso's status, drafts and file list. Version 216 of shared· capacity· Oct 15 (2026-10-15 05:07 UTC) · Not checked
view.ts: a view picks a moved line's relocation only when a walk to find a line's file reaches that line. That is #relocations' own pick, right whenever the walk goes on to a file's start, since only lines on a loop have their relocation set aside; a walk that comes back to a line it passed resolves every move as before. shareMoves now takes the other view's moves only when this view first needs all of them, such as for a layout, so a view that only finds a few lines' files never resolves them. weight() counts the picks. pathindex.ts keptPaths: shared's files at a version, folded from version 0 over each version's kept files made and taken out, with no file laid out. Only on a stored writer, and only when every version up to it has a kept row that describes it; otherwise the version is laid out as before. pathsAt uses it. On abso's export (81,855 entries, 1,224 versions), one opened project, answers matching Project.load:
status: 104 s to 5.8 s (under the profiler) drafts: over 60 s to 5.7 s files at head: over 60 s to 1.2 s files at 612: 54 s to 0.3 s version-files.test.ts now also checks the file list at every version against the in-memory project. 124 of 124 related tests pass; tsc clean.
Version 215 · Files at version 216
5 files, 86 lines added, 6 removed.
--- a/src/engine/view.ts
+++ b/src/engine/view.ts
@@ -295,6 +295,8 @@
296 296 #relocations(): Map<LineId, RelocationInfo> { 297 297 if (this.#relocs) return this.#relocs; 299 + if (this.#relocs) return this.#relocs; 298 300 const graph = this.graph; 299 301 const skeleton = skeletonOf(graph); 300 302 const stronger = (a: RelocationInfo, b: RelocationInfo): boolean => graph.comparePriority(a.atom, b.atom) > 0; @@ -365,13 +367,25 @@
365 367 return this.#relocs; 370 + /** The view whose moves this one may take, until it needs them all; then the view it took them from. */ 371 + #movesFrom: View | undefined; 372 + #movesTaken: View | undefined; 369 375 * Take another view's resolved moves (abso Capacity), when both sets hold the very same atoms that move lines: the 370 − * moves then resolve the same, and every line sits where it sits there. Checked here, so any caller may ask.
376 + * moves then resolve the same, and every line sits where it sits there. Checked when this view first needs all its 377 + * moves, so any caller may ask, and a view that only finds a few lines' files never resolves them. 372 379 shareMoves(from: View): void { 373 − if (from.graph !== this.graph || from.#hasMoves !== this.#hasMoves || !this.#hasMoves) return;
374 − if (this.#relocs || from.#scratchMoves()) return;
380 + if (from.graph !== this.graph || from.#hasMoves !== this.#hasMoves || !this.#hasMoves || this.#relocs) return; 381 + this.#movesFrom = from; 384 + #takeShared(): void { 385 + const from = this.#movesFrom; 387 + this.#movesFrom = undefined; 388 + if (from.#scratchMoves()) return; 375 389 for (const id of this.graph.movers()) { 376 390 const seq = seqOf(id); 377 391 if (this.#has(seq) !== from.#has(seq)) return; @@ -379,9 +393,29 @@
379 393 this.#relocs = from.#relocations(); 380 394 this.#relocsN = from.#relocationsN(); 381 395 this.#movesOnDisk = false; 382 − this.#movedFrom = from.#movedInFrom();
396 + this.#movesTaken = from; 399 + /** Moved lines' relocations picked one at a time, before the view resolves them all (null: not moved here). */ 400 + readonly #picked = new Map<number, MoveEntry | null>(); 403 + * The relocation of moved line n that counts here, as #relocations picks it before any loop: right whenever the 404 + * walk that reached n goes on to a file's start, since only lines on a loop have their relocation set aside. 406 + #pickOne(n: number): MoveEntry | undefined { 407 + let picked = this.#picked.get(n); 408 + if (picked === undefined) { 409 + const graph = this.graph; 410 + let best: MoveEntry | undefined; 411 + for (const e of skeletonOf(graph).byLine.get(n) ?? []) { 412 + if (this.#has(seqOf(e.r.atom)) && (!best || graph.comparePriority(e.r.atom, best.r.atom) > 0)) best = e; 414 + this.#picked.set(n, (picked = best ?? null)); 416 + return picked ?? undefined; 385 419 /** Whether moves are resolved on disk for each layout: only a stored graph's view with more than MOVED_LINES_KEPT. */ 386 420 #scratchMoves(): boolean { 387 421 if (!this.#hasMoves || !this.graph.hasOrderedChildren) return false; @@ -453,8 +487,21 @@
453 487 /** The file a node sits in, in this set: up by where lines were written, through the moves that count here. */ 454 488 #fileOfCode(code: number): string { 455 489 const graph = this.graph; 456 − const relocs = this.#relocationsN();
457 490 const skeleton = skeletonOf(graph); 491 + if (!this.#relocsN) { 492 + // One moved line at a time, until a walk comes back to a line it passed: then moves loop, and are resolved whole. 493 + const passed = new Set<number>(); 496 + c = skeleton.climb(c); 497 + if (c < 0) return graph.nodeOf(c).slice(1); 498 + if (passed.has(c)) break; 500 + const e = this.#pickOne(c); 501 + c = e ? e.parent : graph.parentCodeOf(c); 504 + const relocs = this.#relocationsN(); 460 507 c = skeleton.climb(c); @@ -569,6 +616,8 @@
569 616 #movedFrom: Map<string, Set<number>> | undefined; 570 617 #movedInFrom(): Map<string, Set<number>> { 571 618 if (this.#movedFrom) return this.#movedFrom; 619 + this.#relocations(); 620 + if (this.#movesTaken) return (this.#movedFrom = this.#movesTaken.#movedInFrom()); 572 621 const graph = this.graph; 573 622 const out = new Map<string, Set<number>>(); 574 623 if (this.#hasMoves) { @@ -962,6 +1011,7 @@
962 1011 if (this.#knownList) n += ARRAY_HEADER_BYTES + REFERENCE_BYTES * this.#knownList.length; 963 1012 if (this.#relocs) n += MAP_HEADER_BYTES + MAP_ENTRY_BYTES * this.#relocs.size; 964 1013 if (this.#relocsN) n += MAP_HEADER_BYTES + (MAP_ENTRY_BYTES + OBJECT_BYTES) * this.#relocsN.size; 1014 + n += MAP_ENTRY_BYTES * this.#picked.size; 965 1015 for (const f of this.#files.values()) { 966 1016 n += MAP_ENTRY_BYTES; 967 1017 if (f !== NO_FILE) { --- a/worker/project/pathindex.ts
+++ b/worker/project/pathindex.ts
@@ -41,6 +41,28 @@
41 41 /** Each version's files made and taken out, and moves (#41), worked out with its files. */ 42 42 readonly #shapeCache = new WeakMap<Space, Map<number, VersionShape>>(); 44 + /** The files at the newest version folded so far from kept shapes, per space (keptPaths). */ 45 + readonly #keptPaths = new WeakMap<Space, { version: number; files: Set<string> }>(); 48 + * The files a space has at a version, from the kept rows of every version up to it: each one's files made and 49 + * taken out, folded from version 0 (abso Capacity). Undefined when a version has no kept row that describes it; 50 + * then the caller lays the version out. 52 + keptPaths(space: Space, version: number): string[] | undefined { 53 + let fold = this.#keptPaths.get(space); 54 + if (!fold || fold.version > version) fold = { version: -1, files: new Set() }; 55 + const files = new Set(fold.files); 56 + for (let v = fold.version + 1; v <= version; v++) { 57 + if (!this.#keptFiles(space, v)) return undefined; 58 + const shape = this.#shapeCache.get(space)!.get(v)!; 59 + for (const f of shape.gone) files.delete(f); 60 + for (const f of shape.made) files.add(f); 62 + this.#keptPaths.set(space, { version, files }); 63 + return [...files].sort(); 44 66 /** Each space's path index (#41): built the first time it's asked for, then kept up as versions land. */ 45 67 readonly #pathIndex = new WeakMap<Space, { upTo: number; paths: Map<string, PathLife> }>(); --- a/worker/project/project-status.ts
+++ b/worker/project/project-status.ts
@@ -40,6 +40,8 @@
40 40 spaceNamed(name: string | null): Space; 41 41 checkVersion(space: Space, version: number): void; 42 42 viewAt(space: Space, version: number): ReadView; 43 + /** A version's file list from kept version shapes, when every version up to it has one (pathindex.ts). */ 44 + keptPaths?(space: Space, version: number): string[] | undefined; 43 45 agentView(agent: AgentState): ReadView; 45 47 /** Shared's project file (224), or undefined before init or without one. */ @@ -74,7 +76,7 @@
74 76 const space = host.spaceNamed(draft); 75 77 const v = version ?? last(space); 76 78 host.checkVersion(space, v); 77 − return { version: v, draft, files: host.viewAt(space, v).paths() };
79 + return { version: v, draft, files: host.keptPaths?.(space, v) ?? host.viewAt(space, v).paths() }; --- a/worker/project/project.ts
+++ b/worker/project/project.ts
@@ -2643,6 +2643,9 @@
2643 2643 spaceNamed: (name) => this.#spaceNamed(name), 2644 2644 checkVersion: (space, version) => this.#checkVersion(space, version), 2645 2645 viewAt: (space, version) => this.#viewAt(space, version), 2646 + // Shared's lists from kept shapes on a stored writer, where a version's layout reads its files from disk. 2647 + keptPaths: (space, version) => 2648 + this.#writerStorage && space.name === SHARED ? this.#paths.keptPaths(space, version) : undefined, 2646 2649 agentView: (agent) => this.#agentView(agent), 2647 2650 version: () => this.version, 2648 2651 projectFile: () => (this.initialized ? projectFileIn(this.#sharedView()) : undefined), --- a/worker/project/test/version-files.test.ts
+++ b/worker/project/test/version-files.test.ts
@@ -52,6 +52,9 @@
52 52 for (const path of ["a.txt", "b.txt", "c.txt", "d.txt", "e.txt", "gone.txt"]) 53 53 assert.deepEqual(project.log({ limit: 100, path }), oracle.log({ limit: 100, path }), path); 54 54 for (let v = 0; v <= oracle.version; v++) assert.deepEqual(project.show(v), oracle.show(v), `version ${v}`); 55 + // The file list at each version, folded from the kept shapes' files made and taken out: newest first, then from 0. 56 + assert.deepEqual(project.pathsAt(oracle.version), oracle.pathsAt(oracle.version)); 57 + for (let v = 0; v <= oracle.version; v++) assert.deepEqual(project.pathsAt(v), oracle.pathsAt(v), `paths at ${v}`); 55 58 // A compare reads the kept lists for the versions between (version-log.ts): both ways, and across the drop. 56 59 for (const [from, to] of [ 57 60 [0, oracle.version],