paperlint 3.2.0 → 4.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 (312) hide show
  1. package/CLAUDE.md +2 -2
  2. package/dist/adapters/banal/failure.d.ts +1 -7
  3. package/dist/adapters/banal/failure.d.ts.map +1 -1
  4. package/dist/adapters/banal/failure.js +5 -7
  5. package/dist/adapters/banal/failure.js.map +1 -1
  6. package/dist/adapters/banal/index.d.ts.map +1 -1
  7. package/dist/adapters/banal/index.js +8 -11
  8. package/dist/adapters/banal/index.js.map +1 -1
  9. package/dist/adapters/banal/install.d.ts.map +1 -1
  10. package/dist/adapters/banal/install.js +4 -3
  11. package/dist/adapters/banal/install.js.map +1 -1
  12. package/dist/adapters/banal/invocation.d.ts +9 -4
  13. package/dist/adapters/banal/invocation.d.ts.map +1 -1
  14. package/dist/adapters/banal/invocation.js +13 -1
  15. package/dist/adapters/banal/invocation.js.map +1 -1
  16. package/dist/adapters/banal/locate.d.ts +12 -9
  17. package/dist/adapters/banal/locate.d.ts.map +1 -1
  18. package/dist/adapters/banal/locate.js +19 -12
  19. package/dist/adapters/banal/locate.js.map +1 -1
  20. package/dist/adapters/banal/run.d.ts +10 -1
  21. package/dist/adapters/banal/run.d.ts.map +1 -1
  22. package/dist/adapters/banal/run.js +8 -4
  23. package/dist/adapters/banal/run.js.map +1 -1
  24. package/dist/adapters/banal/settings.d.ts +1 -1
  25. package/dist/adapters/banal/settings.d.ts.map +1 -1
  26. package/dist/adapters/banal/settings.js +2 -1
  27. package/dist/adapters/banal/settings.js.map +1 -1
  28. package/dist/adapters/memory/index.d.ts.map +1 -1
  29. package/dist/adapters/memory/index.js +8 -2
  30. package/dist/adapters/memory/index.js.map +1 -1
  31. package/dist/adapters/node/process.io.d.ts +6 -3
  32. package/dist/adapters/node/process.io.d.ts.map +1 -1
  33. package/dist/adapters/node/process.io.js.map +1 -1
  34. package/dist/adapters/node/workspace.io.d.ts.map +1 -1
  35. package/dist/adapters/node/workspace.io.js +4 -2
  36. package/dist/adapters/node/workspace.io.js.map +1 -1
  37. package/dist/adapters/references/index.d.ts.map +1 -1
  38. package/dist/adapters/references/index.js +4 -2
  39. package/dist/adapters/references/index.js.map +1 -1
  40. package/dist/build-engine.d.ts +1 -1
  41. package/dist/build-engine.d.ts.map +1 -1
  42. package/dist/build-engine.js +8 -1
  43. package/dist/build-engine.js.map +1 -1
  44. package/dist/build.d.ts +2 -3
  45. package/dist/build.d.ts.map +1 -1
  46. package/dist/build.js +5 -6
  47. package/dist/build.js.map +1 -1
  48. package/dist/caller-path.d.ts +3 -0
  49. package/dist/caller-path.d.ts.map +1 -0
  50. package/dist/caller-path.js +13 -0
  51. package/dist/caller-path.js.map +1 -0
  52. package/dist/cli.d.ts +10 -17
  53. package/dist/cli.d.ts.map +1 -1
  54. package/dist/cli.js +62 -12
  55. package/dist/cli.js.map +1 -1
  56. package/dist/doctor.d.ts +12 -3
  57. package/dist/doctor.d.ts.map +1 -1
  58. package/dist/doctor.js +2 -1
  59. package/dist/doctor.js.map +1 -1
  60. package/dist/domain/paths.d.ts +8 -2
  61. package/dist/domain/paths.d.ts.map +1 -1
  62. package/dist/domain/paths.js +12 -1
  63. package/dist/domain/paths.js.map +1 -1
  64. package/dist/domain/ready.d.ts +24 -0
  65. package/dist/domain/ready.d.ts.map +1 -0
  66. package/dist/domain/ready.js +11 -0
  67. package/dist/domain/ready.js.map +1 -0
  68. package/dist/domain/record.d.ts +8 -0
  69. package/dist/domain/record.d.ts.map +1 -0
  70. package/dist/domain/record.js +8 -0
  71. package/dist/domain/record.js.map +1 -0
  72. package/dist/domain/sha256.d.ts.map +1 -1
  73. package/dist/domain/sha256.js +4 -2
  74. package/dist/domain/sha256.js.map +1 -1
  75. package/dist/engine.d.ts +23 -22
  76. package/dist/engine.d.ts.map +1 -1
  77. package/dist/engine.js.map +1 -1
  78. package/dist/eslint-rules/bib-reachable-entry.d.ts +1 -1
  79. package/dist/eslint-rules/bib-reachable-entry.js.map +1 -1
  80. package/dist/eslint-rules/install-path-literals.d.ts +2 -2
  81. package/dist/eslint-rules/install-path-literals.js.map +1 -1
  82. package/dist/eslint-rules/paper-research-question.d.ts +1 -1
  83. package/dist/eslint-rules/paper-research-question.js.map +1 -1
  84. package/dist/eslint-rules/paper-stages.d.ts +2 -2
  85. package/dist/eslint-rules/paper-stages.js.map +1 -1
  86. package/dist/eslint-rules/paper-typography.d.ts +6 -6
  87. package/dist/eslint-rules/paper-typography.js.map +1 -1
  88. package/dist/eslint-rules/pdf-last-page-balance.d.ts +1 -1
  89. package/dist/eslint-rules/pdf-last-page-balance.js.map +1 -1
  90. package/dist/eslint-rules/review-frontmatter.d.ts +2 -2
  91. package/dist/eslint-rules/review-frontmatter.js.map +1 -1
  92. package/dist/eslint-rules/sibling-frontmatter.d.ts +1 -1
  93. package/dist/eslint-rules/sibling-frontmatter.d.ts.map +1 -1
  94. package/dist/eslint-rules/temp-root-realpath.d.ts +1 -1
  95. package/dist/eslint-rules/temp-root-realpath.js.map +1 -1
  96. package/dist/eslint-rules/tex-build.d.ts +2 -2
  97. package/dist/eslint-rules/tex-build.js.map +1 -1
  98. package/dist/facts-file.d.ts.map +1 -1
  99. package/dist/facts-file.js +29 -26
  100. package/dist/facts-file.js.map +1 -1
  101. package/dist/hooks-settings.d.ts.map +1 -1
  102. package/dist/hooks-settings.js +17 -2
  103. package/dist/hooks-settings.js.map +1 -1
  104. package/dist/init.d.ts +3 -4
  105. package/dist/init.d.ts.map +1 -1
  106. package/dist/init.js +18 -8
  107. package/dist/init.js.map +1 -1
  108. package/dist/lib/paper-config.d.ts.map +1 -1
  109. package/dist/lib/paper-config.js +1 -5
  110. package/dist/lib/paper-config.js.map +1 -1
  111. package/dist/new-paper.d.ts.map +1 -1
  112. package/dist/new-paper.js +5 -1
  113. package/dist/new-paper.js.map +1 -1
  114. package/dist/paper-files.d.ts +4 -4
  115. package/dist/paper-files.d.ts.map +1 -1
  116. package/dist/paper-files.js +6 -6
  117. package/dist/paper-files.js.map +1 -1
  118. package/dist/paper-settings.js +3 -3
  119. package/dist/paper-settings.js.map +1 -1
  120. package/dist/pdf-facts.d.ts +51 -1
  121. package/dist/pdf-facts.d.ts.map +1 -1
  122. package/dist/pdf-facts.js +23 -15
  123. package/dist/pdf-facts.js.map +1 -1
  124. package/dist/pdf-geometry.d.ts.map +1 -1
  125. package/dist/pdf-geometry.js +2 -3
  126. package/dist/pdf-geometry.js.map +1 -1
  127. package/dist/ports/tool-installer.d.ts +2 -14
  128. package/dist/ports/tool-installer.d.ts.map +1 -1
  129. package/dist/presets.d.ts.map +1 -1
  130. package/dist/presets.js +16 -4
  131. package/dist/presets.js.map +1 -1
  132. package/dist/references.d.ts.map +1 -1
  133. package/dist/references.js +4 -4
  134. package/dist/references.js.map +1 -1
  135. package/dist/rules-config.d.ts +26 -1
  136. package/dist/rules-config.d.ts.map +1 -1
  137. package/dist/rules-config.js +9 -9
  138. package/dist/rules-config.js.map +1 -1
  139. package/dist/tex-requirements.d.ts +4 -0
  140. package/dist/tex-requirements.d.ts.map +1 -1
  141. package/dist/tex-requirements.js +14 -2
  142. package/dist/tex-requirements.js.map +1 -1
  143. package/dist/types.d.ts +5 -3
  144. package/dist/types.d.ts.map +1 -1
  145. package/dist/venue-rules.d.ts.map +1 -1
  146. package/dist/venue-rules.js +20 -7
  147. package/dist/venue-rules.js.map +1 -1
  148. package/docs/configuration.md +2 -2
  149. package/eslint-rules/bib-reachable-entry.ts +1 -1
  150. package/eslint-rules/install-path-literals.ts +2 -2
  151. package/eslint-rules/paper-research-question.ts +1 -1
  152. package/eslint-rules/paper-stages.ts +2 -2
  153. package/eslint-rules/paper-typography.ts +2 -2
  154. package/eslint-rules/pdf-last-page-balance.ts +1 -1
  155. package/eslint-rules/review-frontmatter.ts +1 -1
  156. package/eslint-rules/temp-root-realpath.ts +1 -1
  157. package/eslint-rules/tex-build.ts +2 -2
  158. package/eslint.config.mjs +7 -0
  159. package/fixtures/install-path-literals/clean.fixture.mjs +1 -1
  160. package/fixtures/install-path-literals/clean.md +2 -2
  161. package/fixtures/install-path-literals/defect.fixture.mjs +1 -1
  162. package/fixtures/install-path-literals/defect.md +2 -2
  163. package/hooks/paper-status-gates.sh +9 -19
  164. package/lib/paper-config.harness.mjs +1 -1
  165. package/lib/paper-config.ts +1 -5
  166. package/lib/skill-checks.mjs +24 -381
  167. package/lib/skill-checks.test.mjs +63 -115
  168. package/lib/skill-corpus.mjs +10 -251
  169. package/lib/skill-corpus.test.mjs +2 -13
  170. package/lib/skill-trigger-cases.mjs +1 -1
  171. package/package.json +1 -1
  172. package/scripts/coverage-config.test.ts +0 -1
  173. package/scripts/harness-api.frozen.json +0 -1
  174. package/skills/analyze-sibling-paper/SKILL.md +1 -39
  175. package/skills/analyze-sibling-paper/SKILL.md.spec.ts +0 -38
  176. package/skills/argument-arc/SKILL.md +2 -36
  177. package/skills/argument-arc/SKILL.md.spec.ts +1 -43
  178. package/skills/build-benchmark/SKILL.md +1 -41
  179. package/skills/build-benchmark/SKILL.md.spec.ts +0 -40
  180. package/skills/camera-ready/SKILL.md +1 -34
  181. package/skills/camera-ready/SKILL.md.spec.ts +0 -33
  182. package/skills/cold-read-diff/SKILL.md +1 -35
  183. package/skills/cold-read-diff/SKILL.md.spec.ts +0 -34
  184. package/skills/draft-paper/SKILL.md +2 -41
  185. package/skills/draft-paper/SKILL.md.spec.ts +1 -50
  186. package/skills/extend-paper/SKILL.md +2 -33
  187. package/skills/extend-paper/SKILL.md.spec.ts +1 -42
  188. package/skills/find-venue/SKILL.md +2 -38
  189. package/skills/find-venue/SKILL.md.spec.ts +1 -47
  190. package/skills/grade-paper-writing/SKILL.md +3 -38
  191. package/skills/grade-paper-writing/SKILL.md.spec.ts +2 -47
  192. package/skills/grade-paper-writing/prose-lint.mjs +2 -3
  193. package/skills/grade-paper-writing/prose-lint.test.ts +1 -1
  194. package/skills/harden-paper/SKILL.md +1 -39
  195. package/skills/harden-paper/SKILL.md.spec.ts +0 -38
  196. package/skills/map-prior-work/SKILL.md +1 -35
  197. package/skills/map-prior-work/SKILL.md.spec.ts +0 -34
  198. package/skills/osf-artifact-upload/osf-artifact-upload.harness.ts +3 -4
  199. package/skills/paper-adversarial-review/SKILL.md +2 -35
  200. package/skills/paper-adversarial-review/SKILL.md.spec.ts +1 -43
  201. package/skills/paper-pipeline/SKILL.md +2 -28
  202. package/skills/paper-pipeline/SKILL.md.spec.ts +1 -27
  203. package/skills/paper-pipeline/grade-paper-writing-ablation.eval.mjs +1 -1
  204. package/skills/paper-pipeline/paper-pipeline.harness.mjs +25 -40
  205. package/skills/paper-pipeline/references/acceptance-gate.md +1 -6
  206. package/skills/paper-pipeline/references/pipeline-status-template.md +8 -35
  207. package/skills/paper-pipeline/scripts/README.md +30 -225
  208. package/skills/paper-pipeline/scripts/artifact-coverage.harness.mjs +4 -8
  209. package/skills/paper-pipeline/scripts/consumer.harness.mjs +6 -104
  210. package/skills/paper-pipeline/scripts/consumer.mjs +23 -104
  211. package/skills/paper-pipeline/scripts/generated-code.harness.mjs +2 -3
  212. package/skills/paper-pipeline/scripts/population-map.harness.mjs +3 -3
  213. package/skills/paper-status/SKILL.md +2 -42
  214. package/skills/paper-status/SKILL.md.spec.ts +1 -41
  215. package/skills/pc-panel-review/SKILL.md +2 -46
  216. package/skills/pc-panel-review/SKILL.md.spec.ts +1 -45
  217. package/skills/plan-paper-timeline/SKILL.md +2 -36
  218. package/skills/plan-paper-timeline/SKILL.md.spec.ts +0 -36
  219. package/skills/render-paper/SKILL.md +1 -37
  220. package/skills/render-paper/SKILL.md.spec.ts +0 -36
  221. package/skills/research-ideate/SKILL.md +2 -39
  222. package/skills/research-ideate/SKILL.md.spec.ts +1 -47
  223. package/skills/study-accepted-papers/SKILL.md +1 -34
  224. package/skills/study-accepted-papers/SKILL.md.spec.ts +0 -33
  225. package/skills/submit-paper/SKILL.md +1 -33
  226. package/skills/submit-paper/SKILL.md.spec.ts +0 -32
  227. package/skills/sweep-design-space/SKILL.md +1 -38
  228. package/skills/sweep-design-space/SKILL.md.spec.ts +0 -37
  229. package/skills/tighten-paper/SKILL.md +2 -39
  230. package/skills/tighten-paper/SKILL.md.spec.ts +1 -47
  231. package/skills/tighten-paper/structure.mjs +4 -11
  232. package/skills/verify-citations/SKILL.md +2 -38
  233. package/skills/verify-citations/SKILL.md.spec.ts +1 -37
  234. package/src/adapters/banal/failure.ts +9 -10
  235. package/src/adapters/banal/index.test.ts +2 -2
  236. package/src/adapters/banal/index.ts +8 -10
  237. package/src/adapters/banal/install.ts +9 -4
  238. package/src/adapters/banal/invocation.test.ts +20 -8
  239. package/src/adapters/banal/invocation.ts +23 -8
  240. package/src/adapters/banal/locate.test.ts +2 -2
  241. package/src/adapters/banal/locate.ts +27 -21
  242. package/src/adapters/banal/run.test.ts +2 -2
  243. package/src/adapters/banal/run.ts +16 -10
  244. package/src/adapters/banal/settings.ts +2 -2
  245. package/src/adapters/curl/download.test.ts +4 -4
  246. package/src/adapters/memory/index.ts +4 -3
  247. package/src/adapters/node/files.test.ts +5 -3
  248. package/src/adapters/node/process.io.ts +9 -2
  249. package/src/adapters/node/process.test.ts +4 -4
  250. package/src/adapters/node/workspace.io.ts +9 -4
  251. package/src/adapters/references/index.ts +7 -2
  252. package/src/build-engine.test.ts +11 -6
  253. package/src/build-engine.ts +10 -5
  254. package/src/build.test.ts +10 -11
  255. package/src/build.ts +8 -9
  256. package/src/caller-path.ts +13 -0
  257. package/src/cli.harness.mjs +0 -2
  258. package/src/cli.test.ts +19 -8
  259. package/src/cli.ts +82 -25
  260. package/src/doctor.test.ts +1 -1
  261. package/src/doctor.ts +14 -5
  262. package/src/domain/paths.test.ts +15 -0
  263. package/src/domain/paths.ts +20 -1
  264. package/src/domain/ready.ts +31 -0
  265. package/src/domain/record.test.ts +20 -0
  266. package/src/domain/record.ts +12 -0
  267. package/src/domain/sha256.ts +5 -3
  268. package/src/engine.ts +30 -2
  269. package/src/facts-file.ts +43 -28
  270. package/src/hooks-settings.harness.ts +17 -0
  271. package/src/hooks-settings.ts +28 -4
  272. package/src/init.test.ts +25 -5
  273. package/src/init.ts +26 -12
  274. package/src/new-paper.harness.mjs +7 -23
  275. package/src/new-paper.ts +7 -3
  276. package/src/paper-files.test.ts +22 -19
  277. package/src/paper-files.ts +16 -27
  278. package/src/paper-settings.test.ts +2 -2
  279. package/src/paper-settings.ts +5 -5
  280. package/src/pdf-facts.test.ts +16 -5
  281. package/src/pdf-facts.ts +79 -22
  282. package/src/pdf-geometry.ts +5 -3
  283. package/src/ports/tool-installer.ts +2 -17
  284. package/src/presets.ts +28 -14
  285. package/src/references.test.ts +25 -19
  286. package/src/references.ts +4 -5
  287. package/src/rules-config.ts +40 -11
  288. package/src/tex-requirements.test.ts +21 -0
  289. package/src/tex-requirements.ts +29 -6
  290. package/src/toolchain.test.ts +9 -5
  291. package/src/toolchain.ts +2 -2
  292. package/src/types.ts +5 -3
  293. package/src/venue-rules.test.ts +8 -4
  294. package/src/venue-rules.ts +21 -11
  295. package/skills/paper-pipeline/scripts/announce.mjs +0 -67
  296. package/skills/paper-pipeline/scripts/announce.test.mjs +0 -102
  297. package/skills/paper-pipeline/scripts/fixtures/clean/PIPELINE-STATUS.md +0 -51
  298. package/skills/paper-pipeline/scripts/fixtures/dirty/PIPELINE-STATUS.md +0 -52
  299. package/skills/paper-pipeline/scripts/fixtures/dirty/paper.md +0 -6
  300. package/skills/paper-pipeline/scripts/fixtures/scorecard.ts +0 -100
  301. package/skills/paper-pipeline/scripts/ledger.cli.test.mjs +0 -302
  302. package/skills/paper-pipeline/scripts/ledger.mjs +0 -623
  303. package/skills/paper-pipeline/scripts/ledger.test.mjs +0 -254
  304. package/skills/paper-pipeline/scripts/pipeline-check.cli.test.mjs +0 -474
  305. package/skills/paper-pipeline/scripts/pipeline-check.harness.mjs +0 -328
  306. package/skills/paper-pipeline/scripts/pipeline-check.mjs +0 -750
  307. package/skills/paper-pipeline/scripts/pipeline-edges.mjs +0 -169
  308. package/skills/paper-pipeline/scripts/pipeline-edges.test.mjs +0 -73
  309. package/skills/paper-pipeline/scripts/run-mechanical.mjs +0 -648
  310. package/skills/paper-pipeline/scripts/run-mechanical.test.mjs +0 -468
  311. package/skills/paper-pipeline/scripts/status.mjs +0 -295
  312. package/skills/paper-pipeline/scripts/status.test.mjs +0 -232
@@ -10,30 +10,10 @@ export default experimental_skill({
10
10
  name: "tighten-paper",
11
11
  description:
12
12
  "Use when a paper \"feels long / bloated / overly complex / hard to read / doesn't deliver its point / the middle drags\" — or after review rounds deposited hedge-mass. The developmental / editorial pass on a DRAFTED paper: what a real human editor thinks reading it cover to cover — the ONE point, does every section earn its place, can it be SKIMMED, is it too long for its contribution, which sections are TMI that belong in the artifact/appendix, does the conclusion pay off the intro's promise. Produces a structural verdict + a concrete cut / fold / merge / reorder plan — NOT sentence fixes. Its verdict is a required INPUT to pc-panel-review and a hard gate in harden-paper. NOT sentence craft or a writing grade (grade-paper-writing), NOT jargon stalls (the persona stall pass), NOT scientific defects (pc-panel-review / paper-adversarial-review). Run it BEFORE those on a bloated draft — no point polishing sentences in a section that should be cut.",
13
- tools: [
14
- "Read",
15
- "Write",
16
- "Edit",
17
- "Grep",
18
- "Glob",
19
- "Agent",
20
- "Bash(node .claude/skills/paper-pipeline/scripts/announce.mjs:*)",
21
- "Bash(node .claude/skills/paper-pipeline/scripts/ledger.mjs:*)",
22
- ],
13
+ tools: ["Read", "Write", "Edit", "Grep", "Glob", "Agent"],
23
14
  body: `
24
15
  # tighten-paper — the developmental edit
25
16
 
26
- ## Run me
27
-
28
- 🔴 FIRST, before any other step:
29
-
30
- \`\`\`
31
- node .claude/skills/paper-pipeline/scripts/announce.mjs tighten-paper <paper-dir>
32
- \`\`\`
33
-
34
- An advisory pass cannot be observed failing — silence is both its error state and its normal
35
- state — so starting is an event, and events get written down.
36
-
37
17
  Sentence-level passes make a wall of text into readable text. They do **not** tell you the wall shouldn't be there
38
18
  at all. This pass is the editor who reads the whole paper once and asks: *is this the right paper, at the right
39
19
  length, delivering the right point?* Its deliverable is a **cut/fold/merge/reorder plan and a length verdict**, not
@@ -336,32 +316,6 @@ Produce:
336
316
  - **The middle-sag diagnosis** and the fix (consolidate these findings, lead each with its point).
337
317
  - **Skim-test failures** (headings/lead-sentences that don't carry the argument).
338
318
 
339
- ## Record the verdict
340
-
341
- 🔴 LAST step, once the deliverable exists:
342
-
343
- \`\`\`
344
- node .claude/skills/paper-pipeline/scripts/ledger.mjs record tighten-paper <paper-dir> FINDING <count> <report-path>
345
- node .claude/skills/paper-pipeline/scripts/ledger.mjs record tighten-paper <paper-dir> ABSTAINED <reason> "<one line>"
346
- \`\`\`
347
-
348
- **FINDING** is the normal row — \`<count>\` is the number of CUT / FOLD / MERGE / REORDER actions in
349
- the plan and \`<report-path>\` is the plan itself. Add \`--blocking\` when the paper is over its limit
350
- and the plan cannot get it under.
351
- **ABSTAINED** — \`no-witness\`: a cover-to-cover read produced no action at all, which on a real draft
352
- should be rare. \`blocked\`: the declined pass of the section above — content is still being added, so
353
- there was nothing to read whole.
354
-
355
- 🔴 **This is the check with the documented history of never saying no**: a tightening pass once
356
- returned KEEP on 80 of 81 sections and still counted as run. It is also one of the three failures
357
- that deleted \`PASS\` — the word made "I read it all and nothing moved" indistinguishable from "I did
358
- not really read it". \`status.mjs\` reports a check that has never recorded a finding, on the
359
- mutation-testing principle that a test which kills no mutant is not a test. So an \`ABSTAINED
360
- no-witness\` here owes a note saying what was read and why nothing moved.
361
-
362
- The mechanical half of this skill files separately, under \`tighten-paper/structure\` — one check, one
363
- row. Do not record a \`structure.mjs\` result here.
364
-
365
319
  ## Compose
366
320
  Run this FIRST on a draft that "feels bloated" — before grade-paper-writing / the stall pass / pc-panel, because
367
321
  polishing sentences in a section that should be folded to the artifact is wasted work. After the plan is applied,
@@ -22,7 +22,7 @@
22
22
  *
23
23
  * ── 2026-08-26, EVENING: BOTH NAMED CONSUMERS ARE CLOSED, AND A THIRD ONE TURNED UP ────────
24
24
  *
25
- * The paragraph above named two callers and said that until they are converted, the ledger writes
25
+ * The paragraph above named two callers and said that until they are converted, they read
26
26
  * "no findings" BY SILENCE. That was true and measured: on `the reference paper/paper.md`
27
27
  * `--flags-only` printed 0 lines, while the same bytes through ESLint give **6 findings**
28
28
  * (`subsection-size` ×2 · `section-lead` · `free-section-size` ×2 · `block-ungraded`).
@@ -31,11 +31,6 @@
31
31
  * stood next to it, running the same rules over the same glob; a measurement showed a
32
32
  * byte-identical list of files. The full justification is in the comment where the removed
33
33
  * step used to be.
34
- * `run-mechanical.mjs`, the `tighten-paper/structure` line → CONVERTED to ESLint
35
- * (`read: 'eslint'`, filtered by the rules from `eslint-rules/paper-structure.mjs`). Not
36
- * deleted: ESLint writes nothing into the ledger, and the ledger is the only place where the
37
- * fact "somebody looked at this paper's structure on these bytes" is stored with a hash of the
38
- * input.
39
34
  *
40
35
  * 🔴 A THIRD CALLER THE BANNER DID NOT KNOW ABOUT: `.githooks/pre-commit`. It printed nothing and
41
36
  * swallowed the exit code through `|| true`. The lesson is exactly the one already recorded in
@@ -294,11 +289,9 @@ const freeTotal = freeSections.reduce((a, r) => a + r.words, 0);
294
289
  // edit, and there is nothing to settle the question of which one is right.
295
290
 
296
291
  if (flagsOnly) {
297
- // Silence and exit code 0 — ALWAYS. Deliberately not one line on stdout/stderr:
298
- // `run-mechanical.mjs` reads this mode as `read: 'flags'`, that is, "non-empty output = a
299
- // finding", and a pointer saying "the checks have moved" would turn into a permanent false finding
300
- // in the ledger. The limitation of this mode is named in the banner at the top; it is cured by
301
- // converting both callers to `npx eslint`, not here.
292
+ // Silence and exit code 0 — ALWAYS. Deliberately not one line on stdout/stderr: a caller that
293
+ // reads "non-empty output = a finding" would turn a pointer saying "the checks have moved" into a
294
+ // permanent false finding. The limitation of this mode is named in the banner at the top.
302
295
  process.exit(0);
303
296
  }
304
297
 
@@ -4,21 +4,10 @@ description: Verify every citation is a real work with correct metadata, and tha
4
4
  allowed-tools: [Read, Write, Edit, Grep, Glob, Bash, WebSearch, WebFetch, Agent]
5
5
  ---
6
6
 
7
- <!-- vigiles:sha256:3a7e10662d0084c4 compiled from skills/verify-citations/SKILL.md.spec.ts -->
7
+ <!-- vigiles:sha256:fe3634eb63db5c0d compiled from skills/verify-citations/SKILL.md.spec.ts -->
8
8
 
9
9
  # verify-citations — every cite real, the delta explicit
10
10
 
11
- ## Run me
12
-
13
- 🔴 FIRST, before any other step:
14
-
15
- ```
16
- node .claude/skills/paper-pipeline/scripts/announce.mjs verify-citations <paper-dir>
17
- ```
18
-
19
- An advisory pass cannot be observed failing — silence is both its error state and its normal
20
- state — so starting is an event, and events get written down.
21
-
22
11
  Reviewers reject on a single fabricated or wrong citation — it reads as either sloppiness or a
23
12
  hallucinated bibliography, and either one is fatal. And they reject on "this was already done by ___" if
24
13
  your delta over the nearest prior work isn't spelled out. This skill closes both holes before submit.
@@ -30,8 +19,7 @@ bibliography changes, including the edit you make on the last day. Scorecard row
30
19
  `<paper-dir>/PIPELINE-STATUS.md`; see the CONTINUOUS section of `paper-pipeline`.
31
20
 
32
21
  - **A pass dated before the current text is STALE, and stale reads as green.** The date in the `cites`
33
- row is compared against the paper's own mtime, and `../paper-pipeline/scripts/pipeline-check.mjs` reports the
34
- mismatch — because a `☑` from three days and forty edits ago is worse than a `☐`: it looks closed.
22
+ row is compared against the paper's own mtime — because a `☑` from three days and forty edits ago is worse than a `☐`: it looks closed.
35
23
  - **"We checked last cycle" does not count.** Say it plainly, because it is the exact sentence that
36
24
  ships a fabricated cite: a review round adds text, added text adds citations, and the run that
37
25
  cleared the bibliography never saw them.
@@ -294,30 +282,6 @@ therefore being checked for the first time.
294
282
  fails CI if any line or branch of them goes unexercised. Run `npx vitest run src/references.test.ts`
295
283
  after any edit to the rules.
296
284
 
297
- ## 6. Record the verdict
298
-
299
- 🔴 LAST step, once the deliverable exists:
300
-
301
- ```
302
- node .claude/skills/paper-pipeline/scripts/ledger.mjs record verify-citations <paper-dir> FINDING <count> <report-path>
303
- node .claude/skills/paper-pipeline/scripts/ledger.mjs record verify-citations <paper-dir> ABSTAINED <reason> "<one line>"
304
- ```
305
-
306
- **FINDING** — `<count>` is the number of cites still `% VERIFY` or `unresolvable`; `<report-path>`
307
- lists them. Add `--blocking` for a cite an authoritative source disproves, or a missing delta
308
- sentence; either is a submit blocker.
309
- **ABSTAINED** — `no-witness`: every cite resolved with correct metadata and the delta sentence is in
310
- the prose. `crashed`: the registries were unreachable, so nothing was verified — which is emphatically
311
- not the same as everything checking out, and under the old vocabulary both came back `PASS`.
312
-
313
- 🔴 **There is no PASS.** `no-witness` here means every cite the paper makes was looked up and none
314
- of them came back wrong. It does not mean the bibliography is complete: this check cannot see a work
315
- that should have been cited and is not. That gap belongs to `map-prior-work`, and no row here covers it.
316
-
317
- Because this check is CONTINUOUS, it writes a row per run and never a final one. That is the point:
318
- the ledger compares the row against the paper's current bytes, so a pass that predates the last three
319
- `\cite` additions reports as STALE-PAPER instead of reading as green.
320
-
321
285
  ## Rules
322
286
  - **Re-run on every `\cite` added or moved.** A `cites` row older than the paper's text is a stale pass,
323
287
  not a green one — "we checked last cycle" is not a verification.
@@ -24,17 +24,6 @@ export default experimental_skill({
24
24
  body: `
25
25
  # verify-citations — every cite real, the delta explicit
26
26
 
27
- ## Run me
28
-
29
- 🔴 FIRST, before any other step:
30
-
31
- \`\`\`
32
- node .claude/skills/paper-pipeline/scripts/announce.mjs verify-citations <paper-dir>
33
- \`\`\`
34
-
35
- An advisory pass cannot be observed failing — silence is both its error state and its normal
36
- state — so starting is an event, and events get written down.
37
-
38
27
  Reviewers reject on a single fabricated or wrong citation — it reads as either sloppiness or a
39
28
  hallucinated bibliography, and either one is fatal. And they reject on "this was already done by ___" if
40
29
  your delta over the nearest prior work isn't spelled out. This skill closes both holes before submit.
@@ -46,8 +35,7 @@ bibliography changes, including the edit you make on the last day. Scorecard row
46
35
  \`<paper-dir>/PIPELINE-STATUS.md\`; see the CONTINUOUS section of \`paper-pipeline\`.
47
36
 
48
37
  - **A pass dated before the current text is STALE, and stale reads as green.** The date in the \`cites\`
49
- row is compared against the paper's own mtime, and \`../paper-pipeline/scripts/pipeline-check.mjs\` reports the
50
- mismatch — because a \`☑\` from three days and forty edits ago is worse than a \`☐\`: it looks closed.
38
+ row is compared against the paper's own mtime — because a \`☑\` from three days and forty edits ago is worse than a \`☐\`: it looks closed.
51
39
  - **"We checked last cycle" does not count.** Say it plainly, because it is the exact sentence that
52
40
  ships a fabricated cite: a review round adds text, added text adds citations, and the run that
53
41
  cleared the bibliography never saw them.
@@ -310,30 +298,6 @@ therefore being checked for the first time.
310
298
  fails CI if any line or branch of them goes unexercised. Run \`npx vitest run src/references.test.ts\`
311
299
  after any edit to the rules.
312
300
 
313
- ## 6. Record the verdict
314
-
315
- 🔴 LAST step, once the deliverable exists:
316
-
317
- \`\`\`
318
- node .claude/skills/paper-pipeline/scripts/ledger.mjs record verify-citations <paper-dir> FINDING <count> <report-path>
319
- node .claude/skills/paper-pipeline/scripts/ledger.mjs record verify-citations <paper-dir> ABSTAINED <reason> "<one line>"
320
- \`\`\`
321
-
322
- **FINDING** — \`<count>\` is the number of cites still \`% VERIFY\` or \`unresolvable\`; \`<report-path>\`
323
- lists them. Add \`--blocking\` for a cite an authoritative source disproves, or a missing delta
324
- sentence; either is a submit blocker.
325
- **ABSTAINED** — \`no-witness\`: every cite resolved with correct metadata and the delta sentence is in
326
- the prose. \`crashed\`: the registries were unreachable, so nothing was verified — which is emphatically
327
- not the same as everything checking out, and under the old vocabulary both came back \`PASS\`.
328
-
329
- 🔴 **There is no PASS.** \`no-witness\` here means every cite the paper makes was looked up and none
330
- of them came back wrong. It does not mean the bibliography is complete: this check cannot see a work
331
- that should have been cited and is not. That gap belongs to \`map-prior-work\`, and no row here covers it.
332
-
333
- Because this check is CONTINUOUS, it writes a row per run and never a final one. That is the point:
334
- the ledger compares the row against the paper's current bytes, so a pass that predates the last three
335
- \`\\cite\` additions reports as STALE-PAPER instead of reading as green.
336
-
337
301
  ## Rules
338
302
  - **Re-run on every \`\\cite\` added or moved.** A \`cites\` row older than the paper's text is a stale pass,
339
303
  not a green one — "we checked last cycle" is not a verification.
@@ -59,9 +59,8 @@ function missing(m: BanalMissing): string {
59
59
 
60
60
  type Kind = BanalFailure["kind"];
61
61
  /** One sentence-writer per variant. A mapped type over `kind`, so a new variant without one is a compile error. */
62
- type Describers = {
63
- readonly [K in Kind]: (f: Extract<BanalFailure, { kind: K }>) => Lines;
64
- };
62
+ type FailureOf = { readonly [K in Kind]: Extract<BanalFailure, { kind: K }> };
63
+ type Describers = { readonly [K in Kind]: (f: FailureOf[K]) => Lines };
65
64
 
66
65
  const orNone = (s: string): string => s || "no output";
67
66
 
@@ -101,15 +100,15 @@ const DESCRIBE: Describers = {
101
100
  };
102
101
 
103
102
  /**
104
- * What to tell a person. Most failures are one line; a sha256 mismatch shows both hashes.
105
- *
106
- * The one assertion below narrows the table's entry for `f.kind` to a function of `f`: the mapped
107
- * type already pairs each kind with its own variant, and TypeScript cannot correlate the index with
108
- * the argument on its own.
103
+ * The describer for `kind`, applied to its own variant. Generic over the kind, so the table's entry
104
+ * and the argument are correlated through `FailureOf[K]` and need no assertion (TypeScript#47109).
109
105
  */
106
+ const describeKind = <K extends Kind>(kind: K, f: FailureOf[K]): Lines =>
107
+ DESCRIBE[kind](f);
108
+
109
+ /** What to tell a person. Most failures are one line; a sha256 mismatch shows both hashes. */
110
110
  export function describe(f: BanalFailure): Lines {
111
- const write = DESCRIBE[f.kind] as (f: BanalFailure) => Lines;
112
- return write(f);
111
+ return describeKind(f.kind, f);
113
112
  }
114
113
 
115
114
  /** `describe` as one line, for a caller that has a single line to fill. */
@@ -7,7 +7,7 @@
7
7
  import assert from "node:assert/strict";
8
8
  import { test } from "vitest";
9
9
  import { whyNoGeometry } from "../../domain/geometry.ts";
10
- import type { AbsolutePath } from "../../domain/paths.ts";
10
+ import { absolutePath } from "../../domain/paths.ts";
11
11
  import type { ProcessExit } from "../../ports/process.ts";
12
12
  import { sha256Hex } from "../../domain/sha256.ts";
13
13
  import {
@@ -21,7 +21,7 @@ import type { Ready } from "../../ports/tool-installer.ts";
21
21
  import { banalInstaller, banalMeasurer, parseBanalSettings } from "./index.ts";
22
22
 
23
23
  const dirs = { home: "/h", tmp: "/t", cwd: "/r" };
24
- const project = "/r" as AbsolutePath;
24
+ const project = absolutePath("/r");
25
25
  const MEASURED =
26
26
  '{"papersize":[792,612],"columns":2,"bodyfontsize":9,"pages":[{},{"type":"bib","reffontsize":7}]}';
27
27
 
@@ -14,7 +14,8 @@ import type { Geometry, Provenance } from "../../domain/geometry.ts";
14
14
  import type { AbsolutePath } from "../../domain/paths.ts";
15
15
  import { err, ok } from "../../domain/result.ts";
16
16
  import type { MeasureGeometry } from "../../ports/measure-geometry.ts";
17
- import type { Ready, ToolInstaller } from "../../ports/tool-installer.ts";
17
+ import { ready, type Ready } from "../../domain/ready.ts";
18
+ import type { ToolInstaller } from "../../ports/tool-installer.ts";
18
19
  import { describe } from "./failure.ts";
19
20
  import { provenanceLabel, type BanalCandidate } from "./locate.ts";
20
21
  import { pinLabel, type BanalSource } from "./pin.ts";
@@ -65,15 +66,12 @@ export function banalMeasurer(
65
66
  }
66
67
 
67
68
  /** The one place banal's `Ready` is minted: from an `Installed`, whose `PinnedBanal` only run.ts mints. */
68
- const ready = (i: Installed): Ready => {
69
- // Widened by annotation: the brand of the path is not part of `Ready`'s shape.
70
- const where: string = i.banal.path;
71
- return {
72
- where,
69
+ const readyOf = (i: Installed): Ready =>
70
+ ready({
71
+ where: i.banal.path,
73
72
  fresh: i.fresh,
74
73
  verified: "sha256 verified, and it measured a probe page",
75
- } as Ready;
76
- };
74
+ });
77
75
 
78
76
  /**
79
77
  * banal as the `ToolInstaller` port: download at the pin, check the sha256, accept by measuring a
@@ -91,12 +89,12 @@ export function banalInstaller(
91
89
  ...(source ? { source } : {}),
92
90
  onDownload: report,
93
91
  });
94
- return r.ok ? ok(ready(r.value)) : err(describe(r.error));
92
+ return r.ok ? ok(readyOf(r.value)) : err(describe(r.error));
95
93
  },
96
94
  check() {
97
95
  const r = checkBanal(d, s, source);
98
96
  return r.ok
99
- ? ok(ready({ banal: r.value, fresh: false }))
97
+ ? ok(readyOf({ banal: r.value, fresh: false }))
100
98
  : err(describe(r.error));
101
99
  },
102
100
  };
@@ -15,14 +15,19 @@ export interface ShaMismatch {
15
15
  readonly got: Sha256;
16
16
  }
17
17
 
18
+ // The brand's one owner: the predicate IS the pin check, so no assertion is needed to mint the type.
19
+ const isPinned = (
20
+ bytes: Uint8Array,
21
+ source: BanalSource,
22
+ ): bytes is PinnedBytes => sha256Hex(bytes) === source.sha256;
23
+
18
24
  export function verifyPin(
19
25
  bytes: Uint8Array,
20
26
  source: BanalSource,
21
27
  ): Result<PinnedBytes, ShaMismatch> {
22
- const got = sha256Hex(bytes);
23
- return got === source.sha256
24
- ? ok(bytes as PinnedBytes)
25
- : err({ expected: source.sha256, got });
28
+ return isPinned(bytes, source)
29
+ ? ok(bytes)
30
+ : err({ expected: source.sha256, got: sha256Hex(bytes) });
26
31
  }
27
32
 
28
33
  /** What is installed, judged against the pin. */
@@ -11,15 +11,15 @@ import { tmpdir } from "node:os";
11
11
  import { join } from "node:path";
12
12
  import { afterAll as after, test } from "vitest";
13
13
  import { nodeAdapters } from "../node/index.ts";
14
- import type { AbsolutePath } from "../../domain/paths.ts";
14
+ import { absolutePath } from "../../domain/paths.ts";
15
+ import type { Scratch } from "../../ports/workspace.ts";
15
16
  import {
16
17
  banalCommand,
18
+ parseShQuoted,
17
19
  shQuote,
18
20
  stage,
19
21
  stageBanalInput,
20
- type StagedInput,
21
22
  } from "./invocation.ts";
22
- import type { LocatedBanal } from "./locate.ts";
23
23
  import { XML_DIALECT } from "./xml.ts";
24
24
 
25
25
  test("the staging holds BOTH files: the XML and the -v stub answering the dialect paperlint writes", () => {
@@ -32,11 +32,14 @@ test("the staging holds BOTH files: the XML and the -v stub answering the dialec
32
32
  });
33
33
 
34
34
  test("banalCommand: perl runs banal on the staged .xml, with $PDFTOHTML quoted", () => {
35
- const banal = {
36
- path: "/b/banal" as AbsolutePath,
37
- provenance: { kind: "cache" },
38
- } as LocatedBanal;
39
- const staged = { xml: "/s/paper.xml", stub: "/s d/pdftohtml" } as StagedInput;
35
+ // A scratch that places the two files in different directories, one with a space.
36
+ const scratch: Scratch = {
37
+ dir: absolutePath("/s"),
38
+ write: (name) =>
39
+ absolutePath(name === "paper.xml" ? "/s/paper.xml" : "/s d/pdftohtml"),
40
+ };
41
+ const staged = stage(scratch, stageBanalInput([]));
42
+ const banal = { path: absolutePath("/b/banal") };
40
43
  const c = banalCommand(banal, staged, { PATH: "/bin" });
41
44
  assert.deepEqual(
42
45
  [c.file, ...c.args],
@@ -50,6 +53,15 @@ test("shQuote survives a single quote", () => {
50
53
  assert.equal(shQuote("it's"), `'it'"'"'s'`);
51
54
  });
52
55
 
56
+ test("parseShQuoted refuses a word the shell would split or expand", () => {
57
+ assert.equal(parseShQuoted(`'a b'`), `'a b'`);
58
+ assert.throws(() => parseShQuoted("a b"), /not one single-quoted shell word/);
59
+ assert.throws(
60
+ () => parseShQuoted(`'a'b'`),
61
+ /not one single-quoted shell word/,
62
+ );
63
+ });
64
+
53
65
  const root = realpathSync(mkdtempSync(join(tmpdir(), "paperlint-stage-test-")));
54
66
  after(() => {
55
67
  rmSync(root, { recursive: true, force: true });
@@ -13,7 +13,7 @@ import type { Opaque } from "ts-essentials";
13
13
  import type { AbsolutePath } from "../../domain/paths.ts";
14
14
  import type { Command } from "../../ports/process.ts";
15
15
  import type { Scratch } from "../../ports/workspace.ts";
16
- import type { LocatedBanal } from "./locate.ts";
16
+ import type { BanalCandidate } from "./locate.ts";
17
17
  import type { PageLayout } from "../../domain/page-layout.ts";
18
18
  import { pdf2xml, XML_DIALECT } from "./xml.ts";
19
19
 
@@ -23,9 +23,19 @@ export const BANAL_RUN_MS = 120_000;
23
23
  /** A path quoted for `/bin/sh`. Minted by `shQuote` only. */
24
24
  export type ShQuoted = Opaque<string, "ShQuoted">;
25
25
 
26
+ // One single-quoted word: any run of non-quotes, each quote spelled `'"'"'`. What `shQuote` writes.
27
+ const SH_QUOTED = /^'(?:[^']|'"'"')*'$/;
28
+ const isShQuoted = (s: string): s is ShQuoted => SH_QUOTED.test(s);
29
+
30
+ /** A word already quoted for `/bin/sh`, checked; anything else throws. */
31
+ export function parseShQuoted(s: string): ShQuoted {
32
+ if (!isShQuoted(s)) throw new Error(`not one single-quoted shell word: ${s}`);
33
+ return s;
34
+ }
35
+
26
36
  /** banal interpolates `$PDFTOHTML` into a shell command unquoted — so the value is quoted here. */
27
37
  export const shQuote = (s: string): ShQuoted =>
28
- `'${s.replace(/'/g, `'"'"'`)}'` as ShQuoted;
38
+ parseShQuoted(`'${s.replace(/'/g, `'"'"'`)}'`);
29
39
 
30
40
  /** The stub standing in for `pdftohtml`: it answers `-v` and refuses to convert anything. */
31
41
  export const PDFTOHTML_STUB = [
@@ -64,11 +74,15 @@ export const stageBanalInput = (
64
74
  ],
65
75
  });
66
76
 
77
+ // Not exported: only `stage` can write the property, so only it can make a StagedInput.
78
+ const STAGED = Symbol("StagedInput");
79
+
67
80
  /** The staging written to disk. Minted by `stage` only: both files written, or nothing returned. */
68
- export type StagedInput = Opaque<
69
- { readonly xml: AbsolutePath; readonly stub: AbsolutePath },
70
- "StagedInput"
71
- >;
81
+ export interface StagedInput {
82
+ readonly xml: AbsolutePath;
83
+ readonly stub: AbsolutePath;
84
+ readonly [STAGED]: true;
85
+ }
72
86
 
73
87
  /** Write a staging into a scratch directory, the stub executable. The only minter of `StagedInput`. */
74
88
  export function stage(s: Scratch, staging: BanalStaging): StagedInput {
@@ -76,12 +90,13 @@ export function stage(s: Scratch, staging: BanalStaging): StagedInput {
76
90
  return {
77
91
  xml: s.write(xml.name, xml.content, xml.mode),
78
92
  stub: s.write(stub.name, stub.content, stub.mode),
79
- } as StagedInput;
93
+ [STAGED]: true,
94
+ };
80
95
  }
81
96
 
82
97
  /** `perl banal -no-time -json <xml>`, with `$PDFTOHTML` quoted by construction. */
83
98
  export function banalCommand(
84
- banal: LocatedBanal,
99
+ banal: Pick<BanalCandidate, "path">,
85
100
  staged: StagedInput,
86
101
  baseEnv: Readonly<Record<string, string>>,
87
102
  ): Command {
@@ -1,13 +1,13 @@
1
1
  import assert from "node:assert/strict";
2
2
  import { test } from "vitest";
3
- import type { AbsolutePath } from "../../domain/paths.ts";
3
+ import { absolutePath } from "../../domain/paths.ts";
4
4
  import { err } from "../../domain/result.ts";
5
5
  import { installedBanal, lookupOrder, pickBanal } from "./locate.ts";
6
6
  import { BANAL_PIN } from "./pin.ts";
7
7
  import { parseBanalSettings } from "./settings.ts";
8
8
 
9
9
  const dirs = { home: "/h", tmp: "/t", cwd: "/w" };
10
- const project = "/p" as AbsolutePath;
10
+ const project = absolutePath("/p");
11
11
  const cache = `/h/.cache/paperlint/banal/${BANAL_PIN.commit.slice(0, 12)}/banal`;
12
12
  const on =
13
13
  (...files: string[]) =>
@@ -3,9 +3,7 @@
3
3
  * `$BANAL` (an explicit choice — if it names nothing, there is NO fallback), `<project>/vendor/banal`
4
4
  * (a project that vendors its own copy), then the one `paperlint toolchain` installed.
5
5
  */
6
- import { join } from "node:path";
7
- import type { Opaque } from "ts-essentials";
8
- import type { AbsolutePath } from "../../domain/paths.ts";
6
+ import { joinPath, type AbsolutePath } from "../../domain/paths.ts";
9
7
  import { err, ok, type Result } from "../../domain/result.ts";
10
8
  import { BANAL_PIN } from "./pin.ts";
11
9
  import type { BanalSettings } from "./settings.ts";
@@ -20,14 +18,20 @@ export interface BanalCandidate {
20
18
  readonly provenance: Provenance;
21
19
  }
22
20
 
23
- /** A candidate the `Files` port confirmed is a file. Minted by `pickBanal` only. */
24
- export type LocatedBanal = Opaque<BanalCandidate, "LocatedBanal">;
21
+ // Not exported: only this module can write the property, so only `locate` can make a LocatedBanal.
22
+ const LOCATED = Symbol("LocatedBanal");
25
23
 
26
- /**
27
- * `paperlint toolchain`'s banal after its bytes hashed to the pin AND it measured the probe page. Minted by
28
- * `ensureBanal` / `checkBanal` only (`./index.ts`): a "ready" line cannot be printed without one.
29
- */
30
- export type PinnedBanal = Opaque<BanalCandidate, "PinnedBanal">;
24
+ /** A candidate the `Files` port confirmed is a file. Minted by `pickBanal` (through `locate`) only. */
25
+ export type LocatedBanal = BanalCandidate & { readonly [LOCATED]: true };
26
+
27
+ /** `path` as a banal to run — when the `Files` port says it is a file, else null. */
28
+ function locate(
29
+ path: AbsolutePath,
30
+ kind: Provenance["kind"],
31
+ isFile: (p: AbsolutePath) => boolean,
32
+ ): LocatedBanal | null {
33
+ return isFile(path) ? { path, provenance: { kind }, [LOCATED]: true } : null;
34
+ }
31
35
 
32
36
  /** Why there is no banal to run. */
33
37
  export type BanalMissing =
@@ -47,7 +51,7 @@ export type LookupOrder =
47
51
 
48
52
  /** Where `paperlint toolchain` puts the pinned banal: one directory per HotCRP commit. */
49
53
  export const installedBanal = (s: BanalSettings): AbsolutePath =>
50
- join(s.cacheDir, BANAL_PIN.commit.slice(0, 12), "banal") as AbsolutePath;
54
+ joinPath(s.cacheDir, BANAL_PIN.commit.slice(0, 12), "banal");
51
55
 
52
56
  export function lookupOrder(
53
57
  s: BanalSettings,
@@ -56,25 +60,27 @@ export function lookupOrder(
56
60
  if (s.explicit) return { kind: "explicit", path: s.explicit };
57
61
  return {
58
62
  kind: "search",
59
- vendor: join(projectRoot, "vendor", "banal") as AbsolutePath,
63
+ vendor: joinPath(projectRoot, "vendor", "banal"),
60
64
  cache: installedBanal(s),
61
65
  };
62
66
  }
63
67
 
64
- const located = (path: AbsolutePath, kind: Provenance["kind"]) =>
65
- ok({ path, provenance: { kind } } as LocatedBanal);
66
-
67
68
  export function pickBanal(
68
69
  order: LookupOrder,
69
70
  isFile: (p: AbsolutePath) => boolean,
70
71
  ): Result<LocatedBanal, BanalMissing> {
71
- if (order.kind === "explicit")
72
- return isFile(order.path)
73
- ? located(order.path, "env")
72
+ if (order.kind === "explicit") {
73
+ const own = locate(order.path, "env", isFile);
74
+ return own
75
+ ? ok(own)
74
76
  : err({ kind: "explicit-not-found", path: order.path });
75
- if (isFile(order.vendor)) return located(order.vendor, "vendor");
76
- if (isFile(order.cache)) return located(order.cache, "cache");
77
- return err({ kind: "not-installed", installed: order.cache });
77
+ }
78
+ const found =
79
+ locate(order.vendor, "vendor", isFile) ??
80
+ locate(order.cache, "cache", isFile);
81
+ return found
82
+ ? ok(found)
83
+ : err({ kind: "not-installed", installed: order.cache });
78
84
  }
79
85
 
80
86
  /** Which rule found it, as a person reads it. */
@@ -18,7 +18,7 @@ import { checkBanal, ensureBanal, measureGeometry } from "./run.ts";
18
18
  import { sha256Hex } from "../../domain/sha256.ts";
19
19
  import { installedBanal } from "./locate.ts";
20
20
  import { parseBanalSettings } from "./settings.ts";
21
- import type { AbsolutePath } from "../../domain/paths.ts";
21
+ import { absolutePath } from "../../domain/paths.ts";
22
22
  import type { Command, ProcessExit } from "../../ports/process.ts";
23
23
 
24
24
  const s = parseBanalSettings(
@@ -29,7 +29,7 @@ const noExplicit = parseBanalSettings(
29
29
  { PATH: "/bin" },
30
30
  { home: "/h", tmp: "/t", cwd: "/w" },
31
31
  );
32
- const project = "/p" as AbsolutePath;
32
+ const project = absolutePath("/p");
33
33
  /** What banal prints for the one-page probe. */
34
34
  const MEASURED = '{"bodyfontsize": 10.3, "columns": 1, "pages": [{}]}';
35
35
  const banalAnswers = (e: ProcessExit) =>
@@ -44,8 +44,6 @@ import {
44
44
  lookupOrder,
45
45
  pickBanal,
46
46
  type BanalCandidate,
47
- type LocatedBanal,
48
- type PinnedBanal,
49
47
  } from "./locate.ts";
50
48
  import {
51
49
  geometryOf,
@@ -89,11 +87,14 @@ export type BanalOutcome =
89
87
  readonly tried: BanalCandidate | null;
90
88
  };
91
89
 
92
- /** Run `banal` on `pages` in a scratch directory that is gone when this returns. */
90
+ /**
91
+ * Run `banal` on `pages` in a scratch directory that is gone when this returns. It needs the path
92
+ * only: `measureGeometry` passes the banal `pickBanal` located, `probe` the one whose bytes it verified.
93
+ */
93
94
  function runBanal(
94
95
  d: BanalDeps,
95
96
  s: BanalSettings,
96
- banal: LocatedBanal,
97
+ banal: Pick<BanalCandidate, "path">,
97
98
  pages: readonly PageLayout[],
98
99
  ): Result<BanalMeasurement, BanalFailure> {
99
100
  return d.workspace.within("paperlint-banal-", (scratch) =>
@@ -148,6 +149,15 @@ function perlRuns(d: BanalDeps, s: BanalSettings): boolean {
148
149
  return r.kind === "exited" && r.status === 0;
149
150
  }
150
151
 
152
+ // Not exported: only `probe` below can write the property, so only it can make a PinnedBanal.
153
+ const PINNED = Symbol("PinnedBanal");
154
+
155
+ /**
156
+ * `paperlint toolchain`'s banal after its bytes hashed to the pin AND it measured the probe page. Minted by
157
+ * `probe` only, for `ensureBanal` / `checkBanal` (`./index.ts`): a "ready" line cannot be printed without one.
158
+ */
159
+ export type PinnedBanal = BanalCandidate & { readonly [PINNED]: true };
160
+
151
161
  /**
152
162
  * Does the installed, pin-verified banal RUN — accepted by measuring the probe page, not by a
153
163
  * download's exit code. The one place a `PinnedBanal` is minted; callers verified the bytes first.
@@ -157,13 +167,9 @@ function probe(
157
167
  s: BanalSettings,
158
168
  path: AbsolutePath,
159
169
  ): Result<PinnedBanal, BanalFailure> {
160
- const at: BanalCandidate = { path, provenance: { kind: "cache" } };
161
- const r = andThen(
162
- runBanal(d, s, at as LocatedBanal, [PROBE_PAGE]),
163
- acceptProbe,
164
- );
170
+ const r = andThen(runBanal(d, s, { path }, [PROBE_PAGE]), acceptProbe);
165
171
  return r.ok
166
- ? ok(at as PinnedBanal)
172
+ ? ok({ path, provenance: { kind: "cache" }, [PINNED]: true })
167
173
  : err({ kind: "does-not-run", path, why: r.error });
168
174
  }
169
175