paperlint 20.1.1 → 20.2.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 (126) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/.github/workflows/ci.yml +7 -0
  3. package/CLAUDE.md +6 -2
  4. package/CONTRIBUTING.md +2 -2
  5. package/{action.harness.mjs → action.test.mjs} +147 -138
  6. package/dist/adapters/venue-corpus/index.d.ts +345 -0
  7. package/dist/adapters/venue-corpus/index.d.ts.map +1 -0
  8. package/dist/adapters/venue-corpus/index.js +205 -0
  9. package/dist/adapters/venue-corpus/index.js.map +1 -0
  10. package/dist/domain/licence.d.ts +51 -0
  11. package/dist/domain/licence.d.ts.map +1 -0
  12. package/dist/domain/licence.js +61 -0
  13. package/dist/domain/licence.js.map +1 -0
  14. package/dist/domain/venue-corpus.d.ts +120 -0
  15. package/dist/domain/venue-corpus.d.ts.map +1 -0
  16. package/dist/domain/venue-corpus.js +13 -0
  17. package/dist/domain/venue-corpus.js.map +1 -0
  18. package/dist/eslint-rules/CLAUDE.md.spec.d.ts.map +1 -1
  19. package/dist/eslint-rules/CLAUDE.md.spec.js +1 -0
  20. package/dist/eslint-rules/CLAUDE.md.spec.js.map +1 -1
  21. package/dist/eslint-rules/papers.js +1 -1
  22. package/dist/latex-log.d.ts +1 -1
  23. package/dist/latex-log.js +1 -1
  24. package/dist/latex-loop.d.ts +1 -1
  25. package/dist/latex-loop.js +1 -1
  26. package/dist/lib/paper-config.d.ts +3 -3
  27. package/dist/lib/paper-config.js +3 -3
  28. package/dist/ports/venue-corpus-codec.d.ts +11 -0
  29. package/dist/ports/venue-corpus-codec.d.ts.map +1 -0
  30. package/dist/ports/venue-corpus-codec.js +2 -0
  31. package/dist/ports/venue-corpus-codec.js.map +1 -0
  32. package/dist/skill-chunks/chunk-5KCU4WTN.js +108 -0
  33. package/dist/skill-chunks/{chunk-X4VKG4KT.js → chunk-6YEM4VDI.js} +11 -9
  34. package/dist/skill-chunks/{chunk-L3NJUJUP.js → chunk-CXAGKT44.js} +5 -3
  35. package/dist/skill-chunks/{chunk-6NU6CXUS.js → chunk-J5XYPERO.js} +12 -72
  36. package/dist/skill-chunks/{chunk-IREAROCV.js → chunk-Z5YMDZYW.js} +4 -0
  37. package/dist/skills/study-accepted-papers/scripts/corpus-licences-core.d.ts +54 -0
  38. package/dist/skills/study-accepted-papers/scripts/corpus-licences.d.ts +2 -0
  39. package/docs/design/venue-corpus.md +250 -0
  40. package/docs/e2e.md +9 -9
  41. package/docs/testing.md +3 -4
  42. package/docs/venues.md +144 -21
  43. package/eslint-rules/CLAUDE.md +5 -1
  44. package/eslint-rules/CLAUDE.md.spec.ts +3 -0
  45. package/eslint-rules/{install-path-literals.harness.mjs → install-path-literals.test.mjs} +14 -13
  46. package/eslint-rules/{latex-language.harness.mjs → latex-language-rules.test.mjs} +61 -51
  47. package/eslint-rules/{paper-stages.harness.mjs → paper-stages-rule.test.mjs} +66 -69
  48. package/eslint-rules/{papers.harness.mjs → papers.test.mjs} +41 -30
  49. package/eslint-rules/papers.ts +1 -1
  50. package/eslint-rules/{pdf-last-page-balance.harness.mjs → pdf-last-page-balance.test.mjs} +27 -15
  51. package/eslint-rules/{temp-root-realpath.harness.mjs → temp-root-realpath.test.mjs} +24 -24
  52. package/eslint-rules/{tex-build.harness.mjs → tex-build.test.mjs} +292 -271
  53. package/eslint.config.mjs +15 -2
  54. package/fixtures/pdf-facts/README.md +1 -1
  55. package/fixtures/render-paper/build-clean.sh +1 -1
  56. package/fixtures/toolchain-mirror/install-tl +1 -1
  57. package/lib/{agent-cli-version.harness.mjs → agent-cli-version.test.mjs} +17 -18
  58. package/lib/{paper-config.harness.mjs → paper-config.test.mjs} +21 -20
  59. package/lib/paper-config.ts +3 -3
  60. package/lib/{skill-trigger-cases.harness.mjs → skill-trigger-cases-carrier.test.mjs} +78 -115
  61. package/package.json +4 -3
  62. package/presets/acm-acmsmall.jsonc +1 -1
  63. package/scripts/bundle-skills.ts +1 -0
  64. package/scripts/check-workflow.test.ts +368 -0
  65. package/scripts/check.ts +2 -2
  66. package/scripts/eslint-file-length.mjs +9 -9
  67. package/scripts/eslint-report-guard.mjs +1 -1
  68. package/scripts/eslint-report-guard.test.mjs +1 -1
  69. package/scripts/harness-api.test.ts +7 -46
  70. package/scripts/{rules-see-files.harness.mjs → rules-see-files-rule.test.mjs} +10 -6
  71. package/scripts/rules-see-files.mjs +1 -1
  72. package/scripts/venue-corpus-schema.test.ts +39 -0
  73. package/scripts/venue-corpus-schema.ts +17 -0
  74. package/skills/argument-arc/scripts/headings.js +6 -4
  75. package/skills/cold-read-diff/scripts/cold-read.js +6 -4
  76. package/skills/paper-pipeline/{paper-pipeline.harness.mjs → paper-pipeline.test.mjs} +45 -46
  77. package/skills/paper-pipeline/scripts/{consumer.harness.mjs → consumer-paths.test.mjs} +66 -59
  78. package/skills/paper-pipeline/scripts/consumer.mjs +3 -3
  79. package/skills/paper-pipeline/scripts/{extract-ref-facts.harness.mjs → extract-ref-facts-cli.test.mjs} +29 -31
  80. package/skills/paper-pipeline/scripts/extract-ref-facts.js +6 -5
  81. package/skills/paper-pipeline/scripts/fixtures/real-bib/refs.bib +1 -1
  82. package/skills/paper-pipeline/scripts/{generated-code.harness.mjs → generated-code-fixtures.test.mjs} +39 -46
  83. package/skills/pc-panel-review/scripts/prior-reviews.js +7 -5
  84. package/skills/render-paper/{extract-pdf-facts.harness.ts → extract-pdf-facts.test.ts} +20 -13
  85. package/skills/render-paper/{render-paper.harness.mjs → render-paper.test.mjs} +41 -40
  86. package/skills/study-accepted-papers/SKILL.md +28 -2
  87. package/skills/study-accepted-papers/SKILL.md.spec.ts +27 -1
  88. package/skills/study-accepted-papers/papers.schema.json +427 -0
  89. package/skills/study-accepted-papers/scripts/corpus-licences-core.js +180 -0
  90. package/skills/study-accepted-papers/scripts/corpus-licences-core.ts +302 -0
  91. package/skills/study-accepted-papers/scripts/corpus-licences.js +383 -0
  92. package/skills/study-accepted-papers/scripts/corpus-licences.test.ts +485 -0
  93. package/skills/study-accepted-papers/scripts/corpus-licences.ts +27 -0
  94. package/skills/verify-citations/scripts/bib-authors.js +6 -5
  95. package/skills/verify-citations/scripts/verify-cites.js +6 -5
  96. package/src/adapters/pdfjs/fill.test.ts +1 -1
  97. package/src/adapters/venue-corpus/index.test.ts +279 -0
  98. package/src/adapters/venue-corpus/index.ts +286 -0
  99. package/src/{build-engine.harness.mjs → build-engine-prepare.test.mjs} +98 -81
  100. package/src/{build.harness.mjs → build-fake-tex.test.mjs} +61 -28
  101. package/src/{cli.harness.mjs → cli-e2e.test.mjs} +108 -102
  102. package/src/cli.test.ts +1 -1
  103. package/src/{doctor.harness.mjs → doctor-install.test.mjs} +28 -29
  104. package/src/domain/licence.test.ts +122 -0
  105. package/src/domain/licence.ts +95 -0
  106. package/src/domain/venue-corpus.ts +130 -0
  107. package/src/{engine.harness.mjs → engine.test.mjs} +120 -106
  108. package/src/facts-file.test.ts +1 -1
  109. package/src/{hooks-settings.harness.ts → hooks-settings.test.ts} +161 -146
  110. package/src/latex-log.test.ts +395 -0
  111. package/src/latex-log.ts +1 -1
  112. package/src/latex-loop.test.ts +553 -0
  113. package/src/latex-loop.ts +1 -1
  114. package/src/{link-skills.harness.ts → link-skills-fs.test.ts} +26 -26
  115. package/src/{new-paper.harness.mjs → new-paper-scaffold.test.mjs} +31 -19
  116. package/src/{pdf-facts.harness.ts → pdf-facts-tables.test.ts} +28 -22
  117. package/src/{pdf-geometry.harness.ts → pdf-geometry.test.ts} +93 -75
  118. package/src/ports/venue-corpus-codec.ts +11 -0
  119. package/src/{rules-config.harness.ts → rules-config.test.ts} +41 -31
  120. package/src/{structure.harness.ts → structure.test.ts} +12 -10
  121. package/src/{tex-requirements.harness.ts → tex-requirements-tables.test.ts} +106 -85
  122. package/src/{toolchain.harness.mjs → toolchain-mirror.test.mjs} +204 -186
  123. package/scripts/check.harness.ts +0 -343
  124. package/scripts/harness-api.frozen.json +0 -41
  125. package/src/latex-log.harness.ts +0 -382
  126. package/src/latex-loop.harness.ts +0 -515
@@ -133,7 +133,7 @@ as judgement, against the base rates of \`references/base-rates.md\`; simulated
133
133
 
134
134
  | what | where | why there |
135
135
  |---|---|---|
136
- | **the venue corpus** | \`<papers-root>/venues/<venue>/\` (the papers directory from the project's \`paperlint.json\`) | **shared by every paper that targets the venue**, collected once and reused by every later mode. \`MANIFEST.md\` (sources, years, what was capped, the proxy and its base rate), the winner and ordinary lists, \`measurements.json\` (L0/L1 codes, one row per paper), \`text/\` extractions, the scripts, \`deep-reads/\` (one file per paper, reusable by any paper). Corpus 2 goes in its own labelled subfolder. **PDFs are not committed**: record the IDs and the command. |
136
+ | **the venue corpus** | \`<papers-root>/venues/<venue>/\` (the papers directory from the project's \`paperlint.json\`; the folder is the preset's series) | **shared by every paper that targets the venue**, collected once and reused by every later mode. \`papers.json\` (one row per paper: winners \`award\`, ordinary \`accepted\`, corpus 2 \`sister\`; every copy with its licence), \`MANIFEST.md\` (sources, years, what was capped, the proxy and its base rate, the commands run), \`measurements.json\` (L0/L1 codes keyed by the row's \`key\`), \`pdf/<key>.pdf\` and \`text/<key>.txt\` only as the licence step below permits, \`deep-reads/<key>.md\`, \`sources/\` (saved listing and call pages). No other name. |
137
137
  | **the scorecard** | the section **"Strong-accept scorecard (M1–M10)"** of the paper's \`PIPELINE-STATUS.md\` | a row per mechanism: status (pass / partial / fail), evidence (\`file:line\`), owner, plan or "accept ceiling". **The only place the verdicts live**; update it there. |
138
138
  | **the reasoning** | \`<paper>/reviews/<YYYY-MM-DD>-study-accepted-<venue>-<mode>.md\` | a dated report per run, with frontmatter (below). It keeps the reasoning, the selection and the per-mechanism argument, and **points to the scorecard section; it never copies the table**. |
139
139
  | **the stage** | the SETUP row with id \`venuebar\` in \`PIPELINE-STATUS.md\` (the id is kept for existing scorecards) | status, date, the mode and depth run, and a link to the report. One row, updated by every mode. |
@@ -163,6 +163,32 @@ scorecard: PIPELINE-STATUS.md#strong-accept-scorecard-m1m10
163
163
  ---
164
164
  \`\`\`
165
165
 
166
+ ## The record before any PDF or text
167
+
168
+ The corpus keeps third-party papers, so what it may store is decided per copy, before anything is
169
+ downloaded or extracted. The record's fields are in \`\${CLAUDE_SKILL_DIR}/papers.schema.json\`; the
170
+ script below refuses a record that breaks them, with the path of the field, and checks what a schema
171
+ cannot (unique keys, a paper's edition among the listed ones, a stored copy's \`fetched_from\`).
172
+
173
+ 1. **A row per paper** in \`papers.json\`, with its ids, title, authors and abstract: metadata, kept
174
+ whatever the licence.
175
+ 2. **A copy per version you find** (the published one, the arXiv preprint), each with the licence read
176
+ from the source \`docs/venues.md\` names for that kind of copy ("Where a copy's licence is read
177
+ from"): \`read_from\` is the page or API response, \`read_on\` the date. Never the licence line
178
+ printed inside a PDF: it can belong to another copy. No source gives it → \`{ "id": "NOASSERTION" }\`.
179
+ 3. **Run** \`node \${CLAUDE_SKILL_DIR}/scripts/corpus-licences.js <venue>\`.
180
+ Exit 1: the record does not parse, or there is not exactly one; fix what it names and run it again. Exit 0: one line per paper
181
+ and kind (\`text\`, \`pdf\`).
182
+ 4. **Store only on a \`keep\` line**: download from that copy to \`pdf/<key>.pdf\`, or extract to
183
+ \`text/<key>.txt\`, then add the kind to that copy's \`stored\` and set \`fetched_from\` to the URL the
184
+ bytes came from. On a \`none\` line store nothing of that kind: read the copy where it is, in a
185
+ scratch folder outside the repository, and keep only codes, short quotes and ids. A copy refused
186
+ only as "permits it only in a project declared non-commercial" may be stored when the author says
187
+ the project is non-commercial.
188
+
189
+ \`corpus/record\` and \`corpus/licence\` (not shipped yet) will hold what this step writes; until they
190
+ ship, the script is the only check of the record.
191
+
166
192
  ## Before any level: pin the venue's stated bar
167
193
 
168
194
  \`WebFetch\` the current call for papers and, if separate, the reviewer guidelines. Capture in the
@@ -0,0 +1,427 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "type": "object",
4
+ "properties": {
5
+ "venue": {
6
+ "type": "string",
7
+ "minLength": 1
8
+ },
9
+ "editions": {
10
+ "type": "array",
11
+ "items": {
12
+ "type": "object",
13
+ "properties": {
14
+ "edition": {
15
+ "type": "integer",
16
+ "exclusiveMinimum": 0,
17
+ "maximum": 9007199254740991
18
+ },
19
+ "listed_from": {
20
+ "type": "string",
21
+ "format": "uri"
22
+ },
23
+ "read_on": {
24
+ "type": "string",
25
+ "format": "date",
26
+ "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$"
27
+ },
28
+ "accepted": {
29
+ "type": "integer",
30
+ "minimum": 0,
31
+ "maximum": 9007199254740991
32
+ }
33
+ },
34
+ "required": [
35
+ "edition",
36
+ "listed_from",
37
+ "read_on"
38
+ ],
39
+ "additionalProperties": false
40
+ }
41
+ },
42
+ "papers": {
43
+ "type": "array",
44
+ "items": {
45
+ "oneOf": [
46
+ {
47
+ "type": "object",
48
+ "properties": {
49
+ "key": {
50
+ "type": "string",
51
+ "pattern": "^[A-Za-z0-9][A-Za-z0-9_-]*$"
52
+ },
53
+ "title": {
54
+ "type": "string",
55
+ "minLength": 1
56
+ },
57
+ "authors": {
58
+ "type": "array",
59
+ "items": {
60
+ "type": "string",
61
+ "minLength": 1
62
+ }
63
+ },
64
+ "abstract": {
65
+ "type": [
66
+ "string",
67
+ "null"
68
+ ]
69
+ },
70
+ "ids": {
71
+ "type": "object",
72
+ "properties": {
73
+ "doi": {
74
+ "type": "string",
75
+ "minLength": 1
76
+ },
77
+ "arxiv": {
78
+ "type": "string",
79
+ "minLength": 1
80
+ },
81
+ "dblp": {
82
+ "type": "string",
83
+ "minLength": 1
84
+ },
85
+ "s2": {
86
+ "type": "string",
87
+ "minLength": 1
88
+ },
89
+ "url": {
90
+ "type": "string",
91
+ "format": "uri"
92
+ }
93
+ },
94
+ "additionalProperties": false
95
+ },
96
+ "copies": {
97
+ "type": "array",
98
+ "items": {
99
+ "oneOf": [
100
+ {
101
+ "type": "object",
102
+ "properties": {
103
+ "version": {
104
+ "type": "string",
105
+ "enum": [
106
+ "published",
107
+ "accepted",
108
+ "preprint"
109
+ ]
110
+ },
111
+ "url": {
112
+ "type": "string",
113
+ "format": "uri"
114
+ },
115
+ "licence": {
116
+ "type": "object",
117
+ "properties": {
118
+ "id": {
119
+ "type": "string"
120
+ },
121
+ "read_from": {
122
+ "type": "string",
123
+ "format": "uri"
124
+ },
125
+ "read_on": {
126
+ "type": "string",
127
+ "format": "date",
128
+ "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$"
129
+ }
130
+ },
131
+ "required": [
132
+ "id"
133
+ ],
134
+ "additionalProperties": false
135
+ },
136
+ "stored": {
137
+ "type": "array",
138
+ "items": {
139
+ "type": "string",
140
+ "enum": [
141
+ "text",
142
+ "pdf"
143
+ ]
144
+ }
145
+ },
146
+ "fetched_from": {
147
+ "type": "string",
148
+ "format": "uri"
149
+ }
150
+ },
151
+ "required": [
152
+ "version",
153
+ "url",
154
+ "licence",
155
+ "stored"
156
+ ],
157
+ "additionalProperties": false
158
+ },
159
+ {
160
+ "type": "object",
161
+ "properties": {
162
+ "version": {
163
+ "type": "string",
164
+ "const": "unknown"
165
+ },
166
+ "licence": {
167
+ "type": "object",
168
+ "properties": {
169
+ "id": {
170
+ "type": "string",
171
+ "const": "NOASSERTION"
172
+ }
173
+ },
174
+ "required": [
175
+ "id"
176
+ ],
177
+ "additionalProperties": false
178
+ },
179
+ "stored": {
180
+ "type": "array",
181
+ "items": {
182
+ "type": "string",
183
+ "enum": [
184
+ "text",
185
+ "pdf"
186
+ ]
187
+ }
188
+ },
189
+ "fetched_from": {
190
+ "type": "string",
191
+ "format": "uri"
192
+ }
193
+ },
194
+ "required": [
195
+ "version",
196
+ "licence",
197
+ "stored"
198
+ ],
199
+ "additionalProperties": false
200
+ }
201
+ ]
202
+ }
203
+ },
204
+ "group": {
205
+ "type": "string",
206
+ "enum": [
207
+ "accepted",
208
+ "award"
209
+ ]
210
+ },
211
+ "edition": {
212
+ "type": "integer",
213
+ "exclusiveMinimum": 0,
214
+ "maximum": 9007199254740991
215
+ }
216
+ },
217
+ "required": [
218
+ "key",
219
+ "title",
220
+ "ids",
221
+ "copies",
222
+ "group",
223
+ "edition"
224
+ ],
225
+ "additionalProperties": {}
226
+ },
227
+ {
228
+ "type": "object",
229
+ "properties": {
230
+ "key": {
231
+ "type": "string",
232
+ "pattern": "^[A-Za-z0-9][A-Za-z0-9_-]*$"
233
+ },
234
+ "title": {
235
+ "type": "string",
236
+ "minLength": 1
237
+ },
238
+ "authors": {
239
+ "type": "array",
240
+ "items": {
241
+ "type": "string",
242
+ "minLength": 1
243
+ }
244
+ },
245
+ "abstract": {
246
+ "type": [
247
+ "string",
248
+ "null"
249
+ ]
250
+ },
251
+ "ids": {
252
+ "type": "object",
253
+ "properties": {
254
+ "doi": {
255
+ "type": "string",
256
+ "minLength": 1
257
+ },
258
+ "arxiv": {
259
+ "type": "string",
260
+ "minLength": 1
261
+ },
262
+ "dblp": {
263
+ "type": "string",
264
+ "minLength": 1
265
+ },
266
+ "s2": {
267
+ "type": "string",
268
+ "minLength": 1
269
+ },
270
+ "url": {
271
+ "type": "string",
272
+ "format": "uri"
273
+ }
274
+ },
275
+ "additionalProperties": false
276
+ },
277
+ "copies": {
278
+ "type": "array",
279
+ "items": {
280
+ "oneOf": [
281
+ {
282
+ "type": "object",
283
+ "properties": {
284
+ "version": {
285
+ "type": "string",
286
+ "enum": [
287
+ "published",
288
+ "accepted",
289
+ "preprint"
290
+ ]
291
+ },
292
+ "url": {
293
+ "type": "string",
294
+ "format": "uri"
295
+ },
296
+ "licence": {
297
+ "type": "object",
298
+ "properties": {
299
+ "id": {
300
+ "type": "string"
301
+ },
302
+ "read_from": {
303
+ "type": "string",
304
+ "format": "uri"
305
+ },
306
+ "read_on": {
307
+ "type": "string",
308
+ "format": "date",
309
+ "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$"
310
+ }
311
+ },
312
+ "required": [
313
+ "id"
314
+ ],
315
+ "additionalProperties": false
316
+ },
317
+ "stored": {
318
+ "type": "array",
319
+ "items": {
320
+ "type": "string",
321
+ "enum": [
322
+ "text",
323
+ "pdf"
324
+ ]
325
+ }
326
+ },
327
+ "fetched_from": {
328
+ "type": "string",
329
+ "format": "uri"
330
+ }
331
+ },
332
+ "required": [
333
+ "version",
334
+ "url",
335
+ "licence",
336
+ "stored"
337
+ ],
338
+ "additionalProperties": false
339
+ },
340
+ {
341
+ "type": "object",
342
+ "properties": {
343
+ "version": {
344
+ "type": "string",
345
+ "const": "unknown"
346
+ },
347
+ "licence": {
348
+ "type": "object",
349
+ "properties": {
350
+ "id": {
351
+ "type": "string",
352
+ "const": "NOASSERTION"
353
+ }
354
+ },
355
+ "required": [
356
+ "id"
357
+ ],
358
+ "additionalProperties": false
359
+ },
360
+ "stored": {
361
+ "type": "array",
362
+ "items": {
363
+ "type": "string",
364
+ "enum": [
365
+ "text",
366
+ "pdf"
367
+ ]
368
+ }
369
+ },
370
+ "fetched_from": {
371
+ "type": "string",
372
+ "format": "uri"
373
+ }
374
+ },
375
+ "required": [
376
+ "version",
377
+ "licence",
378
+ "stored"
379
+ ],
380
+ "additionalProperties": false
381
+ }
382
+ ]
383
+ }
384
+ },
385
+ "group": {
386
+ "type": "string",
387
+ "const": "sister"
388
+ },
389
+ "venue": {
390
+ "type": "string",
391
+ "minLength": 1
392
+ },
393
+ "year": {
394
+ "type": "integer",
395
+ "exclusiveMinimum": 0,
396
+ "maximum": 9007199254740991
397
+ },
398
+ "listed_from": {
399
+ "type": "string",
400
+ "format": "uri"
401
+ }
402
+ },
403
+ "required": [
404
+ "key",
405
+ "title",
406
+ "ids",
407
+ "copies",
408
+ "group",
409
+ "venue",
410
+ "year",
411
+ "listed_from"
412
+ ],
413
+ "additionalProperties": {}
414
+ }
415
+ ]
416
+ }
417
+ }
418
+ },
419
+ "required": [
420
+ "venue",
421
+ "editions",
422
+ "papers"
423
+ ],
424
+ "additionalProperties": false,
425
+ "title": "A venue corpus's papers.json",
426
+ "description": "The record of a venue corpus, papers.json: one row per paper, every copy with its licence. This schema lists the fields; it cannot express that a key is unique, that a paper's edition is one of editions[].edition, or that a copy that stores a file names where it was fetched from. `node ${CLAUDE_SKILL_DIR}/scripts/corpus-licences.js <venue>` checks those and refuses a wrong record with the path of the field."
427
+ }
@@ -0,0 +1,180 @@
1
+ /**
2
+ * corpus-licences-core — for each paper of a venue corpus's `papers.json` and each kind a corpus
3
+ * stores (its extracted text, its PDF), the copy whose licence permits keeping it, or each copy's
4
+ * reason it may not be kept. study-accepted-papers reads it before it downloads a PDF or extracts a
5
+ * text (docs/venues.md, "Licences"; docs/design/venue-corpus.md, decisions 2 and 3).
6
+ *
7
+ * The record is parsed by `VenueCorpusCodec`; what a licence permits is `src/domain/licence.ts`'s
8
+ * table, never restated here. The project's non-commercial setting arrives with `corpus/licence`;
9
+ * until then the runner judges as for a project that has not declared itself non-commercial.
10
+ * No model, no network.
11
+ *
12
+ * Usage: node corpus-licences.js <venue>
13
+ * The record is `<papers-root>/venues/<venue>/papers.json`: the project root is the git top level of
14
+ * the folder the command runs in, the papers roots are the project's `papersDir` (src/papers-roots.ts).
15
+ * Exit: 0 — one line per paper and kind · 1 — not in a git repository, no papers.json in any papers
16
+ * root or one in several, or it does not parse · 2 — no venue named, or not a folder name.
17
+ */
18
+ import { dirname, join } from "node:path";
19
+ import { CONFIG_FILE, PAPERS_DIR_FIELD } from "#lib/paper-config";
20
+ import { callerPath } from "#src/caller-path";
21
+ import { permits, STORED_KINDS, } from "#src/domain/licence";
22
+ import { CORPUS_RECORD, } from "#src/domain/venue-corpus";
23
+ import { papersRoots } from "#src/papers-roots";
24
+ const isRefused = (j) => j.permission.kind !== "permitted";
25
+ /** The first copy, in the record's order, whose licence permits the kind. */
26
+ const keptOf = (judged) => judged
27
+ .map((j) => j.copy)
28
+ .find((c, i) => judged[i]?.permission.kind === "permitted" && c.version !== "unknown");
29
+ /** Every copy that may not be kept as the kind, with why. */
30
+ const refusalsOf = (judged) => judged.filter(isRefused).map((j) => ({
31
+ version: j.copy.version,
32
+ licence: j.copy.licence.id,
33
+ permission: j.permission,
34
+ }));
35
+ /** The verdict for one paper and one kind: the copy to keep, or every copy's refusal. */
36
+ function verdictOf(paper, stored, settings) {
37
+ const judged = paper.copies.map((copy) => ({
38
+ copy,
39
+ permission: permits(copy.licence.id, stored, settings),
40
+ }));
41
+ const kept = keptOf(judged);
42
+ const { key } = paper;
43
+ return kept === undefined
44
+ ? {
45
+ key,
46
+ stored,
47
+ outcome: "none",
48
+ refusals: refusalsOf(judged),
49
+ }
50
+ : {
51
+ key,
52
+ stored,
53
+ outcome: "keep",
54
+ version: kept.version,
55
+ licence: kept.licence.id,
56
+ url: kept.url,
57
+ };
58
+ }
59
+ /** Every paper's verdict for each kind, in the record's order. */
60
+ export const verdicts = (corpus, settings) => corpus.papers.flatMap((p) => STORED_KINDS.map((kind) => verdictOf(p, kind, settings)));
61
+ /** Why a copy may not be kept, in words. */
62
+ function reason(r) {
63
+ switch (r.permission.kind) {
64
+ case "forbidden":
65
+ return `${r.licence}: ${r.permission.why}`;
66
+ case "non-commercial-only":
67
+ return `${r.licence} permits it only in a project declared non-commercial`;
68
+ case "not-read":
69
+ return "its licence was not read (NOASSERTION)";
70
+ case "unlisted":
71
+ return `${r.permission.id} is not in the licence table, so it permits nothing`;
72
+ }
73
+ }
74
+ /** One verdict as the line the command prints. */
75
+ function line(v) {
76
+ const what = v.outcome === "keep"
77
+ ? `keep the ${v.version} copy (${v.licence}), ${v.url}`
78
+ : v.refusals.length === 0
79
+ ? "none: no copy recorded"
80
+ : `none: ${v.refusals.map((r) => `${r.version}: ${reason(r)}`).join("; ")}`;
81
+ return `${v.key} ${v.stored}: ${what}`;
82
+ }
83
+ /** What the command prints for `all`. */
84
+ export const listing = (all) => all.length === 0
85
+ ? `${CORPUS_RECORD} holds no paper\n`
86
+ : `${all.map(line).join("\n")}\n`;
87
+ /**
88
+ * `git rev-parse --show-toplevel` in `cwd`: the project's root, or null outside a repository (or
89
+ * when git did not run). `path` is the caller's PATH, the only variable git is given.
90
+ */
91
+ export function gitTopLevel(git, path, cwd) {
92
+ const r = git.run({
93
+ file: "git",
94
+ args: ["rev-parse", "--show-toplevel"],
95
+ env: { PATH: path ?? "" },
96
+ timeoutMs: 10_000,
97
+ cwd: callerPath(cwd),
98
+ });
99
+ const top = r.kind === "exited" && r.status === 0 ? r.stdout.trim() : "";
100
+ return top === "" ? null : top;
101
+ }
102
+ /** The project's setting the table reads, until `corpus/licence` ships it: not declared. */
103
+ const UNDECLARED = { nonCommercial: false };
104
+ /** A venue is one folder name: no separator, and not a way up. */
105
+ const VENUE = /^[A-Za-z0-9][A-Za-z0-9._-]*$/u;
106
+ const USAGE = "usage: node corpus-licences.js <venue>\n";
107
+ /** The project's `papersDir` setting, read through the disk port; absent file, default setting. */
108
+ function settingsOf(files, root) {
109
+ const file = join(root, CONFIG_FILE);
110
+ const bytes = files.readBytes(callerPath(file));
111
+ if (bytes === null)
112
+ return { ok: true, opts: {} };
113
+ const parsed = jsonOf(new TextDecoder().decode(bytes));
114
+ if (parsed === undefined)
115
+ return { ok: false, why: `${file} is not JSON` };
116
+ return {
117
+ ok: true,
118
+ opts: isObject(parsed)
119
+ ? { [PAPERS_DIR_FIELD]: parsed[PAPERS_DIR_FIELD] }
120
+ : {},
121
+ };
122
+ }
123
+ const isObject = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
124
+ /** The JSON `text` holds, or undefined when it is not JSON. */
125
+ function jsonOf(text) {
126
+ try {
127
+ return JSON.parse(text);
128
+ }
129
+ catch {
130
+ return undefined;
131
+ }
132
+ }
133
+ /** The one `papers.json` of `venue` among the project's papers roots, or why there is not exactly one. */
134
+ function recordOf(deps, venue) {
135
+ const root = deps.projectRoot(deps.cwd);
136
+ if (root === null)
137
+ return {
138
+ ok: false,
139
+ why: `${deps.cwd} is not inside a git repository: run it in the project`,
140
+ };
141
+ const settings = settingsOf(deps.files, root);
142
+ if (!settings.ok)
143
+ return settings;
144
+ const looked = papersRoots({ opts: settings.opts, root }).map((papers) => join(papers, "venues", venue, CORPUS_RECORD));
145
+ const found = looked.filter((f) => deps.files.isFile(callerPath(f)));
146
+ const [only] = found;
147
+ if (only !== undefined && found.length === 1)
148
+ return { ok: true, file: only };
149
+ return {
150
+ ok: false,
151
+ why: found.length === 0
152
+ ? `no ${CORPUS_RECORD} for venue "${venue}": looked in ${looked.map((f) => dirname(f)).join(", ")}; write the record first`
153
+ : `venue "${venue}" is in more than one papers folder: ${found.map((f) => dirname(f)).join(", ")}`,
154
+ };
155
+ }
156
+ /** Run the command on `argv`; the exit code. */
157
+ export function main(argv, deps, { out, err }) {
158
+ const [venue, ...rest] = argv;
159
+ if (venue === undefined || rest.length > 0 || !VENUE.test(venue)) {
160
+ err(USAGE);
161
+ return 2;
162
+ }
163
+ const at = recordOf(deps, venue);
164
+ if (!at.ok) {
165
+ err(`corpus-licences: ${at.why}\n`);
166
+ return 1;
167
+ }
168
+ const bytes = deps.files.readBytes(callerPath(at.file));
169
+ if (bytes === null) {
170
+ err(`corpus-licences: ${at.file} could not be read\n`);
171
+ return 1;
172
+ }
173
+ const parsed = deps.codec.parse(new TextDecoder().decode(bytes));
174
+ if (!parsed.ok) {
175
+ err(`corpus-licences: ${parsed.why}\n`);
176
+ return 1;
177
+ }
178
+ out(listing(verdicts(parsed.corpus, UNDECLARED)));
179
+ return 0;
180
+ }