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.
- package/.claude-plugin/plugin.json +1 -1
- package/.github/workflows/ci.yml +7 -0
- package/CLAUDE.md +6 -2
- package/CONTRIBUTING.md +2 -2
- package/{action.harness.mjs → action.test.mjs} +147 -138
- 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/eslint-rules/papers.js +1 -1
- package/dist/latex-log.d.ts +1 -1
- package/dist/latex-log.js +1 -1
- package/dist/latex-loop.d.ts +1 -1
- package/dist/latex-loop.js +1 -1
- package/dist/lib/paper-config.d.ts +3 -3
- package/dist/lib/paper-config.js +3 -3
- 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/e2e.md +9 -9
- package/docs/testing.md +3 -4
- package/docs/venues.md +144 -21
- package/eslint-rules/CLAUDE.md +5 -1
- package/eslint-rules/CLAUDE.md.spec.ts +3 -0
- package/eslint-rules/{install-path-literals.harness.mjs → install-path-literals.test.mjs} +14 -13
- package/eslint-rules/{latex-language.harness.mjs → latex-language-rules.test.mjs} +61 -51
- package/eslint-rules/{paper-stages.harness.mjs → paper-stages-rule.test.mjs} +66 -69
- package/eslint-rules/{papers.harness.mjs → papers.test.mjs} +41 -30
- package/eslint-rules/papers.ts +1 -1
- package/eslint-rules/{pdf-last-page-balance.harness.mjs → pdf-last-page-balance.test.mjs} +27 -15
- package/eslint-rules/{temp-root-realpath.harness.mjs → temp-root-realpath.test.mjs} +24 -24
- package/eslint-rules/{tex-build.harness.mjs → tex-build.test.mjs} +292 -271
- package/eslint.config.mjs +15 -2
- package/fixtures/pdf-facts/README.md +1 -1
- package/fixtures/render-paper/build-clean.sh +1 -1
- package/fixtures/toolchain-mirror/install-tl +1 -1
- package/lib/{agent-cli-version.harness.mjs → agent-cli-version.test.mjs} +17 -18
- package/lib/{paper-config.harness.mjs → paper-config.test.mjs} +21 -20
- package/lib/paper-config.ts +3 -3
- package/lib/{skill-trigger-cases.harness.mjs → skill-trigger-cases-carrier.test.mjs} +78 -115
- package/package.json +4 -3
- package/presets/acm-acmsmall.jsonc +1 -1
- package/scripts/bundle-skills.ts +1 -0
- package/scripts/check-workflow.test.ts +368 -0
- package/scripts/check.ts +2 -2
- package/scripts/eslint-file-length.mjs +9 -9
- package/scripts/eslint-report-guard.mjs +1 -1
- package/scripts/eslint-report-guard.test.mjs +1 -1
- package/scripts/harness-api.test.ts +7 -46
- package/scripts/{rules-see-files.harness.mjs → rules-see-files-rule.test.mjs} +10 -6
- package/scripts/rules-see-files.mjs +1 -1
- 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/{paper-pipeline.harness.mjs → paper-pipeline.test.mjs} +45 -46
- package/skills/paper-pipeline/scripts/{consumer.harness.mjs → consumer-paths.test.mjs} +66 -59
- package/skills/paper-pipeline/scripts/consumer.mjs +3 -3
- package/skills/paper-pipeline/scripts/{extract-ref-facts.harness.mjs → extract-ref-facts-cli.test.mjs} +29 -31
- package/skills/paper-pipeline/scripts/extract-ref-facts.js +6 -5
- package/skills/paper-pipeline/scripts/fixtures/real-bib/refs.bib +1 -1
- package/skills/paper-pipeline/scripts/{generated-code.harness.mjs → generated-code-fixtures.test.mjs} +39 -46
- package/skills/pc-panel-review/scripts/prior-reviews.js +7 -5
- package/skills/render-paper/{extract-pdf-facts.harness.ts → extract-pdf-facts.test.ts} +20 -13
- package/skills/render-paper/{render-paper.harness.mjs → render-paper.test.mjs} +41 -40
- 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/pdfjs/fill.test.ts +1 -1
- package/src/adapters/venue-corpus/index.test.ts +279 -0
- package/src/adapters/venue-corpus/index.ts +286 -0
- package/src/{build-engine.harness.mjs → build-engine-prepare.test.mjs} +98 -81
- package/src/{build.harness.mjs → build-fake-tex.test.mjs} +61 -28
- package/src/{cli.harness.mjs → cli-e2e.test.mjs} +108 -102
- package/src/cli.test.ts +1 -1
- package/src/{doctor.harness.mjs → doctor-install.test.mjs} +28 -29
- 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/{engine.harness.mjs → engine.test.mjs} +120 -106
- package/src/facts-file.test.ts +1 -1
- package/src/{hooks-settings.harness.ts → hooks-settings.test.ts} +161 -146
- package/src/latex-log.test.ts +395 -0
- package/src/latex-log.ts +1 -1
- package/src/latex-loop.test.ts +553 -0
- package/src/latex-loop.ts +1 -1
- package/src/{link-skills.harness.ts → link-skills-fs.test.ts} +26 -26
- package/src/{new-paper.harness.mjs → new-paper-scaffold.test.mjs} +31 -19
- package/src/{pdf-facts.harness.ts → pdf-facts-tables.test.ts} +28 -22
- package/src/{pdf-geometry.harness.ts → pdf-geometry.test.ts} +93 -75
- package/src/ports/venue-corpus-codec.ts +11 -0
- package/src/{rules-config.harness.ts → rules-config.test.ts} +41 -31
- package/src/{structure.harness.ts → structure.test.ts} +12 -10
- package/src/{tex-requirements.harness.ts → tex-requirements-tables.test.ts} +106 -85
- package/src/{toolchain.harness.mjs → toolchain-mirror.test.mjs} +204 -186
- package/scripts/check.harness.ts +0 -343
- package/scripts/harness-api.frozen.json +0 -41
- package/src/latex-log.harness.ts +0 -382
- package/src/latex-loop.harness.ts +0 -515
|
@@ -7,9 +7,8 @@
|
|
|
7
7
|
* doctor has exactly the same property — it will print a cheerful list of checkmarks and never
|
|
8
8
|
* notice a mismatch. That is, the check for a silent failure can itself fail silently, and only
|
|
9
9
|
* this file can tell the two apart.
|
|
10
|
-
*
|
|
11
|
-
* Run: npx vigiles test src/doctor.harness.mjs
|
|
12
10
|
*/
|
|
11
|
+
import { expect, it } from "vitest";
|
|
13
12
|
import { PAPERS_DIR_FIELD } from "../lib/paper-config.ts";
|
|
14
13
|
import {
|
|
15
14
|
mkdtempSync,
|
|
@@ -21,14 +20,18 @@ import {
|
|
|
21
20
|
import { tmpdir } from "node:os";
|
|
22
21
|
import { dirname, join } from "node:path";
|
|
23
22
|
import { fileURLToPath } from "node:url";
|
|
24
|
-
import { createChecker } from "../lib/check.ts";
|
|
25
23
|
|
|
26
24
|
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
27
25
|
const { doctor, detectPapers, PROGRAMS, found } = await import(
|
|
28
26
|
join(HERE, "doctor.ts")
|
|
29
27
|
);
|
|
30
28
|
|
|
31
|
-
|
|
29
|
+
// A failed check is recorded and the rest of the test keeps running.
|
|
30
|
+
const check = (label, cond, detail) => {
|
|
31
|
+
expect
|
|
32
|
+
.soft(cond, detail === undefined ? label : `${label}\n${String(detail)}`)
|
|
33
|
+
.toBeTruthy();
|
|
34
|
+
};
|
|
32
35
|
|
|
33
36
|
/** A consumer on disk: a papers directory, and maybe a declaration in the root paperlint.json. */
|
|
34
37
|
function consumer({ papersDir, declared, makeDir = true }) {
|
|
@@ -70,7 +73,7 @@ const runDoctor = (
|
|
|
70
73
|
};
|
|
71
74
|
|
|
72
75
|
// ── I. A CONSISTENT INSTALL IS SILENT ───────────────────────────────────────────────────────
|
|
73
|
-
{
|
|
76
|
+
it("I. A CONSISTENT INSTALL IS SILENT", () => {
|
|
74
77
|
const dir = consumer({ papersDir: "papers", declared: "papers" });
|
|
75
78
|
const r = runDoctor(dir, { cliPapers: "papers" });
|
|
76
79
|
check("a consistent install — exit ZERO", r.code === 0);
|
|
@@ -79,12 +82,12 @@ const runDoctor = (
|
|
|
79
82
|
/linted\s+papers$/m.test(r.out),
|
|
80
83
|
);
|
|
81
84
|
rmSync(dir, { recursive: true, force: true });
|
|
82
|
-
}
|
|
85
|
+
});
|
|
83
86
|
|
|
84
87
|
// ── II. THE VERY DEFECT: THE PAPERS LIVE SOMEWHERE THE SETTINGS DO NOT NAME ─────────────────
|
|
85
88
|
// The install that motivated doctor (issue #33): nothing declared, so lint and the hooks both
|
|
86
89
|
// watch `papers/`, while the papers are in another directory.
|
|
87
|
-
{
|
|
90
|
+
it("II. THE VERY DEFECT: THE PAPERS LIVE SOMEWHERE THE SETTINGS DO NOT NAME", () => {
|
|
88
91
|
const dir = consumer({ papersDir: "writing/drafts" });
|
|
89
92
|
const r = runDoctor(dir, { cliPapers: "papers" });
|
|
90
93
|
check(
|
|
@@ -100,11 +103,11 @@ const runDoctor = (
|
|
|
100
103
|
/papers look like they live in: writing\/drafts/.test(r.out),
|
|
101
104
|
);
|
|
102
105
|
rmSync(dir, { recursive: true, force: true });
|
|
103
|
-
}
|
|
106
|
+
});
|
|
104
107
|
|
|
105
108
|
// ── II-bis. NO paperlint.json — EVERY DEFAULT, AND THAT IS A VALID PROJECT ─────────────────
|
|
106
109
|
// The CLI and the hooks both take `papers` when nothing is declared, so they cannot disagree.
|
|
107
|
-
{
|
|
110
|
+
it("II-bis. NO paperlint.json — EVERY DEFAULT, AND THAT IS A VALID PROJECT", () => {
|
|
108
111
|
const dir = consumer({ papersDir: "papers" });
|
|
109
112
|
const r = runDoctor(dir, { cliPapers: "papers" });
|
|
110
113
|
check("no paperlint.json — exit ZERO", r.code === 0);
|
|
@@ -115,10 +118,10 @@ const runDoctor = (
|
|
|
115
118
|
),
|
|
116
119
|
);
|
|
117
120
|
rmSync(dir, { recursive: true, force: true });
|
|
118
|
-
}
|
|
121
|
+
});
|
|
119
122
|
|
|
120
123
|
// ── II-quater. A paperlint.json THAT DOES NOT PARSE — lint refuses to run ────────────────
|
|
121
|
-
{
|
|
124
|
+
it("II-quater. A paperlint.json THAT DOES NOT PARSE — lint refuses to run", () => {
|
|
122
125
|
const dir = consumer({ papersDir: "papers" });
|
|
123
126
|
writeFileSync(join(dir, "paperlint.json"), '{ "papersDir": <<<<<<< HEAD\n');
|
|
124
127
|
const r = runDoctor(dir, { cliPapers: "papers" });
|
|
@@ -129,13 +132,13 @@ const runDoctor = (
|
|
|
129
132
|
/`paperlint lint` refuses to run/.test(r.out),
|
|
130
133
|
);
|
|
131
134
|
rmSync(dir, { recursive: true, force: true });
|
|
132
|
-
}
|
|
135
|
+
});
|
|
133
136
|
|
|
134
137
|
// ── II-ter. A FRESH PROJECT WITH NO PAPERS YET IS NOT BROKEN ───────────────────────────────
|
|
135
138
|
// `init --yes` declares the default and creates no paper. The declared directory does not exist,
|
|
136
139
|
// and no papers live anywhere else: there is nothing to check yet. A warning with the next
|
|
137
140
|
// step, not a failure. (A missing directory while papers DO live elsewhere stays ✗ — case II.)
|
|
138
|
-
{
|
|
141
|
+
it("II-ter. A FRESH PROJECT WITH NO PAPERS YET IS NOT BROKEN", () => {
|
|
139
142
|
const dir = consumer({
|
|
140
143
|
papersDir: "papers",
|
|
141
144
|
declared: "papers",
|
|
@@ -150,10 +153,10 @@ const runDoctor = (
|
|
|
150
153
|
!/watching nothing/.test(r.out),
|
|
151
154
|
);
|
|
152
155
|
rmSync(dir, { recursive: true, force: true });
|
|
153
|
-
}
|
|
156
|
+
});
|
|
154
157
|
|
|
155
158
|
// ── V. A SETTING THAT NAMES NO DIRECTORY IS NAMED, NOT TURNED INTO ONE ─────────────────────
|
|
156
|
-
{
|
|
159
|
+
it("V. A SETTING THAT NAMES NO DIRECTORY IS NAMED, NOT TURNED INTO ONE", () => {
|
|
157
160
|
const dir = consumer({ papersDir: "papers", declared: "" });
|
|
158
161
|
const r = runDoctor(dir, { cliPapers: null });
|
|
159
162
|
check(
|
|
@@ -161,10 +164,10 @@ const runDoctor = (
|
|
|
161
164
|
/name no directory/.test(r.out),
|
|
162
165
|
);
|
|
163
166
|
rmSync(dir, { recursive: true, force: true });
|
|
164
|
-
}
|
|
167
|
+
});
|
|
165
168
|
|
|
166
169
|
// ── VI. EXTERNAL PROGRAMS ARE A FACT, NOT A VERDICT ─────────────────────────────────────────
|
|
167
|
-
{
|
|
170
|
+
it("VI. EXTERNAL PROGRAMS ARE A FACT, NOT A VERDICT", () => {
|
|
168
171
|
const dir = consumer({ papersDir: "papers", declared: "papers" });
|
|
169
172
|
const none = runDoctor(dir, { cliPapers: "papers", have: () => 1 });
|
|
170
173
|
check(
|
|
@@ -197,10 +200,10 @@ const runDoctor = (
|
|
|
197
200
|
none.out,
|
|
198
201
|
);
|
|
199
202
|
rmSync(dir, { recursive: true, force: true });
|
|
200
|
-
}
|
|
203
|
+
});
|
|
201
204
|
|
|
202
205
|
// ── VII. DETECTING THE PAPERS DIRECTORY ─────────────────────────────────────────────────────
|
|
203
|
-
{
|
|
206
|
+
it("VII. DETECTING THE PAPERS DIRECTORY", () => {
|
|
204
207
|
const dir = realpathSync(mkdtempSync(join(tmpdir(), "paperlint-detect-")));
|
|
205
208
|
mkdirSync(join(dir, "writing", "drafts", "p1"), { recursive: true });
|
|
206
209
|
writeFileSync(join(dir, "writing", "drafts", "p1", "paper.tex"), "x");
|
|
@@ -233,13 +236,13 @@ const runDoctor = (
|
|
|
233
236
|
!detectPapers(dir).includes("only-template"),
|
|
234
237
|
);
|
|
235
238
|
rmSync(dir, { recursive: true, force: true });
|
|
236
|
-
}
|
|
239
|
+
});
|
|
237
240
|
|
|
238
241
|
// ── VII-bis. SKILLS THAT ARE NOT LINKED ARE NAMED — AND DO NOT FAIL THE RUN ─────────────────
|
|
239
242
|
// Before this section a consumer without `.claude/skills/` links had no `/paper-pipeline`, and
|
|
240
|
-
// nothing anywhere said so. The link state itself is `link-skills.
|
|
243
|
+
// nothing anywhere said so. The link state itself is `link-skills-fs.test.ts`'s subject; here
|
|
241
244
|
// only doctor's REPORTING of it is judged, so the state is handed in rather than built on disk.
|
|
242
|
-
{
|
|
245
|
+
it("VII-bis. SKILLS THAT ARE NOT LINKED ARE NAMED — AND DO NOT FAIL THE RUN", () => {
|
|
243
246
|
const dir = consumer({ papersDir: "papers", declared: "papers" });
|
|
244
247
|
const state = {
|
|
245
248
|
ok: true,
|
|
@@ -274,17 +277,13 @@ const runDoctor = (
|
|
|
274
277
|
/✓ all 1 shipped skills are reachable/.test(all.out),
|
|
275
278
|
);
|
|
276
279
|
rmSync(dir, { recursive: true, force: true });
|
|
277
|
-
}
|
|
280
|
+
});
|
|
278
281
|
|
|
279
282
|
// ── VIII. `found` ASKS THE SYSTEM, IT DOES NOT GUESS BY NAME ────────────────────────────────
|
|
280
|
-
{
|
|
283
|
+
it("VIII. `found` ASKS THE SYSTEM, IT DOES NOT GUESS BY NAME", () => {
|
|
281
284
|
check("a program that really exists is found", found("node") === true);
|
|
282
285
|
check(
|
|
283
286
|
"a made-up one is not (otherwise the check answers the form, not the subject)",
|
|
284
287
|
found("paperlint-definitely-not-a-real-binary-xyz") === false,
|
|
285
288
|
);
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
console.log(
|
|
289
|
-
`✓ ${check.count} assertions passed — paperlint doctor: an install can vouch for itself`,
|
|
290
|
-
);
|
|
289
|
+
});
|
|
@@ -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
|
+
});
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THE LICENCE TABLE — what a copy's licence permits a venue corpus to store (docs/design/venue-corpus.md,
|
|
3
|
+
* decision 3). A corpus keeps third-party papers; each stored file is a copy of one version, judged by
|
|
4
|
+
* that copy's licence (`papers.json`, `src/domain/venue-corpus.ts`).
|
|
5
|
+
*
|
|
6
|
+
* Any SPDX id or `LicenseRef-…` is a licence id where the record is parsed; this table decides what
|
|
7
|
+
* one permits. An id it does not list permits nothing and is its own result, naming the id, so one
|
|
8
|
+
* `CC-BY-3.0` does not hide the rest of a record and a typo is still loud. `NOASSERTION` (the licence
|
|
9
|
+
* was not read) permits nothing, as its own result. A non-commercial licence permits storing only in a
|
|
10
|
+
* project that declares itself non-commercial: paperlint does not assume it.
|
|
11
|
+
*
|
|
12
|
+
* A version of a CC licence other than 4.0 gets its row when a corpus meets it.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/** What a corpus stores of a copy: its extracted text (every variant), or the PDF. */
|
|
16
|
+
export const STORED_KINDS = ["text", "pdf"] as const;
|
|
17
|
+
export type StoredKind = (typeof STORED_KINDS)[number];
|
|
18
|
+
|
|
19
|
+
/** SPDX's own id for "no licence information was given": here, the licence was not read. */
|
|
20
|
+
export const NOASSERTION = "NOASSERTION";
|
|
21
|
+
|
|
22
|
+
/** The project's one setting the table reads: it declares itself non-commercial. */
|
|
23
|
+
export interface LicenceSettings {
|
|
24
|
+
readonly nonCommercial: boolean;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** What a licence permits for one kind: storing it, or the one reason it may not be stored. */
|
|
28
|
+
export type Permission =
|
|
29
|
+
| { readonly kind: "permitted" }
|
|
30
|
+
| { readonly kind: "forbidden"; readonly why: string }
|
|
31
|
+
/** A non-commercial licence, in a project that has not declared itself non-commercial. */
|
|
32
|
+
| { readonly kind: "non-commercial-only" }
|
|
33
|
+
/** `NOASSERTION`: no licence was read for the copy. */
|
|
34
|
+
| { readonly kind: "not-read" }
|
|
35
|
+
/** An id the table does not list. */
|
|
36
|
+
| { readonly kind: "unlisted"; readonly id: string };
|
|
37
|
+
|
|
38
|
+
/** One kind's grant: always, never (with why), or only in a non-commercial project. */
|
|
39
|
+
type Grant = "yes" | { readonly no: string } | "non-commercial";
|
|
40
|
+
|
|
41
|
+
interface Row {
|
|
42
|
+
readonly text: Grant;
|
|
43
|
+
readonly pdf: Grant;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const ND = {
|
|
47
|
+
no: "ND permits reproduction in unmodified form; whether an extracted text is an adaptation is unsettled",
|
|
48
|
+
} as const;
|
|
49
|
+
|
|
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"',
|
|
52
|
+
} as const;
|
|
53
|
+
|
|
54
|
+
const PUBLISHER = {
|
|
55
|
+
no: "the publisher grants no right to third parties",
|
|
56
|
+
} as const;
|
|
57
|
+
|
|
58
|
+
/** The table: an id → what it grants for text and for the PDF. */
|
|
59
|
+
const TABLE: ReadonlyMap<string, Row> = new Map<string, Row>([
|
|
60
|
+
["CC0-1.0", { text: "yes", pdf: "yes" }],
|
|
61
|
+
["CC-BY-4.0", { text: "yes", pdf: "yes" }],
|
|
62
|
+
["CC-BY-SA-4.0", { text: "yes", pdf: "yes" }],
|
|
63
|
+
["CC-BY-NC-4.0", { text: "non-commercial", pdf: "non-commercial" }],
|
|
64
|
+
["CC-BY-NC-SA-4.0", { text: "non-commercial", pdf: "non-commercial" }],
|
|
65
|
+
["CC-BY-ND-4.0", { text: ND, pdf: "yes" }],
|
|
66
|
+
["CC-BY-NC-ND-4.0", { text: ND, pdf: "non-commercial" }],
|
|
67
|
+
["LicenseRef-arxiv-nonexclusive-1.0", { text: ARXIV, pdf: ARXIV }],
|
|
68
|
+
["LicenseRef-publisher", { text: PUBLISHER, pdf: PUBLISHER }],
|
|
69
|
+
]);
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* True for an SPDX license id's shape (letters, digits, `-` and `.`, and the deprecated `+` suffix)
|
|
73
|
+
* or a `LicenseRef-` of SPDX and REUSE; listed or not. An expression (`MIT OR Apache-2.0`), a phrase
|
|
74
|
+
* or a URL is not an id.
|
|
75
|
+
*/
|
|
76
|
+
export const isLicenceId = (id: string): boolean =>
|
|
77
|
+
/^(?:LicenseRef-[A-Za-z0-9.-]+|[A-Za-z0-9][A-Za-z0-9.-]*\+?)$/u.test(id);
|
|
78
|
+
|
|
79
|
+
/** Whether a copy under licence `id` may be stored as `kind`, in a project of `settings`. */
|
|
80
|
+
export function permits(
|
|
81
|
+
id: string,
|
|
82
|
+
kind: StoredKind,
|
|
83
|
+
settings: Readonly<LicenceSettings>,
|
|
84
|
+
): Permission {
|
|
85
|
+
if (id === NOASSERTION) return { kind: "not-read" };
|
|
86
|
+
const row = TABLE.get(id);
|
|
87
|
+
if (row === undefined) return { kind: "unlisted", id };
|
|
88
|
+
const grant = row[kind];
|
|
89
|
+
if (grant === "yes") return { kind: "permitted" };
|
|
90
|
+
if (grant === "non-commercial")
|
|
91
|
+
return settings.nonCommercial
|
|
92
|
+
? { kind: "permitted" }
|
|
93
|
+
: { kind: "non-commercial-only" };
|
|
94
|
+
return { kind: "forbidden", why: grant.no };
|
|
95
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A VENUE CORPUS'S RECORD — `<papers-root>/venues/<venue>/papers.json` (docs/design/venue-corpus.md,
|
|
3
|
+
* decision 1; docs/venues.md): the papers a venue accepted and, for each, every copy we know of with
|
|
4
|
+
* its licence. Codes and measurements stay in `measurements.json`, keyed by a paper's `key`; prose
|
|
5
|
+
* stays in `MANIFEST.md`.
|
|
6
|
+
*
|
|
7
|
+
* The text of the file is checked once, where it enters: `VenueCorpusCodec`
|
|
8
|
+
* (`src/ports/venue-corpus-codec.ts`), whose adapter holds the zod schema of this shape. The domain
|
|
9
|
+
* holds the value: only the codec mints one, so a value built by hand can hold what the schema
|
|
10
|
+
* refuses (a stored copy without `fetched_from`, a key with a slash). The top level, an edition, a copy, its licence and a paper's ids are strict; a paper
|
|
11
|
+
* row keeps any further field as it is, because a consumer's own scripts read them.
|
|
12
|
+
*
|
|
13
|
+
* 🔴 A licence belongs to a copy, not to a paper (decision 2): the same paper is often CC BY in the
|
|
14
|
+
* proceedings and under arXiv's licence as a preprint, and a stored file is a copy of one version. What
|
|
15
|
+
* a licence permits is `src/domain/licence.ts`'s table.
|
|
16
|
+
*/
|
|
17
|
+
import type { NOASSERTION, StoredKind } from "./licence.ts";
|
|
18
|
+
|
|
19
|
+
export const CORPUS_RECORD = "papers.json";
|
|
20
|
+
|
|
21
|
+
/** `accepted` and `award` are this venue's; `sister`, a paper of another venue (corpus 2). */
|
|
22
|
+
export const PAPER_GROUPS = ["accepted", "award", "sister"] as const;
|
|
23
|
+
export type PaperGroup = (typeof PAPER_GROUPS)[number];
|
|
24
|
+
|
|
25
|
+
/** OpenAlex's `publishedVersion` / `acceptedVersion` / `submittedVersion`. */
|
|
26
|
+
export const KNOWN_VERSIONS = ["published", "accepted", "preprint"] as const;
|
|
27
|
+
export type KnownVersion = (typeof KNOWN_VERSIONS)[number];
|
|
28
|
+
|
|
29
|
+
/** The ids a paper may carry; `url` is its page on the listing, when nothing else identifies it. */
|
|
30
|
+
export const PAPER_ID_KINDS = ["doi", "arxiv", "dblp", "s2", "url"] as const;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* A key names the stored files (`pdf/<key>.pdf`) and the measurement rows: one path segment, with
|
|
34
|
+
* no dot, because `text/<key>.<variant>.txt` is read up to the first dot. An arXiv id goes in `ids`.
|
|
35
|
+
*/
|
|
36
|
+
export const KEY_PATTERN = /^[A-Za-z0-9][A-Za-z0-9_-]*$/u;
|
|
37
|
+
|
|
38
|
+
/** One edition of this venue the corpus covers. */
|
|
39
|
+
export interface Edition {
|
|
40
|
+
readonly edition: number;
|
|
41
|
+
/** The page that lists what the edition accepted. */
|
|
42
|
+
readonly listed_from: string;
|
|
43
|
+
readonly read_on: string;
|
|
44
|
+
/** How many it accepted, when the page says. */
|
|
45
|
+
readonly accepted?: number | undefined;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** A licence read from a source, or `NOASSERTION`: none was read. */
|
|
49
|
+
export type Licence =
|
|
50
|
+
| { readonly id: typeof NOASSERTION }
|
|
51
|
+
| {
|
|
52
|
+
/** An SPDX id or a `LicenseRef-`. */
|
|
53
|
+
readonly id: string;
|
|
54
|
+
/** The page or API response it was read from, never inferred. */
|
|
55
|
+
readonly read_from: string;
|
|
56
|
+
readonly read_on: string;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
/** What of a copy is in the corpus, and where its bytes came from. */
|
|
60
|
+
interface Storage {
|
|
61
|
+
/**
|
|
62
|
+
* Each kind at most once per copy (two copies of one paper storing one kind is `corpus/record`'s
|
|
63
|
+
* finding); `text` covers every text variant of the paper.
|
|
64
|
+
*/
|
|
65
|
+
readonly stored: readonly StoredKind[];
|
|
66
|
+
/** Present whenever `stored` is not empty. */
|
|
67
|
+
readonly fetched_from?: string | undefined;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* One copy of a paper. A copy whose origin nobody recorded is `unknown`, and its licence is
|
|
72
|
+
* `NOASSERTION`, so it permits nothing.
|
|
73
|
+
*/
|
|
74
|
+
export type Copy =
|
|
75
|
+
| (Storage & {
|
|
76
|
+
readonly version: KnownVersion;
|
|
77
|
+
readonly url: string;
|
|
78
|
+
readonly licence: Licence;
|
|
79
|
+
})
|
|
80
|
+
| (Storage & {
|
|
81
|
+
readonly version: "unknown";
|
|
82
|
+
readonly licence: { readonly id: typeof NOASSERTION };
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
export interface PaperIds {
|
|
86
|
+
readonly doi?: string | undefined;
|
|
87
|
+
readonly arxiv?: string | undefined;
|
|
88
|
+
readonly dblp?: string | undefined;
|
|
89
|
+
readonly s2?: string | undefined;
|
|
90
|
+
readonly url?: string | undefined;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
interface PaperFields {
|
|
94
|
+
/** Unique in the file. */
|
|
95
|
+
readonly key: string;
|
|
96
|
+
readonly title: string;
|
|
97
|
+
readonly authors?: readonly string[] | undefined;
|
|
98
|
+
/** Kept as metadata whatever the copies' licences. */
|
|
99
|
+
/** `null` where the listing gave none. */
|
|
100
|
+
readonly abstract?: string | null | undefined;
|
|
101
|
+
/** At least one. */
|
|
102
|
+
readonly ids: PaperIds;
|
|
103
|
+
readonly copies: readonly Copy[];
|
|
104
|
+
readonly [extra: string]: unknown;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export type Paper =
|
|
108
|
+
| (PaperFields & {
|
|
109
|
+
readonly group: "accepted" | "award";
|
|
110
|
+
/** One of the record's `editions[].edition`. */
|
|
111
|
+
readonly edition: number;
|
|
112
|
+
})
|
|
113
|
+
| (PaperFields & {
|
|
114
|
+
readonly group: "sister";
|
|
115
|
+
readonly venue: string;
|
|
116
|
+
readonly year: number;
|
|
117
|
+
readonly listed_from: string;
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
export interface VenueCorpus {
|
|
121
|
+
/** The corpus folder's name: the venue preset's series. */
|
|
122
|
+
readonly venue: string;
|
|
123
|
+
readonly editions: readonly Edition[];
|
|
124
|
+
readonly papers: readonly Paper[];
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** A `papers.json`'s text, parsed: the record, or every reason it is not one. */
|
|
128
|
+
export type ParsedCorpus =
|
|
129
|
+
| { readonly ok: true; readonly corpus: VenueCorpus }
|
|
130
|
+
| { readonly ok: false; readonly why: string };
|