Links: the reviewer's reading order uses descendants; jobs gather phrases in one place
descendantsInOrder was a copy of model.ts's descendants. A job worked out the phrases to look up for a set of nodes the same way three times. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014yB6q4BHMwptTX3YFtkRab
This commit is contained in:
1 parent
9f8245e6d7
commit
e8b8d72e61
2 files changed
+8
-22
No files matched your search
+2
-15
@@ -12,7 +12,7 @@
|
||||
* model, as it does when the model writes.
|
||||
*/
|
||||
import { ownerSection } from "../../src/core/links";
|
||||
import { ancestors, label, notesOf, sections, topOf, tops, type NodeId, type Snap } from "../../src/core/model";
|
||||
import { ancestors, descendants, label, notesOf, sections, topOf, tops, type NodeId, type Snap } from "../../src/core/model";
|
||||
import type { Ref } from "../../src/core/ref";
|
||||
import { clip, plain, sentences } from "../../src/core/text";
|
||||
import type { LinkVerdicts, LLM } from "../../src/llm/types";
|
||||
@@ -159,7 +159,7 @@ export class Reviewer {
|
||||
const snap = this.o.snap();
|
||||
const order = new Map<NodeId, number>();
|
||||
let i = 0;
|
||||
for (const d of tops(snap)) for (const id of [d, ...descendantsInOrder(snap, d)]) order.set(id, i++);
|
||||
for (const d of tops(snap)) for (const id of [d, ...descendants(snap, d)]) order.set(id, i++);
|
||||
const sorted = [...list].sort((a, b) => (order.get(a.node) ?? 1e9) - (order.get(b.node) ?? 1e9) || a.range[0] - b.range[0]);
|
||||
for (let at = 0; at < sorted.length; at += BATCH) {
|
||||
if (budget.calls >= budget.max) return { ...report, fallback: `the reviewer's limit of ${budget.max} model call${budget.max === 1 ? "" : "s"} was reached` };
|
||||
@@ -233,16 +233,3 @@ export class Reviewer {
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/** A node's sections and notes, depth first, in reading order. */
|
||||
function descendantsInOrder(snap: Snap, id: NodeId): NodeId[] {
|
||||
const out: NodeId[] = [];
|
||||
const visit = (x: NodeId) => {
|
||||
for (const c of snap.nodes[x].children) {
|
||||
out.push(c);
|
||||
visit(c);
|
||||
}
|
||||
};
|
||||
visit(id);
|
||||
return out;
|
||||
}
|
||||
Reference in new issue
Block a user