clearotron 0.6.0 → 0.7.0-beta.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/INSTALL.md +7 -4
- package/QUICKSTART.md +1 -0
- package/README.md +5 -2
- package/THIRD-PARTY-NOTICES.md +1 -1
- package/bin/clearotron.mjs +4 -2
- package/bin/onboard.mjs +158 -29
- package/build-info.json +2 -2
- package/docs/CLIENT-MCP.md +3 -1
- package/docs/DELIVERY.md +6 -3
- package/docs/architecture/02-architecture.md +1 -1
- package/docs/branding.md +4 -4
- package/docs/report-data/clearance-1.schema.json +320 -0
- package/docs/report-data/knockout-1.schema.json +268 -0
- package/driver/CHANGELOG.md +39 -0
- package/driver/connotation-search.mjs +1 -1
- package/driver/contract-e3-backlog.mjs +1 -1
- package/driver/coverage-ledger.mjs +18 -2
- package/driver/deferral-row.mjs +1 -1
- package/driver/degraded-parts.mjs +1 -0
- package/driver/driver.config.mjs +4 -3
- package/driver/effective-scope.mjs +3 -1
- package/driver/engagement-receipt.mjs +3 -3
- package/driver/engine/anthropic-agent.mjs +15 -1
- package/driver/engine/common.mjs +7 -0
- package/driver/engine/mcp/band-server.mjs +7 -16
- package/driver/engine/mcp/codex-config.mjs +3 -0
- package/driver/engine/mcp/recording-server.mjs +45 -34
- package/driver/engine/openai-agent.mjs +74 -7
- package/driver/gateway.mjs +67 -10
- package/driver/jx.mjs +13 -5
- package/driver/manuals-seen.mjs +146 -0
- package/driver/mark-logos.mjs +144 -0
- package/driver/methodology-witness.mjs +2 -1
- package/driver/owner-use-check.mjs +3 -3
- package/driver/package.json +1 -1
- package/driver/pipeline-knockout.mjs +4 -0
- package/driver/pipeline.mjs +92 -7
- package/driver/portal-local-auth.mjs +6 -2
- package/driver/portal-report.mjs +43 -12
- package/driver/portal-routes/me.mjs +4 -1
- package/driver/portal-runs.mjs +6 -9
- package/driver/profiles.mjs +4 -4
- package/driver/publish/README.md +9 -7
- package/driver/publish/email-conditions.mjs +2 -2
- package/driver/publish/evidence-words.mjs +21 -0
- package/driver/publish/index.mjs +104 -90
- package/driver/publish/knockout.mjs +75 -49
- package/driver/publish/office-record-links.mjs +11 -9
- package/driver/publish/page-shell.mjs +98 -0
- package/driver/publish/publish-inputs.mjs +4 -0
- package/driver/publish/regions.mjs +24 -3
- package/driver/publish/register-record.mjs +150 -0
- package/driver/publish/render-knockout.mjs +195 -642
- package/driver/publish/render.mjs +270 -363
- package/driver/publish/report-data.mjs +225 -12
- package/driver/publish/strings.mjs +662 -0
- package/driver/publish/templates/knockout.css +200 -0
- package/driver/publish/templates/report.css +72 -52
- package/driver/publish/xlsx.mjs +148 -125
- package/driver/record-goods.mjs +42 -0
- package/driver/reference-score.mjs +4 -1
- package/driver/register-reach.mjs +39 -0
- package/driver/registry-fidelity.mjs +3 -8
- package/driver/repair-composers.mjs +6 -2
- package/driver/repair-targets.mjs +4 -1
- package/driver/run-delivered.mjs +6 -1
- package/driver/runner.mjs +73 -29
- package/driver/scope-facts.mjs +27 -6
- package/driver/search-policy.mjs +9 -4
- package/driver/stages.mjs +3 -3
- package/driver/steps/overview-and-cards.mjs +50 -14
- package/driver/steps/verdict-gate.mjs +33 -13
- package/driver/suite-census.json +368 -68
- package/driver/terminal-clamp.mjs +6 -1
- package/mcp-server/CHANGELOG.md +4 -0
- package/mcp-server/lib/audit-view.mjs +5 -2
- package/mcp-server/lib/brief.mjs +2 -1
- package/mcp-server/lib/evidence.mjs +31 -4
- package/mcp-server/lib/knockout.mjs +1 -1
- package/mcp-server/lib/scrub.mjs +1 -1
- package/mcp-server/package.json +1 -1
- package/mcp-server/server.mjs +5 -3
- package/package.json +4 -1
- package/portal-ui/dist/assets/{index-CYaO2ygd.js → index-CtkllKJ2.js} +225 -77
- package/portal-ui/dist/assets/{index-izLa9apq.css → index-CxAkJXIT.css} +25 -5
- package/portal-ui/dist/index.html +2 -2
- package/portal-ui/package.json +3 -3
- package/providers/_shared/ledger.mjs +30 -2
- package/providers/_shared/record-uri.mjs +15 -0
- package/providers/clarivate/src/adapter.js +11 -0
- package/providers/clarivate/src/core.js +17 -1
- package/providers/oauth-mcp-bridge/CHANGELOG.md +4 -0
- package/providers/oauth-mcp-bridge/package.json +1 -1
- package/scripts/README.md +147 -3
- package/scripts/e2e-first-time.mjs +3 -3
- package/scripts/freeze-example-run.mjs +3 -3
- package/scripts/mint-search-level-tags.mjs +61 -0
- package/scripts/mint-source-pin-census.mjs +89 -0
- package/scripts/release-note-required.mjs +65 -6
- package/scripts/test-durations-reporter.mjs +25 -0
- package/scripts/test-full.mjs +72 -18
- package/scripts/test-run.mjs +18 -1
- package/shared/brand.mjs +85 -5
- package/shared/inline-markdown.mjs +53 -0
- package/shared/portal-tokens.mjs +2 -1
- package/shared/register-selection.mjs +8 -3
- package/shared/search-level-tags.json +25 -0
- package/shared/tools/derive-band-pairs.mjs +10 -0
- package/driver/own-rights.mjs +0 -83
- package/driver/use-check.mjs +0 -85
|
@@ -101,6 +101,23 @@
|
|
|
101
101
|
// A deletion that gives no reason still refuses, and names the deleting commit as where the reason goes.
|
|
102
102
|
// The move a pre-release makes — `.changeset/<name>.md` deleted and `.changeset/pre/<name>.md` added in
|
|
103
103
|
// one commit — is not a withdrawal: the note still reaches a reader, and a version commit is that shape.
|
|
104
|
+
//
|
|
105
|
+
// ── A NOTE A RELEASE ALREADY PUBLISHED IS AN ANSWER ───────────────────────────────────────────────────
|
|
106
|
+
//
|
|
107
|
+
// A line branched from the previous line, not from main, carries that line's commits one by one across
|
|
108
|
+
// its stable release. Main holds them only as squashes, so none is reached by ancestry and every one is
|
|
109
|
+
// read again. Before the stable, each note a beta had consumed sat under `.changeset/pre/` at the head and
|
|
110
|
+
// answered by its name. The stable publishes them all and deletes them, the merge back carries the
|
|
111
|
+
// deletion, and the last deletion in the range, a commit removing copies an earlier merge had revived,
|
|
112
|
+
// read as a withdrawal that gave no reason. Measured on the 0.6.1 line, 2026-11-18: 35 commits whose notes
|
|
113
|
+
// shipped in 0.6.0 were charged as owing one, and the only fix offered was rewriting pushed history.
|
|
114
|
+
//
|
|
115
|
+
// So a note a VERSION COMMIT on main's own line deleted, at either path, has been published, and it
|
|
116
|
+
// answers for the commits that wrote or named it. The version commit is recognised as the placement check
|
|
117
|
+
// recognises it (`release-duplicate-notes.mjs`), by the pipeline's own author and subject. Not where that
|
|
118
|
+
// release is already in the commit's own history: a note written after the release merged back is a new
|
|
119
|
+
// note sharing a name, and it answers as any other note does. Every commit excused this way is printed
|
|
120
|
+
// with the release that published its note.
|
|
104
121
|
// ── A LATER COMMIT MAY ANSWER A BARE `none` FOR ONE NAMED COMMIT ───────────────────────────────────────
|
|
105
122
|
//
|
|
106
123
|
// A commit carried `Release-note: none` with no reason and was merged into an integration branch before
|
|
@@ -145,6 +162,7 @@ import { readFileSync } from "node:fs";
|
|
|
145
162
|
import { join, dirname } from "node:path";
|
|
146
163
|
import { fileURLToPath } from "node:url";
|
|
147
164
|
import { isEntrypoint } from "../shared/is-entrypoint.mjs";
|
|
165
|
+
import { cutCommitSubject, isVersionCommit } from "./release-duplicate-notes.mjs";
|
|
148
166
|
|
|
149
167
|
const ROOT = join(dirname(fileURLToPath(import.meta.url)), "..");
|
|
150
168
|
|
|
@@ -275,15 +293,18 @@ const shipped = (paths, files) => paths.filter((p) => !NEVER_A_NOTE.some((re) =>
|
|
|
275
293
|
* @param {string[]} o.files the package's own `files` list
|
|
276
294
|
* @param {string[]|null} [o.atHead] every path the head carries under `.changeset/`, when the caller read it
|
|
277
295
|
* @param {((a:string, b:string) => boolean)|null} [o.isAncestor] git ancestry for `Release-note-for:` answers; range order without it
|
|
296
|
+
* @param {Map<string, {sha:string, subject:string}>|null} [o.released] note name → the version commit on main's
|
|
297
|
+
* line that published it, when the caller read it
|
|
278
298
|
* @returns {{visible:string[], notes:string[], declined:Array<{sha:string, subject:string, reason:string}>,
|
|
279
299
|
* withdrawals:Array<{sha:string, subject:string, note:string, by:string, reason:string}>,
|
|
300
|
+
* published:Array<{sha:string, subject:string, note:string, by:string, release:string}>,
|
|
280
301
|
* answered:Array<{sha:string, subject:string, by:string, reason:string}>,
|
|
281
302
|
* refusedAnswers:Array<{sha:string, subject:string, text:string, problem:string}>,
|
|
282
303
|
* unneeded:Array<{sha:string, by:string, said:string}>,
|
|
283
304
|
* owed:Array<{sha:string, subject:string, why:"no-note"|"prose"|"bare-none"|"names-a-missing-note"|"note-withdrawn-unsaid",
|
|
284
305
|
* paths?:string[], text?:string, by?:string}>}}
|
|
285
306
|
*/
|
|
286
|
-
export function commitVerdicts({ commits = [], files = [], atHead = null, isAncestor = null } = {}) {
|
|
307
|
+
export function commitVerdicts({ commits = [], files = [], atHead = null, isAncestor = null, released = null } = {}) {
|
|
287
308
|
// `added` and `atHead` are what the command reads from git; a caller that passes neither keeps the older
|
|
288
309
|
// reading of every changed path, which is what a pure table of paths means.
|
|
289
310
|
// MATCHED ON THE NAME, NOT THE PATH, BECAUSE A PRE-RELEASE MOVES A NOTE IT CONSUMES.
|
|
@@ -331,7 +352,13 @@ export function commitVerdicts({ commits = [], files = [], atHead = null, isAnce
|
|
|
331
352
|
});
|
|
332
353
|
// AND A NAME THE HEAD STILL CARRIES WAS NEVER WITHDRAWN AT ALL: the release assembles what the head has.
|
|
333
354
|
if (presentNames) for (const name of [...withdrawn.keys()]) if (presentNames.has(name)) withdrawn.delete(name);
|
|
334
|
-
|
|
355
|
+
// THE RELEASE THAT PUBLISHED A NOTE OF THIS NAME (see the header), unless this commit's own history
|
|
356
|
+
// already holds that release, which makes its note a new one.
|
|
357
|
+
const publishedBy = (c, name) => {
|
|
358
|
+
const r = released?.get(name);
|
|
359
|
+
return r && !(isAncestor && isAncestor(r.sha, c.sha)) ? r : null;
|
|
360
|
+
};
|
|
361
|
+
const declined = [], owed = [], withdrawals = [], answered = [], unneeded = [], published = [];
|
|
335
362
|
const { answers, refused: refusedAnswers } = readAnswers(commits, isAncestor);
|
|
336
363
|
const used = new Set();
|
|
337
364
|
for (const [i, c] of commits.entries()) {
|
|
@@ -342,13 +369,15 @@ export function commitVerdicts({ commits = [], files = [], atHead = null, isAnce
|
|
|
342
369
|
const named = values.map((v) => NAMED_NOTE.exec(v)?.groups.name).filter(Boolean);
|
|
343
370
|
const prose = values.filter((v) => !/^none\b/i.test(v) && !NAMED_NOTE.test(v));
|
|
344
371
|
const at = { sha: c.sha, subject: c.subject };
|
|
372
|
+
const firstPublished = (names) => names.map((n) => [n, publishedBy(c, n)]).find(([, r]) => r);
|
|
373
|
+
const ownPublished = addsNote ? null : firstPublished((c.added ?? c.paths).filter(isNotePath).map(nameOf));
|
|
345
374
|
// A LATER COMMIT'S ANSWER NAMING A NOTE: taken for a sentence line or a bare `none`, when the range adds it.
|
|
346
375
|
const byNote = (answer) => {
|
|
347
376
|
used.add(c.sha);
|
|
348
377
|
if (!noteNames.has(answer.note)) { owed.push({ ...at, why: "names-a-missing-note", text: answer.note, by: answer.by }); return; }
|
|
349
378
|
answered.push({ ...at, by: answer.by, note: answer.note, said: prose[0] ?? "none" });
|
|
350
379
|
};
|
|
351
|
-
if (prose.length && !addsNote) {
|
|
380
|
+
if (prose.length && !addsNote && !ownPublished) {
|
|
352
381
|
const answer = answers.get(c.sha);
|
|
353
382
|
if (answer?.note) byNote(answer);
|
|
354
383
|
else owed.push({ ...at, why: "prose", text: prose[0] });
|
|
@@ -365,6 +394,12 @@ export function commitVerdicts({ commits = [], files = [], atHead = null, isAnce
|
|
|
365
394
|
continue;
|
|
366
395
|
}
|
|
367
396
|
if (addsNote) continue; // it carries its own note
|
|
397
|
+
const releasedNote = ownPublished ?? firstPublished(named);
|
|
398
|
+
if (releasedNote) {
|
|
399
|
+
const [note, by] = releasedNote;
|
|
400
|
+
published.push({ ...at, note, by: by.sha, release: by.subject });
|
|
401
|
+
continue;
|
|
402
|
+
}
|
|
368
403
|
// THE NOTE THIS COMMIT ANSWERED WITH, TAKEN BACK BY A LATER ONE. Only a later commit: a name deleted
|
|
369
404
|
// before this commit named it was never this commit's answer.
|
|
370
405
|
const addedNames = [...new Set((c.added ?? c.paths).filter(isNotePath).map(nameOf))];
|
|
@@ -395,7 +430,7 @@ export function commitVerdicts({ commits = [], files = [], atHead = null, isAnce
|
|
|
395
430
|
: `names ${sha.slice(0, 7)}, which owes a note this line cannot give: an answer covers only a bare \`none\``)
|
|
396
431
|
: `names ${sha.slice(0, 7)}, which owes no answer: it ships no code, carries a note, or gives its own reason` });
|
|
397
432
|
}
|
|
398
|
-
return { visible, notes, declined, withdrawals, owed, answered, refusedAnswers, unneeded };
|
|
433
|
+
return { visible, notes, declined, withdrawals, published, owed, answered, refusedAnswers, unneeded };
|
|
399
434
|
}
|
|
400
435
|
|
|
401
436
|
const argAfter = (flag) => {
|
|
@@ -415,6 +450,7 @@ function main() {
|
|
|
415
450
|
const head = argAfter("--head") || "HEAD";
|
|
416
451
|
const git = (...a) => execFileSync("git", a, { encoding: "utf8", maxBuffer: 1 << 28 });
|
|
417
452
|
let changed, commits, atHead, onMainLine = [];
|
|
453
|
+
const released = new Map();
|
|
418
454
|
try {
|
|
419
455
|
changed = git("diff", "--name-only", `${base}...${head}`).split("\n").filter(Boolean);
|
|
420
456
|
// THE BRANCH'S OWN COMMITS. On a pull request the range can reach commits main already carries, from
|
|
@@ -441,6 +477,24 @@ function main() {
|
|
|
441
477
|
deleted: git("diff-tree", "--no-commit-id", "--name-only", "-r", "--root", "--diff-filter=D", sha).split("\n").filter(Boolean),
|
|
442
478
|
}));
|
|
443
479
|
atHead = git("ls-tree", "-r", "--name-only", head, "--", ".changeset/").split("\n").filter(Boolean);
|
|
480
|
+
// EVERY NOTE A RELEASE ON MAIN'S OWN LINE PUBLISHED (see the header): the names a version commit
|
|
481
|
+
// deleted, at either path. Newest first, so the first sighting of a name is the latest release.
|
|
482
|
+
if (mainKnown) {
|
|
483
|
+
const cutSubject = cutCommitSubject(ROOT);
|
|
484
|
+
let version = null;
|
|
485
|
+
const log = git("log", "--first-parent", "--no-renames", "--diff-filter=D", "--name-status",
|
|
486
|
+
"--format=@@%H%x00%an%x00%s", "origin/main", "--", ".changeset/");
|
|
487
|
+
for (const line of log.split("\n")) {
|
|
488
|
+
if (line.startsWith("@@")) {
|
|
489
|
+
const [sha, author, subject] = line.slice(2).split("\0");
|
|
490
|
+
version = isVersionCommit({ author, subject }, cutSubject) ? { sha, subject } : null;
|
|
491
|
+
continue;
|
|
492
|
+
}
|
|
493
|
+
const path = line.split("\t")[1] ?? "";
|
|
494
|
+
const name = path.split("/").pop();
|
|
495
|
+
if (version && isNotePath(path) && !released.has(name)) released.set(name, version);
|
|
496
|
+
}
|
|
497
|
+
}
|
|
444
498
|
} catch (e) {
|
|
445
499
|
// COULD NOT LOOK, never a pass — an unresolvable base is the shape this repository cares about.
|
|
446
500
|
console.error(`release-note-required: cannot read the range against ${base}: ${e.message.split("\n")[0]}`);
|
|
@@ -462,11 +516,13 @@ function main() {
|
|
|
462
516
|
}
|
|
463
517
|
// ANCESTRY FROM GIT, NEVER TIMESTAMPS: an answer must come from a commit the named one is an ancestor of.
|
|
464
518
|
const isAncestor = (a, b) => { try { git("merge-base", "--is-ancestor", a, b); return true; } catch { return false; } };
|
|
465
|
-
const { visible, notes, declined, withdrawals, owed, answered, refusedAnswers, unneeded } =
|
|
519
|
+
const { visible, notes, declined, withdrawals, published, owed, answered, refusedAnswers, unneeded } =
|
|
520
|
+
commitVerdicts({ commits, files, atHead, isAncestor, released });
|
|
466
521
|
console.log(`release-note-required: ${changed.length} changed file(s) against ${base}`
|
|
467
522
|
+ `${head === "HEAD" ? "" : ` (head ${head})`}; `
|
|
468
523
|
+ `${visible.length} ship as code; ${notes.length} release note(s) in the range; ${commits.length} commit(s) read`
|
|
469
|
-
+ `${withdrawals.length ? `; ${withdrawals.length} answered by a note the range withdrew` : ""}`
|
|
524
|
+
+ `${withdrawals.length ? `; ${withdrawals.length} answered by a note the range withdrew` : ""}`
|
|
525
|
+
+ `${published.length ? `; ${published.length} answered by a note a release already published` : ""}`);
|
|
470
526
|
// PER COMMIT, SAID AS PER COMMIT. "no note, declared on purpose" read as a verdict on the range, and beside
|
|
471
527
|
// a range that carries a note it told a reader skimming the output that none went out. Found in review.
|
|
472
528
|
if (onMainLine.length) {
|
|
@@ -481,6 +537,9 @@ function main() {
|
|
|
481
537
|
for (const w of withdrawals) {
|
|
482
538
|
console.log(` ${w.sha.slice(0, 7)} answered with ${w.note}, which ${w.by.slice(0, 7)} withdrew: ${w.reason}`);
|
|
483
539
|
}
|
|
540
|
+
for (const p of published) {
|
|
541
|
+
console.log(` ${p.sha.slice(0, 7)} answered with ${p.note}, which ${p.by.slice(0, 7)} (${p.release}) published`);
|
|
542
|
+
}
|
|
484
543
|
for (const a of answered) {
|
|
485
544
|
console.log(a.note
|
|
486
545
|
? ` ${a.sha.slice(0, 7)} said ${a.said === "none" ? "a bare `none`" : `"${a.said}"`}, which ${a.by.slice(0, 7)} answers with ${a.note}`
|
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
// test-durations-reporter.mjs — a `node --test` reporter that writes how long each test FILE took, one JSON line per
|
|
5
|
+
// file: `{"file":"driver/test/x.test.mjs","ms":1234}`, the path relative to the repository root.
|
|
6
|
+
//
|
|
7
|
+
// WHY A REPORTER. `node --test` runs a shard's files in parallel and its TAP names no file, so a file's cost cannot be
|
|
8
|
+
// read back from the suite's log. Every top-level test it reports does carry its file, so this sums their durations per
|
|
9
|
+
// file. That leaves out the time a file spends importing before its first test, the same few hundred milliseconds for
|
|
10
|
+
// most files, so the sums rank files as a shard pays for them. `scripts/test-run.mjs` adds it when `CT_DURATIONS_DIR` is
|
|
11
|
+
// set, beside the TAP stream, and CI keeps what it writes with each shard's log.
|
|
12
|
+
import { dirname, join, relative, sep } from "node:path";
|
|
13
|
+
import { fileURLToPath } from "node:url";
|
|
14
|
+
|
|
15
|
+
const ROOT = join(dirname(fileURLToPath(import.meta.url)), "..");
|
|
16
|
+
|
|
17
|
+
export default async function* durations(source) {
|
|
18
|
+
const perFile = new Map();
|
|
19
|
+
for await (const { type, data } of source) {
|
|
20
|
+
if ((type !== "test:pass" && type !== "test:fail") || data?.nesting !== 0 || !data.file) continue;
|
|
21
|
+
const file = relative(ROOT, data.file).split(sep).join("/");
|
|
22
|
+
perFile.set(file, (perFile.get(file) ?? 0) + (data.details?.duration_ms ?? 0));
|
|
23
|
+
}
|
|
24
|
+
for (const [file, ms] of perFile) yield `${JSON.stringify({ file, ms: Math.round(ms) })}\n`;
|
|
25
|
+
}
|
package/scripts/test-full.mjs
CHANGED
|
@@ -45,7 +45,7 @@ import { join, dirname } from "node:path";
|
|
|
45
45
|
import { fileURLToPath } from "node:url";
|
|
46
46
|
import { isEntrypoint } from "../shared/is-entrypoint.mjs";
|
|
47
47
|
|
|
48
|
-
const ROOT = join(dirname(fileURLToPath(import.meta.url)), "..");
|
|
48
|
+
export const ROOT = join(dirname(fileURLToPath(import.meta.url)), "..");
|
|
49
49
|
|
|
50
50
|
/**
|
|
51
51
|
* Every `*.test.mjs` under `providers/`, at any depth, deduplicated and ordered.
|
|
@@ -175,12 +175,22 @@ export function plan(root = ROOT, { providerFiles } = {}) {
|
|
|
175
175
|
* ~980 test files in the tree, executed in one serial job. Agents write faster than that gate opens, so
|
|
176
176
|
* the gate — not the work — set the pace of the day.
|
|
177
177
|
*
|
|
178
|
-
* A shard is
|
|
179
|
-
*
|
|
180
|
-
*
|
|
181
|
-
*
|
|
182
|
-
*
|
|
183
|
-
*
|
|
178
|
+
* A shard is DEALT BY MEASURED DURATION: the files go out longest first, each to the shard with the
|
|
179
|
+
* least time dealt so far, ties to the lower shard, from the table in `scripts/test-durations.json`.
|
|
180
|
+
* Every file is dealt exactly once, so the shards are exhaustive and disjoint by construction, for any
|
|
181
|
+
* n and any table — the union of the shards is the whole list as a property of the deal, not as
|
|
182
|
+
* something a check has to confirm afterwards. Every shard reads the same committed table, so every
|
|
183
|
+
* shard computes the same deal.
|
|
184
|
+
*
|
|
185
|
+
* It replaced a slice by index (`index % n`), which interleaved the sorted list and still left the
|
|
186
|
+
* longest shard about twice the shortest: measured over 38 green runs, 2026-11-11 to 2026-11-17, a
|
|
187
|
+
* median of 10.4 minutes against 5.3, while the four summed to 29.1. The required checks wait for the
|
|
188
|
+
* longest.
|
|
189
|
+
*
|
|
190
|
+
* A TABLE THAT IS STALE COSTS BALANCE, NEVER COVERAGE. A file the table does not name is dealt at the
|
|
191
|
+
* median of the files it does name, so it lands in exactly one shard like any other, and every shard's
|
|
192
|
+
* log says how many files that was. `scripts/measure-test-durations.mjs --run <id> --write` rebuilds the
|
|
193
|
+
* table from what a CI run measured.
|
|
184
194
|
*
|
|
185
195
|
* WHAT IS NOT SHARDED, and why that is stated rather than assumed. Only a corpus whose own test script
|
|
186
196
|
* is the plain `node --test test/*.test.mjs` shape can be expressed as an explicit file list and cut up
|
|
@@ -191,10 +201,38 @@ export function plan(root = ROOT, { providerFiles } = {}) {
|
|
|
191
201
|
*/
|
|
192
202
|
const PLAIN_GLOB = /^node \.\.\/scripts\/test-run\.mjs node --test test\/\*\.test\.mjs$/;
|
|
193
203
|
|
|
194
|
-
export
|
|
195
|
-
|
|
204
|
+
export const DURATIONS_FILE = "scripts/test-durations.json";
|
|
205
|
+
|
|
206
|
+
/** The measured table (milliseconds per file), or an empty one: a missing table deals every file at one cost. */
|
|
207
|
+
export function readDurations(root = ROOT) {
|
|
208
|
+
try {
|
|
209
|
+
const table = JSON.parse(readFileSync(join(root, DURATIONS_FILE), "utf8"));
|
|
210
|
+
return { measured: table.measured ?? null, ms: table.ms ?? {} };
|
|
211
|
+
} catch { return { measured: null, ms: {} }; }
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
const timed = (ms, f) => Number.isFinite(ms[f]) && ms[f] >= 0;
|
|
215
|
+
|
|
216
|
+
/** Shard i of n of `list`, dealt by `ms` (see above). Returned in `list`'s own order. */
|
|
217
|
+
export function shardByDuration(list, i, n, ms = {}) {
|
|
218
|
+
const known = list.filter((f) => timed(ms, f)).map((f) => ms[f]).sort((a, b) => a - b);
|
|
219
|
+
const median = known.length ? known[Math.floor(known.length / 2)] : 1;
|
|
220
|
+
const deal = list.map((f, at) => ({ f, at, cost: timed(ms, f) ? ms[f] : median }))
|
|
221
|
+
.sort((a, b) => b.cost - a.cost || a.at - b.at);
|
|
222
|
+
const load = new Array(n).fill(0);
|
|
223
|
+
const owner = new Map();
|
|
224
|
+
for (const { f, cost } of deal) {
|
|
225
|
+
let k = 0;
|
|
226
|
+
for (let j = 1; j < n; j++) if (load[j] < load[k]) k = j;
|
|
227
|
+
load[k] += cost;
|
|
228
|
+
owner.set(f, k);
|
|
229
|
+
}
|
|
230
|
+
return list.filter((f) => owner.get(f) === i - 1);
|
|
196
231
|
}
|
|
197
232
|
|
|
233
|
+
/** How many files of `list` the table does not name. */
|
|
234
|
+
export const untimedCount = (list, ms = {}) => list.filter((f) => !timed(ms, f)).length;
|
|
235
|
+
|
|
198
236
|
function workspaceTestFiles(root, ws) {
|
|
199
237
|
const dir = join(root, ws, "test");
|
|
200
238
|
if (!existsSync(dir)) return [];
|
|
@@ -213,22 +251,28 @@ function isShardable(root, ws) {
|
|
|
213
251
|
} catch { return false; }
|
|
214
252
|
}
|
|
215
253
|
|
|
254
|
+
/** Every file the shards deal, corpus by corpus: what `measure-test-durations` needs a figure for. */
|
|
255
|
+
export function shardableFiles(corpora, root = ROOT) {
|
|
256
|
+
return corpora.flatMap((c) => (c.kind === "files" ? c.files
|
|
257
|
+
: c.kind === "workspace" && isShardable(root, c.name) ? workspaceTestFiles(root, c.name) : []));
|
|
258
|
+
}
|
|
259
|
+
|
|
216
260
|
/**
|
|
217
261
|
* Rewrite the plan for one shard. Every corpus stays in the list and is reported; what changes is how
|
|
218
|
-
* many of its files THIS shard runs.
|
|
262
|
+
* many of its files THIS shard runs, and how many of them the table did not name.
|
|
219
263
|
*/
|
|
220
|
-
export function applyShard(corpora, { i, n }, root = ROOT) {
|
|
264
|
+
export function applyShard(corpora, { i, n }, root = ROOT, ms = readDurations(root).ms) {
|
|
221
265
|
return corpora.map((c) => {
|
|
222
266
|
if (c.kind === "covered") return c;
|
|
223
267
|
if (c.kind === "files") {
|
|
224
|
-
const mine =
|
|
225
|
-
return { ...c, files: mine, total: c.files.length,
|
|
268
|
+
const mine = shardByDuration(c.files, i, n, ms);
|
|
269
|
+
return { ...c, files: mine, total: c.files.length, untimed: untimedCount(c.files, ms),
|
|
226
270
|
argv: ["node", "scripts/test-run.mjs", "node", "--test", ...mine] };
|
|
227
271
|
}
|
|
228
272
|
if (c.kind === "workspace" && isShardable(root, c.name)) {
|
|
229
273
|
const all = workspaceTestFiles(root, c.name);
|
|
230
|
-
const mine =
|
|
231
|
-
return { ...c, kind: "files", files: mine, total: all.length,
|
|
274
|
+
const mine = shardByDuration(all, i, n, ms);
|
|
275
|
+
return { ...c, kind: "files", files: mine, total: all.length, untimed: untimedCount(all, ms),
|
|
232
276
|
argv: ["node", "scripts/test-run.mjs", "node", "--test", ...mine] };
|
|
233
277
|
}
|
|
234
278
|
// Not expressible as a file list: run it whole, once, on shard 1.
|
|
@@ -249,7 +293,8 @@ function main() {
|
|
|
249
293
|
return { i: a, n: b };
|
|
250
294
|
})();
|
|
251
295
|
const { corpora: full, faults } = plan();
|
|
252
|
-
const
|
|
296
|
+
const durations = readDurations(ROOT);
|
|
297
|
+
const corpora = shard ? applyShard(full, shard, ROOT, durations.ms) : full;
|
|
253
298
|
|
|
254
299
|
// FAULTS BEFORE ANYTHING RUNS. A missing corpus discovered after a green suite reads as an
|
|
255
300
|
// afterthought; discovered first, it is the answer.
|
|
@@ -266,6 +311,17 @@ function main() {
|
|
|
266
311
|
process.exit(2);
|
|
267
312
|
}
|
|
268
313
|
|
|
314
|
+
// SAID BEFORE A LISTING TOO, so the deal and how much of it the table measured can be read without running a shard.
|
|
315
|
+
if (shard) {
|
|
316
|
+
const dealt = corpora.filter((c) => c.kind === "files");
|
|
317
|
+
const total = dealt.reduce((a, c) => a + c.total, 0);
|
|
318
|
+
const untimed = dealt.reduce((a, c) => a + c.untimed, 0);
|
|
319
|
+
console.log(`\ntest-full: shard ${shard.i} of ${shard.n} — files are dealt by measured duration, longest first to the `
|
|
320
|
+
+ `shard with the least so far, so the shards are disjoint and their union is the whole list. `
|
|
321
|
+
+ `${DURATIONS_FILE} (measured ${durations.measured ?? "never"}) names ${total - untimed} of the ${total} file(s); `
|
|
322
|
+
+ `${untimed} have no recorded duration and were dealt at the median.`);
|
|
323
|
+
}
|
|
324
|
+
|
|
269
325
|
if (listOnly) {
|
|
270
326
|
for (const c of chosen) {
|
|
271
327
|
console.log(c.kind === "covered"
|
|
@@ -275,8 +331,6 @@ function main() {
|
|
|
275
331
|
return;
|
|
276
332
|
}
|
|
277
333
|
|
|
278
|
-
if (shard) console.log(`\ntest-full: shard ${shard.i} of ${shard.n} — slices are taken by index from the sorted file list, so the shards are disjoint and their union is the whole list.`);
|
|
279
|
-
|
|
280
334
|
const ran = [];
|
|
281
335
|
for (const c of chosen) {
|
|
282
336
|
if (c.kind === "covered") { ran.push({ ...c, status: "covered" }); continue; }
|
package/scripts/test-run.mjs
CHANGED
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
import { spawn } from "node:child_process";
|
|
49
49
|
import { mkdtempSync, mkdirSync, rmSync, readdirSync, statSync, existsSync, readFileSync, symlinkSync, copyFileSync, chmodSync, writeFileSync, realpathSync } from "node:fs";
|
|
50
50
|
import { delimiter, dirname, join, parse as parsePath, resolve, sep } from "node:path";
|
|
51
|
-
import { fileURLToPath } from "node:url";
|
|
51
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
52
52
|
import { tmpdir, homedir } from "node:os";
|
|
53
53
|
import { snapshotRepo, repoWrites, explainRepoWrites, snapshotHome, explainHomeWrites } from "./repo-writes.mjs";
|
|
54
54
|
|
|
@@ -213,6 +213,23 @@ if (process.env.CT_COVERAGE_DIR && argv.includes("--test")) {
|
|
|
213
213
|
console.error(`[test-run] coverage on — ${join(dir, name)}`);
|
|
214
214
|
}
|
|
215
215
|
|
|
216
|
+
// ── — EACH FILE'S DURATION ON REQUEST, SO THE SHARDS CAN BE DEALT BY IT ───────────────────────────
|
|
217
|
+
//
|
|
218
|
+
// `CT_DURATIONS_DIR` adds `scripts/test-durations-reporter.mjs`, which writes one JSON line per test file with its
|
|
219
|
+
// summed test time; `scripts/measure-test-durations.mjs` builds the shard table from what a CI run kept. Additive for
|
|
220
|
+
// the reason coverage is: naming a reporter silences the default TAP, so TAP is named too, once. One file per
|
|
221
|
+
// invocation, by directory and process, because a shard runs several corpora through this wrapper.
|
|
222
|
+
if (process.env.CT_DURATIONS_DIR && argv.includes("--test")) {
|
|
223
|
+
const dir = process.env.CT_DURATIONS_DIR;
|
|
224
|
+
mkdirSync(dir, { recursive: true });
|
|
225
|
+
const name = `${parsePath(process.cwd()).base || "root"}-${process.pid}.jsonl`;
|
|
226
|
+
// A file URL, not a path: on Windows a drive letter reads as a URL scheme.
|
|
227
|
+
const reporter = pathToFileURL(join(dirname(fileURLToPath(import.meta.url)), "test-durations-reporter.mjs")).href;
|
|
228
|
+
const tap = argv.includes("--test-reporter=tap") ? [] : ["--test-reporter=tap", "--test-reporter-destination=stdout"];
|
|
229
|
+
argv.splice(argv.indexOf("--test") + 1, 0, ...tap,
|
|
230
|
+
`--test-reporter=${reporter}`, `--test-reporter-destination=${join(dir, name)}`);
|
|
231
|
+
}
|
|
232
|
+
|
|
216
233
|
// ── THE TEST RUN DECLARES ITS REGISTER PROVIDER ───────────────────────────────────────────
|
|
217
234
|
//
|
|
218
235
|
// `CLEAROTRON_DATABASE` has no default any more. It used to fall back to "corsearch" inside
|
package/shared/brand.mjs
CHANGED
|
@@ -253,6 +253,76 @@ export const PALETTE_DARK = {
|
|
|
253
253
|
codeBg: 'rgba(236,229,216,.08)',// parchment at 8%
|
|
254
254
|
};
|
|
255
255
|
|
|
256
|
+
// — THE RISK RAMP, ONE SOURCE FOR EVERY SURFACE. Five stops, lowest first, keyed as the report's tokens are
|
|
257
|
+
// (--clear … --severe). The report's tokens below read these, and so do the emails, the staff index and the
|
|
258
|
+
// audit workbook, which each used to draw bands in a palette of their own (2026-11-18). A band's TONE picks
|
|
259
|
+
// its stop: minimal → clear, low → low, medium → med, high → high, severe → severe.
|
|
260
|
+
export const BAND_BY_TONE = Object.freeze({ minimal: 'clear', low: 'low', medium: 'med', high: 'high', severe: 'severe' });
|
|
261
|
+
export const BAND_RAMP = Object.freeze({ clear: '#5F8A64', low: '#8A9440', med: '#C8871B', high: '#B23A2E', severe: '#7C1E15' });
|
|
262
|
+
export const BAND_RAMP_DARK = Object.freeze({ clear: '#7EA382', low: '#A8B25A', med: '#DDA13E', high: '#CA594E', severe: '#A22D22' });
|
|
263
|
+
// The text on a band's fill, chosen per stop for contrast, light and dark.
|
|
264
|
+
export const BAND_ON = Object.freeze({ clear: PALETTE.ink, low: PALETTE.ink, med: PALETTE.ink, high: '#fff', severe: '#fff' });
|
|
265
|
+
export const BAND_ON_DARK = Object.freeze({ clear: PALETTE.ink, low: PALETTE.ink, med: PALETTE.ink, high: PALETTE.ink, severe: '#fff' });
|
|
266
|
+
// The soft fill a chip sits on and the text on it, derived from the bases by the rule in
|
|
267
|
+
// shared/tools/derive-band-pairs.mjs.
|
|
268
|
+
export const BAND_SOFT = Object.freeze({ clear: '#E0E8E1', med: '#F4E8D4', high: '#F1DAD8' });
|
|
269
|
+
export const BAND_SOFT_TEXT = Object.freeze({ clear: '#38553B', med: '#82550A', high: '#742018' });
|
|
270
|
+
// A band's word as coloured text on white, as the emails print it: the base itself where it reads 4.5:1 on
|
|
271
|
+
// white, and otherwise its darker text value by the same rule. Darkening every stop would print High and
|
|
272
|
+
// Very High in one dark red.
|
|
273
|
+
export const BAND_TEXT = Object.freeze({ clear: '#38553B', low: '#5E6527', med: '#82550A', high: '#B23A2E', severe: '#7C1E15' });
|
|
274
|
+
|
|
275
|
+
// — THE EMAILS' AND THE WORKBOOK'S OTHER COLOURS, NAMED FOR WHERE THEY ARE USED. Each surface drew with its own
|
|
276
|
+
// literals, so a re-skin that edited this file still missed them.
|
|
277
|
+
|
|
278
|
+
/** The email risk tiers, on the report's ramp: the cell fill, the text on it, and the band's word as text. */
|
|
279
|
+
const emailTier = (stop) => Object.freeze({ bg: BAND_RAMP[stop], fg: BAND_ON[stop], txt: BAND_TEXT[stop] });
|
|
280
|
+
export const EMAIL_TIER = Object.freeze({
|
|
281
|
+
veryHigh: emailTier('severe'),
|
|
282
|
+
high: emailTier('high'),
|
|
283
|
+
medium: emailTier('med'),
|
|
284
|
+
manageable: emailTier('low'),
|
|
285
|
+
low: emailTier('clear'),
|
|
286
|
+
unrated: Object.freeze({ bg: '#bfbfbf', fg: '#000', txt: '#555' }),
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
/** The emails' other colours: the clearance cover note's links, headline and boxes, and the access note. */
|
|
290
|
+
export const EMAIL_COLOURS = Object.freeze({
|
|
291
|
+
reportLink: '#1a4fd6',
|
|
292
|
+
auditLink: '#3b4fd6',
|
|
293
|
+
headline: '#1a1a2e',
|
|
294
|
+
quiet: '#7a8290', // the access note, and the coverage line
|
|
295
|
+
warning: '#7a2b12', // the handling note, and an applicant named mid-run
|
|
296
|
+
closeBoxFill: '#fdeeee', // "Only you can close these"
|
|
297
|
+
closeBoxLine: '#c98a86',
|
|
298
|
+
closeBoxText: '#6e1512',
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
/** The audit workbook's colours, as the spreadsheet library takes them: RRGGBB, or AARRGGBB where it asks for alpha. */
|
|
302
|
+
export const WORKBOOK_COLOURS = Object.freeze({
|
|
303
|
+
headerFill: '11132A',
|
|
304
|
+
headerText: 'FFFFFFFF',
|
|
305
|
+
link: 'FF0563C1',
|
|
306
|
+
sectionFill: 'FFEDEDED',
|
|
307
|
+
// The coverage states take the report's own: a clean search on the clear stop's soft fill, a limited or
|
|
308
|
+
// open one on the medium stop's, as the report colours its coverage cells.
|
|
309
|
+
stateClean: BAND_SOFT.clear.slice(1),
|
|
310
|
+
stateLimited: BAND_SOFT.med.slice(1),
|
|
311
|
+
stateOpen: BAND_SOFT.med.slice(1),
|
|
312
|
+
stateNote: 'EDEDED',
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
/** The clearance report's quadrant, which stays a fixed light surface in both themes: its markers, the pending marker's
|
|
316
|
+
* fill, the grid, the axis titles and the zone label. Its ink and its zone's red are PALETTE.ink and PALETTE.crimson. */
|
|
317
|
+
export const QUADRANT_COLOURS = Object.freeze({
|
|
318
|
+
onField: '#C8871B',
|
|
319
|
+
secondary: '#5F8A64',
|
|
320
|
+
pendingFill: '#FFFDF9',
|
|
321
|
+
grid: '#E4DACA',
|
|
322
|
+
axisText: '#6B5D52',
|
|
323
|
+
zoneLabel: '#B89A6E',
|
|
324
|
+
});
|
|
325
|
+
|
|
256
326
|
// The typefaces themselves are not linked from anywhere: brand-fonts.mjs embeds them in each page that
|
|
257
327
|
// sets text, and this module only names them, so it stays free of file reads for the tools that import it.
|
|
258
328
|
|
|
@@ -408,7 +478,9 @@ const D = PALETTE_DARK;
|
|
|
408
478
|
export const WARM_ROOT =
|
|
409
479
|
`:root{--bg:${P.cream};--card:${P.cardWarm};--ink:${P.ink};--muted:${P.muted};--line:${P.line};` +
|
|
410
480
|
`--crimson:${P.crimson};--crimson-deep:${P.crimsonDeep};--crimson-mid:${P.crimsonMid};--accent:${P.crimson};` +
|
|
411
|
-
`--h-green:${P.sage};--h-amber:${P.ochre};--h-red:${P.crimson};--h-grey:${P.warmGrey}
|
|
481
|
+
`--h-green:${P.sage};--h-amber:${P.ochre};--h-red:${P.crimson};--h-grey:${P.warmGrey};` +
|
|
482
|
+
// The risk ramp and the text on each stop, for the staff index's band pills (2026-11-18).
|
|
483
|
+
Object.keys(BAND_RAMP).map((k) => `--${k}:${BAND_RAMP[k]};--${k}-on:${BAND_ON[k]};`).join('') + `}`;
|
|
412
484
|
|
|
413
485
|
// :root for the clearance report (templates/report.css). Shared brand colours come from PALETTE;
|
|
414
486
|
// report-specific values (risk scale, soft pairs, neutrals, shadow, mono) are literals. Kept in
|
|
@@ -426,10 +498,14 @@ export const REPORT_ROOT =
|
|
|
426
498
|
// of its own: --high is deliberately NOT --accent any more (the shipped --high was byte-identical to
|
|
427
499
|
// #860F09, so a High risk dot read as a Start button and needed a ring workaround). --accent /
|
|
428
500
|
// --crimson / --maroon above are untouched. The gauge's stop order is clear→low→med→high→severe.
|
|
429
|
-
`--clear
|
|
501
|
+
`--clear:${BAND_RAMP.clear}; --low:${BAND_RAMP.low}; --med:${BAND_RAMP.med}; --high:${BAND_RAMP.high}; --severe:${BAND_RAMP.severe};` +
|
|
502
|
+
// THE TEXT ON A BAND. A band pill printed white on every band, and white scored 3.03:1 on Medium, 3.29 on Low and
|
|
503
|
+
// 3.96 on Clear, under the 4.5 a 14px label needs. Each band names its own text (BAND_ON): the ink on the three light
|
|
504
|
+
// bands, white on the two dark ones (WCAG 2.x: 4.74, 5.71, 6.20, 5.94, 10.23). No single colour clears all five.
|
|
505
|
+
`--clear-on:${BAND_ON.clear}; --low-on:${BAND_ON.low}; --med-on:${BAND_ON.med}; --high-on:${BAND_ON.high}; --severe-on:${BAND_ON.severe};` +
|
|
430
506
|
// Soft/text pairs: re-derived from the five bases by the rule in shared/tools/derive-band-pairs.mjs (same
|
|
431
507
|
// hue, soft at L .895 / S×.78, text at L .275 / S×1.12). Every pair clears WCAG AA on its own chip.
|
|
432
|
-
`--med-soft
|
|
508
|
+
`--med-soft:${BAND_SOFT.med}; --med-tx:${BAND_SOFT_TEXT.med}; --clear-soft:${BAND_SOFT.clear}; --clear-tx:${BAND_SOFT_TEXT.clear}; --high-soft:${BAND_SOFT.high}; --high-tx:${BAND_SOFT_TEXT.high};` +
|
|
433
509
|
`--taupe:#A99A82;` +
|
|
434
510
|
// The mark-itself disclosure toggles. A DEDICATED token: --crimson has no dark variant, and
|
|
435
511
|
// reusing it left the toggles barely legible on the dark ground.
|
|
@@ -473,7 +549,8 @@ const darkBlock = (tokens, rules, { auto = true } = {}) => {
|
|
|
473
549
|
const WARM_DARK_TOKENS =
|
|
474
550
|
`color-scheme:dark;--bg:${D.ground};--card:${D.cardWarm};--ink:${D.ink};--muted:${D.muted};--line:${D.line};` +
|
|
475
551
|
`--crimson:${P.crimson};--crimson-deep:${D.crimsonDeep};--crimson-mid:${D.crimsonMid};--accent:${P.crimson};` +
|
|
476
|
-
`--h-green:#6f9463;--h-amber:#d6a24a;--h-red:${P.crimson};--h-grey:#9a8c7a;--web-glow:rgba(94,7,14,.5);--surface-high:#25201b
|
|
552
|
+
`--h-green:#6f9463;--h-amber:#d6a24a;--h-red:${P.crimson};--h-grey:#9a8c7a;--web-glow:rgba(94,7,14,.5);--surface-high:#25201b;` +
|
|
553
|
+
Object.keys(BAND_RAMP_DARK).map((k) => `--${k}:${BAND_RAMP_DARK[k]};--${k}-on:${BAND_ON_DARK[k]}`).join(';');
|
|
477
554
|
|
|
478
555
|
// Scoped warm-surface overrides — a SUPERSET across the warm pages (like WARM_ROOT itself): crimson-TEXT
|
|
479
556
|
// recolors + the hardcoded light-background islands (#fff/#efe6d8/#faf5ec chips, tracks, forms) that would
|
|
@@ -513,7 +590,10 @@ const REPORT_DARK_TOKENS =
|
|
|
513
590
|
`--line:#322c24;--line2:#3d362c;` +
|
|
514
591
|
`--crimson:${P.crimson};--maroon:${D.crimsonDeep};--rose:${D.crimsonMid};--rose2:#cf8681;--tan:#c8b89a;--mark:${D.ink};` +
|
|
515
592
|
`--crimson-deep:${D.crimsonDeep};--crimson-mid:${D.crimsonMid};` +
|
|
516
|
-
`--clear
|
|
593
|
+
`--clear:${BAND_RAMP_DARK.clear};--low:${BAND_RAMP_DARK.low};--med:${BAND_RAMP_DARK.med};--high:${BAND_RAMP_DARK.high};--severe:${BAND_RAMP_DARK.severe};` +
|
|
594
|
+
// The dark bands are lighter, so the light ink stays (it does not flip with the theme) and covers High too: white
|
|
595
|
+
// on dark High is 4.16, the ink 4.51. Severe keeps white (7.16).
|
|
596
|
+
`--clear-on:${BAND_ON_DARK.clear};--low-on:${BAND_ON_DARK.low};--med-on:${BAND_ON_DARK.med};--high-on:${BAND_ON_DARK.high};--severe-on:${BAND_ON_DARK.severe};` +
|
|
517
597
|
`--med-soft:#352915;--med-tx:#E4BF81;--clear-soft:#212922;--clear-tx:#A7BEA9;--high-soft:#311B19;--high-tx:#D8938D;` +
|
|
518
598
|
`--taupe:#8f8570;` +
|
|
519
599
|
`--ma-toggle:#E8A87C;` +
|
|
@@ -0,0 +1,53 @@
|
|
|
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
|
+
// shared/inline-markdown.mjs — the one inline-markdown dialect the report pages read model-written prose in.
|
|
4
|
+
//
|
|
5
|
+
// The model writes markdown because every other surface it feeds renders markdown. The clearance renderer read links,
|
|
6
|
+
// bold and italic; the Knockout renderer read bold, italic and code; and several clearance fields were escaped and
|
|
7
|
+
// nothing else. So a model-written `[label](https://…)` reached a delivered page as those characters on some fields
|
|
8
|
+
// and as a link on others, and the same sentence printed differently on a clearance and on a Knockout. Both renderers
|
|
9
|
+
// now read the same four forms through this function. The portal's span reader
|
|
10
|
+
// (portal-ui/src/contract/inlineMd.ts) mirrors it without ever building HTML.
|
|
11
|
+
//
|
|
12
|
+
// IT TAKES TEXT ITS CALLER HAS ALREADY ESCAPED. Each renderer escapes as it always has (both escape & < >; the
|
|
13
|
+
// Knockout also escapes quotes), so a page's existing text keeps its bytes and only the markdown forms change.
|
|
14
|
+
// Nothing here may be handed raw model text.
|
|
15
|
+
//
|
|
16
|
+
// THE FORMS, IN ORDER: links, then bold, then italic, then code. Bold runs before italic so the inner asterisks of a
|
|
17
|
+
// `**bold**` run are never read as a pair of italics, and an unmatched marker stays visible: `2 * 3` is a
|
|
18
|
+
// multiplication, and swallowing the character would silently edit a client's document.
|
|
19
|
+
|
|
20
|
+
const LINK = /\[([^\]]+)\]\(([^)]+)\)/g;
|
|
21
|
+
|
|
22
|
+
/** Does a link target open anything safely? http(s), mailto and an in-page `#` anchor; any other scheme is text. */
|
|
23
|
+
export const isSafeLinkTarget = (href) => /^https?:\/\//i.test(href) || /^mailto:/i.test(href) || String(href).startsWith('#');
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Escaped text → the same text with its inline markdown as HTML.
|
|
27
|
+
*
|
|
28
|
+
* Links: an external link opens in a new tab; an in-page anchor keeps same-tab navigation. A target with any other
|
|
29
|
+
* scheme (javascript:, data:, vbscript:, …) renders as its label alone, as plain text.
|
|
30
|
+
*
|
|
31
|
+
* Provenance honesty: an authored 'Corsearch · <name>' label whose href is NOT a Corsearch page (live case: storefront
|
|
32
|
+
* links labelled as the register vendor) gets its vendor token replaced by the link's actual host — a lawyer must never
|
|
33
|
+
* cite a storefront as a register record.
|
|
34
|
+
*/
|
|
35
|
+
export function inlineMarkdown(escaped) {
|
|
36
|
+
return String(escaped ?? '')
|
|
37
|
+
.replace(LINK, (mm, txt, href) => {
|
|
38
|
+
let label = txt;
|
|
39
|
+
const vend = /^(Corsearch)\s*·\s*(.+)$/i.exec(txt);
|
|
40
|
+
if (vend && /^https?:\/\//i.test(href) && !/corsearch\./i.test(href)) {
|
|
41
|
+
try { label = `${new URL(href.replace(/&/g, '&')).host.replace(/^www\./, '')} · ${vend[2]}`; } catch { /* keep authored label */ }
|
|
42
|
+
}
|
|
43
|
+
if (!isSafeLinkTarget(href)) return label;
|
|
44
|
+
// XSS: the caller's escaping may not cover quotes, and a `"` in the href would break out of the attribute, so
|
|
45
|
+
// quotes are escaped here. Not a second full escape: that would double-encode `&` in query strings
|
|
46
|
+
// (?a=1&b=2 → &amp;).
|
|
47
|
+
const safeHref = href.replace(/"/g, '"');
|
|
48
|
+
return /^https?:\/\//i.test(href) ? `<a href="${safeHref}" target="_blank" rel="noopener noreferrer">${label}</a>` : `<a href="${safeHref}">${label}</a>`;
|
|
49
|
+
})
|
|
50
|
+
.replace(/\*\*([^*]+)\*\*/g, '<b>$1</b>')
|
|
51
|
+
.replace(/(^|[^*])\*([^*]+)\*/g, '$1<i>$2</i>')
|
|
52
|
+
.replace(/`([^`]+)`/g, '<span class="mono">$1</span>');
|
|
53
|
+
}
|
package/shared/portal-tokens.mjs
CHANGED
|
@@ -87,7 +87,8 @@ const semantic = () => {
|
|
|
87
87
|
// borders + focus
|
|
88
88
|
["--border-hairline", L("--line"), D("--line"), "brand --line"],
|
|
89
89
|
["--border-strong", L("--line2"), D("--line2"), "brand --line2"],
|
|
90
|
-
["--focus-ring", L("--crimson"),
|
|
90
|
+
["--focus-ring", L("--crimson"), "#e0736b",
|
|
91
|
+
"brand --crimson; dark takes the dark --text-accent, since crimson on the dark page is too faint to see a focus by"],
|
|
91
92
|
|
|
92
93
|
// type, shadow, motion
|
|
93
94
|
["--font-body", L("--font"), L("--font"), "brand --font"],
|
|
@@ -110,9 +110,14 @@ export const PROVIDERS = [
|
|
|
110
110
|
id: "uspto-local", label: "USPTO (local index) — the US register only", cost: "free",
|
|
111
111
|
covers: "the US register, and nothing else, from an index you build and hold locally.",
|
|
112
112
|
credentials: ["USPTO_LOCAL_DB"],
|
|
113
|
-
|
|
113
|
+
// NO EU HALF: setup says nothing about the EU register for this row.
|
|
114
|
+
warnings: USPTO_WARNINGS.filter((w) => !/^The EU register /.test(w)),
|
|
114
115
|
uspToLocalKey: "USPTO_LOCAL_DB",
|
|
116
|
+
euHalf: false,
|
|
115
117
|
},
|
|
116
|
-
|
|
117
|
-
{ id: "
|
|
118
|
+
// NO VENDOR STEPS ARE WRITTEN for these two: the shipped sentence says where the key comes from.
|
|
119
|
+
{ id: "corsearch", label: "Corsearch — global", cost: "subscription", covers: "a global sweep.", credentials: ["CORSEARCH_SESSION_KEY"],
|
|
120
|
+
signup: ["The key arrives through your Corsearch sales agreement, not a signup form."] },
|
|
121
|
+
{ id: "clarivate", label: "Clarivate — global", cost: "subscription", covers: "a global sweep.", credentials: ["CLARIVATE_API_KEY"],
|
|
122
|
+
signup: ["The key arrives through your Clarivate sales agreement, not a signup form."] },
|
|
118
123
|
];
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_generated": "by scripts/mint-search-level-tags.mjs from driver/search-policy.mjs PRODUCT_POLICIES — do not edit; re-mint",
|
|
3
|
+
"levels": [
|
|
4
|
+
{
|
|
5
|
+
"product": "knockout-search",
|
|
6
|
+
"tag": "KO",
|
|
7
|
+
"name": "Knockout search"
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"product": "global-preliminary-search",
|
|
11
|
+
"tag": "Prelim",
|
|
12
|
+
"name": "Global preliminary search"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"product": "multi-country-focus-search",
|
|
16
|
+
"tag": "Multi",
|
|
17
|
+
"name": "Multi-country focus search"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"product": "full-country-search",
|
|
21
|
+
"tag": "Full",
|
|
22
|
+
"name": "Full country search"
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
}
|
|
@@ -102,3 +102,13 @@ for (const [k, base] of Object.entries(NEW)) {
|
|
|
102
102
|
const OLD_HIGH = '#860F09';
|
|
103
103
|
console.log(`\naccent-collision check: old --high ${OLD_HIGH} vs --accent #860F09 -> contrast ${contrast(OLD_HIGH, '#860F09').toFixed(2)} (identical)`);
|
|
104
104
|
console.log(` new --high ${NEW.high} vs --accent #860F09 -> contrast ${contrast(NEW.high, '#860F09').toFixed(2)}`);
|
|
105
|
+
|
|
106
|
+
// THE EMAILS PRINT A BAND'S WORD AS COLOURED TEXT ON WHITE, so every stop needs a text value, low and severe
|
|
107
|
+
// included, which the report's chips never asked for. A base that reads 4.5:1 on white is used as it is;
|
|
108
|
+
// otherwise the light rule darkens it. Darkening all five would print High and Very High in one dark red.
|
|
109
|
+
const TEXT_ONLY = { low: '#8A9440', severe: '#7C1E15' };
|
|
110
|
+
console.log('\n=== a band\'s word on white, all five stops (brand.mjs BAND_TEXT) ===');
|
|
111
|
+
for (const [k, base] of Object.entries({ ...NEW, ...TEXT_ONLY })) {
|
|
112
|
+
const word = contrast(base, '#FFFFFF') >= 4.5 ? base : txLight(hsl(base));
|
|
113
|
+
console.log(`${k.padEnd(6)} base ${base} on #FFFFFF ${contrast(base, '#FFFFFF').toFixed(2)} word ${word} on #FFFFFF ${contrast(word, '#FFFFFF').toFixed(2)}`);
|
|
114
|
+
}
|