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,159 @@
1
+ /**
2
+ * THE LAYOUT OF A VENUE CORPUS — what may stand at the top of `<papers-root>/venues/<venue>/`
3
+ * (docs/design/venue-corpus.md, decision 5; docs/rules/corpus/allowed-files-only.md): the record,
4
+ * its caveats, the codes, the stored copies, the deep reads and the pages as they were read. Every
5
+ * other name is reported with where it goes; what the operating system and interpreters leave (the
6
+ * lists `paper-layout.ts` and `repro-layout.ts` never report) is never reported. Only the top is
7
+ * judged: `pdf/` and `text/` are `corpus/record`'s. Pure: the caller lists the folder.
8
+ */
9
+ import { extname } from "node:path";
10
+ import { leaf, renderTree } from "./layout-tree.ts";
11
+ import {
12
+ IMAGE_EXTENSIONS,
13
+ OS_FILES,
14
+ type LayoutEntry,
15
+ } from "./paper-layout.ts";
16
+ import {
17
+ DATA_EXTENSIONS,
18
+ NOTE_EXTENSIONS,
19
+ REPRO_BYPRODUCTS,
20
+ SCRIPT_EXTENSIONS,
21
+ TOOL_FILES,
22
+ } from "./repro-layout.ts";
23
+ import { CORPUS_RECORD } from "./venue-corpus.ts";
24
+
25
+ /** The names a corpus may hold at its top, files then folders, each with what it holds. */
26
+ const FILE_NOTES: readonly (readonly [string, string])[] = [
27
+ [CORPUS_RECORD, "the record: every paper, each copy of it and its licence"],
28
+ ["MANIFEST.md", "optional: caveats only, the prose no field holds"],
29
+ ["measurements.json", "the codes of L0 and L1, one row per paper, by key"],
30
+ [".gitignore", "optional: keeps the stored copies out of git"],
31
+ ];
32
+ const DIR_NOTES: readonly (readonly [string, string])[] = [
33
+ ["pdf", "pdf/<key>.pdf, when a copy's licence permits it"],
34
+ ["text", "text/<key>.txt and text/<key>.<variant>.txt"],
35
+ ["deep-reads", "deep-reads/<key>.md, one per paper read in full"],
36
+ ["sources", "the listing and call pages as they were read"],
37
+ ];
38
+
39
+ /** The drawing of a corpus's layout: the rule's message and its page. */
40
+ export const CORPUS_LAYOUT_TREE: string = renderTree(
41
+ "<papers-root>/venues/<venue>/",
42
+ [
43
+ ...FILE_NOTES.map(([name, note]) => leaf(name, note)),
44
+ ...DIR_NOTES.map(([name, note]) => leaf(`${name}/`, note)),
45
+ ],
46
+ );
47
+
48
+ /** Where a folder goes, and a file of a kind no other cure names. */
49
+ export const DIR_CURE =
50
+ "copies of papers into pdf/ or text/, each claimed in papers.json; saved pages into sources/; notes on one paper into deep-reads/<key>.md";
51
+ export const FILE_CURE = `decide by what it is — ${DIR_CURE}; caveats into MANIFEST.md`;
52
+
53
+ /** For a stray file, the place its name or extension says, the first match winning. */
54
+ export const FILE_CURES: readonly {
55
+ readonly names: readonly string[];
56
+ readonly extensions: readonly string[];
57
+ readonly cure: string;
58
+ }[] = [
59
+ {
60
+ names: [],
61
+ extensions: [".pdf"],
62
+ cure: "pdf/<key>.pdf, claimed by its copy in papers.json",
63
+ },
64
+ {
65
+ names: [],
66
+ extensions: [".txt"],
67
+ cure: "text/<key>.txt, claimed by its copy in papers.json",
68
+ },
69
+ {
70
+ names: [],
71
+ extensions: NOTE_EXTENSIONS,
72
+ cure: "MANIFEST.md when it is a caveat about the whole corpus; deep-reads/<key>.md when it is about one paper",
73
+ },
74
+ {
75
+ names: TOOL_FILES,
76
+ extensions: SCRIPT_EXTENSIONS,
77
+ cure: "out of the corpus: the paper's repro/tools/, and the command that runs it into papers.json's `rebuild`",
78
+ },
79
+ {
80
+ names: [],
81
+ extensions: DATA_EXTENSIONS,
82
+ cure: "its rows into papers.json (the papers) or measurements.json (their codes); the list as it was downloaded into sources/",
83
+ },
84
+ {
85
+ names: [],
86
+ extensions: [".html", ".htm", ".mhtml", ...IMAGE_EXTENSIONS],
87
+ cure: "sources/, beside the other pages as they were read",
88
+ },
89
+ ];
90
+
91
+ /** An entry at the top of a corpus that is not one of its names (a folder's ends in a slash), with where it goes. */
92
+ export interface CorpusStray {
93
+ readonly name: string;
94
+ readonly cure: string;
95
+ }
96
+
97
+ const isAllowed = (e: LayoutEntry): boolean =>
98
+ OS_FILES.includes(e.name) ||
99
+ REPRO_BYPRODUCTS.includes(e.name) ||
100
+ (e.kind === "dir" ? DIR_NOTES : FILE_NOTES).some(([n]) => n === e.name);
101
+
102
+ const fileCure = (name: string): string =>
103
+ FILE_CURES.find(
104
+ (c) =>
105
+ c.names.includes(name) ||
106
+ c.extensions.includes(extname(name).toLowerCase()),
107
+ )?.cure ?? FILE_CURE;
108
+
109
+ /** The entries at the top of a corpus that are not part of its layout, in the order given. Pure. */
110
+ export const judgeCorpusLayout = (
111
+ entries: readonly LayoutEntry[],
112
+ ): readonly CorpusStray[] =>
113
+ entries
114
+ .filter((e) => !isAllowed(e))
115
+ .map((e) =>
116
+ e.kind === "dir"
117
+ ? { name: `${e.name}/`, cure: DIR_CURE }
118
+ : { name: e.name, cure: fileCure(e.name) },
119
+ );
120
+
121
+ /** Whether a corpus stores copies (`pdf/` or `text/`) and has no `papers.json` to record them. Pure. */
122
+ export const storesWithoutRecord = (entries: readonly LayoutEntry[]): boolean =>
123
+ entries.some((e) => e.kind === "dir" && ["pdf", "text"].includes(e.name)) &&
124
+ !entries.some((e) => e.kind === "file" && e.name === CORPUS_RECORD);
125
+
126
+ const RULE_LINE =
127
+ "Rule corpus/allowed-files-only: https://github.com/zernie/paperlint/blob/main/docs/rules/corpus/allowed-files-only.md";
128
+
129
+ /** The text a stray is reported with; `corpus` is the corpus folder as the reader sees it. */
130
+ export const corpusStrayMessage = (corpus: string, s: CorpusStray): string =>
131
+ [
132
+ `\`${corpus}/${s.name}\` is not one of the names a venue corpus holds. Where it goes: ${s.cure}.`,
133
+ "What a corpus holds (.DS_Store and what interpreters leave, like __pycache__/, are never reported):",
134
+ CORPUS_LAYOUT_TREE,
135
+ RULE_LINE,
136
+ ].join("\n");
137
+
138
+ /** The text a corpus that stores copies without its record is reported with. */
139
+ export const unrecordedMessage = (corpus: string): string =>
140
+ `\`${corpus}/\` stores copies in pdf/ or text/ and has no ${CORPUS_RECORD}, so nothing records which paper each file is a copy of, or under which licence it is kept. What to do: write ${corpus}/${CORPUS_RECORD} (study-accepted-papers writes it; its fields are in papers.schema.json), or remove pdf/ and text/ and keep the papers' ids. ${RULE_LINE}`;
141
+
142
+ /** What `venues/` may hold besides its corpus folders: an index and the agent instruction files. */
143
+ const VENUES_FILES: readonly string[] = ["README.md", "CLAUDE.md", "AGENTS.md"];
144
+
145
+ /** The files loose at the top of `venues/`, in the order given; a folder there is a corpus. Pure. */
146
+ export const judgeVenues = (
147
+ entries: readonly LayoutEntry[],
148
+ ): readonly string[] =>
149
+ entries
150
+ .filter(
151
+ (e) =>
152
+ e.kind === "file" &&
153
+ ![...VENUES_FILES, ...OS_FILES, ...REPRO_BYPRODUCTS].includes(e.name),
154
+ )
155
+ .map((e) => e.name);
156
+
157
+ /** The text a file loose in `venues/` is reported with; `venues` is the folder as the reader sees it. */
158
+ export const looseMessage = (venues: string, name: string): string =>
159
+ `\`${venues}/${name}\` is a file loose in venues/, which holds one folder per venue corpus, and ${VENUES_FILES.slice(0, -1).join(", ")} or ${VENUES_FILES.slice(-1).join("")}. 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 ${CORPUS_RECORD}'s \`rebuild\`). ${RULE_LINE}`;
@@ -0,0 +1,128 @@
1
+ /** The licence judge: each refusal of the table reaches a finding at its copy's `stored`, a permitted kind none. */
2
+ import { describe, expect, it } from "vitest";
3
+ import { judgeLicences, licenceMessage } from "./corpus-licence.ts";
4
+ import type { Copy, Paper, VenueCorpus } from "./venue-corpus.ts";
5
+
6
+ const copy = (id: string, stored: Copy["stored"]): Copy => ({
7
+ version: "published",
8
+ url: "https://doi.org/10.1/x",
9
+ licence: { id, read_from: "https://example.org", read_on: "2026-11-03" },
10
+ stored,
11
+ fetched_from: "https://doi.org/10.1/x",
12
+ });
13
+
14
+ const paper = (key: string, copies: readonly Copy[]): Paper => ({
15
+ key,
16
+ title: "A title",
17
+ group: "accepted",
18
+ edition: 2026,
19
+ ids: { doi: "10.1/x" },
20
+ copies,
21
+ });
22
+
23
+ const corpus = (papers: readonly Paper[]): VenueCorpus => ({
24
+ venue: "agent",
25
+ editions: [],
26
+ papers,
27
+ rebuild: [],
28
+ });
29
+
30
+ const OFF = { nonCommercial: false };
31
+
32
+ describe("judgeLicences", () => {
33
+ it("is silent on a permitted licence and on a copy that stores nothing", () => {
34
+ expect(
35
+ judgeLicences(
36
+ corpus([
37
+ paper("a", [
38
+ copy("CC-BY-4.0", ["pdf", "text"]),
39
+ { ...copy("LicenseRef-publisher", []), fetched_from: undefined },
40
+ ]),
41
+ ]),
42
+ OFF,
43
+ ),
44
+ ).toEqual([]);
45
+ });
46
+
47
+ it("reports each refused kind of each copy at that copy's stored, in the record's order", () => {
48
+ const found = judgeLicences(
49
+ corpus([
50
+ paper("a", [copy("CC-BY-4.0", ["pdf"])]),
51
+ paper("b", [
52
+ copy("CC-BY-4.0", ["text"]),
53
+ copy("CC-BY-ND-4.0", ["pdf", "text"]),
54
+ copy("CC-BY-3.0", ["pdf"]),
55
+ ]),
56
+ ]),
57
+ OFF,
58
+ );
59
+ expect(found.map((f) => [f.at, f.stored, f.refusal.kind])).toEqual([
60
+ [["papers", 1, "copies", 1, "stored"], ["text"], "forbidden"],
61
+ [["papers", 1, "copies", 2, "stored"], ["pdf"], "unlisted"],
62
+ ]);
63
+ });
64
+
65
+ it("gives a copy one finding per reason, naming every kind it stands against", () => {
66
+ // Guards: two kinds refused for the same reason are one finding, not one per kind.
67
+ const found = judgeLicences(
68
+ corpus([
69
+ paper("a", [
70
+ copy("NOASSERTION", ["pdf", "text"]),
71
+ copy("CC-BY-NC-ND-4.0", ["pdf", "text"]),
72
+ ]),
73
+ ]),
74
+ OFF,
75
+ );
76
+ expect(found.map((f) => [f.at, f.stored, f.refusal.kind])).toEqual([
77
+ [["papers", 0, "copies", 0, "stored"], ["pdf", "text"], "not-read"],
78
+ [["papers", 0, "copies", 1, "stored"], ["pdf"], "non-commercial-only"],
79
+ [["papers", 0, "copies", 1, "stored"], ["text"], "forbidden"],
80
+ ]);
81
+ });
82
+
83
+ it("asks the table with the project's setting", () => {
84
+ const nc = corpus([paper("a", [copy("CC-BY-NC-4.0", ["pdf"])])]);
85
+ expect(judgeLicences(nc, OFF).map((f) => f.refusal.kind)).toEqual([
86
+ "non-commercial-only",
87
+ ]);
88
+ expect(judgeLicences(nc, { nonCommercial: true })).toEqual([]);
89
+ });
90
+ });
91
+
92
+ describe("licenceMessage: each refusal names its cure", () => {
93
+ const messageOf = (id: string, stored: Copy["stored"]) => {
94
+ const [f] = judgeLicences(corpus([paper("k", [copy(id, stored)])]), OFF);
95
+ return f === undefined ? "" : licenceMessage(f);
96
+ };
97
+
98
+ it.each([
99
+ [
100
+ "NOASSERTION",
101
+ "a copy of `k` stores `pdf` (`pdf/<key>.pdf`), and no licence was read for that copy (`NOASSERTION`). What to do: record the licence and where it was read (`licence.id`, `read_from`, `read_on`), or remove the file and `\"pdf\"` from that copy's `stored`, and keep the paper's ids",
102
+ ],
103
+ [
104
+ "CC-BY-3.0",
105
+ "a copy of `k` stores `pdf` (`pdf/<key>.pdf`) under `CC-BY-3.0`, and the licence table does not list that id, so it permits nothing. What to do: correct the id if it is misspelt; otherwise remove the file and `\"pdf\"` from that copy's `stored`, and keep the paper's ids",
106
+ ],
107
+ [
108
+ "LicenseRef-publisher",
109
+ "a copy of `k` stores `pdf` (`pdf/<key>.pdf`) under `LicenseRef-publisher`, which does not permit it: the publisher grants no right to third parties. What to do: remove the file and `\"pdf\"` from that copy's `stored`, and keep the paper's ids",
110
+ ],
111
+ [
112
+ "CC-BY-NC-4.0",
113
+ 'a copy of `k` stores `pdf` (`pdf/<key>.pdf`) under `CC-BY-NC-4.0`, which permits it only in a non-commercial project, and this one has not declared itself one. What to do: if it is one, set `"corpus/licence": ["warn", { "nonCommercial": true }]` in the root `paperlint.json`; otherwise remove the file and `"pdf"` from that copy\'s `stored`, and keep the paper\'s ids',
114
+ ],
115
+ ])("%s", (id, text) => {
116
+ expect(messageOf(id, ["pdf"])).toBe(text);
117
+ });
118
+
119
+ it("names every kind and file of a finding", () => {
120
+ expect(messageOf("LicenseRef-publisher", ["pdf", "text"])).toBe(
121
+ 'a copy of `k` stores `pdf` and `text` (`pdf/<key>.pdf`, `text/<key>.txt`) under `LicenseRef-publisher`, which does not permit them: the publisher grants no right to third parties. What to do: remove the files and `"pdf"` and `"text"` from that copy\'s `stored`, and keep the paper\'s ids',
122
+ );
123
+ });
124
+
125
+ it("names the text file for a stored text", () => {
126
+ expect(messageOf("NOASSERTION", ["text"])).toContain("(`text/<key>.txt`)");
127
+ });
128
+ });
@@ -0,0 +1,99 @@
1
+ /**
2
+ * `corpus/licence`'s judgement of one venue corpus (docs/design/venue-corpus.md, decisions 3 and 4;
3
+ * docs/rules/corpus/licence.md): whether the licence of each copy permits keeping each kind it
4
+ * stores. Pure: the record, already parsed by the codec, and the one setting in; the findings out.
5
+ * What a licence permits is the table in `licence.ts`, asked here and never copied.
6
+ */
7
+ import { groupBy } from "remeda";
8
+ import { storedAt } from "./corpus-record.ts";
9
+ import {
10
+ permits,
11
+ type LicenceSettings,
12
+ type Permission,
13
+ type StoredKind,
14
+ } from "./licence.ts";
15
+ import type { Copy, RecordPath, VenueCorpus } from "./venue-corpus.ts";
16
+
17
+ /** What stands against storing one kind of one copy: any permission but the one that allows it. */
18
+ export type Refusal = Exclude<Permission, { readonly kind: "permitted" }>;
19
+
20
+ /**
21
+ * The kinds of one copy that one refusal stands against, with `at`, the copy's `stored` in `papers.json`.
22
+ * A copy whose kinds are refused for the same reason is one finding naming them all; ND, which
23
+ * refuses one kind and not the other, gives one finding for that kind.
24
+ */
25
+ export interface LicenceFinding {
26
+ readonly at: RecordPath;
27
+ readonly key: string;
28
+ readonly licence: string;
29
+ readonly stored: readonly [StoredKind, ...StoredKind[]];
30
+ readonly refusal: Refusal;
31
+ }
32
+
33
+ /** One stored kind of a copy and what refuses it. */
34
+ interface Refused {
35
+ readonly stored: StoredKind;
36
+ readonly refusal: Refusal;
37
+ }
38
+
39
+ /** The stored kinds of `copy` its licence refuses, in its `stored` order. */
40
+ const refusedKinds = (
41
+ copy: Readonly<Copy>,
42
+ settings: Readonly<LicenceSettings>,
43
+ ): readonly Refused[] =>
44
+ copy.stored.flatMap((stored) => {
45
+ const refusal = permits(copy.licence.id, stored, settings);
46
+ return refusal.kind === "permitted" ? [] : [{ stored, refusal }];
47
+ });
48
+
49
+ /** The refusals of one copy, one per reason (two refusals that print the same message are one), each with its kinds. */
50
+ const byReason = (
51
+ refused: readonly Refused[],
52
+ ): readonly Pick<LicenceFinding, "stored" | "refusal">[] =>
53
+ Object.values(groupBy(refused, (r) => JSON.stringify(r.refusal))).map(
54
+ ([first, ...rest]) => ({
55
+ stored: [first.stored, ...rest.map((r) => r.stored)],
56
+ refusal: first.refusal,
57
+ }),
58
+ );
59
+
60
+ /** Every refusal of every copy, with the stored kinds it stands against, in the record's order. */
61
+ export const judgeLicences = (
62
+ corpus: VenueCorpus,
63
+ settings: Readonly<LicenceSettings>,
64
+ ): readonly LicenceFinding[] =>
65
+ corpus.papers.flatMap((p, paper) =>
66
+ p.copies.flatMap((c, copy) =>
67
+ byReason(refusedKinds(c, settings)).map((r) => ({
68
+ at: storedAt(paper, [copy]),
69
+ key: p.key,
70
+ licence: c.licence.id,
71
+ ...r,
72
+ })),
73
+ ),
74
+ );
75
+
76
+ const FILE: Readonly<Record<StoredKind, string>> = {
77
+ pdf: "pdf/<key>.pdf",
78
+ text: "text/<key>.txt",
79
+ };
80
+
81
+ /** The text of a finding: what is wrong, then what to do. */
82
+ export function licenceMessage(f: LicenceFinding): string {
83
+ const kinds = f.stored.map((k) => `\`${k}\``).join(" and ");
84
+ const files = f.stored.map((k) => `\`${FILE[k]}\``).join(", ");
85
+ const quoted = f.stored.map((k) => `\`"${k}"\``).join(" and ");
86
+ const it = f.stored.length === 1 ? "it" : "them";
87
+ const what = `a copy of \`${f.key}\` stores ${kinds} (${files})`;
88
+ const remove = `remove ${f.stored.length === 1 ? "the file" : "the files"} and ${quoted} from that copy's \`stored\`, and keep the paper's ids`;
89
+ switch (f.refusal.kind) {
90
+ case "not-read":
91
+ return `${what}, and no licence was read for that copy (\`NOASSERTION\`). What to do: record the licence and where it was read (\`licence.id\`, \`read_from\`, \`read_on\`), or ${remove}`;
92
+ case "unlisted":
93
+ return `${what} under \`${f.refusal.id}\`, and the licence table does not list that id, so it permits nothing. What to do: correct the id if it is misspelt; otherwise ${remove}`;
94
+ case "forbidden":
95
+ return `${what} under \`${f.licence}\`, which does not permit ${it}: ${f.refusal.why}. What to do: ${remove}`;
96
+ case "non-commercial-only":
97
+ return `${what} under \`${f.licence}\`, which permits ${it} only in a non-commercial project, and this one has not declared itself one. What to do: if it is one, set \`"corpus/licence": ["warn", { "nonCommercial": true }]\` in the root \`paperlint.json\`; otherwise ${remove}`;
98
+ }
99
+ }
@@ -37,7 +37,7 @@ const folder = (
37
37
  record: CorpusFolder["record"],
38
38
  pdf: readonly string[] = [],
39
39
  text: readonly string[] = [],
40
- ): CorpusFolder => ({ record, stored: { pdf, text } });
40
+ ): CorpusFolder => ({ folder: "agent", record, stored: { pdf, text } });
41
41
 
42
42
  const read = (papers: readonly Paper[]): CorpusFolder["record"] => ({
43
43
  ok: true,
@@ -61,6 +61,12 @@ describe("storedKey: the paper a stored file's name belongs to", () => {
61
61
  });
62
62
 
63
63
  describe("judgeCorpus", () => {
64
+ it("names a record whose venue is not its folder's name, at the venue field", () => {
65
+ expect(judgeCorpus({ ...folder(read([])), folder: "other" })).toEqual([
66
+ { kind: "venue", at: ["venue"], venue: "agent", folder: "other" },
67
+ ]);
68
+ });
69
+
64
70
  it("is silent when every stored file is claimed by exactly one copy and exists", () => {
65
71
  expect(
66
72
  judgeCorpus(
@@ -23,6 +23,8 @@ export const CORPORA_DIR = "venues";
23
23
 
24
24
  /** What the rule reads of one corpus folder. */
25
25
  export interface CorpusFolder {
26
+ /** The corpus folder's name: the venue preset's series, which the record's `venue` must repeat. */
27
+ readonly folder: string;
26
28
  /** `papers.json`, as the codec parsed it. */
27
29
  readonly record: ParsedCorpus;
28
30
  /** The names in `pdf/` and in `text/`, hidden ones left out; none when the folder is absent. */
@@ -35,6 +37,11 @@ export interface CorpusFolder {
35
37
  */
36
38
  export type CorpusFinding = { readonly at: RecordPath } & (
37
39
  | { readonly kind: "unparsed"; readonly message: string }
40
+ | {
41
+ readonly kind: "venue";
42
+ readonly venue: string;
43
+ readonly folder: string;
44
+ }
38
45
  | {
39
46
  readonly kind: "unclaimed";
40
47
  readonly file: string;
@@ -95,13 +102,10 @@ interface Claim {
95
102
  }
96
103
 
97
104
  /** The `stored` of a paper's copy (`copy` holds its index), as a path. */
98
- const storedAt = (paper: number, copy: readonly number[]): RecordPath => [
99
- "papers",
100
- paper,
101
- "copies",
102
- ...copy,
103
- "stored",
104
- ];
105
+ export const storedAt = (
106
+ paper: number,
107
+ copy: readonly number[],
108
+ ): RecordPath => ["papers", paper, "copies", ...copy, "stored"];
105
109
 
106
110
  /** A paper's kind stored by more than one of its copies, reported at the second one. */
107
111
  const twice = (claims: readonly Claim[]): readonly CorpusFinding[] =>
@@ -162,11 +166,21 @@ const missing = (
162
166
  file: expectedFile(c.kind, c.key),
163
167
  }));
164
168
 
169
+ /** The record's `venue`, when it is not the name of the folder it stands in. */
170
+ const venueName = (
171
+ corpus: VenueCorpus,
172
+ folder: string,
173
+ ): readonly CorpusFinding[] =>
174
+ corpus.venue === folder
175
+ ? []
176
+ : [{ kind: "venue", at: ["venue"], venue: corpus.venue, folder }];
177
+
165
178
  /** What a read record says about the folder. */
166
179
  function judgeRecord(
167
180
  corpus: VenueCorpus,
168
- stored: CorpusFolder["stored"],
181
+ folder: CorpusFolder,
169
182
  ): readonly CorpusFinding[] {
183
+ const { stored } = folder;
170
184
  const claims = STORED_KINDS.flatMap((kind) =>
171
185
  corpus.papers.map((p, paper) => ({
172
186
  kind,
@@ -176,6 +190,7 @@ function judgeRecord(
176
190
  })),
177
191
  );
178
192
  return [
193
+ ...venueName(corpus, folder.folder),
179
194
  ...twice(claims),
180
195
  ...unclaimed(claims, stored),
181
196
  ...missing(claims, stored),
@@ -185,7 +200,7 @@ function judgeRecord(
185
200
  /** Every finding about one corpus folder; none for a corpus whose record accounts for each copy. */
186
201
  export const judgeCorpus = (folder: CorpusFolder): readonly CorpusFinding[] =>
187
202
  folder.record.ok
188
- ? judgeRecord(folder.record.corpus, folder.stored)
203
+ ? judgeRecord(folder.record.corpus, folder)
189
204
  : folder.record.problems.map((p) => ({
190
205
  kind: "unparsed",
191
206
  at: p.path,
@@ -200,6 +215,8 @@ export function corpusMessage(f: CorpusFinding): string {
200
215
  switch (f.kind) {
201
216
  case "unparsed":
202
217
  return `\`${pathText(f.at)}\`: ${f.message}. What to do: correct the field; the fields are in the JSON Schema \`papers.schema.json\` that \`study-accepted-papers\` ships`;
218
+ case "venue":
219
+ return `the record says \`"venue": "${f.venue}"\`, and its folder is \`${f.folder}\`. What to do: rename the folder to \`${f.venue}\`, or correct the field to \`${f.folder}\``;
203
220
  case "unclaimed":
204
221
  return `\`${f.file}\` is stored, and no copy in \`${CORPUS_RECORD}\` claims it${f.key === null ? `: its name is not \`pdf/<key>.pdf\`, \`text/<key>.txt\` or \`text/<key>.<variant>.txt\`` : ` (no copy of the paper \`${f.key}\` lists it in \`stored\`)`}. What to do: record it under the copy it was fetched from, with \`fetched_from\`, its licence and where the licence was read; ${KEEP_IDS}`;
205
222
  case "missing":
@@ -13,8 +13,14 @@
13
13
  */
14
14
  import { sortBy } from "remeda";
15
15
 
16
- /** A venue preset's id: a series of lowercase words and digits joined by hyphens, then `-<year>`. */
17
- export const EDITION_ID = /^([a-z0-9]+(?:-[a-z0-9]+)*)-(\d{4})$/u;
16
+ /** A series: lowercase words and digits joined by hyphens (`icse`, `usenix-sec`). */
17
+ const SERIES = "[a-z0-9]+(?:-[a-z0-9]+)*";
18
+
19
+ /** A venue preset's id: a series, then `-<year>`. */
20
+ export const EDITION_ID = new RegExp(`^(${SERIES})-(\\d{4})$`, "u");
21
+
22
+ /** A series id's shape, the part of an edition's id before its year; whether it ends in a year is `endsInYear`. */
23
+ export const SERIES_ID = new RegExp(`^${SERIES}$`, "u");
18
24
 
19
25
  /** An edition: its series and its year. */
20
26
  export interface Edition {
@@ -25,7 +25,7 @@ const both = (id: string, settings = COMMERCIAL) =>
25
25
  const PERMITTED = { kind: "permitted" } as const;
26
26
  const NC_ONLY = { kind: "non-commercial-only" } as const;
27
27
  const ARXIV_WHY =
28
- 'it grants arXiv alone the right to distribute: "We are thus unable to grant others the right to distribute arXiv articles"';
28
+ 'its only grant is to arXiv: "I grant arXiv.org a perpetual, non-exclusive license to distribute this article" (arxiv.org/licenses/nonexclusive-distrib/1.0/license.html), and nothing to anyone else';
29
29
  const ND_WHY =
30
30
  "ND permits reproduction in unmodified form; whether an extracted text is an adaptation is unsettled";
31
31
 
@@ -16,7 +16,7 @@
16
16
  export const STORED_KINDS = ["text", "pdf"] as const;
17
17
  export type StoredKind = (typeof STORED_KINDS)[number];
18
18
 
19
- /** SPDX's own id for "no licence information was given": here, the licence was not read. */
19
+ /** SPDX's keyword (not a list id) for "no licence information was given": here, the licence was not read. */
20
20
  export const NOASSERTION = "NOASSERTION";
21
21
 
22
22
  /** The project's one setting the table reads: it declares itself non-commercial. */
@@ -48,7 +48,7 @@ const ND = {
48
48
  } as const;
49
49
 
50
50
  const ARXIV = {
51
- no: 'it grants arXiv alone the right to distribute: "We are thus unable to grant others the right to distribute arXiv articles"',
51
+ no: 'its only grant is to arXiv: "I grant arXiv.org a perpetual, non-exclusive license to distribute this article" (arxiv.org/licenses/nonexclusive-distrib/1.0/license.html), and nothing to anyone else',
52
52
  } as const;
53
53
 
54
54
  const PUBLISHER = {
@@ -319,8 +319,9 @@ export const VENUES_DIR = "venues";
319
319
 
320
320
  /**
321
321
  * The papers directory as the README and `docs/layout.md` draw it: the venues' corpora beside the
322
- * paper folders, and each paper folder with its layout. Only the paper folder's part is enforced (by
323
- * the two layout rules); `venues/` is drawn so a reader sees where a corpus goes, and no rule reads it.
322
+ * paper folders, and each paper folder with its layout. The paper folder's part is enforced by the two
323
+ * layout rules; each corpus in `venues/` by `corpus/record` and `corpus/allowed-files-only`, whose
324
+ * layout is `corpus-layout.ts`.
324
325
  */
325
326
  export const PAPERS_NODES: readonly TreeNode[] = [
326
327
  {
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * The pages draw the layout the code enforces. Each page embeds the drawing between
3
3
  * `<!-- layout:begin … -->` and `<!-- layout:end -->`, and that block must equal the render of the
4
- * constants that decide what is allowed (`PAPER_LAYOUT_TREE`, `REPRO_LAYOUT_TREE`, and
4
+ * constants that decide what is allowed (`PAPER_LAYOUT_TREE`, `REPRO_LAYOUT_TREE`, `CORPUS_LAYOUT_TREE`, and
5
5
  * `PAPERS_LAYOUT_TREE`, which draws the paper folder beside the venues' corpora) — so a page cannot
6
6
  * show an entry the rule reports, or miss one it allows. Both halves: the committed pages match, and
7
7
  * a page with one entry changed or with no block at all does not.
@@ -17,6 +17,7 @@ import {
17
17
  PAPER_LAYOUT_TREE,
18
18
  PAPERS_LAYOUT_TREE,
19
19
  } from "./domain/paper-layout.ts";
20
+ import { CORPUS_LAYOUT_TREE } from "./domain/corpus-layout.ts";
20
21
  import { REPRO_LAYOUT_TREE } from "./domain/repro-layout.ts";
21
22
 
22
23
  const ROOT = dirname(dirname(fileURLToPath(import.meta.url)));
@@ -24,6 +25,7 @@ const ROOT = dirname(dirname(fileURLToPath(import.meta.url)));
24
25
  const PAGES: readonly (readonly [string, string])[] = [
25
26
  ["docs/rules/paper/allowed-files-only.md", PAPER_LAYOUT_TREE],
26
27
  ["docs/rules/repro/allowed-files-only.md", REPRO_LAYOUT_TREE],
28
+ ["docs/rules/corpus/allowed-files-only.md", CORPUS_LAYOUT_TREE],
27
29
  ["docs/layout.md", PAPERS_LAYOUT_TREE],
28
30
  ];
29
31
 
@@ -41,6 +41,7 @@
41
41
  * - `files: [["a", "b"]]` matches a file only when BOTH patterns match.
42
42
  */
43
43
  import { relative, sep } from "node:path";
44
+ import { CONFIG_FILE } from "#lib/paper-config";
44
45
  import { CORPORA_DIR } from "./domain/corpus-record.ts";
45
46
  import type {
46
47
  ConfigBlock,
@@ -53,8 +54,9 @@ import type {
53
54
  * Which papers' own files paperlint's blocks claim. `any` is the config's SHAPE, for the rule list and
54
55
  * the docs: a file in any folder. `papers` is what `paperlint lint` runs on: the real papers, as glob
55
56
  * prefixes relative to ESLint's `cwd` ("" for `cwd` itself), so a copy of a paper kept inside one (a
56
- * review snapshot, a build copy) is claimed by no block (#582); and the papers roots (absolute),
57
- * whose `venues/` hold the venue corpora.
57
+ * review snapshot, a build copy) is claimed by no block (#582); the papers roots (absolute),
58
+ * whose `venues/` hold the venue corpora; and the project root (absolute) whose `paperlint.json`
59
+ * is linted, or null when it is not (no papers root holds `venues/`).
58
60
  */
59
61
  export type PaperScope =
60
62
  | { readonly kind: "any" }
@@ -63,6 +65,7 @@ export type PaperScope =
63
65
  readonly cwd: string;
64
66
  readonly prefixes: readonly string[];
65
67
  readonly roots: readonly string[];
68
+ readonly home: string | null;
66
69
  };
67
70
 
68
71
  export const ANY_PAPER: PaperScope = { kind: "any" };
@@ -75,18 +78,31 @@ const literalGlob = (path: string): string =>
75
78
  const posixRelative = (from: string, to: string): string =>
76
79
  relative(from, to).split(sep).join("/");
77
80
 
78
- /** The papers `dirs` and the papers `roots` under ESLint's `cwd`: the scope `paperlint lint` lints. Pure. */
81
+ /**
82
+ * The papers `dirs` and the papers `roots` under ESLint's `cwd`, and the project root `home` whose
83
+ * `paperlint.json` is linted (null: none is): the scope `paperlint lint` lints. Pure.
84
+ */
79
85
  export const papersScope = (
80
86
  dirs: readonly string[],
81
87
  cwd: string,
82
88
  roots: readonly string[],
89
+ home: string | null = null,
83
90
  ): PaperScope => ({
84
91
  kind: "papers",
85
92
  cwd,
86
93
  prefixes: dirs.map((d) => literalGlob(posixRelative(cwd, d))),
87
94
  roots,
95
+ home,
88
96
  });
89
97
 
98
+ /** The project's root settings file, as the glob that names it from ESLint's `cwd`; none without a `home`. Pure. */
99
+ export const rootSettingsFile = (scope: PaperScope): readonly string[] => {
100
+ if (scope.kind === "any") return [CONFIG_FILE];
101
+ if (scope.home === null) return [];
102
+ const dir = posixRelative(scope.cwd, scope.home);
103
+ return [dir === "" ? CONFIG_FILE : `${literalGlob(dir)}/${CONFIG_FILE}`];
104
+ };
105
+
90
106
  /** A glob of a paper's own file (`paper.tex`, `reviews/*.md`) in each paper of `scope`. Pure. */
91
107
  export const paperFiles = (
92
108
  scope: PaperScope,