paperlint 20.2.0 → 20.4.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/dist/adapters/venue-corpus/index.d.ts +19 -3
- package/dist/adapters/venue-corpus/index.d.ts.map +1 -1
- package/dist/adapters/venue-corpus/index.js +36 -8
- package/dist/adapters/venue-corpus/index.js.map +1 -1
- package/dist/cli.d.ts +4 -3
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +42 -13
- package/dist/cli.js.map +1 -1
- package/dist/corpus-record-rule.d.ts +65 -0
- package/dist/corpus-record-rule.d.ts.map +1 -0
- package/dist/corpus-record-rule.js +85 -0
- package/dist/corpus-record-rule.js.map +1 -0
- package/dist/domain/corpus-record.d.ts +51 -0
- package/dist/domain/corpus-record.d.ts.map +1 -0
- package/dist/domain/corpus-record.js +119 -0
- package/dist/domain/corpus-record.js.map +1 -0
- package/dist/domain/venue-corpus.d.ts +36 -5
- package/dist/domain/venue-corpus.d.ts.map +1 -1
- package/dist/domain/venue-corpus.js +20 -0
- package/dist/domain/venue-corpus.js.map +1 -1
- package/dist/paper-files.d.ts +10 -3
- package/dist/paper-files.d.ts.map +1 -1
- package/dist/paper-files.js +17 -2
- package/dist/paper-files.js.map +1 -1
- package/dist/papers-roots.d.ts +6 -0
- package/dist/papers-roots.d.ts.map +1 -1
- package/dist/papers-roots.js +14 -0
- package/dist/papers-roots.js.map +1 -1
- package/docs/design/venue-corpus.md +62 -40
- package/docs/layout.md +2 -2
- package/docs/rules/corpus/record.md +122 -0
- package/docs/rules.md +1 -0
- package/docs/venues.md +35 -20
- package/eslint.config.mjs +1 -0
- package/package.json +2 -1
- package/scripts/eslint-file-length.mjs +3 -3
- package/skills/study-accepted-papers/SKILL.md +14 -8
- package/skills/study-accepted-papers/SKILL.md.spec.ts +13 -7
- package/skills/study-accepted-papers/papers.schema.json +50 -2
- package/skills/study-accepted-papers/scripts/corpus-licences-core.js +2 -2
- package/skills/study-accepted-papers/scripts/corpus-licences-core.ts +2 -1
- package/skills/study-accepted-papers/scripts/corpus-licences.js +39 -10
- package/skills/study-accepted-papers/scripts/corpus-licences.test.ts +5 -1
- package/src/adapters/venue-corpus/index.test.ts +81 -55
- package/src/adapters/venue-corpus/index.ts +42 -9
- package/src/adapters/venue-corpus/schema.test.ts +47 -0
- package/src/cli-e2e.test.mjs +2 -2
- package/src/cli.test.ts +1 -1
- package/src/cli.ts +57 -13
- package/src/corpus-record-rule.test.ts +229 -0
- package/src/corpus-record-rule.ts +175 -0
- package/src/domain/corpus-record.test.ts +163 -0
- package/src/domain/corpus-record.ts +210 -0
- package/src/domain/venue-corpus.test.ts +85 -0
- package/src/domain/venue-corpus.ts +59 -5
- package/src/paper-files.test.ts +13 -4
- package/src/paper-files.ts +23 -2
- package/src/paper-settings-commands.test.ts +2 -2
- package/src/papers-roots.test.ts +34 -1
- package/src/papers-roots.ts +15 -0
- package/src/rule-cases.test.ts +15 -0
- package/src/settled-paper.test.ts +1 -1
- package/src/unowned-file.test.ts +1 -1
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/** The corpus record's judge: each finding of `corpus/record`, and silence on a corpus that keeps its record. */
|
|
2
|
+
import { describe, expect, it } from "vitest";
|
|
3
|
+
import {
|
|
4
|
+
corpusMessage,
|
|
5
|
+
judgeCorpus,
|
|
6
|
+
storedKey,
|
|
7
|
+
type CorpusFinding,
|
|
8
|
+
type CorpusFolder,
|
|
9
|
+
} from "./corpus-record.ts";
|
|
10
|
+
import type { Copy, Paper, VenueCorpus } from "./venue-corpus.ts";
|
|
11
|
+
|
|
12
|
+
const copy = (stored: Copy["stored"]): Copy => ({
|
|
13
|
+
version: "published",
|
|
14
|
+
url: "https://doi.org/10.1/x",
|
|
15
|
+
licence: { id: "NOASSERTION" },
|
|
16
|
+
stored,
|
|
17
|
+
...(stored.length > 0 ? { fetched_from: "https://doi.org/10.1/x" } : {}),
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const paper = (key: string, copies: readonly Copy[]): Paper => ({
|
|
21
|
+
key,
|
|
22
|
+
title: "A title",
|
|
23
|
+
group: "accepted",
|
|
24
|
+
edition: 2026,
|
|
25
|
+
ids: { doi: "10.1/x" },
|
|
26
|
+
copies,
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const corpus = (papers: readonly Paper[]): VenueCorpus => ({
|
|
30
|
+
venue: "agent",
|
|
31
|
+
editions: [],
|
|
32
|
+
papers,
|
|
33
|
+
rebuild: [],
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
const folder = (
|
|
37
|
+
record: CorpusFolder["record"],
|
|
38
|
+
pdf: readonly string[] = [],
|
|
39
|
+
text: readonly string[] = [],
|
|
40
|
+
): CorpusFolder => ({ record, stored: { pdf, text } });
|
|
41
|
+
|
|
42
|
+
const read = (papers: readonly Paper[]): CorpusFolder["record"] => ({
|
|
43
|
+
ok: true,
|
|
44
|
+
corpus: corpus(papers),
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
describe("storedKey: the paper a stored file's name belongs to", () => {
|
|
48
|
+
it.each([
|
|
49
|
+
["pdf", "2026-01.pdf", "2026-01"],
|
|
50
|
+
["text", "2026-01.txt", "2026-01"],
|
|
51
|
+
["text", "2026-01.pdfminer.txt", "2026-01"],
|
|
52
|
+
["pdf", "2026-01.txt", null],
|
|
53
|
+
["pdf", "a.b.pdf", null],
|
|
54
|
+
["text", "2026-01.pdf", null],
|
|
55
|
+
["text", "2026-01..txt", null],
|
|
56
|
+
["text", ".txt", null],
|
|
57
|
+
] as const)("%s/%s → %s", (kind, name, key) => {
|
|
58
|
+
// Guards: a name outside `<key>.pdf` / `<key>[.<variant>].txt` belongs to no paper.
|
|
59
|
+
expect(storedKey(kind, name)).toBe(key);
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
describe("judgeCorpus", () => {
|
|
64
|
+
it("is silent when every stored file is claimed by exactly one copy and exists", () => {
|
|
65
|
+
expect(
|
|
66
|
+
judgeCorpus(
|
|
67
|
+
folder(
|
|
68
|
+
read([paper("a", [copy(["pdf", "text"]), copy([])])]),
|
|
69
|
+
["a.pdf"],
|
|
70
|
+
["a.txt", "a.pdfminer.txt"],
|
|
71
|
+
),
|
|
72
|
+
),
|
|
73
|
+
).toEqual([]);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it("reports a record that does not parse: each of the codec's problems at its path", () => {
|
|
77
|
+
expect(
|
|
78
|
+
judgeCorpus(
|
|
79
|
+
folder({
|
|
80
|
+
ok: false,
|
|
81
|
+
problems: [
|
|
82
|
+
{ path: ["papers", 0, "key"], message: "x" },
|
|
83
|
+
{ path: [], message: "not JSON" },
|
|
84
|
+
],
|
|
85
|
+
}),
|
|
86
|
+
),
|
|
87
|
+
).toEqual([
|
|
88
|
+
{ kind: "unparsed", at: ["papers", 0, "key"], message: "x" },
|
|
89
|
+
{ kind: "unparsed", at: [], message: "not JSON" },
|
|
90
|
+
]);
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
describe("judgeCorpus: a record that does not account for the folder", () => {
|
|
95
|
+
it("reports a claimed PDF that is not there at the stored of the copy that claims it", () => {
|
|
96
|
+
expect(
|
|
97
|
+
judgeCorpus(folder(read([paper("a", [copy([]), copy(["pdf"])])]))),
|
|
98
|
+
).toEqual([
|
|
99
|
+
{
|
|
100
|
+
kind: "missing",
|
|
101
|
+
at: ["papers", 0, "copies", 1, "stored"],
|
|
102
|
+
key: "a",
|
|
103
|
+
stored: "pdf",
|
|
104
|
+
file: "pdf/a.pdf",
|
|
105
|
+
},
|
|
106
|
+
]);
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it("reports an unclaimed file, a missing file and two copies storing one kind", () => {
|
|
110
|
+
expect(
|
|
111
|
+
judgeCorpus(
|
|
112
|
+
folder(
|
|
113
|
+
read([
|
|
114
|
+
paper("a", [copy(["pdf"]), copy(["pdf"])]),
|
|
115
|
+
paper("b", [copy(["text"])]),
|
|
116
|
+
]),
|
|
117
|
+
["a.pdf", "b.pdf", "c.pdf", "notes.docx"],
|
|
118
|
+
[],
|
|
119
|
+
),
|
|
120
|
+
),
|
|
121
|
+
).toEqual([
|
|
122
|
+
{
|
|
123
|
+
kind: "twice",
|
|
124
|
+
at: ["papers", 0, "copies", 1, "stored"],
|
|
125
|
+
key: "a",
|
|
126
|
+
stored: "pdf",
|
|
127
|
+
copies: [0, 1],
|
|
128
|
+
},
|
|
129
|
+
// A file of a listed paper is reported at that paper's copies; any other, on the record.
|
|
130
|
+
{
|
|
131
|
+
kind: "unclaimed",
|
|
132
|
+
at: ["papers", 1, "copies"],
|
|
133
|
+
file: "pdf/b.pdf",
|
|
134
|
+
key: "b",
|
|
135
|
+
},
|
|
136
|
+
{ kind: "unclaimed", at: [], file: "pdf/c.pdf", key: "c" },
|
|
137
|
+
{ kind: "unclaimed", at: [], file: "pdf/notes.docx", key: null },
|
|
138
|
+
{
|
|
139
|
+
kind: "missing",
|
|
140
|
+
at: ["papers", 1, "copies", 0, "stored"],
|
|
141
|
+
key: "b",
|
|
142
|
+
stored: "text",
|
|
143
|
+
file: "text/b.txt",
|
|
144
|
+
},
|
|
145
|
+
]);
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
describe("corpusMessage: every finding names its cure", () => {
|
|
150
|
+
const at = ["papers", 0, "copies", 0, "stored"];
|
|
151
|
+
const findings: readonly CorpusFinding[] = [
|
|
152
|
+
{ kind: "unparsed", at: ["papers", 0, "key"], message: "x" },
|
|
153
|
+
{ kind: "unparsed", at: [], message: "not JSON" },
|
|
154
|
+
{ kind: "unclaimed", at: [], file: "pdf/b.pdf", key: "b" },
|
|
155
|
+
{ kind: "unclaimed", at: [], file: "pdf/x.docx", key: null },
|
|
156
|
+
{ kind: "missing", at, key: "b", stored: "text", file: "text/b.txt" },
|
|
157
|
+
{ kind: "twice", at, key: "a", stored: "pdf", copies: [0, 1] },
|
|
158
|
+
];
|
|
159
|
+
it.each(findings)("$kind", (f) => {
|
|
160
|
+
// Guards: each message says what to do, after the finding itself.
|
|
161
|
+
expect(corpusMessage(f)).toMatch(/What to do: \S/u);
|
|
162
|
+
});
|
|
163
|
+
});
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `corpus/record`'s judgement of one venue corpus (docs/design/venue-corpus.md, decisions 4–6;
|
|
3
|
+
* docs/rules/corpus/record.md): whether every copy stored in `pdf/` and `text/` is accounted for by
|
|
4
|
+
* `papers.json`. Pure: the folder's listing and the record, already parsed by the codec, in; the
|
|
5
|
+
* findings out. What the record's fields mean is `venue-corpus.ts`; this file never re-checks them.
|
|
6
|
+
*
|
|
7
|
+
* A stored file's path follows from its paper's `key` (decision 5): `pdf/<key>.pdf`,
|
|
8
|
+
* `text/<key>.txt` and `text/<key>.<variant>.txt`. The folder is named after the kind it holds.
|
|
9
|
+
*/
|
|
10
|
+
import { STORED_KINDS, type StoredKind } from "./licence.ts";
|
|
11
|
+
import {
|
|
12
|
+
CORPUS_RECORD,
|
|
13
|
+
KEY_PATTERN,
|
|
14
|
+
pathText,
|
|
15
|
+
type Paper,
|
|
16
|
+
type ParsedCorpus,
|
|
17
|
+
type RecordPath,
|
|
18
|
+
type VenueCorpus,
|
|
19
|
+
} from "./venue-corpus.ts";
|
|
20
|
+
|
|
21
|
+
/** The folder in a papers root that holds one corpus per venue. */
|
|
22
|
+
export const CORPORA_DIR = "venues";
|
|
23
|
+
|
|
24
|
+
/** What the rule reads of one corpus folder. */
|
|
25
|
+
export interface CorpusFolder {
|
|
26
|
+
/** `papers.json`, as the codec parsed it. */
|
|
27
|
+
readonly record: ParsedCorpus;
|
|
28
|
+
/** The names in `pdf/` and in `text/`, hidden ones left out; none when the folder is absent. */
|
|
29
|
+
readonly stored: Readonly<Record<StoredKind, readonly string[]>>;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* One finding, with `at`, the path in `papers.json` it is reported at (empty: the whole file);
|
|
34
|
+
* `file` is relative to the corpus folder.
|
|
35
|
+
*/
|
|
36
|
+
export type CorpusFinding = { readonly at: RecordPath } & (
|
|
37
|
+
| { readonly kind: "unparsed"; readonly message: string }
|
|
38
|
+
| {
|
|
39
|
+
readonly kind: "unclaimed";
|
|
40
|
+
readonly file: string;
|
|
41
|
+
readonly key: string | null;
|
|
42
|
+
}
|
|
43
|
+
| {
|
|
44
|
+
readonly kind: "missing";
|
|
45
|
+
readonly key: string;
|
|
46
|
+
readonly stored: StoredKind;
|
|
47
|
+
readonly file: string;
|
|
48
|
+
}
|
|
49
|
+
| {
|
|
50
|
+
readonly kind: "twice";
|
|
51
|
+
readonly key: string;
|
|
52
|
+
readonly stored: StoredKind;
|
|
53
|
+
readonly copies: readonly number[];
|
|
54
|
+
}
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
const keyOrNull = (key: string): string | null =>
|
|
58
|
+
KEY_PATTERN.test(key) ? key : null;
|
|
59
|
+
|
|
60
|
+
/** The key a stored file's name belongs to, or null when the name is not one a copy can store. */
|
|
61
|
+
export function storedKey(kind: StoredKind, name: string): string | null {
|
|
62
|
+
switch (kind) {
|
|
63
|
+
case "pdf":
|
|
64
|
+
return name.endsWith(".pdf") ? keyOrNull(name.slice(0, -4)) : null;
|
|
65
|
+
case "text": {
|
|
66
|
+
if (!name.endsWith(".txt")) return null;
|
|
67
|
+
const [key = "", ...variant] = name.slice(0, -4).split(".");
|
|
68
|
+
return variant.length > 0 && variant.join(".") === ""
|
|
69
|
+
? null
|
|
70
|
+
: keyOrNull(key);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** The extension of a stored kind's file. */
|
|
76
|
+
const EXTENSION: Readonly<Record<StoredKind, string>> = {
|
|
77
|
+
pdf: "pdf",
|
|
78
|
+
text: "txt",
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
/** The name the record expects a paper's stored kind under, for a message. */
|
|
82
|
+
const expectedFile = (kind: StoredKind, key: string): string =>
|
|
83
|
+
`${kind}/${key}.${EXTENSION[kind]}`;
|
|
84
|
+
|
|
85
|
+
/** The indexes of `p`'s copies that store `kind`. */
|
|
86
|
+
const storing = (p: Paper, kind: StoredKind): readonly number[] =>
|
|
87
|
+
p.copies.flatMap((c, i) => (c.stored.includes(kind) ? [i] : []));
|
|
88
|
+
|
|
89
|
+
/** Which copies of one paper (the `paper`-th of the record) store one kind. */
|
|
90
|
+
interface Claim {
|
|
91
|
+
readonly kind: StoredKind;
|
|
92
|
+
readonly key: string;
|
|
93
|
+
readonly paper: number;
|
|
94
|
+
readonly copies: readonly number[];
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** The `stored` of a paper's copy (`copy` holds its index), as a path. */
|
|
98
|
+
const storedAt = (paper: number, copy: readonly number[]): RecordPath => [
|
|
99
|
+
"papers",
|
|
100
|
+
paper,
|
|
101
|
+
"copies",
|
|
102
|
+
...copy,
|
|
103
|
+
"stored",
|
|
104
|
+
];
|
|
105
|
+
|
|
106
|
+
/** A paper's kind stored by more than one of its copies, reported at the second one. */
|
|
107
|
+
const twice = (claims: readonly Claim[]): readonly CorpusFinding[] =>
|
|
108
|
+
claims
|
|
109
|
+
.filter((c) => c.copies.length > 1)
|
|
110
|
+
.map((c) => ({
|
|
111
|
+
kind: "twice",
|
|
112
|
+
at: storedAt(c.paper, c.copies.slice(1, 2)),
|
|
113
|
+
key: c.key,
|
|
114
|
+
stored: c.kind,
|
|
115
|
+
copies: c.copies,
|
|
116
|
+
}));
|
|
117
|
+
|
|
118
|
+
/** A stored file no copy claims: at its paper's copies when the record lists the paper, else on the file. */
|
|
119
|
+
const unclaimed = (
|
|
120
|
+
claims: readonly Claim[],
|
|
121
|
+
stored: CorpusFolder["stored"],
|
|
122
|
+
): readonly CorpusFinding[] =>
|
|
123
|
+
STORED_KINDS.flatMap((kind) =>
|
|
124
|
+
stored[kind]
|
|
125
|
+
.map((name) => ({ name, key: storedKey(kind, name) }))
|
|
126
|
+
.filter(
|
|
127
|
+
(f) =>
|
|
128
|
+
!claims.some(
|
|
129
|
+
(c) => c.kind === kind && c.key === f.key && c.copies.length > 0,
|
|
130
|
+
),
|
|
131
|
+
)
|
|
132
|
+
.map((f) => ({
|
|
133
|
+
kind: "unclaimed",
|
|
134
|
+
at: atPaper(claims, f.key),
|
|
135
|
+
file: `${kind}/${f.name}`,
|
|
136
|
+
key: f.key,
|
|
137
|
+
})),
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
/** The copies of the paper `key` names, as a path; the whole file when no paper has that key. */
|
|
141
|
+
const atPaper = (claims: readonly Claim[], key: string | null): RecordPath => {
|
|
142
|
+
const claim = claims.find((c) => c.key === key);
|
|
143
|
+
return claim === undefined ? [] : ["papers", claim.paper, "copies"];
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
/** A claimed kind with no file of its paper's key. */
|
|
147
|
+
const missing = (
|
|
148
|
+
claims: readonly Claim[],
|
|
149
|
+
stored: CorpusFolder["stored"],
|
|
150
|
+
): readonly CorpusFinding[] =>
|
|
151
|
+
claims
|
|
152
|
+
.filter(
|
|
153
|
+
(c) =>
|
|
154
|
+
c.copies.length > 0 &&
|
|
155
|
+
!stored[c.kind].some((name) => storedKey(c.kind, name) === c.key),
|
|
156
|
+
)
|
|
157
|
+
.map((c) => ({
|
|
158
|
+
kind: "missing",
|
|
159
|
+
at: storedAt(c.paper, c.copies.slice(0, 1)),
|
|
160
|
+
key: c.key,
|
|
161
|
+
stored: c.kind,
|
|
162
|
+
file: expectedFile(c.kind, c.key),
|
|
163
|
+
}));
|
|
164
|
+
|
|
165
|
+
/** What a read record says about the folder. */
|
|
166
|
+
function judgeRecord(
|
|
167
|
+
corpus: VenueCorpus,
|
|
168
|
+
stored: CorpusFolder["stored"],
|
|
169
|
+
): readonly CorpusFinding[] {
|
|
170
|
+
const claims = STORED_KINDS.flatMap((kind) =>
|
|
171
|
+
corpus.papers.map((p, paper) => ({
|
|
172
|
+
kind,
|
|
173
|
+
key: p.key,
|
|
174
|
+
paper,
|
|
175
|
+
copies: storing(p, kind),
|
|
176
|
+
})),
|
|
177
|
+
);
|
|
178
|
+
return [
|
|
179
|
+
...twice(claims),
|
|
180
|
+
...unclaimed(claims, stored),
|
|
181
|
+
...missing(claims, stored),
|
|
182
|
+
];
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/** Every finding about one corpus folder; none for a corpus whose record accounts for each copy. */
|
|
186
|
+
export const judgeCorpus = (folder: CorpusFolder): readonly CorpusFinding[] =>
|
|
187
|
+
folder.record.ok
|
|
188
|
+
? judgeRecord(folder.record.corpus, folder.stored)
|
|
189
|
+
: folder.record.problems.map((p) => ({
|
|
190
|
+
kind: "unparsed",
|
|
191
|
+
at: p.path,
|
|
192
|
+
message: p.message,
|
|
193
|
+
}));
|
|
194
|
+
|
|
195
|
+
const KEEP_IDS =
|
|
196
|
+
"or remove the file and keep the paper's ids in `papers.json`, which is all a corpus needs to measure against it";
|
|
197
|
+
|
|
198
|
+
/** The text of a finding: what is wrong, then what to do. */
|
|
199
|
+
export function corpusMessage(f: CorpusFinding): string {
|
|
200
|
+
switch (f.kind) {
|
|
201
|
+
case "unparsed":
|
|
202
|
+
return `\`${pathText(f.at)}\`: ${f.message}. What to do: correct the field; the fields are in the JSON Schema \`papers.schema.json\` that \`study-accepted-papers\` ships`;
|
|
203
|
+
case "unclaimed":
|
|
204
|
+
return `\`${f.file}\` is stored, and no copy in \`${CORPUS_RECORD}\` claims it${f.key === null ? `: its name is not \`pdf/<key>.pdf\`, \`text/<key>.txt\` or \`text/<key>.<variant>.txt\`` : ` (no copy of the paper \`${f.key}\` lists it in \`stored\`)`}. What to do: record it under the copy it was fetched from, with \`fetched_from\`, its licence and where the licence was read; ${KEEP_IDS}`;
|
|
205
|
+
case "missing":
|
|
206
|
+
return `a copy of \`${f.key}\` stores \`${f.stored}\` in \`${CORPUS_RECORD}\`, and \`${f.file}\` is not there. What to do: put the file back, or remove \`"${f.stored}"\` from that copy's \`stored\``;
|
|
207
|
+
case "twice":
|
|
208
|
+
return `copies ${f.copies.join(" and ")} of \`${f.key}\` both store \`${f.stored}\`, and one stored file is a copy of one version. What to do: keep \`"${f.stored}"\` in the \`stored\` of the copy the file was fetched from, and remove it from the other`;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { editionCountIssue, type Edition, type Paper } from "./venue-corpus.ts";
|
|
3
|
+
|
|
4
|
+
const EDITION: Edition = {
|
|
5
|
+
edition: 2026,
|
|
6
|
+
listed_from: "https://example.org/accepted",
|
|
7
|
+
read_on: "2026-11-03",
|
|
8
|
+
accepted: 2,
|
|
9
|
+
capped: null,
|
|
10
|
+
proxy: null,
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const row = (
|
|
14
|
+
key: string,
|
|
15
|
+
group: "accepted" | "award",
|
|
16
|
+
edition = 2026,
|
|
17
|
+
): Paper => ({
|
|
18
|
+
key,
|
|
19
|
+
edition,
|
|
20
|
+
group,
|
|
21
|
+
title: key,
|
|
22
|
+
ids: { doi: `10.1/${key}` },
|
|
23
|
+
copies: [],
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const SISTER: Paper = {
|
|
27
|
+
key: "other",
|
|
28
|
+
group: "sister",
|
|
29
|
+
venue: "nlbse",
|
|
30
|
+
year: 2026,
|
|
31
|
+
listed_from: "https://example.org/nlbse",
|
|
32
|
+
title: "other",
|
|
33
|
+
ids: { doi: "10.1/other" },
|
|
34
|
+
copies: [],
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
describe("an edition's papers against what it accepted", () => {
|
|
38
|
+
it("🔴 uncapped: the winners and the ordinary papers together are all it accepted", () => {
|
|
39
|
+
// Guards: an award row is one of the accepted papers; a sister or another edition's row is not.
|
|
40
|
+
expect(
|
|
41
|
+
editionCountIssue(EDITION, [
|
|
42
|
+
row("a", "accepted"),
|
|
43
|
+
row("b", "award"),
|
|
44
|
+
row("c", "accepted", 2025),
|
|
45
|
+
SISTER,
|
|
46
|
+
]),
|
|
47
|
+
).toBeNull();
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it("🔴 uncapped: fewer rows than it accepted is a list copied in part", () => {
|
|
51
|
+
expect(editionCountIssue(EDITION, [row("a", "accepted")])).toBe(
|
|
52
|
+
"1 papers of 2026 are listed and 2 were accepted: list them all, or say in capped what was left out",
|
|
53
|
+
);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it("🔴 uncapped: more rows than it accepted", () => {
|
|
57
|
+
expect(
|
|
58
|
+
editionCountIssue(EDITION, [
|
|
59
|
+
row("a", "accepted"),
|
|
60
|
+
row("b", "accepted"),
|
|
61
|
+
row("c", "award"),
|
|
62
|
+
]),
|
|
63
|
+
).toBe(
|
|
64
|
+
"3 papers of 2026 are listed and 2 were accepted: list them all, or say in capped what was left out",
|
|
65
|
+
);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it("🔴 capped: fewer rows than it accepted is what capped says", () => {
|
|
69
|
+
expect(
|
|
70
|
+
editionCountIssue({ ...EDITION, capped: "the research track only" }, [
|
|
71
|
+
row("a", "accepted"),
|
|
72
|
+
]),
|
|
73
|
+
).toBeNull();
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it("🔴 capped: still never more rows than it accepted", () => {
|
|
77
|
+
expect(
|
|
78
|
+
editionCountIssue({ ...EDITION, capped: "the research track only" }, [
|
|
79
|
+
row("a", "accepted"),
|
|
80
|
+
row("b", "accepted"),
|
|
81
|
+
row("c", "accepted"),
|
|
82
|
+
]),
|
|
83
|
+
).toBe("3 papers of 2026 are listed, more than the 2 it accepted");
|
|
84
|
+
});
|
|
85
|
+
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* A VENUE CORPUS'S RECORD — `<papers-root>/venues/<venue>/papers.json` (docs/design/venue-corpus.md,
|
|
3
3
|
* decision 1; docs/venues.md): the papers a venue accepted and, for each, every copy we know of with
|
|
4
|
-
* its licence
|
|
5
|
-
*
|
|
4
|
+
* its licence, and the facts of how the corpus was collected. Codes and measurements stay in
|
|
5
|
+
* `measurements.json`, keyed by a paper's `key`; only caveats stay prose, in an optional `MANIFEST.md`.
|
|
6
6
|
*
|
|
7
7
|
* The text of the file is checked once, where it enters: `VenueCorpusCodec`
|
|
8
8
|
* (`src/ports/venue-corpus-codec.ts`), whose adapter holds the zod schema of this shape. The domain
|
|
@@ -41,8 +41,21 @@ export interface Edition {
|
|
|
41
41
|
/** The page that lists what the edition accepted. */
|
|
42
42
|
readonly listed_from: string;
|
|
43
43
|
readonly read_on: string;
|
|
44
|
-
/**
|
|
45
|
-
|
|
44
|
+
/**
|
|
45
|
+
* How many it accepted: the rows of the page that lists them. Without `capped` the corpus lists
|
|
46
|
+
* exactly this many of the edition's papers; with it, at most this many.
|
|
47
|
+
*/
|
|
48
|
+
readonly accepted: number;
|
|
49
|
+
/** What was left out of the edition and why; null when nothing was (never left out). */
|
|
50
|
+
readonly capped: string | null;
|
|
51
|
+
/** The stand-in for "strong accept" in this edition; null when it has none. */
|
|
52
|
+
readonly proxy: StrongAcceptProxy | null;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** What stands in for "strong accept" (an award, an oral slot), and how many papers it marks. */
|
|
56
|
+
export interface StrongAcceptProxy {
|
|
57
|
+
readonly what: string;
|
|
58
|
+
readonly papers: number;
|
|
46
59
|
}
|
|
47
60
|
|
|
48
61
|
/** A licence read from a source, or `NOASSERTION`: none was read. */
|
|
@@ -122,9 +135,50 @@ export interface VenueCorpus {
|
|
|
122
135
|
readonly venue: string;
|
|
123
136
|
readonly editions: readonly Edition[];
|
|
124
137
|
readonly papers: readonly Paper[];
|
|
138
|
+
/** The commands that regenerate the corpus, in order; empty when none was kept. */
|
|
139
|
+
readonly rebuild: readonly string[];
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/** Where in a `papers.json` a problem is: keys and indexes from the top; empty for the whole file. */
|
|
143
|
+
export type RecordPath = readonly (string | number)[];
|
|
144
|
+
|
|
145
|
+
/** One reason a `papers.json` is not a record. */
|
|
146
|
+
export interface CorpusProblem {
|
|
147
|
+
readonly path: RecordPath;
|
|
148
|
+
readonly message: string;
|
|
125
149
|
}
|
|
126
150
|
|
|
127
151
|
/** A `papers.json`'s text, parsed: the record, or every reason it is not one. */
|
|
128
152
|
export type ParsedCorpus =
|
|
129
153
|
| { readonly ok: true; readonly corpus: VenueCorpus }
|
|
130
|
-
| { readonly ok: false; readonly
|
|
154
|
+
| { readonly ok: false; readonly problems: readonly CorpusProblem[] };
|
|
155
|
+
|
|
156
|
+
/** A path as a message names it: `papers.0.copies`, or `(top)` for the whole file. */
|
|
157
|
+
export const pathText = (path: RecordPath): string =>
|
|
158
|
+
path.length === 0 ? "(top)" : path.join(".");
|
|
159
|
+
|
|
160
|
+
/** Every problem on one line, each with its path. */
|
|
161
|
+
export const problemsText = (problems: readonly CorpusProblem[]): string =>
|
|
162
|
+
`${CORPUS_RECORD}: ${problems.map((p) => `${pathText(p.path)}: ${p.message}`).join("; ")}`;
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* What an edition lists against what it accepted, or null when they agree: without `capped` its
|
|
166
|
+
* papers (`accepted` and `award` rows; a `sister` is another venue's) number exactly `accepted`,
|
|
167
|
+
* with `capped` at most that many.
|
|
168
|
+
*/
|
|
169
|
+
export const editionCountIssue = (
|
|
170
|
+
edition: Readonly<Edition>,
|
|
171
|
+
papers: readonly Paper[],
|
|
172
|
+
): string | null => {
|
|
173
|
+
const listed = papers.filter(
|
|
174
|
+
(p) => p.group !== "sister" && p.edition === edition.edition,
|
|
175
|
+
).length;
|
|
176
|
+
const tally = `${String(listed)} papers of ${String(edition.edition)} are listed`;
|
|
177
|
+
if (edition.capped === null)
|
|
178
|
+
return listed === edition.accepted
|
|
179
|
+
? null
|
|
180
|
+
: `${tally} and ${String(edition.accepted)} were accepted: list them all, or say in capped what was left out`;
|
|
181
|
+
return listed > edition.accepted
|
|
182
|
+
? `${tally}, more than the ${String(edition.accepted)} it accepted`
|
|
183
|
+
: null;
|
|
184
|
+
};
|
package/src/paper-files.test.ts
CHANGED
|
@@ -27,6 +27,7 @@ import {
|
|
|
27
27
|
ownedScopes,
|
|
28
28
|
paperFiles,
|
|
29
29
|
papersScope,
|
|
30
|
+
corpusFiles,
|
|
30
31
|
rebaseGlob,
|
|
31
32
|
ruleOwners,
|
|
32
33
|
scopeToOwned,
|
|
@@ -48,14 +49,15 @@ describe("the papers the config claims (#582)", () => {
|
|
|
48
49
|
buildConfig(
|
|
49
50
|
{},
|
|
50
51
|
texLanguage,
|
|
51
|
-
papersScope(["/w/papers/p", "/w/papers/q"], "/w"),
|
|
52
|
+
papersScope(["/w/papers/p", "/w/papers/q"], "/w", ["/w/papers"]),
|
|
52
53
|
),
|
|
53
54
|
).filter((g) => !FRAGMENT_FILES.includes(g));
|
|
55
|
+
// Beside the papers' own files, only each venue corpus's papers.json (corpus/record).
|
|
54
56
|
expect(
|
|
55
57
|
claimed.filter(
|
|
56
58
|
(g) => !g.startsWith("papers/p/") && !g.startsWith("papers/q/"),
|
|
57
59
|
),
|
|
58
|
-
).toEqual([]);
|
|
60
|
+
).toEqual(["papers/venues/*/papers.json"]);
|
|
59
61
|
expect(claimed).toContain("papers/q/paper.tex");
|
|
60
62
|
});
|
|
61
63
|
|
|
@@ -63,6 +65,7 @@ describe("the papers the config claims (#582)", () => {
|
|
|
63
65
|
const scope = papersScope(
|
|
64
66
|
["/w/papers/p", "/w/papers/[draft] x*", "/w"],
|
|
65
67
|
"/w",
|
|
68
|
+
["/w", "/w/[a]", "/x/papers", "/"],
|
|
66
69
|
);
|
|
67
70
|
expect(paperFiles(scope, "reviews/*.md")).toEqual([
|
|
68
71
|
"papers/p/reviews/*.md",
|
|
@@ -70,6 +73,12 @@ describe("the papers the config claims (#582)", () => {
|
|
|
70
73
|
"reviews/*.md",
|
|
71
74
|
]);
|
|
72
75
|
expect(paperFiles({ kind: "any" }, "paper.tex")).toEqual(["**/paper.tex"]);
|
|
76
|
+
// A papers root's corpora likewise; a root outside cwd has none ESLint could lint.
|
|
77
|
+
expect(corpusFiles(scope, "M.md")).toEqual([
|
|
78
|
+
"venues/*/M.md",
|
|
79
|
+
"\\[a\\]/venues/*/M.md",
|
|
80
|
+
]);
|
|
81
|
+
expect(corpusFiles({ kind: "any" }, "M.md")).toEqual(["**/venues/*/M.md"]);
|
|
73
82
|
});
|
|
74
83
|
});
|
|
75
84
|
|
|
@@ -101,9 +110,9 @@ describe("a paper's own settings read from its folder (#582)", () => {
|
|
|
101
110
|
const own = buildConfig(
|
|
102
111
|
{},
|
|
103
112
|
texLanguage,
|
|
104
|
-
papersScope(["/w/papers/a"], "/w"),
|
|
113
|
+
papersScope(["/w/papers/a"], "/w", []),
|
|
105
114
|
);
|
|
106
|
-
const scope = papersScope(["/w/papers/a"], "/w");
|
|
115
|
+
const scope = papersScope(["/w/papers/a"], "/w", []);
|
|
107
116
|
const block = (basePath: string) =>
|
|
108
117
|
narrowToOwners(
|
|
109
118
|
{ basePath, rules: { "paper/stages": "warn" } },
|
package/src/paper-files.ts
CHANGED
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
* - `files: [["a", "b"]]` matches a file only when BOTH patterns match.
|
|
42
42
|
*/
|
|
43
43
|
import { relative, sep } from "node:path";
|
|
44
|
+
import { CORPORA_DIR } from "./domain/corpus-record.ts";
|
|
44
45
|
import type {
|
|
45
46
|
ConfigBlock,
|
|
46
47
|
RuleBlock,
|
|
@@ -52,7 +53,8 @@ import type {
|
|
|
52
53
|
* Which papers' own files paperlint's blocks claim. `any` is the config's SHAPE, for the rule list and
|
|
53
54
|
* the docs: a file in any folder. `papers` is what `paperlint lint` runs on: the real papers, as glob
|
|
54
55
|
* prefixes relative to ESLint's `cwd` ("" for `cwd` itself), so a copy of a paper kept inside one (a
|
|
55
|
-
* review snapshot, a build copy) is claimed by no block (#582)
|
|
56
|
+
* review snapshot, a build copy) is claimed by no block (#582); and the papers roots (absolute),
|
|
57
|
+
* whose `venues/` hold the venue corpora.
|
|
56
58
|
*/
|
|
57
59
|
export type PaperScope =
|
|
58
60
|
| { readonly kind: "any" }
|
|
@@ -60,6 +62,7 @@ export type PaperScope =
|
|
|
60
62
|
readonly kind: "papers";
|
|
61
63
|
readonly cwd: string;
|
|
62
64
|
readonly prefixes: readonly string[];
|
|
65
|
+
readonly roots: readonly string[];
|
|
63
66
|
};
|
|
64
67
|
|
|
65
68
|
export const ANY_PAPER: PaperScope = { kind: "any" };
|
|
@@ -72,14 +75,16 @@ const literalGlob = (path: string): string =>
|
|
|
72
75
|
const posixRelative = (from: string, to: string): string =>
|
|
73
76
|
relative(from, to).split(sep).join("/");
|
|
74
77
|
|
|
75
|
-
/** The papers `dirs` under ESLint's `cwd`: the scope `paperlint lint` lints. Pure. */
|
|
78
|
+
/** The papers `dirs` and the papers `roots` under ESLint's `cwd`: the scope `paperlint lint` lints. Pure. */
|
|
76
79
|
export const papersScope = (
|
|
77
80
|
dirs: readonly string[],
|
|
78
81
|
cwd: string,
|
|
82
|
+
roots: readonly string[],
|
|
79
83
|
): PaperScope => ({
|
|
80
84
|
kind: "papers",
|
|
81
85
|
cwd,
|
|
82
86
|
prefixes: dirs.map((d) => literalGlob(posixRelative(cwd, d))),
|
|
87
|
+
roots,
|
|
83
88
|
});
|
|
84
89
|
|
|
85
90
|
/** A glob of a paper's own file (`paper.tex`, `reviews/*.md`) in each paper of `scope`. Pure. */
|
|
@@ -91,6 +96,22 @@ export const paperFiles = (
|
|
|
91
96
|
? [`**/${glob}`]
|
|
92
97
|
: scope.prefixes.map((p) => (p === "" ? glob : `${p}/${glob}`));
|
|
93
98
|
|
|
99
|
+
/**
|
|
100
|
+
* A glob of a file in each venue corpus, `<papers-root>/venues/<venue>/<glob>`; none for a root
|
|
101
|
+
* outside ESLint's `cwd`, whose files ESLint never lints. Pure.
|
|
102
|
+
*/
|
|
103
|
+
export const corpusFiles = (
|
|
104
|
+
scope: PaperScope,
|
|
105
|
+
glob: string,
|
|
106
|
+
): readonly string[] => {
|
|
107
|
+
const inCorpus = `${CORPORA_DIR}/*/${glob}`;
|
|
108
|
+
if (scope.kind === "any") return [`**/${inCorpus}`];
|
|
109
|
+
return scope.roots
|
|
110
|
+
.map((r) => posixRelative(scope.cwd, r))
|
|
111
|
+
.filter((r) => r !== ".." && !r.startsWith("../"))
|
|
112
|
+
.map((r) => (r === "" ? inCorpus : `${literalGlob(r)}/${inCorpus}`));
|
|
113
|
+
};
|
|
114
|
+
|
|
94
115
|
/**
|
|
95
116
|
* A glob relative to `cwd`, as the block whose `basePath` is `base` must write it — ESLint reads a
|
|
96
117
|
* block's patterns from its `basePath`, and a paper's own settings carry the paper's folder. None
|
|
@@ -230,7 +230,7 @@ describe("paperlint lint — the venue preset's rules", () => {
|
|
|
230
230
|
}),
|
|
231
231
|
});
|
|
232
232
|
const cfgOf = await import("./cli.ts").then((m) =>
|
|
233
|
-
m.paperRuleBlocks([join(root, "papers")]),
|
|
233
|
+
m.paperRuleBlocks([join(root, "papers")], [join(root, "papers")]),
|
|
234
234
|
);
|
|
235
235
|
expect(cfgOf.ok && cfgOf.value.preset).toEqual([
|
|
236
236
|
{
|
|
@@ -276,7 +276,7 @@ describe("paperlint lint — the paper over its preset, and the project's own pr
|
|
|
276
276
|
}),
|
|
277
277
|
});
|
|
278
278
|
const blocks = await import("./cli.ts").then((m) =>
|
|
279
|
-
m.paperRuleBlocks([join(root, "papers")]),
|
|
279
|
+
m.paperRuleBlocks([join(root, "papers")], [join(root, "papers")]),
|
|
280
280
|
);
|
|
281
281
|
// The preset's block comes first and the paper's own after it: the later block wins.
|
|
282
282
|
expect(blocks.ok && blocks.value.preset[0]?.rules).toEqual({
|