paperlint 19.0.3 → 20.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +1 -1
- package/dist/cli.d.ts +7 -4
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +31 -18
- package/dist/cli.js.map +1 -1
- package/dist/domain/paper-stage.d.ts +20 -0
- package/dist/domain/paper-stage.d.ts.map +1 -0
- package/dist/domain/paper-stage.js +9 -0
- package/dist/domain/paper-stage.js.map +1 -0
- package/dist/eslint-rules/CLAUDE.md.spec.d.ts.map +1 -1
- package/dist/eslint-rules/CLAUDE.md.spec.js +1 -0
- package/dist/eslint-rules/CLAUDE.md.spec.js.map +1 -1
- package/dist/paper-files.d.ts +2 -1
- package/dist/paper-files.d.ts.map +1 -1
- package/dist/paper-files.js +1 -0
- package/dist/paper-files.js.map +1 -1
- package/dist/rules-config.d.ts +6 -0
- package/dist/rules-config.d.ts.map +1 -1
- package/dist/rules-config.js.map +1 -1
- package/dist/settled-paper.d.ts +6 -0
- package/dist/settled-paper.d.ts.map +1 -0
- package/dist/settled-paper.js +69 -0
- package/dist/settled-paper.js.map +1 -0
- package/docs/configuration.md +17 -3
- package/docs/rules/paper/edition-over.md +4 -3
- package/eslint-rules/CLAUDE.md +5 -1
- package/eslint-rules/CLAUDE.md.spec.ts +3 -0
- package/lib/skill-eval-kit.mjs +0 -14
- package/package.json +1 -2
- package/scripts/coverage-config.test.ts +0 -1
- package/src/cli.ts +39 -21
- package/src/domain/paper-stage.ts +25 -0
- package/src/paper-files.ts +8 -1
- package/src/paper-settings-commands.test.ts +13 -16
- package/src/rules-config.ts +8 -0
- package/src/settled-paper.test.ts +214 -0
- package/src/settled-paper.ts +78 -0
- package/lib/trigger-ledger.mjs +0 -215
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A paper's stage, read from its `cycles` and `versions/lock.json`, adds rule blocks after its venue
|
|
3
|
+
* preset's (#583, #553): the rules stay what they are, the config decides where they run.
|
|
4
|
+
*/
|
|
5
|
+
import assert from "node:assert/strict";
|
|
6
|
+
import { readFileSync } from "node:fs";
|
|
7
|
+
import { join } from "node:path";
|
|
8
|
+
import { test } from "vitest";
|
|
9
|
+
import { useTempDir, writeTree } from "../test/support.ts";
|
|
10
|
+
import { paperRuleBlocks, run } from "./cli.ts";
|
|
11
|
+
import { currentCycle, parseCycles } from "./domain/cycle.ts";
|
|
12
|
+
import { paperStage } from "./domain/paper-stage.ts";
|
|
13
|
+
import { lockText } from "./domain/versions.ts";
|
|
14
|
+
|
|
15
|
+
const root = useTempDir("settled-paper-");
|
|
16
|
+
|
|
17
|
+
const CYCLE = {
|
|
18
|
+
id: "alpha-2026",
|
|
19
|
+
venue: { kind: "named", name: "Alpha 2026", url: "https://alpha.example" },
|
|
20
|
+
opened: "2026-07-01",
|
|
21
|
+
submission: { id: 3 },
|
|
22
|
+
};
|
|
23
|
+
const OPEN = { ...CYCLE, outcome: { kind: "open" } };
|
|
24
|
+
const ACCEPTED = {
|
|
25
|
+
...CYCLE,
|
|
26
|
+
outcome: { kind: "accepted", date: "2026-08-21", evidence: "m.eml" },
|
|
27
|
+
};
|
|
28
|
+
const REJECTED = {
|
|
29
|
+
...CYCLE,
|
|
30
|
+
outcome: {
|
|
31
|
+
kind: "rejected",
|
|
32
|
+
date: "2026-08-21",
|
|
33
|
+
evidence: "m.eml",
|
|
34
|
+
desk: true,
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
const FROZEN = {
|
|
38
|
+
kind: "file" as const,
|
|
39
|
+
bytes: 4,
|
|
40
|
+
sha256: "0".repeat(64),
|
|
41
|
+
frozen: "2026-08-29",
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/** One paper: its cycles, and the lock entries of its frozen files. */
|
|
45
|
+
function paper(
|
|
46
|
+
name: string,
|
|
47
|
+
cycles: readonly object[],
|
|
48
|
+
frozen: readonly string[],
|
|
49
|
+
): string {
|
|
50
|
+
const dir = writeTree(join(root, name), {
|
|
51
|
+
"p/paper.tex": "% p\n",
|
|
52
|
+
"p/PIPELINE-STATUS.md": "# status\n",
|
|
53
|
+
"p/paperlint.json": JSON.stringify({ cycles }),
|
|
54
|
+
"p/versions/lock.json": lockText(
|
|
55
|
+
Object.fromEntries(frozen.map((k) => [k, FROZEN])),
|
|
56
|
+
),
|
|
57
|
+
});
|
|
58
|
+
return join(dir, "p");
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** The blocks the paper's stage adds. */
|
|
62
|
+
function stageBlocks(dir: string) {
|
|
63
|
+
const r = paperRuleBlocks([dir]);
|
|
64
|
+
assert.ok(r.ok, r.ok ? "" : r.error);
|
|
65
|
+
return r.value.stage;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const off = (b: { readonly rules: Readonly<Record<string, unknown>> }) =>
|
|
69
|
+
Object.entries(b.rules).filter(([, v]) => v === "off");
|
|
70
|
+
|
|
71
|
+
test("a final paper — accepted, camera-ready frozen — turns its text and build rules off, keeps its record rules, and edition-over goes", () => {
|
|
72
|
+
const dir = paper("final", [ACCEPTED], ["alpha-2026/camera-ready.pdf"]);
|
|
73
|
+
const blocks = stageBlocks(dir);
|
|
74
|
+
const tex = blocks.find((b) => b.files?.includes("**/*.tex"));
|
|
75
|
+
assert.ok(tex, JSON.stringify(blocks));
|
|
76
|
+
assert.equal(tex.basePath, dir);
|
|
77
|
+
const texOff = new Set(off(tex).map(([id]) => id));
|
|
78
|
+
for (const id of ["pdf/fresh", "pdf/last-page-balance", "pdf/measured"])
|
|
79
|
+
assert.ok(texOff.has(id), id);
|
|
80
|
+
// The record of attempts is what a final paper is judged on: whether its camera-ready came from
|
|
81
|
+
// what was accepted.
|
|
82
|
+
for (const id of ["tex/max-sentence-words", "bib/reachable-entry"])
|
|
83
|
+
assert.ok(texOff.has(id), id);
|
|
84
|
+
// What is still delivered after the camera-ready (the talk, the public artifact) and the records
|
|
85
|
+
// (attempts, the lock, the study) keep their rules: freezing the PDF says nothing about them.
|
|
86
|
+
for (const id of [
|
|
87
|
+
"cycle/camera-ready-source",
|
|
88
|
+
"cycle/draft-drift",
|
|
89
|
+
"talk/required-files",
|
|
90
|
+
"artifact/upload-current",
|
|
91
|
+
"versions/layout",
|
|
92
|
+
"repro/study-result",
|
|
93
|
+
])
|
|
94
|
+
assert.ok(!texOff.has(id), id);
|
|
95
|
+
assert.deepEqual(
|
|
96
|
+
blocks.filter((b) => b.files === undefined).map((b) => b.rules),
|
|
97
|
+
[{ "paper/edition-over": "off" }],
|
|
98
|
+
);
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
test("an accepted paper whose camera-ready is not frozen keeps its build rules; only edition-over goes", () => {
|
|
102
|
+
const dir = paper("camera-ready", [ACCEPTED], []);
|
|
103
|
+
assert.deepEqual(stageBlocks(dir), [
|
|
104
|
+
{ basePath: dir, rules: { "paper/edition-over": "off" } },
|
|
105
|
+
]);
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
test("an open or rejected paper — still being written — adds no block", () => {
|
|
109
|
+
assert.deepEqual(stageBlocks(paper("open", [OPEN], [])), []);
|
|
110
|
+
assert.deepEqual(
|
|
111
|
+
stageBlocks(paper("rejected", [REJECTED], ["alpha-2026/camera-ready.pdf"])),
|
|
112
|
+
[],
|
|
113
|
+
);
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
test("no cycles, or a lock that is missing or not JSON, is not a final paper", () => {
|
|
117
|
+
const dir = writeTree(join(root, "unlocked"), {
|
|
118
|
+
"none/paper.tex": "% p\n",
|
|
119
|
+
"missing/paper.tex": "% p\n",
|
|
120
|
+
"missing/paperlint.json": JSON.stringify({ cycles: [ACCEPTED] }),
|
|
121
|
+
"broken/paper.tex": "% p\n",
|
|
122
|
+
"broken/paperlint.json": JSON.stringify({ cycles: [ACCEPTED] }),
|
|
123
|
+
"broken/versions/lock.json": "{ not json",
|
|
124
|
+
});
|
|
125
|
+
assert.deepEqual(stageBlocks(join(dir, "none")), []);
|
|
126
|
+
for (const name of ["missing", "broken"])
|
|
127
|
+
assert.deepEqual(stageBlocks(join(dir, name)), [
|
|
128
|
+
{ basePath: join(dir, name), rules: { "paper/edition-over": "off" } },
|
|
129
|
+
]);
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
test("paperStage: working, accepted, final", () => {
|
|
133
|
+
const parsed = parseCycles([ACCEPTED]);
|
|
134
|
+
assert.ok(parsed.ok && parsed.value !== null);
|
|
135
|
+
const current = currentCycle(parsed.value);
|
|
136
|
+
assert.ok(current.ok);
|
|
137
|
+
const frozen = { "alpha-2026/camera-ready.pdf": FROZEN };
|
|
138
|
+
assert.equal(paperStage(current.value, frozen), "final");
|
|
139
|
+
assert.equal(paperStage(current.value, {}), "accepted");
|
|
140
|
+
assert.equal(paperStage({ kind: "none" }, frozen), "working");
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
/** `paperlint lint [flags] papers/p` in `cwd`: its exit code and what it printed. */
|
|
144
|
+
async function lint(cwd: string, ...flags: readonly string[]) {
|
|
145
|
+
const out: string[] = [];
|
|
146
|
+
const code = await run(["lint", ...flags, "papers/p"], {
|
|
147
|
+
log: (...a: unknown[]) => out.push(a.join(" ")),
|
|
148
|
+
err: (...a: unknown[]) => out.push(a.join(" ")),
|
|
149
|
+
cwd,
|
|
150
|
+
now: () => 0,
|
|
151
|
+
install: {
|
|
152
|
+
command: (_r, spec) => ["npm", spec],
|
|
153
|
+
run: () => ({ ok: true }),
|
|
154
|
+
},
|
|
155
|
+
claude: {
|
|
156
|
+
present: () => false,
|
|
157
|
+
plugin: () => ({ enabled: false, version: null }),
|
|
158
|
+
enable: () => assert.fail("lint does not touch the plugin"),
|
|
159
|
+
},
|
|
160
|
+
});
|
|
161
|
+
return { code, out: out.join("\n") };
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
const LONG = Array.from({ length: 70 }, () => "word").join(" ");
|
|
165
|
+
const TEX = `\\documentclass{article}\n\\begin{document}\n${LONG}.\n\\end{document}\n`;
|
|
166
|
+
const ON = { "tex/max-sentence-words": "warn" };
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* A project with one paper whose text has a 70-word sentence. `at: "root"` turns the writing rule on
|
|
170
|
+
* for every paper by a glob in the ROOT paperlint.json; `at: "own"` in the paper's own.
|
|
171
|
+
*/
|
|
172
|
+
function project(
|
|
173
|
+
name: string,
|
|
174
|
+
cycles: readonly object[],
|
|
175
|
+
at: "root" | "own" = "root",
|
|
176
|
+
tex: string = TEX,
|
|
177
|
+
): string {
|
|
178
|
+
const rootRules =
|
|
179
|
+
at === "root" ? [{ files: ["papers/*/paper.tex"], rules: ON }] : [];
|
|
180
|
+
return writeTree(join(root, name), {
|
|
181
|
+
"package.json": "{}",
|
|
182
|
+
"paperlint.json": JSON.stringify({ papersDir: "papers", rules: rootRules }),
|
|
183
|
+
"papers/p/PIPELINE-STATUS.md": "# status\n",
|
|
184
|
+
"papers/p/paper.tex": tex,
|
|
185
|
+
"papers/p/paperlint.json": JSON.stringify(
|
|
186
|
+
at === "own" ? { cycles, rules: ON } : { cycles },
|
|
187
|
+
),
|
|
188
|
+
"papers/p/versions/lock.json": lockText({
|
|
189
|
+
"alpha-2026/camera-ready.pdf": FROZEN,
|
|
190
|
+
}),
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
test("lint: the root's glob reaches a paper being written, and not a final one — the stage comes after the root", async () => {
|
|
195
|
+
const open = await lint(project("lint-open", [OPEN]));
|
|
196
|
+
assert.match(open.out, /tex\/max-sentence-words/);
|
|
197
|
+
const final = await lint(project("lint-final", [ACCEPTED]));
|
|
198
|
+
assert.doesNotMatch(final.out, /max-sentence-words/);
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
test("lint: a writing rule the paper turns on in its OWN settings is off on a final paper too — the stage comes last", async () => {
|
|
202
|
+
const open = await lint(project("own-open", [OPEN], "own"));
|
|
203
|
+
assert.match(open.out, /tex\/max-sentence-words/);
|
|
204
|
+
const final = await lint(project("own-final", [ACCEPTED], "own"));
|
|
205
|
+
assert.doesNotMatch(final.out, /max-sentence-words/);
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
test("lint --fix: a disable comment on a final paper is not reported unused, and the published text is not rewritten", async () => {
|
|
209
|
+
const tex = `\\documentclass{article}\n\\begin{document}\n% eslint-disable-next-line tex/max-sentence-words\n${LONG}.\n\\end{document}\n`;
|
|
210
|
+
const dir = project("directive-final", [ACCEPTED], "root", tex);
|
|
211
|
+
const r = await lint(dir, "--fix");
|
|
212
|
+
assert.doesNotMatch(r.out, /[Uu]nused eslint-disable/);
|
|
213
|
+
assert.equal(readFileSync(join(dir, "papers/p/paper.tex"), "utf8"), tex);
|
|
214
|
+
});
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The rule blocks a paper's stage adds (#583, #553).
|
|
3
|
+
*
|
|
4
|
+
* A rule judges its own subject and knows nothing about where a paper is in its life. Whether it
|
|
5
|
+
* should run on a paper that is done is a question about WHICH FILES a rule runs on, and in ESLint
|
|
6
|
+
* that is the config's question. So the stage (`src/domain/paper-stage.ts`) becomes blocks here, in
|
|
7
|
+
* the one place that already reads every paper's `paperlint.json` to build its blocks:
|
|
8
|
+
*
|
|
9
|
+
* accepted `paper/edition-over` off: the edition being over is where an accepted paper ends up
|
|
10
|
+
* final also every rule about the text and the build off on the paper's `.tex`: the published
|
|
11
|
+
* text and PDF are frozen in `versions/`, so "rebuild", "too long" or "not built yet" has
|
|
12
|
+
* nothing left to fix. The talk, the artifact and the records keep their rules
|
|
13
|
+
*
|
|
14
|
+
* The blocks go LAST, after the root `paperlint.json` and after the paper's own `rules`: a writing
|
|
15
|
+
* rule turned on while the paper was written, at either level, says nothing on its published text.
|
|
16
|
+
* Nothing turns a text rule back on for a final paper; the paper is worked on again in a new cycle,
|
|
17
|
+
* and an open cycle makes it `working`.
|
|
18
|
+
*/
|
|
19
|
+
import { paperStage } from "./domain/paper-stage.ts";
|
|
20
|
+
import type { Cycles } from "./domain/cycle.ts";
|
|
21
|
+
import type { Files } from "./ports/files.ts";
|
|
22
|
+
import type { RuleBlock } from "./rules-config.ts";
|
|
23
|
+
import { readLock } from "./versions.ts";
|
|
24
|
+
|
|
25
|
+
/** The paper's own `.tex` files: `paper.tex` and the files it includes. Relative to the paper. */
|
|
26
|
+
const PAPER_TEX = "**/*.tex";
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* The plugins whose rules judge the paper's TEXT and its BUILD: what the frozen camera-ready already
|
|
30
|
+
* fixed. Only these go off on a final paper. The rest stay on, because freezing the PDF says nothing
|
|
31
|
+
* about them: the talk and the public artifact are still being delivered (`talk/*`, `artifact/*`),
|
|
32
|
+
* and the records are what a final paper is judged on (`cycle/*`, `versions/*`, `repro/*`,
|
|
33
|
+
* `study/*`). A list of what goes off, not of what stays, so a new plugin stays on until someone
|
|
34
|
+
* decides it judges the frozen text.
|
|
35
|
+
*/
|
|
36
|
+
const FROZEN_TEXT_PLUGINS: readonly string[] = [
|
|
37
|
+
"tex",
|
|
38
|
+
"bib",
|
|
39
|
+
"pdf",
|
|
40
|
+
"format",
|
|
41
|
+
"anonymity",
|
|
42
|
+
"paper",
|
|
43
|
+
];
|
|
44
|
+
|
|
45
|
+
/** The blocks for the paper in `dir`, or none while it is being written. Reads the lock through `files`. */
|
|
46
|
+
export function stageBlocks(
|
|
47
|
+
dir: string,
|
|
48
|
+
cycles: Cycles | null,
|
|
49
|
+
files: Files,
|
|
50
|
+
shipped: ReadonlySet<string>,
|
|
51
|
+
): readonly RuleBlock[] {
|
|
52
|
+
if (cycles === null) return [];
|
|
53
|
+
const lock = readLock(dir, files);
|
|
54
|
+
const stage = paperStage(cycles.current, lock?.ok ? lock.value : {});
|
|
55
|
+
if (stage === "working") return [];
|
|
56
|
+
const accepted: RuleBlock = {
|
|
57
|
+
basePath: dir,
|
|
58
|
+
rules: { "paper/edition-over": "off" },
|
|
59
|
+
};
|
|
60
|
+
if (stage === "accepted") return [accepted];
|
|
61
|
+
const textOff = Object.fromEntries(
|
|
62
|
+
[...shipped]
|
|
63
|
+
.filter((id) => FROZEN_TEXT_PLUGINS.some((p) => id.startsWith(`${p}/`)))
|
|
64
|
+
.map((id) => [id, "off" as const]),
|
|
65
|
+
);
|
|
66
|
+
// A disable comment for a rule this block turns off suppresses nothing, and ESLint would report it
|
|
67
|
+
// as unused, and `--fix` would delete it from the published text: the trap `rulesOff` in cli.ts
|
|
68
|
+
// closes the same way.
|
|
69
|
+
return [
|
|
70
|
+
accepted,
|
|
71
|
+
{
|
|
72
|
+
basePath: dir,
|
|
73
|
+
files: [PAPER_TEX],
|
|
74
|
+
linterOptions: { reportUnusedDisableDirectives: "off" },
|
|
75
|
+
rules: textOff,
|
|
76
|
+
},
|
|
77
|
+
];
|
|
78
|
+
}
|
package/lib/trigger-ledger.mjs
DELETED
|
@@ -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
|
-
}
|