paperlint 19.0.2 → 20.0.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.
Files changed (90) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CLAUDE.md +2 -2
  3. package/dist/CLAUDE.md.spec.d.ts.map +1 -1
  4. package/dist/CLAUDE.md.spec.js +7 -1
  5. package/dist/CLAUDE.md.spec.js.map +1 -1
  6. package/dist/cli.d.ts +2 -21
  7. package/dist/cli.d.ts.map +1 -1
  8. package/dist/cli.js +45 -93
  9. package/dist/cli.js.map +1 -1
  10. package/dist/doctor.d.ts +8 -10
  11. package/dist/doctor.d.ts.map +1 -1
  12. package/dist/doctor.js +27 -37
  13. package/dist/doctor.js.map +1 -1
  14. package/dist/hooks-notice.d.ts +8 -2
  15. package/dist/hooks-notice.d.ts.map +1 -1
  16. package/dist/hooks-notice.js +15 -20
  17. package/dist/hooks-notice.js.map +1 -1
  18. package/dist/hooks-settings.d.ts +1 -1
  19. package/dist/hooks-settings.js +1 -1
  20. package/dist/init.d.ts +1 -1
  21. package/dist/init.js +5 -5
  22. package/dist/lib/paper-config.d.ts +4 -9
  23. package/dist/lib/paper-config.d.ts.map +1 -1
  24. package/dist/lib/paper-config.js +4 -9
  25. package/dist/lib/paper-config.js.map +1 -1
  26. package/dist/papers-roots.d.ts +19 -0
  27. package/dist/papers-roots.d.ts.map +1 -0
  28. package/dist/papers-roots.js +42 -0
  29. package/dist/papers-roots.js.map +1 -0
  30. package/dist/retired-hooks.d.ts +6 -0
  31. package/dist/retired-hooks.d.ts.map +1 -0
  32. package/dist/retired-hooks.js +34 -0
  33. package/dist/retired-hooks.js.map +1 -0
  34. package/dist/skill-chunks/chunk-C2G5EK7S.js +579 -0
  35. package/dist/skill-chunks/{chunk-UL4INX2P.js → chunk-L3NJUJUP.js} +446 -446
  36. package/dist/skill-chunks/{chunk-EOVEVX67.js → chunk-X4VKG4KT.js} +1 -1
  37. package/dist/types.d.ts +1 -1
  38. package/docs/install.md +9 -11
  39. package/docs/layout.md +2 -4
  40. package/docs/rules/paper/allowed-files-only.md +1 -2
  41. package/docs/testing.md +1 -1
  42. package/eslint.config.mjs +1 -1
  43. package/lib/paper-config.harness.mjs +3 -6
  44. package/lib/paper-config.ts +4 -9
  45. package/lib/skill-eval-kit.mjs +0 -14
  46. package/package.json +2 -4
  47. package/plugin/hooks/hooks.json +0 -13
  48. package/scripts/coverage-config.test.ts +0 -2
  49. package/scripts/eslint-file-length.mjs +0 -1
  50. package/skills/argument-arc/scripts/headings.js +2 -2
  51. package/skills/build-label-page/scripts/label-page.js +125 -125
  52. package/skills/cold-read-diff/scripts/cold-read.js +11 -11
  53. package/skills/paper-pipeline/scripts/extract-ref-facts.js +3 -3
  54. package/skills/paper-status/SKILL.md +1 -2
  55. package/skills/paper-status/SKILL.md.spec.ts +0 -1
  56. package/skills/pc-panel-review/scripts/prior-reviews.js +1 -1
  57. package/skills/verify-citations/scripts/bib-authors.js +3 -3
  58. package/skills/verify-citations/scripts/verify-cites.js +3 -3
  59. package/src/CLAUDE.md +16 -1
  60. package/src/CLAUDE.md.spec.ts +12 -1
  61. package/src/cli.harness.mjs +14 -79
  62. package/src/cli.test.ts +4 -34
  63. package/src/cli.ts +47 -140
  64. package/src/doctor.harness.mjs +17 -59
  65. package/src/doctor.test.ts +1 -1
  66. package/src/doctor.ts +26 -41
  67. package/src/domain/paper-folder.test.ts +1 -1
  68. package/src/hooks-notice.test.ts +21 -74
  69. package/src/hooks-notice.ts +30 -20
  70. package/src/hooks-settings.harness.ts +25 -27
  71. package/src/hooks-settings.ts +1 -1
  72. package/src/in-process-hooks.test.ts +18 -0
  73. package/src/init.ts +5 -5
  74. package/src/lint-edited-site-example.test.ts +0 -3
  75. package/src/papers-roots.test.ts +56 -0
  76. package/src/papers-roots.ts +56 -0
  77. package/src/retired-hooks.test.ts +155 -0
  78. package/src/retired-hooks.ts +41 -0
  79. package/src/types.ts +1 -1
  80. package/dist/skill-chunks/chunk-GRSXIWYF.js +0 -352
  81. package/hooks/CLAUDE.md +0 -34
  82. package/hooks/CLAUDE.md.spec.ts +0 -30
  83. package/hooks/hooks.harness.ts +0 -566
  84. package/hooks/paper-edit-guard.hook.d.mts +0 -12
  85. package/hooks/paper-edit-guard.hook.mjs +0 -443
  86. package/hooks/paper-edit-guard.test.ts +0 -66
  87. package/hooks/paper-skills-nudge.hook.d.mts +0 -22
  88. package/hooks/paper-skills-nudge.hook.mjs +0 -193
  89. package/hooks/paper-skills-nudge.test.ts +0 -122
  90. package/lib/trigger-ledger.mjs +0 -215
@@ -1,193 +0,0 @@
1
- /**
2
- * paper-skills-nudge — a PostToolUse react: editing a paper SOURCE surfaces the static
3
- * pre-submit checklist, so the pipeline is driven rather than winged.
4
- *
5
- * ── THE BUG THIS REMOVES ────────────────────────────────────────────────────
6
- * Its shell predecessor was dead for twelve days: it read the payload from `$CLAUDE_TOOL_INPUT`
7
- * while the harness delivers on stdin, so its path match never ran and it exited 0 in silence
8
- * across dozens of paper edits. An advisory hook cannot be NOTICED failing — silence is also its
9
- * success case, which is why it took a frozen throttle stamp to find it. A `react` never touches
10
- * the payload: the runtime decodes the event and hands in `e.path`, so the whole family of "read
11
- * the wrong input / wrote the wrong field / exited the wrong code" is unrepresentable here.
12
- *
13
- * ── DELIVERY, MEASURED (2026-09-12, vigiles 27.1.4) ─────────────────────────
14
- * `PostToolUse` is in the adapter's `injectableEvents`, so a `notice` on this event reaches the
15
- * model as `hookSpecificOutput.additionalContext` on STDOUT — 1 346 bytes on a paper edit, 0 on
16
- * anything else — with a copy on stderr for a human. That is NOT true of every event: `Stop` and
17
- * `PreToolUse` are absent from that list, and a `notice` there reaches only the debug log. Do not
18
- * move this hook to another event assuming its text still lands.
19
- *
20
- * ── WHY `.mjs` AND NOT A `.hook.ts` SPEC ────────────────────────────────────
21
- * Measured in `paper-edit-guard.hook.mjs` — a `.ts` hook reached through `node_modules` does not
22
- * load at all, and a consumer-side thin spec that imports this logic is refused by
23
- * `vigiles compile` and can therefore never be re-stamped. The full reasoning, with both
24
- * measurements, is in that file's header; the capability surface of this one is asserted by
25
- * `hooks.harness.ts` running `checkHookImports` over the shipped artifact.
26
- */
27
- import {
28
- experimental_defineReact,
29
- tools,
30
- provide,
31
- notice,
32
- nothing,
33
- record,
34
- state,
35
- } from "vigiles/hook";
36
-
37
- /** The tool's name — the package this hook resolves its scripts through. */
38
- export const CONFIG_KEY = "paperlint";
39
- /** The settings file at the project root. Optional: absent means every default. */
40
- export const CONFIG_FILE = "paperlint.json";
41
- /** The default. A consumer that declares nothing is assumed to keep papers in `papers/`. */
42
- export const DEFAULT_PAPERS_ROOT = "papers";
43
- /**
44
- * The field of the root `paperlint.json` that names the papers directory. These are copies of the
45
- * constants in `lib/paper-config.mjs` (a hook may import nothing but `vigiles/hook`);
46
- * `lib/paper-config.harness.mjs` checks that the copies match.
47
- */
48
- export const PAPERS_DIR_FIELD = "papersDir";
49
-
50
- /**
51
- * The provider: the root `paperlint.json`, or `{}` when the project has none — so an ABSENT file
52
- * (every default) and an UNREADABLE one (the empty string the runtime gives a failed provider)
53
- * stay two different inputs.
54
- *
55
- * 🔴 THE PATH IS ANCHORED TO THE PROJECT ROOT. vigiles runs a provider "via execSync in the hook's
56
- * cwd", which is the consumer's wiring — a string this hook cannot see. A bare relative path reads
57
- * from whatever directory the Bash tool last moved to.
58
- */
59
- const READ_CONFIG = `f="\${CLAUDE_PROJECT_DIR:-.}/${CONFIG_FILE}"; if [ -e "$f" ]; then cat "$f"; else echo '{}'; fi`;
60
-
61
- /**
62
- * The declared papers root, or `null` when it is unusable.
63
- *
64
- * ⚠️ NO TRAILING-SLASH NORMALISATION HERE, and that is measured rather than sloppy. The guard
65
- * hand-writes its own prefix tests (`startsWith(p + "/")`), where a slash the consumer typed
66
- * becomes `//` and matches nothing — a defect that shipped once. This hook instead uses
67
- * `e.path.under()`, and vigiles normalises the prefix itself (`normalizePrefix` →
68
- * `trimTrailingSeparators`), so `"docs/papers/"` and `"docs/papers"` are the same prefix to it.
69
- * A normalise here would be a line no test could kill, which is a line that documents a
70
- * defence that does not exist. Confirmed 2026-09-12: removing it left the harness green, which
71
- * is the finding that produced this paragraph.
72
- *
73
- * ⚠️ A NUDGE FALLS SILENT WHERE THE GATE REFUSES, and the asymmetry is the decision, not an
74
- * inconsistency. `paper-edit-guard` denies on an unreadable declaration because a gate that
75
- * quietly reverts to the default would pass every write it exists to stop. This hook has no such
76
- * failure mode: with no root it prints nothing, which is what it already does on every
77
- * non-paper edit. Denying here would mean an advisory hook blocking work over a courtesy
78
- * message — and a `react` cannot deny at all: its type has no `deny`, so it always exits 0.
79
- *
80
- * 🔴 `declared === undefined`, NOT `declared ?? DEFAULT` — `"papersDir": null` is a keystroke, not
81
- * an absence. Same distinction as every other carrier in this package.
82
- */
83
- const papersRoot = (rawConfig) => {
84
- let declared;
85
- try {
86
- declared = JSON.parse(rawConfig)?.[PAPERS_DIR_FIELD];
87
- } catch {
88
- return null;
89
- }
90
- const root = declared === undefined ? DEFAULT_PAPERS_ROOT : declared;
91
- if (typeof root !== "string" || root.length === 0) return null;
92
- return root;
93
- };
94
-
95
- /**
96
- * The shipped skills, one per line as name, a tab, and the description, read from the package's own
97
- * skills folder (the consumer's node_modules copy; in this repository, its own folder). The list used
98
- * to be typed into this file and drifted: a skill added to the package never reached the nudge.
99
- * An empty result (no folder, no skills) leaves the list out and keeps the rest of the message.
100
- */
101
- const READ_SKILLS =
102
- `d="\${CLAUDE_PROJECT_DIR:-.}/node_modules/paperlint/skills"; [ -d "$d" ] || d="\${CLAUDE_PROJECT_DIR:-.}/skills"; ` +
103
- `for f in "$d"/*/SKILL.md; do [ -f "$f" ] || continue; ` +
104
- `awk 'NR==1 && $0!="---" {exit} NR>1 && $0=="---" {exit} ` +
105
- `/^name: / {n=substr($0, 7)} /^description: / {d=substr($0, 14)} END {if (n!="") print n "\t" d}' "$f"; done`;
106
-
107
- /** One line per skill: its name and the description's first clause, at most 110 characters. */
108
- export const skillLines = (raw) =>
109
- String(raw ?? "")
110
- .split("\n")
111
- .map((l) => l.split("\t"))
112
- .filter(([name]) => /^[a-z0-9-]+$/.test(name))
113
- .map(([name, desc = ""]) => {
114
- const clause = desc
115
- .replace(/^["']|["']$/g, "")
116
- .replace(/\\"/g, '"')
117
- .split(/ — |\. /)[0];
118
- return ` • ${name} — ${clause.length > 110 ? `${clause.slice(0, 107)}...` : clause}`;
119
- });
120
-
121
- /** A path or root in one spelling: no leading "./", no doubled or trailing separators. */
122
- const tidy = (p) =>
123
- p
124
- .replace(/^(\.\/+)+/, "")
125
- .replace(/\/{2,}/g, "/")
126
- .replace(/\/+$/, "");
127
-
128
- /**
129
- * The paper a path belongs to: the first folder under the papers root, when the file sits inside one.
130
- * A file directly in the root (its README) belongs to no paper and stays silent. The path comes in
131
- * every spelling the event has (repo-relative and as sent), and the root in any spelling the config
132
- * allows (with a leading dot-slash, doubled slashes, absolute); the first spelling under the root wins.
133
- */
134
- export const paperOf = (paths, root) => {
135
- const prefix = `${tidy(root)}/`;
136
- const names = paths
137
- .filter((p) => typeof p === "string")
138
- .map(tidy)
139
- .filter((p) => p.startsWith(prefix))
140
- .map((p) => p.slice(prefix.length).split("/"))
141
- .map((parts) => (parts.length >= 2 ? parts[0] : null));
142
- return names.length ? names[0] : null;
143
- };
144
-
145
- /** How long one paper stays nudged. Touching a different paper speaks again at once. */
146
- const QUIET_FOR = "3h";
147
-
148
- export const message = (paper, lines) =>
149
- `📄 Working on paper "${paper}". Before deciding a step yourself, check whether a skill owns it ` +
150
- "(Skill tool) — a hand-written brief or a winged review is how pipeline stages get skipped.\n" +
151
- " → Update <paper-dir>/PIPELINE-STATUS.md: mark the row for any stage you (re)ran, and read its\n" +
152
- " verdict line to see what's still ☐/◐/⚠ before submit.\n" +
153
- (lines.length
154
- ? `The paper skills shipped with this package:\n${lines.join("\n")}\n`
155
- : "") +
156
- "RULES earned the hard way:\n" +
157
- " • After every aggressive rewrite/thinning pass → claim-preservation DIFF vs the pre-pass baseline\n" +
158
- " • Numbers overwhelming the reader? secondary numbers live in the artifact, not the paper\n" +
159
- " • bib inside \\begin{filecontents*}{refs.bib}? edit it THERE — refs.bib is overwritten on build\n" +
160
- " • Done + claim-clean + page-legal ships. Further churn breaks about as much as it fixes.";
161
-
162
- export default experimental_defineReact({
163
- on: "PostToolUse",
164
- // Read too: the moment a paper is opened is when its skills are worth knowing, before anything is
165
- // decided — an edit-only trigger fires after the decision.
166
- match: tools("Read", "Edit", "Write", "MultiEdit"),
167
- // The provider is anchored to the project root (`READ_CONFIG`, above).
168
- //
169
- // ⚠️ THE FAILURE HERE IS SILENT, which makes it more dangerous than its neighbor's.
170
- // `paper-edit-guard` on PreToolUse DENIES loudly and visibly when the declaration is
171
- // unreadable. This hook on PostToolUse just returns `nothing()`, i.e. simply stops firing:
172
- // the `cat` fails → empty string → `JSON.parse("")` throws → `papersRoot` returns null
173
- // → silence. And silence is exactly what a nudge's success state looks like, so a dead hook
174
- // is indistinguishable from a working one.
175
- needs: [
176
- provide("config", READ_CONFIG),
177
- provide("skills", READ_SKILLS),
178
- state("paper-skills.shown"),
179
- ],
180
- react: (e) => {
181
- const root = papersRoot(e.ctx.config);
182
- if (root === null || !e.path.under([tidy(root)])) return nothing();
183
- const paper = paperOf([e.path.rel, e.path.raw], root);
184
- if (paper === null) return nothing();
185
- const shown = e.ctx["paper-skills.shown"];
186
- // Once per paper: the same paper again within QUIET_FOR stays silent; another paper speaks.
187
- if (shown.value === paper && shown.fresherThan(QUIET_FOR)) return nothing();
188
- return notice(
189
- message(paper, skillLines(e.ctx.skills)),
190
- record("paper-skills.shown", paper),
191
- );
192
- },
193
- });
@@ -1,122 +0,0 @@
1
- /**
2
- * paper-skills-nudge on the declarations the hooks harness does not carry: none at all (the
3
- * default `papers/` root applies) and one that does not parse (silence — a nudge never blocks).
4
- */
5
- import assert from "node:assert/strict";
6
- import { join } from "node:path";
7
- import { test } from "vitest";
8
- import { hookConsumer, onEdit, runShippedHook } from "../test/hook-consumer.ts";
9
- import { useTempDir } from "../test/support.ts";
10
- import { message, paperOf, skillLines } from "./paper-skills-nudge.hook.mjs";
11
-
12
- const root = useTempDir("paper-skills-nudge-");
13
-
14
- test("no paperlint.json: an edit to papers/<p>/paper.tex gets the checklist", () => {
15
- const dir = hookConsumer(join(root, "default"));
16
- const r = runShippedHook(
17
- "paper-skills-nudge",
18
- onEdit("papers/alpha/paper.tex"),
19
- dir,
20
- );
21
- assert.equal(r.exitCode, 0);
22
- assert.notEqual(r.stdout, "");
23
- });
24
-
25
- test("a paperlint.json that does not parse: silent, exit 0", () => {
26
- const dir = hookConsumer(join(root, "broken"), {
27
- "paperlint.json": "{ nope",
28
- });
29
- const r = runShippedHook(
30
- "paper-skills-nudge",
31
- onEdit("papers/alpha/paper.tex"),
32
- dir,
33
- );
34
- assert.deepEqual([r.exitCode, r.stdout, r.stderr], [0, "", ""]);
35
- });
36
-
37
- test("a file directly under the papers root belongs to no paper: silent", () => {
38
- const dir = hookConsumer(join(root, "root-file"));
39
- const r = runShippedHook(
40
- "paper-skills-nudge",
41
- onEdit("papers/README.md"),
42
- dir,
43
- );
44
- assert.deepEqual([r.exitCode, r.stdout, r.stderr], [0, "", ""]);
45
- });
46
-
47
- test("any file of a paper, not only its source: the checklist", () => {
48
- const dir = hookConsumer(join(root, "any-file"));
49
- const r = runShippedHook(
50
- "paper-skills-nudge",
51
- onEdit("papers/alpha/notes.txt"),
52
- dir,
53
- );
54
- assert.equal(r.exitCode, 0);
55
- assert.match(r.stdout, /Working on paper \\"alpha\\"/);
56
- });
57
-
58
- // ── the pure helpers, on the inputs the shipped run never sends ─────────────────────────────
59
-
60
- test("skillLines: a missing provider result is no skills, not a crash", () => {
61
- assert.deepEqual(skillLines(undefined), []);
62
- });
63
-
64
- test("skillLines: a line that is not a skill name is dropped; a name without a description stays", () => {
65
- assert.deepEqual(skillLines("Not A Name\tx\nbare-name"), [
66
- " • bare-name — ",
67
- ]);
68
- });
69
-
70
- test("skillLines: a quoted description is unquoted and cut at its first clause, at most 110 characters", () => {
71
- const long = "a".repeat(200);
72
- assert.deepEqual(
73
- skillLines(`quoted\t"Say \\"hi\\" — then more"\nlong\t${long}`),
74
- [' • quoted — Say "hi"', ` • long — ${"a".repeat(107)}...`],
75
- );
76
- });
77
-
78
- test("paperOf: only a file inside a paper folder belongs to a paper", () => {
79
- assert.deepEqual(
80
- [
81
- paperOf([undefined], "papers"),
82
- paperOf(["elsewhere/alpha/x.tex"], "papers"),
83
- paperOf(["papers/README.md"], "papers"),
84
- paperOf(["papers/alpha/x.tex"], "papers/"),
85
- ],
86
- [null, null, null, "alpha"],
87
- );
88
- });
89
-
90
- test("message: with no skills found, the list is left out and the rest stays", () => {
91
- const m = message("alpha", []);
92
- assert.equal(m.includes("shipped with this package"), false);
93
- assert.match(m, /RULES earned the hard way/);
94
- });
95
-
96
- test("paperOf: the root in any spelling the path check accepts — ./, doubled slashes, absolute", () => {
97
- assert.deepEqual(
98
- [
99
- paperOf(["papers/alpha/x.tex"], "./papers"),
100
- paperOf(["papers/alpha/x.tex"], ".//papers//"),
101
- paperOf(
102
- ["papers/alpha/x.tex", "/repo/papers/alpha/x.tex"],
103
- "/repo/papers",
104
- ),
105
- paperOf(["papers/README.md", "/repo/papers/README.md"], "/repo/papers"),
106
- ],
107
- ["alpha", "alpha", "alpha", null],
108
- );
109
- });
110
-
111
- test("a ./-spelled papersDir: the checklist still lands", () => {
112
- const dir = hookConsumer(join(root, "dot-slash"), {
113
- "paperlint.json": JSON.stringify({ papersDir: "./papers" }),
114
- });
115
- const r = runShippedHook(
116
- "paper-skills-nudge",
117
- onEdit("papers/alpha/paper.tex"),
118
- dir,
119
- );
120
- assert.equal(r.exitCode, 0);
121
- assert.match(r.stdout, /Working on paper/);
122
- });
@@ -1,215 +0,0 @@
1
- /**
2
- * trigger-ledger.mjs — "this description was measured, here is when and with what result".
3
- *
4
- * WHY. Trigger evals cost money and are therefore not in CI ("Not CI. Run it deliberately" —
5
- * that is what every `*.eval.mjs` says). The consequence, measured 2026-08-28: recall is a
6
- * quantity obtained ONCE, not one that is maintained. Let anyone reword a `description`
7
- * tomorrow — nobody will ever catch the firing regression, because there is nothing and
8
- * nobody to catch it with.
9
- *
10
- * 🔴 WHY THE READY-MADE `skillHash()` WAS NOT TAKEN. It hashes the WHOLE skill directory
11
- * (`.md`, `.mjs`, `.sh`, `.py`, `.ts`). EXACTLY ONE FIELD affects the model's choice of a
12
- * skill — `description`: the eval kit sets `stubSkillBodies: true` with the comment
13
- * "selection is decided by frontmatter; don't run the body". Had we taken the whole
14
- * directory, the gate would redden at a typo in the body and at every new harness, that is,
15
- * almost always. A check that is red for no reason lives one day, gets silenced, and the hole
16
- * comes back, this time unnoticed. So the field is what gets hashed.
17
- *
18
- * ⚠️ WHAT THIS LEDGER DOES NOT KNOW. It does not know that a description got BETTER or WORSE
19
- * — only that it is DIFFERENT. The verdict still comes from the paid run; all that is
20
- * recorded here is that the run relates to this text and not to some earlier one.
21
- *
22
- * vigiles:local-by-design — the generic version ("coverage must cover the eval tier, not only
23
- * the harness") belongs to the product: `.vigiles/coverage.json` is written by the CLI from a
24
- * completed run, while `*.eval.mjs` are started as `node <file>` past the CLI, so there are
25
- * ZERO evals there against 50 harness records (measured 2026-08-28). What stays here is ours:
26
- * WHICH of our descriptions were measured and with what number.
27
- */
28
- import { createHash } from "node:crypto";
29
- import { existsSync, readFileSync, writeFileSync } from "node:fs";
30
- import { join } from "node:path";
31
- import {
32
- consumerRoot,
33
- installedSkills,
34
- } from "../skills/paper-pipeline/scripts/consumer.mjs";
35
-
36
- // The CONSUMER's root, not this file's grandparent — see the same note in `skill-corpus.mjs`.
37
- // The ledger itself (`.claude/skill-trigger-runs.json`) is the consumer's DATA and stays there;
38
- // only the code that reads and writes it lives here.
39
- export const ROOT = consumerRoot();
40
- export const LEDGER = join(ROOT, ".claude", "skill-trigger-runs.json");
41
- const SKILLS = join(ROOT, ".claude", "skills");
42
-
43
- // THE DEBT BASELINE WAS DELETED 2026-08-28. A ratchet with 24 names "never measured once"
44
- // stood here — and it was a way of not doing the work. The corpus owner: "a ratchet again, fuck…
45
- // let's just fix it properly". All 24 were run (~40 min of machine time, $0 metered —
46
- // subscription), the debt is paid off, the check became an ordinary gate. Its meaning changed
47
- // with that: it was "the debt does not grow", it became "a measurement must relate to the
48
- // current description". The same transition as the markdown-regex debt, and for the same
49
- // reason — paying it off is cheaper than servicing it.
50
-
51
- /** The exact text of `description:` from the frontmatter. Empty string if the field is absent. */
52
- export function descriptionOf(skill) {
53
- const p = join(SKILLS, skill, "SKILL.md");
54
- if (!existsSync(p)) return "";
55
- const src = readFileSync(p, "utf8");
56
- const fm = src.match(/^---\r?\n([\s\S]*?)\r?\n---/);
57
- if (!fm) return "";
58
- // description may be multi-line, up to the next top-level key
59
- const m = fm[1].match(
60
- /^description:[ \t]*([\s\S]*?)(?=\r?\n[a-zA-Z_-]+:|$)/m,
61
- );
62
- return m ? m[1].trim() : "";
63
- }
64
-
65
- export const hashOf = (s) =>
66
- createHash("sha256").update(s).digest("hex").slice(0, 16);
67
-
68
- /**
69
- * A hash of the WHOLE set of descriptions — "against whom it was measured".
70
- *
71
- * 🔴 Why a second mark (the corpus owner's question, 2026-08-28). A trigger eval measures the
72
- * model's CHOICE out of all installed descriptions — the kit says exactly that: "whole-harness by
73
- * construction… an isolated measurement OVERSTATES recall and UNDERSTATES false positives". So my
74
- * recall can go stale from an edit to a NEIGHBOUR'S DESCRIPTION: it starts winning my prompts
75
- * while my own description does not change by a single character. A hash of my own field is not
76
- * enough for that.
77
- *
78
- * ⚠️ But hashing the corpus STRICTLY is not allowed either: one edit to any description would
79
- * void every record at once, and the check would again be always-red. Hence the different
80
- * loudness:
81
- * my own description changed → THE MEASUREMENT IS INVALID (an error);
82
- * the set of competitors changed → the measurement WEAKENED (a note in the ledger, no shouting).
83
- */
84
- export function corpusHash() {
85
- const names = installedSkills(SKILLS);
86
- return hashOf(
87
- names.map((n) => n + "\u0000" + descriptionOf(n)).join("\u0001"),
88
- );
89
- }
90
-
91
- export const readLedger = () =>
92
- existsSync(LEDGER)
93
- ? JSON.parse(readFileSync(LEDGER, "utf8"))
94
- : { v: 1, runs: {} };
95
-
96
- /** Record a measurement that happened. Called by the kit AFTER the run, not before. */
97
- export function recordRun(skill, { recall, precision, model, trials }) {
98
- const l = readLedger();
99
- l.runs[skill] = {
100
- description_sha: hashOf(descriptionOf(skill)),
101
- corpus_sha: corpusHash(),
102
- measured_at: new Date().toISOString().slice(0, 10),
103
- recall,
104
- precision,
105
- model,
106
- trials,
107
- };
108
- writeFileSync(LEDGER, JSON.stringify(l, null, 2) + "\n");
109
- return l.runs[skill];
110
- }
111
-
112
- /**
113
- * Skills that HAVE an `*.eval.mjs` but whose measurement does not relate to the current
114
- * description. Returns [{skill, reason}]. `reason` — 'never' or 'changed'.
115
- */
116
- export function staleSkills(skillsWithEval) {
117
- const l = readLedger();
118
- const out = [];
119
- for (const s of skillsWithEval) {
120
- const rec = l.runs[s];
121
- if (!rec) {
122
- out.push({ skill: s, reason: "never" });
123
- continue;
124
- }
125
- if (rec.description_sha !== hashOf(descriptionOf(s))) {
126
- out.push({ skill: s, reason: "changed", measured_at: rec.measured_at });
127
- continue;
128
- }
129
- // The skill's own description is the same but the competitors differ — the measurement
130
- // weakened, it did not die.
131
- if (rec.corpus_sha && rec.corpus_sha !== corpusHash())
132
- out.push({
133
- skill: s,
134
- reason: "corpus",
135
- measured_at: rec.measured_at,
136
- soft: true,
137
- });
138
- }
139
- return out;
140
- }
141
-
142
- // ── CLI: `node .claude/lib/trigger-ledger.mjs --check` ────────────────────────────
143
- // Cheap: no model, no network — only reading frontmatter and comparing hashes.
144
- // That is exactly why this can be kept in CI, unlike the evals themselves.
145
- if (process.argv[1] && process.argv[1].endsWith("trigger-ledger.mjs")) {
146
- const withEval = installedSkills(SKILLS).filter((d) =>
147
- existsSync(join(SKILLS, d, `${d}.eval.mjs`)),
148
- );
149
- // A RATCHET, not a gate. Measured 2026-08-28 on a clean tree: 24 findings "never measured
150
- // once" — for the paper skills firing had been measured earlier, just not into this ledger,
151
- // which is five minutes old. A check with 24 red lines on its first day does not get read, it
152
- // gets silenced: that is exactly how the markdown-regex debt already died in this repo, and
153
- // there it was turned into a ratchet.
154
- //
155
- // So: "the description changed after the measurement" — LOUD ALWAYS, that is the very
156
- // regression all of this was started for. "Never measured once" — loud only for skills that
157
- // are not in the debt baseline, that is, for NEW ones. The debt does not grow silently, but it
158
- // does not shout on every run either.
159
- const all = staleSkills(withEval);
160
- const soft = all.filter((x) => x.soft);
161
- const stale = all.filter((x) => !x.soft);
162
- // ONE line, not one line per skill. Measured 2026-08-28: an edit to ONE description changes
163
- // the corpus hash as a whole, and per-line output produced 27 notes at once. Twenty-seven
164
- // informational lines per edit is noise, and noise gets silenced; and then the hard half stops
165
- // being read along with it.
166
- // Three names + a counter, not only a counter and not 27 lines. A bare counter cannot be
167
- // checked and gives nothing to start a re-measurement from; one line per skill is 27 lines of
168
- // noise per edit (measured 2026-08-28). The assertion "the note is addressed" in the harness
169
- // requires exactly the names — and it was RED from 2026-08-28 to 2026-08-31, because the code
170
- // printed only the counter: the harness was written, declared working, and not run.
171
- if (soft.length) {
172
- const names = soft
173
- .slice(0, 3)
174
- .map((x) => x.skill)
175
- .join(", ");
176
- console.log(
177
- `ℹ️ the set of competing descriptions changed after the last measurement — ` +
178
- `for ${soft.length} skill(s) recall may have shifted without their own description being ` +
179
- `touched (${names}${soft.length > 3 ? ` and ${soft.length - 3} more` : ""}). ` +
180
- `Not an error: re-measure when convenient.`,
181
- );
182
- }
183
- // 🔴 THE DENOMINATOR IS MANDATORY. The line "✓ current for 27" reads as "27 skills are fine",
184
- // whereas the true statement is "27 of 50 fall under this check at all": a skill without its
185
- // own .eval.mjs is inexpressible for this gate, there is nothing to re-measure for it.
186
- // Measured 2026-08-31: 50 skills on disk, 27 with an eval, 23 without. That day I changed the
187
- // description of telegram-channel-audit (no eval), the gate printed green, and that looked
188
- // like "the change was verified". A counter that does not name what it ignores lies — the
189
- // CLAUDE.md rule §"A counter that counts what it IGNORES".
190
- const total = installedSkills(SKILLS).length;
191
- const noEval = total - withEval.length;
192
- if (!stale.length) {
193
- console.log(
194
- `✓ trigger measurements are current for ${withEval.length} skill(s) of ${total}` +
195
- (noEval
196
- ? ` — the other ${noEval} have NO .eval.mjs of their own, they are outside this ` +
197
- `check by construction (nothing to measure, not "fine")`
198
- : ""),
199
- );
200
- process.exit(0);
201
- }
202
- for (const s of stale) {
203
- console.error(
204
- s.reason === "never"
205
- ? `✗ ${s.skill}: ${s.skill}.eval.mjs exists, but a firing measurement NEVER happened`
206
- : `✗ ${s.skill}: description changed after the ${s.measured_at} measurement — recall relates to the former text`,
207
- );
208
- }
209
- console.error(
210
- `\nRun it: node .claude/skills/<skill>/<skill>.eval.mjs` +
211
- `\nThis is the paid tier (a real model), so CI does not run it — it only requires that a run ` +
212
- `exists and relates to the current description.`,
213
- );
214
- process.exit(1);
215
- }