paperlint 20.1.2 → 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.
- package/.claude-plugin/plugin.json +1 -1
- package/CLAUDE.md +5 -1
- package/dist/adapters/venue-corpus/index.d.ts +345 -0
- package/dist/adapters/venue-corpus/index.d.ts.map +1 -0
- package/dist/adapters/venue-corpus/index.js +205 -0
- package/dist/adapters/venue-corpus/index.js.map +1 -0
- package/dist/domain/licence.d.ts +51 -0
- package/dist/domain/licence.d.ts.map +1 -0
- package/dist/domain/licence.js +61 -0
- package/dist/domain/licence.js.map +1 -0
- package/dist/domain/venue-corpus.d.ts +120 -0
- package/dist/domain/venue-corpus.d.ts.map +1 -0
- package/dist/domain/venue-corpus.js +13 -0
- package/dist/domain/venue-corpus.js.map +1 -0
- package/dist/eslint-rules/CLAUDE.md.spec.d.ts.map +1 -1
- package/dist/eslint-rules/CLAUDE.md.spec.js +1 -0
- package/dist/eslint-rules/CLAUDE.md.spec.js.map +1 -1
- package/dist/ports/venue-corpus-codec.d.ts +11 -0
- package/dist/ports/venue-corpus-codec.d.ts.map +1 -0
- package/dist/ports/venue-corpus-codec.js +2 -0
- package/dist/ports/venue-corpus-codec.js.map +1 -0
- package/dist/skill-chunks/chunk-5KCU4WTN.js +108 -0
- package/dist/skill-chunks/{chunk-X4VKG4KT.js → chunk-6YEM4VDI.js} +11 -9
- package/dist/skill-chunks/{chunk-L3NJUJUP.js → chunk-CXAGKT44.js} +5 -3
- package/dist/skill-chunks/{chunk-6NU6CXUS.js → chunk-J5XYPERO.js} +12 -72
- package/dist/skill-chunks/{chunk-IREAROCV.js → chunk-Z5YMDZYW.js} +4 -0
- package/dist/skills/study-accepted-papers/scripts/corpus-licences-core.d.ts +54 -0
- package/dist/skills/study-accepted-papers/scripts/corpus-licences.d.ts +2 -0
- package/docs/design/venue-corpus.md +250 -0
- package/docs/venues.md +144 -21
- package/eslint-rules/CLAUDE.md +5 -1
- package/eslint-rules/CLAUDE.md.spec.ts +3 -0
- package/package.json +2 -1
- package/scripts/bundle-skills.ts +1 -0
- package/scripts/venue-corpus-schema.test.ts +39 -0
- package/scripts/venue-corpus-schema.ts +17 -0
- package/skills/argument-arc/scripts/headings.js +6 -4
- package/skills/cold-read-diff/scripts/cold-read.js +6 -4
- package/skills/paper-pipeline/scripts/extract-ref-facts.js +6 -5
- package/skills/pc-panel-review/scripts/prior-reviews.js +7 -5
- package/skills/study-accepted-papers/SKILL.md +28 -2
- package/skills/study-accepted-papers/SKILL.md.spec.ts +27 -1
- package/skills/study-accepted-papers/papers.schema.json +427 -0
- package/skills/study-accepted-papers/scripts/corpus-licences-core.js +180 -0
- package/skills/study-accepted-papers/scripts/corpus-licences-core.ts +302 -0
- package/skills/study-accepted-papers/scripts/corpus-licences.js +383 -0
- package/skills/study-accepted-papers/scripts/corpus-licences.test.ts +485 -0
- package/skills/study-accepted-papers/scripts/corpus-licences.ts +27 -0
- package/skills/verify-citations/scripts/bib-authors.js +6 -5
- package/skills/verify-citations/scripts/verify-cites.js +6 -5
- package/src/adapters/venue-corpus/index.test.ts +279 -0
- package/src/adapters/venue-corpus/index.ts +286 -0
- package/src/domain/licence.test.ts +122 -0
- package/src/domain/licence.ts +95 -0
- package/src/domain/venue-corpus.ts +130 -0
- package/src/ports/venue-corpus-codec.ts +11 -0
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The schema of a venue corpus's `papers.json` (docs/design/venue-corpus.md, decision 1): a record
|
|
3
|
+
* parses to itself with a paper row's extra fields kept, and every way a file can fail to be one is
|
|
4
|
+
* refused with the zod path of each problem.
|
|
5
|
+
*/
|
|
6
|
+
import { readFileSync } from "node:fs";
|
|
7
|
+
import { dirname, join } from "node:path";
|
|
8
|
+
import { fileURLToPath } from "node:url";
|
|
9
|
+
import { describe, expect, it } from "vitest";
|
|
10
|
+
import { z } from "zod";
|
|
11
|
+
import type { Paper, VenueCorpus } from "../../domain/venue-corpus.ts";
|
|
12
|
+
import {
|
|
13
|
+
SCHEMA_FILE,
|
|
14
|
+
venueCorpusCodec,
|
|
15
|
+
venueCorpusJsonSchema,
|
|
16
|
+
venueCorpusSchemaText,
|
|
17
|
+
} from "./index.ts";
|
|
18
|
+
|
|
19
|
+
const parse = venueCorpusCodec.parse;
|
|
20
|
+
|
|
21
|
+
const LICENCE = {
|
|
22
|
+
id: "CC-BY-4.0",
|
|
23
|
+
read_from: "https://api.crossref.org/works/10.1145/3786167.3788430",
|
|
24
|
+
read_on: "2026-11-03",
|
|
25
|
+
} as const;
|
|
26
|
+
|
|
27
|
+
const COPY = {
|
|
28
|
+
version: "published",
|
|
29
|
+
url: "https://doi.org/10.1145/3786167.3788430",
|
|
30
|
+
licence: LICENCE,
|
|
31
|
+
fetched_from: "https://dl.acm.org/doi/pdf/10.1145/3786167.3788430",
|
|
32
|
+
stored: ["text", "pdf"],
|
|
33
|
+
} as const;
|
|
34
|
+
|
|
35
|
+
const PAPER = {
|
|
36
|
+
key: "2026-01",
|
|
37
|
+
edition: 2026,
|
|
38
|
+
group: "accepted",
|
|
39
|
+
title: "A Catalogue of Evaluation Metrics",
|
|
40
|
+
authors: ["Ingrid Lima", "Paulo Maia"],
|
|
41
|
+
abstract: "LLM-based Multi-Agent frameworks …",
|
|
42
|
+
ids: { doi: "10.1145/3786167.3788430" },
|
|
43
|
+
copies: [COPY],
|
|
44
|
+
} as const;
|
|
45
|
+
|
|
46
|
+
const EDITION = {
|
|
47
|
+
edition: 2026,
|
|
48
|
+
listed_from: "https://conf.researchr.org/home/icse-2026/agent-2026",
|
|
49
|
+
read_on: "2026-11-03",
|
|
50
|
+
accepted: 27,
|
|
51
|
+
} as const;
|
|
52
|
+
|
|
53
|
+
const RECORD = { venue: "agent", editions: [EDITION], papers: [PAPER] };
|
|
54
|
+
|
|
55
|
+
const text = (v: unknown): string => JSON.stringify(v);
|
|
56
|
+
/** The record with its one paper replaced by `paper`. */
|
|
57
|
+
const withPaper = (paper: Readonly<Record<string, unknown>>): string =>
|
|
58
|
+
text({ ...RECORD, papers: [paper] });
|
|
59
|
+
/** The record with its one paper's one copy replaced by `copy`. */
|
|
60
|
+
const withCopy = (copy: Readonly<Record<string, unknown>>): string =>
|
|
61
|
+
withPaper({ ...PAPER, copies: [copy] });
|
|
62
|
+
|
|
63
|
+
describe("parsing a papers.json", () => {
|
|
64
|
+
it("🔴 the design note's record parses to itself", () => {
|
|
65
|
+
// Guards: a valid record comes back whole, nothing dropped or added.
|
|
66
|
+
expect(parse(text(RECORD))).toEqual({ ok: true, corpus: RECORD });
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it("🔴 a paper row's extra fields are kept, whatever they hold", () => {
|
|
70
|
+
const row = { ...PAPER, award: "distinguished", pages: 8, found_at: null };
|
|
71
|
+
// Guards: a row is loose — the consumer's own fields survive the parse.
|
|
72
|
+
expect(parse(withPaper(row))).toEqual({
|
|
73
|
+
ok: true,
|
|
74
|
+
corpus: { ...RECORD, papers: [row] },
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it("🔴 an abstract a listing left null parses as null", () => {
|
|
79
|
+
const row = { ...PAPER, abstract: null };
|
|
80
|
+
// Guards: scraped listings leave the abstract null (8 of 16 rows of one real corpus); null is not refused.
|
|
81
|
+
expect(parse(withPaper(row))).toEqual({
|
|
82
|
+
ok: true,
|
|
83
|
+
corpus: { ...RECORD, papers: [row] },
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it("a sister paper names its venue, year and where it was found; an unknown copy stores under NOASSERTION", () => {
|
|
88
|
+
const { edition, ...rest } = PAPER;
|
|
89
|
+
const sister: Paper = {
|
|
90
|
+
...rest,
|
|
91
|
+
group: "sister",
|
|
92
|
+
venue: "nlbse",
|
|
93
|
+
year: 2025,
|
|
94
|
+
listed_from: "https://nlbse.github.io/2025/",
|
|
95
|
+
ids: { url: "https://nlbse.github.io/2025/papers/7" },
|
|
96
|
+
copies: [
|
|
97
|
+
{
|
|
98
|
+
version: "unknown",
|
|
99
|
+
licence: { id: "NOASSERTION" },
|
|
100
|
+
fetched_from: "https://example.org/7.pdf",
|
|
101
|
+
stored: ["pdf"],
|
|
102
|
+
},
|
|
103
|
+
],
|
|
104
|
+
};
|
|
105
|
+
const record: VenueCorpus = { ...RECORD, papers: [sister] };
|
|
106
|
+
// Guards: the sister shape and the unknown-origin copy are both representable.
|
|
107
|
+
expect([edition, parse(text(record))]).toEqual([
|
|
108
|
+
2026,
|
|
109
|
+
{ ok: true, corpus: record },
|
|
110
|
+
]);
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
it("an unlisted licence id parses: the table, not the parser, judges it", () => {
|
|
114
|
+
const copy = { ...COPY, licence: { ...LICENCE, id: "CC-BY-3.0" } };
|
|
115
|
+
// Guards: one unlisted id does not make the whole record unreadable.
|
|
116
|
+
expect(parse(withCopy(copy))).toEqual({
|
|
117
|
+
ok: true,
|
|
118
|
+
corpus: { ...RECORD, papers: [{ ...PAPER, copies: [copy] }] },
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
describe("a copy whose licence was never read", () => {
|
|
124
|
+
it("🔴 a known copy under NOASSERTION, storing nothing, parses: the record is not the licence check", () => {
|
|
125
|
+
const copy = {
|
|
126
|
+
version: "preprint",
|
|
127
|
+
url: "https://arxiv.org/abs/2601.00001",
|
|
128
|
+
licence: { id: "NOASSERTION" },
|
|
129
|
+
stored: [],
|
|
130
|
+
};
|
|
131
|
+
// Guards: a corpus migrated before its licences were read still validates.
|
|
132
|
+
expect(parse(withCopy(copy))).toEqual({
|
|
133
|
+
ok: true,
|
|
134
|
+
corpus: { ...RECORD, papers: [{ ...PAPER, copies: [copy] }] },
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
/** A file that is no record, and the reasons it is refused with. */
|
|
140
|
+
const REFUSED: readonly (readonly [string, string, string])[] = [
|
|
141
|
+
[
|
|
142
|
+
"🔴 a misspelt key in a copy",
|
|
143
|
+
withCopy({ ...COPY, licence: undefined, lisence: LICENCE }),
|
|
144
|
+
'papers.0.copies.0.licence: Invalid input: expected object, received undefined; papers.0.copies.0: Unrecognized key: "lisence"',
|
|
145
|
+
],
|
|
146
|
+
[
|
|
147
|
+
"🔴 a copy without its licence object",
|
|
148
|
+
withCopy({ ...COPY, licence: undefined }),
|
|
149
|
+
"papers.0.copies.0.licence: Invalid input: expected object, received undefined",
|
|
150
|
+
],
|
|
151
|
+
[
|
|
152
|
+
"🔴 a key two papers share",
|
|
153
|
+
text({ ...RECORD, papers: [PAPER, { ...PAPER, title: "Other" }] }),
|
|
154
|
+
'papers.1.key: "2026-01" is the key of papers.0 too',
|
|
155
|
+
],
|
|
156
|
+
[
|
|
157
|
+
"a misspelt key at the top level",
|
|
158
|
+
text({ ...RECORD, edtions: [] }),
|
|
159
|
+
'(top): Unrecognized key: "edtions"',
|
|
160
|
+
],
|
|
161
|
+
[
|
|
162
|
+
"a misspelt key in a licence",
|
|
163
|
+
withCopy({ ...COPY, licence: { ...LICENCE, read_form: "x" } }),
|
|
164
|
+
'papers.0.copies.0.licence: Unrecognized key: "read_form"',
|
|
165
|
+
],
|
|
166
|
+
[
|
|
167
|
+
"a licence read from nowhere",
|
|
168
|
+
withCopy({ ...COPY, licence: { id: "CC-BY-4.0" } }),
|
|
169
|
+
"papers.0.copies.0.licence.read_from: a licence other than NOASSERTION names where it was read; papers.0.copies.0.licence.read_on: a licence other than NOASSERTION names when it was read",
|
|
170
|
+
],
|
|
171
|
+
[
|
|
172
|
+
"NOASSERTION with a source: a licence read is not NOASSERTION",
|
|
173
|
+
withCopy({ ...COPY, licence: { ...LICENCE, id: "NOASSERTION" } }),
|
|
174
|
+
"papers.0.copies.0.licence.read_from: NOASSERTION means the licence was not read; papers.0.copies.0.licence.read_on: NOASSERTION means the licence was not read",
|
|
175
|
+
],
|
|
176
|
+
[
|
|
177
|
+
"a licence id that is no SPDX id",
|
|
178
|
+
withCopy({ ...COPY, licence: { ...LICENCE, id: "CC BY 4.0" } }),
|
|
179
|
+
"papers.0.copies.0.licence.id: an SPDX license id or a LicenseRef-",
|
|
180
|
+
],
|
|
181
|
+
[
|
|
182
|
+
"a copy of unknown origin under a licence",
|
|
183
|
+
withCopy({ ...COPY, version: "unknown" }),
|
|
184
|
+
'papers.0.copies.0.licence.id: Invalid input: expected "NOASSERTION"; papers.0.copies.0.licence: Unrecognized keys: "read_from", "read_on"; papers.0.copies.0: Unrecognized key: "url"',
|
|
185
|
+
],
|
|
186
|
+
[
|
|
187
|
+
"a stored copy that does not say where its bytes came from",
|
|
188
|
+
withCopy({ ...COPY, fetched_from: undefined }),
|
|
189
|
+
"papers.0.copies.0.fetched_from: a copy that stores a file names where it was fetched from",
|
|
190
|
+
],
|
|
191
|
+
[
|
|
192
|
+
"a copy fetched from somewhere that is not a web address",
|
|
193
|
+
withCopy({ ...COPY, fetched_from: "file:///home/me/x.pdf" }),
|
|
194
|
+
"papers.0.copies.0.fetched_from: an http or https address",
|
|
195
|
+
],
|
|
196
|
+
[
|
|
197
|
+
"a kind stored twice by one copy",
|
|
198
|
+
withCopy({ ...COPY, stored: ["pdf", "pdf"] }),
|
|
199
|
+
'papers.0.copies.0.stored: "pdf" is listed twice',
|
|
200
|
+
],
|
|
201
|
+
[
|
|
202
|
+
"a paper of an edition the record does not list",
|
|
203
|
+
withPaper({ ...PAPER, edition: 2025 }),
|
|
204
|
+
"papers.0.edition: 2025 is not one of editions[].edition (2026)",
|
|
205
|
+
],
|
|
206
|
+
[
|
|
207
|
+
"an edition listed twice",
|
|
208
|
+
text({ ...RECORD, editions: [EDITION, EDITION] }),
|
|
209
|
+
"editions.1.edition: 2026 is listed twice",
|
|
210
|
+
],
|
|
211
|
+
[
|
|
212
|
+
"a paper with no id",
|
|
213
|
+
withPaper({ ...PAPER, ids: {} }),
|
|
214
|
+
"papers.0.ids: at least one of doi, arxiv, dblp, s2, url",
|
|
215
|
+
],
|
|
216
|
+
[
|
|
217
|
+
"a misspelt id",
|
|
218
|
+
withPaper({ ...PAPER, ids: { dio: "10.1/x" } }),
|
|
219
|
+
'papers.0.ids: Unrecognized key: "dio"; papers.0.ids: at least one of doi, arxiv, dblp, s2, url',
|
|
220
|
+
],
|
|
221
|
+
[
|
|
222
|
+
"a key that cannot name a file",
|
|
223
|
+
withPaper({ ...PAPER, key: "../x" }),
|
|
224
|
+
"papers.0.key: a letter or digit, then letters, digits, '_' or '-'",
|
|
225
|
+
],
|
|
226
|
+
[
|
|
227
|
+
// Guards: text/<key>.<variant>.txt splits at the first dot, so a dotted key would read as a variant.
|
|
228
|
+
"a key with a dot",
|
|
229
|
+
withPaper({ ...PAPER, key: "2501.15919" }),
|
|
230
|
+
"papers.0.key: a letter or digit, then letters, digits, '_' or '-'",
|
|
231
|
+
],
|
|
232
|
+
];
|
|
233
|
+
|
|
234
|
+
describe("refusing what is not a papers.json", () => {
|
|
235
|
+
it("text that is not JSON", () => {
|
|
236
|
+
// Guards: a broken file is named as such, not parsed as an empty record.
|
|
237
|
+
expect(parse("{ venue: agent")).toEqual({
|
|
238
|
+
ok: false,
|
|
239
|
+
why: "papers.json is not JSON",
|
|
240
|
+
});
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
it.each(REFUSED)("%s", (_name, file, why) => {
|
|
244
|
+
// Guards: the record is refused, and the reason names the path of every problem.
|
|
245
|
+
expect(parse(file)).toEqual({ ok: false, why: `papers.json: ${why}` });
|
|
246
|
+
});
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
describe("venueCorpusJsonSchema — the shipped schema file", () => {
|
|
250
|
+
const SHIPPED = join(
|
|
251
|
+
dirname(fileURLToPath(import.meta.url)),
|
|
252
|
+
"../../../",
|
|
253
|
+
SCHEMA_FILE,
|
|
254
|
+
);
|
|
255
|
+
|
|
256
|
+
it("🔴 is the generated schema, byte for byte", () => {
|
|
257
|
+
// Guards: the schema the skill points at never drifts from the parser that judges the record.
|
|
258
|
+
expect(
|
|
259
|
+
readFileSync(SHIPPED, "utf8"),
|
|
260
|
+
`${SCHEMA_FILE} is stale: regenerate it with \`npm run schema:venue-corpus\``,
|
|
261
|
+
).toBe(venueCorpusSchemaText());
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
it("🔴 says the parser checks what a schema cannot, and names the record's fields", () => {
|
|
265
|
+
const schema = z
|
|
266
|
+
.looseObject({
|
|
267
|
+
description: z.string(),
|
|
268
|
+
properties: z.looseObject({}),
|
|
269
|
+
})
|
|
270
|
+
.parse(venueCorpusJsonSchema());
|
|
271
|
+
expect(schema.description).toContain("papers.json");
|
|
272
|
+
expect(schema.description).toContain("corpus-licences.js");
|
|
273
|
+
expect(Object.keys(schema.properties)).toEqual([
|
|
274
|
+
"venue",
|
|
275
|
+
"editions",
|
|
276
|
+
"papers",
|
|
277
|
+
]);
|
|
278
|
+
});
|
|
279
|
+
});
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The schema of a venue corpus's `papers.json` — the one place its shape is checked
|
|
3
|
+
* (docs/design/venue-corpus.md, decision 1). The text is parsed once, here, into the domain's
|
|
4
|
+
* `VenueCorpus`; whatever reads a record after it never re-validates. The study registry's pattern
|
|
5
|
+
* (`src/adapters/study-registry/`).
|
|
6
|
+
*
|
|
7
|
+
* The top level, an edition, a copy, a licence and a paper's ids are strict, so a misspelt key is an
|
|
8
|
+
* error. A paper row is loose: a consumer's scripts read their own fields from it. A licence id is
|
|
9
|
+
* checked for its shape only: whether the id permits anything is `src/domain/licence.ts`'s table, so
|
|
10
|
+
* one unlisted id does not make the record unreadable.
|
|
11
|
+
*/
|
|
12
|
+
import { z } from "zod";
|
|
13
|
+
import {
|
|
14
|
+
isLicenceId,
|
|
15
|
+
NOASSERTION,
|
|
16
|
+
STORED_KINDS,
|
|
17
|
+
} from "../../domain/licence.ts";
|
|
18
|
+
import {
|
|
19
|
+
CORPUS_RECORD,
|
|
20
|
+
KEY_PATTERN,
|
|
21
|
+
KNOWN_VERSIONS,
|
|
22
|
+
PAPER_ID_KINDS,
|
|
23
|
+
type Copy,
|
|
24
|
+
type Edition,
|
|
25
|
+
type Licence,
|
|
26
|
+
type ParsedCorpus,
|
|
27
|
+
type Paper,
|
|
28
|
+
type PaperIds,
|
|
29
|
+
type VenueCorpus,
|
|
30
|
+
} from "../../domain/venue-corpus.ts";
|
|
31
|
+
import type { VenueCorpusCodec } from "../../ports/venue-corpus-codec.ts";
|
|
32
|
+
|
|
33
|
+
const words = z.string().min(1);
|
|
34
|
+
const date = z.iso.date();
|
|
35
|
+
/** Where a page or a file was read: a web address, never a local path or another scheme. */
|
|
36
|
+
const webUrl = z.url({
|
|
37
|
+
protocol: /^https?$/u,
|
|
38
|
+
error: "an http or https address",
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
/** The index of each value that occurs earlier in `values`, with the index of its first. */
|
|
42
|
+
const repeats = (
|
|
43
|
+
values: readonly unknown[],
|
|
44
|
+
): readonly (readonly [number, number])[] =>
|
|
45
|
+
values.flatMap((v, i) => {
|
|
46
|
+
const first = values.indexOf(v);
|
|
47
|
+
return first === i ? [] : [[i, first] as const];
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
const licenceId = z
|
|
51
|
+
.string()
|
|
52
|
+
.refine(isLicenceId, "an SPDX license id or a LicenseRef-");
|
|
53
|
+
|
|
54
|
+
const notRead = z.strictObject({ id: z.literal(NOASSERTION) });
|
|
55
|
+
|
|
56
|
+
/** A licence: NOASSERTION alone, or any other id with where and when it was read. */
|
|
57
|
+
const licence = z
|
|
58
|
+
.strictObject({
|
|
59
|
+
id: licenceId,
|
|
60
|
+
read_from: webUrl.optional(),
|
|
61
|
+
read_on: date.optional(),
|
|
62
|
+
})
|
|
63
|
+
.transform((l, ctx): Licence => {
|
|
64
|
+
const fields = ["read_from", "read_on"] as const;
|
|
65
|
+
const noneRead = l.id === NOASSERTION;
|
|
66
|
+
const wrong = fields.filter((f) => (l[f] === undefined) !== noneRead);
|
|
67
|
+
wrong.forEach((f) => {
|
|
68
|
+
ctx.addIssue({
|
|
69
|
+
code: "custom",
|
|
70
|
+
path: [f],
|
|
71
|
+
message: noneRead
|
|
72
|
+
? "NOASSERTION means the licence was not read"
|
|
73
|
+
: `a licence other than NOASSERTION names ${f === "read_from" ? "where" : "when"} it was read`,
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
return l.read_from === undefined || l.read_on === undefined
|
|
77
|
+
? { id: NOASSERTION }
|
|
78
|
+
: { id: l.id, read_from: l.read_from, read_on: l.read_on };
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
const storage = {
|
|
82
|
+
stored: z.array(z.enum(STORED_KINDS)),
|
|
83
|
+
fetched_from: webUrl.optional(),
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
/** Each kind at most once, and a stored copy names where its bytes came from. */
|
|
87
|
+
const stores = (
|
|
88
|
+
c: Readonly<{ stored: readonly string[]; fetched_from?: string | undefined }>,
|
|
89
|
+
ctx: Readonly<z.core.$RefinementCtx>,
|
|
90
|
+
): void => {
|
|
91
|
+
repeats(c.stored).forEach(([i]) => {
|
|
92
|
+
ctx.addIssue({
|
|
93
|
+
code: "custom",
|
|
94
|
+
path: ["stored"],
|
|
95
|
+
message: `"${String(c.stored[i])}" is listed twice`,
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
if (c.stored.length > 0 && c.fetched_from === undefined)
|
|
99
|
+
ctx.addIssue({
|
|
100
|
+
code: "custom",
|
|
101
|
+
path: ["fetched_from"],
|
|
102
|
+
message: "a copy that stores a file names where it was fetched from",
|
|
103
|
+
});
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
const copy = z.discriminatedUnion("version", [
|
|
107
|
+
z
|
|
108
|
+
.strictObject({
|
|
109
|
+
version: z.enum(KNOWN_VERSIONS),
|
|
110
|
+
url: webUrl,
|
|
111
|
+
licence,
|
|
112
|
+
...storage,
|
|
113
|
+
})
|
|
114
|
+
.superRefine(stores),
|
|
115
|
+
z
|
|
116
|
+
.strictObject({
|
|
117
|
+
version: z.literal("unknown"),
|
|
118
|
+
licence: notRead,
|
|
119
|
+
...storage,
|
|
120
|
+
})
|
|
121
|
+
.superRefine(stores),
|
|
122
|
+
]);
|
|
123
|
+
|
|
124
|
+
const ids = z
|
|
125
|
+
.strictObject({
|
|
126
|
+
doi: words.optional(),
|
|
127
|
+
arxiv: words.optional(),
|
|
128
|
+
dblp: words.optional(),
|
|
129
|
+
s2: words.optional(),
|
|
130
|
+
url: webUrl.optional(),
|
|
131
|
+
})
|
|
132
|
+
.refine(
|
|
133
|
+
(i) => Object.values(i).some((v) => v !== undefined),
|
|
134
|
+
`at least one of ${PAPER_ID_KINDS.join(", ")}`,
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
const paperFields = {
|
|
138
|
+
key: z
|
|
139
|
+
.string()
|
|
140
|
+
.regex(KEY_PATTERN, "a letter or digit, then letters, digits, '_' or '-'"),
|
|
141
|
+
title: words,
|
|
142
|
+
authors: z.array(words).optional(),
|
|
143
|
+
abstract: z.string().nullable().optional(),
|
|
144
|
+
ids,
|
|
145
|
+
copies: z.array(copy),
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
const year = z.number().int().positive();
|
|
149
|
+
|
|
150
|
+
const paper = z.discriminatedUnion("group", [
|
|
151
|
+
z.looseObject({
|
|
152
|
+
...paperFields,
|
|
153
|
+
group: z.enum(["accepted", "award"]),
|
|
154
|
+
edition: year,
|
|
155
|
+
}),
|
|
156
|
+
z.looseObject({
|
|
157
|
+
...paperFields,
|
|
158
|
+
group: z.literal("sister"),
|
|
159
|
+
venue: words,
|
|
160
|
+
year,
|
|
161
|
+
listed_from: webUrl,
|
|
162
|
+
}),
|
|
163
|
+
]);
|
|
164
|
+
|
|
165
|
+
const edition = z.strictObject({
|
|
166
|
+
edition: year,
|
|
167
|
+
listed_from: webUrl,
|
|
168
|
+
read_on: date,
|
|
169
|
+
accepted: z.number().int().nonnegative().optional(),
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
/** Keys unique, editions unique, and every paper of this venue of a listed edition. */
|
|
173
|
+
const consistent = (
|
|
174
|
+
r: Readonly<{ editions: readonly Edition[]; papers: readonly Paper[] }>,
|
|
175
|
+
ctx: Readonly<z.core.$RefinementCtx>,
|
|
176
|
+
): void => {
|
|
177
|
+
const years = r.editions.map((e) => e.edition);
|
|
178
|
+
repeats(years).forEach(([i]) => {
|
|
179
|
+
ctx.addIssue({
|
|
180
|
+
code: "custom",
|
|
181
|
+
path: ["editions", i, "edition"],
|
|
182
|
+
message: `${String(years[i])} is listed twice`,
|
|
183
|
+
});
|
|
184
|
+
});
|
|
185
|
+
const keys = r.papers.map((p) => p.key);
|
|
186
|
+
repeats(keys).forEach(([i, first]) => {
|
|
187
|
+
ctx.addIssue({
|
|
188
|
+
code: "custom",
|
|
189
|
+
path: ["papers", i, "key"],
|
|
190
|
+
message: `"${String(keys[i])}" is the key of papers.${String(first)} too`,
|
|
191
|
+
});
|
|
192
|
+
});
|
|
193
|
+
r.papers.forEach((p, i) => {
|
|
194
|
+
if (p.group !== "sister" && !years.includes(p.edition))
|
|
195
|
+
ctx.addIssue({
|
|
196
|
+
code: "custom",
|
|
197
|
+
path: ["papers", i, "edition"],
|
|
198
|
+
message: `${String(p.edition)} is not one of editions[].edition (${years.join(", ")})`,
|
|
199
|
+
});
|
|
200
|
+
});
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
const record = z
|
|
204
|
+
.strictObject({
|
|
205
|
+
venue: words,
|
|
206
|
+
editions: z.array(edition),
|
|
207
|
+
papers: z.array(paper),
|
|
208
|
+
})
|
|
209
|
+
.superRefine(consistent);
|
|
210
|
+
|
|
211
|
+
// ── the schemas ARE the domain's types (as in the study registry's adapter) ──────────────────
|
|
212
|
+
|
|
213
|
+
/** `T`, readonly all the way down: zod's outputs are mutable, the domain's are not. */
|
|
214
|
+
type Frozen<T> = T extends readonly (infer U)[]
|
|
215
|
+
? readonly Frozen<U>[]
|
|
216
|
+
: T extends object
|
|
217
|
+
? { readonly [K in keyof T]: Frozen<T[K]> }
|
|
218
|
+
: T;
|
|
219
|
+
|
|
220
|
+
/** True when `A` and `B`, both made readonly all the way down, are one type. */
|
|
221
|
+
type Same<A, B> =
|
|
222
|
+
(<T>() => T extends Frozen<A> ? readonly [T] : 2) extends <
|
|
223
|
+
T,
|
|
224
|
+
>() => T extends Frozen<B> ? readonly [T] : 2
|
|
225
|
+
? true
|
|
226
|
+
: false;
|
|
227
|
+
|
|
228
|
+
/** Compiles only when every schema's output is its domain type. */
|
|
229
|
+
export type SchemasAreTheDomain = [
|
|
230
|
+
Same<z.output<typeof record>, VenueCorpus>,
|
|
231
|
+
Same<z.output<typeof edition>, Edition>,
|
|
232
|
+
Same<z.output<typeof paper>, Paper>,
|
|
233
|
+
Same<z.output<typeof copy>, Copy>,
|
|
234
|
+
Same<z.output<typeof licence>, Licence>,
|
|
235
|
+
Same<z.output<typeof ids>, PaperIds>,
|
|
236
|
+
] extends true[]
|
|
237
|
+
? true
|
|
238
|
+
: never;
|
|
239
|
+
|
|
240
|
+
/** The proof is used, so the build checks it. */
|
|
241
|
+
export const SCHEMAS_ARE_THE_DOMAIN: SchemasAreTheDomain = true;
|
|
242
|
+
|
|
243
|
+
/** The JSON `text` holds, or undefined when it is not JSON. */
|
|
244
|
+
function jsonOf(text: string): unknown {
|
|
245
|
+
try {
|
|
246
|
+
return JSON.parse(text);
|
|
247
|
+
} catch {
|
|
248
|
+
return undefined;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/** A `papers.json`'s text, parsed once at the boundary: the record, or every reason it is not one. */
|
|
253
|
+
export function parseVenueCorpus(text: string): ParsedCorpus {
|
|
254
|
+
const json = jsonOf(text);
|
|
255
|
+
if (json === undefined)
|
|
256
|
+
return { ok: false, why: `${CORPUS_RECORD} is not JSON` };
|
|
257
|
+
const parsed = record.safeParse(json);
|
|
258
|
+
if (parsed.success) return { ok: true, corpus: parsed.data };
|
|
259
|
+
const reasons = parsed.error.issues.map(
|
|
260
|
+
(i) => `${i.path.length === 0 ? "(top)" : i.path.join(".")}: ${i.message}`,
|
|
261
|
+
);
|
|
262
|
+
return { ok: false, why: `${CORPUS_RECORD}: ${reasons.join("; ")}` };
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
export const venueCorpusCodec: VenueCorpusCodec = { parse: parseVenueCorpus };
|
|
266
|
+
|
|
267
|
+
/** Where the shipped JSON Schema of the record sits, below the package root: in the skill that writes it. */
|
|
268
|
+
export const SCHEMA_FILE = "skills/study-accepted-papers/papers.schema.json";
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* The JSON Schema of a `papers.json`, generated from the parser's own shape: the fields a skill (or
|
|
272
|
+
* an editor) reads instead of a hand-written table. Shipped as `SCHEMA_FILE`; a test holds the file
|
|
273
|
+
* to this. A schema cannot say that a key is unique, that a paper's edition is a listed one, or that
|
|
274
|
+
* a stored copy names where it was fetched from: `corpus-licences.js` checks those and names the
|
|
275
|
+
* field's path.
|
|
276
|
+
*/
|
|
277
|
+
export const venueCorpusJsonSchema = (): unknown => ({
|
|
278
|
+
...z.toJSONSchema(record, { io: "input", unrepresentable: "any" }),
|
|
279
|
+
title: "A venue corpus's papers.json",
|
|
280
|
+
description:
|
|
281
|
+
"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.",
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
/** The shipped file's text: the schema, indented, with a closing newline. */
|
|
285
|
+
export const venueCorpusSchemaText = (): string =>
|
|
286
|
+
`${JSON.stringify(venueCorpusJsonSchema(), null, 2)}\n`;
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The licence table (docs/design/venue-corpus.md, decision 3): what a copy's licence permits the
|
|
3
|
+
* corpus to store, for each kind, with and without the project's non-commercial setting.
|
|
4
|
+
*/
|
|
5
|
+
import { describe, expect, it } from "vitest";
|
|
6
|
+
import {
|
|
7
|
+
isLicenceId,
|
|
8
|
+
permits,
|
|
9
|
+
type LicenceSettings,
|
|
10
|
+
type StoredKind,
|
|
11
|
+
} from "./licence.ts";
|
|
12
|
+
|
|
13
|
+
const COMMERCIAL: LicenceSettings = { nonCommercial: false };
|
|
14
|
+
const NON_COMMERCIAL: LicenceSettings = { nonCommercial: true };
|
|
15
|
+
|
|
16
|
+
/** What `id` permits for text and for the PDF, under `settings`. */
|
|
17
|
+
const both = (id: string, settings = COMMERCIAL) =>
|
|
18
|
+
Object.fromEntries(
|
|
19
|
+
(["text", "pdf"] as const satisfies readonly StoredKind[]).map((k) => [
|
|
20
|
+
k,
|
|
21
|
+
permits(id, k, settings),
|
|
22
|
+
]),
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
const PERMITTED = { kind: "permitted" } as const;
|
|
26
|
+
const NC_ONLY = { kind: "non-commercial-only" } as const;
|
|
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"';
|
|
29
|
+
const ND_WHY =
|
|
30
|
+
"ND permits reproduction in unmodified form; whether an extracted text is an adaptation is unsettled";
|
|
31
|
+
|
|
32
|
+
describe("permits — what a copy's licence lets the corpus store", () => {
|
|
33
|
+
it.each(["CC0-1.0", "CC-BY-4.0", "CC-BY-SA-4.0"])(
|
|
34
|
+
"%s permits text and the PDF, whatever the setting",
|
|
35
|
+
(id) => {
|
|
36
|
+
// Guards: the open licences permit both kinds, commercial or not.
|
|
37
|
+
expect([both(id), both(id, NON_COMMERCIAL)]).toEqual([
|
|
38
|
+
{ text: PERMITTED, pdf: PERMITTED },
|
|
39
|
+
{ text: PERMITTED, pdf: PERMITTED },
|
|
40
|
+
]);
|
|
41
|
+
},
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
it("🔴 CC-BY-NC-4.0 permits both only when the project is declared non-commercial", () => {
|
|
45
|
+
// Guards: NC is never assumed; the setting turns it on.
|
|
46
|
+
expect([
|
|
47
|
+
both("CC-BY-NC-4.0"),
|
|
48
|
+
both("CC-BY-NC-4.0", NON_COMMERCIAL),
|
|
49
|
+
]).toEqual([
|
|
50
|
+
{ text: NC_ONLY, pdf: NC_ONLY },
|
|
51
|
+
{ text: PERMITTED, pdf: PERMITTED },
|
|
52
|
+
]);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it("CC-BY-ND-4.0 permits the PDF and no extracted text; NC-ND adds the setting to the PDF", () => {
|
|
56
|
+
const noText = { kind: "forbidden", why: ND_WHY };
|
|
57
|
+
// Guards: ND never permits text, even under the setting; its PDF follows the NC rule.
|
|
58
|
+
expect([
|
|
59
|
+
both("CC-BY-ND-4.0"),
|
|
60
|
+
both("CC-BY-NC-ND-4.0"),
|
|
61
|
+
both("CC-BY-NC-ND-4.0", NON_COMMERCIAL),
|
|
62
|
+
]).toEqual([
|
|
63
|
+
{ text: noText, pdf: PERMITTED },
|
|
64
|
+
{ text: noText, pdf: NC_ONLY },
|
|
65
|
+
{ text: noText, pdf: PERMITTED },
|
|
66
|
+
]);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it("🔴 arXiv's non-exclusive licence permits nothing, even under the setting", () => {
|
|
70
|
+
const no = { kind: "forbidden", why: ARXIV_WHY };
|
|
71
|
+
// Guards: the arXiv default grants nothing to a third party.
|
|
72
|
+
expect(both("LicenseRef-arxiv-nonexclusive-1.0", NON_COMMERCIAL)).toEqual({
|
|
73
|
+
text: no,
|
|
74
|
+
pdf: no,
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it("NOASSERTION permits nothing, as its own result: the licence was not read", () => {
|
|
79
|
+
// Guards: an unread licence is not confused with a forbidding one.
|
|
80
|
+
expect(both("NOASSERTION", NON_COMMERCIAL)).toEqual({
|
|
81
|
+
text: { kind: "not-read" },
|
|
82
|
+
pdf: { kind: "not-read" },
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it.each(["CC-BY-3.0", "CC-BY-4.O", "LicenseRef-mine", "constructor"])(
|
|
87
|
+
"🔴 an id outside the table (%s) permits nothing and is named",
|
|
88
|
+
(id) => {
|
|
89
|
+
// Guards: an unlisted id is its own result naming the id, never a permission.
|
|
90
|
+
expect(both(id, NON_COMMERCIAL)).toEqual({
|
|
91
|
+
text: { kind: "unlisted", id },
|
|
92
|
+
pdf: { kind: "unlisted", id },
|
|
93
|
+
});
|
|
94
|
+
},
|
|
95
|
+
);
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
describe("isLicenceId — the shape of an SPDX id or a LicenseRef", () => {
|
|
99
|
+
it("any SPDX-shaped id or LicenseRef- parses, listed or not", () => {
|
|
100
|
+
const ids = [
|
|
101
|
+
"CC-BY-4.0",
|
|
102
|
+
"CC-BY-3.0",
|
|
103
|
+
"GPL-2.0+",
|
|
104
|
+
"NOASSERTION",
|
|
105
|
+
"LicenseRef-arxiv-nonexclusive-1.0",
|
|
106
|
+
];
|
|
107
|
+
// Guards: the parser accepts what the table may not list; the table judges it.
|
|
108
|
+
expect(ids.filter(isLicenceId)).toEqual(ids);
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it("text that is no id does not", () => {
|
|
112
|
+
const notIds = [
|
|
113
|
+
"",
|
|
114
|
+
"CC BY 4.0",
|
|
115
|
+
"MIT OR Apache-2.0",
|
|
116
|
+
"-x",
|
|
117
|
+
"https://x.org",
|
|
118
|
+
];
|
|
119
|
+
// Guards: a phrase, an expression or a URL is refused where it is read.
|
|
120
|
+
expect(notIds.filter(isLicenceId)).toEqual([]);
|
|
121
|
+
});
|
|
122
|
+
});
|