A model reviewer for found links, with every determination kept

server/links/review.ts asks the configured model to judge the scanner's candidates
as a careful Wikipedia editor would: up to 60 a call, grouped by document and
section, each with its sentence, its section's path, the target's title and
description (and first sentence when cached) and, for a library target, how it
stands to the section. No tools; structured verdicts with a one-line reason. The
prompt names the scanner's known blind spots.

The pending store keeps verdicts, a person's decisions and when an approved link
was handed out, keyed by phrase and target, so a candidate found again is never
judged twice and a rejected phrase is not looked for again. Its file keeps the
old shape; old entries read as pending.

The scan route reviews what it found when asked (at most 2 calls) and hands the
approved links back to be made; jobs review as they go within IE_REVIEW_CALLS
(default 50) calls, with the count in their state. No model, a failed call or
the cap leaves the rest pending, with the reason. The mock reviewer links names
and terms, not single lower-case words, and fails on 'mockfail'.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014yB6q4BHMwptTX3YFtkRab
This commit is contained in:
thalladaandClaude Opus 5.5 committed 2026-11-16 16:39:15 -05:00
1 parent 428f7290ee
commit 46b48d3497
10 files changed
+889 -93

No files matched your search

+14 -1
View File
@@ -4,7 +4,7 @@
* It reads the structured `vars` of a request rather than the prose prompt.
*/
import { clip } from "../core/text";
import type { CascadeDecision, Contradictions, JsonReq, LLM, Req, Resolutions, Turn, TurnReq } from "./types";
import type { CascadeDecision, Contradictions, JsonReq, LinkVerdicts, LLM, Req, Resolutions, Turn, TurnReq } from "./types";
import { webOf } from "./web";
const sleep = (ms: number) => new Promise((r) => setTimeout(r, ms));
@@ -47,9 +47,22 @@ function mockJson(req: JsonReq): unknown {
}
case "contradictions":
return { contradictions: [] } satisfies Contradictions;
case "review": {
// The link reviewer, so a test knows each verdict in advance (mockLinks). A proposal whose
// words or sentence say "mockfail" makes the whole call fail, as a real one may (a limit
// reached, the network gone).
const props: { id: string; quote: string; sentence: string }[] = JSON.parse(v.proposals ?? "[]");
if (props.some((p) => /mockfail/i.test(`${p.quote} ${p.sentence}`))) throw new Error("mock reviewer: the call failed");
return {
verdicts: props.map((p) => ({ id: p.id, link: mockLinks(p.quote), reason: mockLinks(p.quote) ? "mock: a name or a term a reader may look up" : "mock: one ordinary word needs no link" })),
} satisfies LinkVerdicts;
}
}
}
/** The mock link reviewer's rule: a name or a term of several words is linked; a single lower-case word is not. */
export const mockLinks = (quote: string) => /[A-Z0-9]/.test(quote) || /\s/.test(quote.trim());
// ---- web research, without a network ----
/** What the mock web search finds, for any query. Fixed, so a test can name the URLs. */
+6 -1
View File
@@ -19,7 +19,7 @@ export interface Req {
maxTokens?: number;
}
export type SchemaName = "cascade" | "resolve" | "contradictions";
export type SchemaName = "cascade" | "resolve" | "contradictions" | "review";
export interface JsonReq extends Req {
schema: SchemaName;
@@ -89,3 +89,8 @@ export interface Resolutions {
export interface Contradictions {
contradictions: { node: string; other: string; explanation: string; text: string }[];
}
/** The link reviewer's verdicts (server/links/review.ts): one per proposal, by its id. */
export interface LinkVerdicts {
verdicts: { id: string; link: boolean; reason: string }[];
}