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.
Files changed (64) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/dist/adapters/venue-corpus/index.d.ts +19 -3
  3. package/dist/adapters/venue-corpus/index.d.ts.map +1 -1
  4. package/dist/adapters/venue-corpus/index.js +36 -8
  5. package/dist/adapters/venue-corpus/index.js.map +1 -1
  6. package/dist/cli.d.ts +4 -3
  7. package/dist/cli.d.ts.map +1 -1
  8. package/dist/cli.js +42 -13
  9. package/dist/cli.js.map +1 -1
  10. package/dist/corpus-record-rule.d.ts +65 -0
  11. package/dist/corpus-record-rule.d.ts.map +1 -0
  12. package/dist/corpus-record-rule.js +85 -0
  13. package/dist/corpus-record-rule.js.map +1 -0
  14. package/dist/domain/corpus-record.d.ts +51 -0
  15. package/dist/domain/corpus-record.d.ts.map +1 -0
  16. package/dist/domain/corpus-record.js +119 -0
  17. package/dist/domain/corpus-record.js.map +1 -0
  18. package/dist/domain/venue-corpus.d.ts +36 -5
  19. package/dist/domain/venue-corpus.d.ts.map +1 -1
  20. package/dist/domain/venue-corpus.js +20 -0
  21. package/dist/domain/venue-corpus.js.map +1 -1
  22. package/dist/paper-files.d.ts +10 -3
  23. package/dist/paper-files.d.ts.map +1 -1
  24. package/dist/paper-files.js +17 -2
  25. package/dist/paper-files.js.map +1 -1
  26. package/dist/papers-roots.d.ts +6 -0
  27. package/dist/papers-roots.d.ts.map +1 -1
  28. package/dist/papers-roots.js +14 -0
  29. package/dist/papers-roots.js.map +1 -1
  30. package/docs/design/venue-corpus.md +62 -40
  31. package/docs/layout.md +2 -2
  32. package/docs/rules/corpus/record.md +122 -0
  33. package/docs/rules.md +1 -0
  34. package/docs/venues.md +35 -20
  35. package/eslint.config.mjs +1 -0
  36. package/package.json +2 -1
  37. package/scripts/eslint-file-length.mjs +3 -3
  38. package/skills/study-accepted-papers/SKILL.md +14 -8
  39. package/skills/study-accepted-papers/SKILL.md.spec.ts +13 -7
  40. package/skills/study-accepted-papers/papers.schema.json +50 -2
  41. package/skills/study-accepted-papers/scripts/corpus-licences-core.js +2 -2
  42. package/skills/study-accepted-papers/scripts/corpus-licences-core.ts +2 -1
  43. package/skills/study-accepted-papers/scripts/corpus-licences.js +39 -10
  44. package/skills/study-accepted-papers/scripts/corpus-licences.test.ts +5 -1
  45. package/src/adapters/venue-corpus/index.test.ts +81 -55
  46. package/src/adapters/venue-corpus/index.ts +42 -9
  47. package/src/adapters/venue-corpus/schema.test.ts +47 -0
  48. package/src/cli-e2e.test.mjs +2 -2
  49. package/src/cli.test.ts +1 -1
  50. package/src/cli.ts +57 -13
  51. package/src/corpus-record-rule.test.ts +229 -0
  52. package/src/corpus-record-rule.ts +175 -0
  53. package/src/domain/corpus-record.test.ts +163 -0
  54. package/src/domain/corpus-record.ts +210 -0
  55. package/src/domain/venue-corpus.test.ts +85 -0
  56. package/src/domain/venue-corpus.ts +59 -5
  57. package/src/paper-files.test.ts +13 -4
  58. package/src/paper-files.ts +23 -2
  59. package/src/paper-settings-commands.test.ts +2 -2
  60. package/src/papers-roots.test.ts +34 -1
  61. package/src/papers-roots.ts +15 -0
  62. package/src/rule-cases.test.ts +15 -0
  63. package/src/settled-paper.test.ts +1 -1
  64. package/src/unowned-file.test.ts +1 -1
@@ -60,6 +60,17 @@ var CORPUS_RECORD = "papers.json";
60
60
  var KNOWN_VERSIONS = ["published", "accepted", "preprint"];
61
61
  var PAPER_ID_KINDS = ["doi", "arxiv", "dblp", "s2", "url"];
62
62
  var KEY_PATTERN = /^[A-Za-z0-9][A-Za-z0-9_-]*$/u;
63
+ var pathText = (path) => path.length === 0 ? "(top)" : path.join(".");
64
+ var problemsText = (problems) => `${CORPUS_RECORD}: ${problems.map((p) => `${pathText(p.path)}: ${p.message}`).join("; ")}`;
65
+ var editionCountIssue = (edition2, papers) => {
66
+ const listed = papers.filter(
67
+ (p) => p.group !== "sister" && p.edition === edition2.edition
68
+ ).length;
69
+ const tally = `${String(listed)} papers of ${String(edition2.edition)} are listed`;
70
+ if (edition2.capped === null)
71
+ return listed === edition2.accepted ? null : `${tally} and ${String(edition2.accepted)} were accepted: list them all, or say in capped what was left out`;
72
+ return listed > edition2.accepted ? `${tally}, more than the ${String(edition2.accepted)} it accepted` : null;
73
+ };
63
74
 
64
75
  // src/adapters/venue-corpus/index.ts
65
76
  var words = external_exports.string().min(1);
@@ -156,11 +167,15 @@ var paper = external_exports.discriminatedUnion("group", [
156
167
  listed_from: webUrl
157
168
  })
158
169
  ]);
170
+ var count = external_exports.number().int().nonnegative();
171
+ var proxy = external_exports.strictObject({ what: words, papers: count });
159
172
  var edition = external_exports.strictObject({
160
173
  edition: year,
161
174
  listed_from: webUrl,
162
175
  read_on: date,
163
- accepted: external_exports.number().int().nonnegative().optional()
176
+ accepted: count,
177
+ capped: words.nullable(),
178
+ proxy: proxy.nullable()
164
179
  });
165
180
  var consistent = (r, ctx) => {
166
181
  const years = r.editions.map((e) => e.edition);
@@ -191,8 +206,19 @@ var consistent = (r, ctx) => {
191
206
  var record = external_exports.strictObject({
192
207
  venue: words,
193
208
  editions: external_exports.array(edition),
194
- papers: external_exports.array(paper)
195
- }).superRefine(consistent);
209
+ papers: external_exports.array(paper),
210
+ rebuild: external_exports.array(words)
211
+ }).superRefine(consistent).superRefine((r, ctx) => {
212
+ r.editions.forEach((e, i) => {
213
+ const message = editionCountIssue(e, r.papers);
214
+ if (message !== null)
215
+ ctx.addIssue({
216
+ code: "custom",
217
+ path: ["editions", i, "accepted"],
218
+ message
219
+ });
220
+ });
221
+ });
196
222
  function jsonOf(text) {
197
223
  try {
198
224
  return JSON.parse(text);
@@ -200,16 +226,19 @@ function jsonOf(text) {
200
226
  return void 0;
201
227
  }
202
228
  }
229
+ var problemOf = (i) => ({
230
+ path: [
231
+ ...i.path.filter((s) => typeof s !== "symbol"),
232
+ ...i.code === "unrecognized_keys" ? i.keys.slice(0, 1) : []
233
+ ],
234
+ message: i.message
235
+ });
203
236
  function parseVenueCorpus(text) {
204
237
  const json = jsonOf(text);
205
238
  if (json === void 0)
206
- return { ok: false, why: `${CORPUS_RECORD} is not JSON` };
239
+ return { ok: false, problems: [{ path: [], message: "not JSON" }] };
207
240
  const parsed = record.safeParse(json);
208
- if (parsed.success) return { ok: true, corpus: parsed.data };
209
- const reasons = parsed.error.issues.map(
210
- (i) => `${i.path.length === 0 ? "(top)" : i.path.join(".")}: ${i.message}`
211
- );
212
- return { ok: false, why: `${CORPUS_RECORD}: ${reasons.join("; ")}` };
241
+ return parsed.success ? { ok: true, corpus: parsed.data } : { ok: false, problems: parsed.error.issues.map(problemOf) };
213
242
  }
214
243
  var venueCorpusCodec = { parse: parseVenueCorpus };
215
244
 
@@ -358,7 +387,7 @@ function main(argv, deps, { out, err }) {
358
387
  }
359
388
  const parsed = deps.codec.parse(new TextDecoder().decode(bytes));
360
389
  if (!parsed.ok) {
361
- err(`corpus-licences: ${parsed.why}
390
+ err(`corpus-licences: ${problemsText(parsed.problems)}
362
391
  `);
363
392
  return 1;
364
393
  }
@@ -71,15 +71,19 @@ const record = (papers: readonly object[]) => ({
71
71
  edition: 2026,
72
72
  listed_from: "https://conf.researchr.org/home/icse-2026/agent-2026",
73
73
  read_on: "2026-11-03",
74
+ accepted: papers.length,
75
+ capped: null,
76
+ proxy: null,
74
77
  },
75
78
  ],
76
79
  papers,
80
+ rebuild: [],
77
81
  });
78
82
 
79
83
  /** The record parsed by the real codec, as the command reads it. */
80
84
  const corpus = (papers: readonly object[]): VenueCorpus => {
81
85
  const parsed = venueCorpusCodec.parse(JSON.stringify(record(papers)));
82
- if (!parsed.ok) throw new Error(parsed.why);
86
+ if (!parsed.ok) throw new Error(JSON.stringify(parsed.problems));
83
87
  return parsed.corpus;
84
88
  };
85
89
 
@@ -3,18 +3,13 @@
3
3
  * parses to itself with a paper row's extra fields kept, and every way a file can fail to be one is
4
4
  * refused with the zod path of each problem.
5
5
  */
6
- import { readFileSync } from "node:fs";
7
- import { dirname, join } from "node:path";
8
- import { fileURLToPath } from "node:url";
9
6
  import { describe, expect, it } from "vitest";
10
- import { z } from "zod";
11
- import type { Paper, VenueCorpus } from "../../domain/venue-corpus.ts";
12
7
  import {
13
- SCHEMA_FILE,
14
- venueCorpusCodec,
15
- venueCorpusJsonSchema,
16
- venueCorpusSchemaText,
17
- } from "./index.ts";
8
+ problemsText,
9
+ type Paper,
10
+ type VenueCorpus,
11
+ } from "../../domain/venue-corpus.ts";
12
+ import { venueCorpusCodec } from "./index.ts";
18
13
 
19
14
  const parse = venueCorpusCodec.parse;
20
15
 
@@ -47,10 +42,17 @@ const EDITION = {
47
42
  edition: 2026,
48
43
  listed_from: "https://conf.researchr.org/home/icse-2026/agent-2026",
49
44
  read_on: "2026-11-03",
50
- accepted: 27,
45
+ accepted: 1,
46
+ capped: null,
47
+ proxy: { what: "distinguished-paper award", papers: 1 },
51
48
  } as const;
52
49
 
53
- const RECORD = { venue: "agent", editions: [EDITION], papers: [PAPER] };
50
+ const RECORD = {
51
+ venue: "agent",
52
+ editions: [EDITION],
53
+ papers: [PAPER],
54
+ rebuild: ["node scripts/list-accepted.mjs agent 2026"],
55
+ };
54
56
 
55
57
  const text = (v: unknown): string => JSON.stringify(v);
56
58
  /** The record with its one paper replaced by `paper`. */
@@ -85,7 +87,7 @@ describe("parsing a papers.json", () => {
85
87
  });
86
88
 
87
89
  it("a sister paper names its venue, year and where it was found; an unknown copy stores under NOASSERTION", () => {
88
- const { edition, ...rest } = PAPER;
90
+ const { edition, ...rest } = { ...PAPER, key: "nlbse-2025-07" };
89
91
  const sister: Paper = {
90
92
  ...rest,
91
93
  group: "sister",
@@ -102,7 +104,7 @@ describe("parsing a papers.json", () => {
102
104
  },
103
105
  ],
104
106
  };
105
- const record: VenueCorpus = { ...RECORD, papers: [sister] };
107
+ const record: VenueCorpus = { ...RECORD, papers: [PAPER, sister] };
106
108
  // Guards: the sister shape and the unknown-origin copy are both representable.
107
109
  expect([edition, parse(text(record))]).toEqual([
108
110
  2026,
@@ -134,14 +136,32 @@ describe("a copy whose licence was never read", () => {
134
136
  corpus: { ...RECORD, papers: [{ ...PAPER, copies: [copy] }] },
135
137
  });
136
138
  });
139
+
140
+ it("🔴 the collection facts parse: what was capped, no proxy, no rebuild command", () => {
141
+ const facts = {
142
+ ...RECORD,
143
+ editions: [
144
+ EDITION,
145
+ {
146
+ ...EDITION,
147
+ edition: 2025,
148
+ capped: "the research track only, 100 of 312",
149
+ proxy: null,
150
+ },
151
+ ],
152
+ rebuild: [],
153
+ };
154
+ // Guards: each fact is a field, and "none" is null or an empty list.
155
+ expect(parse(text(facts))).toEqual({ ok: true, corpus: facts });
156
+ });
137
157
  });
138
158
 
139
159
  /** A file that is no record, and the reasons it is refused with. */
140
160
  const REFUSED: readonly (readonly [string, string, string])[] = [
141
161
  [
142
- "🔴 a misspelt key in a copy",
162
+ "🔴 a misspelt key in a copy, at the key",
143
163
  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"',
164
+ 'papers.0.copies.0.licence: Invalid input: expected object, received undefined; papers.0.copies.0.lisence: Unrecognized key: "lisence"',
145
165
  ],
146
166
  [
147
167
  "🔴 a copy without its licence object",
@@ -151,17 +171,17 @@ const REFUSED: readonly (readonly [string, string, string])[] = [
151
171
  [
152
172
  "🔴 a key two papers share",
153
173
  text({ ...RECORD, papers: [PAPER, { ...PAPER, title: "Other" }] }),
154
- 'papers.1.key: "2026-01" is the key of papers.0 too',
174
+ 'papers.1.key: "2026-01" is the key of papers.0 too; editions.0.accepted: 2 papers of 2026 are listed and 1 were accepted: list them all, or say in capped what was left out',
155
175
  ],
156
176
  [
157
177
  "a misspelt key at the top level",
158
178
  text({ ...RECORD, edtions: [] }),
159
- '(top): Unrecognized key: "edtions"',
179
+ 'edtions: Unrecognized key: "edtions"',
160
180
  ],
161
181
  [
162
182
  "a misspelt key in a licence",
163
183
  withCopy({ ...COPY, licence: { ...LICENCE, read_form: "x" } }),
164
- 'papers.0.copies.0.licence: Unrecognized key: "read_form"',
184
+ 'papers.0.copies.0.licence.read_form: Unrecognized key: "read_form"',
165
185
  ],
166
186
  [
167
187
  "a licence read from nowhere",
@@ -181,7 +201,7 @@ const REFUSED: readonly (readonly [string, string, string])[] = [
181
201
  [
182
202
  "a copy of unknown origin under a licence",
183
203
  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"',
204
+ 'papers.0.copies.0.licence.id: Invalid input: expected "NOASSERTION"; papers.0.copies.0.licence.read_from: Unrecognized keys: "read_from", "read_on"; papers.0.copies.0.url: Unrecognized key: "url"',
185
205
  ],
186
206
  [
187
207
  "a stored copy that does not say where its bytes came from",
@@ -201,7 +221,7 @@ const REFUSED: readonly (readonly [string, string, string])[] = [
201
221
  [
202
222
  "a paper of an edition the record does not list",
203
223
  withPaper({ ...PAPER, edition: 2025 }),
204
- "papers.0.edition: 2025 is not one of editions[].edition (2026)",
224
+ "papers.0.edition: 2025 is not one of editions[].edition (2026); editions.0.accepted: 0 papers of 2026 are listed and 1 were accepted: list them all, or say in capped what was left out",
205
225
  ],
206
226
  [
207
227
  "an edition listed twice",
@@ -216,7 +236,7 @@ const REFUSED: readonly (readonly [string, string, string])[] = [
216
236
  [
217
237
  "a misspelt id",
218
238
  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',
239
+ 'papers.0.ids.dio: Unrecognized key: "dio"; papers.0.ids: at least one of doi, arxiv, dblp, s2, url',
220
240
  ],
221
241
  [
222
242
  "a key that cannot name a file",
@@ -229,6 +249,26 @@ const REFUSED: readonly (readonly [string, string, string])[] = [
229
249
  withPaper({ ...PAPER, key: "2501.15919" }),
230
250
  "papers.0.key: a letter or digit, then letters, digits, '_' or '-'",
231
251
  ],
252
+ [
253
+ "🔴 an edition that leaves out how many it accepted and what was capped, and a proxy marking -1 papers",
254
+ text({
255
+ ...RECORD,
256
+ editions: [
257
+ {
258
+ ...EDITION,
259
+ accepted: undefined,
260
+ capped: undefined,
261
+ proxy: { what: "award", papers: -1 },
262
+ },
263
+ ],
264
+ }),
265
+ "editions.0.accepted: Invalid input: expected number, received undefined; editions.0.capped: Invalid input: expected string, received undefined; editions.0.proxy.papers: Too small: expected number to be >=0",
266
+ ],
267
+ [
268
+ "🔴 a record without its rebuild commands",
269
+ text({ ...RECORD, rebuild: undefined }),
270
+ "rebuild: Invalid input: expected array, received undefined",
271
+ ],
232
272
  ];
233
273
 
234
274
  describe("refusing what is not a papers.json", () => {
@@ -236,44 +276,30 @@ describe("refusing what is not a papers.json", () => {
236
276
  // Guards: a broken file is named as such, not parsed as an empty record.
237
277
  expect(parse("{ venue: agent")).toEqual({
238
278
  ok: false,
239
- why: "papers.json is not JSON",
279
+ problems: [{ path: [], message: "not JSON" }],
240
280
  });
241
281
  });
242
282
 
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.
283
+ it("🔴 each problem carries its path, a misspelt key's ending at the key", () => {
284
+ // Guards: `corpus/record` walks the path to the field it reports on.
258
285
  expect(
259
- readFileSync(SHIPPED, "utf8"),
260
- `${SCHEMA_FILE} is stale: regenerate it with \`npm run schema:venue-corpus\``,
261
- ).toBe(venueCorpusSchemaText());
286
+ parse(withPaper({ ...PAPER, ids: { doi: "10.1/x", dio: "10.1/x" } })),
287
+ ).toEqual({
288
+ ok: false,
289
+ problems: [
290
+ {
291
+ path: ["papers", 0, "ids", "dio"],
292
+ message: 'Unrecognized key: "dio"',
293
+ },
294
+ ],
295
+ });
262
296
  });
263
297
 
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
- ]);
298
+ it.each(REFUSED)("%s", (_name, file, why) => {
299
+ // Guards: the record is refused, and the reason names the path of every problem.
300
+ const parsed = parse(file);
301
+ expect(parsed.ok ? "parsed" : problemsText(parsed.problems)).toBe(
302
+ `papers.json: ${why}`,
303
+ );
278
304
  });
279
305
  });
@@ -16,16 +16,18 @@ import {
16
16
  STORED_KINDS,
17
17
  } from "../../domain/licence.ts";
18
18
  import {
19
- CORPUS_RECORD,
20
19
  KEY_PATTERN,
21
20
  KNOWN_VERSIONS,
22
21
  PAPER_ID_KINDS,
23
22
  type Copy,
24
23
  type Edition,
24
+ editionCountIssue,
25
25
  type Licence,
26
26
  type ParsedCorpus,
27
27
  type Paper,
28
28
  type PaperIds,
29
+ type CorpusProblem,
30
+ type StrongAcceptProxy,
29
31
  type VenueCorpus,
30
32
  } from "../../domain/venue-corpus.ts";
31
33
  import type { VenueCorpusCodec } from "../../ports/venue-corpus-codec.ts";
@@ -162,11 +164,18 @@ const paper = z.discriminatedUnion("group", [
162
164
  }),
163
165
  ]);
164
166
 
167
+ const count = z.number().int().nonnegative();
168
+
169
+ const proxy = z.strictObject({ what: words, papers: count });
170
+
171
+ // `capped` and `proxy` are required, and "none" is null: a fact left out is not a fact recorded.
165
172
  const edition = z.strictObject({
166
173
  edition: year,
167
174
  listed_from: webUrl,
168
175
  read_on: date,
169
- accepted: z.number().int().nonnegative().optional(),
176
+ accepted: count,
177
+ capped: words.nullable(),
178
+ proxy: proxy.nullable(),
170
179
  });
171
180
 
172
181
  /** Keys unique, editions unique, and every paper of this venue of a listed edition. */
@@ -205,8 +214,21 @@ const record = z
205
214
  venue: words,
206
215
  editions: z.array(edition),
207
216
  papers: z.array(paper),
217
+ rebuild: z.array(words),
208
218
  })
209
- .superRefine(consistent);
219
+ .superRefine(consistent)
220
+ .superRefine((r, ctx) => {
221
+ // Each edition's papers add up to what it accepted (the domain decides how).
222
+ r.editions.forEach((e, i) => {
223
+ const message = editionCountIssue(e, r.papers);
224
+ if (message !== null)
225
+ ctx.addIssue({
226
+ code: "custom",
227
+ path: ["editions", i, "accepted"],
228
+ message,
229
+ });
230
+ });
231
+ });
210
232
 
211
233
  // ── the schemas ARE the domain's types (as in the study registry's adapter) ──────────────────
212
234
 
@@ -229,6 +251,7 @@ type Same<A, B> =
229
251
  export type SchemasAreTheDomain = [
230
252
  Same<z.output<typeof record>, VenueCorpus>,
231
253
  Same<z.output<typeof edition>, Edition>,
254
+ Same<z.output<typeof proxy>, StrongAcceptProxy>,
232
255
  Same<z.output<typeof paper>, Paper>,
233
256
  Same<z.output<typeof copy>, Copy>,
234
257
  Same<z.output<typeof licence>, Licence>,
@@ -249,17 +272,27 @@ function jsonOf(text: string): unknown {
249
272
  }
250
273
  }
251
274
 
275
+ /**
276
+ * One zod issue as a problem. A misspelt key's path ends at the key (the first, when there are
277
+ * several), so a reader of the file lands on it rather than on the object holding it.
278
+ */
279
+ const problemOf = (i: z.core.$ZodIssue): CorpusProblem => ({
280
+ path: [
281
+ ...i.path.filter((s) => typeof s !== "symbol"),
282
+ ...(i.code === "unrecognized_keys" ? i.keys.slice(0, 1) : []),
283
+ ],
284
+ message: i.message,
285
+ });
286
+
252
287
  /** A `papers.json`'s text, parsed once at the boundary: the record, or every reason it is not one. */
253
288
  export function parseVenueCorpus(text: string): ParsedCorpus {
254
289
  const json = jsonOf(text);
255
290
  if (json === undefined)
256
- return { ok: false, why: `${CORPUS_RECORD} is not JSON` };
291
+ return { ok: false, problems: [{ path: [], message: "not JSON" }] };
257
292
  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("; ")}` };
293
+ return parsed.success
294
+ ? { ok: true, corpus: parsed.data }
295
+ : { ok: false, problems: parsed.error.issues.map(problemOf) };
263
296
  }
264
297
 
265
298
  export const venueCorpusCodec: VenueCorpusCodec = { parse: parseVenueCorpus };
@@ -0,0 +1,47 @@
1
+ /**
2
+ * The JSON Schema `study-accepted-papers` ships for `papers.json`: generated from the parser, so the
3
+ * fields an editor or a skill reads are the ones the record is judged by.
4
+ */
5
+ import { readFileSync } from "node:fs";
6
+ import { dirname, join } from "node:path";
7
+ import { fileURLToPath } from "node:url";
8
+ import { describe, expect, it } from "vitest";
9
+ import { z } from "zod";
10
+ import {
11
+ SCHEMA_FILE,
12
+ venueCorpusJsonSchema,
13
+ venueCorpusSchemaText,
14
+ } from "./index.ts";
15
+
16
+ describe("venueCorpusJsonSchema — the shipped schema file", () => {
17
+ const SHIPPED = join(
18
+ dirname(fileURLToPath(import.meta.url)),
19
+ "../../../",
20
+ SCHEMA_FILE,
21
+ );
22
+
23
+ it("🔴 is the generated schema, byte for byte", () => {
24
+ // Guards: the schema the skill points at never drifts from the parser that judges the record.
25
+ expect(
26
+ readFileSync(SHIPPED, "utf8"),
27
+ `${SCHEMA_FILE} is stale: regenerate it with \`npm run schema:venue-corpus\``,
28
+ ).toBe(venueCorpusSchemaText());
29
+ });
30
+
31
+ it("🔴 says the parser checks what a schema cannot, and names the record's fields", () => {
32
+ const schema = z
33
+ .looseObject({
34
+ description: z.string(),
35
+ properties: z.looseObject({}),
36
+ })
37
+ .parse(venueCorpusJsonSchema());
38
+ expect(schema.description).toContain("papers.json");
39
+ expect(schema.description).toContain("corpus-licences.js");
40
+ expect(Object.keys(schema.properties)).toEqual([
41
+ "venue",
42
+ "editions",
43
+ "papers",
44
+ "rebuild",
45
+ ]);
46
+ });
47
+ });
@@ -180,11 +180,11 @@ it("config is assembled, and consumer data gets through", async () => {
180
180
  const ruleBlocks = (c) => c.filter((b) => Array.isArray(b.files));
181
181
  check(
182
182
  "without a LaTeX language the config still gets built — a corpus with no .tex is not a reason to refuse",
183
- Array.isArray(cfg) && ruleBlocks(cfg).length === 3,
183
+ Array.isArray(cfg) && ruleBlocks(cfg).length === 4,
184
184
  );
185
185
  check(
186
186
  "with a LaTeX language two blocks are added: paper.tex, and the files it includes",
187
- ruleBlocks(buildConfig({}, {})).length === 5,
187
+ ruleBlocks(buildConfig({}, {})).length === 6,
188
188
  );
189
189
  check(
190
190
  "🔴 the project's paper TEMPLATE directory is ignored — flat config does not skip dot-directories",
package/src/cli.test.ts CHANGED
@@ -682,7 +682,7 @@ test("a paper's paperlint.json that does not parse stops the lint with its path"
682
682
  "p/paper.tex": "% P\n",
683
683
  "p/paperlint.json": "{ nope",
684
684
  });
685
- const r = paperRuleBlocks([join(dir, "p")]);
685
+ const r = paperRuleBlocks([join(dir, "p")], []);
686
686
  assert.equal(r.ok, false);
687
687
  assert.match(r.error, /^.*rules-broken\/p\/paperlint\.json: /);
688
688
  });