paperlint 16.8.0 → 17.1.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 (300) hide show
  1. package/CLAUDE.md +10 -2
  2. package/CONTRIBUTING.md +1 -1
  3. package/README.md +17 -14
  4. package/dist/adapters/latex/abstract.d.ts +7 -1
  5. package/dist/adapters/latex/abstract.d.ts.map +1 -1
  6. package/dist/adapters/latex/abstract.js +19 -4
  7. package/dist/adapters/latex/abstract.js.map +1 -1
  8. package/dist/adapters/latex/captions.d.ts +6 -5
  9. package/dist/adapters/latex/captions.d.ts.map +1 -1
  10. package/dist/adapters/latex/captions.js +14 -30
  11. package/dist/adapters/latex/captions.js.map +1 -1
  12. package/dist/adapters/latex/index.d.ts +1 -1
  13. package/dist/adapters/latex/index.d.ts.map +1 -1
  14. package/dist/adapters/latex/index.js +5 -2
  15. package/dist/adapters/latex/index.js.map +1 -1
  16. package/dist/adapters/latex/prose.d.ts +6 -0
  17. package/dist/adapters/latex/prose.d.ts.map +1 -1
  18. package/dist/adapters/latex/prose.js +18 -12
  19. package/dist/adapters/latex/prose.js.map +1 -1
  20. package/dist/cli.d.ts +6 -1
  21. package/dist/cli.d.ts.map +1 -1
  22. package/dist/cli.js +16 -8
  23. package/dist/cli.js.map +1 -1
  24. package/dist/domain/register.d.ts +23 -1
  25. package/dist/domain/register.d.ts.map +1 -1
  26. package/dist/domain/register.js +37 -14
  27. package/dist/domain/register.js.map +1 -1
  28. package/dist/domain/term-definitions.d.ts +48 -0
  29. package/dist/domain/term-definitions.d.ts.map +1 -0
  30. package/dist/domain/term-definitions.js +228 -0
  31. package/dist/domain/term-definitions.js.map +1 -0
  32. package/dist/domain/tex-document.d.ts +11 -0
  33. package/dist/domain/tex-document.d.ts.map +1 -1
  34. package/dist/domain/tex-document.js.map +1 -1
  35. package/dist/eslint-rules/review-frontmatter.js +5 -5
  36. package/dist/eslint-rules/review-frontmatter.schema.json +15 -8
  37. package/dist/eslint-rules/sibling-frontmatter.d.ts.map +1 -1
  38. package/dist/folder-venue-rule.d.ts +1 -1
  39. package/dist/folder-venue-rule.d.ts.map +1 -1
  40. package/dist/folder-venue-rule.js +4 -2
  41. package/dist/folder-venue-rule.js.map +1 -1
  42. package/dist/hooks-notice.d.ts +3 -3
  43. package/dist/hooks-notice.d.ts.map +1 -1
  44. package/dist/hooks-notice.js +41 -8
  45. package/dist/hooks-notice.js.map +1 -1
  46. package/dist/link-skills.d.ts +5 -0
  47. package/dist/link-skills.d.ts.map +1 -1
  48. package/dist/link-skills.js +7 -0
  49. package/dist/link-skills.js.map +1 -1
  50. package/dist/ports/latex.d.ts +11 -1
  51. package/dist/ports/latex.d.ts.map +1 -1
  52. package/dist/presets.d.ts +21 -2
  53. package/dist/presets.d.ts.map +1 -1
  54. package/dist/presets.js +66 -17
  55. package/dist/presets.js.map +1 -1
  56. package/dist/readability.d.ts +12 -2
  57. package/dist/readability.d.ts.map +1 -1
  58. package/dist/readability.js +76 -3
  59. package/dist/readability.js.map +1 -1
  60. package/dist/register-bands.d.ts +16 -5
  61. package/dist/register-bands.d.ts.map +1 -1
  62. package/dist/register-bands.js +56 -17
  63. package/dist/register-bands.js.map +1 -1
  64. package/dist/skills/argument-arc/scripts/headings-core.d.ts +12 -0
  65. package/dist/skills/argument-arc/scripts/headings.d.ts +2 -0
  66. package/dist/skills/cold-read-diff/scripts/cold-read-core.d.ts +12 -0
  67. package/dist/skills/cold-read-diff/scripts/readers.d.ts +2 -1
  68. package/dist/term-definition-rules.d.ts +26 -0
  69. package/dist/term-definition-rules.d.ts.map +1 -0
  70. package/dist/term-definition-rules.js +137 -0
  71. package/dist/term-definition-rules.js.map +1 -0
  72. package/dist/tex-paper.d.ts +6 -0
  73. package/dist/tex-paper.d.ts.map +1 -1
  74. package/dist/tex-paper.js +10 -0
  75. package/dist/tex-paper.js.map +1 -1
  76. package/dist/tex-requirements.d.ts +2 -0
  77. package/dist/tex-requirements.d.ts.map +1 -1
  78. package/dist/tex-requirements.js +9 -0
  79. package/dist/tex-requirements.js.map +1 -1
  80. package/dist/tex-venue-rules.d.ts +3 -2
  81. package/dist/tex-venue-rules.d.ts.map +1 -1
  82. package/dist/tex-venue-rules.js +3 -2
  83. package/dist/tex-venue-rules.js.map +1 -1
  84. package/docs/configuration.md +2 -2
  85. package/{skills/paper-pipeline/references → docs/design}/acceptance-gate.md +50 -53
  86. package/docs/design/paper-pipeline-history.md +217 -0
  87. package/docs/design/skill-provenance.md +132 -0
  88. package/docs/design/study-modes.md +1 -1
  89. package/docs/design/verify-citations-history.md +135 -0
  90. package/docs/design/writing-exemplars.md +19 -0
  91. package/docs/install.md +7 -4
  92. package/docs/layout.md +5 -4
  93. package/docs/optional-rules.md +4 -0
  94. package/docs/osf-artifact.md +54 -0
  95. package/docs/pipeline.md +171 -0
  96. package/docs/render.md +82 -0
  97. package/docs/rules/paper/folder-venue-leftover.md +10 -7
  98. package/docs/rules/tex/contrast-frames.md +1 -2
  99. package/docs/rules/tex/max-caption-words.md +82 -0
  100. package/docs/rules/tex/max-paragraph-words.md +2 -2
  101. package/docs/rules/tex/negated-sentences.md +96 -0
  102. package/docs/rules/tex/term-before-definition.md +103 -0
  103. package/docs/rules/tex/term-defined-twice.md +62 -0
  104. package/docs/rules/tex/venue-leftover.md +13 -1
  105. package/docs/rules.md +23 -18
  106. package/docs/skills.md +16 -21
  107. package/docs/submission.md +14 -0
  108. package/docs/texlive-install-decision.md +1 -1
  109. package/docs/toolchain.md +11 -11
  110. package/eslint-rules/review-frontmatter.schema.json +15 -8
  111. package/eslint-rules/review-frontmatter.test.mjs +8 -5
  112. package/eslint-rules/review-frontmatter.ts +5 -5
  113. package/eslint.config.mjs +1 -5
  114. package/hooks/paper-status-gates.sh +21 -4
  115. package/hooks/paper-status-gates.test.ts +51 -0
  116. package/lib/skill-checks.test.mjs +2 -6
  117. package/lib/skill-trigger-cases.mjs +12 -97
  118. package/lib/skill-trigger-cases.test.ts +0 -6
  119. package/package.json +3 -1
  120. package/presets/acm-sigconf.md +1 -1
  121. package/presets/agenticdev.jsonc +5 -2
  122. package/presets/agenticdev.md +4 -2
  123. package/presets/aidc.jsonc +14 -1
  124. package/presets/aidc.md +3 -2
  125. package/presets/aisec.jsonc +9 -3
  126. package/presets/aisec.md +4 -1
  127. package/presets/ase.jsonc +145 -0
  128. package/presets/ase.md +178 -0
  129. package/presets/ccs.jsonc +87 -0
  130. package/presets/ccs.md +184 -0
  131. package/presets/icse.jsonc +100 -0
  132. package/presets/icse.md +126 -0
  133. package/presets/ieee-conference.md +1 -1
  134. package/presets/sp.jsonc +152 -0
  135. package/presets/sp.md +160 -0
  136. package/presets/venue-profile.schema.json +22 -3
  137. package/scripts/harness-api.frozen.json +0 -4
  138. package/scripts/pipeline.ts +481 -0
  139. package/skills/CLAUDE.md +2 -2
  140. package/skills/CLAUDE.md.spec.ts +26 -1
  141. package/skills/analyze-sibling-paper/SKILL.md +2 -20
  142. package/skills/analyze-sibling-paper/SKILL.md.spec.ts +9 -19
  143. package/skills/argument-arc/SKILL.md +32 -18
  144. package/skills/argument-arc/SKILL.md.spec.ts +43 -17
  145. package/skills/argument-arc/scripts/headings-core.js +46 -0
  146. package/skills/argument-arc/scripts/headings-core.ts +65 -0
  147. package/skills/argument-arc/scripts/headings.js +15 -0
  148. package/skills/argument-arc/scripts/headings.test.ts +105 -0
  149. package/skills/argument-arc/scripts/headings.ts +20 -0
  150. package/skills/build-benchmark/SKILL.md +1 -12
  151. package/skills/build-benchmark/SKILL.md.spec.ts +15 -11
  152. package/skills/build-label-page/SKILL.md.spec.ts +11 -0
  153. package/skills/camera-ready/SKILL.md +1 -8
  154. package/skills/camera-ready/SKILL.md.spec.ts +8 -7
  155. package/skills/cold-read-diff/SKILL.md +36 -25
  156. package/skills/cold-read-diff/SKILL.md.spec.ts +44 -24
  157. package/skills/cold-read-diff/scripts/cold-read-core.js +63 -6
  158. package/skills/cold-read-diff/scripts/cold-read-core.ts +81 -6
  159. package/skills/cold-read-diff/scripts/cold-read.js +1 -1
  160. package/skills/cold-read-diff/scripts/cold-read.test.ts +66 -0
  161. package/skills/cold-read-diff/scripts/cold-read.ts +1 -1
  162. package/skills/cold-read-diff/scripts/readers.js +2 -1
  163. package/skills/cold-read-diff/scripts/readers.ts +2 -1
  164. package/skills/draft-paper/SKILL.md +16 -29
  165. package/skills/draft-paper/SKILL.md.spec.ts +27 -28
  166. package/skills/extend-paper/SKILL.md +7 -16
  167. package/skills/extend-paper/SKILL.md.spec.ts +18 -15
  168. package/skills/find-venue/SKILL.md +11 -24
  169. package/skills/find-venue/SKILL.md.spec.ts +19 -23
  170. package/skills/harden-paper/SKILL.md +62 -290
  171. package/skills/harden-paper/SKILL.md.spec.ts +82 -304
  172. package/skills/harden-paper/harden-paper.harness.mjs +1 -2
  173. package/skills/jobs.ts +25 -0
  174. package/skills/label-agent-runs/SKILL.md.spec.ts +10 -0
  175. package/skills/map-prior-work/SKILL.md +5 -4
  176. package/skills/map-prior-work/SKILL.md.spec.ts +13 -3
  177. package/skills/paper-pipeline/SKILL.md +80 -278
  178. package/skills/paper-pipeline/SKILL.md.spec.ts +130 -276
  179. package/skills/paper-pipeline/description-language.eval.mjs +0 -22
  180. package/skills/paper-pipeline/framing-vs-vocabulary.eval.mjs +0 -29
  181. package/skills/paper-pipeline/paper-pipeline.harness.mjs +0 -16
  182. package/skills/paper-pipeline/pipeline-firing.eval.mjs +7 -29
  183. package/skills/paper-pipeline/pipeline-language.eval.mjs +0 -52
  184. package/skills/paper-pipeline/references/artifact-checklist.md +6 -1
  185. package/skills/paper-pipeline/references/body-vs-appendix.md +3 -4
  186. package/skills/paper-pipeline/references/pipeline-status-template.md +8 -10
  187. package/skills/paper-pipeline/references/review-ratchet.md +4 -7
  188. package/skills/paper-pipeline/references/venue-bar.md +1 -2
  189. package/skills/paper-pipeline/references/writing-craft.md +21 -281
  190. package/skills/paper-status/SKILL.md +17 -20
  191. package/skills/paper-status/SKILL.md.spec.ts +23 -19
  192. package/skills/pc-panel-review/SKILL.md +66 -93
  193. package/skills/pc-panel-review/SKILL.md.spec.ts +75 -92
  194. package/skills/plan-paper-timeline/SKILL.md +7 -29
  195. package/skills/plan-paper-timeline/SKILL.md.spec.ts +16 -28
  196. package/skills/plan-paper-timeline/plan-paper-timeline.effects.harness.mjs +2 -2
  197. package/skills/render-paper/check-render.sh +2 -2
  198. package/skills/render-paper/render-paper.harness.mjs +4 -20
  199. package/skills/research-ideate/SKILL.md +15 -32
  200. package/skills/research-ideate/SKILL.md.spec.ts +25 -31
  201. package/skills/rewrite-unclear/SKILL.md +15 -14
  202. package/skills/rewrite-unclear/SKILL.md.spec.ts +24 -15
  203. package/skills/rewrite-unclear/rewrite-unclear.eval.ts +2 -3
  204. package/skills/run-agent-grid/SKILL.md +3 -3
  205. package/skills/run-agent-grid/SKILL.md.spec.ts +10 -2
  206. package/skills/study-accepted-papers/SKILL.md +5 -5
  207. package/skills/study-accepted-papers/SKILL.md.spec.ts +27 -4
  208. package/skills/submit-paper/SKILL.md +37 -31
  209. package/skills/submit-paper/SKILL.md.spec.ts +46 -30
  210. package/skills/submit-paper/check-deanon.sh +1 -1
  211. package/skills/tighten-paper/SKILL.md +43 -68
  212. package/skills/tighten-paper/SKILL.md.spec.ts +51 -67
  213. package/skills/verify-citations/SKILL.md +18 -112
  214. package/skills/verify-citations/SKILL.md.spec.ts +27 -114
  215. package/src/adapters/latex/abstract.test.ts +42 -0
  216. package/src/adapters/latex/abstract.ts +23 -6
  217. package/src/adapters/latex/captions.test.ts +36 -38
  218. package/src/adapters/latex/captions.ts +16 -33
  219. package/src/adapters/latex/index.test.ts +11 -0
  220. package/src/adapters/latex/index.ts +5 -2
  221. package/src/adapters/latex/prose.ts +23 -11
  222. package/src/cli.ts +26 -5
  223. package/src/domain/register.test.ts +65 -0
  224. package/src/domain/register.ts +72 -16
  225. package/src/domain/term-definitions.test.ts +240 -0
  226. package/src/domain/term-definitions.ts +329 -0
  227. package/src/domain/tex-document.ts +12 -0
  228. package/src/domain/venue-name.test.ts +4 -4
  229. package/src/folder-venue-rule.test.ts +23 -2
  230. package/src/folder-venue-rule.ts +8 -8
  231. package/src/hooks-notice.test.ts +127 -0
  232. package/src/hooks-notice.ts +50 -10
  233. package/src/link-skills.ts +9 -0
  234. package/src/new-paper.test.ts +2 -2
  235. package/src/paper-settings-commands.test.ts +1 -1
  236. package/src/ports/latex.ts +11 -0
  237. package/src/preset-card-rule.test.ts +4 -0
  238. package/src/presets.test.ts +141 -4
  239. package/src/presets.ts +113 -22
  240. package/src/readability.test.ts +92 -0
  241. package/src/readability.ts +113 -5
  242. package/src/register-bands.test.ts +81 -1
  243. package/src/register-bands.ts +88 -23
  244. package/src/rule-cases.test.ts +122 -2
  245. package/src/term-definition-rules.test.ts +150 -0
  246. package/src/term-definition-rules.ts +189 -0
  247. package/src/tex-paper.test.ts +18 -1
  248. package/src/tex-paper.ts +11 -0
  249. package/src/tex-requirements.ts +15 -0
  250. package/src/tex-venue-rules.test.ts +45 -1
  251. package/src/tex-venue-rules.ts +8 -3
  252. package/src/venue-rules.test.ts +2 -2
  253. package/templates/paper/PIPELINE-STATUS.md +19 -19
  254. package/dist/paper-prose.d.ts +0 -17
  255. package/dist/paper-prose.d.ts.map +0 -1
  256. package/dist/paper-prose.js +0 -46
  257. package/dist/paper-prose.js.map +0 -1
  258. package/skills/grade-paper-writing/SKILL.md +0 -494
  259. package/skills/grade-paper-writing/SKILL.md.spec.ts +0 -501
  260. package/skills/grade-paper-writing/__snapshots__/prose-lint.test.ts.snap +0 -84
  261. package/skills/grade-paper-writing/fixtures/control_gopen.txt +0 -1
  262. package/skills/grade-paper-writing/fixtures/control_human_paper.txt +0 -1
  263. package/skills/grade-paper-writing/fixtures/rewrite.txt +0 -1
  264. package/skills/grade-paper-writing/fixtures/specimen.txt +0 -1
  265. package/skills/grade-paper-writing/fixtures/structure-checks.md +0 -22
  266. package/skills/grade-paper-writing/grade-paper-writing.eval.mjs +0 -19
  267. package/skills/grade-paper-writing/grade-paper-writing.harness.mjs +0 -23
  268. package/skills/grade-paper-writing/prose-lint.mjs +0 -602
  269. package/skills/grade-paper-writing/prose-lint.test.ts +0 -413
  270. package/skills/osf-artifact-upload/SKILL.md +0 -58
  271. package/skills/osf-artifact-upload/SKILL.md.spec.ts +0 -65
  272. package/skills/osf-artifact-upload/osf-artifact-upload.eval.mjs +0 -22
  273. package/skills/osf-artifact-upload/osf-artifact-upload.harness.ts +0 -102
  274. package/skills/paper-adversarial-review/SKILL.md +0 -100
  275. package/skills/paper-adversarial-review/SKILL.md.spec.ts +0 -107
  276. package/skills/paper-adversarial-review/paper-adversarial-review.eval.mjs +0 -19
  277. package/skills/paper-adversarial-review/paper-adversarial-review.harness.mjs +0 -24
  278. package/skills/paper-pipeline/grade-paper-writing-ablation.eval.mjs +0 -1274
  279. package/skills/paper-pipeline/references/credit-criteria.md +0 -69
  280. package/skills/paper-pipeline/references/occupancy-2026-08-06-probe/README.md +0 -35
  281. package/skills/paper-pipeline/references/occupancy-2026-08-06-probe/run_retext.mjs +0 -24
  282. package/skills/paper-pipeline/references/occupancy-2026-08-06-probe/sentences.txt +0 -11
  283. package/skills/paper-pipeline/references/occupancy-2026-08-06-probe/test_sentences.py +0 -25
  284. package/skills/paper-pipeline/references/occupancy-2026-08-06-prose-checkers.md +0 -538
  285. package/skills/paper-pipeline/references/occupancy-2026-08-06-reproducible-tooling.md +0 -431
  286. package/skills/paper-pipeline/references/occupancy-2026-08-06-staleness-and-orchestration.md +0 -592
  287. package/skills/paper-pipeline/repro/2026-08-08-parent-replication.mjs +0 -92
  288. package/skills/render-paper/SKILL.md +0 -123
  289. package/skills/render-paper/SKILL.md.spec.ts +0 -130
  290. package/skills/render-paper/render-paper.eval.mjs +0 -19
  291. package/skills/submission-portal/SKILL.md +0 -129
  292. package/skills/submission-portal/SKILL.md.spec.ts +0 -134
  293. package/skills/submission-portal/submission-portal.eval.mjs +0 -15
  294. package/skills/submission-portal/submission-portal.test.ts +0 -12
  295. package/skills/sweep-design-space/SKILL.md +0 -232
  296. package/skills/sweep-design-space/SKILL.md.spec.ts +0 -248
  297. package/skills/sweep-design-space/sweep-design-space.eval.mjs +0 -19
  298. package/skills/sweep-design-space/sweep-design-space.harness.mjs +0 -23
  299. package/src/paper-prose.test.ts +0 -78
  300. package/src/paper-prose.ts +0 -67
@@ -0,0 +1,240 @@
1
+ /**
2
+ * Terms against their definitions, on real parses: what is read as a definition, what as a use,
3
+ * and the two findings — a use before the first definition, a definition set again.
4
+ */
5
+ import { describe, expect, it } from "vitest";
6
+ import { latexReader } from "../adapters/latex/index.ts";
7
+ import { bodySentences } from "./register.ts";
8
+ import {
9
+ DEFAULT_TERM_OPTIONS,
10
+ definedAgain,
11
+ definitionsOf,
12
+ isDefinition,
13
+ usedBefore,
14
+ usePattern,
15
+ usesOf,
16
+ type TermOptions,
17
+ } from "./term-definitions.ts";
18
+
19
+ const doc = (body: string, abstract = ""): string =>
20
+ `\\documentclass{article}\n\\begin{document}\n${
21
+ abstract === "" ? "" : `\\begin{abstract}\n${abstract}\n\\end{abstract}\n`
22
+ }${body}\n\\end{document}\n`;
23
+
24
+ /** The paper as the rules read it: definitions, sentences, the abstract's span. */
25
+ const read = (src: string, opts: TermOptions = DEFAULT_TERM_OPTIONS) => {
26
+ const abstract = latexReader.abstractSpan(src);
27
+ return {
28
+ abstract,
29
+ defs: definitionsOf(latexReader.bodyEmphasis(src), opts, abstract),
30
+ sentences: bodySentences(latexReader.bodyProse(src)),
31
+ };
32
+ };
33
+
34
+ /** The terms the body defines, as written. */
35
+ const defined = (src: string, opts?: TermOptions): readonly string[] =>
36
+ read(src, opts).defs.map((d) => d.text);
37
+
38
+ /** Each term used before its definition: `term: first use … definition (count)`, as source text. */
39
+ const before = (src: string, opts?: TermOptions): readonly string[] => {
40
+ const r = read(src, opts);
41
+ return usedBefore(r.defs, r.sentences, r.abstract).map(
42
+ (u) =>
43
+ `${u.term}: ${src.slice(u.firstUse.start, u.firstUse.end)} @${String(u.firstUse.start < u.definition.span.start)} ×${String(u.count)}`,
44
+ );
45
+ };
46
+
47
+ /** Each later definition, as its source text and the first's. */
48
+ const again = (src: string, opts?: TermOptions): readonly string[] =>
49
+ definedAgain(read(src, opts).defs).map(
50
+ (d) =>
51
+ `${src.slice(d.again.span.start, d.again.span.end)} after ${src.slice(d.first.span.start, d.first.span.end)}`,
52
+ );
53
+
54
+ describe("a definition: a phrase set with the commands, 1–maxWords words, a word that names something", () => {
55
+ it("🔴 \\emph by default; \\textit, \\textbf and a {\\em …} group only when the option names them", () => {
56
+ const src = doc(
57
+ "A \\emph{witness} is a file. A \\textit{gate} blocks. A {\\em probe} asks. A \\textbf{guard} stops.",
58
+ );
59
+ expect(defined(src)).toEqual(["witness"]);
60
+ // Guards: \textit sets titles and variable names too, so it is read only on request.
61
+ expect(
62
+ defined(src, { commands: ["textit", "em", "textbf"], maxWords: 4 }),
63
+ ).toEqual(["gate", "probe", "guard"]);
64
+ });
65
+
66
+ it("🔴 not a phrase longer than maxWords, holding a digit, ending on a stop, or of function words only", () => {
67
+ expect(
68
+ defined(
69
+ doc(
70
+ "We define \\emph{a long phrase of five words}, \\emph{run 2}, \\emph{gain:} and \\emph{not}. We did \\emph{not all} of it. A \\emph{read set} is kept.",
71
+ ),
72
+ ),
73
+ ).toEqual(["read set"]);
74
+ expect(
75
+ defined(doc("We define \\emph{a long phrase of five words}."), {
76
+ commands: ["emph"],
77
+ maxWords: 6,
78
+ }),
79
+ ).toEqual(["a long phrase of five words"]);
80
+ });
81
+
82
+ it("🔴 not one in the abstract; not a run-in heading; an item's label counts", () => {
83
+ expect(
84
+ defined(
85
+ doc(
86
+ "\\emph{Scope.} The scope is narrow.\n\\begin{itemize}\n\\item \\emph{Gate}: blocks a call.\n\\end{itemize}",
87
+ "We study \\emph{witness} files.",
88
+ ),
89
+ ),
90
+ ).toEqual(["Gate"]);
91
+ });
92
+
93
+ it("an emphasised phrase of no word at all is none", () => {
94
+ expect(
95
+ isDefinition(
96
+ {
97
+ style: "italic",
98
+ command: "emph",
99
+ place: "inline",
100
+ text: "",
101
+ span: { start: 0, end: 1 },
102
+ },
103
+ DEFAULT_TERM_OPTIONS,
104
+ null,
105
+ ),
106
+ ).toBe(false);
107
+ });
108
+ });
109
+
110
+ describe("a use: whole words, the term's forms, case ignored unless the term is in capitals", () => {
111
+ const matches = (term: string, text: string): readonly string[] =>
112
+ [...text.matchAll(usePattern(term))].map((m) => m[0]);
113
+
114
+ it("🔴 the forms: as written, +s, +es, y→ies, and without a final s; never inside a longer word", () => {
115
+ expect(matches("witness", "Witness witnesses witnessed")).toEqual([
116
+ "Witness",
117
+ "witnesses",
118
+ ]);
119
+ expect(matches("query", "queries query querying")).toEqual([
120
+ "queries",
121
+ "query",
122
+ ]);
123
+ expect(matches("gate", "gates gate gated")).toEqual(["gates", "gate"]);
124
+ expect(matches("rules", "a rule, two rules")).toEqual(["rule", "rules"]);
125
+ });
126
+
127
+ it("a term of several words matches across any spacing; one in capitals keeps its case", () => {
128
+ expect(matches("read set", "the read\n set and the Read Set")).toEqual([
129
+ "read\n set",
130
+ "Read Set",
131
+ ]);
132
+ expect(matches("CI", "CI runs; ci is not it")).toEqual(["CI"]);
133
+ expect(matches("c++", "in c++ and c")).toEqual(["c++"]);
134
+ });
135
+ });
136
+
137
+ describe("tex/term-before-definition's finding: the first use before the first definition", () => {
138
+ it("🔴 reports the first earlier use once, with how many there are", () => {
139
+ expect(
140
+ before(
141
+ doc(
142
+ "A gate runs. Every gate blocks.\n\nA \\emph{gate} is a check that blocks a call. The gate holds.",
143
+ ),
144
+ ),
145
+ ).toEqual(["gate: gate @true ×2"]);
146
+ });
147
+
148
+ it("🔴 silent when the first use is the definition, and for a use in the defining sentence", () => {
149
+ expect(
150
+ before(
151
+ doc(
152
+ "A file the two readings disagree on, the witness, is a \\emph{witness}. The witness is kept.",
153
+ ),
154
+ ),
155
+ ).toEqual([]);
156
+ });
157
+
158
+ it("🔴 a use in the abstract is no use", () => {
159
+ expect(
160
+ before(
161
+ doc(
162
+ "A \\emph{witness} is a file. The witness is kept.",
163
+ "We find a witness in each repository.",
164
+ ),
165
+ ),
166
+ ).toEqual([]);
167
+ });
168
+
169
+ it("silent for a term used only after it, a \\textit use is still a use, a table cell is no use", () => {
170
+ expect(
171
+ before(
172
+ doc(
173
+ "\\begin{tabular}{l}witness\\end{tabular}\nA \\emph{witness} is a file. The witness is kept.",
174
+ ),
175
+ ),
176
+ ).toEqual([]);
177
+ expect(
178
+ before(
179
+ doc("The \\textit{witness} came first. A \\emph{witness} is a file."),
180
+ ),
181
+ ).toEqual(["witness: witness @true ×1"]);
182
+ });
183
+ });
184
+
185
+ describe("a term written in capitals keeps its case", () => {
186
+ it("🔴 \\emph{CI} is used before by «CI», never by «ci»; \\emph{ci} is another term, of any case", () => {
187
+ const src = doc(
188
+ "The ci script runs. Our CI blocks.\n\nWe call the check \\emph{CI}. Later a \\emph{ci} job.",
189
+ );
190
+ // «CI» matches only «CI» (one earlier use); «ci», written in lower case, matches every case:
191
+ // «ci», «CI», and the «CI» of the sentence defining the other term.
192
+ expect(before(src)).toEqual(["CI: CI @true ×1", "ci: ci @true ×3"]);
193
+ expect(again(src)).toEqual([]);
194
+ });
195
+ });
196
+
197
+ describe("tex/term-defined-twice's finding: each later definition", () => {
198
+ it("🔴 every definition after the first, in document order, against the first", () => {
199
+ expect(
200
+ again(
201
+ doc(
202
+ "A \\emph{witness} is a file. A \\emph{gate} blocks. Again, a \\emph{gate} is a check. A \\emph{Witness} is that file.",
203
+ ),
204
+ ),
205
+ ).toEqual([
206
+ "\\emph{gate} after \\emph{gate}",
207
+ "\\emph{Witness} after \\emph{witness}",
208
+ ]);
209
+ });
210
+
211
+ it("silent for one definition, a run-in heading after it, and a \\textit setting", () => {
212
+ expect(
213
+ again(
214
+ doc(
215
+ "A \\emph{witness} is a file.\n\n\\emph{Witness.} A witness is kept. The \\textit{witness} again.",
216
+ ),
217
+ ),
218
+ ).toEqual([]);
219
+ });
220
+ });
221
+
222
+ describe("a sentence or a match the parser gave no place is never a use", () => {
223
+ it("reports nothing it cannot place", () => {
224
+ const run = { segments: [{ text: "witness", at: 10 }] } as const;
225
+ // A sentence reaching past its run, as no parse yields: no span, so no use.
226
+ const lost = {
227
+ text: "witness here",
228
+ raw: "witness here",
229
+ words: 2,
230
+ first: "witness",
231
+ run,
232
+ from: 0,
233
+ };
234
+ expect(usesOf("witness", [lost], [], null)).toEqual([]);
235
+ const fits = { ...lost, text: "witness", raw: "witness" };
236
+ expect(usesOf("witness", [fits], [], null)).toEqual([
237
+ { start: 10, end: 17 },
238
+ ]);
239
+ });
240
+ });
@@ -0,0 +1,329 @@
1
+ /**
2
+ * A TERM USED BEFORE ITS DEFINITION, OR DEFINED TWICE — what `tex/term-before-definition` and
3
+ * `tex/term-defined-twice` judge. Pure: the body's emphasised phrases and sentences in, findings out.
4
+ *
5
+ * ── THE CONVENTION IT READS ──────────────────────────────────────────────────────
6
+ * A paper that sets a new word in italics where it explains it («a file that one reading flags and
7
+ * the other passes is a \emph{witness}») has marked the definition in its markup. From that phrase
8
+ * on, the reader knows the word. A definition is a phrase set with one of the `commands` (default
9
+ * `emph`) that:
10
+ *
11
+ * - stands in the body, outside the abstract (a summary read on its own: neither a definition
12
+ * nor a use there counts);
13
+ * - is 1 to `maxWords` words (default 4) — a longer phrase is stress, not a term;
14
+ * - holds no digit (an italic number is a result) and does not end on a stop or a comma;
15
+ * - holds a word outside FUNCTION_WORDS («\emph{not}», «\emph{only}» stress a word, name nothing).
16
+ *
17
+ * A run-in heading (`\emph{Scope.} …`) is no definition: the reader never gives it (`bodyEmphasis`).
18
+ *
19
+ * ── WHAT A USE IS ────────────────────────────────────────────────────────────────
20
+ * The term in a body sentence: whole words, case ignored (a term written in capitals, «CI», keeps
21
+ * its case), any spacing between its words, its last word as written, `+s`, `+es`, `y→ies`, or —
22
+ * when it ends in `s` — without it. Not a use: one in the abstract, and one in a sentence that
23
+ * holds a definition of the term («a file, which we call a \emph{witness}» defines once).
24
+ * No lemmatizer: «witnesses» is not «witness».
25
+ */
26
+ import { groupBy, isNonNull, isTruthy, sortBy, values } from "remeda";
27
+ import type { BodySentence } from "./register.ts";
28
+ import type { Emphasis, Span } from "./tex-document.ts";
29
+ import { spanIn } from "./tex-document.ts";
30
+
31
+ /** What the rules read a definition as: the commands that mark one, and its longest phrase. */
32
+ export interface TermOptions {
33
+ readonly commands: readonly [string, ...string[]];
34
+ readonly maxWords: number;
35
+ }
36
+
37
+ export const DEFAULT_TERM_OPTIONS: TermOptions = {
38
+ commands: ["emph"],
39
+ maxWords: 4,
40
+ };
41
+
42
+ /** The commands the parser reports an emphasised phrase under: the values `commands` may hold. */
43
+ export const EMPHASIS_COMMANDS: readonly string[] = [
44
+ "emph",
45
+ "textit",
46
+ "textsl",
47
+ "textbf",
48
+ "underline",
49
+ "uline",
50
+ "em",
51
+ "itshape",
52
+ "it",
53
+ "slshape",
54
+ "bfseries",
55
+ "bf",
56
+ ];
57
+
58
+ /**
59
+ * Words that name nothing on their own: articles, conjunctions, negation, quantifiers, modals,
60
+ * pronouns, prepositions, auxiliaries. A closed list from grammar, not tuned to a corpus: a phrase
61
+ * of these alone is stress, not a term.
62
+ */
63
+ export const FUNCTION_WORDS: ReadonlySet<string> = new Set([
64
+ "a",
65
+ "an",
66
+ "the",
67
+ "and",
68
+ "or",
69
+ "but",
70
+ "nor",
71
+ "so",
72
+ "yet",
73
+ "not",
74
+ "no",
75
+ "only",
76
+ "all",
77
+ "any",
78
+ "some",
79
+ "each",
80
+ "every",
81
+ "both",
82
+ "either",
83
+ "neither",
84
+ "more",
85
+ "most",
86
+ "less",
87
+ "least",
88
+ "much",
89
+ "many",
90
+ "few",
91
+ "must",
92
+ "may",
93
+ "might",
94
+ "can",
95
+ "could",
96
+ "should",
97
+ "would",
98
+ "will",
99
+ "shall",
100
+ "do",
101
+ "does",
102
+ "did",
103
+ "is",
104
+ "are",
105
+ "was",
106
+ "were",
107
+ "be",
108
+ "been",
109
+ "has",
110
+ "have",
111
+ "had",
112
+ "this",
113
+ "that",
114
+ "these",
115
+ "those",
116
+ "it",
117
+ "its",
118
+ "we",
119
+ "our",
120
+ "they",
121
+ "their",
122
+ "before",
123
+ "after",
124
+ "always",
125
+ "never",
126
+ "also",
127
+ "very",
128
+ "too",
129
+ "just",
130
+ "even",
131
+ "still",
132
+ "then",
133
+ "there",
134
+ "here",
135
+ "what",
136
+ "which",
137
+ "who",
138
+ "when",
139
+ "where",
140
+ "why",
141
+ "how",
142
+ "if",
143
+ "than",
144
+ "as",
145
+ "of",
146
+ "in",
147
+ "on",
148
+ "at",
149
+ "to",
150
+ "for",
151
+ "from",
152
+ "by",
153
+ "with",
154
+ "without",
155
+ "into",
156
+ "over",
157
+ "under",
158
+ "per",
159
+ "via",
160
+ "about",
161
+ ]);
162
+
163
+ /** A phrase set as a definition: its term (the key two definitions share), as written, where. */
164
+ export interface Definition {
165
+ readonly term: string;
166
+ readonly text: string;
167
+ readonly command: string;
168
+ readonly span: Span;
169
+ }
170
+
171
+ const inside = (at: Span, area: Span | null): boolean =>
172
+ area !== null && at.start >= area.start && at.start < area.end;
173
+
174
+ const overlaps = (a: Span, b: Span): boolean =>
175
+ a.start < b.end && b.start < a.end;
176
+
177
+ /** A phrase written in capitals keeps its case; any other is compared lower-cased. */
178
+ const isCapitals = (text: string): boolean =>
179
+ /\p{Lu}/u.test(text) && text === text.toUpperCase();
180
+
181
+ const termOf = (text: string): string =>
182
+ isCapitals(text) ? text : text.toLowerCase();
183
+
184
+ /** Whether an emphasised phrase is a definition under `opts`, outside `abstract`. */
185
+ export function isDefinition(
186
+ e: Emphasis,
187
+ opts: TermOptions,
188
+ abstract: Span | null,
189
+ ): boolean {
190
+ const words = e.text.split(" ").filter(isTruthy);
191
+ return (
192
+ opts.commands.includes(e.command) &&
193
+ !inside(e.span, abstract) &&
194
+ words.length <= opts.maxWords &&
195
+ !/\p{N}/u.test(e.text) &&
196
+ !/[.:;,!?]$/u.test(e.text) &&
197
+ words.some((w) => !FUNCTION_WORDS.has(w.toLowerCase()))
198
+ );
199
+ }
200
+
201
+ /** The body's definitions under `opts`, in document order. */
202
+ export const definitionsOf = (
203
+ emphases: readonly Emphasis[],
204
+ opts: TermOptions,
205
+ abstract: Span | null,
206
+ ): readonly Definition[] =>
207
+ emphases
208
+ .filter((e) => isDefinition(e, opts, abstract))
209
+ .map((e) => ({
210
+ term: termOf(e.text),
211
+ text: e.text,
212
+ command: e.command,
213
+ span: e.span,
214
+ }));
215
+
216
+ const escaped = (s: string): string =>
217
+ s.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&");
218
+
219
+ /** The forms a word is used in: as written, `+s`, `+es`, `y→ies`, and without a final `s`. */
220
+ function formsOf(word: string): readonly string[] {
221
+ const e = escaped(word);
222
+ const ies = /y$/iu.test(word) ? [`${escaped(word.slice(0, -1))}ies`] : [];
223
+ const bare = /s$/iu.test(word) ? [escaped(word.slice(0, -1))] : [];
224
+ return [`${e}es`, `${e}s`, ...ies, e, ...bare];
225
+ }
226
+
227
+ /** The pattern of a term's uses: whole words, any spacing between them, the last word's forms. */
228
+ export function usePattern(term: string): Readonly<RegExp> {
229
+ const words = term.split(" ");
230
+ const body = words
231
+ .map((w, i) =>
232
+ i === words.length - 1 ? `(?:${formsOf(w).join("|")})` : escaped(w),
233
+ )
234
+ .join("\\s+");
235
+ return new RegExp(
236
+ `(?<![\\p{L}\\p{N}])${body}(?![\\p{L}\\p{N}])`,
237
+ isCapitals(term) ? "gu" : "giu",
238
+ );
239
+ }
240
+
241
+ /** A sentence with its span in the source; none when the parser gave it no place. */
242
+ const placed = (
243
+ s: BodySentence,
244
+ ): { readonly s: BodySentence; readonly span: Span } | null => {
245
+ const span = spanIn(s.run, s.from, s.from + s.raw.length);
246
+ return span === null ? null : { s, span };
247
+ };
248
+
249
+ /** Where the term is used in the body, in order: outside the abstract and every sentence defining it. */
250
+ export function usesOf(
251
+ term: string,
252
+ sentences: readonly BodySentence[],
253
+ definitions: readonly Span[],
254
+ abstract: Span | null,
255
+ ): readonly Span[] {
256
+ const pattern = usePattern(term);
257
+ return sentences
258
+ .map(placed)
259
+ .filter(isNonNull)
260
+ .filter(
261
+ ({ span }) =>
262
+ !inside(span, abstract) && !definitions.some((d) => overlaps(d, span)),
263
+ )
264
+ .flatMap(({ s }) =>
265
+ [...s.raw.matchAll(pattern)].map((m) =>
266
+ spanIn(s.run, s.from + m.index, s.from + m.index + m[0].length),
267
+ ),
268
+ )
269
+ .filter(isNonNull);
270
+ }
271
+
272
+ /** A term used before its first definition: the first use, how many uses precede it, the definition. */
273
+ export interface UsedBefore {
274
+ readonly term: string;
275
+ readonly definition: Definition;
276
+ readonly firstUse: Span;
277
+ readonly count: number;
278
+ }
279
+
280
+ /** A term set as a definition again: the later definition, and the first. */
281
+ export interface DefinedAgain {
282
+ readonly again: Definition;
283
+ readonly first: Definition;
284
+ }
285
+
286
+ /** Each term's definitions, the first first: in document order. */
287
+ const byTerm = (
288
+ defs: readonly Definition[],
289
+ ): readonly (readonly [Definition, ...Definition[]])[] =>
290
+ values(groupBy(defs, (d) => d.term));
291
+
292
+ /** Every term the body uses before its first definition, in the order of their definitions. */
293
+ export function usedBefore(
294
+ defs: readonly Definition[],
295
+ sentences: readonly BodySentence[],
296
+ abstract: Span | null,
297
+ ): readonly UsedBefore[] {
298
+ return byTerm(defs).flatMap((ds) => {
299
+ const [first] = ds;
300
+ const earlier = usesOf(
301
+ first.term,
302
+ sentences,
303
+ ds.map((d) => d.span),
304
+ abstract,
305
+ ).filter((u) => u.start < first.span.start);
306
+ const [firstUse] = earlier;
307
+ return firstUse === undefined
308
+ ? []
309
+ : [
310
+ {
311
+ term: first.text,
312
+ definition: first,
313
+ firstUse,
314
+ count: earlier.length,
315
+ },
316
+ ];
317
+ });
318
+ }
319
+
320
+ /** Every later definition of a term already defined, in document order. */
321
+ export const definedAgain = (
322
+ defs: readonly Definition[],
323
+ ): readonly DefinedAgain[] =>
324
+ sortBy(
325
+ byTerm(defs).flatMap((ds) =>
326
+ ds.slice(1).map((again) => ({ again, first: ds[0] })),
327
+ ),
328
+ (d) => d.again.span.start,
329
+ );
@@ -160,6 +160,12 @@ export interface Passage {
160
160
  readonly registeredNumbers: number;
161
161
  }
162
162
 
163
+ /** A caption a reader sees under a figure or a table: its prose, and the `\caption` it stands in. */
164
+ export interface Caption {
165
+ readonly passages: readonly [Passage, ...Passage[]];
166
+ readonly span: Span;
167
+ }
168
+
163
169
  /** How an emphasised phrase is set: bold, italic (or `\emph`), or underlined. */
164
170
  export type EmphasisStyle = "bold" | "italic" | "underline";
165
171
 
@@ -177,6 +183,12 @@ export type EmphasisPlace = "opening" | "inline";
177
183
  */
178
184
  export interface Emphasis {
179
185
  readonly style: EmphasisStyle;
186
+ /**
187
+ * The macro or declaration that set it, without its backslash: `emph`, `textit`, `em`, `itshape`…
188
+ * Two of one style are not one convention: `\emph` may mark a definition where `\textit` sets a
189
+ * title.
190
+ */
191
+ readonly command: string;
180
192
  readonly place: EmphasisPlace;
181
193
  readonly text: string;
182
194
  readonly span: Span;
@@ -31,7 +31,7 @@ describe("nameTokens — a name as the words it is made of", () => {
31
31
  /**
32
32
  * The venues are the SHIPPED presets, read through the one source of venue names
33
33
  * (`shippedVenueNames`) — never a list of names written here. A case below depends on what a preset
34
- * says (`aidc`'s alias ACSAC, `aisec`'s ACM CCS); a preset edit that changes it shows here.
34
+ * says (`aidc`'s alias ACSAC, `ccs`'s name ACM CCS); a preset edit that changes it shows here.
35
35
  */
36
36
  const VENUES: readonly NamedVenue[] = shippedVenueNames({
37
37
  files: nodeFiles,
@@ -43,11 +43,11 @@ describe("venuesNamedBy — which venues a folder name names", () => {
43
43
  ["the label", "aisec-2026", [{ venue: "AISec", name: "AISec" }]],
44
44
  ["an alias", "acsac-2026", [{ venue: "AIDC", name: "ACSAC" }]],
45
45
  [
46
- "a two-word alias, as two tokens in a row",
46
+ "a two-word name, as two tokens in a row",
47
47
  "acm-ccs-agents",
48
- [{ venue: "AISec", name: "ACM CCS" }],
48
+ [{ venue: "ACM CCS", name: "ACM CCS" }],
49
49
  ],
50
- ["the two words of an alias apart are not it", "acm-agents-ccs", []],
50
+ ["the two words of a name apart are not it", "acm-agents-ccs", []],
51
51
  ["glued to a year", "realm2026", [{ venue: "REALM", name: "REALM" }]],
52
52
  [
53
53
  "two venues, each once, in the order they are listed",
@@ -85,10 +85,10 @@ describe("paper/folder-venue-leftover — the folder names another venue", () =>
85
85
 
86
86
  it("a venue named by an alias says which alias", () => {
87
87
  expect(
88
- lint("acm-ccs-agents", AIDC).map(
88
+ lint("emnlp-agents", AIDC).map(
89
89
  (r) => /names the venue (.*?), and/u.exec(r.message)?.[1],
90
90
  ),
91
- ).toEqual(["AISec («ACM CCS»)"]);
91
+ ).toEqual(["REALM («EMNLP»)"]);
92
92
  });
93
93
 
94
94
  it("two other venues are two findings", () => {
@@ -129,6 +129,17 @@ describe("paper/folder-venue-leftover — the folder names another venue", () =>
129
129
  });
130
130
  });
131
131
 
132
+ describe("paper/folder-venue-leftover — a workshop's parent conference", () => {
133
+ it("🔴 in another venue's paper it is reported once, as itself", () => {
134
+ const named = (folder: string) =>
135
+ lint(folder, AIDC).map(
136
+ (r) => /names the venue (.*?), and/u.exec(r.message)?.[1],
137
+ );
138
+ expect(named("acm-ccs-agents")).toEqual(["ACM CCS"]);
139
+ expect(named("ase-agents")).toEqual(["ASE"]);
140
+ });
141
+ });
142
+
132
143
  describe("paper/folder-venue-leftover — silent", () => {
133
144
  it.each<[string, string, object | undefined]>([
134
145
  [
@@ -137,6 +148,16 @@ describe("paper/folder-venue-leftover — silent", () => {
137
148
  { extends: "paperlint:agenticdev", kind: "short" },
138
149
  ],
139
150
  ["by its alias", "acsac-2026", AIDC],
151
+ [
152
+ "the conference the workshop is held at (`parent`)",
153
+ "ase-agents",
154
+ { extends: "paperlint:agenticdev", kind: "short" },
155
+ ],
156
+ [
157
+ "the parent conference by its two words",
158
+ "acm-ccs-agents",
159
+ { extends: "paperlint:aisec", kind: "research" },
160
+ ],
140
161
  ["the folder names no venue", "agent-rule-drift", AIDC],
141
162
  // Whole words only: REALM is not inside these.
142
163
  ["a venue's name inside another word", "overrealm-realms", AIDC],
@@ -11,7 +11,8 @@
11
11
  * The folder's name, as the path module gives it (the directory of the linted file), its words
12
12
  * against each shipped venue's label and `aliases` (`src/domain/venue-name.ts`). The venues are
13
13
  * `otherVenues` — the presets not on this paper's own chain, the same list `tex/venue-leftover`
14
- * reads — and the paper's own label and aliases are never reported.
14
+ * reads — and the paper's own label and aliases, and its parent conference's names (`parentNames`),
15
+ * are never reported.
15
16
  *
16
17
  * ── WHICH FILE IT REPORTS ON ─────────────────────────────────────────────────────
17
18
  * The folder itself is not a file ESLint lints. `PIPELINE-STATUS.md` is: every paper folder has one
@@ -71,15 +72,14 @@ const shown = (n: NamedIn): string =>
71
72
  */
72
73
  export function judgeFolder(
73
74
  folder: string,
74
- preset: Pick<Preset, "label" | "aliases">,
75
+ preset: Pick<Preset, "label" | "aliases" | "parentNames">,
75
76
  others: readonly OtherVenue[],
76
77
  ): readonly Finding[] {
77
- return venuesNamedBy(folder, others, [preset.label, ...preset.aliases]).map(
78
- (n) => ({
79
- messageId: "leftover",
80
- data: { folder, other: shown(n), venue: preset.label },
81
- }),
82
- );
78
+ const own = [preset.label, ...preset.aliases, ...preset.parentNames];
79
+ return venuesNamedBy(folder, others, own).map((n) => ({
80
+ messageId: "leftover",
81
+ data: { folder, other: shown(n), venue: preset.label },
82
+ }));
83
83
  }
84
84
 
85
85
  /**