Lines 10–16 at 318 (were 10–16 at 314)
1010// made when a caller asks for them, and the latest asked for is kept. 1212import type { Graph, RelocationInfo } from "./graph.ts"; 13−import { isStartNode, lineId, seqOf } from "./keys.ts";
13+import { atomId, isStartNode, lineId, seqOf } from "./keys.ts"; 1414import { resolveScratchMoves, scratchLayoutNodes } from "./relocation-scratch.ts"; 1515import { isClosedSet, StableSet } from "./state-source.ts"; 1616import { joinLines } from "./text.ts"; Lines 1095–1108 at 318 (were 1095–1101 at 314)
10971097 *lineChunks(path: string): IterableIterator<() => Iterable<string>> { 1098− for (const n of this.#file(path).vis) yield () => this.graph.textChunks(n);
1098+ // The texts the packed layout already holds, read a page at a time (abso Capacity, 714): a record's diff read each 1099+ // line's own row, 11,873 statements for abso's index.ts. Only a line too long to pack is read in chunks. 1100+ const { vis, visText } = this.#file(path); 1101+ for (let i = 0; i < vis.length; i++) { 1102+ const packed = visText?.[i]; 1103+ if (packed != null) yield () => [packed]; 1104+ else yield () => this.graph.textChunks(vis[i]!); 11011108 /** Visible lines without retaining their text in the view cache. */ Lines 1112–1118 at 318 (were 1105–1111 at 314)
11061113 id: graph.lineIdOf(n), 11071114 text: graph.textOf(n), 1108− atom: graph.idOfSeq(graph.writerSeqOf(n)),
1115+ atom: atomId(graph.writerSeqOf(n)), Lines 1126–1137 at 318 (were 1119–1130 at 314)
11191126 const n = vis[i]!; 11201127 const packed = visText?.[i]; 1122− id: visWriter && visK ? lineId(graph.idOfSeq(visWriter[i]!), visK[i]!) : graph.lineIdOf(n),
1129+ id: visWriter && visK ? lineId(atomId(visWriter[i]!), visK[i]!) : graph.lineIdOf(n), 11231130 textChunks: () => graph.textChunks(n), 11251132 return packed ?? graph.textOf(n); 1127− atom: graph.idOfSeq(visWriter ? visWriter[i]! : graph.writerSeqOf(n)),
1134+ atom: atomId(visWriter ? visWriter[i]! : graph.writerSeqOf(n)), Lines 1143–1156 at 318 (were 1136–1147 at 314)
11361143 const graph = this.graph; 11371144 const { vis, visText, visWriter, visK } = this.#file(path); 11381145 const lines: VisibleLine[] = new Array(vis.length); 1146+ // Writer seqs come from the graph's own layout, so they're named with atomId, not checked by idOfSeq (abso 738): 1147+ // on a stored graph its check read the atom count once a line, about 0.9 s of a warm draft-state on abso. 11391148 for (let i = 0; i < vis.length; i++) { 11401149 const n = vis[i]!; 1142− id: visWriter && visK ? lineId(graph.idOfSeq(visWriter[i]!), visK[i]!) : graph.lineIdOf(n),
1151+ id: visWriter && visK ? lineId(atomId(visWriter[i]!), visK[i]!) : graph.lineIdOf(n), 11431152 text: visText?.[i] ?? graph.textOf(n), 1144− atom: graph.idOfSeq(visWriter ? visWriter[i]! : graph.writerSeqOf(n)),
1153+ atom: atomId(visWriter ? visWriter[i]! : graph.writerSeqOf(n)), 11471156 this.#linesCache = { path, lines }; Lines 1172–1184 at 318 (were 1163–1175 at 314)
11631172 const writer = seqWriter ? seqWriter[i]! : graph.writerSeqOf(n); 11641173 let text: string | undefined; 1166− id: seqWriter && seqK ? lineId(graph.idOfSeq(writer), seqK[i]!) : graph.lineIdOf(n),
1175+ id: seqWriter && seqK ? lineId(atomId(writer), seqK[i]!) : graph.lineIdOf(n), 11681177 text ??= graph.textOf(n); 1171− atom: graph.idOfSeq(writer),
1172− deletedBy: by ? by.map((s) => graph.idOfSeq(s)) : NONE,
1180+ atom: atomId(writer), 1181+ deletedBy: by ? by.map((s) => atomId(s)) : NONE, 11731182 visible: by === undefined, Lines 68–74 at 318 (were 68–74 at 314)
6969 for (const key of claimsOf(atom)) streams.push(g.eachWriterOf(key)); 7070 const theirs: AtomId[] = []; 71− for (const id of orderedClaimants(g, streams)) if (against.has(id)) theirs.push(id);
71+ for (const id of orderedClaimants(streams)) if (against.has(id)) theirs.push(id); 7272 out.set(yours, theirs); Lines 136–142 at 318 (were 136–142 at 314)
137137/** Claim indexes append in canonical seq order. Merge one cursor per current 138138 * atom key, retaining no candidate set proportional to historical claims. */ 139−function* orderedClaimants(g: Graph, streams: IterableIterator<AtomId>[]): IterableIterator<AtomId> {
139+function* orderedClaimants(streams: IterableIterator<AtomId>[]): IterableIterator<AtomId> { 141141 type Head = { id: AtomId; seq: number; stream: number }; 142142 const heap: Head[] = []; Lines 152–162 at 318 (were 152–160 at 314)
155+ // Each claimant's seq from its id, as the graph reads it (abso 738): loading the stored atom for it read a row a 156+ // claimant, most of a warm draft-state's pairing on abso. 155157 const advance = (stream: number) => { 156158 const next = streams[stream]!.next(); 157− if (!next.done) push({ id: next.value, seq: g.atom(next.value).seq, stream });
159+ if (!next.done) push({ id: next.value, seq: seqOf(next.value), stream }); 159161 for (let stream = 0; stream < streams.length; stream++) advance(stream); 160162 let previous = -1; Lines 192–199 at 318 (were 190–197 at 314)
190192 let a = left.next(); 191193 let b = right.next(); 192194 while (!a.done && !b.done) { 193− const x = g.atom(a.value).seq;
194− const y = g.atom(b.value).seq;
195+ const x = seqOf(a.value); 196+ const y = seqOf(b.value); 195197 if (x === y && settled.has(a.value)) return true; 196198 if (x <= y) a = left.next(); 197199 if (y <= x) b = right.next(); Lines 125–135 at 318 (were 125–130 at 314)
125125 spaceName: string, 126126 kept?: { parts: KeptParts; uses: string; changed: string }, 127127 names?: ReadonlySet<string>, 129+ * The files the newer work changed, when the caller knows them without placing its lines (land and draft-state: 130+ * shared's kept version files, abso 738); undefined, or one that answers undefined, and they're worked out here. 132+ changedFiles?: () => ReadonlySet<string> | undefined, 128133 ): DefinitionCollision[] { 129134 if (draft.size === 0 || newer.size === 0) return []; Lines 158–168 at 318 (were 153–161 at 314)
153158 // Only a file the newer work touched can hold a changed definition, and only one a use means can matter: just those 154159 // files are laid out, before and with the newer work (abso 738). Laying out every file the newer work touched cost 155160 // codex-prose-authorship-610's draft-state 494 files a view where its uses reach 7. 156− const touched = kept
157− ? kept.parts.get(`touched ${kept.changed}`, () => this.#touched(newer, baseView, nowOf()), filesBytes)
158− : this.#touchedFor(newer, baseView, nowOf());
164+ ? kept.parts.get(`touched ${kept.changed}`, () => this.#touched(newer, baseView, nowOf()), filesBytes) 165+ : this.#touchedFor(newer, baseView, nowOf())); 159166 const changed = new Map<string, Changed>(); 160167 const changedIn = (file: string): Changed => { 161168 let c = changed.get(file); Lines 29–36 at 318 (were 29–34 at 314)
2929 pairs(draft: readonly AtomId[], against: ReadonlySet<AtomId>, settled: ReadonlySet<AtomId>): Pair[]; 3030 describe(pair: Pair, yoursView: ReadView, theirsView: ReadView, spaceName: string): Collision; 3131 definitionRule(): DefinitionRule; 32+ /** The files a space's versions after `from`, up to `to`, changed, when each one's are kept; else undefined. */ 33+ changedSince(space: Space, from: number, to: number): ReadonlySet<string> | undefined; Lines 95–118 at 318 (were 93–103 at 314)
9395 ? host.viewAt(shared, sharedBaseOf(space), changes) 9496 : host.viewAt(space, space.versions.length - 1); 9597 const describeLand = (p: Pair): Collision => host.describe(p, draftView, host.sharedView(), SHARED); 98+ // Where shared changed since the draft's base, from the files each version since kept as it landed (abso 738): working 99+ // it out from the newer atoms placed every line they wrote or deleted, about 30% of a warm draft-state read. 100+ const changed = () => host.changedSince(shared, sharedBaseOf(space), host.version()); 96101 const collisions = [ 97102 ...host.pairs(changes, newer, union).map(describeLand), 100− .collisions(own, draftView, host.viewAt(shared, sharedBaseOf(space)), host.sharedView(), newer, SHARED)
108+ host.viewAt(shared, sharedBaseOf(space)), 101116 .map((d) => d.collision), 103118 return { collisions, newer, union }; Lines 90–110 at 318 (were 90–95 at 314)
9090 return files && [...files].sort(); 94+ * The files the versions after `from`, up to `to`, changed, from each version's kept row (abso 738): undefined when one 95+ * has none, and the caller works them out from the atoms. Every file whose text differs between the two versions is 96+ * in it, since some version between changed it. 98+ keptChangesSince(space: Space, from: number, to: number): ReadonlySet<string> | undefined { 99+ const out = new Set<string>(); 100+ for (let v = from + 1; v <= to; v++) { 101+ const files = this.#keptFiles(space, v); 102+ if (!files) return undefined; 103+ for (const f of files) out.add(f); 93108 /** keptPaths as a set, kept for the newest version asked: never changed once made, so a view can hold it. */ 94109 keptPathSet(space: Space, version: number): ReadonlySet<string> | undefined { 95110 let fold = this.#keptPaths.get(space); Lines 2499–2507 at 318 (were 2499–2504 at 314)
24992499 pairs: (draft, against, settled) => this.#pairs(draft, against, settled), 25002500 describe: (pair, yoursView, theirsView, spaceName) => this.#describe(pair, yoursView, theirsView, spaceName), 25012501 definitionRule: () => this.#definitionRule, 2502+ // Only from a stored writer's kept rows, as keptPaths: a project in memory keeps none, and works them out. 2503+ changedSince: (space, from, to) => 2504+ this.#writerStorage ? this.#paths.keptChangesSince(space, from, to) : undefined, 25022505 refuse: (agent, space, via, time, collisions, entries) => 25032506 this.#refuse(agent, space, via, time, collisions, entries), 25042507 requireClosed: (tie, union) => this.#requireClosed(tie, union), Lines 3218–3236 at 318 (were 3215–3229 at 314)
32153218 const base = agent.mine.some((id) => at.has(id)) 32163219 ? this.#view(differenceSet(at, new StableOverlaySet(agent.mine))) 32173220 : this.#viewAt(space, agent.base); 3221+ const to = version ?? last(space); 32183222 return this.#definitionRule.collisions( 32203224 this.#agentView(agent), 3222− this.#viewAt(space, version ?? last(space)),
3226+ this.#viewAt(space, to), 3231+ // Where the space changed since the agent's base, from each version's kept files on a stored writer, as land's 3232+ // (abso 714): walking every newer atom for them was 6.5 s of a publish 770 versions behind on abso. 3233+ () => (this.#writerStorage ? this.#paths.keptChangesSince(space, agent.base, to) : undefined), Lines 73–81 at 318 (were 73–79 at 314)
7373export function spellingOf(view: ReadView, path: string): string { 7474 if (view.hasFile(path)) return path; 7575 const key = pathKey(path); 76− // Known paths first, by key, then only those laid out (#46).
77− const twins = view.knownPaths().filter((p) => pathKey(p) === key && view.hasFile(p));
76+ // Every path the graph has ever had, by key, then only those the view has a file at (#46). Not the view's known paths 77+ // (abso Capacity, 714): those read every atom's membership and file list, 36,360 statements of a record on abso, as 78+ // clashIn found. A path the view never had has no file in it, so the answers are the same. 79+ const twins = [...view.graph.knownFiles()].filter((p) => pathKey(p) === key && view.hasFile(p)); 7880 return twins.length === 1 ? twins[0]! : path;