clearotron 0.5.0-beta.8 → 0.5.0-beta.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build-info.json +2 -2
- package/driver/CHANGELOG.md +13 -0
- package/driver/contract-vocabulary.mjs +3 -3
- package/driver/corrections-delivered.mjs +7 -5
- package/driver/corrections-feedforward.mjs +89 -3
- package/driver/coverage-form.mjs +61 -2
- package/driver/engine/mcp/band-server.mjs +16 -6
- package/driver/engine/openai-agent.mjs +24 -1
- package/driver/engine/probe.mjs +64 -9
- package/driver/goods-evidence.mjs +16 -3
- package/driver/narrative-refutation-record.mjs +17 -2
- package/driver/package.json +1 -1
- package/driver/pipeline.mjs +237 -30
- package/driver/predelivery-lint.mjs +91 -2
- package/driver/record-fold.mjs +16 -0
- package/driver/record-goods.mjs +24 -8
- package/driver/repair-composers.mjs +61 -7
- package/driver/saved-register-pages.mjs +144 -0
- package/driver/stage-context.mjs +4 -0
- package/driver/suite-census.json +72 -6
- package/driver/verify.mjs +6 -3
- package/mcp-server/CHANGELOG.md +4 -0
- package/mcp-server/package.json +1 -1
- package/package.json +1 -1
- package/portal-ui/package.json +1 -1
- package/providers/oauth-mcp-bridge/CHANGELOG.md +4 -0
- package/providers/oauth-mcp-bridge/package.json +1 -1
- package/providers/signa/src/core.js +18 -4
- package/scripts/e2e-first-time.mjs +6 -4
- package/scripts/release-duplicate-notes.mjs +5 -0
package/build-info.json
CHANGED
package/driver/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# clearotron-driver
|
|
2
2
|
|
|
3
|
+
## 0.5.0-beta.9
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fixed: A clearance on the Claude engine no longer stops with a false "not signed in" message before the search begins, while the Claude sign-in is being renewed.
|
|
8
|
+
- Fixed: A clearance on the Codex engine no longer stops as if signed out when the Codex sign-in fails to renew for a moment.
|
|
9
|
+
- Fixed: A report's list of conditions now shows each legal step as the last correction before delivery left the step, not as first written.
|
|
10
|
+
- Fixed: The audit workbook no longer lists the same open search twice, once in the report's words and once as a follow-up row with a shortened title.
|
|
11
|
+
- Fixed: The reviewing lawyer's open questions no longer say a coverage line was removed when a correction gave it the new title the review asked for.
|
|
12
|
+
- Fixed: Searches on the Signa register now ask for each goods statement in full, so a report weighs an owner's whole goods rather than the first 280 characters.
|
|
13
|
+
- Fixed: When a late correction adds, changes, or withdraws a finding, the answers in the report's summary panel are now checked against that finding and updated where they rest on it.
|
|
14
|
+
- Fixed: For a European Union order, the audit workbook now names every national register that was not searched, instead of only the first few.
|
|
15
|
+
|
|
3
16
|
## 0.5.0-beta.8
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
|
@@ -530,9 +530,9 @@ export const INNER_CODES = Object.freeze([
|
|
|
530
530
|
// ONE CODE, TWO TOKENS, and the split is by `cause` rather than by code: verify.mjs peels the
|
|
531
531
|
// `axis_invalid` cause into its own family before counting the rest. A ruling naming only
|
|
532
532
|
// `coverage_no_status` would be true of most `no_status` records and false of the ones that matter most.
|
|
533
|
-
{ code: "no_status", mints: ["driver/coverage-form.mjs:
|
|
533
|
+
{ code: "no_status", mints: ["driver/coverage-form.mjs:998"], rollsUpTo: ["coverage_no_status", "coverage_form_axis_invalid"],
|
|
534
534
|
why: "Two composites, split on the record's `cause`: coverageFormFail() in verify.mjs for cause `axis_invalid`, and the same function for the rest. NOT the `@returns` annotation of findCoverageFormViolations() in coverage-form.mjs — that is the annotation, not the mint." },
|
|
535
|
-
{ code: "engine_vocabulary", mints: ["driver/coverage-form.mjs:
|
|
535
|
+
{ code: "engine_vocabulary", mints: ["driver/coverage-form.mjs:988"], rollsUpTo: ["coverage_form_engine_vocabulary"],
|
|
536
536
|
why: "#669 — the seat wrote an engine token into the `reason` sentence that reaches the reader's page. Checked on settled rows too, because a row the seat considers finished is exactly the one whose sentence gets printed. Namespaced by coverageFormFail() in verify.mjs; the bare code names a row, never a stage." },
|
|
537
537
|
|
|
538
538
|
// ── ONE CODE, TWO MODULES ────────────────────────────────────────────────────────────────────────
|
|
@@ -544,7 +544,7 @@ export const INNER_CODES = Object.freeze([
|
|
|
544
544
|
// failure tokens" already states the rule this row records: `coverage_form_damaged`, never a bare
|
|
545
545
|
// `form_damaged`.
|
|
546
546
|
{ code: "form_damaged",
|
|
547
|
-
mints: ["driver/connotation-search.mjs:2002", "driver/connotation-search.mjs:2078", "driver/coverage-form.mjs:
|
|
547
|
+
mints: ["driver/connotation-search.mjs:2002", "driver/connotation-search.mjs:2078", "driver/coverage-form.mjs:980"],
|
|
548
548
|
rollsUpTo: ["connotation_form_damaged", "coverage_form_damaged"],
|
|
549
549
|
why: "Minted in two lanes and namespaced per lane: connotationDispositionFail() in verify.mjs for the meaning sweep, coverageFormFail() in verify.mjs for the register digest. The namespacing is what keeps them apart — see verify.mjs's block headed \"the register coverage-form failure tokens\"." },
|
|
550
550
|
]);
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
// finding has a card is the assembly's choice, not the correction's fate.
|
|
30
30
|
//
|
|
31
31
|
// PURE — no node imports. The pipeline reads and writes the files.
|
|
32
|
-
import { reportLines, linesOf } from "./corrections-feedforward.mjs";
|
|
32
|
+
import { reportLines, linesOf, renamedAs } from "./corrections-feedforward.mjs";
|
|
33
33
|
|
|
34
34
|
/** The finding fields a correction can change that a report prints from the record. */
|
|
35
35
|
export const DELIVERED_FINDING_FIELDS = Object.freeze(["net", "legal_position", "practical_position"]);
|
|
@@ -55,8 +55,8 @@ export function correctionTargets(rows, preDoc, postDoc) {
|
|
|
55
55
|
const checkable = Boolean(preDoc && postDoc);
|
|
56
56
|
const preOrd = byOrdinal(preDoc), postOrd = byOrdinal(postDoc);
|
|
57
57
|
const preName = byName(preDoc), postName = byName(postDoc);
|
|
58
|
-
const preLines = reportLines(preDoc);
|
|
59
|
-
const postLines = new Map(
|
|
58
|
+
const preLines = reportLines(preDoc), postList = reportLines(postDoc);
|
|
59
|
+
const postLines = new Map(postList.map((l) => [l.key, l.text]));
|
|
60
60
|
return (Array.isArray(rows) ? rows : []).map((r) => {
|
|
61
61
|
const out = { n: r?.n ?? null, kind: r?.kind ?? null, applied: r?.outcome ?? null, changes: [] };
|
|
62
62
|
if (!checkable || r?.outcome === "not-checkable") return { ...out, why: "not-checkable" };
|
|
@@ -64,8 +64,10 @@ export function correctionTargets(rows, preDoc, postDoc) {
|
|
|
64
64
|
const add = (c, key) => { if (!seen.has(key)) { seen.add(key); out.changes.push(c); } };
|
|
65
65
|
if (r.outcome === "line-changed") {
|
|
66
66
|
for (const l of linesOf(r.text, preLines)) {
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
// A line the pass renamed is looked for under its new key, as the applied table joined it.
|
|
68
|
+
const moved = postLines.has(l.key) ? null : renamedAs(l, preLines, postList);
|
|
69
|
+
const now = moved ? moved.text : postLines.get(l.key);
|
|
70
|
+
if (now !== undefined && (moved || squash(now) !== squash(l.text))) add({ line: moved?.key ?? l.key, text: now }, moved?.key ?? l.key);
|
|
69
71
|
}
|
|
70
72
|
} else if (r.outcome === "findings-changed") {
|
|
71
73
|
const declared = (Array.isArray(r.ordinals) ? r.ordinals : []).filter((o) => preOrd.has(o) || postOrd.has(o));
|
|
@@ -136,6 +136,46 @@ export function linesOf(flagText, lines) {
|
|
|
136
136
|
return (lines ?? []).filter((l) => namesLine(hay, l) || quotesLine(hay, l.text));
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
+
/**
|
|
140
|
+
* THE LINE A PASS PUT IN A GONE LINE'S PLACE: the same line, renamed. A coverage line is known by its title and an
|
|
141
|
+
* action by its id, so a flag asking for a new title, answered, left no line under the old key and the line read as
|
|
142
|
+
* deleted. The reviewing lawyer was then told "removed rather than corrected" of two coverage lines the writer had
|
|
143
|
+
* retitled as asked (two flags of one test run, 2026-11-03).
|
|
144
|
+
*
|
|
145
|
+
* CLAIMED ONLY WHERE THE RECORD SHOWS IT. Among lines of the same kind, the gone line must be the only one gone
|
|
146
|
+
* between its nearest neighbours the pass kept. Of the lines the pass added between those neighbours, exactly one
|
|
147
|
+
* must carry at least two in five of the gone line's words, title and text together. A writer can split a line,
|
|
148
|
+
* so one added line beside it is not enough; the successor is the one that keeps its words. On that run the two
|
|
149
|
+
* successors kept 0.88 and 0.55 of them, and no other line kept more than 0.18. Anything else (two gone, no
|
|
150
|
+
* successor, two candidates, the neighbours reordered) stays a removal: a deletion read as a rename would hide it
|
|
151
|
+
* from the lawyer. The mark assessment's two reads have fixed keys, so neither is ever a rename. Returns the
|
|
152
|
+
* post-pass line, or null. PURE.
|
|
153
|
+
*/
|
|
154
|
+
const RENAME_SHARE = 0.4;
|
|
155
|
+
const lineWords = (l) => new Set(norm(`${String(l.key).slice(String(l.key).indexOf(":") + 1)} ${l.text}`)
|
|
156
|
+
.split(" ").filter((w) => w.length > 2));
|
|
157
|
+
export function renamedAs(line, preLines, postLines) {
|
|
158
|
+
const kindOf = (l) => String(l?.key ?? "").slice(0, Math.max(0, String(l?.key ?? "").indexOf(":")));
|
|
159
|
+
const kind = kindOf(line);
|
|
160
|
+
if (kind !== "coverage" && kind !== "action") return null;
|
|
161
|
+
const before = (preLines ?? []).filter((l) => kindOf(l) === kind);
|
|
162
|
+
const after = (postLines ?? []).filter((l) => kindOf(l) === kind);
|
|
163
|
+
const kept = new Set(after.map((l) => l.key));
|
|
164
|
+
const had = new Set(before.map((l) => l.key));
|
|
165
|
+
const at = before.findIndex((l) => l.key === line.key);
|
|
166
|
+
if (at < 0 || kept.has(line.key)) return null;
|
|
167
|
+
let lo = at - 1; while (lo >= 0 && !kept.has(before[lo].key)) lo--;
|
|
168
|
+
let hi = at + 1; while (hi < before.length && !kept.has(before[hi].key)) hi++;
|
|
169
|
+
if (hi - lo !== 2) return null; // another line went from the same gap
|
|
170
|
+
const from = lo >= 0 ? after.findIndex((l) => l.key === before[lo].key) : -1;
|
|
171
|
+
const to = hi < before.length ? after.findIndex((l) => l.key === before[hi].key) : after.length;
|
|
172
|
+
const added = (to > from ? after.slice(from + 1, to) : []).filter((l) => !had.has(l.key));
|
|
173
|
+
const mine = lineWords(line);
|
|
174
|
+
if (!mine.size) return null;
|
|
175
|
+
const keeps = added.filter((l) => { const theirs = lineWords(l); let n = 0; for (const w of mine) if (theirs.has(w)) n++; return n / mine.size >= RENAME_SHARE; });
|
|
176
|
+
return keeps.length === 1 ? keeps[0] : null;
|
|
177
|
+
}
|
|
178
|
+
|
|
139
179
|
/** The corrective pass's own words about a line it was flagged on, from the `corrections` register. PURE. */
|
|
140
180
|
function reasonFor(hit, doc) {
|
|
141
181
|
const c = doc?.corrections;
|
|
@@ -281,7 +321,7 @@ export function buildCorrectionsApplied(rows, preDoc, postDoc, { sections = null
|
|
|
281
321
|
const known = knownEntities(preDoc, postDoc);
|
|
282
322
|
const pre = byName(preDoc), post = byName(postDoc);
|
|
283
323
|
const preOrd = byOrdinal(preDoc), postOrd = byOrdinal(postDoc);
|
|
284
|
-
const preLines = reportLines(preDoc), postLine = new Map(
|
|
324
|
+
const preLines = reportLines(preDoc), postLines = reportLines(postDoc), postLine = new Map(postLines.map((l) => [l.key, l]));
|
|
285
325
|
return (rows ?? []).map((r) => {
|
|
286
326
|
// — a DECLARED ordinal wins over the name match. `targetsOf` is a normalised prose join and it
|
|
287
327
|
// is why six of nine flags on a delivered run resolved to nothing; the declaration is the reviewer's
|
|
@@ -320,9 +360,11 @@ export function buildCorrectionsApplied(rows, preDoc, postDoc, { sections = null
|
|
|
320
360
|
else if (hit.length) {
|
|
321
361
|
// The same three answers a finding gets, asked of the line's own text. REMOVAL WINS, as it does
|
|
322
362
|
// for a finding: a line gone after the pass was answered by deletion, and that is the question.
|
|
323
|
-
|
|
363
|
+
// A line renamed in place is still there, and a new title is a change (`renamedAs`).
|
|
364
|
+
const now = (l) => postLine.get(l.key) ?? renamedAs(l, preLines, postLines);
|
|
365
|
+
const gone = hit.filter((l) => !now(l));
|
|
324
366
|
if (gone.length) { outcome = "line-removed"; removed = gone.map((l) => l.label); }
|
|
325
|
-
else outcome = hit.some((l) =>
|
|
367
|
+
else outcome = hit.some((l) => now(l).key !== l.key || squash(now(l).text) !== squash(l.text)) ? "line-changed" : "line-unchanged";
|
|
326
368
|
}
|
|
327
369
|
else if (declaredOrds.length) {
|
|
328
370
|
// The certain path. Every question below is asked of the finding the reviewer NAMED, by ordinal.
|
|
@@ -371,6 +413,50 @@ export function buildCorrectionsApplied(rows, preDoc, postDoc, { sections = null
|
|
|
371
413
|
});
|
|
372
414
|
}
|
|
373
415
|
|
|
416
|
+
/**
|
|
417
|
+
* THE ANSWERS A CORRECTION MAY HAVE LEFT BEHIND: findings the pass moved that an answer citing findings may depend on.
|
|
418
|
+
*
|
|
419
|
+
* Each of the four answers that cites findings names them by ordinal (`four_answers.<answer>.ordinals`). On a test run
|
|
420
|
+
* (2026-11-03) a correction raised a finding from Moderate to High and updated the verdict, and the third-party-rights
|
|
421
|
+
* answer kept naming findings 1 to 3. The recheck saw it, but no pass follows the recheck, so the report kept the answer.
|
|
422
|
+
*
|
|
423
|
+
* A REASON TO ASK, NEVER A REQUIRED CITATION (design, 2026-11-03). For each answer that names findings, two things
|
|
424
|
+
* suggest a missing dependency:
|
|
425
|
+
* - a live adversarial finding the pass added, re-banded or re-typed, rated at or above the lowest band among the
|
|
426
|
+
* live findings the answer names, and not named by it: a shared band is a reason to check, not a rule;
|
|
427
|
+
* - a finding the answer names that the pass withdrew.
|
|
428
|
+
* A finding the pass did not move is never listed: what the writer cited before the correction is its own judgment. An
|
|
429
|
+
* answer that names no finding is not checked here, which is not a pass, and no absent answer is invented. Current
|
|
430
|
+
* citations do not make an answer's prose current; the recheck reads that. `bands` is the framework's ladder, most
|
|
431
|
+
* severe first. Returns `[{answer, cited, floor, uncited: [{ordinal, band}], withdrawn: [ordinal]}]`, empty when none. PURE.
|
|
432
|
+
*/
|
|
433
|
+
export function answersLeftBehind(preDoc, postDoc, bands) {
|
|
434
|
+
const labels = (bands ?? []).map((b) => String(b?.label ?? b ?? "").trim());
|
|
435
|
+
const ladder = labels.map((b) => b.toLowerCase());
|
|
436
|
+
const rank = (band) => ladder.indexOf(String(band ?? "").trim().toLowerCase());
|
|
437
|
+
const answers = postDoc?.four_answers ?? postDoc?.fourAnswers;
|
|
438
|
+
if (!answers || typeof answers !== "object") return [];
|
|
439
|
+
const live = (f) => f && f.disposition !== "withdrawn";
|
|
440
|
+
const before = byOrdinal(preDoc), after = byOrdinal(postDoc);
|
|
441
|
+
const moved = (f) => { const was = before.get(f.ordinal); return !was || was.band !== f.band || was.disposition !== f.disposition; };
|
|
442
|
+
const out = [];
|
|
443
|
+
for (const [answer, a] of Object.entries(answers)) {
|
|
444
|
+
if (!a || !Array.isArray(a.ordinals) || !a.ordinals.length) continue;
|
|
445
|
+
const cited = new Set(a.ordinals.map(Number));
|
|
446
|
+
const withdrawn = [...cited].filter((o) => after.get(o)?.disposition === "withdrawn" && before.get(o)?.disposition !== "withdrawn");
|
|
447
|
+
const ranks = [...cited].map((o) => after.get(o)).filter(live).map((f) => rank(f.band)).filter((i) => i >= 0);
|
|
448
|
+
const floor = ranks.length ? Math.max(...ranks) : -1;
|
|
449
|
+
const uncited = floor < 0 ? [] : [...after.values()].filter((f) => {
|
|
450
|
+
if (cited.has(f.ordinal) || !live(f) || f.disposition !== "adversarial") return false;
|
|
451
|
+
const i = rank(f.band);
|
|
452
|
+
return i >= 0 && i <= floor && moved(f);
|
|
453
|
+
}).map((f) => ({ ordinal: f.ordinal, band: f.band }));
|
|
454
|
+
if (uncited.length || withdrawn.length)
|
|
455
|
+
out.push({ answer, cited: [...cited].sort((x, y) => x - y), floor: floor < 0 ? null : labels[floor], uncited, withdrawn });
|
|
456
|
+
}
|
|
457
|
+
return out;
|
|
458
|
+
}
|
|
459
|
+
|
|
374
460
|
/**
|
|
375
461
|
*, T3b — WHICH OF THE REVIEWER'S OBJECTIONS THE RUN COULD NOT SHOW IT CLOSED.
|
|
376
462
|
*
|
package/driver/coverage-form.mjs
CHANGED
|
@@ -33,6 +33,7 @@ import { REGISTER_AXES, COVERAGE_STATUSES, normalizeAxis, CROWD_RULING_TOKEN,
|
|
|
33
33
|
import { shortId } from "./connotation-search.mjs";
|
|
34
34
|
import { openBlocksByAxis, crowdNarrowing, blocksByQidOf, isProviderHardErrorReason, refusedSearchSentence, notSearchedSentence } from "./register-plan.mjs";
|
|
35
35
|
import { territoryLayerReport, unsearchedLayerReason } from "./binding-layers.mjs"; import { goodsTermsList } from "../providers/_shared/term-shape.mjs";
|
|
36
|
+
import OFFERED from "../shared/offered-territories.json" with { type: "json" }; // the order form's own territory names
|
|
36
37
|
|
|
37
38
|
const STATUS_SET = new Set(COVERAGE_STATUSES);
|
|
38
39
|
const DRIVER_KINDS = new Set(["axis", "block", "deferred", "family"]);
|
|
@@ -556,8 +557,7 @@ export function coverageFormRows({ skeleton = [], activeAxes = null, plan = null
|
|
|
556
557
|
axis: "primary-sweep", kind: "deferred",
|
|
557
558
|
unit: `${report.territory} — binding registers not all searched`,
|
|
558
559
|
qid: null,
|
|
559
|
-
receipt_reason: report
|
|
560
|
-
.map((u) => `${u.layer} (${u.office}): ${u.state}`).join("; "),
|
|
560
|
+
receipt_reason: layerReceipt(report),
|
|
561
561
|
open: true,
|
|
562
562
|
open_because: unsearchedLayerReason(report),
|
|
563
563
|
status: null, reason: null,
|
|
@@ -585,6 +585,65 @@ export function coverageFormRows({ skeleton = [], activeAxes = null, plan = null
|
|
|
585
585
|
};
|
|
586
586
|
}
|
|
587
587
|
|
|
588
|
+
// ── THE REGISTERS A LAYER ROW LEFT UNSEARCHED, NAMED IN FULL ────────────────────────────────────────
|
|
589
|
+
//
|
|
590
|
+
// The layer row's receipt holds every register the plan did not search: on an EU order through a provider
|
|
591
|
+
// that holds three member registers, 22 of them. The reader saw a handful. The writer's brief cuts a receipt
|
|
592
|
+
// at 160 characters, so the writer named the first five or so after "including", and the workbook's
|
|
593
|
+
// coverage-judgment row cut the writer's reason at 160 characters again, mid-word. Measured on two test
|
|
594
|
+
// runs, 2026-11-03: 5 to 7 of 22 named, on both engines.
|
|
595
|
+
//
|
|
596
|
+
// The list is the driver's to state, from the receipt, so no model retypes it and none can drop one. The
|
|
597
|
+
// receipt is written and read here, in one module, so the two cannot disagree about its shape.
|
|
598
|
+
|
|
599
|
+
/** A layer row's receipt: one `layer (OFFICE): state` entry per register the plan did not search. PURE. */
|
|
600
|
+
export function layerReceipt(report) {
|
|
601
|
+
return report.unsearched.map((u) => `${u.layer} (${u.office}): ${u.state}`).join("; ");
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
const LAYER_RECEIPT_ENTRY_RE = /^(national|regional|international) \(([A-Z]{2})\): (excludes|unestablished)$/;
|
|
605
|
+
|
|
606
|
+
/**
|
|
607
|
+
* The national registers a layer row's receipt names, as office codes, in the receipt's order. null when
|
|
608
|
+
* the receipt is not one `layerReceipt` wrote, or when it names a register of another layer: an EU-wide or
|
|
609
|
+
* international gap is a different sentence, and this one does not stretch to it. PURE.
|
|
610
|
+
*/
|
|
611
|
+
export function nationalRegistersNotSearched(receipt) {
|
|
612
|
+
const entries = String(receipt ?? "").split("; ").filter(Boolean);
|
|
613
|
+
if (!entries.length) return null;
|
|
614
|
+
const offices = [];
|
|
615
|
+
for (const e of entries) {
|
|
616
|
+
const m = LAYER_RECEIPT_ENTRY_RE.exec(e);
|
|
617
|
+
if (!m || m[1] !== "national") return null;
|
|
618
|
+
offices.push(m[2]);
|
|
619
|
+
}
|
|
620
|
+
return offices;
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
const ORDER_FORM_NAMES = new Map([...OFFERED.regions, ...OFFERED.countries].map((t) => [t.code, t.name]));
|
|
624
|
+
|
|
625
|
+
/** A register or territory code in the order form's words, or "" when the form has no such code. PURE. */
|
|
626
|
+
export function orderFormName(code) {
|
|
627
|
+
return ORDER_FORM_NAMES.get(String(code ?? "").trim().toUpperCase()) ?? "";
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
/**
|
|
631
|
+
* "the national registers of A, B, and C were not searched", every name the order form's own, sorted. null
|
|
632
|
+
* when a code has no name: a list with a gap in it is the defect this replaces, so the row stays as it was. PURE.
|
|
633
|
+
*/
|
|
634
|
+
export function nationalRegistersNote(offices) {
|
|
635
|
+
const names = (offices ?? []).map(orderFormName);
|
|
636
|
+
if (!names.length || names.some((n) => !n)) return null;
|
|
637
|
+
const sorted = [...new Set(names)].sort((a, b) => a.localeCompare(b, "en"));
|
|
638
|
+
if (sorted.length === 1) return `the national register of ${sorted[0]} was not searched`;
|
|
639
|
+
const list = sorted.length === 2 ? `${sorted[0]} and ${sorted[1]}`
|
|
640
|
+
: `${sorted.slice(0, -1).join(", ")}, and ${sorted[sorted.length - 1]}`;
|
|
641
|
+
return `the national registers of ${list} were not searched`;
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
/** Is this form row a binding-layer row (`buildCoverageForm`, stage 1)? PURE. */
|
|
645
|
+
export const isLayerRow = (r) => String(r?.row_id ?? "").startsWith("CL-") && r?.kind === "deferred";
|
|
646
|
+
|
|
588
647
|
// ── M6 — THE ABSENCE IS AN ARTIFACT, NOT A MISSING ONE ──────────────────────────────────────────
|
|
589
648
|
//
|
|
590
649
|
// A run whose plan apparatus is out of reach can carry no coverage ROWS: there is no frozen plan to
|
|
@@ -25,7 +25,8 @@ import { classifyRecord, prepareTargets, SHAPE_TIERS, isLiveRecord, niceClassKey
|
|
|
25
25
|
import { recordQids } from "../../named-band.mjs";
|
|
26
26
|
import { normalizeRecordUri } from "../../registry-fidelity.mjs";
|
|
27
27
|
import { bandGoodsIndex, goodsFor, goodsWordCounter, goodsWordsMatched, rawGoodsCarried, untaggedIsEnglish, rowGoods } from "../../record-goods.mjs";
|
|
28
|
-
import { recordGoodsEvidence, heldRecordProvenance, recordFetchOutcomes, readRunCallRows, goodsFromLabel } from "../../goods-evidence.mjs";
|
|
28
|
+
import { recordGoodsEvidence, heldRecordProvenance, recordFetchOutcomes, readRunCallRows, goodsFromLabel, registerPageLabel } from "../../goods-evidence.mjs";
|
|
29
|
+
import { savedStatusPages } from "../../saved-register-pages.mjs";
|
|
29
30
|
import { DEFAULT_LEDGER_PATH } from "../../provider-usage.mjs";
|
|
30
31
|
|
|
31
32
|
const RUN_DIR = process.env.CLEAROTRON_BAND_RUN_DIR || "";
|
|
@@ -301,9 +302,15 @@ const shapeGoodsTest = () => {
|
|
|
301
302
|
testCache = { words, matched: goodsWordsMatched(words, { stems: true }) };
|
|
302
303
|
return testCache;
|
|
303
304
|
};
|
|
305
|
+
// THE REGISTER'S OWN PAGES THE RUN'S RESEARCH SAVED (saved-register-pages.mjs), read again at the start of each lookup
|
|
306
|
+
// and each record call, never once per server as the held bodies are: a stage's own research question can save a
|
|
307
|
+
// record's page after the stage's first lookup, and the stage reads it from its next one.
|
|
308
|
+
const statusPages = savedStatusPages(RUN_DIR);
|
|
309
|
+
let pagesNow = new Map();
|
|
304
310
|
// The record's body first; where the run holds none, the statements the row carries, as the shape reads them
|
|
305
|
-
// (`rowGoods`, a statement the register cut marked so); a row that carries its goods as
|
|
306
|
-
|
|
311
|
+
// (`rowGoods`, a statement the register cut marked so, or continued from a saved page); a row that carries its goods as
|
|
312
|
+
// one string stands in last.
|
|
313
|
+
const goodsOfRow = (r) => goodsFor(goodsIndex(), r) ?? rowGoods(r, pagesNow)
|
|
307
314
|
?? (typeof r?.goods === "string" && r.goods.trim() ? [{ classes: [], text: r.goods.trim(), ...(untaggedIsEnglish(r?.record_id) ? {} : { en: false }) }] : null);
|
|
308
315
|
// WHAT A RECORD'S GOODS REST ON, from the run's own files and its fetches, by the shared reader's one rule
|
|
309
316
|
// (goods-evidence.mjs `recordGoodsEvidence`): the supporting evidence the record holds, never the last call made
|
|
@@ -386,6 +393,7 @@ function bandLookup(params = {}) {
|
|
|
386
393
|
}
|
|
387
394
|
|
|
388
395
|
const all = Array.isArray(band?.enumerated) ? band.enumerated : [];
|
|
396
|
+
pagesNow = statusPages();
|
|
389
397
|
const hits = [];
|
|
390
398
|
let matched = 0;
|
|
391
399
|
for (const r of all) {
|
|
@@ -557,7 +565,8 @@ function bandRecord(params = {}) {
|
|
|
557
565
|
const parsed = hit.miss !== "unparsable-uri";
|
|
558
566
|
const key = normalizeRecordUri(uri) || normalizeRecordUri(`/${String(uri ?? "").trim().replace(/^\/+/, "")}`);
|
|
559
567
|
const bandRow = parsed && key ? bandRowFor(key) : null;
|
|
560
|
-
|
|
568
|
+
if (bandRow) pagesNow = statusPages();
|
|
569
|
+
const statements = bandRow ? rowGoods(bandRow, pagesNow) : null;
|
|
561
570
|
const fetched = parsed ? runEvidence().fetches : null;
|
|
562
571
|
const fetch = fetched && key ? (fetched.get(key) ?? fetched.get(key.split("/").pop())) : null;
|
|
563
572
|
const failed = Boolean(fetch?.failed && !fetch.ok);
|
|
@@ -572,7 +581,8 @@ function bandRecord(params = {}) {
|
|
|
572
581
|
return { isError: true, text: `${why} ${rest}` };
|
|
573
582
|
}
|
|
574
583
|
const goodsLines = statements.map((g) => JSON.stringify({ class: g.classes.join(",") || null, text: g.text,
|
|
575
|
-
goods_from: g.cut ? "search answer, cut by the register" : g.unknown ? "search answer, completeness not established"
|
|
584
|
+
goods_from: g.cut ? "search answer, cut by the register" : g.unknown ? "search answer, completeness not established"
|
|
585
|
+
: g.page ? registerPageLabel(g.page.question) : "search answer" }));
|
|
576
586
|
const text = [why, ...goodsLines, rest].join("\n");
|
|
577
587
|
const parts = splitAtLines(text, RESPONSE_CHARS);
|
|
578
588
|
const wanted = Number(params.part ?? 1);
|
|
@@ -610,7 +620,7 @@ const GROUP_PAGES = process.env.CLEAROTRON_BAND_GROUPS === "1";
|
|
|
610
620
|
// served the shape without them (the owner's ruling, 2026-10-14). Each is removed with the space before it, inside
|
|
611
621
|
// its line, so no line moves and the line each listed mark is printed on, which `linesByPart` reads, still holds.
|
|
612
622
|
// (band-shape.mjs `withoutPlacementOrders` removes them, with the shape's other placement-only orders and its group-page commands.)
|
|
613
|
-
const LOOKUP_DESCRIPTION = "Look up enumerated records in this run's frozen register band (read-only; logged to the reading audit). Filters AND together: record_id (exact uri), owner (substring), nice_class, tier (identical|near-identical|same-family|other|unclassifiable — classified against the shape's frozen targets), qid (exact plan-entry id — the plan-execution ledger join; a record surfaced by several slices matches under EVERY one of them), query (the _query slice that surfaced the record), text (substring of mark_text), status (substring), live_only, goods (words: records whose goods contain any of them, as whole words, singular or plural; a record with no goods on file matches too), group (a, b, c, d, rest or no_goods: that list's lines in the shape's order, one per mark of an owner), limit (default 20, max 100), offset (default 0: where in the matching records or lines to start — a capped answer names the offset where the next page starts). On each record served, `goods_words` gives the client's goods words its goods hold, as the shape tests them (k of N: the words), or null where its goods cannot be read; `goods_from` says what those goods rest on: official record; official record, cut by the register; official record, completeness not established; official record, no goods listed; search answer; search answer, cut by the register; search answer, completeness not established; fetch failed; or nothing held. The goods text is in band_record. Matching un-enumerated crowd descriptors ride along so a lookup can never mistake a counted-only zone for a clean.";
|
|
623
|
+
const LOOKUP_DESCRIPTION = "Look up enumerated records in this run's frozen register band (read-only; logged to the reading audit). Filters AND together: record_id (exact uri), owner (substring), nice_class, tier (identical|near-identical|same-family|other|unclassifiable — classified against the shape's frozen targets), qid (exact plan-entry id — the plan-execution ledger join; a record surfaced by several slices matches under EVERY one of them), query (the _query slice that surfaced the record), text (substring of mark_text), status (substring), live_only, goods (words: records whose goods contain any of them, as whole words, singular or plural; a record with no goods on file matches too), group (a, b, c, d, rest or no_goods: that list's lines in the shape's order, one per mark of an owner), limit (default 20, max 100), offset (default 0: where in the matching records or lines to start — a capped answer names the offset where the next page starts). On each record served, `goods_words` gives the client's goods words its goods hold, as the shape tests them (k of N: the words), or null where its goods cannot be read; `goods_from` says what those goods rest on: official record; official record, cut by the register; official record, completeness not established; official record, no goods listed; search answer; search answer, cut by the register; search answer, completeness not established; the register's own page, saved by research question <N>; fetch failed; or nothing held. The goods text is in band_record. Matching un-enumerated crowd descriptors ride along so a lookup can never mistake a counted-only zone for a clean.";
|
|
614
624
|
const LOOKUP_GROUP_CLAUSE = "group (a, b, c, d, rest or no_goods: that list's lines in the shape's order, one per mark of an owner), ";
|
|
615
625
|
const LOOKUP_OFFSET_GROUPS = "offset (default 0: where in the matching records or lines to start — a capped answer names the offset where the next page starts)";
|
|
616
626
|
const LOOKUP_OFFSET_BAND = "offset (default 0: where in the matching records to start — a capped answer names the offset where the next page starts)";
|
|
@@ -726,7 +726,26 @@ const RATE_LIMIT_RE = /\b429\b|rate.?limit|usage limit|quota|too many requests|i
|
|
|
726
726
|
// A SIGN-IN THAT CAN NO LONGER BE REFRESHED, in codex's own words (measured on a live install, 2026-09-11).
|
|
727
727
|
// Narrow on purpose: a register provider's 401 or 403 can land in a stage's stderr too, and reading that as
|
|
728
728
|
// the operator's codex login having expired would send them to sign in again for nothing.
|
|
729
|
-
|
|
729
|
+
//
|
|
730
|
+
// A REFUSED RENEWAL ONLY: a 401 at renewal, or codex's words for a token spent, expired or revoked. 0.162.0
|
|
731
|
+
// says "Failed to refresh token status=401 …" and "Your access token could not be refreshed because …"; the
|
|
732
|
+
// live capture of 2026-09-11 said "Failed to refresh token: 401 Unauthorized: …already been used…". A bare
|
|
733
|
+
// "failed to refresh token" also matched every renewal that failed for a passing reason, because 0.162.0
|
|
734
|
+
// writes that line for each one: a 503, a dropped connection, and an outage the renewal recovered from
|
|
735
|
+
// within the same turn (measured offline, 2026-11-03). Read as a sign-out, each of those ended the stage's
|
|
736
|
+
// retries on its first attempt.
|
|
737
|
+
const REFRESH_FAILED_RE = /refresh token (?:has|was) already been used|access token could not be refreshed|failed to refresh token(?::| status=) ?401\b/i;
|
|
738
|
+
// …AND A RENEWAL THAT FAILED WITHOUT BEING REFUSED, which is not a sign-out: the line codex writes for any
|
|
739
|
+
// renewal attempt that did not succeed. Its own signal, read only where the refusal above is absent, so the
|
|
740
|
+
// run door can check again after a wait (engine/probe.mjs) while a stage retries as on any failed turn.
|
|
741
|
+
//
|
|
742
|
+
// READ ON A KILLED TURN TOO. On a dropped connection codex does not end the turn: it retries the renewal, 44
|
|
743
|
+
// times in the door's 60 s probe on one measured run, until the watchdog stops it. The stopped turn's text
|
|
744
|
+
// still names the renewal address, ".../oauth/token", and the door's sign-in pattern reads that `oauth` as a
|
|
745
|
+
// sign-out, so a signal kept off killed turns let the door refuse the job (measured offline on 0.162.0,
|
|
746
|
+
// 2026-11-03). The signal stays off wherever the refusal above appears, whatever ended the turn, so a 401
|
|
747
|
+
// stays a sign-out.
|
|
748
|
+
const REFRESH_ATTEMPT_FAILED_RE = /failed to refresh token/i;
|
|
730
749
|
|
|
731
750
|
// A retry hint, WHEN THE MESSAGE HAPPENS TO CARRY ONE. Two anchored shapes and nothing clever: an
|
|
732
751
|
// explicit timestamp, or a relative delay with a unit. Anything else yields undefined and the driver
|
|
@@ -805,6 +824,7 @@ function settleTuple({ r, ev, resumeRef }) {
|
|
|
805
824
|
const rateLimitText = `${ev.turnFailed || ""}\n${ev.streamError || ""}\n${r.stderr || ""}`;
|
|
806
825
|
const rateLimited = !killed && RATE_LIMIT_RE.test(rateLimitText);
|
|
807
826
|
const signedOut = !killed && REFRESH_FAILED_RE.test(rateLimitText);
|
|
827
|
+
const refreshFailed = !REFRESH_FAILED_RE.test(rateLimitText) && REFRESH_ATTEMPT_FAILED_RE.test(rateLimitText);
|
|
808
828
|
const resetsAt = rateLimited ? parseResetHint(rateLimitText) : undefined;
|
|
809
829
|
return {
|
|
810
830
|
code: killed ? 137 : (failed ? (r.rawCode || 1) : 0),
|
|
@@ -859,6 +879,9 @@ function settleTuple({ r, ev, resumeRef }) {
|
|
|
859
879
|
// The engine's sign-in could not be refreshed: what the operator runs to fix it. The gateway names the
|
|
860
880
|
// stage's failure with it.
|
|
861
881
|
signedOut: signedOut ? "codex sign-in expired — run `codex login`, then start the search again" : undefined,
|
|
882
|
+
// A renewal attempt failed and was not refused, on a turn that ended or one the watchdog stopped. Read by the
|
|
883
|
+
// run door only; a stage's ladder treats the turn as any failed turn.
|
|
884
|
+
refreshFailed: refreshFailed || undefined,
|
|
862
885
|
// Every tool call refused and none completed: codex's own sandbox on this host, and what fixes it. The
|
|
863
886
|
// turn is still `ok` here; when the stage then fails, the gateway names its failure with this, as it
|
|
864
887
|
// names a sign-in, instead of the missing file the refusal left behind.
|
package/driver/engine/probe.mjs
CHANGED
|
@@ -153,6 +153,15 @@ const DETAIL_CHARS = 400;
|
|
|
153
153
|
// Please run /login"); bare "login" is deliberately NOT matched, because it appears in prose that is not
|
|
154
154
|
// about being signed out.
|
|
155
155
|
const SIGNED_OUT_RE = /not logged in|logged out|signed out|please log ?in|\/login\b|claude login|codex login|no auth\.json|credentials? (?:were )?not found|no .* credentials|unauthori[sz]ed|authentication[_ ]error|invalid[_ -]?api[_ -]?key|oauth|\b401\b|\b403\b/i;
|
|
156
|
+
// A SIGN-IN REFRESH ANOTHER COPY OF THE PROGRAM IS HOLDING, which is not a sign-out. The Claude program renews
|
|
157
|
+
// an expired sign-in under a lock that every copy on the same sign-in shares. When another copy holds it and
|
|
158
|
+
// does not renew it, the program gives up and says to retry in a minute, and files that as a server error,
|
|
159
|
+
// not an authentication failure. Claude Code 2.1.295 carries three wordings: the line a `-p` turn ends with,
|
|
160
|
+
// the one an interactive session shows, and the error's own message. Measured on the test machine,
|
|
161
|
+
// 2026-11-03: the first matched `oauth` above, and a job failed at the door as "not signed in" while the same
|
|
162
|
+
// sign-in renewed at the first try twelve minutes later. Read BEFORE that pattern, which keeps `oauth`: "OAuth
|
|
163
|
+
// session expired and could not be refreshed" is a real sign-out and matches through nothing else.
|
|
164
|
+
const REFRESH_LOCKED_RE = /another Claude Code process is (?:refreshing it|holding the refresh lock)/i;
|
|
156
165
|
const TIER_RE = /model[_ -]?not[_ -]?found|unknown model|not a valid model|does not have access|no access to|model .{0,40}(?:not available|unavailable|not supported|unsupported)|unsupported model|no claude model mapped|no GPT tier mapped|permission[_ ]error/i;
|
|
157
166
|
|
|
158
167
|
const tail = (s) => {
|
|
@@ -347,6 +356,22 @@ export function classifyProbe({ engine, tuple = null, error = null, timeoutSec =
|
|
|
347
356
|
{ resetsAt: s.resetsAt ?? null, detail });
|
|
348
357
|
}
|
|
349
358
|
|
|
359
|
+
// A turn that ran and failed, in words that claim nothing they cannot see: the last answer below, and the
|
|
360
|
+
// locked refresh, whose explanation is the engine's own and rides in `detail`.
|
|
361
|
+
const ranAndFailed = (mode, basis) => v(mode, basis, `${id} ran but the turn failed (exit ${tuple.code})`,
|
|
362
|
+
"The engine's stderr below is the whole story; a turn that starts and fails is not a configuration this check can name.", { detail });
|
|
363
|
+
|
|
364
|
+
// A SIGN-IN REFRESH ANOTHER COPY IS HOLDING, before the pattern that would read it as a sign-out. It answers
|
|
365
|
+
// as a turn that ran and failed, with the program's "retry in a minute" beneath, under a mode of its own:
|
|
366
|
+
// outside the configuration lane, and the one the run door checks again once the lock has gone stale.
|
|
367
|
+
if (REFRESH_LOCKED_RE.test(text)) return ranAndFailed("refresh-locked", "text-match");
|
|
368
|
+
|
|
369
|
+
// A CODEX RENEWAL THAT FAILED WITHOUT BEING REFUSED (the adapter's signal, openai-agent.mjs), before the
|
|
370
|
+
// sign-in pattern too: a dropped connection's line names the renewal address, ".../oauth/token", and the
|
|
371
|
+
// pattern read that as a sign-out (measured offline on 0.162.0, 2026-11-03). The same answer as the locked
|
|
372
|
+
// refresh, and the same second check at the door.
|
|
373
|
+
if (s.refreshFailed) return ranAndFailed("refresh-failed", "text-match");
|
|
374
|
+
|
|
350
375
|
// THE MODE STAYS `signed-out` UNDER EVERY WAY OF PAYING, because the run door refuses on the mode and a
|
|
351
376
|
// refused credential is as much this machine's to fix as a signed-out program. Only the words follow how
|
|
352
377
|
// the turn is paid for.
|
|
@@ -373,8 +398,7 @@ export function classifyProbe({ engine, tuple = null, error = null, timeoutSec =
|
|
|
373
398
|
? `That is what refused credentials look like, so start there: check ${refused.check}, then run this again. The engine's stderr below is the diagnosis if it is something else.`
|
|
374
399
|
: `That is the signed-out shape, so start there: ${signInLine(id, program)}, then run this again. The engine's stderr below is the diagnosis if it is something else.`, { detail });
|
|
375
400
|
|
|
376
|
-
return
|
|
377
|
-
"The engine's stderr below is the whole story; a turn that starts and fails is not a configuration this check can name.", { detail });
|
|
401
|
+
return ranAndFailed("failed", "nonzero-exit");
|
|
378
402
|
}
|
|
379
403
|
|
|
380
404
|
/** What fixes a host that refuses every tool call. On codex it is its own sandbox, and the setting is named. */
|
|
@@ -687,18 +711,49 @@ export async function probeEngineTurn({
|
|
|
687
711
|
* or a missing `runTurn` export escapes as a raw error. That is a driver bug, and a driver bug must not
|
|
688
712
|
* reach a client as a terminal refusal at the door — it fails open, loudly, and the run dies at stage one
|
|
689
713
|
* with the engine's own message if it is real.
|
|
714
|
+
*
|
|
715
|
+
* A SIGN-IN REFRESH ANOTHER COPY IS HOLDING IS CHECKED ONCE MORE. The program says to retry in a minute, and
|
|
716
|
+
* its lock goes stale 60 s after its holder last renewed it, so the door waits `REFRESH_LOCK_WAIT_MS` and runs
|
|
717
|
+
* the probe again. The second verdict is the door's answer: a pass starts the run, a configuration fault
|
|
718
|
+
* refuses, and a lock still held is weather like any other. It carries the first as `recheckedAfter`, for the
|
|
719
|
+
* run record. `opts.wait` stands in for the wait, in tests.
|
|
720
|
+
*
|
|
721
|
+
* A CODEX RENEWAL THAT FAILED WITHOUT BEING REFUSED gets the same second check: a passing outage at the
|
|
722
|
+
* provider's sign-in, which a minute's wait may outlast.
|
|
690
723
|
*/
|
|
691
724
|
export async function preflightEngineTurn(opts = {}) {
|
|
692
|
-
let verdict;
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
725
|
+
let verdict = await doorProbe(opts);
|
|
726
|
+
if (RECHECKED_MODES.has(verdict.mode)) {
|
|
727
|
+
const first = verdict;
|
|
728
|
+
console.error(`[preflight] ${probeFailureText(first)}${first.detail ? `\n engine said: ${first.detail}` : ""}\n`
|
|
729
|
+
+ ` CHECKING AGAIN in ${REFRESH_LOCK_WAIT_MS / 1000}s (${first.mode}/${first.basis}): the engine could not renew its sign-in just now.`);
|
|
730
|
+
await (opts.wait ?? sleep)(REFRESH_LOCK_WAIT_MS);
|
|
731
|
+
verdict = { ...await doorProbe(opts),
|
|
732
|
+
recheckedAfter: { mode: first.mode, basis: first.basis, detail: first.detail, waitedMs: REFRESH_LOCK_WAIT_MS } };
|
|
699
733
|
}
|
|
700
734
|
if (verdict.ok) return verdict;
|
|
701
735
|
if (probeVerdictLane(verdict) !== "configuration") return { ...verdict, warning: probeWeatherWarning(verdict) };
|
|
702
736
|
const detail = verdict.detail ? `\n engine said: ${verdict.detail}` : "";
|
|
703
737
|
throw new Error(`[preflight] ${probeFailureText(verdict)}${detail}`);
|
|
704
738
|
}
|
|
739
|
+
|
|
740
|
+
/**
|
|
741
|
+
* How long the door waits before checking a locked refresh again: the lock goes stale 60 s after its holder last
|
|
742
|
+
* renewed it (Claude Code 2.1.295 renews it every 5 s while it holds it), so 65 s from the first answer is past
|
|
743
|
+
* that whenever the holder stopped.
|
|
744
|
+
*/
|
|
745
|
+
export const REFRESH_LOCK_WAIT_MS = 65_000;
|
|
746
|
+
/** The verdicts the door checks once more after that wait: a sign-in renewal that could not happen just now. */
|
|
747
|
+
const RECHECKED_MODES = new Set(["refresh-locked", "refresh-failed"]);
|
|
748
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
749
|
+
|
|
750
|
+
/** One probe, as the door reads it: every throw from underneath is a verdict (see `preflightEngineTurn`). */
|
|
751
|
+
async function doorProbe(opts) {
|
|
752
|
+
try {
|
|
753
|
+
return await probeEngineTurn(opts);
|
|
754
|
+
} catch (e) {
|
|
755
|
+
return { ok: false, engine: String((opts?.env ?? process.env).CLEAROTRON_AI || DEFAULT_ENGINE_ID),
|
|
756
|
+
mode: "probe-error", basis: "driver-bug", detail: null,
|
|
757
|
+
headline: "the engine probe itself failed to run", fix: `This is a bug in the probe, not a fault on this box: ${String(e?.message ?? e)}` };
|
|
758
|
+
}
|
|
759
|
+
}
|
|
@@ -8,7 +8,9 @@
|
|
|
8
8
|
//
|
|
9
9
|
// complete the run holds the text whole, on a basis the record names: a full record from an operation
|
|
10
10
|
// whose goods are whole (the record text, the register's own flag on a retrieved record, the
|
|
11
|
-
// bulk register statement),
|
|
11
|
+
// bulk register statement), a search answer's statement shorter than its documented cut, or the
|
|
12
|
+
// register's own page, saved by the run's research, continuing a statement the search answer cut
|
|
13
|
+
// or did not establish whole;
|
|
12
14
|
// cut the register marked the statement as cut: a missing word proves nothing;
|
|
13
15
|
// unknown goods are held and their completeness is not established: a search answer's unflagged
|
|
14
16
|
// statement at or over the default answer's documented cut, a retrieved record's statement with
|
|
@@ -191,7 +193,8 @@ export function recordGoodsEvidence(record, { goods = null, held = null, fetches
|
|
|
191
193
|
const readable = statements?.length ? statements.some((g) => g?.en !== false) : null;
|
|
192
194
|
const cut = (statements ?? []).some((g) => g?.cut === true);
|
|
193
195
|
const unknown = (statements ?? []).some((g) => g?.unknown === true);
|
|
194
|
-
const
|
|
196
|
+
const page = (statements ?? []).find((g) => g?.page)?.page ?? null;
|
|
197
|
+
const row = (state, source, basis, extra = null) => ({ uri, state, source, basis, ...extra, readable, held: body, fetch });
|
|
195
198
|
// The statements are a held body's where the reader says so; a reader that cannot tell reads bodies only.
|
|
196
199
|
if (statements?.length && fromBody) {
|
|
197
200
|
const op = body?.goods?.operation ?? "undocumented";
|
|
@@ -199,6 +202,10 @@ export function recordGoodsEvidence(record, { goods = null, held = null, fetches
|
|
|
199
202
|
cut ? "register-flag" : unknown ? (op === "retrieve" ? "retrieved-record-without-flag" : "full-record-operation-undocumented")
|
|
200
203
|
: op === "retrieve" ? "register-flag" : op === "bulk-register" ? "bulk-register-statement" : "full-record");
|
|
201
204
|
}
|
|
205
|
+
// A search answer's statements that a register page the run's research saved continues whole (record-goods.mjs
|
|
206
|
+
// `rowGoods`). The record rests on that page once none is left cut or not established whole; where its classes were
|
|
207
|
+
// continued from pages two questions saved, the question named is its first such class's.
|
|
208
|
+
if (statements?.length && page && !cut && !unknown) return row("complete", "register-page", "register-page-statement", { question: page.question });
|
|
202
209
|
if (statements?.length) return row(cut ? "cut" : unknown ? "unknown" : "complete", "search-row",
|
|
203
210
|
cut ? "register-flag" : unknown ? "default-answer-at-or-over-its-cut" : "default-answer-under-its-cut");
|
|
204
211
|
if (body) {
|
|
@@ -216,10 +223,13 @@ export function recordGoodsEvidence(record, { goods = null, held = null, fetches
|
|
|
216
223
|
* WHAT A RECORD'S GOODS REST ON, IN THE WORDS THE STAGES READ (the band lookup's `goods_from`, the write-up's list):
|
|
217
224
|
* the supporting evidence the record holds and its completeness, never the last call made for it. "No goods listed"
|
|
218
225
|
* needs a full record from an operation whose goods are whole, with the field there and empty; a record whose goods
|
|
219
|
-
* field is missing is "completeness not established".
|
|
226
|
+
* field is missing is "completeness not established". Goods continued whole from a register page the run's research
|
|
227
|
+
* saved name the question that saved it (`question`, which a caller passing the row on carries with it). null where
|
|
228
|
+
* there is no evidence row. PURE.
|
|
220
229
|
*/
|
|
221
230
|
export function goodsFromLabel(e) {
|
|
222
231
|
if (!e) return null;
|
|
232
|
+
if (e.source === "register-page") return registerPageLabel(e.question);
|
|
223
233
|
if (e.source === "record-body") return e.state === "absent" ? "official record, no goods listed"
|
|
224
234
|
: e.state === "cut" ? "official record, cut by the register"
|
|
225
235
|
: e.state === "unknown" ? "official record, completeness not established" : "official record";
|
|
@@ -228,6 +238,9 @@ export function goodsFromLabel(e) {
|
|
|
228
238
|
return e.state === "unavailable" ? "fetch failed" : "nothing held";
|
|
229
239
|
}
|
|
230
240
|
|
|
241
|
+
/** What the stages read for goods taken whole from a register page the run's research saved, naming the question. PURE. */
|
|
242
|
+
export const registerPageLabel = (question) => `the register's own page, saved by research question ${question}`;
|
|
243
|
+
|
|
231
244
|
/** Records counted by state, by source and by basis; `unreadable` counts goods held in no language the engine reads. PURE. */
|
|
232
245
|
export function goodsEvidenceTotals(rows) {
|
|
233
246
|
const list = Array.isArray(rows) ? rows : [];
|
|
@@ -39,7 +39,7 @@ import { captureCall, mergeCapture, nextSeq } from "./call-capture.mjs";
|
|
|
39
39
|
import { join } from "node:path";
|
|
40
40
|
import { driverDir } from "../shared/driver-dir.mjs";
|
|
41
41
|
import { normalizeRecordUri } from "./registry-fidelity.mjs";
|
|
42
|
-
import { parseVerdict, countCitedDefects, parseCorrectionKinds, correctionFlagContent, CORRECTION_KINDS } from "./verify.mjs";
|
|
42
|
+
import { parseVerdict, countCitedDefects, parseCorrectionKinds, correctionFlagContent, CORRECTION_KINDS, SECTION_HEADING_RE } from "./verify.mjs";
|
|
43
43
|
|
|
44
44
|
export const REVIEW_FILE = "senior-eye-review.md";
|
|
45
45
|
|
|
@@ -107,12 +107,27 @@ export function renderRefutation(verdict, flags, planAudit) {
|
|
|
107
107
|
}
|
|
108
108
|
if (planAudit && planAudit.length) {
|
|
109
109
|
out.push("## PLAN-EXECUTION CHECK", "");
|
|
110
|
-
for (const l of planAudit) out.push(
|
|
110
|
+
for (const l of planAudit) out.push(planAuditLine(l));
|
|
111
111
|
out.push("");
|
|
112
112
|
}
|
|
113
113
|
return out.join("\n").replace(/\n+$/, "\n");
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
+
// ── A PLAN-AUDIT LINE CANNOT OPEN A SECTION ─────────────────────────────────────────────────────────
|
|
117
|
+
//
|
|
118
|
+
// The audit's lines are the reviewer's own, and the parsers read a markdown heading or a line of capitals as
|
|
119
|
+
// a section heading. One that names corrections ("CORRECTION REVIEW SCOPE", written by a recheck after a
|
|
120
|
+
// correction) became the document's corrections section: `parseCorrections` then read only what followed it,
|
|
121
|
+
// the flags above it counted none, and the round-trip refused both calls of a recheck as
|
|
122
|
+
// `refutation_roundtrip_kinds:fact` (measured on a saved recheck, 2026-11-03). Any heading-shaped line also
|
|
123
|
+
// ends the audit for `countCitedDefects`. Such a line renders in bold, its words unchanged: it still reads as
|
|
124
|
+
// a sub-heading, and no parser reads it as one. The heading test is the parsers' own (verify.mjs).
|
|
125
|
+
function planAuditLine(line) {
|
|
126
|
+
const s = String(line);
|
|
127
|
+
const t = s.trim();
|
|
128
|
+
return SECTION_HEADING_RE.test(t) ? `**${t.replace(/^#{1,6}\s+/, "")}**` : s;
|
|
129
|
+
}
|
|
130
|
+
|
|
116
131
|
const HEADING_OR_LIST = /^\s*(?:#{1,6}\s|(?:\*{0,2})(?:[-*•]|\d+[.)]|[A-Za-z][.)])(?:\*{0,2})\s)/;
|
|
117
132
|
const textDefect = (t) => {
|
|
118
133
|
if (typeof t !== "string" || !t.trim()) return "empty";
|
package/driver/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "clearotron-driver",
|
|
3
3
|
"private": true,
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "0.5.0-beta.
|
|
5
|
+
"version": "0.5.0-beta.9",
|
|
6
6
|
"license": "AGPL-3.0-only",
|
|
7
7
|
"description": "Deterministic driver for the trademark clearance workflow: orchestration in code (fan-out, fan-in barrier, gating, retries); the model does judgment leaves only, through a reasoning CLI spawned per stage.",
|
|
8
8
|
"engines": {
|