paperlint 18.2.1 → 18.3.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 (71) hide show
  1. package/.github/dependabot.yml +17 -0
  2. package/.github/workflows/ci.yml +30 -5
  3. package/CLAUDE.md +2 -1
  4. package/dist/domain/register.d.ts +1 -1
  5. package/dist/domain/register.d.ts.map +1 -1
  6. package/dist/domain/sentences.d.ts +3 -11
  7. package/dist/domain/sentences.d.ts.map +1 -1
  8. package/dist/domain/sentences.js +53 -8
  9. package/dist/domain/sentences.js.map +1 -1
  10. package/dist/eslint-rules/CLAUDE.md.spec.js +2 -2
  11. package/dist/eslint-rules/CLAUDE.md.spec.js.map +1 -1
  12. package/dist/folder-venue-rule.js +1 -1
  13. package/dist/readability.d.ts +12 -9
  14. package/dist/readability.d.ts.map +1 -1
  15. package/dist/readability.js +3 -3
  16. package/dist/readability.js.map +1 -1
  17. package/docs/design/paper-sources.md +1 -1
  18. package/docs/e2e.md +2 -2
  19. package/docs/optional-rules.md +2 -2
  20. package/docs/rules/pdf/body-size.md +1 -1
  21. package/docs/rules/tex/heading-case.md +2 -2
  22. package/docs/rules/tex/max-paragraph-numbers.md +13 -7
  23. package/docs/rules/tex/max-paragraph-words.md +17 -28
  24. package/docs/rules/tex/max-sentence-words.md +3 -2
  25. package/docs/rules/tex/negated-sentences.md +2 -2
  26. package/docs/rules/tex/register.md +1 -1
  27. package/docs/rules/tex/term-before-definition.md +1 -1
  28. package/docs/rules.md +3 -3
  29. package/docs/venues.md +1 -1
  30. package/docs/website.md +61 -5
  31. package/eslint-rules/CLAUDE.md +3 -3
  32. package/eslint-rules/CLAUDE.md.spec.ts +2 -2
  33. package/eslint.config.mjs +15 -4
  34. package/fixtures/real-papers.test.ts +24 -19
  35. package/package.json +4 -5
  36. package/presets/acm-sigconf.jsonc +1 -1
  37. package/presets/aidc-2026.jsonc +4 -4
  38. package/presets/aidc-2026.md +1 -1
  39. package/presets/ase-2026.md +1 -1
  40. package/presets/ieee-conference.jsonc +1 -1
  41. package/presets/msr-2027.jsonc +1 -1
  42. package/presets/neurips-style.jsonc +2 -2
  43. package/presets/neurips-style.md +1 -1
  44. package/presets/sp-2027.md +1 -1
  45. package/presets/venue-profile.schema.json +1 -1
  46. package/scripts/check.ts +9 -1
  47. package/scripts/coverage-config.test.ts +2 -0
  48. package/scripts/grow-real-papers/archive.test.ts +294 -0
  49. package/scripts/grow-real-papers/archive.ts +287 -0
  50. package/scripts/grow-real-papers/collect.test.ts +329 -0
  51. package/scripts/grow-real-papers/collect.ts +316 -0
  52. package/scripts/grow-real-papers/http.test.ts +95 -0
  53. package/scripts/grow-real-papers/http.ts +76 -0
  54. package/scripts/grow-real-papers/main.test.ts +295 -0
  55. package/scripts/grow-real-papers/main.ts +221 -0
  56. package/scripts/grow-real-papers/paper.test.ts +305 -0
  57. package/scripts/grow-real-papers/paper.ts +241 -0
  58. package/scripts/grow-real-papers/rules.test.ts +222 -0
  59. package/scripts/grow-real-papers/rules.ts +250 -0
  60. package/scripts/grow-real-papers/sources.test.ts +275 -0
  61. package/scripts/grow-real-papers/sources.ts +239 -0
  62. package/scripts/grow-real-papers/testkit.ts +79 -0
  63. package/src/domain/register.ts +1 -1
  64. package/src/domain/sentences.test.ts +128 -0
  65. package/src/domain/sentences.ts +60 -11
  66. package/src/folder-venue-rule.test.ts +1 -1
  67. package/src/folder-venue-rule.ts +1 -1
  68. package/src/readability.test.ts +82 -41
  69. package/src/readability.ts +12 -9
  70. package/src/register-bands.test.ts +4 -4
  71. package/src/rule-cases.test.ts +6 -6
@@ -0,0 +1,305 @@
1
+ /**
2
+ * What a kept paper becomes: the preset it is linted as, its files, its manifest entry and its note.
3
+ */
4
+ import * as R from "remeda";
5
+ import { describe, expect, test } from "vitest";
6
+ import { recordOf, stagingPlan, type StagingPlan } from "./archive.ts";
7
+ import { keptPaper, presetFor, slug, type Kept } from "./paper.ts";
8
+ import { preambleOf, type Slot } from "./rules.ts";
9
+ import { file, mainTex } from "./testkit.ts";
10
+
11
+ const slot: Slot = {
12
+ field: "nlp",
13
+ series: "ACL",
14
+ year: 2025,
15
+ cap: 1,
16
+ queries: [],
17
+ max_results: 50,
18
+ venue: "acl",
19
+ classSpec: "acl",
20
+ };
21
+ const main = mainTex("Hi.", "\\documentclass[11pt]{article}");
22
+ const plan = (files = [file("sub/main.tex", main)]): StagingPlan => {
23
+ const p = stagingPlan(files);
24
+ if (!p.ok) throw new Error(p.reason);
25
+ return p;
26
+ };
27
+ const base: Kept = {
28
+ c: {
29
+ id: "2501.00001v2",
30
+ updated: "2025-05-20",
31
+ title: "A Title",
32
+ comment: "Accepted at ACL 2025",
33
+ journal_ref: "",
34
+ category: "cs.CL",
35
+ authors: ["Ann", "Bo"],
36
+ rank: 3,
37
+ query: 'co:"ACL 2025"',
38
+ },
39
+ slot,
40
+ track: null,
41
+ licence: {
42
+ key: "http://creativecommons.org/licenses/by/4.0/",
43
+ name: "CC BY 4.0",
44
+ url: "https://creativecommons.org/licenses/by/4.0/",
45
+ },
46
+ plan: plan(),
47
+ preamble: preambleOf(main),
48
+ style: "acl",
49
+ styleOpts: "",
50
+ sourceSha: "abc",
51
+ shipped: new Set(),
52
+ };
53
+
54
+ /** The README of `base`, whole. */
55
+ const README = `# A Title
56
+
57
+ - **Authors:** Ann, Bo
58
+ - **Source:** arXiv [2501.00001v2](https://arxiv.org/abs/2501.00001v2), e-print \`https://arxiv.org/src/2501.00001v2\` (sha256 \`abc\`)
59
+ - **Category:** cs.CL; **document class:** \`[11pt]{article}\`, **style package:** \`acl\`
60
+ - **Licence:** [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/), as the arXiv abstract page states. The files are redistributed under it.
61
+ - **Accepted at:** ACL 2025. The arXiv comment of [2501.00001v2](https://arxiv.org/abs/2501.00001v2) says: «Accepted at ACL 2025»
62
+ - **Linted as:** \`paperlint:acl-latex\`, the camera-ready of an accepted attempt (the ACL style family as no preset ships for this edition)
63
+ - **Text sources only, figures omitted.** Kept: \`.tex\`, \`.bib\`, \`.bbl\`, \`.cls\`, \`.sty\`, \`.bst\`, \`.cfg\`, \`.def\`, each at its path from the archive's root, where arXiv compiles. Dropped: images, PDFs, data.
64
+ - **Renamed, nothing inside changed:** \`sub/main.tex\` to \`paper.tex\`.
65
+ - **Ours:** \`paperlint.json\`, \`PIPELINE-STATUS.md\`, \`record-by-hand.json\`, \`baseline.json\`, \`README.md\`.
66
+
67
+ \`paperlint.json\` records one attempt, accepted, whose evidence is this file. Its dates are those of the arXiv version that states the acceptance: the real decision day is earlier and not known here. \`record-by-hand.json\` is NOT TeX's answer: it lists \`paper.tex\`, the class and style files at the root, then the \`\\input\`/\`\\include\` files in the order the source names them, hashed over the bytes here. See [\`../README.md\`](../README.md).
68
+ `;
69
+
70
+ describe("the preset", () => {
71
+ const ccs = { series: "ACM CCS", year: 2025 };
72
+ test.each([
73
+ {
74
+ name: "a shipped edition, by its alias",
75
+ s: ccs,
76
+ cls: "{acmart}",
77
+ style: undefined,
78
+ preset: "paperlint:ccs-2025",
79
+ },
80
+ {
81
+ name: "the style's family",
82
+ s: slot,
83
+ cls: "{article}",
84
+ style: "neurips_2025",
85
+ preset: "paperlint:neurips-style",
86
+ },
87
+ {
88
+ name: "acmart sigconf",
89
+ s: slot,
90
+ cls: "[sigconf]{acmart}",
91
+ style: undefined,
92
+ preset: "paperlint:acm-sigconf",
93
+ },
94
+ {
95
+ name: "acmart in another format",
96
+ s: slot,
97
+ cls: "[acmtog]{acmart}",
98
+ style: undefined,
99
+ preset: null,
100
+ },
101
+ {
102
+ name: "IEEEtran conference",
103
+ s: slot,
104
+ cls: "[conference]{IEEEtran}",
105
+ style: undefined,
106
+ preset: "paperlint:ieee-conference",
107
+ },
108
+ {
109
+ name: "IEEEtran journal",
110
+ s: slot,
111
+ cls: "[journal]{IEEEtran}",
112
+ style: undefined,
113
+ preset: null,
114
+ },
115
+ {
116
+ name: "no family",
117
+ s: slot,
118
+ cls: "{article}",
119
+ style: undefined,
120
+ preset: null,
121
+ },
122
+ ])("$name", ({ s, cls, style, preset }) => {
123
+ const p = preambleOf(`\\documentclass${cls}`);
124
+ // Guards: which preset, never a guess outside the families.
125
+ expect(presetFor(s, p, style, new Set(["ccs-2025"])).preset).toBe(preset);
126
+ });
127
+ });
128
+
129
+ describe("a kept paper", () => {
130
+ test("its files: the sources, the record, the status, the cycle and the README", () => {
131
+ const k = keptPaper(base);
132
+ // Guards: what lands in the paper's directory.
133
+ expect([...k.files.keys()]).toEqual([
134
+ "paper.tex",
135
+ "record-by-hand.json",
136
+ "PIPELINE-STATUS.md",
137
+ "paperlint.json",
138
+ "README.md",
139
+ ]);
140
+ // Guards: the record is the staged sources' record.
141
+ expect(k.files.get("record-by-hand.json")).toBe(
142
+ `${JSON.stringify(recordOf(base.plan.staged), null, 2)}\n`,
143
+ );
144
+ // Guards: the cycle a lint run reads.
145
+ expect(JSON.parse(String(k.files.get("paperlint.json")))).toEqual({
146
+ cycles: [
147
+ {
148
+ id: "acl-2025",
149
+ venue: { kind: "preset", extends: "paperlint:acl-latex" },
150
+ opened: "2025-05-20",
151
+ outcome: {
152
+ kind: "accepted",
153
+ date: "2025-05-20",
154
+ evidence: "README.md",
155
+ },
156
+ },
157
+ ],
158
+ });
159
+ // Guards: the generated README, whole (it is the output, every paper's from one template).
160
+ expect(k.files.get("README.md")).toBe(README);
161
+ });
162
+ });
163
+
164
+ describe("a kept paper's entry", () => {
165
+ test("its manifest entry and note, from a comment", () => {
166
+ const k = keptPaper({
167
+ ...base,
168
+ track: "Findings",
169
+ c: { ...base.c, journal_ref: "Findings of ACL 2025" },
170
+ });
171
+ // Guards: every field balance.ts and the baselines read.
172
+ expect(k.entry).toEqual({
173
+ arxiv_id: "2501.00001v2",
174
+ license: "http://creativecommons.org/licenses/by/4.0/",
175
+ source_sha256: "abc",
176
+ main_tex: "./sub/main.tex",
177
+ class: "article",
178
+ category: "cs.CL",
179
+ size_bytes: main.length,
180
+ dir: "2501.00001v2",
181
+ accepted: {
182
+ quote: "Accepted at ACL 2025 | journal-ref: Findings of ACL 2025",
183
+ url: "https://arxiv.org/abs/2501.00001v2",
184
+ venue: "ACL 2025 (Findings)",
185
+ },
186
+ preset: "paperlint:acl-latex",
187
+ kind: null,
188
+ field: "nlp",
189
+ series: "ACL",
190
+ year: 2025,
191
+ track: "Findings",
192
+ source: "arxiv-comment",
193
+ acceptance: "arxiv-comment",
194
+ });
195
+ // Guards: the staging note a reviewer audits.
196
+ expect(k.note).toEqual({
197
+ clsOpts: "11pt",
198
+ style: "acl",
199
+ styleOpts: "",
200
+ mainCandidates: 1,
201
+ presetWhy: "the ACL style family as no preset ships for this edition",
202
+ edits: [],
203
+ renames: ["sub/main.tex to paper.tex"],
204
+ title: "A Title",
205
+ });
206
+ });
207
+ });
208
+
209
+ /** A paper kept from a Semantic Scholar listing, with no style. */
210
+ const listed = (publicationDate: string | null, comment: string) =>
211
+ keptPaper({
212
+ ...R.omit(base, ["style", "styleOpts"]),
213
+ c: { ...base.c, comment, s2: { venue: "OSDI", publicationDate } },
214
+ preamble: preambleOf("\\documentclass{article}"),
215
+ plan: plan([file("ms.tex", mainTex("")), file("w.tex", "\\input{ms}")]),
216
+ });
217
+
218
+ describe("a kept paper from a listing", () => {
219
+ test("from a Semantic Scholar listing, without a style or preset", () => {
220
+ const late = listed("2025-07-01", "");
221
+ const early = listed(null, "OSDI 2025");
222
+ // Guards: the listing is the evidence, and a version older than the venue date is said.
223
+ expect([
224
+ late.entry.accepted,
225
+ late.note.versionNote,
226
+ late.entry.source,
227
+ ]).toEqual([
228
+ {
229
+ quote:
230
+ 'Semantic Scholar venue listing: venue "OSDI", year 2025, publication date 2025-07-01',
231
+ url: "https://arxiv.org/abs/2501.00001v2",
232
+ venue: "ACL 2025",
233
+ },
234
+ "latest arXiv version (2025-05-20) predates the venue date (2025-07-01); kept the latest version",
235
+ "semantic-scholar",
236
+ ]);
237
+ // Guards: no date, and the comment appended to the quote.
238
+ expect([early.entry.accepted, early.note.versionNote]).toEqual([
239
+ {
240
+ quote:
241
+ 'Semantic Scholar venue listing: venue "OSDI", year 2025, publication date not given; arXiv comment: OSDI 2025',
242
+ url: "https://arxiv.org/abs/2501.00001v2",
243
+ venue: "ACL 2025",
244
+ },
245
+ "latest arXiv version 2025-05-20; venue date not given",
246
+ ]);
247
+ });
248
+ });
249
+
250
+ describe("a listed paper's files", () => {
251
+ test("a listed paper's README and cycle", () => {
252
+ const early = listed(null, "OSDI 2025");
253
+ const readme = String(early.files.get("README.md")).split("\n");
254
+ // Guards: the lines that differ for a listed paper with no preset and a rewritten wrapper.
255
+ expect([readme[4], readme[6], readme[7], readme[9]]).toEqual([
256
+ "- **Category:** cs.CL; **document class:** `[]{article}`",
257
+ '- **Accepted at:** ACL 2025. Semantic Scholar\'s venue listing (the proceedings) holds [2501.00001v2](https://arxiv.org/abs/2501.00001v2) — acceptance evidence without comment wording — query `co:"ACL 2025"`: «Semantic Scholar venue listing: venue "OSDI", year 2025, publication date not given; arXiv comment: OSDI 2025»',
258
+ "- **Linted as:** no preset (`extends` left out), the camera-ready of an accepted attempt (no preset ships for this edition and no template family matches the class: no `extends`, as arxiv-papers does for such papers, but with the accepted cycle)",
259
+ "- **Renamed, one thing changed inside:** `ms.tex` to `paper.tex`; `\\input{ms}` to `\\input{paper}`.",
260
+ ]);
261
+ // Guards: a named venue in the cycle, and the style left null in the note.
262
+ expect([
263
+ JSON.parse(String(early.files.get("paperlint.json"))),
264
+ early.note.style,
265
+ ]).toEqual([
266
+ {
267
+ cycles: [
268
+ {
269
+ id: "acl-2025",
270
+ venue: {
271
+ kind: "named",
272
+ name: "ACL 2025",
273
+ url: "https://arxiv.org/abs/2501.00001v2",
274
+ },
275
+ opened: "2025-05-20",
276
+ outcome: {
277
+ kind: "accepted",
278
+ date: "2025-05-20",
279
+ evidence: "README.md",
280
+ },
281
+ },
282
+ ],
283
+ },
284
+ null,
285
+ ]);
286
+ });
287
+ });
288
+
289
+ describe("the README's variants", () => {
290
+ test("a style with options, and a main file already named paper.tex", () => {
291
+ const k = keptPaper({
292
+ ...base,
293
+ styleOpts: "final",
294
+ plan: plan([file("paper.tex", main)]),
295
+ });
296
+ const readme = String(k.files.get("README.md")).split("\n");
297
+ // Guards: the options shown, and nothing renamed.
298
+ expect([readme[4], readme[9]]).toEqual([
299
+ "- **Category:** cs.CL; **document class:** `[11pt]{article}`, **style package:** `acl[final]`",
300
+ "- **Nothing renamed, nothing inside changed:** the main file was already paper.tex.",
301
+ ]);
302
+ // Guards: a slug of a series.
303
+ expect(slug("IEEE S&P")).toBe("ieee-s-p");
304
+ });
305
+ });
@@ -0,0 +1,241 @@
1
+ /**
2
+ * What a kept paper becomes: its directory's files (the staged sources, `record-by-hand.json`,
3
+ * `paperlint.json`, `PIPELINE-STATUS.md`, `README.md`), its `venue-manifest.json` entry, and its
4
+ * `staging-notes.json` note. Pure: the collector hands the bytes it fetched, and gets back what to write.
5
+ */
6
+ import { recordOf, type StagingPlan } from "./archive.ts";
7
+ import type { Preamble, Slot } from "./rules.ts";
8
+
9
+ /** One candidate paper, as the arXiv API (and, for a listing, Semantic Scholar) describes it. */
10
+ export type Candidate = Readonly<{
11
+ id: string;
12
+ updated: string;
13
+ title: string;
14
+ comment: string;
15
+ journal_ref: string;
16
+ category: string;
17
+ authors: readonly string[];
18
+ rank: number;
19
+ query: string;
20
+ /** Set when the candidate came from a Semantic Scholar venue listing. */
21
+ s2?: Readonly<{ venue: string; publicationDate: string | null }>;
22
+ }>;
23
+
24
+ export const slug = (s: string): string =>
25
+ s
26
+ .toLowerCase()
27
+ .replace(/[^a-z0-9]+/g, "-")
28
+ .replace(/^-|-$/g, "");
29
+
30
+ const FAMILIES: readonly (readonly [RegExp, string, string])[] = [
31
+ [/^(neurips|nips)_/, "neurips-style", "the NeurIPS style family"],
32
+ [/^icml/, "icml-style", "the ICML style family"],
33
+ [/^(acl|emnlp|naacl|eacl)/, "acl-latex", "the ACL style family"],
34
+ [/^aaai/, "aaai-press", "the AAAI Press style family"],
35
+ ];
36
+ const NONE = " as no preset ships for this edition";
37
+
38
+ type PresetChoice = Readonly<{ preset: string | null; why: string }>;
39
+ const ALIAS: Readonly<Record<string, string>> = {
40
+ "acm-ccs": "ccs",
41
+ "ieee-s-p": "sp",
42
+ };
43
+
44
+ /** The template family of an acmart or IEEEtran class, or null. */
45
+ const classFamily = (p: Preamble): PresetChoice | null => {
46
+ if (p.cls === "IEEEtran" && p.clsOpts.includes("conference"))
47
+ return {
48
+ preset: "paperlint:ieee-conference",
49
+ why: `the IEEE conference family${NONE}`,
50
+ };
51
+ if (p.cls !== "acmart") return null;
52
+ const fmt = /acmsmall|sigconf/.exec(p.clsOpts)?.[0];
53
+ return fmt === undefined
54
+ ? {
55
+ preset: null,
56
+ why: `no preset: the class is acmart with format [${p.clsOpts}], which is neither the sigconf nor the acmsmall family, and no preset ships for this edition`,
57
+ }
58
+ : {
59
+ preset: `paperlint:acm-${fmt}`,
60
+ why: `the acmart ${fmt} family${NONE}`,
61
+ };
62
+ };
63
+
64
+ /**
65
+ * The preset a paper is linted against: the edition's when paperlint ships it, else the family of
66
+ * its style or class, else none (a named venue, so no venue rule applies).
67
+ */
68
+ export function presetFor(
69
+ slot: Pick<Slot, "series" | "year">,
70
+ p: Preamble,
71
+ style: string | undefined,
72
+ shipped: ReadonlySet<string>,
73
+ ): PresetChoice {
74
+ const edition = `${ALIAS[slug(slot.series)] ?? slug(slot.series)}-${String(slot.year)}`;
75
+ if (shipped.has(edition))
76
+ return {
77
+ preset: `paperlint:${edition}`,
78
+ why: `the shipped edition preset ${edition}`,
79
+ };
80
+ const family = FAMILIES.find(([re]) => re.test(style ?? ""));
81
+ if (family !== undefined)
82
+ return { preset: `paperlint:${family[1]}`, why: family[2] + NONE };
83
+ return (
84
+ classFamily(p) ?? {
85
+ preset: null,
86
+ why: "no preset ships for this edition and no template family matches the class: no `extends`, as arxiv-papers does for such papers, but with the accepted cycle",
87
+ }
88
+ );
89
+ }
90
+
91
+ const pair = (r: string): string => {
92
+ const [from, to] = r.split(" to ");
93
+ return `\`${String(from)}\` to \`${String(to)}\``;
94
+ };
95
+
96
+ /** Everything the collector writes for one kept paper. */
97
+ export type KeptPaper = Readonly<{
98
+ id: string;
99
+ /** Path inside the paper's directory, to its bytes or text. */
100
+ files: ReadonlyMap<string, Uint8Array | string>;
101
+ entry: Readonly<Record<string, unknown>> & Readonly<{ arxiv_id: string }>;
102
+ note: Readonly<Record<string, unknown>>;
103
+ }>;
104
+
105
+ /** What the collector learned about a paper that passed rules 1 to 4. */
106
+ export type Kept = Readonly<{
107
+ c: Candidate;
108
+ slot: Slot;
109
+ track: string | null;
110
+ licence: Readonly<{ key: string; name: string; url: string }>;
111
+ plan: StagingPlan;
112
+ preamble: Preamble;
113
+ style?: string;
114
+ styleOpts?: string;
115
+ sourceSha: string;
116
+ shipped: ReadonlySet<string>;
117
+ }>;
118
+
119
+ const absUrl = (c: Candidate): string => `https://arxiv.org/abs/${c.id}`;
120
+ const venueOf = (k: Kept): string =>
121
+ `${k.slot.series} ${String(k.slot.year)}${k.track === null ? "" : ` (${k.track})`}`;
122
+
123
+ /** The acceptance evidence quoted in the manifest: the comment, or the listing. */
124
+ const quoteOf = ({ c, slot }: Kept): string =>
125
+ c.s2 === undefined
126
+ ? [c.comment, c.journal_ref && `journal-ref: ${c.journal_ref}`]
127
+ .filter(Boolean)
128
+ .join(" | ")
129
+ : `Semantic Scholar venue listing: venue "${c.s2.venue}", year ${String(slot.year)}, publication date ${c.s2.publicationDate ?? "not given"}${c.comment ? `; arXiv comment: ${c.comment}` : ""}`;
130
+
131
+ const changesOf = (plan: StagingPlan): string => {
132
+ const head = `${plan.renames.length > 0 ? "Renamed" : "Nothing renamed"}${plan.edits.length > 0 ? ", one thing changed inside" : ", nothing inside changed"}`;
133
+ const list = [
134
+ plan.renames.length > 0
135
+ ? plan.renames.map(pair).join(", ")
136
+ : "the main file was already paper.tex",
137
+ ...plan.edits.map(pair),
138
+ ].join("; ");
139
+ return `**${head}:** ${list}.`;
140
+ };
141
+
142
+ const readmeOf = (k: Kept, choice: PresetChoice): string => {
143
+ const { c, preamble: p } = k;
144
+ const style =
145
+ k.style === undefined
146
+ ? ""
147
+ : `, **style package:** \`${k.style}${k.styleOpts ? `[${k.styleOpts}]` : ""}\``;
148
+ const evidence =
149
+ c.s2 === undefined
150
+ ? `The arXiv comment of [${c.id}](${absUrl(c)}) says: «${quoteOf(k)}»`
151
+ : `Semantic Scholar's venue listing (the proceedings) holds [${c.id}](${absUrl(c)}) — acceptance evidence without comment wording — query \`${c.query}\`: «${quoteOf(k)}»`;
152
+ const linted =
153
+ choice.preset === null
154
+ ? "no preset (`extends` left out)"
155
+ : `\`${choice.preset}\``;
156
+ return `# ${c.title}
157
+
158
+ - **Authors:** ${c.authors.join(", ")}
159
+ - **Source:** arXiv [${c.id}](${absUrl(c)}), e-print \`https://arxiv.org/src/${c.id}\` (sha256 \`${k.sourceSha}\`)
160
+ - **Category:** ${c.category}; **document class:** \`[${p.clsOpts}]{${String(p.cls)}}\`${style}
161
+ - **Licence:** [${k.licence.name}](${k.licence.url}), as the arXiv abstract page states. The files are redistributed under it.
162
+ - **Accepted at:** ${venueOf(k)}. ${evidence}
163
+ - **Linted as:** ${linted}, the camera-ready of an accepted attempt (${choice.why})
164
+ - **Text sources only, figures omitted.** Kept: \`.tex\`, \`.bib\`, \`.bbl\`, \`.cls\`, \`.sty\`, \`.bst\`, \`.cfg\`, \`.def\`, each at its path from the archive's root, where arXiv compiles. Dropped: images, PDFs, data.
165
+ - ${changesOf(k.plan)}
166
+ - **Ours:** \`paperlint.json\`, \`PIPELINE-STATUS.md\`, \`record-by-hand.json\`, \`baseline.json\`, \`README.md\`.
167
+
168
+ \`paperlint.json\` records one attempt, accepted, whose evidence is this file. Its dates are those of the arXiv version that states the acceptance: the real decision day is earlier and not known here. \`record-by-hand.json\` is NOT TeX's answer: it lists \`paper.tex\`, the class and style files at the root, then the \`\\input\`/\`\\include\` files in the order the source names them, hashed over the bytes here. See [\`../README.md\`](../README.md).
169
+ `;
170
+ };
171
+
172
+ const cycleOf = (k: Kept, choice: PresetChoice) => ({
173
+ id: `${slug(k.slot.series)}-${String(k.slot.year)}${k.track === null ? "" : "-findings"}`,
174
+ venue:
175
+ choice.preset === null
176
+ ? { kind: "named", name: venueOf(k), url: absUrl(k.c) }
177
+ : { kind: "preset", extends: choice.preset },
178
+ opened: k.c.updated,
179
+ outcome: { kind: "accepted", date: k.c.updated, evidence: "README.md" },
180
+ });
181
+
182
+ const entryOf = (k: Kept, choice: PresetChoice): KeptPaper["entry"] => ({
183
+ arxiv_id: k.c.id,
184
+ license: k.licence.key,
185
+ source_sha256: k.sourceSha,
186
+ main_tex: `./${k.plan.main}`,
187
+ class: k.preamble.cls,
188
+ category: k.c.category,
189
+ size_bytes: k.plan.size,
190
+ dir: k.c.id,
191
+ accepted: { quote: quoteOf(k), url: absUrl(k.c), venue: venueOf(k) },
192
+ preset: choice.preset,
193
+ kind: null,
194
+ field: k.slot.field,
195
+ series: k.slot.series,
196
+ year: k.slot.year,
197
+ ...(k.track === null ? {} : { track: k.track }),
198
+ source: k.c.s2 === undefined ? "arxiv-comment" : "semantic-scholar",
199
+ acceptance: k.c.s2 === undefined ? "arxiv-comment" : "s2-venue-listing",
200
+ });
201
+
202
+ /** For a listed paper: whether the arXiv version kept predates the venue's date. */
203
+ const versionNote = (
204
+ updated: string,
205
+ s2: NonNullable<Candidate["s2"]>,
206
+ ): string =>
207
+ s2.publicationDate !== null && updated < s2.publicationDate
208
+ ? `latest arXiv version (${updated}) predates the venue date (${s2.publicationDate}); kept the latest version`
209
+ : `latest arXiv version ${updated}; venue date ${s2.publicationDate ?? "not given"}`;
210
+
211
+ const noteOf = (k: Kept, choice: PresetChoice) => ({
212
+ clsOpts: k.preamble.clsOpts,
213
+ style: k.style ?? null,
214
+ styleOpts: k.styleOpts ?? null,
215
+ mainCandidates: k.plan.mainCandidates,
216
+ presetWhy: choice.why,
217
+ edits: k.plan.edits,
218
+ renames: k.plan.renames,
219
+ title: k.c.title,
220
+ ...(k.c.s2 === undefined
221
+ ? {}
222
+ : { versionNote: versionNote(k.c.updated, k.c.s2) }),
223
+ });
224
+
225
+ const json = (v: unknown): string => `${JSON.stringify(v, null, 2)}\n`;
226
+
227
+ export function keptPaper(k: Kept): KeptPaper {
228
+ const choice = presetFor(k.slot, k.preamble, k.style, k.shipped);
229
+ return {
230
+ id: k.c.id,
231
+ files: new Map<string, Uint8Array | string>([
232
+ ...k.plan.staged.map((f) => [f.path, f.bytes] as const),
233
+ ["record-by-hand.json", json(recordOf(k.plan.staged))],
234
+ ["PIPELINE-STATUS.md", "---\nstages: []\n---\n# PIPELINE-STATUS\n"],
235
+ ["paperlint.json", json({ cycles: [cycleOf(k, choice)] })],
236
+ ["README.md", readmeOf(k, choice)],
237
+ ]),
238
+ entry: entryOf(k, choice),
239
+ note: noteOf(k, choice),
240
+ };
241
+ }