clearotron 0.3.1-beta.4 → 0.3.2-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/CONTRIBUTING.md +30 -1
- package/README.md +1 -0
- package/build-info.json +2 -2
- package/docs/writing-rules.md +208 -0
- package/docs/writing-standard.md +85 -0
- package/driver/CHANGELOG.md +81 -0
- package/driver/contract-e3-backlog.mjs +3 -3
- package/driver/contract-vocabulary.mjs +15 -14
- package/driver/gateway.mjs +33 -17
- package/driver/package.json +1 -1
- package/driver/publish/render-knockout.mjs +6 -26
- package/driver/publish/render.mjs +25 -5
- package/driver/suite-census.json +30 -0
- package/driver/verify.mjs +22 -3
- package/mcp-server/CHANGELOG.md +19 -0
- package/mcp-server/package.json +1 -1
- package/package.json +1 -1
- package/portal-ui/package.json +1 -1
- package/providers/oauth-mcp-bridge/CHANGELOG.md +8 -0
- package/providers/oauth-mcp-bridge/package.json +1 -1
- package/scripts/mint-writing-standard-backlog.mjs +82 -0
- package/scripts/release-approve-parked.mjs +151 -0
- package/scripts/writing-standard-check.mjs +122 -0
- package/shared/says-something-new.mjs +62 -0
- package/shared/writing-standard-caveats.json +14 -0
- package/shared/writing-standard-classes.mjs +526 -0
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only
|
|
3
|
+
// Copyright 2026 Cordillera Sàrl. Additional terms under section 7 of the AGPL-3.0 apply — see ADDITIONAL-TERMS.md
|
|
4
|
+
//
|
|
5
|
+
// WHAT THIS CHANGE ADDS TO A CUSTOMER SURFACE IS REFUSED. What is already here is not this check's business.
|
|
6
|
+
//
|
|
7
|
+
// node scripts/writing-standard-check.mjs [--base <ref>]
|
|
8
|
+
//
|
|
9
|
+
// The standard is `docs/writing-standard.md`, and the prose rules under it are `docs/writing-rules.md`.
|
|
10
|
+
// This refuses the five classes a machine can judge; the classes and the reasoning behind each site rule
|
|
11
|
+
// are in `shared/writing-standard-classes.mjs`, next to the table, because that is where the next person
|
|
12
|
+
// changing one will be looking.
|
|
13
|
+
//
|
|
14
|
+
// ── WHY THIS IS DIFF-SHAPED AND NOT A SWEEP ──────────────────────────────────────────────────────
|
|
15
|
+
//
|
|
16
|
+
// Three of the five classes have a standing population in this tree — the knockout's scope block and the
|
|
17
|
+
// clearance renderer's coverage caveat are the very sentences the standard quotes as what not to write,
|
|
18
|
+
// and they are still on the page. A guard that refused them all would refuse every pull request from its
|
|
19
|
+
// first day, and a guard everybody bypasses protects nothing. So this one asks the smaller question that
|
|
20
|
+
// has a clean answer: did THIS change add another.
|
|
21
|
+
//
|
|
22
|
+
// The standing population is not thereby accepted. It is counted, per file and per class, in
|
|
23
|
+
// `driver/test/fixtures/writing-standard-backlog.json`, and the floor beside it refuses any file that
|
|
24
|
+
// grows. Between the two the number can only fall.
|
|
25
|
+
//
|
|
26
|
+
// ── TWO SHAPES OF CLASS, AND WHY THE SECOND CANNOT BE A LINE READ ───────────────────────────────
|
|
27
|
+
//
|
|
28
|
+
// `engineering-identifier`, `internal-marker` and `known-caveat` are properties of text, so an added line
|
|
29
|
+
// carries them. `eyebrow-heading` and `restating-lede` are not: "this screen writes its own page heading"
|
|
30
|
+
// is a property of a FILE, and "this lede restates its title" needs the two lines at once. Adding a lede
|
|
31
|
+
// under an existing title adds one line and creates the offence; a line-only reading would miss it.
|
|
32
|
+
//
|
|
33
|
+
// So both shapes are evaluated against the file as it stands at HEAD, and the DIFF decides only whether
|
|
34
|
+
// this change is answerable for what it finds: a line class must have its line in the added set; a block
|
|
35
|
+
// class must have its file in the changed set. That is a deliberate widening of "reads the lines a change
|
|
36
|
+
// adds", and it is the only way the last two classes mean anything.
|
|
37
|
+
//
|
|
38
|
+
// ── AN EMPTY DIFF IS A LEGITIMATE PASS, AND IT IS PRINTED AS ONE ────────────────────────────────
|
|
39
|
+
//
|
|
40
|
+
// A pull request can touch only files this check does not read. The count is printed either way, so a
|
|
41
|
+
// reader can tell "looked and found nothing" from "had nothing to look at".
|
|
42
|
+
import { execFileSync } from "node:child_process";
|
|
43
|
+
import { readFileSync } from "node:fs";
|
|
44
|
+
import { CLASSES, fileOffences, isExempt } from "../shared/writing-standard-classes.mjs";
|
|
45
|
+
|
|
46
|
+
const baseArg = () => {
|
|
47
|
+
const i = process.argv.indexOf("--base");
|
|
48
|
+
return i === -1 ? null : process.argv[i + 1];
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* The added lines of a diff, as `{ path, lines: Set<number> }` per file.
|
|
53
|
+
*
|
|
54
|
+
* `--unified=0` so nothing but genuinely added text is read: with context lines a neighbouring sentence
|
|
55
|
+
* would be reported as though this change wrote it, and a guard that blames the wrong line is one people
|
|
56
|
+
* learn to ignore. The hunk header carries the new-side start and count, which is what maps an added line
|
|
57
|
+
* back to its number in the file at HEAD.
|
|
58
|
+
*/
|
|
59
|
+
export function addedByFile(diffText) {
|
|
60
|
+
const out = new Map();
|
|
61
|
+
let path = null;
|
|
62
|
+
let nextLine = 0;
|
|
63
|
+
for (const line of diffText.split("\n")) {
|
|
64
|
+
if (line.startsWith("+++ b/")) { path = line.slice(6); if (!out.has(path)) out.set(path, new Set()); continue; }
|
|
65
|
+
if (line.startsWith("+++ ") || line.startsWith("--- ")) continue;
|
|
66
|
+
const hunk = /^@@ -\d+(?:,\d+)? \+(\d+)(?:,(\d+))? @@/.exec(line);
|
|
67
|
+
if (hunk) { nextLine = Number(hunk[1]); continue; }
|
|
68
|
+
if (line.startsWith("+") && path) { out.get(path).add(nextLine); nextLine++; continue; }
|
|
69
|
+
if (line.startsWith("-")) continue;
|
|
70
|
+
nextLine++;
|
|
71
|
+
}
|
|
72
|
+
return out;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function main() {
|
|
76
|
+
const base = baseArg() || "origin/main";
|
|
77
|
+
let diff;
|
|
78
|
+
try {
|
|
79
|
+
diff = execFileSync("git", ["diff", "--unified=0", `${base}...HEAD`], { encoding: "utf8", maxBuffer: 1 << 28 });
|
|
80
|
+
} catch (e) {
|
|
81
|
+
console.error(`writing-standard-check: cannot diff against ${base}: ${e.message.split("\n")[0]}`);
|
|
82
|
+
process.exit(2);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const added = addedByFile(diff);
|
|
86
|
+
const lineClasses = new Set(["engineering-identifier", "internal-marker", "known-caveat"]);
|
|
87
|
+
const hits = [];
|
|
88
|
+
let read = 0;
|
|
89
|
+
|
|
90
|
+
for (const [path, lines] of added) {
|
|
91
|
+
if (isExempt(path)) continue;
|
|
92
|
+
let text;
|
|
93
|
+
try { text = readFileSync(path, "utf8"); } catch { continue; } // deleted in this change
|
|
94
|
+
read += lines.size;
|
|
95
|
+
for (const o of fileOffences(path, text)) {
|
|
96
|
+
// A LINE CLASS ANSWERS FOR ITS LINE; A BLOCK CLASS ANSWERS FOR ITS FILE. Holding a block class to
|
|
97
|
+
// the added-line test would excuse the case it exists for — a lede added under a title that was
|
|
98
|
+
// already there, where the offending pair is one new line and one old one.
|
|
99
|
+
if (lineClasses.has(o.id) && !lines.has(o.line)) continue;
|
|
100
|
+
hits.push({ path, ...o });
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
console.log(`writing-standard-check: read ${read} added line(s) in ${added.size} file(s) against ${base}`);
|
|
105
|
+
if (!hits.length) return;
|
|
106
|
+
|
|
107
|
+
// GROUPED BY CLASS, because the remedy is per class and a flat list makes the reader derive it five
|
|
108
|
+
// times. Each heading is said once, then the lines it applies to.
|
|
109
|
+
console.error(`\n${hits.length} line(s) added that a customer surface must not carry:\n`);
|
|
110
|
+
for (const { id, why } of CLASSES) {
|
|
111
|
+
const mine = hits.filter((h) => h.id === id);
|
|
112
|
+
if (!mine.length) continue;
|
|
113
|
+
console.error(` ${id} — ${why}`);
|
|
114
|
+
for (const h of mine) console.error(` ${h.path}:${h.line}\n ${h.token}`);
|
|
115
|
+
console.error("");
|
|
116
|
+
}
|
|
117
|
+
console.error(" The standard is docs/writing-standard.md. It never rewrites: a rewritten sentence is a");
|
|
118
|
+
console.error(" sentence nobody reviewed, and a report is the one document a reader may trust literally.\n");
|
|
119
|
+
process.exit(1);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (import.meta.url === `file://${process.argv[1]}`) main();
|
|
@@ -0,0 +1,62 @@
|
|
|
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
|
+
// DOES THIS SENTENCE ASSERT ANYTHING ITS REFERENCE DOES NOT?
|
|
5
|
+
//
|
|
6
|
+
// One question, two callers. The knockout renderer asks it of a model-written caveat against the scope
|
|
7
|
+
// block the page already prints, and drops the caveat when the answer is no. The writing-standard check
|
|
8
|
+
// asks it of a page's lede against that page's title, and refuses the lede when the answer is no. The
|
|
9
|
+
// two are the same rule — "this line adds nothing to the line above it" — and they were one function
|
|
10
|
+
// private to the renderer until the check needed it.
|
|
11
|
+
//
|
|
12
|
+
// LIFTED RATHER THAN COPIED, AND THAT IS THE WHOLE POINT. Two definitions of one rule is one definition
|
|
13
|
+
// and one imitation of it, and the imitation is whichever the reader did not run. A copy here would
|
|
14
|
+
// drift the first time either caller tuned its stopword list, and the drift would be invisible: both
|
|
15
|
+
// sides would keep passing their own tests.
|
|
16
|
+
//
|
|
17
|
+
// ── THE STEM MUST BE IDEMPOTENT ON THE SINGULAR ─────────────────────────────────────────────────
|
|
18
|
+
//
|
|
19
|
+
// Carried over from the renderer with the defect it had already been repaired for, stated here so it is
|
|
20
|
+
// not reintroduced. An earlier form stripped a trailing "es" — which turned "gives" into "giv" while
|
|
21
|
+
// leaving "give" alone, so the two never matched and every caveat read as new. The fold has to map the
|
|
22
|
+
// plural onto the singular AND leave the singular where it is. Strip one trailing "s" and nothing else.
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Words that carry no claim, so their presence or absence says nothing about what a sentence asserts.
|
|
26
|
+
*
|
|
27
|
+
* Exported because a caller comparing two short strings — a title against a lede — can be left with no
|
|
28
|
+
* content words at all, and that case needs naming rather than inferring from a false return.
|
|
29
|
+
*/
|
|
30
|
+
export const STOPWORDS = new Set(['a', 'an', 'and', 'are', 'as', 'at', 'be', 'been', 'but', 'by', 'can', 'do',
|
|
31
|
+
'does', 'each', 'for', 'from', 'has', 'have', 'here', 'in', 'is', 'it', 'its', 'no', 'not', 'of', 'on',
|
|
32
|
+
'or', 'that', 'the', 'their', 'them', 'there', 'these', 'they', 'this', 'to', 'up', 'was', 'we', 'were',
|
|
33
|
+
'what', 'when', 'which', 'will', 'with', 'you', 'your']);
|
|
34
|
+
|
|
35
|
+
/** The words in a string that carry a claim: longer than two characters, and not a stopword. */
|
|
36
|
+
export const contentWords = (s) => String(s ?? '').toLowerCase().replace(/[^a-z0-9\s-]/g, ' ')
|
|
37
|
+
.split(/\s+/).filter((w) => w.length > 2 && !STOPWORDS.has(w));
|
|
38
|
+
|
|
39
|
+
/** Fold plural onto singular. Idempotent on the singular, which is the property that makes it work. */
|
|
40
|
+
export const stem = (w) => w.replace(/ies$/, 'y').replace(/s$/, '');
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Does `line` assert anything `reference` does not already assert?
|
|
44
|
+
*
|
|
45
|
+
* TRUE unless every content word in the line is already in the reference. An empty line has nothing to
|
|
46
|
+
* say and returns false; a line with one unfamiliar word is kept. Singular and plural are folded, so
|
|
47
|
+
* "conclusion" does not read as new beside "conclusions".
|
|
48
|
+
*
|
|
49
|
+
* THE TEST IS SUBSET, NOT SIMILARITY, and the difference is the whole safety argument for the renderer's
|
|
50
|
+
* use of it: a caveat is dropped only when EVERY content word in it already appears in the reference. A
|
|
51
|
+
* caveat making any new claim survives.
|
|
52
|
+
*
|
|
53
|
+
* @param {string} line the sentence being judged
|
|
54
|
+
* @param {string} reference the text it is judged against
|
|
55
|
+
* @returns {boolean}
|
|
56
|
+
*/
|
|
57
|
+
export function saysSomethingNew(line, reference) {
|
|
58
|
+
const known = new Set(contentWords(reference).map(stem));
|
|
59
|
+
const words = contentWords(line);
|
|
60
|
+
if (!words.length) return false;
|
|
61
|
+
return words.some((w) => !known.has(stem(w)));
|
|
62
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"note": "The caveat sentences the writing standard forbids, held as data rather than in shared/writing-standard-classes.mjs. A class list that reprints its own specimens counts itself, and that module is read by the census that counts them. Matching is case-insensitive and whitespace-flattened, over a file's joined printed text, so a sentence built by string concatenation across source lines is still one sentence. Keep each entry long enough to be unambiguous: a fragment short enough to occur in ordinary prose will match ordinary prose.",
|
|
3
|
+
"sentences": [
|
|
4
|
+
"What it is not. A clearance search.",
|
|
5
|
+
"We drew no register conclusions and give no filing advice.",
|
|
6
|
+
"A name that passes here is not clear",
|
|
7
|
+
"A count is not a conflict",
|
|
8
|
+
"No coverage record was produced for this run.",
|
|
9
|
+
"This section normally lists what each search covered",
|
|
10
|
+
"Ask us before relying on it",
|
|
11
|
+
"the Japan adapter was unavailable this session",
|
|
12
|
+
"Source routing attempted"
|
|
13
|
+
]
|
|
14
|
+
}
|