paperlint 20.1.1 → 20.1.2

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 (73) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/.github/workflows/ci.yml +7 -0
  3. package/CLAUDE.md +2 -2
  4. package/CONTRIBUTING.md +2 -2
  5. package/{action.harness.mjs → action.test.mjs} +147 -138
  6. package/dist/eslint-rules/papers.js +1 -1
  7. package/dist/latex-log.d.ts +1 -1
  8. package/dist/latex-log.js +1 -1
  9. package/dist/latex-loop.d.ts +1 -1
  10. package/dist/latex-loop.js +1 -1
  11. package/dist/lib/paper-config.d.ts +3 -3
  12. package/dist/lib/paper-config.js +3 -3
  13. package/docs/e2e.md +9 -9
  14. package/docs/testing.md +3 -4
  15. package/eslint-rules/{install-path-literals.harness.mjs → install-path-literals.test.mjs} +14 -13
  16. package/eslint-rules/{latex-language.harness.mjs → latex-language-rules.test.mjs} +61 -51
  17. package/eslint-rules/{paper-stages.harness.mjs → paper-stages-rule.test.mjs} +66 -69
  18. package/eslint-rules/{papers.harness.mjs → papers.test.mjs} +41 -30
  19. package/eslint-rules/papers.ts +1 -1
  20. package/eslint-rules/{pdf-last-page-balance.harness.mjs → pdf-last-page-balance.test.mjs} +27 -15
  21. package/eslint-rules/{temp-root-realpath.harness.mjs → temp-root-realpath.test.mjs} +24 -24
  22. package/eslint-rules/{tex-build.harness.mjs → tex-build.test.mjs} +292 -271
  23. package/eslint.config.mjs +15 -2
  24. package/fixtures/pdf-facts/README.md +1 -1
  25. package/fixtures/render-paper/build-clean.sh +1 -1
  26. package/fixtures/toolchain-mirror/install-tl +1 -1
  27. package/lib/{agent-cli-version.harness.mjs → agent-cli-version.test.mjs} +17 -18
  28. package/lib/{paper-config.harness.mjs → paper-config.test.mjs} +21 -20
  29. package/lib/paper-config.ts +3 -3
  30. package/lib/{skill-trigger-cases.harness.mjs → skill-trigger-cases-carrier.test.mjs} +78 -115
  31. package/package.json +3 -3
  32. package/presets/acm-acmsmall.jsonc +1 -1
  33. package/scripts/check-workflow.test.ts +368 -0
  34. package/scripts/check.ts +2 -2
  35. package/scripts/eslint-file-length.mjs +9 -9
  36. package/scripts/eslint-report-guard.mjs +1 -1
  37. package/scripts/eslint-report-guard.test.mjs +1 -1
  38. package/scripts/harness-api.test.ts +7 -46
  39. package/scripts/{rules-see-files.harness.mjs → rules-see-files-rule.test.mjs} +10 -6
  40. package/scripts/rules-see-files.mjs +1 -1
  41. package/skills/paper-pipeline/{paper-pipeline.harness.mjs → paper-pipeline.test.mjs} +45 -46
  42. package/skills/paper-pipeline/scripts/{consumer.harness.mjs → consumer-paths.test.mjs} +66 -59
  43. package/skills/paper-pipeline/scripts/consumer.mjs +3 -3
  44. package/skills/paper-pipeline/scripts/{extract-ref-facts.harness.mjs → extract-ref-facts-cli.test.mjs} +29 -31
  45. package/skills/paper-pipeline/scripts/fixtures/real-bib/refs.bib +1 -1
  46. package/skills/paper-pipeline/scripts/{generated-code.harness.mjs → generated-code-fixtures.test.mjs} +39 -46
  47. package/skills/render-paper/{extract-pdf-facts.harness.ts → extract-pdf-facts.test.ts} +20 -13
  48. package/skills/render-paper/{render-paper.harness.mjs → render-paper.test.mjs} +41 -40
  49. package/src/adapters/pdfjs/fill.test.ts +1 -1
  50. package/src/{build-engine.harness.mjs → build-engine-prepare.test.mjs} +98 -81
  51. package/src/{build.harness.mjs → build-fake-tex.test.mjs} +61 -28
  52. package/src/{cli.harness.mjs → cli-e2e.test.mjs} +108 -102
  53. package/src/cli.test.ts +1 -1
  54. package/src/{doctor.harness.mjs → doctor-install.test.mjs} +28 -29
  55. package/src/{engine.harness.mjs → engine.test.mjs} +120 -106
  56. package/src/facts-file.test.ts +1 -1
  57. package/src/{hooks-settings.harness.ts → hooks-settings.test.ts} +161 -146
  58. package/src/latex-log.test.ts +395 -0
  59. package/src/latex-log.ts +1 -1
  60. package/src/latex-loop.test.ts +553 -0
  61. package/src/latex-loop.ts +1 -1
  62. package/src/{link-skills.harness.ts → link-skills-fs.test.ts} +26 -26
  63. package/src/{new-paper.harness.mjs → new-paper-scaffold.test.mjs} +31 -19
  64. package/src/{pdf-facts.harness.ts → pdf-facts-tables.test.ts} +28 -22
  65. package/src/{pdf-geometry.harness.ts → pdf-geometry.test.ts} +93 -75
  66. package/src/{rules-config.harness.ts → rules-config.test.ts} +41 -31
  67. package/src/{structure.harness.ts → structure.test.ts} +12 -10
  68. package/src/{tex-requirements.harness.ts → tex-requirements-tables.test.ts} +106 -85
  69. package/src/{toolchain.harness.mjs → toolchain-mirror.test.mjs} +204 -186
  70. package/scripts/check.harness.ts +0 -343
  71. package/scripts/harness-api.frozen.json +0 -41
  72. package/src/latex-log.harness.ts +0 -382
  73. package/src/latex-loop.harness.ts +0 -515
@@ -1,343 +0,0 @@
1
- /**
2
- * Both halves for `npm run check` — and the half that matters is not "does it run the gates",
3
- * it is "does its list still describe the CI it claims to mirror".
4
- *
5
- * 🔴 A HANDWRITTEN LIST OF GATES IS A FOSSIL THE DAY AFTER IT IS WRITTEN. That is measured, not
6
- * feared: on 2026-09-19 eleven scripts existed with no aggregate, a subset was run from memory,
7
- * and a suite-breaking change was pushed. Writing the subset down in a doc would have produced
8
- * the same outcome one release later — the list would simply have been wrong instead of absent.
9
- *
10
- * So the assertions below do not check that `check.ts` contains the right strings. They pull
11
- * the job names OUT OF `.github/workflows/ci.yml` and require every one to be accounted for.
12
- * Add a job to CI and this goes red the same day, naming the job nobody covered.
13
- *
14
- * ⚠️ Assertions at the TOP LEVEL: `vigiles test` imports the file and counts "did not throw"
15
- * as a pass.
16
- */
17
- import { existsSync, readdirSync, readFileSync } from "node:fs";
18
- import { dirname, join } from "node:path";
19
- import { fileURLToPath } from "node:url";
20
- import { load } from "js-yaml";
21
- import { z } from "zod";
22
- import { createChecker } from "../lib/check.ts";
23
- import type { Gate } from "./check.ts";
24
-
25
- /** A workflow file, as far as these checks read it. `on` is a plain key: js-yaml reads YAML 1.2. */
26
- const Step = z.looseObject({
27
- name: z.string().optional(),
28
- run: z.string().optional(),
29
- uses: z.string().optional(),
30
- });
31
- const Workflow = z.looseObject({
32
- on: z
33
- .looseObject({
34
- pull_request: z
35
- .looseObject({ types: z.array(z.string()).optional() })
36
- .nullish(),
37
- })
38
- .optional(),
39
- jobs: z
40
- .record(
41
- z.string(),
42
- z.looseObject({
43
- "runs-on": z.string().optional(),
44
- steps: z.array(Step).optional(),
45
- strategy: z
46
- .looseObject({
47
- matrix: z
48
- .looseObject({
49
- os: z.array(z.string()).optional(),
50
- shard: z.array(z.number()).optional(),
51
- })
52
- .optional(),
53
- })
54
- .optional(),
55
- }),
56
- )
57
- .optional(),
58
- });
59
- type Workflow = z.infer<typeof Workflow>;
60
- const PackageJson = z.looseObject({
61
- scripts: z.record(z.string(), z.string()).optional(),
62
- });
63
-
64
- const HERE = dirname(fileURLToPath(import.meta.url));
65
- const ROOT = dirname(HERE);
66
-
67
- const { GATES, NOT_COVERED, outcome, skippedIn, commandOf } =
68
- await import("./check.ts");
69
-
70
- const check = createChecker();
71
-
72
- // ── the workflow is the ORACLE, not a copy of it ───────────────────────────────────────────
73
- // A skip is a THIRD outcome. Folding it into "pass" printed "all gates passed" on a machine where
74
- // the e2e never ran (Codex review on #45); folding it into "fail" would make the command red for
75
- // anyone without pnpm or TeX, and it would be ignored. The count is vitest's own, from its report.
76
- check("exit 0 of a plain gate is a pass", outcome(0) === "pass");
77
- check(
78
- "exit 0 of a vitest gate whose report counts no skip is a pass",
79
- outcome(0, { skipped: 0 }) === "pass",
80
- );
81
- check(
82
- "exit 0 of a vitest gate whose report counts skipped tests is a SKIP — neither a pass nor a failure",
83
- outcome(0, { skipped: 2 }) === "skip",
84
- );
85
- check(
86
- "🔴 exit 0 of a vitest gate with no readable report is a FAILURE — an unread count cannot be a pass",
87
- outcome(0, { skipped: null }) === "fail",
88
- );
89
- check(
90
- "any nonzero exit is a failure, skips or not",
91
- outcome(1) === "fail" &&
92
- outcome(2, { skipped: 0 }) === "fail" &&
93
- outcome(1, { skipped: 3 }) === "fail",
94
- );
95
- check(
96
- "a process killed by a signal (status null) is a failure, not a skip",
97
- outcome(null) === "fail",
98
- );
99
- check(
100
- "skippedIn counts skipped and todo tests from vitest's JSON report",
101
- skippedIn(
102
- JSON.stringify({ numTotalTests: 9, numPendingTests: 3, numTodoTests: 1 }),
103
- ) === 4 &&
104
- skippedIn(JSON.stringify({ numPendingTests: 0, numTodoTests: 0 })) === 0,
105
- );
106
- check(
107
- "skippedIn: no report, not JSON, or not vitest's shape is null — never zero",
108
- skippedIn(null) === null &&
109
- skippedIn("not json") === null &&
110
- skippedIn("{}") === null,
111
- );
112
-
113
- // Every workflow, not just ci.yml: a harness reading one file would stop seeing a job added to
114
- // another without a sound. (macOS lived in platform.yml from 2026-09-23 to 2026-09-24; it is now
115
- // a cell of ci.yml's build-e2e matrix.)
116
- const WF_DIR = join(ROOT, ".github", "workflows");
117
- const workflows = Object.fromEntries(
118
- readdirSync(WF_DIR)
119
- .filter((f) => f.endsWith(".yml"))
120
- .map((f) => [
121
- f,
122
- Workflow.parse(load(readFileSync(join(WF_DIR, f), "utf-8"))),
123
- ]),
124
- );
125
- const ciJobs = Object.values(workflows).flatMap((wf) =>
126
- Object.keys(wf.jobs ?? {}),
127
- );
128
- check(
129
- "the workflows parse and declare jobs — without this every assertion below is vacuous",
130
- ciJobs.length > 0 && "ci.yml" in workflows,
131
- );
132
-
133
- // ── macOS: a cell of the TeX job, on every push ─────────────────────────────────────────
134
- // install-tl-unx must work there, and issue #9 appears there alone. The trigger used to be a
135
- // separate once-per-PR workflow; the repository is public, so the minutes are free.
136
- const prTypes = (wf: Workflow | undefined): string[] =>
137
- wf?.on?.pull_request?.types ?? [];
138
- const buildOs =
139
- workflows["ci.yml"]?.jobs?.["build-e2e"]?.strategy?.matrix?.os ?? [];
140
- check(
141
- "build-e2e runs on Linux AND macOS — one job, two operating systems",
142
- buildOs.includes("ubuntu-latest") && buildOs.includes("macos-latest"),
143
- JSON.stringify(buildOs),
144
- );
145
- const unitMacos = workflows["ci.yml"]?.jobs?.["unit-macos"];
146
- check(
147
- "unit-macos runs npm test on macOS in two shards — issue #9's platform, beside the TeX cell, every test once",
148
- unitMacos?.["runs-on"] === "macos-latest" &&
149
- JSON.stringify(unitMacos.strategy?.matrix?.shard) === "[1,2]" &&
150
- (unitMacos.steps ?? []).some(
151
- (s) => s.run?.trim() === "npm test -- --shard=${{ matrix.shard }}/2",
152
- ),
153
- JSON.stringify({
154
- on: unitMacos?.["runs-on"] ?? null,
155
- shard: unitMacos?.strategy?.matrix?.shard ?? null,
156
- }),
157
- );
158
- check(
159
- "no workflow listens to `labeled` — a label trigger re-fires on every push and can pass by skipping",
160
- Object.values(workflows).every((wf) => !prTypes(wf).includes("labeled")),
161
- );
162
- check(
163
- "ci.yml listens to ready_for_review — otherwise marking a draft ready runs NOTHING",
164
- prTypes(workflows["ci.yml"]).includes("ready_for_review"),
165
- );
166
-
167
- // ── HALF ONE: every CI job is accounted for ────────────────────────────────────────────────
168
- const covered = new Set(GATES.map((g) => g.job).filter(Boolean));
169
- for (const job of ciJobs) {
170
- check(
171
- `CI job «${job}» is either reproduced by a gate or named in NOT_COVERED with a reason — ` +
172
- `an unexplained gap is indistinguishable from an oversight`,
173
- covered.has(job) || typeof NOT_COVERED[job] === "string",
174
- );
175
- }
176
-
177
- // ── HALF TWO: the list names nothing that does not exist ───────────────────────────────────
178
- // A dead job name is worse than a missing one: it reads as coverage and delivers nothing.
179
- for (const g of GATES) {
180
- if (g.job === null) continue;
181
- check(
182
- `gate «${g.name}» names a job that really exists in a workflow (${g.job})`,
183
- ciJobs.includes(g.job),
184
- );
185
- }
186
- for (const job of Object.keys(NOT_COVERED)) {
187
- check(
188
- `NOT_COVERED names a job that really exists in a workflow (${job})`,
189
- ciJobs.includes(job),
190
- );
191
- }
192
-
193
- // ── HALF THREE: every gate is runnable ─────────────────────────────────────────────────────
194
- // A gate whose script or file was renamed fails at the moment someone runs it — which is
195
- // exactly the moment they are trusting it. Catch it here instead.
196
- const scripts =
197
- PackageJson.parse(
198
- JSON.parse(readFileSync(join(ROOT, "package.json"), "utf-8")),
199
- ).scripts ?? {};
200
- for (const g of GATES) {
201
- check(
202
- `gate «${g.name}» says how to run it in exactly one way (script or run)`,
203
- Boolean(g.script) !== Array.isArray(g.run),
204
- );
205
- if (g.script) {
206
- check(
207
- `gate «${g.name}» maps to a script that exists (npm run ${g.script})`,
208
- typeof scripts[g.script] === "string",
209
- );
210
- continue;
211
- }
212
- // A `run` gate names files and programs directly. Every file it names must be on disk, and
213
- // every program other than `node` must be installed in node_modules/.bin.
214
- const argv = commandOf(g);
215
- const files = argv.filter((a) => /\.[cm]?[jt]s$/.test(a));
216
- const programs = [argv[0]];
217
- // Guards: a gate runs SOMETHING — a script of ours, or an installed program such as `tsc`.
218
- check(
219
- `gate «${g.name}» runs files that exist (${files.join(", ")})`,
220
- (files.length > 0 || programs.some((p) => p !== "node")) &&
221
- files.every((f) => existsSync(join(ROOT, f))),
222
- );
223
- check(
224
- `gate «${g.name}» runs programs that are installed (${programs.join(", ")})`,
225
- programs.every(
226
- (p) => p === "node" || existsSync(join(ROOT, "node_modules", ".bin", p)),
227
- ),
228
- );
229
- }
230
- for (const g of GATES.filter((x) => x.vitest)) {
231
- // Guards: the skip count is read from vitest's JSON report, so the script must BE a vitest run.
232
- check(
233
- `gate «${g.name}» is marked vitest, and its script is a vitest run (npm run ${String(g.script)})`,
234
- (scripts[g.script ?? ""] ?? "").startsWith("vitest run"),
235
- );
236
- }
237
- check(
238
- "`check` itself is wired as a script, or nobody can run any of this",
239
- typeof scripts.check === "string",
240
- );
241
-
242
- // ── HALF FOUR: a local-only gate must say WHY ──────────────────────────────────────────────
243
- // Without this, `job: null` becomes the quiet way to drop something out of CI.
244
- for (const g of GATES.filter((g) => g.job === null)) {
245
- check(
246
- `local-only gate «${g.name}» carries a reason`,
247
- typeof g.reason === "string" && g.reason.length > 20,
248
- );
249
- }
250
-
251
- // ── HALF FIVE: the gate's command RUNS in the job it names ─────────────────────────────────
252
- // Half two proves the job exists; it does not prove the job runs the gate. `the tests type-check`
253
- // claimed `gates` for weeks while no step of that job ran tsc — the claim was the only coverage.
254
- // So each step's `run` is split into commands (lines, `&&`, `||`, `;`) and each command into
255
- // tokens, and the gate's own command has to be one of them: `npm run <script>` (flags and extra
256
- // arguments allowed) for a script gate, its argv (an `npx` in front and extra arguments allowed)
257
- // for a run gate. Tokens, not a substring: `npm run lint` must not be found inside
258
- // `npm run lint:skills`, nor a path inside a comment.
259
- const commandsIn = (run: string | undefined): string[][] =>
260
- (run ?? "")
261
- .split(/\n|&&|\|\||;/)
262
- .map((c) => c.trim().split(/\s+/).filter(Boolean))
263
- .filter((t) => t.length > 0);
264
- const stepsOf = (job: string) =>
265
- Object.values(workflows).flatMap((wf) => wf.jobs?.[job]?.steps ?? []);
266
- const startsWith = (tokens: readonly string[], prefix: readonly string[]) =>
267
- prefix.every((p, i) => tokens[i] === p);
268
- const runsGate = (tokens: readonly string[], g: Gate): boolean => {
269
- if (g.script)
270
- return (
271
- tokens[0] === "npm" &&
272
- tokens[1] === "run" &&
273
- tokens.slice(2).find((t) => !t.startsWith("-")) === g.script
274
- );
275
- const argv = commandOf(g);
276
- return (
277
- startsWith(tokens, argv) ||
278
- (tokens[0] === "npx" && startsWith(tokens.slice(1), argv))
279
- );
280
- };
281
- for (const g of GATES) {
282
- if (g.job === null) continue;
283
- const steps = stepsOf(g.job);
284
- const { inCi } = g;
285
- if (inCi) {
286
- // A gate CI runs as a side effect of another step, through an npm lifecycle script: the step
287
- // it names must exist in the job and install the package (npm runs lifecycle scripts there),
288
- // and the lifecycle script must be the gate's own command, so the two cannot drift apart.
289
- const step = steps.find((s) => s.name === inCi.step);
290
- const tokens = commandsIn(step?.run)[0] ?? [];
291
- check(
292
- `gate «${g.name}» runs in CI job «${g.job}» through step «${inCi.step}», whose ${inCi.lifecycle} script is the gate's command`,
293
- step !== undefined &&
294
- tokens[0] === "npm" &&
295
- ["ci", "install"].includes(tokens[1] ?? "") &&
296
- typeof scripts[g.script] === "string" &&
297
- scripts[inCi.lifecycle] === scripts[g.script],
298
- JSON.stringify({ run: step?.run, lifecycle: scripts[inCi.lifecycle] }),
299
- );
300
- continue;
301
- }
302
- check(
303
- `gate «${g.name}» runs its command (${commandOf(g).join(" ")}) in a step of CI job «${g.job}»`,
304
- steps.some((s) => commandsIn(s.run).some((t) => runsGate(t, g))),
305
- steps.map((s) => s.run ?? `(uses ${String(s.uses)})`).join(" | "),
306
- );
307
- }
308
-
309
- // ── the e2e runs are found by vitest's projects, never listed ──────────────────────────────
310
- // A list of e2e files is a second copy of the directory, and the three copies that existed
311
- // (package.json, this script, CI) disagreed: two of four, four of four, a step per file (#132).
312
- const namesE2eFile = (run: string | undefined): string[] =>
313
- commandsIn(run)
314
- .flat()
315
- .filter((t) => /(^|\/)test\/e2e\//.test(t));
316
- check(
317
- "no npm script names a file under test/e2e/ — the vitest projects find them",
318
- Object.values(scripts).flatMap(namesE2eFile).length === 0,
319
- JSON.stringify(scripts),
320
- );
321
- check(
322
- "no workflow step names a file under test/e2e/",
323
- Object.values(workflows)
324
- .flatMap((wf) => Object.values(wf.jobs ?? {}))
325
- .flatMap((j) => j.steps ?? [])
326
- .flatMap((st) => namesE2eFile(st.run)).length === 0,
327
- );
328
- check(
329
- "no gate names a file under test/e2e/",
330
- GATES.flatMap((g) => commandOf(g).filter((t) => t.includes("test/e2e/")))
331
- .length === 0,
332
- );
333
-
334
- // ── and the tail is not optional ───────────────────────────────────────────────────────────
335
- check(
336
- "NOT_COVERED is non-empty — if it ever is, either CI shrank or someone silenced the tail",
337
- Object.keys(NOT_COVERED).length > 0,
338
- );
339
-
340
- console.log(
341
- `✓ ${String(check.count)} assertions passed — npm run check: ${String(GATES.length)} gates, ` +
342
- `${String(ciJobs.length)} CI job(s) all accounted for`,
343
- );
@@ -1,41 +0,0 @@
1
- {
2
- "issue": "https://github.com/zernie/paperlint/issues/77",
3
- "why": "A *.harness.* file tests the agent surface and imports runHook, runHarnessTest or runEval from vigiles. Plain unit tests are *.test.ts, run by vitest. These are the harness files that existed on main on 2026-09-25 and import none of the three. The list only shrinks: rename a file to *.test.ts (issue #77), or make it a real harness, then delete its entry. Checked by scripts/harness-api.test.ts, part of npm test.",
4
- "harnesses": [
5
- "action.harness.mjs",
6
- "eslint-rules/install-path-literals.harness.mjs",
7
- "eslint-rules/latex-language.harness.mjs",
8
- "eslint-rules/paper-stages.harness.mjs",
9
- "eslint-rules/papers.harness.mjs",
10
- "eslint-rules/pdf-last-page-balance.harness.mjs",
11
- "eslint-rules/temp-root-realpath.harness.mjs",
12
- "eslint-rules/tex-build.harness.mjs",
13
- "lib/agent-cli-version.harness.mjs",
14
- "lib/paper-config.harness.mjs",
15
- "lib/skill-trigger-cases.harness.mjs",
16
- "scripts/check.harness.ts",
17
- "scripts/rules-see-files.harness.mjs",
18
- "skills/paper-pipeline/paper-pipeline.harness.mjs",
19
- "skills/paper-pipeline/scripts/consumer.harness.mjs",
20
- "skills/paper-pipeline/scripts/extract-ref-facts.harness.mjs",
21
- "skills/paper-pipeline/scripts/generated-code.harness.mjs",
22
- "skills/render-paper/extract-pdf-facts.harness.ts",
23
- "skills/render-paper/render-paper.harness.mjs",
24
- "src/build-engine.harness.mjs",
25
- "src/build.harness.mjs",
26
- "src/cli.harness.mjs",
27
- "src/doctor.harness.mjs",
28
- "src/engine.harness.mjs",
29
- "src/hooks-settings.harness.ts",
30
- "src/latex-log.harness.ts",
31
- "src/latex-loop.harness.ts",
32
- "src/link-skills.harness.ts",
33
- "src/new-paper.harness.mjs",
34
- "src/pdf-facts.harness.ts",
35
- "src/pdf-geometry.harness.ts",
36
- "src/rules-config.harness.ts",
37
- "src/structure.harness.ts",
38
- "src/tex-requirements.harness.ts",
39
- "src/toolchain.harness.mjs"
40
- ]
41
- }