clearotron 0.5.0 → 0.5.1-beta.1

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.
Files changed (129) hide show
  1. package/CONTRIBUTING.md +2 -2
  2. package/INSTALL.md +351 -308
  3. package/QUICKSTART.md +12 -4
  4. package/README.md +12 -7
  5. package/THIRD-PARTY-NOTICES.md +4 -4
  6. package/bin/README.md +14 -11
  7. package/bin/clearotron.mjs +1 -1
  8. package/bin/connect.mjs +73 -25
  9. package/bin/example.mjs +4 -2
  10. package/bin/onboard.mjs +647 -352
  11. package/bin/start.mjs +213 -66
  12. package/bin/update.mjs +26 -13
  13. package/build-info.json +2 -2
  14. package/docs/CLIENT-MCP.md +1 -1
  15. package/docs/PORTAL.md +2 -2
  16. package/docs/architecture/02-architecture.md +3 -3
  17. package/docs/architecture/04-configuration-reference.md +2 -3
  18. package/docs/architecture/05-config-governance.md +1 -1
  19. package/docs/architecture/06-operations-runbook.md +1 -1
  20. package/driver/CHANGELOG.md +91 -0
  21. package/driver/README.md +2 -2
  22. package/driver/config-inventory.mjs +20 -11
  23. package/driver/contract-e3-backlog.mjs +27 -27
  24. package/driver/contract-e3-baseline.json +2 -2
  25. package/driver/contract-vocabulary.mjs +1 -1
  26. package/driver/degraded-parts.mjs +67 -3
  27. package/driver/dev-portal.mjs +1 -1
  28. package/driver/digest-queue.mjs +5 -5
  29. package/driver/driver.config.mjs +9 -9
  30. package/driver/engine/CONTRACT.md +1 -1
  31. package/driver/engine/anthropic-agent.mjs +4 -2
  32. package/driver/engine/jx-turn.mjs +10 -2
  33. package/driver/engine/mcp/band-server.mjs +1 -21
  34. package/driver/engine/mcp/clarivate-propose-tool.mjs +26 -0
  35. package/driver/engine/mcp/clarivate-server.mjs +2 -18
  36. package/driver/engine/mcp/fixture-register-server.mjs +33 -0
  37. package/driver/engine/mcp/gather-config.mjs +48 -7
  38. package/driver/engine/mcp/recording-server.mjs +206 -14
  39. package/driver/engine/mcp/supplemental.mjs +4 -2
  40. package/driver/engine/openai-agent.mjs +3 -1
  41. package/driver/engine/probe.mjs +10 -0
  42. package/driver/filing-goods.mjs +95 -0
  43. package/driver/findings-model.mjs +3 -0
  44. package/driver/gateway.mjs +42 -40
  45. package/driver/how-it-runs.mjs +103 -0
  46. package/driver/knockout-assess-record.mjs +54 -4
  47. package/driver/knockout-correction-record.mjs +342 -0
  48. package/driver/knockout-frame-record.mjs +4 -2
  49. package/driver/knockout-register-read.mjs +705 -0
  50. package/driver/knockout-register-record.mjs +222 -0
  51. package/driver/knockout-review-record.mjs +96 -25
  52. package/driver/narrative-refutation-record.mjs +87 -1
  53. package/driver/order-tables.mjs +23 -0
  54. package/driver/owner-use-check.mjs +5 -2
  55. package/driver/package.json +1 -1
  56. package/driver/partial-payload-baseline.json +8 -0
  57. package/driver/pipeline-knockout.mjs +506 -313
  58. package/driver/pipeline.mjs +179 -86
  59. package/driver/portal-local-auth.mjs +7 -1
  60. package/driver/portal-service.mjs +99 -9
  61. package/driver/progress.mjs +2 -2
  62. package/driver/publish/index.mjs +18 -21
  63. package/driver/publish/knockout.mjs +40 -18
  64. package/driver/publish/render-knockout.mjs +40 -27
  65. package/driver/publish/report-dates.mjs +43 -0
  66. package/driver/recall-reconciliation.mjs +2 -2
  67. package/driver/record-goods.mjs +50 -9
  68. package/driver/register-count.mjs +12 -59
  69. package/driver/register-fixture-marker.mjs +22 -0
  70. package/driver/register-plan.mjs +48 -0
  71. package/driver/register-records.mjs +84 -266
  72. package/driver/register-taint.mjs +2 -2
  73. package/driver/repair-composers.mjs +15 -8
  74. package/driver/result-noun-fields.mjs +6 -2
  75. package/driver/run-requirements.mjs +111 -37
  76. package/driver/runner.mjs +9 -16
  77. package/driver/skills/clearance-register/providers/clarivate.md +2 -2
  78. package/driver/skills/knockout-assess/SKILL.md +101 -100
  79. package/driver/skills/knockout-frame/SKILL.md +3 -1
  80. package/driver/skills/knockout-register-read/SKILL.md +77 -0
  81. package/driver/stages-knockout.mjs +159 -98
  82. package/driver/stages.mjs +4 -2
  83. package/driver/suite-census.json +435 -81
  84. package/driver/systemd/README.md +2 -2
  85. package/driver/unit-environment.mjs +19 -0
  86. package/driver/verify-knockout.mjs +175 -39
  87. package/driver/verify.mjs +10 -9
  88. package/mcp-server/CHANGELOG.md +8 -0
  89. package/mcp-server/CONNECT.md +4 -0
  90. package/mcp-server/demo-mode.mjs +6 -0
  91. package/mcp-server/lib/demo-texts.mjs +38 -0
  92. package/mcp-server/lib/http-handler.mjs +7 -1
  93. package/mcp-server/lib/knockout.mjs +3 -2
  94. package/mcp-server/lib/options.mjs +3 -1
  95. package/mcp-server/lib/plan.mjs +6 -1
  96. package/mcp-server/lib/runs.mjs +7 -2
  97. package/mcp-server/mint-token.mjs +1 -1
  98. package/mcp-server/package.json +1 -1
  99. package/mcp-server/serve.mjs +11 -0
  100. package/mcp-server/server.mjs +13 -5
  101. package/package.json +1 -1
  102. package/portal-ui/dist/assets/{index-D2wrw9cH.css → index-AtB9ZpDH.css} +29 -0
  103. package/portal-ui/dist/assets/{index-DcLbvFmQ.js → index-fPqAU0sx.js} +237 -231
  104. package/portal-ui/dist/index.html +2 -2
  105. package/portal-ui/package.json +4 -4
  106. package/providers/README.md +4 -4
  107. package/providers/_shared/execute-plan.mjs +45 -1
  108. package/providers/_shared/term-shape.mjs +1 -1
  109. package/providers/clarivate/src/capabilities.js +7 -6
  110. package/providers/clarivate/src/core.js +11 -7
  111. package/providers/clarivate/src/wider-list.js +104 -0
  112. package/providers/oauth-mcp-bridge/CHANGELOG.md +8 -0
  113. package/providers/oauth-mcp-bridge/package.json +1 -1
  114. package/providers/signa/src/capabilities.js +0 -9
  115. package/scripts/e2e-first-time.mjs +8 -7
  116. package/scripts/freeze-example-run.mjs +2 -2
  117. package/scripts/settings-render-check.mjs +5 -3
  118. package/scripts/test-run.mjs +8 -2
  119. package/shared/client-door.mjs +11 -8
  120. package/shared/connect-clients.mjs +10 -4
  121. package/shared/demo-connection.mjs +43 -0
  122. package/shared/demo-start-args.mjs +7 -2
  123. package/shared/invocation.mjs +18 -3
  124. package/shared/permanent-install.mjs +24 -0
  125. package/shared/scope.mjs +8 -1
  126. package/shared/server-units.mjs +37 -1
  127. package/shared/stdio-connect.mjs +43 -21
  128. package/shared/trigger-lane.mjs +7 -0
  129. package/shared/tty-style.mjs +21 -5
@@ -22,8 +22,8 @@ one restarts on failure ten seconds later.
22
22
 
23
23
  These are for a **server, not a laptop**. On a workstation `clearotron start` runs the same product in the foreground,
24
24
  and `clearotron start --background` installs these four units as your own user services ([`INSTALL.md`
25
- §6](../../INSTALL.md)). `node driver/runner.mjs --watch` is what to run by hand if you started with `--no-worker`
26
- (`INSTALL.md` §5): one foreground process that polls for queued jobs and for parked runs whose window has elapsed.
25
+ §5](../../INSTALL.md)). `node driver/runner.mjs --watch` is what to run by hand if you started with `--no-worker`
26
+ (`INSTALL.md` §6): one foreground process that polls for queued jobs and for parked runs whose window has elapsed.
27
27
 
28
28
  The packaged install runs no outbox watcher. An assistant that couriers delivered reports wakes itself
29
29
  ([`../../docs/DELIVERY.md`](../../docs/DELIVERY.md)); `driver/deliver-trigger.sh` is one agent platform's reference
@@ -139,6 +139,25 @@ function applyUnit(unitText, readEnvFile, home) {
139
139
  return { env: { ...env, ...fromFiles }, missing };
140
140
  }
141
141
 
142
+ /**
143
+ * The files a unit's `EnvironmentFile=` lines name, resolved as `applyUnit` resolves them (`%h` is `home`, and a
144
+ * leading `-` only marks the file optional), in the order listed. Null when a path cannot be resolved: then what
145
+ * the unit reads is not known, and naming one of its files would be a guess. PURE.
146
+ */
147
+ export function environmentFilesOf(unitText, home) {
148
+ const out = [];
149
+ for (const raw of String(unitText ?? "").split("\n")) {
150
+ const file = /^EnvironmentFile=(.*)$/.exec(raw.trim());
151
+ if (!file) continue;
152
+ let spec = file[1].trim();
153
+ if (spec.startsWith(OPTIONAL)) spec = spec.slice(1);
154
+ const resolved = expandSpecifiers(spec, home);
155
+ if (resolved.unresolved !== undefined) return null;
156
+ out.push(resolved.path);
157
+ }
158
+ return out;
159
+ }
160
+
142
161
  /**
143
162
  * The environment the units actually run with.
144
163
  *
@@ -3,12 +3,12 @@
3
3
  // verify-knockout.mjs — validators + gates for the KNOCKOUT (Depth 1) lane.
4
4
  // Same contract as verify.mjs validators: (file, text) -> {ok, reason?} for per-stage outputs (they ride
5
5
  // runStage's corrective ladder), plus code-side gates for the merged findings and the pre-publish lint.
6
- // The receipts discipline: every cited URL must appear in THAT mark's raw research payload or in the register
7
- // records supplied for that mark — the knockout analogue of the band-truth gate (a finding the driver cannot trace to held evidence is treated as
6
+ // The receipts discipline: every cited URL must trace to a recorded research payload for this batch, a filing
7
+ // held for this batch, or a recorded owner check linked to a held filing — the knockout analogue of the band-truth gate (a finding the driver cannot trace to held evidence is treated as
8
8
  // fabricated). It runs at three doors and has NO off switch: CLEAROTRON_KNOCKOUT_URL_GATE is deleted.
9
9
  // An env var that disarms a gate makes the gate's absence look exactly like its pass, which is the one
10
10
  // failure mode this lane's gates exist to refuse.
11
- import { readFileSync, existsSync } from "node:fs";
11
+ import { readFileSync, readdirSync, existsSync } from "node:fs";
12
12
  import { join, dirname, basename } from "node:path";
13
13
  import { DRIVER_DIR, driverDir } from "../shared/driver-dir.mjs"; //
14
14
  import { kebab, kebabCollisions, CAPABILITY_SKIPPED_NOTE } from "./search-policy.mjs";
@@ -84,7 +84,7 @@ export function knockoutCitedUrls(f) {
84
84
  }
85
85
 
86
86
  /**
87
- * Every cited URL ∈ that mark's own raw research payload on disk.
87
+ * Every cited URL traces to what `urlHeldFor` admits.
88
88
  *
89
89
  * WHAT A ZERO MEANS, because this gate can pass without doing anything: a batch whose findings cite no
90
90
  * URLs at all is `ok` with `checked.urls === 0`. That is not the same answer as "every citation was
@@ -95,42 +95,48 @@ export function knockoutCitedUrls(f) {
95
95
  * @returns {{ok: boolean, failures: string[], checked: {marks: number, citing: number, findings: number, urls: number}}}
96
96
  */
97
97
  /**
98
- * THE REGISTER FILINGS THE RATING STEP WAS HANDED, per mark, as text (register-records.json, which the rating
99
- * message names when it is on disk). The message lets a citation come from the mark's own payload or from the
100
- * filings supplied for that mark, so the receipts check reads both; another mark's filings license nothing.
98
+ * WHERE A CITED URL MAY COME FROM, for any name in the batch: a recorded research payload for this batch, a filing held for this
99
+ * batch, or a recorded owner check linked to a held filing (design, 2026-11-05). Code checks that the source is held. Whether its
100
+ * content bears on the name is the model's to explain and the check's to read, and a source's presence supports nothing by itself.
101
+ * A URL only in raw web results, or any other file the step was not given as evidence, stays outside.
101
102
  */
102
- function suppliedRecordsByMark(runDir) {
103
+ export const PERMITTED_SOURCES = "a recorded research payload for this batch, a filing held for this batch, or a recorded owner check linked to a held filing";
104
+ export const urlNotHeld = (mark, url) => `knockout_url_unreceipted:${mark}: "${url}" is not traceable to ${PERMITTED_SOURCES}. Cite a source from that held evidence.`;
105
+ const OWNER_PAYLOAD = /^owner-.+-[0-9a-f]{10}\.md$/; // the name `ownerPayloadFile` gives a check's answer
106
+ export function urlHeldFor(runDir) {
107
+ let filings = null;
103
108
  try {
104
109
  const doc = JSON.parse(readFileSync(driverDir(runDir, "register-records.json"), "utf8"));
105
- return new Map((Array.isArray(doc?.marks) ? doc.marks : []).filter((x) => x?.name)
106
- .map((x) => [String(x.name).trim().toLowerCase(), JSON.stringify(Array.isArray(x.records) ? x.records : [])]));
107
- } catch { return new Map(); }
110
+ filings = JSON.stringify((Array.isArray(doc?.marks) ? doc.marks : []).flatMap((x) => [...(Array.isArray(x?.records) ? x.records : []), ...(Array.isArray(x?.setAsideRecords) ? x.setAsideRecords : [])]));
111
+ } catch { filings = null; }
112
+ let checks = [];
113
+ try { checks = JSON.parse(readFileSync(driverDir(runDir, "owner-checks.json"), "utf8")).checks ?? []; } catch { checks = []; }
114
+ const heldIds = registerRecordIdsHeld(runDir);
115
+ const linked = new Set(checks.filter((c) => (c?.recordIds ?? []).some((id) => heldIds.has(String(id)))).map((c) => c?.payloadFile));
116
+ const researchDir = join(runDir, "research");
117
+ let payload = "";
118
+ try {
119
+ payload = readdirSync(researchDir).filter((f) => f.endsWith(".md") && (OWNER_PAYLOAD.test(f) ? linked.has(f) : true)).map((f) => readFileSync(join(researchDir, f), "utf8")).join("\n");
120
+ } catch { payload = ""; }
121
+ return (url) => (filings != null && urlInPayload(url, filings)) || urlInPayload(url, payload);
108
122
  }
109
123
 
110
124
  export function knockoutReceipts(runDir, marks) {
111
125
  const failures = [];
112
126
  const checked = { marks: (marks ?? []).length, citing: 0, findings: 0, urls: 0 };
113
- const supplied = suppliedRecordsByMark(runDir);
127
+ let held = null;
114
128
  for (const m of marks ?? []) {
115
129
  const list = Array.isArray(m?.findings) ? m.findings : [];
116
130
  checked.findings += list.length;
117
- const records = supplied.get(String(m?.name ?? "").trim().toLowerCase()) ?? null;
118
- let payload = null, opened = false;
131
+ let citing = false;
119
132
  for (const f of list) {
120
133
  const cited = knockoutCitedUrls(f);
121
134
  if (!cited.length) continue;
122
- if (!opened) {
123
- opened = true;
124
- checked.citing += 1;
125
- try { payload = readFileSync(join(runDir, "research", `${kebab(m.name)}.md`), "utf8"); } catch { payload = null; }
126
- }
135
+ if (!citing) { checked.citing += 1; citing = true; held ??= urlHeldFor(runDir); }
127
136
  for (const url of cited) {
128
137
  checked.urls += 1;
129
- if (records != null && urlInPayload(url, records)) continue; // a filing supplied for this mark
130
- // One refusal for both branches (design's wording, 2026-10-19): the register records supplied for the mark are
131
- // held evidence too, so a refusal never tells the model to drop one of them.
132
- if (payload == null || !urlInPayload(url, payload))
133
- failures.push(`knockout_url_unreceipted:${m.name}: "${url}" does not appear in the mark's own research payload or in the register records supplied for that mark — cite only held evidence`);
138
+ // One refusal for both kinds of held evidence, so it never tells the model to drop a filing it may cite.
139
+ if (!held(url)) failures.push(urlNotHeld(m.name, url));
134
140
  }
135
141
  }
136
142
  }
@@ -145,12 +151,12 @@ export function knockoutReceipts(runDir, marks) {
145
151
  // rating field is a second vocabulary waiting to happen, which is exactly what rules out.
146
152
  //
147
153
  // THE SET IS ONE WORD, and it is one word because ONE is what the doctrine attests. knockout-assess
148
- // SKILL.md exemplifies "Medium (low)" and calibration rule 6 says enforcer profiling "can cap a middle
154
+ // SKILL.md exemplifies "Medium (low)" and calibration rule 4 says enforcer profiling "can cap a middle
149
155
  // band at its '(low)' qualifier". Nothing in the doctrine, and no artifact in this repo, carries any
150
156
  // other value. So the qualifier can SOFTEN a band and never sharpen it — minting "high" or "mid" to make
151
157
  // the set look like a scale would be this build inventing vocabulary in the change that forbids it.
152
158
  //
153
- // ABSENCE, RECORDED. Calibration rule 5 tells the model to use a customer framework's own dispute-type
159
+ // ABSENCE, RECORDED. Calibration rule 3 tells the model to use a customer framework's own dispute-type
154
160
  // notation (an A–E matrix) "exactly", and the mark row has no field for one: the framework manifest
155
161
  // carries band words and order ONLY (framework.mjs: never a mapping table), so there is no vocabulary to
156
162
  // validate such a notation against. It is not admitted here — a notation smuggled into this field would
@@ -231,10 +237,68 @@ export function registerRecordIdsFor(runDir, markName) {
231
237
  const doc = readJson(driverDir(runDir, "register-records.json"));
232
238
  const want = String(markName ?? "").trim().toLowerCase();
233
239
  const entry = (Array.isArray(doc?.marks) ? doc.marks : []).find((e) => String(e?.name ?? "").trim().toLowerCase() === want);
234
- return new Set((Array.isArray(entry?.records) ? entry.records : [])
240
+ return new Set([...(Array.isArray(entry?.records) ? entry.records : []), ...(Array.isArray(entry?.setAsideRecords) ? entry.setAsideRecords : [])]
241
+ .map((r) => String(r?.recordId ?? "").trim()).filter(Boolean));
242
+ }
243
+
244
+ /** Every register recordId this run holds, under any name: what a check may rest a defect on. Empty set when the lane did not run. */
245
+ export function registerRecordIdsHeld(runDir) {
246
+ const doc = readJson(driverDir(runDir, "register-records.json"));
247
+ return new Set((Array.isArray(doc?.marks) ? doc.marks : []).flatMap((e) => [...(Array.isArray(e?.records) ? e.records : []), ...(Array.isArray(e?.setAsideRecords) ? e.setAsideRecords : [])])
235
248
  .map((r) => String(r?.recordId ?? "").trim()).filter(Boolean));
236
249
  }
237
250
 
251
+ const readNotHeld = (mark, id) => `mark "${mark}": registerReads cites "${id}", which is not a record this run holds. The id must be copied from the filings you were handed — the driver joins it against the store and never takes your word for it`;
252
+ const weighedNotHeld = (mark, finding, id) => `mark "${mark}": finding "${finding}" lists weighedFilings "${id}", which is not a record this run holds. The source chip is derived from this list, so an id the driver cannot join would put a Register label on a finding with no register evidence`;
253
+
254
+ /**
255
+ * THE RULE, WHILE THE MODEL CAN STILL ACT ON IT. The stage's validator reads this join after the turn has ended, so a rating that
256
+ * cited something the run does not hold finished the whole chunk, failed, and on its one retry failed the same way. Refusing the
257
+ * call would not do: a refused call is not kept, and accepted chunks on a saved batch, 2026-11-05, took 554 to 662 s of a 900 s
258
+ * attempt, so there is no room to send one again. So the record tool keeps the call and leaves out only what the rule refuses, and
259
+ * names every row it left out. A filing held for this batch may bear on more than one name, so its id and its source are held
260
+ * whichever name found it (design, 2026-11-05). A finding that loses a source keeps its claim, and leaving the reference out does
261
+ * not support it, so each such loss is returned as a source defect, with the claim as it stood. Returns `{mark, notKept,
262
+ * sourceDefects}`. PURE-ish.
263
+ */
264
+ export function heldCitationsOnly(runDir, mark) {
265
+ const held = registerRecordIdsHeld(runDir);
266
+ const notKept = [], sourceDefects = [];
267
+ const urlHeld = urlHeldFor(runDir);
268
+ const lost = (f, kind, cited) => sourceDefects.push({ mark: mark?.name, name: f?.name, owner: f?.owner, kind, cited, was: { net: f?.net ?? null, basis: f?.basis ?? null, evidence: (f?.evidence ?? []).filter((u) => urlHeld(u)), weighed: (f?.weighedFilings ?? []).filter((id) => held.has(String(id ?? "").trim())) } });
269
+ const isHeld = (raw, say) => {
270
+ const id = String(raw ?? "").trim();
271
+ if (!id || held.has(id)) return true;
272
+ notKept.push(say(id));
273
+ return false;
274
+ };
275
+ if (!Array.isArray(mark?.registerReads) && !Array.isArray(mark?.findings)) return { mark, notKept, sourceDefects };
276
+ const out = { ...mark };
277
+ if (Array.isArray(mark.registerReads)) out.registerReads = mark.registerReads.filter((row) => isHeld(row?.recordId, (id) => readNotHeld(mark.name, id)));
278
+ if (Array.isArray(mark.findings)) out.findings = mark.findings.map((f) => {
279
+ const kept = Array.isArray(f?.weighedFilings) ? { ...f, weighedFilings: f.weighedFilings.filter((id) => isHeld(id, (bad) => { lost(f, "weighed", bad); return weighedNotHeld(mark.name, f?.name, bad); })) } : f;
280
+ if (!Array.isArray(f?.evidence)) return kept;
281
+ const evidence = f.evidence.filter((url) => { if (urlHeld(url)) return true; lost(f, "evidence", url); notKept.push(urlNotHeld(mark.name, url)); return false; });
282
+ return evidence.length === f.evidence.length ? kept : { ...kept, evidence };
283
+ });
284
+ return { mark: notKept.length ? out : mark, notKept, sourceDefects };
285
+ }
286
+
287
+ /**
288
+ * What the run's files say of its register, from what ran, never from what is missing. `skipped` only where the run recorded that it
289
+ * has no register component (the file the lane writes when it starts). `held`: a record of questions and filings, an empty one
290
+ * included. `unavailable`: counts were taken and the listing could not run, or its record says why. `unknown`: nothing establishes
291
+ * what ran. An estimate is owed on the first alone.
292
+ */
293
+ export const REGISTER_LANE_FILE = "register-lane.json";
294
+ export function registerLaneState(runDir) {
295
+ if (readJson(driverDir(runDir, REGISTER_LANE_FILE))?.skipped === true) return { state: "skipped" };
296
+ const doc = readJson(driverDir(runDir, "register-records.json"));
297
+ if (doc?.unavailable) return { state: "unavailable", reason: String(doc.unavailable) };
298
+ if (doc) return { state: "held" };
299
+ return { state: existsSync(driverDir(runDir, "register-counts.json")) ? "unavailable" : "unknown", reason: null };
300
+ }
301
+
238
302
  export const KNOCKOUT_RATING_QUALIFIERS = ["low"];
239
303
  export function normalizeKnockoutQualifier(v) {
240
304
  const word = String(v ?? "").trim().replace(/^\(+|\)+$/g, "").trim().toLowerCase();
@@ -274,6 +338,56 @@ const bandIdx = (ladder, word) => ladder.findIndex((l) => l.toLowerCase() === St
274
338
  // ladder, the interactive skill's rule, generalized by position); registerEstimate above the lowest.
275
339
  const materialIdxMax = (ladder) => ladder.length - 3; // inclusive index bound for "material"
276
340
 
341
+ /** The frozen ladder of a run, worst first, or none where the run holds no framework. */
342
+ export const frozenLadder = (runDir) => ladderOf(readJson(driverDir(runDir, "framework.json")));
343
+
344
+ // ── A NAME'S CONCLUSION BY CLASS GROUP ───────────────────────────────────────────────
345
+ //
346
+ // `rating` and `classesDriving` say nothing of the other classes searched, and an answer can differ by
347
+ // group: on a lawyer's eight-name report two names carried two bands, each with its class list. So a mark
348
+ // may send `classGroups`. It is optional and rests on the evidence, not on a framework flag: no framework
349
+ // deck states a rule by class group, so a gate there would have nothing to read.
350
+ //
351
+ // The band column prints these rows as facts in place of the one chip, which is what each check is for: a
352
+ // word off the ladder has no colour, a class in two rows gets two answers, a class in none loses the line
353
+ // that used to name it, and a top row that disagrees with `rating` or `classesDriving` puts two answers on
354
+ // one page. PURE.
355
+ const groupKey = (g) => `${String(g?.band ?? "").trim().toLowerCase()}|${normalizeKnockoutQualifier(g?.ratingQualifier) ?? ""}`;
356
+ /** The groups as a reader meets them: the highest band first, and within a band the one with no qualifier. PURE. */
357
+ const groupsHighestFirst = (groups, ladder) => [...groups].sort((x, y) => bandIdx(ladder, x.band) - bandIdx(ladder, y.band)
358
+ || Number(Boolean(x.ratingQualifier)) - Number(Boolean(y.ratingQualifier)));
359
+ export function classGroupsDefect(mark, ladder = []) {
360
+ const groups = mark?.classGroups;
361
+ if (groups == null) return null;
362
+ const say = (what) => `knockout_class_groups:${mark?.name}: ${what}`;
363
+ if (!Array.isArray(groups) || groups.length < 2 || new Set(groups.map(groupKey)).size < 2)
364
+ return say("classGroups needs two or more rows that differ in band or qualifier. Where one conclusion holds, leave it out.");
365
+ if (new Set(groups.map(groupKey)).size < groups.length) return say("Combine groups with the same band and qualifier.");
366
+ const seen = new Set();
367
+ const searched = Array.isArray(mark?.classesSearched) ? new Set(mark.classesSearched) : new Set();
368
+ for (const g of groups) {
369
+ if (ladder.length && bandIdx(ladder, g?.band) < 0) return say(`band ${g?.band} is not in the framework's ladder.`);
370
+ if (g?.ratingQualifier != null && !normalizeKnockoutQualifier(g.ratingQualifier))
371
+ return say(`ratingQualifier ${g.ratingQualifier} is not one of ${KNOCKOUT_RATING_QUALIFIERS.join(" / ")}.`);
372
+ if (!Array.isArray(g?.classes) || !g.classes.length || !g.classes.every((n) => Number.isInteger(n) && n >= 1 && n <= 45))
373
+ return say("each group's classes must be Nice-class integers (1–45).");
374
+ for (const n of g.classes) {
375
+ if (seen.has(n)) return say(`class ${n} sits in two groups.`);
376
+ if (searched.size && !searched.has(n)) return say(`class ${n} is in a group but was not searched.`);
377
+ seen.add(n);
378
+ }
379
+ }
380
+ for (const n of searched) if (!seen.has(n)) return say(`class ${n} was searched and is in no group.`);
381
+ if (ladder.length) {
382
+ const top = groupsHighestFirst(groups, ladder)[0];
383
+ if (groupKey(top) !== groupKey({ band: mark?.rating, ratingQualifier: mark?.ratingQualifier }))
384
+ return say(`rating is ${mark?.rating}${mark?.ratingQualifier ? ` (${mark.ratingQualifier})` : ""}, but the highest group is ${top.band}${top.ratingQualifier ? ` (${top.ratingQualifier})` : ""}. They must agree.`);
385
+ const driving = Array.isArray(mark?.classesDriving) ? mark.classesDriving : [];
386
+ if (driving.length !== top.classes.length || !top.classes.every((n) => driving.includes(n))) return say("classesDriving must contain the highest group's classes.");
387
+ }
388
+ return null;
389
+ }
390
+
277
391
  // ── The web search's two lists, checked as the search program will read them ─────────────────────────
278
392
  //
279
393
  // The program searches every place verbatim: the literal `web` is the whole web, and any other entry is
@@ -338,6 +452,20 @@ export function spellingsDefect(name, spellings) {
338
452
  * the bound refused ("a character or a place in a game"), so it would have fired on a frame doing as it
339
453
  * was asked. A long answer makes the cells' queries longer, which makes the screen weaker, not wrong.
340
454
  */
455
+ // ── ONE ITEM'S WRITTEN FORMS ───────────────────────────────────────────────────────────────────────────────────────
456
+ //
457
+ // `alternatives` says where the request gives one item more than one way: each form is asked of the register on its own and
458
+ // stays tied to the row. Which forms the request gives is the frame's reading of the request, so only the shape is checked
459
+ // here. Punctuation cannot tell a list from a name that holds a slash, and a word found somewhere in the request does not
460
+ // show the client supplied that form. Absent or empty: one form.
461
+
462
+ /** Why a row's `alternatives` cannot stand as sent, or null. Shape only. PURE. */
463
+ export function alternativesDefect(name, alternatives) {
464
+ if (alternatives == null) return null;
465
+ return !Array.isArray(alternatives) || alternatives.some((a) => typeof a !== "string" || !a.trim())
466
+ ? `mark "${name}": alternatives is a list of the written forms of this one item, or leave it out` : null;
467
+ }
468
+
341
469
  export function useKindDefect(name, useKind) {
342
470
  const refusal = `mark "${name}": useKind is required: one to three words, the kind of use this name is searched for (task 2c)`;
343
471
  return typeof useKind === "string" && useKind.trim() ? null : refusal;
@@ -365,7 +493,7 @@ export const validators = {
365
493
  if (batchPlacesRefused) return { ok: false, reason: batchPlacesRefused };
366
494
  }
367
495
  if (!Array.isArray(p.marks) || !p.marks.length) return { ok: false, reason: "marks[] is required" };
368
- const MARK_KEYS = ["ref", "name", "classes", "beltAndBraces", "classesPlain", "contextFraming", "useKind", "places", "spellings", "priorKnowledge", "priority"];
496
+ const MARK_KEYS = ["ref", "name", "classes", "beltAndBraces", "classesPlain", "contextFraming", "useKind", "places", "spellings", "alternatives", "priorKnowledge", "priority"];
369
497
  for (const m of p.marks) {
370
498
  for (const k of Object.keys(m)) if (!MARK_KEYS.includes(k)) return { ok: false, reason: `plan mark key "${k}" is not in the closed contract` };
371
499
  if (typeof m.name !== "string" || !m.name.trim()) return { ok: false, reason: "every plan mark needs a verbatim name" };
@@ -375,6 +503,8 @@ export const validators = {
375
503
  if (typeof m.contextFraming !== "string" || !m.contextFraming.trim()) return { ok: false, reason: `mark "${m.name}": contextFraming is required (the rating hangs off it)` };
376
504
  const useKindRefused = useKindDefect(m.name, m.useKind);
377
505
  if (useKindRefused) return { ok: false, reason: useKindRefused };
506
+ const alternativesRefused = alternativesDefect(m.name, m.alternatives);
507
+ if (alternativesRefused) return { ok: false, reason: alternativesRefused };
378
508
  // WHERE THIS NAME IS SEARCHED (ruling 570). Required per name on a fresh plan; a plan frozen before
379
509
  // the field existed carries the batch's list instead and `knockoutGridSpec` falls back to it, so an
380
510
  // archived plan still runs — the same shape `useKind` takes.
@@ -532,6 +662,8 @@ export const validators = {
532
662
  const idx = ladder.length ? bandIdx(ladder, rating) : -1;
533
663
  if (ladder.length && idx <= materialIdxMax(ladder) && !(Array.isArray(m.classesDriving) && m.classesDriving.length))
534
664
  return { ok: false, reason: `mark "${m.name}": classesDriving is mandatory at "${rating}" (class-specific ratings — calibration rule 1)` };
665
+ const groupsDefect = classGroupsDefect(m, ladder);
666
+ if (groupsDefect) return { ok: false, reason: groupsDefect };
535
667
  // ── CONDITIONAL SINCE RF-15 v3, AND IT HAD TO MOVE WITH THE DOCTRINE ──────
536
668
  //
537
669
  // This demanded `registerEstimate` on every mark above the lowest band, unconditionally, citing
@@ -545,11 +677,12 @@ export const validators = {
545
677
  // beside the filings it is guessing about.
546
678
  //
547
679
  // THE DRIVER'S READ, NOT THE SEAT'S. Whether the register ran is a fact about the run; a seat that
548
- // could assert it could waive its own requirement by claiming a lane it cannot see. `dirname(file)`
549
- // is the run dir — `assessChunk` writes `knockout-assess-<n>.json` into it (stages-knockout.mjs).
550
- const registerRan = existsSync(driverDir(dirname(file), "register-records.json"));
680
+ // could assert it could waive its own requirement by claiming a lane it cannot see.
681
+ // SKIPPED, NOT EMPTY. An empty carried list, a verified zero, a failed question and a listing that could not run are all
682
+ // something other than a skip. Only a run that recorded the skip owes an estimate.
683
+ const registerRan = registerLaneState(runDir).state !== "skipped";
551
684
  if (!registerRan && ladder.length && idx < ladder.length - 1 && !(typeof m.registerEstimate === "string" && m.registerEstimate.trim()))
552
- return { ok: false, reason: `mark "${m.name}": registerEstimate is required above the lowest band on a run with no fetched register records (RF-15 v3 — estimation stands where the register did not run)` };
685
+ return { ok: false, reason: `mark "${m.name}": registerEstimate is required above the lowest band on a run that skipped the register (RF-15)` };
553
686
  // ── THE PER-MARK OPENING ASSESSMENT IS OWED ON A MULTI-MARK BATCH ───────
554
687
  //
555
688
  // ONLY on a multi-mark batch, and that is the whole scope of it. A single-mark run's document
@@ -585,14 +718,14 @@ export const validators = {
585
718
  if (m.registerReads !== undefined && m.registerReads !== null) {
586
719
  if (!Array.isArray(m.registerReads))
587
720
  return { ok: false, reason: `mark "${m.name}": registerReads must be an ARRAY of { recordId, read, band? } rows, or omitted entirely` };
588
- const held = registerRecordIdsFor(runDir, m.name);
721
+ const held = registerRecordIdsHeld(runDir);
589
722
  for (const row of m.registerReads) {
590
723
  const id = String(row?.recordId ?? "").trim();
591
724
  const read = String(row?.read ?? "").trim();
592
725
  if (!id) return { ok: false, reason: `mark "${m.name}": a registerReads row has no recordId — cite the record's own id, verbatim from the filings you were given` };
593
726
  if (!read) return { ok: false, reason: `mark "${m.name}": registerReads row "${id}" has an empty read. Omit the row rather than sending an empty one: a filing with no read keeps the card's neutral line, which is true` };
594
727
  if (!held.has(id))
595
- return { ok: false, reason: `mark "${m.name}": registerReads cites "${id}", which is not a record this run holds for that mark. The id must be copied from the filings you were handed — the driver joins it against the store and never takes your word for it` };
728
+ return { ok: false, reason: readNotHeld(m.name, id) };
596
729
  // The band is OPTIONAL and, when present, is the same closed vocabulary the mark's own rating
597
730
  // uses — the card prints it as this filing's rating, so a word outside the frozen ladder would
598
731
  // put a chip on the page in a dialect the framework does not define. Absence stays free: a read
@@ -631,11 +764,11 @@ export const validators = {
631
764
  if (f?.weighedFilings === undefined || f?.weighedFilings === null) continue;
632
765
  if (!Array.isArray(f.weighedFilings))
633
766
  return { ok: false, reason: `mark "${m.name}": findings[].weighedFilings must be an ARRAY of register record ids, or omitted` };
634
- const held = registerRecordIdsFor(runDir, m.name);
767
+ const held = registerRecordIdsHeld(runDir);
635
768
  for (const raw of f.weighedFilings) {
636
769
  const id = String(raw ?? "").trim();
637
770
  if (!id || !held.has(id))
638
- return { ok: false, reason: `mark "${m.name}": finding "${f?.name}" lists weighedFilings "${id}", which is not a record this run holds for that mark. The source chip is derived from this list, so an id the driver cannot join would put a Register label on a finding with no register evidence` };
771
+ return { ok: false, reason: weighedNotHeld(m.name, f?.name, id) };
639
772
  }
640
773
  }
641
774
  if (m.degraded && !(Array.isArray(m.purpleNotes) && m.purpleNotes.some((n) => /manual verification/i.test(n))))
@@ -650,7 +783,7 @@ export const validators = {
650
783
  // for exactly the same invention.
651
784
  const claim = [prose, c.chunkSummary].filter(Boolean).join("\n").match(REGISTER_CLAIM_RE);
652
785
  if (claim)
653
- return { ok: false, reason: `knockout_register_claim:${m.name}: "${claim[0].trim()}" — this turn cannot see the register lane and must not describe it. The report states register coverage in code, from the run's own count sidecar; a summary that says the registers were not run, above a table of counts that were, is the contradiction this rule closes. Delete the clause` };
786
+ return { ok: false, reason: `knockout_register_claim:${m.name}: "${claim[0].trim()}" — weigh the filings you hold and do not describe the search. The report states register coverage in code, from the run's own count sidecar; a summary that says the registers were not run, above a table of counts that were, is the contradiction this rule closes. Delete the clause` };
654
787
  const toneOrFigure = toneOrFigureRefusal(m, prose);
655
788
  if (toneOrFigure) return { ok: false, reason: toneOrFigure };
656
789
  // PR-5 — a "tool was blocked / lacked permission" explanation for missing coverage is a false
@@ -820,7 +953,7 @@ export function validateMergedFindings(runDir, merged, plan) {
820
953
  // reader meets in the executive summary. The renderer owns register coverage; nothing else states it.
821
954
  {
822
955
  const claim = mergedProse.match(REGISTER_CLAIM_RE);
823
- if (claim) failures.push(`knockout_register_claim: "${claim[0].trim()}" — the assessing turn cannot see the register lane and must not describe it; the report states coverage in code from the run's own count sidecar`);
956
+ if (claim) failures.push(`knockout_register_claim: "${claim[0].trim()}" — weigh the filings and do not describe the search; the report states coverage in code from the run's own count sidecar`);
824
957
  }
825
958
  // ── — the typed findings and their receipts, ON THE MERGED ARTIFACT ────────────────────────────
826
959
  // This function is the ONLY gate pipeline-knockout.mjs runs on the composed output, and until now it
@@ -864,6 +997,9 @@ export function validateMergedFindings(runDir, merged, plan) {
864
997
  }
865
998
  const above = markRatedAboveItsCards(manifest, m);
866
999
  if (above) failures.push(above);
1000
+ const groupsDefect = classGroupsDefect(m, ladderOf(manifest));
1001
+ if (groupsDefect) failures.push(groupsDefect);
1002
+ else if (Array.isArray(m.classGroups)) m.classGroups = groupsHighestFirst(m.classGroups, ladderOf(manifest));
867
1003
  }
868
1004
  const receipts = knockoutReceipts(runDir, marks);
869
1005
  failures.push(...receipts.failures);
@@ -913,7 +1049,7 @@ export function markRatedAboveItsCards(framework, m) {
913
1049
  // NO CARDS, NOTHING TO BE ABOVE — and the code stops here deliberately.
914
1050
  //
915
1051
  // The doctrine says a name with nothing found against it takes the bottom band, and that belongs in
916
- // the reasoning where it is written (calibration rule 8). Enforcing it HERE would be a second rule in
1052
+ // the reasoning where it is written (calibration rule 6). Enforcing it HERE would be a second rule in
917
1053
  // code: a floor that forces a band down, which is what the ruling forbids in terms — "do not replace
918
1054
  // the removed rule with another floor, cap or word list. The two rulings are the whole requirement."
919
1055
  //
package/driver/verify.mjs CHANGED
@@ -952,6 +952,11 @@ export function parsePositions(line) {
952
952
  // names none, the whole document is read as before. The fallback cannot reopen this defect, because it
953
953
  // only applies to documents that have no section structure to get wrong.
954
954
  export const CORRECTIONS_SECTION_RE = /\bcorrections?\b/i;
955
+ // THE TOOL'S OWN `## Flags` HEADING COMES FIRST. A recheck's rewrite keeps it and adds sections around it: "## Re-check of prior
956
+ // flags" names no corrections, so each answered flag read as an open one, and "## Corrections verified" took the allowlist from
957
+ // the real flags. Measured on 342 saved reviews, 2026-11-05: 21 change; 169 rows go, none typed, each answering an earlier flag or
958
+ // under a heading such as "surfaced not flagged"; 26 come back, all typed. A review with no such heading reads as it did.
959
+ const FLAGS_SECTION_RE = /^#{1,6}\s+flags\s*:?\s*$/i;
955
960
 
956
961
  // Kept, and now only reachable on the headless path below. It is no longer the mechanism — it is the
957
962
  // last line of defence for a document that names no corrections section at all, where the plan audit is
@@ -1008,13 +1013,9 @@ export const opensWithKind = (content) => /^\[kind:/i.test(String(content ?? "")
1008
1013
  * PURE.
1009
1014
  */
1010
1015
  export function correctionsSection(reviewMd) {
1011
- const rest = String(reviewMd ?? "").split("\n").slice(1);
1012
- for (const raw of rest) {
1013
- const ln = raw.trim();
1014
- if (!SECTION_HEADING_RE.test(ln)) continue;
1015
- if (CORRECTIONS_SECTION_RE.test(ln)) return { named: true, heading: ln.replace(/^#+\s*/, "").trim() };
1016
- }
1017
- return { named: false, heading: null };
1016
+ const rest = String(reviewMd ?? "").split("\n").slice(1).map((l) => l.trim());
1017
+ const found = rest.find((ln) => FLAGS_SECTION_RE.test(ln)) ?? rest.find((ln) => SECTION_HEADING_RE.test(ln) && CORRECTIONS_SECTION_RE.test(ln));
1018
+ return found ? { named: true, heading: found.replace(/^#+\s*/, "").trim() } : { named: false, heading: null };
1018
1019
  }
1019
1020
 
1020
1021
  export function parseCorrections(reviewMd) {
@@ -1023,7 +1024,7 @@ export function parseCorrections(reviewMd) {
1023
1024
 
1024
1025
  const { named, heading } = correctionsSection(reviewMd);
1025
1026
  const isHeading = (ln) => SECTION_HEADING_RE.test(ln);
1026
- void heading;
1027
+ const opensTheSection = /^flags\s*:?\s*$/i.test(String(heading ?? "")) ? (ln) => FLAGS_SECTION_RE.test(ln) : (ln) => CORRECTIONS_SECTION_RE.test(ln);
1027
1028
 
1028
1029
  const candidates = [];
1029
1030
  let excluded = !named ? false : true; // allowlist mode starts CLOSED — nothing counts until the section opens
@@ -1032,7 +1033,7 @@ export function parseCorrections(reviewMd) {
1032
1033
  const ln = raw.trim();
1033
1034
  if (isHeading(ln)) {
1034
1035
  excluded = named
1035
- ? !CORRECTIONS_SECTION_RE.test(ln) // allowlist: only the corrections section is read
1036
+ ? !opensTheSection(ln) // allowlist: only the corrections section is read
1036
1037
  : NOT_A_CORRECTIONS_SECTION_RE.test(ln); // headless: the old walk, minus the plan audit
1037
1038
  sawEnumeratedFlag = false; // the body rule below is per section
1038
1039
  }
@@ -1,5 +1,13 @@
1
1
  # trademark-artifacts-mcp
2
2
 
3
+ ## 0.5.1-beta.1
4
+
5
+ No changes in this release.
6
+
7
+ ## 0.5.1-beta.0
8
+
9
+ No changes in this release.
10
+
3
11
  ## 0.5.0
4
12
 
5
13
  No changes in this release.
@@ -24,6 +24,10 @@ It reads run directories off your disk. So:
24
24
  - **With no install, it shows you the demo.** `npx clearotron mcp` starts this server from the npm package.
25
25
  On a machine with no install it answers from the four sample runs `npx clearotron demo` replays, and every
26
26
  row says it is the demo. On a machine with an install it reads that install's runs.
27
+ - **A demo starts nothing.** Connected to a demo, an assistant can read and explain its sample reports, and
28
+ the tools that start work are not offered. The line `clearotron demo` prints registers as
29
+ `trademark-artifacts-demo`, beside any connection to a real install, and it stops working when that demo's
30
+ folder is gone.
27
31
  - **Nothing here spends money on its own,** with two exceptions that are gated and named: `start_run`
28
32
  enqueues a real clearance, and `what_if_run` re-runs one pipeline stage. Both are refused by default on
29
33
  a sensible allowlist — see "Hold two tools back" below.
@@ -8,3 +8,9 @@
8
8
  // variable because nothing outside this process sets it or reads it, and every environment variable the
9
9
  // product reads is a setting an operator is told about.
10
10
  export const demoMode = { on: false };
11
+
12
+ /**
13
+ * Whether this process serves a demo: `clearotron mcp` said so, or it was started for one, by `clearotron demo` or by
14
+ * the connect line that demo printed, which is what CLEAROTRON_DEMO=1 means wherever it is read.
15
+ */
16
+ export const demoServing = (env = process.env) => demoMode.on || env.CLEAROTRON_DEMO === "1";
@@ -0,0 +1,38 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-only
2
+ // Copyright 2026 Cordillera Sàrl. Additional terms under section 7 of the AGPL-3.0 apply — see ADDITIONAL-TERMS.md
3
+ //
4
+ // demo-texts.mjs — what a demo's assistant is told, where a real install's words would send it to a tool the demo withholds.
5
+ //
6
+ // A demo withholds `start_run` and the what-if tools (shared/scope.mjs, DEMO_WITHHELD_TOOLS), and three texts still sent the
7
+ // assistant to `start_run`: `plan_run`'s description, as the operator's assistant and as a signed-in client's assistant read it,
8
+ // and `describe_options`' closing note. The guidance pack describes starting searches and what-ifs too. In a demo each text takes
9
+ // the owner's replacement (2026-11-06); a real install keeps its words. Each replacement names the exact words it replaces, so a
10
+ // text that has changed underneath it is refused by the test rather than passed through unchanged.
11
+
12
+ /** `[the words a real install says, the words a demo says instead]`, per text. */
13
+ export const DEMO_SWAPS = Object.freeze({
14
+ "plan_run:ops": [
15
+ ["Takes the SAME arguments as start_run. Use this BEFORE start_run whenever the requester has not already confirmed the specifics: it reports", "It reports"],
16
+ ["Show the result to the requester; then call start_run with the SAME arguments to actually run it.", "Show the result to the requester. A demo cannot start it."],
17
+ ],
18
+ "plan_run:client": [
19
+ ["Takes the SAME arguments as start_run and reports", "Reports"],
20
+ ["Show the result to them, then call start_run with the SAME arguments.", "Show the result to them. A demo cannot start it."],
21
+ ],
22
+ "describe_options:note": [
23
+ ["Show that to the requester, and only then call start_run with the SAME arguments.", "Show that to the requester. A demo cannot start it."],
24
+ ],
25
+ });
26
+
27
+ /** The line a demo's guidance opens with, in the owner's words (2026-11-06). */
28
+ export const DEMO_GUIDANCE_LINE = "This is a demo: it answers from finished reports, and cannot start a search or a what-if.";
29
+
30
+ /** `text` with the demo's replacements for `key` made; a text the table does not name is returned as it is. PURE. */
31
+ export function demoText(key, text) {
32
+ let out = String(text ?? "");
33
+ for (const [from, to] of DEMO_SWAPS[key] ?? []) out = out.split(from).join(to);
34
+ return out;
35
+ }
36
+
37
+ /** The guidance a demo's assistant is given: the demo line, then the pack. None stays none. PURE. */
38
+ export const demoGuidance = (pack) => (pack ? `${DEMO_GUIDANCE_LINE}\n\n${pack}` : pack);
@@ -11,6 +11,7 @@ import { isInitializeRequest } from "@modelcontextprotocol/sdk/types.js";
11
11
  import { AuthError } from "./cf-access.mjs";
12
12
  import { appendAudit } from "./audit.mjs";
13
13
  import { resolveScope, isFirmDomain, verifyToken, addressesInGrants } from "./scope.mjs";
14
+ import { BOOT_PROBE_HEADER } from "../../shared/trigger-lane.mjs"; // the portal's boot probe names itself with it
14
15
 
15
16
  const hdr = (v) => (Array.isArray(v) ? v[0] : v);
16
17
 
@@ -220,7 +221,12 @@ export function makeHttpHandler({ verify, limiter, opsLimiter = null, sessions,
220
221
  // principal rather than an anonymous transport.
221
222
  const tok = readInnerToken(url, req.headers, { allowAuthorization: true });
222
223
  if (!tok) {
223
- log("auth reject 401: no key presented on the token-only door");
224
+ // THE PORTAL'S BOOT PROBE IS NOT A REJECTION. It asks, without a key, what this door wants, on
225
+ // every start, and this line read as an error each time. Its answer is unchanged and still
226
+ // audited; only a keyless GET that names itself as the probe goes unlogged here, because the
227
+ // portal logs what it learned. Any other keyless request is still logged as a reject.
228
+ if (!(req.method === "GET" && hdr(req.headers[BOOT_PROBE_HEADER])))
229
+ log("auth reject 401: no key presented on the token-only door");
224
230
  return refuse(res, 401, { error: "this address needs an access key — put it in your assistant's API-key field, or add ?token=<key> to the URL" });
225
231
  }
226
232
  let t;
@@ -362,9 +362,10 @@ export function knockoutCoverage(run) {
362
362
  * product, including the word "verdict".
363
363
  *
364
364
  * `knockout-assess` is chunked (`knockout-assess#N`), so a caller may name the bare stage or one chunk. The
365
- * reviewing pass that follows it is a stage of its own, and its rewrites reach the record a reader receives.
365
+ * reviewing pass that follows it is a stage of its own, and its rewrites reach the record a reader receives. A material
366
+ * defect it names goes back through `knockout-correct#N`, and `knockout-review#1` reads the corrected record.
366
367
  */
367
- export const KNOCKOUT_STAGES = ["knockout-frame", "knockout-sweep", "knockout-register", "knockout-assess", "knockout-review"];
368
+ export const KNOCKOUT_STAGES = ["knockout-frame", "knockout-sweep", "knockout-register", "knockout-register-read", "knockout-assess", "knockout-review", "knockout-correct"];
368
369
 
369
370
  export function knockoutStageFor(target) {
370
371
  const t = String(target ?? "").trim();
@@ -34,6 +34,8 @@
34
34
  // It is a DESCRIPTION and never an order: plan_run is still the free preview of a specific request, and
35
35
  // start_run is still the only thing that spends.
36
36
 
37
+ import { demoServing } from "../demo-mode.mjs";
38
+ import { demoText } from "./demo-texts.mjs"; // — a demo's note names no tool it withholds
37
39
  import { ORDERABLE_PRODUCTS, PRODUCT_POLICIES, productAvailability, gateCause, UNAVAILABLE_NOTE, loadRecipes } from "../../driver/search-policy.mjs";
38
40
  import { productRow } from "../../driver/product-rows.mjs";
39
41
  import { PRODUCTS, productName } from "../../driver/products.mjs";
@@ -351,7 +353,7 @@ export function describeOptions(args = {}, { scope, now = Date.now() } = {}) {
351
353
  const territories = registerTerritoriesFor(snapshot);
352
354
 
353
355
  return {
354
- _note: _NOTE,
356
+ _note: demoServing() ? demoText("describe_options:note", _NOTE) : _NOTE,
355
357
  products: products(built, registerCanCountFor(snapshot), territories),
356
358
  // What this deployment's register can actually search, in the composer's own display names. Omitted
357
359
  // — not nulled — when the snapshot does not say, and `null` when the register declares no
@@ -35,6 +35,7 @@ import { gateResolvedRequest } from "../../driver/door-gates.mjs"; // the reso
35
35
  import { quoteForJob } from "../../driver/run-quote.mjs";
36
36
  import { accountUsage, DEFAULT_CLIENT_DAILY_RUNS } from "../../driver/usage-ledger.mjs";
37
37
  import { config } from "./driver.mjs";
38
+ import { demoServing } from "../demo-mode.mjs"; // — a demo's preview names no tool it withholds
38
39
  import { buildJob, resolveScopedProfileKey } from "./ops.mjs";
39
40
  import { BRAND } from "../../shared/brand.mjs"; // — the operator name in the allowance note, from the tenant seam
40
41
  import { bindingLayersFor } from "../../driver/binding-layers.mjs"; // — what BINDS a territory; never what a provider returns
@@ -364,7 +365,11 @@ export function planRun(args = {}, { scope, now = Date.now() } = {}) {
364
365
  wouldRun: blocking.length === 0,
365
366
  // Named plainly: this is a description, and confirming is a separate act.
366
367
  _note: blocking.length === 0
367
- ? "NOTHING HAS BEEN STARTED and nothing has been charged. This is what would run. Show it to the requester, and call start_run with the SAME arguments only once they have confirmed it."
368
+ // A DEMO HAS NO TOOL THAT STARTS A SEARCH, so its preview does not tell the assistant to call one (the owner's
369
+ // words, 2026-11-06). A real install keeps the sentence that hands the confirmed request to start_run.
370
+ ? (demoServing()
371
+ ? "NOTHING HAS BEEN STARTED and nothing has been charged. This is what would run on a real install. A demo cannot start it."
372
+ : "NOTHING HAS BEEN STARTED and nothing has been charged. This is what would run. Show it to the requester, and call start_run with the SAME arguments only once they have confirmed it.")
368
373
  : "NOTHING HAS BEEN STARTED. This request cannot run as stated — the blockers below are questions to put back to the requester, not failures to retry.",
369
374
  blockers: blocking,
370
375
  warnings: [...(v.warnings ?? []), ...gates.warnings, ...(quotaWarning ? [quotaWarning] : []),