paperlint 20.4.0 → 20.6.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 (100) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/dist/adapters/venue-corpus/index.d.ts.map +1 -1
  3. package/dist/adapters/venue-corpus/index.js +9 -2
  4. package/dist/adapters/venue-corpus/index.js.map +1 -1
  5. package/dist/cli.d.ts.map +1 -1
  6. package/dist/cli.js +61 -26
  7. package/dist/cli.js.map +1 -1
  8. package/dist/corpus-json-rules.d.ts +6 -0
  9. package/dist/corpus-json-rules.d.ts.map +1 -0
  10. package/dist/corpus-json-rules.js +15 -0
  11. package/dist/corpus-json-rules.js.map +1 -0
  12. package/dist/corpus-layout-rule.d.ts +11 -0
  13. package/dist/corpus-layout-rule.d.ts.map +1 -0
  14. package/dist/corpus-layout-rule.js +92 -0
  15. package/dist/corpus-layout-rule.js.map +1 -0
  16. package/dist/corpus-licence-rule.d.ts +27 -0
  17. package/dist/corpus-licence-rule.d.ts.map +1 -0
  18. package/dist/corpus-licence-rule.js +78 -0
  19. package/dist/corpus-licence-rule.js.map +1 -0
  20. package/dist/corpus-record-rule.d.ts +2 -0
  21. package/dist/corpus-record-rule.d.ts.map +1 -1
  22. package/dist/corpus-record-rule.js +6 -3
  23. package/dist/corpus-record-rule.js.map +1 -1
  24. package/dist/domain/corpus-layout.d.ts +30 -0
  25. package/dist/domain/corpus-layout.d.ts.map +1 -0
  26. package/dist/domain/corpus-layout.js +101 -0
  27. package/dist/domain/corpus-layout.js.map +1 -0
  28. package/dist/domain/corpus-licence.d.ts +23 -0
  29. package/dist/domain/corpus-licence.d.ts.map +1 -0
  30. package/dist/domain/corpus-licence.js +50 -0
  31. package/dist/domain/corpus-licence.js.map +1 -0
  32. package/dist/domain/corpus-record.d.ts +8 -0
  33. package/dist/domain/corpus-record.d.ts.map +1 -1
  34. package/dist/domain/corpus-record.js +11 -9
  35. package/dist/domain/corpus-record.js.map +1 -1
  36. package/dist/domain/edition.d.ts +3 -1
  37. package/dist/domain/edition.d.ts.map +1 -1
  38. package/dist/domain/edition.js +6 -2
  39. package/dist/domain/edition.js.map +1 -1
  40. package/dist/domain/licence.d.ts +1 -1
  41. package/dist/domain/licence.d.ts.map +1 -1
  42. package/dist/domain/licence.js +2 -2
  43. package/dist/domain/licence.js.map +1 -1
  44. package/dist/domain/paper-layout.d.ts +3 -2
  45. package/dist/domain/paper-layout.d.ts.map +1 -1
  46. package/dist/domain/paper-layout.js +3 -2
  47. package/dist/domain/paper-layout.js.map +1 -1
  48. package/dist/paper-files.d.ts +11 -4
  49. package/dist/paper-files.d.ts.map +1 -1
  50. package/dist/paper-files.js +16 -2
  51. package/dist/paper-files.js.map +1 -1
  52. package/dist/skill-chunks/chunk-QPWFSYJG.js +17 -0
  53. package/dist/skill-chunks/{chunk-6YEM4VDI.js → chunk-WYQTXKNM.js} +1 -1
  54. package/docs/design/venue-corpus.md +16 -16
  55. package/docs/layout.md +2 -2
  56. package/docs/optional-rules.md +11 -10
  57. package/docs/rules/corpus/allowed-files-only.md +99 -0
  58. package/docs/rules/corpus/licence.md +125 -0
  59. package/docs/rules/corpus/record.md +10 -6
  60. package/docs/rules.md +3 -1
  61. package/docs/venues.md +14 -11
  62. package/package.json +1 -1
  63. package/skills/argument-arc/scripts/headings.js +2 -2
  64. package/skills/cold-read-diff/scripts/cold-read.js +5 -5
  65. package/skills/paper-pipeline/scripts/extract-ref-facts.js +3 -3
  66. package/skills/pc-panel-review/scripts/prior-reviews.js +2 -1
  67. package/skills/study-accepted-papers/SKILL.md +4 -3
  68. package/skills/study-accepted-papers/SKILL.md.spec.ts +3 -2
  69. package/skills/study-accepted-papers/papers.schema.json +2 -2
  70. package/skills/study-accepted-papers/scripts/corpus-licences.js +15 -3
  71. package/skills/study-accepted-papers/scripts/corpus-licences.test.ts +1 -1
  72. package/skills/verify-citations/scripts/bib-authors.js +3 -3
  73. package/skills/verify-citations/scripts/verify-cites.js +3 -3
  74. package/src/adapters/venue-corpus/index.test.ts +25 -0
  75. package/src/adapters/venue-corpus/index.ts +16 -2
  76. package/src/cli-e2e.test.mjs +2 -2
  77. package/src/cli.ts +75 -26
  78. package/src/corpus-json-rules.ts +22 -0
  79. package/src/corpus-layout-rule.test.ts +177 -0
  80. package/src/corpus-layout-rule.ts +145 -0
  81. package/src/corpus-licence-rule.test.ts +217 -0
  82. package/src/corpus-licence-rule.ts +94 -0
  83. package/src/corpus-record-rule.test.ts +27 -4
  84. package/src/corpus-record-rule.ts +8 -3
  85. package/src/domain/corpus-layout.test.ts +118 -0
  86. package/src/domain/corpus-layout.ts +159 -0
  87. package/src/domain/corpus-licence.test.ts +128 -0
  88. package/src/domain/corpus-licence.ts +99 -0
  89. package/src/domain/corpus-record.test.ts +7 -1
  90. package/src/domain/corpus-record.ts +26 -9
  91. package/src/domain/edition.ts +8 -2
  92. package/src/domain/licence.test.ts +1 -1
  93. package/src/domain/licence.ts +2 -2
  94. package/src/domain/paper-layout.ts +3 -2
  95. package/src/layout-docs.test.ts +3 -1
  96. package/src/paper-files.ts +19 -3
  97. package/src/rule-cases.test.ts +6 -70
  98. package/src/rule-id-shape.test.ts +42 -0
  99. package/src/unowned-file.test.ts +1 -1
  100. package/dist/skill-chunks/{chunk-CXAGKT44.js → chunk-EDHTB7KT.js} +4 -4
@@ -0,0 +1,217 @@
1
+ /**
2
+ * `corpus/licence` through `paperlint lint`, the way a consumer runs it: off unless the root
3
+ * `paperlint.json` turns it on, reported at the copy's `stored`, with the non-commercial setting as
4
+ * the rule's own option.
5
+ */
6
+ import { describe, expect, it } from "vitest";
7
+ import { z } from "zod";
8
+ import { run } from "./cli.ts";
9
+ import { useTempDir, writeTree } from "../test/support.ts";
10
+
11
+ const STATUS = "---\nstages: []\n---\n# PIPELINE-STATUS\n";
12
+ const TEX = "\\documentclass{article}\n\\begin{document}\nx\n\\end{document}\n";
13
+ const PAPER = {
14
+ "papers/p/PIPELINE-STATUS.md": STATUS,
15
+ "papers/p/paper.tex": TEX,
16
+ };
17
+ const C = "papers/venues/agent";
18
+ const RECORD = `${C}/papers.json`;
19
+
20
+ /** A copy storing both kinds under `licence`. */
21
+ const copy = (licence: Readonly<Record<string, string>>) => ({
22
+ version: "published",
23
+ url: "https://doi.org/10.1/x",
24
+ licence,
25
+ stored: ["pdf", "text"],
26
+ fetched_from: "https://doi.org/10.1/x",
27
+ });
28
+ const READ = { read_from: "https://example.org", read_on: "2026-11-03" };
29
+ const record = (licences: readonly Record<string, string>[]): string =>
30
+ JSON.stringify(
31
+ {
32
+ venue: "agent",
33
+ editions: [
34
+ {
35
+ edition: 2026,
36
+ listed_from: "https://example.org/accepted",
37
+ read_on: "2026-11-03",
38
+ accepted: 1,
39
+ capped: null,
40
+ proxy: null,
41
+ },
42
+ ],
43
+ papers: [
44
+ {
45
+ key: "a",
46
+ edition: 2026,
47
+ group: "accepted",
48
+ title: "A",
49
+ ids: { doi: "10.1/x" },
50
+ copies: licences.map(copy),
51
+ },
52
+ ],
53
+ rebuild: [],
54
+ },
55
+ null,
56
+ 2,
57
+ );
58
+ /** The corpus whose stored files the record claims. */
59
+ const corpus = (licences: readonly Record<string, string>[]) => ({
60
+ ...PAPER,
61
+ [RECORD]: record(licences),
62
+ [`${C}/pdf/a.pdf`]: "%PDF",
63
+ [`${C}/text/a.txt`]: "a",
64
+ });
65
+ const ON = (options?: Readonly<Record<string, boolean>>) => ({
66
+ "paperlint.json": JSON.stringify({
67
+ rules: {
68
+ "corpus/licence": options === undefined ? "warn" : ["warn", options],
69
+ },
70
+ }),
71
+ });
72
+
73
+ const Results = z.array(
74
+ z.looseObject({
75
+ filePath: z.string(),
76
+ messages: z.array(
77
+ z.looseObject({
78
+ ruleId: z.string().nullable(),
79
+ messageId: z.string().optional(),
80
+ severity: z.number(),
81
+ line: z.number().optional(),
82
+ message: z.string(),
83
+ }),
84
+ ),
85
+ }),
86
+ );
87
+
88
+ /** Every message of `corpus/licence`, with its file. */
89
+ async function licenceFindings(
90
+ tree: Readonly<Record<string, string>>,
91
+ paths: readonly string[] = [],
92
+ ) {
93
+ const dir = writeTree(useTempDir("paperlint-licence-"), {
94
+ "package.json": '{"name":"consumer","private":true}',
95
+ ...tree,
96
+ });
97
+ const out: string[] = [];
98
+ const errs: string[] = [];
99
+ const code = await run(["lint", "--json", ...paths], {
100
+ cwd: dir,
101
+ log: (...a: unknown[]) => out.push(a.join(" ")),
102
+ err: (...a: unknown[]) => errs.push(a.join(" ")),
103
+ });
104
+ if (code !== 0 && out.length === 0) throw new Error(errs.join("\n"));
105
+ return Results.parse(JSON.parse(out.join("\n"))).flatMap((r) =>
106
+ r.messages
107
+ .filter((m) => m.ruleId === "corpus/licence")
108
+ .map((m) => ({ ...m, file: r.filePath.slice(dir.length + 1) })),
109
+ );
110
+ }
111
+
112
+ describe("corpus/licence is off unless it is turned on", () => {
113
+ it("🔴 says nothing about a corpus of forbidden and unread copies when no setting names it", async () => {
114
+ // Guards: opt-in means silent; the same files are legal in a private repository.
115
+ expect(
116
+ await licenceFindings(
117
+ corpus([
118
+ { id: "LicenseRef-publisher", ...READ },
119
+ { id: "NOASSERTION" },
120
+ ]),
121
+ ),
122
+ ).toEqual([]);
123
+ });
124
+
125
+ it("reports a copy's refusal once with warn, at the copy's stored line", async () => {
126
+ // Guards: a copy whose two stored kinds are refused for one reason is one finding, not two.
127
+ const tree = corpus([{ id: "LicenseRef-publisher", ...READ }]);
128
+ const found = await licenceFindings({ ...tree, ...ON() });
129
+ const line =
130
+ tree[RECORD].split("\n").findIndex((l) => l.includes('"stored"')) + 1;
131
+ expect(found.map((m) => [m.file, m.severity, m.line, m.messageId])).toEqual(
132
+ [[RECORD, 1, line, "forbidden"]],
133
+ );
134
+ });
135
+
136
+ it("names each message by what was refused", async () => {
137
+ const found = await licenceFindings({
138
+ ...corpus([
139
+ { id: "NOASSERTION" },
140
+ { id: "CC-BY-3.0", ...READ },
141
+ { id: "CC-BY-NC-4.0", ...READ },
142
+ ]),
143
+ ...ON(),
144
+ });
145
+ expect(new Set(found.map((m) => m.messageId))).toEqual(
146
+ new Set(["not-read", "unlisted", "non-commercial-only"]),
147
+ );
148
+ });
149
+
150
+ it("is silent on a permitted licence even when turned on", async () => {
151
+ expect(
152
+ await licenceFindings({
153
+ ...corpus([{ id: "CC-BY-4.0", ...READ }]),
154
+ ...ON(),
155
+ }),
156
+ ).toEqual([]);
157
+ });
158
+ });
159
+
160
+ describe("corpus/licence: turned on where there is no corpus", () => {
161
+ it("🔴 is refused as a rule that reached nothing, not read as a pass", async () => {
162
+ // Guards: an optional rule that is on and sees no file reports exactly like one that passed.
163
+ await expect(licenceFindings({ ...PAPER, ...ON() })).rejects.toThrow(
164
+ /corpus\/licence is turned on in "rules"/,
165
+ );
166
+ });
167
+ });
168
+
169
+ describe("corpus/licence: a lint of one paper in a project with a corpus", () => {
170
+ it("🔴 runs, and judges no corpus it was not given", async () => {
171
+ // Guards: the rule reaches the project's corpus, so a run over one paper is not refused.
172
+ expect(
173
+ await licenceFindings(
174
+ { ...corpus([{ id: "LicenseRef-publisher", ...READ }]), ...ON() },
175
+ ["papers/p"],
176
+ ),
177
+ ).toEqual([]);
178
+ });
179
+ });
180
+
181
+ describe("corpus/licence: a record that does not parse is corpus/record's", () => {
182
+ it("says nothing of its own about it", async () => {
183
+ // Guards: no licence can be read from a record the schema refuses.
184
+ expect(
185
+ await licenceFindings({
186
+ ...PAPER,
187
+ ...ON(),
188
+ [RECORD]: '{"venue":"agent"}',
189
+ }),
190
+ ).toEqual([]);
191
+ });
192
+ });
193
+
194
+ describe("corpus/licence: the non-commercial setting is the rule's option", () => {
195
+ const nc = corpus([{ id: "CC-BY-NC-4.0", ...READ }]);
196
+
197
+ it("🔴 permits a non-commercial licence with nonCommercial: true", async () => {
198
+ expect(
199
+ await licenceFindings({ ...nc, ...ON({ nonCommercial: true }) }),
200
+ ).toEqual([]);
201
+ });
202
+
203
+ it("refuses it with nonCommercial: false, as by default", async () => {
204
+ expect(
205
+ (await licenceFindings({ ...nc, ...ON({ nonCommercial: false }) })).map(
206
+ (m) => m.messageId,
207
+ ),
208
+ ).toEqual(["non-commercial-only"]);
209
+ });
210
+
211
+ it("refuses an option the rule does not have", async () => {
212
+ // Guards: a misspelt option is ESLint's schema error, not a silent default.
213
+ await expect(
214
+ licenceFindings({ ...nc, ...ON({ noncommercial: true }) }),
215
+ ).rejects.toThrow(/corpus\/licence/);
216
+ });
217
+ });
@@ -0,0 +1,94 @@
1
+ /**
2
+ * `corpus/licence` — the licence of each copy a venue corpus stores permits keeping it
3
+ * (docs/design/venue-corpus.md, decisions 3 and 4; docs/rules/corpus/licence.md). OFF by default and
4
+ * in no rule set: the same files are legal in a private repository and illegal in a public one, and
5
+ * the rule cannot tell which it is in. What is judged is `src/domain/corpus-licence.ts`, which asks
6
+ * the table in `src/domain/licence.ts`; this file reads the record through the codec, reads the
7
+ * rule's one option, and reports.
8
+ *
9
+ * ── WHERE IT REPORTS ─────────────────────────────────────────────────────────────
10
+ * On `<papers-root>/venues/<venue>/papers.json`, at the `stored` of the copy each finding is about
11
+ * (the same location technique as `corpus/record`, `spanAt`). A record that does not parse has
12
+ * findings of `corpus/record`'s and none of this rule's.
13
+ *
14
+ * ── THE OPTION ───────────────────────────────────────────────────────────────────
15
+ * `"corpus/licence": ["warn", { "nonCommercial": true }]` in the root `paperlint.json`: the project
16
+ * declares itself non-commercial, which makes a non-commercial licence permit storing. The
17
+ * default is false: paperlint does not assume it.
18
+ */
19
+ import { spanAt, type JsonRuleModule } from "./corpus-record-rule.ts";
20
+ import {
21
+ judgeLicences,
22
+ licenceMessage,
23
+ type Refusal,
24
+ } from "./domain/corpus-licence.ts";
25
+ import type { VenueCorpusCodec } from "./ports/venue-corpus-codec.ts";
26
+ import { rulePageUrl } from "./venue-rules.ts";
27
+
28
+ /** What the rule reads with. */
29
+ export interface CorpusLicenceDeps {
30
+ readonly codec: VenueCorpusCodec;
31
+ }
32
+
33
+ /** The option, as ESLint's schema validated it: `nonCommercial` is a boolean or absent. */
34
+ const nonCommercial = (options: readonly unknown[]): boolean => {
35
+ const [first] = options;
36
+ return (
37
+ typeof first === "object" &&
38
+ first !== null &&
39
+ "nonCommercial" in first &&
40
+ first.nonCommercial === true
41
+ );
42
+ };
43
+
44
+ const META: JsonRuleModule["meta"] = {
45
+ type: "suggestion",
46
+ docs: {
47
+ description:
48
+ "each copy a venue corpus stores has a licence that permits keeping that file (opt-in: the same files are legal in a private repository and illegal in a public one)",
49
+ url: rulePageUrl("corpus/licence"),
50
+ },
51
+ schema: [
52
+ {
53
+ type: "object",
54
+ properties: { nonCommercial: { type: "boolean" } },
55
+ additionalProperties: false,
56
+ },
57
+ ],
58
+ // One id per kind of refusal, each with the whole text of `licenceMessage`.
59
+ messages: {
60
+ "not-read": "{{text}}",
61
+ unlisted: "{{text}}",
62
+ forbidden: "{{text}}",
63
+ "non-commercial-only": "{{text}}",
64
+ } satisfies Record<Refusal["kind"], string>,
65
+ };
66
+
67
+ /** The rule, reading each record through `deps.codec`. */
68
+ export function corpusLicenceRules(
69
+ deps: CorpusLicenceDeps,
70
+ ): Readonly<Record<"licence", JsonRuleModule>> {
71
+ return {
72
+ licence: {
73
+ meta: META,
74
+ create(context) {
75
+ return {
76
+ Document() {
77
+ const { text, ast } = context.sourceCode;
78
+ const record = deps.codec.parse(text);
79
+ if (!record.ok) return;
80
+ judgeLicences(record.corpus, {
81
+ nonCommercial: nonCommercial(context.options),
82
+ }).forEach((f) => {
83
+ context.report({
84
+ loc: spanAt(ast, f.at),
85
+ messageId: f.refusal.kind,
86
+ data: { text: licenceMessage(f) },
87
+ });
88
+ });
89
+ },
90
+ };
91
+ },
92
+ },
93
+ };
94
+ }
@@ -115,7 +115,7 @@ describe("corpus/record: silent where nothing is wrong", () => {
115
115
  });
116
116
 
117
117
  it("🔴 is silent on a corpus folder with stored files and no papers.json", async () => {
118
- // Guards: a corpus not migrated yet is corpus/allowed-files-only's to report (PR 1b-ii), not this rule's.
118
+ // Guards: a corpus not migrated yet is corpus/allowed-files-only's to report, not this rule's.
119
119
  const r = await lint({
120
120
  ...PAPER,
121
121
  [`${C}/MANIFEST.md`]: "# agent\n",
@@ -184,6 +184,18 @@ describe("corpus/record: each finding, at its place in papers.json", () => {
184
184
  ]);
185
185
  });
186
186
 
187
+ it("🔴 reports a venue that is not its folder's name at the venue field", async () => {
188
+ const text = record([]).replace('"venue": "agent"', '"venue": "agnet"');
189
+ const found = await onCorpus({ ...PAPER, [RECORD]: text });
190
+ // Guards: the folder is the preset's series, so the field must say the same; reported where it is written.
191
+ expect(found.map((m) => [m.ruleId, m.line, m.column, m.messageId])).toEqual(
192
+ [["corpus/record", lineOf(text, '"venue"'), 3, "venue"]],
193
+ );
194
+ expect(found.map((m) => m.message)).toEqual([
195
+ 'the record says `"venue": "agnet"`, and its folder is `agent`. What to do: rename the folder to `agnet`, or correct the field to `agent`',
196
+ ]);
197
+ });
198
+
187
199
  it("is turned off in the root paperlint.json by one line", async () => {
188
200
  expect(
189
201
  await corpusFindings({
@@ -198,8 +210,8 @@ describe("corpus/record: each finding, at its place in papers.json", () => {
198
210
  });
199
211
  });
200
212
 
201
- describe("the JSON language reaches papers.json and nothing else", () => {
202
- it("🔴 lints no other JSON file: the root and a paper's paperlint.json, measurements.json", async () => {
213
+ describe("the JSON language reaches papers.json and the root paperlint.json, nothing else", () => {
214
+ it("🔴 lints no other JSON file: a paper's paperlint.json, measurements.json", async () => {
203
215
  const r = await lint({
204
216
  ...PAPER,
205
217
  "paperlint.json": "{}",
@@ -209,7 +221,18 @@ describe("the JSON language reaches papers.json and nothing else", () => {
209
221
  [`${C}/measurements.json`]: "{ broken",
210
222
  "papers/venues/papers.json": "{ broken",
211
223
  });
212
- expect(r.files.filter((f) => f.endsWith(".json"))).toEqual([RECORD]);
224
+ // The root file is corpus/allowed-files-only's, for a corpus without papers.json; corpus/record
225
+ // is not registered on it.
226
+ expect(r.files.filter((f) => f.endsWith(".json"))).toEqual([
227
+ "paperlint.json",
228
+ RECORD,
229
+ ]);
230
+ // Guards: no broken JSON is parsed; the one message is the stray papers.json loose in venues/.
231
+ expect(
232
+ r.messages
233
+ .filter((m) => m.file.endsWith(".json"))
234
+ .map((m) => [m.file, m.ruleId, m.messageId]),
235
+ ).toEqual([["paperlint.json", "corpus/allowed-files-only", "loose"]]);
213
236
  });
214
237
  });
215
238
 
@@ -9,9 +9,10 @@
9
9
  * language (`@eslint/json`): each finding at the field its path names, walked down the file's JSON
10
10
  * tree; where the path stops being in the file (a required field left out), at the deepest part
11
11
  * that is. A file that is not JSON never reaches the rule: ESLint reports its parse error. A corpus
12
- * folder without `papers.json` has no file to report on, and this rule says nothing about it.
12
+ * folder without `papers.json` has no file to report on, and this rule says nothing about it:
13
+ * `corpus/allowed-files-only` reports it on the root `paperlint.json` (src/corpus-layout-rule.ts).
13
14
  */
14
- import { dirname, join } from "node:path";
15
+ import { basename, dirname, join } from "node:path";
15
16
  import { callerPath } from "./caller-path.ts";
16
17
  import {
17
18
  corpusMessage,
@@ -64,6 +65,8 @@ interface JsonDocument {
64
65
  /** What the rule uses of ESLint's context on a JSON file. */
65
66
  export interface JsonRuleContext {
66
67
  readonly filename: string;
68
+ /** The options the rule was configured with: what follows its severity in `["warn", { … }]`. */
69
+ readonly options: readonly unknown[];
67
70
  readonly sourceCode: { readonly text: string; readonly ast: JsonDocument };
68
71
  report(d: {
69
72
  readonly loc: Span;
@@ -116,6 +119,7 @@ const findingsFor = (
116
119
  deps: CorpusRecordDeps,
117
120
  ): readonly CorpusFinding[] =>
118
121
  judgeCorpus({
122
+ folder: basename(dirname(file)),
119
123
  record: deps.codec.parse(text),
120
124
  stored: {
121
125
  pdf: visible(join(dirname(file), "pdf"), deps),
@@ -127,7 +131,7 @@ const META: FolderRuleModule["meta"] = {
127
131
  type: "suggestion",
128
132
  docs: {
129
133
  description:
130
- "a venue corpus's papers.json is a record, every copy stored in pdf/ and text/ is claimed by one copy in it, and every claimed file is there",
134
+ "a venue corpus's papers.json is a record that names its own folder as its venue, every copy stored in pdf/ and text/ is claimed by one copy in it, and every claimed file is there",
131
135
  url: rulePageUrl("corpus/record"),
132
136
  },
133
137
  schema: [],
@@ -136,6 +140,7 @@ const META: FolderRuleModule["meta"] = {
136
140
  (
137
141
  [
138
142
  "unparsed",
143
+ "venue",
139
144
  "unclaimed",
140
145
  "missing",
141
146
  "twice",
@@ -0,0 +1,118 @@
1
+ /**
2
+ * The layout of a venue corpus (`src/domain/corpus-layout.ts`). Both halves: the seven names and
3
+ * the byproducts are clean; every other entry is reported once, with where it goes by kind.
4
+ */
5
+ import { describe, expect, it } from "vitest";
6
+ import {
7
+ CORPUS_LAYOUT_TREE,
8
+ DIR_CURE,
9
+ FILE_CURE,
10
+ FILE_CURES,
11
+ corpusStrayMessage,
12
+ judgeCorpusLayout,
13
+ judgeVenues,
14
+ looseMessage,
15
+ storesWithoutRecord,
16
+ unrecordedMessage,
17
+ } from "./corpus-layout.ts";
18
+ import type { LayoutEntry } from "./paper-layout.ts";
19
+
20
+ const file = (name: string): LayoutEntry => ({ name, kind: "file" });
21
+ const dir = (name: string): LayoutEntry => ({ name, kind: "dir" });
22
+ const cure = (i: number): string => FILE_CURES[i]?.cure ?? "";
23
+
24
+ const SEVEN: readonly LayoutEntry[] = [
25
+ ...["papers.json", "MANIFEST.md", "measurements.json"].map(file),
26
+ ...["pdf", "text", "deep-reads", "sources"].map(dir),
27
+ ];
28
+
29
+ describe("judgeCorpusLayout", () => {
30
+ it("🔴 reports nothing for the seven names and the byproducts", () => {
31
+ expect(
32
+ judgeCorpusLayout([...SEVEN, file(".DS_Store"), dir("__pycache__")]),
33
+ ).toEqual([]);
34
+ });
35
+
36
+ it("🔴 a .gitignore that keeps the stored copies out of git is no stray", () => {
37
+ // Guards: a public repository keeps a corpus's pdf/ out of git with it (no false red).
38
+ expect(judgeCorpusLayout([...SEVEN, file(".gitignore")])).toEqual([]);
39
+ });
40
+
41
+ it("🔴 reports each stray once, by kind, in the order given", () => {
42
+ // One file per entry of FILE_CURES, in its order.
43
+ const names = [
44
+ "a.pdf",
45
+ "a.txt",
46
+ "notes.md",
47
+ "x.py",
48
+ "list.csv",
49
+ "cfp.html",
50
+ ];
51
+ expect(
52
+ judgeCorpusLayout([...SEVEN, ...names.map(file), file("odd.bin")]),
53
+ ).toEqual([
54
+ ...names.map((name, i) => ({ name, cure: cure(i) })),
55
+ { name: "odd.bin", cure: FILE_CURE },
56
+ ]);
57
+ });
58
+
59
+ it("judges a name by its kind too: a folder named papers.json, a file named pdf", () => {
60
+ expect(judgeCorpusLayout([dir("papers.json"), file("pdf")])).toEqual([
61
+ { name: "papers.json/", cure: DIR_CURE },
62
+ { name: "pdf", cure: FILE_CURE },
63
+ ]);
64
+ });
65
+ });
66
+
67
+ describe("storesWithoutRecord", () => {
68
+ it.each([
69
+ ["pdf/ and no papers.json", [dir("pdf")], true],
70
+ ["text/ and no papers.json", [dir("text"), file("MANIFEST.md")], true],
71
+ ["pdf/ with papers.json", [dir("pdf"), file("papers.json")], false],
72
+ ["no stored copies", [dir("sources")], false],
73
+ ["a file named pdf", [file("pdf")], false],
74
+ ] as const)("%s", (_, entries, want) => {
75
+ expect(storesWithoutRecord(entries)).toBe(want);
76
+ });
77
+ });
78
+
79
+ describe("the messages", () => {
80
+ it("a stray names itself, its cure, the layout and the rule's page", () => {
81
+ expect(
82
+ corpusStrayMessage("venues/agent", { name: "x/", cure: DIR_CURE }),
83
+ ).toBe(
84
+ [
85
+ `\`venues/agent/x/\` is not one of the names a venue corpus holds. Where it goes: ${DIR_CURE}.`,
86
+ "What a corpus holds (.DS_Store and what interpreters leave, like __pycache__/, are never reported):",
87
+ CORPUS_LAYOUT_TREE,
88
+ "Rule corpus/allowed-files-only: https://github.com/zernie/paperlint/blob/main/docs/rules/corpus/allowed-files-only.md",
89
+ ].join("\n"),
90
+ );
91
+ });
92
+
93
+ it("an unrecorded corpus names the folder and both cures", () => {
94
+ expect(unrecordedMessage("papers/venues/agent")).toBe(
95
+ "`papers/venues/agent/` stores copies in pdf/ or text/ and has no papers.json, so nothing records which paper each file is a copy of, or under which licence it is kept. What to do: write papers/venues/agent/papers.json (study-accepted-papers writes it; its fields are in papers.schema.json), or remove pdf/ and text/ and keep the papers' ids. Rule corpus/allowed-files-only: https://github.com/zernie/paperlint/blob/main/docs/rules/corpus/allowed-files-only.md",
96
+ );
97
+ });
98
+ });
99
+
100
+ describe("judgeVenues", () => {
101
+ it("🔴 reports each file loose in venues/, and no corpus folder, index or byproduct", () => {
102
+ const entries = [
103
+ dir("agent"),
104
+ dir("scripts"),
105
+ ...["README.md", "CLAUDE.md", "AGENTS.md", ".DS_Store"].map(file),
106
+ file("codebook.md"),
107
+ file("check.py"),
108
+ ];
109
+ // Guards: a folder is a corpus (its own names are judged inside it); only loose files are strays.
110
+ expect(judgeVenues(entries)).toEqual(["codebook.md", "check.py"]);
111
+ });
112
+
113
+ it("says where a loose file goes, and what venues/ holds", () => {
114
+ expect(looseMessage("papers/venues", "check.py")).toBe(
115
+ "`papers/venues/check.py` is a file loose in venues/, which holds one folder per venue corpus, and README.md, CLAUDE.md or AGENTS.md. Where it goes: into the corpus it is about (caveats into its MANIFEST.md, saved pages into its sources/), or out of venues/ when it serves several (a script into a paper's repro/tools/, its command into each papers.json's `rebuild`). Rule corpus/allowed-files-only: https://github.com/zernie/paperlint/blob/main/docs/rules/corpus/allowed-files-only.md",
116
+ );
117
+ });
118
+ });