clearotron 0.6.0-beta.0 → 0.6.0
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/bin/start.mjs +39 -15
- package/build-info.json +2 -2
- package/driver/CHANGELOG.md +73 -0
- package/driver/band-shape.mjs +21 -3
- package/driver/commonlaw-carry-floor.json +3 -3
- package/driver/contract-arm2-baseline.json +2 -3
- package/driver/contract-e3-backlog.mjs +28 -28
- package/driver/demo-posture.mjs +17 -0
- package/driver/engine/anthropic-agent.mjs +5 -5
- package/driver/engine/mcp/band-server.mjs +14 -7
- package/driver/goods-evidence.mjs +16 -8
- package/driver/named-band.mjs +60 -3
- package/driver/package.json +1 -1
- package/driver/pipeline.mjs +130 -13
- package/driver/portal-service.mjs +4 -1
- package/driver/predelivery-lint.mjs +9 -0
- package/driver/publish/templates/report.css +6 -6
- package/driver/record-goods.mjs +74 -18
- package/driver/skills/clearance-register/digest.md +6 -6
- package/driver/skills/placement-inquiry/SKILL.md +2 -2
- package/driver/stages.mjs +1 -5
- package/driver/steps/frame-comparison.mjs +6 -1
- package/driver/steps/skeptic-and-follow-up.mjs +8 -3
- package/driver/suite-census.json +53 -5
- package/driver/unexecuted-asserts.json +2 -2
- package/mcp-server/CHANGELOG.md +8 -0
- package/mcp-server/http-server.mjs +10 -11
- package/mcp-server/package.json +1 -1
- package/node_modules/buffers/package.json +1 -1
- package/package.json +1 -1
- package/portal-ui/dist/assets/{index-AtB9ZpDH.css → index-izLa9apq.css} +2 -2
- package/portal-ui/dist/index.html +4 -4
- package/portal-ui/package.json +1 -1
- package/providers/oauth-mcp-bridge/CHANGELOG.md +8 -0
- package/providers/oauth-mcp-bridge/package.json +1 -1
- package/scripts/e2e-first-time.mjs +1 -1
- package/scripts/render-check.mjs +1 -1
- package/scripts/unexecuted-asserts.mjs +2 -2
- package/shared/customer-store.mjs +3 -2
- package/vendor/buffers/package.json +1 -1
- /package/portal-ui/dist/assets/{index-D5rkCjDc.js → index-CYaO2ygd.js} +0 -0
|
@@ -575,10 +575,10 @@ export const anthropicAgentEngine = {
|
|
|
575
575
|
const maxBuffer = engineMaxBufferChars();
|
|
576
576
|
let lastMove = Date.now();
|
|
577
577
|
let lastProgress = Date.now(); // honest-progress clock: token movement / agent-loop steps / artifact writes ONLY
|
|
578
|
-
let firstOutputAt = null; //
|
|
578
|
+
let firstOutputAt = null; // first byte of the PROTOCOL (stdout only); until then every clock below is timing STARTUP
|
|
579
579
|
let atKill = null; // what the watchdog had seen when it decided to kill — recording only, see killDecision
|
|
580
580
|
let silentIdleMs = null; // the no-progress clock at the watchdog's last look before the child spoke — recording only
|
|
581
|
-
const GRACE = spawnGraceMs(); // one source of the grace: common.mjs
|
|
581
|
+
const GRACE = spawnGraceMs(); // one source of the grace: common.mjs sets it
|
|
582
582
|
let sawAnyEvent = false; // ANY parseable stream event (incl. system:init) — false on close = the CLI died before streaming (startup-class failure)
|
|
583
583
|
let rateLimitEvent = null; // a 429 session-cap rejection rides a `rate_limit_event` (status:"rejected" + resetsAt)
|
|
584
584
|
// Streamed-usage accumulator: what the turn PROVABLY moved, observed from the stream itself, so a
|
|
@@ -849,7 +849,7 @@ export const anthropicAgentEngine = {
|
|
|
849
849
|
// classification and no recovery park, or the turn never settles with its watchdog already gone.
|
|
850
850
|
// Same belt-and-braces as the thinking gauge's `?.some?.()` on the line above.
|
|
851
851
|
for (const b of Array.isArray(ev.message?.content) ? ev.message.content : []) {
|
|
852
|
-
if (b?.type === "tool_use") { toolCalls++; countTool(toolCallsByName, b?.name); } //
|
|
852
|
+
if (b?.type === "tool_use") { toolCalls++; countTool(toolCallsByName, b?.name); } // every tool, not only Read; the count and its split by name
|
|
853
853
|
if (b?.type === "tool_use" && b?.id != null) toolNameById.set(String(b.id), String(b?.name ?? "?"));
|
|
854
854
|
if (b?.type === "tool_use" && COMMAND_TOOLS.includes(b?.name)) commandToolCalls++;
|
|
855
855
|
if (b?.type === "tool_use" && FILE_WRITE_TOOLS.includes(b?.name) && b?.id != null) writeAsks.add(String(b.id));
|
|
@@ -1061,7 +1061,7 @@ export const anthropicAgentEngine = {
|
|
|
1061
1061
|
const overflowKill = () => { if (overflow) return; overflow = true; killTree(); settle(1); };
|
|
1062
1062
|
child.stdout.on("data", (d) => {
|
|
1063
1063
|
if (settled || overflow) return;
|
|
1064
|
-
if (firstOutputAt === null) firstOutputAt = Date.now(); //
|
|
1064
|
+
if (firstOutputAt === null) firstOutputAt = Date.now(); // the child has spoken; startup is over
|
|
1065
1065
|
chunkSeq += 1; // see toolAskedChunk
|
|
1066
1066
|
chunkBytes = d.length;
|
|
1067
1067
|
chunkGapMs = prevChunkAt === null ? 0 : Date.now() - prevChunkAt;
|
|
@@ -1192,7 +1192,7 @@ export const anthropicAgentEngine = {
|
|
|
1192
1192
|
// true = the 500-path cap dropped at least one further distinct file (so a `read:false` derived
|
|
1193
1193
|
// from this list is unreliable and the consumer must downgrade it to "not observed").
|
|
1194
1194
|
reads: [...reads], readsTruncated,
|
|
1195
|
-
toolCalls, toolWaitMs: settledToolWaitMs, //
|
|
1195
|
+
toolCalls, toolWaitMs: settledToolWaitMs, // two integers, no content
|
|
1196
1196
|
// The same calls by tool name (values sum to toolCalls), and what the session went through: every
|
|
1197
1197
|
// result, cut, refusal and restart (session-record.mjs). `stream` is the raw stream's file and size,
|
|
1198
1198
|
// or why it was not kept. Recording only — `failed` above still reads the last result alone.
|
|
@@ -164,12 +164,14 @@ const NOISE_KEYS = new Set(["raw", "highlight", "score", "poca_scores", "onomati
|
|
|
164
164
|
// the extra provenance is the answer ("which owner slice found this?"). The FILTER always reads the
|
|
165
165
|
// band file itself, never this projection, so matching is unaffected either way.
|
|
166
166
|
const singleton = (v, first) => !Array.isArray(v) || v.length <= 1 || (v.length === 1 && v[0] === first);
|
|
167
|
+
// A record's set-aside is served as its classes and reason. The shape's recorded answer for that wording (`test`) is
|
|
168
|
+
// read into `goods_words`, and is not served on its own.
|
|
167
169
|
const project = (r) => Object.fromEntries(Object.entries(r).filter(([k, v]) => {
|
|
168
170
|
if (NOISE_KEYS.has(k)) return false;
|
|
169
171
|
if (k === "_qids") return !singleton(v, r?._qid);
|
|
170
172
|
if (k === "_queries") return !singleton(v, r?._query);
|
|
171
173
|
return true;
|
|
172
|
-
}));
|
|
174
|
+
}).map(([k, v]) => (k === "goods_set_aside" && v && typeof v === "object" ? [k, { classes: v.classes, reason: v.reason }] : [k, v])));
|
|
173
175
|
|
|
174
176
|
const norm = (s) => String(s ?? "").trim().toLowerCase();
|
|
175
177
|
// A3 (addendum 2026-07-30): the READER lowercases the incoming uri — reader-side ONLY. The archived
|
|
@@ -299,7 +301,7 @@ const shapeGoodsTest = () => {
|
|
|
299
301
|
if (testCache) return testCache;
|
|
300
302
|
let words = [];
|
|
301
303
|
try { words = loadJson(shapeJsonPath()).groups?.goods_test?.words ?? []; } catch { words = []; }
|
|
302
|
-
testCache = { words, matched: goodsWordsMatched(words, { stems: true }) };
|
|
304
|
+
testCache = { words, matched: goodsWordsMatched(words, { stems: true, setAsideTest: true }) };
|
|
303
305
|
return testCache;
|
|
304
306
|
};
|
|
305
307
|
// THE REGISTER'S OWN PAGES THE RUN'S RESEARCH SAVED (saved-register-pages.mjs), read again at the start of each lookup
|
|
@@ -560,9 +562,11 @@ function bandRecord(params = {}) {
|
|
|
560
562
|
logRead("band_record", { record_id: uri }, { ok: false, reason: hit.miss, ...(failed ? { fetch_failed: true } : {}) });
|
|
561
563
|
return { isError: true, text: `${why} ${rest}` };
|
|
562
564
|
}
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
565
|
+
// A class whose goods text the merged band set aside is said as set aside, with no text: never an empty statement.
|
|
566
|
+
const goodsLines = statements.map((g) => JSON.stringify(g.setAside ? { class: g.classes.join(",") || null, text: null, goods_from: SET_ASIDE_FROM }
|
|
567
|
+
: { class: g.classes.join(",") || null, text: g.text,
|
|
568
|
+
goods_from: g.cut ? "search answer, cut by the register" : g.unknown ? "search answer, completeness not established"
|
|
569
|
+
: g.page ? registerPageLabel(g.page.question) : "search answer" }));
|
|
566
570
|
const text = [why, ...goodsLines, rest].join("\n");
|
|
567
571
|
const parts = splitAtLines(text, RESPONSE_CHARS);
|
|
568
572
|
const wanted = Number(params.part ?? 1);
|
|
@@ -574,6 +578,9 @@ function bandRecord(params = {}) {
|
|
|
574
578
|
+ (part < parts.length ? `\n[end of part ${part}/${parts.length} — part ${part + 1} is available with {"record_id": "${uri}", "part": ${part + 1}}]` : "") };
|
|
575
579
|
}
|
|
576
580
|
|
|
581
|
+
// What `band_record` says of a class whose goods text the merged band set aside (named-band.mjs `rowAsHanded`).
|
|
582
|
+
const SET_ASIDE_FROM = "set aside from this run's band, outside the order's classes: not shown, and not the register listing no goods";
|
|
583
|
+
|
|
577
584
|
// The band row a record id names, from the band file, read once per server. null where the band holds none.
|
|
578
585
|
let bandRowsCache = null;
|
|
579
586
|
function bandRowFor(uri) {
|
|
@@ -600,7 +607,7 @@ const GROUP_PAGES = process.env.CLEAROTRON_BAND_GROUPS === "1";
|
|
|
600
607
|
// served the shape without them (the owner's ruling, 2026-10-14). Each is removed with the space before it, inside
|
|
601
608
|
// its line, so no line moves and the line each listed mark is printed on, which `linesByPart` reads, still holds.
|
|
602
609
|
// (band-shape.mjs `withoutPlacementOrders` removes them, with the shape's other placement-only orders and its group-page commands.)
|
|
603
|
-
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.";
|
|
610
|
+
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, and so does one with a class's goods text set aside where the rest holds none of the words), 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 band row names omitted classes in `goods_set_aside`. When the goods served come from the trimmed search answer, `goods_from` names those omissions; a separately fetched official record may supply their wording. A saved goods-word result records the outcome of the shape's stated word test on the wording available when the band was merged. It supports grouping and order. It does not establish that the omitted goods are legally unrelated. `band_record` shows what wording is available to read now. The goods text is in band_record, except a set-aside class's text where no official record was fetched. Matching un-enumerated crowd descriptors ride along so a lookup can never mistake a counted-only zone for a clean.";
|
|
604
611
|
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), ";
|
|
605
612
|
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)";
|
|
606
613
|
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)";
|
|
@@ -633,7 +640,7 @@ serve({
|
|
|
633
640
|
},
|
|
634
641
|
{
|
|
635
642
|
name: "band_record",
|
|
636
|
-
description: "The OFFICIAL registry record the driver fetched into this run's _records/ for a given record_id (/mark/... uri) — the fetched document itself, for detail the band row does not carry. Cite the uri in whatever form the band, the findings or the provider gave you: case, a wrapping provider URL and the registration-instance suffix are all resolved to the same document. Read-only: it never fetches. An unfetched record returns an honest miss listing what is on file, with the goods the register's search answer listed for it where it listed any; a record that IS on file but cannot be opened says so — both are gaps to state, never records without documents. Every call is logged to the reading audit.",
|
|
643
|
+
description: "The OFFICIAL registry record the driver fetched into this run's _records/ for a given record_id (/mark/... uri) — the fetched document itself, for detail the band row does not carry. Cite the uri in whatever form the band, the findings or the provider gave you: case, a wrapping provider URL and the registration-instance suffix are all resolved to the same document. Read-only: it never fetches. A fetched record is served whole, every class. An unfetched record returns an honest miss listing what is on file, with the goods the register's search answer listed for it where it listed any, except the text of a class outside the order's classes, which this run's band set aside and names as set aside; a record that IS on file but cannot be opened says so — both are gaps to state, never records without documents. Every call is logged to the reading audit.",
|
|
637
644
|
inputSchema: { type: "object", required: ["record_id"], properties: { record_id: { type: "string", description: "the /mark/<cc>/<id> uri" }, part: { type: "number", description: "1-based part number when an oversize record is served in parts (default 1)" } } },
|
|
638
645
|
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
|
|
639
646
|
handler: bandRecord,
|
|
@@ -46,7 +46,7 @@ export const GOODS_EVIDENCE_FILE = "goods-evidence.json";
|
|
|
46
46
|
// read later as an official record held whole. The driver keeps the record a cold dispatch of the writer was given
|
|
47
47
|
// (pipeline.mjs, around `stage`), and the delivery check compares the findings with that copy: what they were written on.
|
|
48
48
|
export const GOODS_EVIDENCE_AS_WRITTEN_FILE = "goods-evidence.as-written.json";
|
|
49
|
-
export const GOODS_STATES = Object.freeze(["complete", "cut", "unknown", "absent", "unavailable", "not-held"]);
|
|
49
|
+
export const GOODS_STATES = Object.freeze(["complete", "cut", "unknown", "set-aside", "absent", "unavailable", "not-held"]);
|
|
50
50
|
|
|
51
51
|
const uriKey = (u) => normalizeRecordUri(u);
|
|
52
52
|
// A register's own id for a record, as a fetch row names it where the provider logs its own id rather than the
|
|
@@ -196,14 +196,18 @@ const fetchOf = (fetches, uri) => fetches?.get?.(uriKey(uri)) ?? fetches?.get?.(
|
|
|
196
196
|
export function recordGoodsEvidence(record, { goods = null, held = null, fetches = null } = {}) {
|
|
197
197
|
const uri = uriKey(record?.record_id) || String(record?.record_id ?? "");
|
|
198
198
|
const body = held?.get?.(uri) ?? null;
|
|
199
|
-
const
|
|
199
|
+
const all = goods?.of ? goods.of(record) : null;
|
|
200
|
+
// A class whose wording the merged band set aside is no statement: it is recorded beside the evidence, never read as
|
|
201
|
+
// the register listing no goods (record-goods.mjs `rowGoods`).
|
|
202
|
+
const setAside = (all ?? []).filter((g) => g?.setAside === true).flatMap((g) => g.classes ?? []);
|
|
203
|
+
const statements = all ? all.filter((g) => g?.setAside !== true) : null;
|
|
200
204
|
const fromBody = typeof goods?.held === "function" ? goods.held(record) : Boolean(statements);
|
|
201
205
|
const fetch = fetchOf(fetches, record?.record_id);
|
|
202
206
|
const readable = statements?.length ? statements.some((g) => g?.en !== false) : null;
|
|
203
207
|
const cut = (statements ?? []).some((g) => g?.cut === true);
|
|
204
208
|
const unknown = (statements ?? []).some((g) => g?.unknown === true);
|
|
205
209
|
const page = (statements ?? []).find((g) => g?.page)?.page ?? null;
|
|
206
|
-
const row = (state, source, basis, extra = null) => ({ uri, state, source, basis, ...extra, readable, held: body, fetch });
|
|
210
|
+
const row = (state, source, basis, extra = null) => ({ uri, state, source, basis, ...extra, ...(setAside.length ? { set_aside: setAside } : {}), readable, held: body, fetch });
|
|
207
211
|
// The statements are a held body's where the reader says so; a reader that cannot tell reads bodies only.
|
|
208
212
|
if (statements?.length && fromBody) {
|
|
209
213
|
const op = body?.goods?.operation ?? "undocumented";
|
|
@@ -214,9 +218,9 @@ export function recordGoodsEvidence(record, { goods = null, held = null, fetches
|
|
|
214
218
|
// A search answer's statements that a register page the run's research saved continues whole (record-goods.mjs
|
|
215
219
|
// `rowGoods`). The record rests on that page once none is left cut or not established whole; where its classes were
|
|
216
220
|
// continued from pages two questions saved, the question named is its first such class's.
|
|
217
|
-
if (statements?.length && page && !cut && !unknown) return row("complete", "register-page", "register-page-statement", { question: page.question });
|
|
218
|
-
if (statements?.length) return row(cut ? "cut" : unknown ? "unknown" : "complete", "search-row",
|
|
219
|
-
cut ? "register-flag" : unknown ? "default-answer-at-or-over-its-cut" : "default-answer-under-its-cut");
|
|
221
|
+
if (statements?.length && page && !cut && !unknown && !setAside.length) return row("complete", "register-page", "register-page-statement", { question: page.question });
|
|
222
|
+
if (statements?.length || setAside.length) return row(cut ? "cut" : unknown ? "unknown" : setAside.length ? "set-aside" : "complete", "search-row",
|
|
223
|
+
cut ? "register-flag" : unknown ? "default-answer-at-or-over-its-cut" : setAside.length ? "outside-the-order-classes" : "default-answer-under-its-cut");
|
|
220
224
|
if (body) {
|
|
221
225
|
// Lists no goods only where an operation whose goods are whole supplies the field and it is empty. A body with
|
|
222
226
|
// no goods field, or from an operation the tree documents nowhere, establishes nothing about its goods.
|
|
@@ -242,11 +246,15 @@ export function goodsFromLabel(e) {
|
|
|
242
246
|
if (e.source === "record-body") return e.state === "absent" ? "official record, no goods listed"
|
|
243
247
|
: e.state === "cut" ? "official record, cut by the register"
|
|
244
248
|
: e.state === "unknown" ? "official record, completeness not established" : "official record";
|
|
245
|
-
if (e.source === "search-row") return e.state === "cut" ? "search answer, cut by the register"
|
|
246
|
-
: e.state === "unknown" ? "search answer, completeness not established" : "search answer";
|
|
249
|
+
if (e.source === "search-row") return (e.state === "cut" ? "search answer, cut by the register"
|
|
250
|
+
: e.state === "unknown" ? "search answer, completeness not established" : "search answer") + setAsideNote(e.set_aside);
|
|
247
251
|
return e.state === "unavailable" ? "fetch failed" : "nothing held";
|
|
248
252
|
}
|
|
249
253
|
|
|
254
|
+
/** The classes whose wording the merged band set aside, said after a search answer's label. PURE. */
|
|
255
|
+
export const setAsideNote = (classes) => (Array.isArray(classes) && classes.length
|
|
256
|
+
? `; the goods text of class${classes.length > 1 ? "es" : ""} ${classes.join(", ")} is set aside, outside the order's classes` : "");
|
|
257
|
+
|
|
250
258
|
/** What the stages read for goods taken whole from a register page the run's research saved, naming the question. PURE. */
|
|
251
259
|
export const registerPageLabel = (question) => `the register's own page, saved by research question ${question}`;
|
|
252
260
|
|
package/driver/named-band.mjs
CHANGED
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
// mid-word produces something READABLE and wrong. Importing a pure sibling keeps this module's
|
|
27
27
|
// "no node imports → tests offline" invariant, exactly as connotation-search.mjs already does.
|
|
28
28
|
import { abbrev } from "./repair-contract.mjs";
|
|
29
|
+
import { rowGoods, setAsideTestAnswer } from "./record-goods.mjs";
|
|
29
30
|
|
|
30
31
|
export const BAND_STATES = ["enumerated", "incomplete"];
|
|
31
32
|
|
|
@@ -307,7 +308,8 @@ export function bandCrowds(band) {
|
|
|
307
308
|
* presence, positions and the recall reconciliation all read per-record), so a record surfaced by
|
|
308
309
|
* four slices is still ONE record - it just now says all four.
|
|
309
310
|
*/
|
|
310
|
-
export function mergeNamedBands(bands) {
|
|
311
|
+
export function mergeNamedBands(bands, { orderClasses = null, goodsTest = null } = {}) {
|
|
312
|
+
const handed = (r) => rowAsHanded(r, { orderClasses, goodsTest });
|
|
311
313
|
const byId = new Map();
|
|
312
314
|
const enumerated = [];
|
|
313
315
|
const crowds = [];
|
|
@@ -324,16 +326,71 @@ export function mergeNamedBands(bands) {
|
|
|
324
326
|
if (prior) { stamp(prior, r); continue; }
|
|
325
327
|
// `_qids`/`_queries` are seeded from this first copy's own provenance - a qid-less
|
|
326
328
|
// (model-authored) block still gets no qid invented for it.
|
|
327
|
-
const rec = { ...r, _qids: [], _queries: [] };
|
|
329
|
+
const rec = { ...handed(r), _qids: [], _queries: [] };
|
|
328
330
|
stamp(rec, r);
|
|
329
331
|
if (id) byId.set(id, rec);
|
|
330
332
|
enumerated.push(rec);
|
|
331
333
|
}
|
|
332
|
-
for (const c of bandCrowds(band)) crowds.push(c);
|
|
334
|
+
for (const c of bandCrowds(band)) crowds.push(Array.isArray(c?.sample) ? { ...c, sample: c.sample.map(handed) } : c);
|
|
333
335
|
}
|
|
334
336
|
return { enumerated, crowds };
|
|
335
337
|
}
|
|
336
338
|
|
|
339
|
+
/**
|
|
340
|
+
* THE REGISTER'S RAW ROW, AS FAR AS ANYTHING READS IT FROM THE MERGED BAND.
|
|
341
|
+
*
|
|
342
|
+
* A band record carries the register's whole search row as `raw` beside its normalised fields. No stage is served
|
|
343
|
+
* `raw`: the band tools strip it from every record they serve (`NOISE_KEYS`, engine/mcp/band-server.mjs). What reads
|
|
344
|
+
* it from the merged band reads these fields and no others:
|
|
345
|
+
* · `classifications`, every class statement whole, with its cut flag and language (`rowGoods`, record-goods.mjs);
|
|
346
|
+
* · `office_code` and `application_number`, the US status-page join (`usSerialOf`, saved-register-pages.mjs);
|
|
347
|
+
* · `registration_number`, `ir_number`, `filing_route` and `office_url`, a row's own numbers and office page
|
|
348
|
+
* (`neutralRow`, knockout-register-read.mjs);
|
|
349
|
+
* · `jurisdictions`, the opposition dates (registry-fidelity.mjs).
|
|
350
|
+
*
|
|
351
|
+
* THE REST WAS SIZE AND NOTHING ELSE. A Signa row has 43 fields, its `derived` block alone 4.7 MiB over a 3,224-record
|
|
352
|
+
* band, and a band-reading stage's time limit is derived from the merged band's size (band-size.mjs). Measured in
|
|
353
|
+
* testing, 2026-11-17: a 41.1 MB band refused placement at dispatch; the same band, kept to these fields, is 25.7 MB
|
|
354
|
+
* with every class statement whole.
|
|
355
|
+
*
|
|
356
|
+
* GOODS TEXT FOR THE ORDER'S CLASSES ONLY, for the same reason: goods text in other classes was the largest part of
|
|
357
|
+
* the band left after the raw trim. Given the order's classes, a class statement in any other class keeps its class
|
|
358
|
+
* number and loses its text, and the record says so: `goods_set_aside` names those classes
|
|
359
|
+
* and why, so a class number is never silently all that is left. Every record is treated alike, live or dead.
|
|
360
|
+
* Without the order's classes, every statement is kept.
|
|
361
|
+
*
|
|
362
|
+
* THE SHAPE'S ANSWER IS KEPT. Given the band shape's goods-test words (`goodsTest`, record-goods.mjs `shapeGoodsTest`),
|
|
363
|
+
* the record's whole wording is tested before any of it goes, every statement joined as the test joins them, and the
|
|
364
|
+
* answer rides in `goods_set_aside.test`: the words matched, or null where the test could not tell, with the list's key
|
|
365
|
+
* (`setAsideTestAnswer`). The shape then groups each record as the wording held at the merge would, and a test on any
|
|
366
|
+
* other list still cannot tell.
|
|
367
|
+
*
|
|
368
|
+
* THE MERGED BAND ONLY. Each axis's band, the executor's record of what the register answered, keeps the whole row.
|
|
369
|
+
* A reader that needs another field from the merged band adds it here. PURE.
|
|
370
|
+
*/
|
|
371
|
+
export const RAW_FIELDS_READ = Object.freeze(["classifications", "office_code", "application_number", "registration_number",
|
|
372
|
+
"ir_number", "filing_route", "office_url", "jurisdictions"]);
|
|
373
|
+
export const GOODS_SET_ASIDE_REASON = "outside the order's classes";
|
|
374
|
+
export function rowAsHanded(r, { orderClasses = null, goodsTest = null } = {}) {
|
|
375
|
+
if (!r || typeof r !== "object" || !r.raw || typeof r.raw !== "object" || Array.isArray(r.raw)) return r;
|
|
376
|
+
const raw = {};
|
|
377
|
+
for (const k of RAW_FIELDS_READ) if (Object.hasOwn(r.raw, k)) raw[k] = r.raw[k];
|
|
378
|
+
const order = Array.isArray(orderClasses) && orderClasses.length ? new Set(orderClasses.map((c) => String(c).trim())) : null;
|
|
379
|
+
if (!order || !Array.isArray(raw.classifications)) return { ...r, raw };
|
|
380
|
+
const setAside = [];
|
|
381
|
+
raw.classifications = raw.classifications.map((c) => {
|
|
382
|
+
if (!c || typeof c !== "object" || order.has(String(c.nice_class ?? "").trim())) return c;
|
|
383
|
+
if (typeof c.goods_services_text !== "string" || !c.goods_services_text) return c;
|
|
384
|
+
setAside.push(c.nice_class);
|
|
385
|
+
const { goods_services_text: _text, goods_services_text_truncated: _cut, goods_services_language: _lang, ...kept } = c;
|
|
386
|
+
return kept;
|
|
387
|
+
});
|
|
388
|
+
if (!setAside.length) return { ...r, raw };
|
|
389
|
+
// The answer on the whole row, as the test joins it, not on the set-aside statements alone.
|
|
390
|
+
const test = goodsTest?.words?.length ? setAsideTestAnswer(rowGoods(r), { words: goodsTest.words, stems: goodsTest.stems === true }) : null;
|
|
391
|
+
return { ...r, raw, goods_set_aside: { classes: setAside, reason: GOODS_SET_ASIDE_REASON, ...(test ? { test } : {}) } };
|
|
392
|
+
}
|
|
393
|
+
|
|
337
394
|
/** Every qid that surfaced a merged band record (the stamp union), first-seen first. PURE. */
|
|
338
395
|
export function recordQids(r) {
|
|
339
396
|
const out = Array.isArray(r?._qids) ? r._qids.filter(Boolean).map(String) : [];
|
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.6.0
|
|
5
|
+
"version": "0.6.0",
|
|
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": {
|
package/driver/pipeline.mjs
CHANGED
|
@@ -133,7 +133,7 @@ import { atomicWrite } from "./run-record.mjs";
|
|
|
133
133
|
import { writeOutboxPacket } from "./outbox.mjs";
|
|
134
134
|
import { parseCaseLawProfiles, joinCaseLawProfiles } from "./publish/parse.mjs"; import { buildAuditMd } from "./publish/audit-from-spine.mjs";
|
|
135
135
|
import { lastAcceptedMatterFrame, withFrameClasses, frameIdentifiedClassRows, frameHouseElementCandidate, readInstructedScope } from "./matter-frame-record.mjs"; // — the frame's inferred scope, when nothing was instructed; and the classes it judged necessary beyond the instructed ones, each with its reason, which the plan compile gives one identical-mark question apiece (decision 18)
|
|
136
|
-
import { bandShapeGoods, instructedOrder, goodsEvidence } from "./record-goods.mjs"; // — the band's goods, read from the run's own records, so the shape can sort by the client's goods
|
|
136
|
+
import { bandShapeGoods, shapeGoodsTest, instructedOrder, goodsEvidence } from "./record-goods.mjs"; // — the band's goods, read from the run's own records, so the shape can sort by the client's goods
|
|
137
137
|
import { frameWebChoiceFor, frameAskedForWebGrid, webGridOf } from "./web-grid.mjs"; // — the web grid the matter frame decides: its stores, its forms, what it set aside
|
|
138
138
|
import { mintSupplementalQid, stableStringify } from "./register-plan.mjs";
|
|
139
139
|
import { excludeHouseElement, verifyHouseElementOwnership, resolveRegions as resolvePlanRegions, HOUSE_ELEMENT_RECEIPT, rowOutsideProviderOffices } from "./register-plan.mjs";
|
|
@@ -450,7 +450,7 @@ export function takeSlicesOutOfTheBand(P, slices) { // @internal
|
|
|
450
450
|
// `named_band_*` tokens — a parse miss is a stage fail with the token, never a hard crash. mergeNamedBands
|
|
451
451
|
// de-dups enumerated records by record_id and preserves every crowd descriptor. Returns the merged band
|
|
452
452
|
// object {enumerated, crowds} plus { axes:[…], invalid:[{axis,reason}] } so the caller can flag a bad axis.
|
|
453
|
-
export function mergeRegisterBands(P, axes = []) { // @internal
|
|
453
|
+
export function mergeRegisterBands(P, axes = [], { orderClasses = null, goodsTest = null } = {}) { // @internal
|
|
454
454
|
const recorded = recordedSlicesByAxis(P);
|
|
455
455
|
const bands = [];
|
|
456
456
|
const merged = [];
|
|
@@ -486,7 +486,7 @@ export function mergeRegisterBands(P, axes = []) { // @internal
|
|
|
486
486
|
invalid.push({ axis: a, reason: String(e.message).slice(0, 120) });
|
|
487
487
|
}
|
|
488
488
|
}
|
|
489
|
-
return { band: mergeNamedBands(bands), axes: merged, invalid };
|
|
489
|
+
return { band: mergeNamedBands(bands, { orderClasses, goodsTest }), axes: merged, invalid };
|
|
490
490
|
}
|
|
491
491
|
|
|
492
492
|
// Merge the per-axis bands and write the UNION to register-named-band.json (atomic temp+rename) so Layer B's
|
|
@@ -550,7 +550,10 @@ export function stickyGapUnits(P) { // @internal
|
|
|
550
550
|
return new Set(rows.filter((r) => r?.kind === "deferred" && sticky.has(String(r.qid ?? ""))).map(formRowUnitKey));
|
|
551
551
|
}
|
|
552
552
|
|
|
553
|
-
|
|
553
|
+
// `reasked` names questions the run has just asked again by code (reaskFollowUpErrors) and `unsent` the ones it tried to
|
|
554
|
+
// and could not send. The first are counted as through the ladder; the second never are, wherever the last receipt
|
|
555
|
+
// listed them, so a receipt written again after a dispatch that sent nothing defers nothing.
|
|
556
|
+
export function writePlanExecutionReceipt(ctx, joinRes, { reasked = [], unsent = [] } = {}) { // @internal
|
|
554
557
|
const P = ctx.paths;
|
|
555
558
|
joinRes = holdStickyGapsIn(joinRes, readStickyGaps(P));
|
|
556
559
|
// — the ONE place the receipt is written is the one place this decision is taken. The
|
|
@@ -574,8 +577,11 @@ export function writePlanExecutionReceipt(ctx, joinRes) { // @internal
|
|
|
574
577
|
// will recur byte-identically forever. `\bhttp\s?5\d\d\b` matched it, so seven slices on one axis
|
|
575
578
|
// were filed ladder-spent with `permanent: 0` — a structural refusal recorded as weather.
|
|
576
579
|
// `retryCannotHelpWith` keeps the old rule and adds the one that outranks it.
|
|
580
|
+
const exhausted = ladderExhaustedQids(prior);
|
|
581
|
+
for (const q of reasked ?? []) exhausted.add(String(q));
|
|
582
|
+
for (const q of unsent ?? []) exhausted.delete(String(q));
|
|
577
583
|
const { join, converted } = deferExhaustedProviderErrors(
|
|
578
|
-
joinRes, readRegisterBands(P, ctx.axes ?? []),
|
|
584
|
+
joinRes, readRegisterBands(P, ctx.axes ?? []), exhausted,
|
|
579
585
|
retryCannotHelpWith);
|
|
580
586
|
if (converted.length) {
|
|
581
587
|
joinRes = join;
|
|
@@ -803,6 +809,95 @@ export function refreshSupplementalExecution(ctx) { // @internal
|
|
|
803
809
|
} catch (e) { note(`supplemental receipt refresh skipped (${String(e.message).slice(0, 80)}) — never-kill`); }
|
|
804
810
|
}
|
|
805
811
|
|
|
812
|
+
/**
|
|
813
|
+
* The questions to ask again after a follow-up turn: each `missing` from the bands as they stand that holds a provider
|
|
814
|
+
* error the run reads as passing (an outage, a 5xx). Read off the bands, not off the last receipt's `missing`, because
|
|
815
|
+
* the refresh above writes a follow-up's new questions there without asking any of them again. Left out: a question
|
|
816
|
+
* with no answer of any kind (no error block), a sticky gap, a refusal retrying cannot help (deferred at once, by the
|
|
817
|
+
* writer's own test), and anything the receipt already defers. PURE but for the reads.
|
|
818
|
+
*/
|
|
819
|
+
function followUpErrorsToReask(ctx, bands) {
|
|
820
|
+
const P = ctx.paths;
|
|
821
|
+
const deferredNow = new Set((readPlanExecution(ctx)?.deferred ?? []).map((d) => String(d?.qid ?? "")));
|
|
822
|
+
const joined = holdStickyGapsIn(joinPlanToBands(ctx.registerPlan, bands, joinOptions(ctx)), readStickyGaps(P));
|
|
823
|
+
const { join: open } = deferExhaustedProviderErrors(joined, bands, new Set(), retryCannotHelpWith);
|
|
824
|
+
const causeOf = new Map();
|
|
825
|
+
for (const arr of Object.values(bands ?? {}))
|
|
826
|
+
for (const b of arr ?? []) if (b && typeof b.qid === "string" && b.qid && b.error === true && b.deferred !== true && b.reason) causeOf.set(b.qid, String(b.reason));
|
|
827
|
+
const axisOf = new Map((ctx.registerPlan.entries ?? []).map((e) => [e.qid, e.axis]));
|
|
828
|
+
return (open.missing ?? []).filter((q) => causeOf.has(q) && !deferredNow.has(q) && axisOf.get(q))
|
|
829
|
+
.map((q) => ({ qid: q, axis: axisOf.get(q), cause: causeOf.get(q) }));
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
/**
|
|
833
|
+
* A FOLLOW-UP TURN'S QUESTION THAT CAME BACK A PROVIDER ERROR IS ASKED AGAIN BY CODE BEFORE THE RUN GOES ON.
|
|
834
|
+
*
|
|
835
|
+
* An escalation, an envelope close or a frame reopen can propose register questions, and the tool that takes them asks
|
|
836
|
+
* them at once. When the register answers one with an error the run reads as passing, the question joins the receipt as
|
|
837
|
+
* `missing`, and the receipt defers a provider error only after the run has asked it again. Nothing asked it again
|
|
838
|
+
* before the reading step: the fan-in had already run its ladder. So the axis read `unexecuted`, the reading step's
|
|
839
|
+
* clean rows on that axis were refused on each attempt, and the run parked to have a resume ask what one code call
|
|
840
|
+
* could ask in the same pass. Measured on a test run of 2026-11-12: two axes, six questions, three asked per axis in
|
|
841
|
+
* 20 requests; the run spent 318 more across two resumes (120, 46 and 152) and still delivered with the gap.
|
|
842
|
+
*
|
|
843
|
+
* Each such question is now sent once more through the executor (code, no model turn), axis by axis, and the attempt
|
|
844
|
+
* and what it brought back are logged before the receipt is written. The receipt then counts the questions it sent as
|
|
845
|
+
* asked again: one the register now answers is executed; one that still errors is deferred with its error as the stated
|
|
846
|
+
* reason, under the rule every deferral of a provider error follows. A question the executor could not send (no
|
|
847
|
+
* executor, its repair budget spent, a dispatch that failed before the register answered) is not counted and stays
|
|
848
|
+
* `missing`. `reasked` names questions the caller has already asked again by code in this pass (the frame reopen
|
|
849
|
+
* re-attempts its own), counted without a third ask. A run on which no follow-up question errored sends nothing more.
|
|
850
|
+
* NEVER-KILL: returns null when there was nothing to ask, else what was sent and what came back.
|
|
851
|
+
*/
|
|
852
|
+
export async function reaskFollowUpErrors(ctx, dispatchPlanQids, site, { reasked = [] } = {}) { // @internal
|
|
853
|
+
if (!ctx.registerPlan) return null;
|
|
854
|
+
refreshSupplementalExecution(ctx);
|
|
855
|
+
const P = ctx.paths;
|
|
856
|
+
try {
|
|
857
|
+
const pending = followUpErrorsToReask(ctx, readRegisterBands(P, ctx.axes ?? []));
|
|
858
|
+
if (!pending.length) return null;
|
|
859
|
+
const before = new Set((reasked ?? []).map(String));
|
|
860
|
+
const sent = pending.filter((q) => before.has(q.qid)).map((q) => q.qid);
|
|
861
|
+
const unsent = [];
|
|
862
|
+
const byAxis = new Map();
|
|
863
|
+
for (const q of pending) if (!before.has(q.qid)) { if (!byAxis.has(q.axis)) byAxis.set(q.axis, []); byAxis.get(q.axis).push(q.qid); }
|
|
864
|
+
const dispatches = [];
|
|
865
|
+
for (const [axis, qids] of byAxis) {
|
|
866
|
+
const dispatch = typeof dispatchPlanQids === "function" ? await dispatchPlanQids(axis, qids, `follow-up-reask:${site}`, 1) : null;
|
|
867
|
+
(dispatch === "ok" ? sent : unsent).push(...qids);
|
|
868
|
+
dispatches.push({ axis, qids, dispatch: dispatch ?? "not sent: no executor at this seam, or its repair budget is spent" });
|
|
869
|
+
}
|
|
870
|
+
// What came back, read off the bands before the receipt is written: the record of the attempt is the run log's.
|
|
871
|
+
const answeredNow = new Set(), errorNow = new Map();
|
|
872
|
+
for (const arr of Object.values(readRegisterBands(P, ctx.axes ?? [])))
|
|
873
|
+
for (const b of arr ?? []) {
|
|
874
|
+
if (!b || typeof b.qid !== "string" || !b.qid) continue;
|
|
875
|
+
if (b.error === true) errorNow.set(b.qid, String(b.reason ?? ""));
|
|
876
|
+
else answeredNow.add(b.qid);
|
|
877
|
+
}
|
|
878
|
+
const sentSet = new Set(sent);
|
|
879
|
+
const rows = [...new Set(pending.map((q) => q.axis))].map((axis) => {
|
|
880
|
+
const mine = pending.filter((q) => q.axis === axis).map((q) => q.qid);
|
|
881
|
+
const d = dispatches.find((x) => x.axis === axis);
|
|
882
|
+
const went = mine.filter((q) => sentSet.has(q));
|
|
883
|
+
return { axis, qids: mine.slice(0, 8), qids_omitted: Math.max(0, mine.length - 8),
|
|
884
|
+
dispatch: d ? String(d.dispatch).slice(0, 160) : "asked again by the caller in this pass",
|
|
885
|
+
sent: went.length, answered: went.filter((q) => answeredNow.has(q)).length,
|
|
886
|
+
still_erroring: went.filter((q) => errorNow.has(q) && !answeredNow.has(q)).length,
|
|
887
|
+
causes: [...new Set(went.filter((q) => errorNow.has(q)).map((q) => errorNow.get(q).slice(0, 160)))].slice(0, 3) };
|
|
888
|
+
});
|
|
889
|
+
runLog(P.runDir, { event: "follow-up-reask", site, rows });
|
|
890
|
+
if (!sent.length) return { site, sent, unsent, rows };
|
|
891
|
+
remergeIfBandsMoved(ctx, `follow-up-reask:${site}`);
|
|
892
|
+
writePlanExecutionReceipt(ctx, joinPlanToBands(ctx.registerPlan, readRegisterBands(P, ctx.axes ?? []), joinOptions(ctx)), { reasked: sent, unsent });
|
|
893
|
+
runLog(P.runDir, { event: "plan-execution-refresh", added: 0, reasked: sent.length, site });
|
|
894
|
+
return { site, sent, unsent, rows };
|
|
895
|
+
} catch (e) {
|
|
896
|
+
note(`follow-up re-ask (${site}) skipped (${String(e?.message ?? e).slice(0, 80)}) — never-kill`);
|
|
897
|
+
return null;
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
|
|
806
901
|
/** One axis band's bytes, or null where it has none: what a re-run's change is measured against. */
|
|
807
902
|
function bandBytesOf(P, axis) { try { return readFileSync(P.registerBand(axis), "utf8"); } catch { return null; } }
|
|
808
903
|
|
|
@@ -835,7 +930,7 @@ export function remergeIfBandsMoved(ctx, why, { refusing = (bytes) => stagesRefu
|
|
|
835
930
|
const now = axisBandsFingerprint(P, ctx.axes);
|
|
836
931
|
if (now === ctx.bandsMergedAt || now === ctx.bandsRefusedAt) return false; // unmoved, or already refused as it stands
|
|
837
932
|
try {
|
|
838
|
-
const merged = mergeRegisterBands(P, ctx.axes ?? []);
|
|
933
|
+
const merged = mergeRegisterBands(P, ctx.axes ?? [], bandTrim(ctx));
|
|
839
934
|
if (!merged.invalid.length) {
|
|
840
935
|
const bytes = Buffer.byteLength(namedBandText(merged.band));
|
|
841
936
|
const stages = refusing(bytes);
|
|
@@ -885,13 +980,21 @@ export function refusedRecordsLeftOut(P) { // @internal — driven by its test
|
|
|
885
980
|
return ids.map((x) => String(x).toLowerCase()).filter((id) => id && !inBand.has(id));
|
|
886
981
|
}
|
|
887
982
|
|
|
888
|
-
/**
|
|
889
|
-
|
|
983
|
+
/**
|
|
984
|
+
* The named band as it is written to disk: what a dispatch over it measures.
|
|
985
|
+
*
|
|
986
|
+
* WRITTEN WITHOUT INDENTATION. Every reader parses it, but one: the form-gap check (`mechanicalFormGapDirectives`)
|
|
987
|
+
* also searches its text for each near-form term. A term holds no JSON punctuation, so it matches inside one token
|
|
988
|
+
* or not at all, and the indentation between tokens changes nothing it finds. Indented, the band was an eighth
|
|
989
|
+
* whitespace: measured in testing, 2026-11-17, a 25,677,439-byte band was 22,026,521 bytes compact, with the
|
|
990
|
+
* check's answer the same for every one of the run's 345 near-form terms.
|
|
991
|
+
*/
|
|
992
|
+
export const namedBandText = (band) => JSON.stringify(band) + "\n"; // @internal — driven by its test
|
|
890
993
|
|
|
891
994
|
export function deriveNamedBand(ctx, merged = null) { // @internal — driven by its test with a run's own files
|
|
892
995
|
const P = ctx.paths;
|
|
893
996
|
const axes = ctx.axes ?? [];
|
|
894
|
-
const { band, axes: ok, invalid } = merged ?? mergeRegisterBands(P, axes); // a caller that measured the merge first hands it in
|
|
997
|
+
const { band, axes: ok, invalid } = merged ?? mergeRegisterBands(P, axes, bandTrim(ctx)); // a caller that measured the merge first hands it in
|
|
895
998
|
const mergedFrom = axisBandsFingerprint(P, axes);
|
|
896
999
|
if (invalid.length) {
|
|
897
1000
|
const detail = invalid.map((x) => `${x.axis}:${x.reason}`).join("; ");
|
|
@@ -1087,8 +1190,7 @@ function deriveBandShape(ctx, band) {
|
|
|
1087
1190
|
try { if (existsSync(P.crowdContext)) crowdContext = JSON.parse(readFileSync(P.crowdContext, "utf8")); }
|
|
1088
1191
|
catch { /* evidence artifact unreadable — the shape's crowds simply carry no join */ }
|
|
1089
1192
|
// The instructed classes and those the frame added for the client's own goods (decision 18, ruled 2026-09-21): a live identical record in either is a floor.
|
|
1090
|
-
|
|
1091
|
-
inScopeClasses = withFrameClasses(inScopeClasses, P.runDir);
|
|
1193
|
+
const inScopeClasses = bandClasses(ctx);
|
|
1092
1194
|
// P2-A (charter P2d) — the exact-identity POSITIONS projection rides every shape derivation, so
|
|
1093
1195
|
// the identity collapse exists BEFORE any digest reads the band. The detail index (registration
|
|
1094
1196
|
// numbers, IR-base linkage, Madrid designations) comes from _records/ — the fields search rows
|
|
@@ -7515,6 +7617,21 @@ export function readFindingsForReport(P) {
|
|
|
7515
7617
|
// The matter's FULL in-scope Nice-class set (incl. services 42/44) — declared classes (top-level OR per-mark)
|
|
7516
7618
|
// else the profile defaults. The dangerous-band floor + its coverage gate must span ALL of these, never a
|
|
7517
7619
|
// goods-only subset (the VELTRIPHEN services-class miss). Strings, deduped.
|
|
7620
|
+
/**
|
|
7621
|
+
* The classes this run's band is read in: the instructed ones, then those the frame added for the client's own goods
|
|
7622
|
+
* (decision 18). One answer for two readers: the band shape, where a live identical mark in any of them is a floor, and
|
|
7623
|
+
* the merged band, which carries goods text for these classes only (named-band.mjs `rowAsHanded`). IMPURE: reads the
|
|
7624
|
+
* accepted frame.
|
|
7625
|
+
*/
|
|
7626
|
+
// What the merge needs to set goods text aside: the order's classes, and the shape's goods-test words, whose answer
|
|
7627
|
+
// for the set-aside wording the merge keeps (named-band.mjs `rowAsHanded`). IMPURE: reads the run's frame and manifest.
|
|
7628
|
+
const bandTrim = (ctx) => ({ orderClasses: bandClasses(ctx), goodsTest: ctx?.paths ? shapeGoodsTest(ctx.paths) : null });
|
|
7629
|
+
|
|
7630
|
+
export function bandClasses(ctx) { // @internal — driven by its test
|
|
7631
|
+
let classes = [];
|
|
7632
|
+
try { classes = inScopeClassList(ctx?.job, ctx?.profile).map(String); } catch { classes = (ctx?.job?.classes ?? []).map(String); }
|
|
7633
|
+
return withFrameClasses(classes, ctx?.paths?.runDir);
|
|
7634
|
+
}
|
|
7518
7635
|
export function inScopeClassList(job, profile) { // @internal — also read by scripts/register-plan-shape.mjs, which must resolve scope exactly as the run did
|
|
7519
7636
|
const fromMarks = Array.isArray(job?.marks) ? job.marks.flatMap((m) => (Array.isArray(m?.classes) ? m.classes : [])) : [];
|
|
7520
7637
|
const declared = [...(Array.isArray(job?.classes) ? job.classes : []), ...fromMarks];
|
|
@@ -9728,7 +9845,7 @@ async function pipelineInner(job, opts = {}) {
|
|
|
9728
9845
|
} },
|
|
9729
9846
|
{ name: "frame-comparison", run: async () => {
|
|
9730
9847
|
// The blind frame compared with what the run scoped, and the reopen (steps/frame-comparison.mjs).
|
|
9731
|
-
await runFrameComparison({ P, axes, ctx, dispatchPlanQids, flushDigestQueue, job, mintDigestWork, planExec, run, runCommonLaw, unitKey }, { bandBytesOf, deriveNamedBand, forceFromActive, inScopeClassList, joinOptions, loadCoverageLedger, mechanicalFormGapDirectives, readRegisterBands, refreshSupplementalExecution, remergeIfBandsMoved, settleOneShotStamp, stage });
|
|
9848
|
+
await runFrameComparison({ P, axes, ctx, dispatchPlanQids, flushDigestQueue, job, mintDigestWork, planExec, run, runCommonLaw, unitKey }, { bandBytesOf, deriveNamedBand, forceFromActive, inScopeClassList, joinOptions, loadCoverageLedger, mechanicalFormGapDirectives, readRegisterBands, reaskFollowUpErrors, refreshSupplementalExecution, remergeIfBandsMoved, settleOneShotStamp, stage });
|
|
9732
9849
|
} },
|
|
9733
9850
|
{ name: "placement-and-digest", run: async () => {
|
|
9734
9851
|
// Step 2C placement → Step 2D digest
|
|
@@ -9742,7 +9859,7 @@ async function pipelineInner(job, opts = {}) {
|
|
|
9742
9859
|
} },
|
|
9743
9860
|
{ name: "skeptic-and-follow-up", run: async () => {
|
|
9744
9861
|
// The skeptic, and the searches and rechecks that follow it (steps/skeptic-and-follow-up.mjs).
|
|
9745
|
-
await runSkepticAndFollowUp({ P, agent, axes, ctx, dispatchPlanQids, flushDigestQueue, job, mintDigestWork, opts, planExec, run, unitKey }, { askableOf, bandBytesOf, capabilityGapAxes, defaultRecordFetcher, deriveBandShape, deriveNamedBand, envelopeDecision, envelopeHeldNote, escalationHeldNote, findFloorBreaches, forceFromActive, isInactiveAxisRow, lateRecordIds, loadCoverageLedger, officeGapOf, readFloorAxes, readPlanExecution, recordPlacementPass, recordScreenGateEvidence, refreshSupplementalExecution, remergeIfBandsMoved, runBatched, screenGateSnapshot, settleOneShotStamp, skepticDeferralExtra, stage, stickyGapUnits });
|
|
9862
|
+
await runSkepticAndFollowUp({ P, agent, axes, ctx, dispatchPlanQids, flushDigestQueue, job, mintDigestWork, opts, planExec, run, unitKey }, { askableOf, bandBytesOf, capabilityGapAxes, defaultRecordFetcher, deriveBandShape, deriveNamedBand, envelopeDecision, envelopeHeldNote, escalationHeldNote, findFloorBreaches, forceFromActive, isInactiveAxisRow, lateRecordIds, loadCoverageLedger, officeGapOf, readFloorAxes, readPlanExecution, reaskFollowUpErrors, recordPlacementPass, recordScreenGateEvidence, refreshSupplementalExecution, remergeIfBandsMoved, runBatched, screenGateSnapshot, settleOneShotStamp, skepticDeferralExtra, stage, stickyGapUnits });
|
|
9746
9863
|
} },
|
|
9747
9864
|
{ name: "synthesis", run: async () => {
|
|
9748
9865
|
// The writer, the case-law grounding and the first review (steps/synthesis.mjs).
|
|
@@ -1304,12 +1304,15 @@ const STORE_TTL_MS = 30_000;
|
|
|
1304
1304
|
*
|
|
1305
1305
|
* `posture` is the demo's own sentence. In a demo it stands wherever this would otherwise say more.
|
|
1306
1306
|
*/
|
|
1307
|
+
export const UNSET_OVERLAY_LINE = "CLEAROTRON_INSTRUCTIONS_DIR and PROFILE_REPO_ROOT are unset, so risk frameworks are read from the files that ship with this install. A framework kept only in a separate config store is not read: the company's profile page says its framework could not be read, or shows a shipped framework of the same file name. To use that store, set CLEAROTRON_INSTRUCTIONS_DIR to its instruction folder, or PROFILE_REPO_ROOT to the store containing that folder as skills.";
|
|
1307
1308
|
export function skillsOverlayAtBoot({ explicit = null, profileRepoRoot = null, readdir = readdirSync, exists = existsSync, posture = null } = {}) {
|
|
1308
1309
|
const synthetic = "customer risk frameworks will resolve to this repo's demo fixtures and the Brand profile page will "
|
|
1309
1310
|
+ "show either \"could not be read\" or a SYNTHETIC framework as though it were the customer's own. "
|
|
1310
1311
|
+ "Set CLEAROTRON_INSTRUCTIONS_DIR (or PROFILE_REPO_ROOT) to the config store.";
|
|
1311
1312
|
if (explicit) return { pin: null, line: exists(explicit) ? null : (posture || `WARNING: skills overlay unreadable (${explicit}) — ${synthetic}`) };
|
|
1312
|
-
|
|
1313
|
+
// NOTHING SET IS A FRESH LOCAL INSTALL as often as a hosted one that left a setting out, so the line says what is read,
|
|
1314
|
+
// what is not, and the remedy, without a warning's prefix. Design's wording (2026-11-17).
|
|
1315
|
+
if (!profileRepoRoot) return { pin: null, line: posture || UNSET_OVERLAY_LINE };
|
|
1313
1316
|
const dir = join(profileRepoRoot, "skills");
|
|
1314
1317
|
const nothing = (how) => posture || (`skills overlay: ${dir} ${how}, so this install overrides nothing and the product's own `
|
|
1315
1318
|
+ "instruction files are used. To override one, put the file there, commit it, set CLEAROTRON_INSTRUCTIONS_DIR to that folder, and restart.");
|
|
@@ -98,6 +98,11 @@ function stripHtml(s) {
|
|
|
98
98
|
// "April 2014", "MAY 2026" — dates pass the Title-Case-multi-word shape but are never entities.
|
|
99
99
|
const DATE_TOKEN_RE = /^(january|february|march|april|may|june|july|august|september|october|november|december)(\s+\d{1,4})?$/i;
|
|
100
100
|
|
|
101
|
+
// A PRODUCT TIER IS A LABEL, NOT A PARTY. An action about the client's own range wrote "Tier 1", and the report's
|
|
102
|
+
// check named it as a party no finding identifies. The label is the word with a number or a single letter, as
|
|
103
|
+
// "Level 3" is vocabulary. The word on its own, or with a name after it, stays a candidate: a company can carry it.
|
|
104
|
+
const TIER_LABEL_RE = /^tier (?:\d+|[a-z])$/;
|
|
105
|
+
|
|
101
106
|
// Proper-name candidates in a text span: ALL-CAPS tokens (RTVE, IKEA, SATIN & BRONZE) and Title-Case
|
|
102
107
|
// multi-word names (High 5 Games). Single Title-Case words are excluded (too noisy).
|
|
103
108
|
export function properNameCandidates(text, extraVocab = null, { actionBullets = false, territories = false } = {}) {
|
|
@@ -115,6 +120,7 @@ export function properNameCandidates(text, extraVocab = null, { actionBullets =
|
|
|
115
120
|
const isVocab = (tok) => {
|
|
116
121
|
const n = norm(tok);
|
|
117
122
|
if (inList(n)) return true; // whole-phrase entries ("apple app store", "epic games store")
|
|
123
|
+
if (TIER_LABEL_RE.test(n)) return true;
|
|
118
124
|
return n.split(" ").every((w) => !w || inList(w) || /^\d+$/.test(w));
|
|
119
125
|
};
|
|
120
126
|
// norm-keyed so "AMAZON SILK" and "Amazon Silk" are ONE candidate; the mixed-case form wins the display
|
|
@@ -130,6 +136,9 @@ export function properNameCandidates(text, extraVocab = null, { actionBullets =
|
|
|
130
136
|
// ("Trademark Register") into a phantom company. An entity name is always on one line in these surfaces.
|
|
131
137
|
for (const m of t.matchAll(/\b([A-Z][A-Z0-9]{2,}(?:[ \t]*[&+][ \t]*[A-Z][A-Z0-9]{1,})*(?:[ \t]+[A-Z][A-Z0-9]{2,})*)\b/g)) {
|
|
132
138
|
const tok = m[1].trim();
|
|
139
|
+
// this pattern stops before the number, so "TIER 3" reaches here as "TIER"; the label is read with what follows
|
|
140
|
+
const next = (t.slice(m.index + m[0].length).match(/^[ \t]+(?:\d+|[A-Za-z])\b/) ?? [""])[0];
|
|
141
|
+
if (TIER_LABEL_RE.test(norm(`${tok}${next}`))) continue;
|
|
133
142
|
if (!isVocab(tok) && norm(tok).length >= 3) add(tok);
|
|
134
143
|
}
|
|
135
144
|
// — A BULLET'S OPENING VERB IS NOT A NAME. The action list flagged "Instruct Japanese", which is
|