paperlint 11.0.0 → 11.1.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 (76) hide show
  1. package/dist/adapters/hotcrp/index.d.ts +1 -1
  2. package/dist/adapters/hotcrp/index.d.ts.map +1 -1
  3. package/dist/adapters/hotcrp/index.js +1 -1
  4. package/dist/adapters/hotcrp/index.js.map +1 -1
  5. package/dist/adapters/hotcrp/portal.io.d.ts.map +1 -1
  6. package/dist/adapters/hotcrp/portal.io.js +17 -2
  7. package/dist/adapters/hotcrp/portal.io.js.map +1 -1
  8. package/dist/adapters/hotcrp/response.d.ts +7 -1
  9. package/dist/adapters/hotcrp/response.d.ts.map +1 -1
  10. package/dist/adapters/hotcrp/response.js +35 -3
  11. package/dist/adapters/hotcrp/response.js.map +1 -1
  12. package/dist/adapters/hotcrp/site.d.ts +1 -1
  13. package/dist/adapters/hotcrp/site.d.ts.map +1 -1
  14. package/dist/adapters/hotcrp/site.js +1 -2
  15. package/dist/adapters/hotcrp/site.js.map +1 -1
  16. package/dist/cli.d.ts.map +1 -1
  17. package/dist/cli.js +6 -1
  18. package/dist/cli.js.map +1 -1
  19. package/dist/domain/submission-fields.d.ts +77 -0
  20. package/dist/domain/submission-fields.d.ts.map +1 -0
  21. package/dist/domain/submission-fields.js +127 -0
  22. package/dist/domain/submission-fields.js.map +1 -0
  23. package/dist/domain/submission.d.ts +10 -0
  24. package/dist/domain/submission.d.ts.map +1 -1
  25. package/dist/domain/submission.js.map +1 -1
  26. package/dist/lib/paper-config.d.ts.map +1 -1
  27. package/dist/lib/paper-config.js +2 -0
  28. package/dist/lib/paper-config.js.map +1 -1
  29. package/dist/paper-settings.d.ts +5 -0
  30. package/dist/paper-settings.d.ts.map +1 -1
  31. package/dist/paper-settings.js +5 -2
  32. package/dist/paper-settings.js.map +1 -1
  33. package/dist/ports/submission-portal.d.ts +3 -1
  34. package/dist/ports/submission-portal.d.ts.map +1 -1
  35. package/dist/presets.d.ts +3 -0
  36. package/dist/presets.d.ts.map +1 -1
  37. package/dist/presets.js +3 -1
  38. package/dist/presets.js.map +1 -1
  39. package/dist/submission.d.ts +24 -5
  40. package/dist/submission.d.ts.map +1 -1
  41. package/dist/submission.js +140 -50
  42. package/dist/submission.js.map +1 -1
  43. package/dist/tex-requirements.d.ts +3 -0
  44. package/dist/tex-requirements.d.ts.map +1 -1
  45. package/dist/tex-requirements.js +30 -2
  46. package/dist/tex-requirements.js.map +1 -1
  47. package/docs/submission.md +29 -6
  48. package/lib/paper-config.ts +3 -0
  49. package/package.json +1 -1
  50. package/presets/msr.jsonc +66 -0
  51. package/presets/venue-profile.schema.json +41 -0
  52. package/skills/submission-portal/SKILL.md +51 -20
  53. package/skills/submission-portal/SKILL.md.spec.ts +50 -19
  54. package/src/adapters/hotcrp/cassette/README.md +7 -6
  55. package/src/adapters/hotcrp/cassette/get-searchcompletion.json +100 -0
  56. package/src/adapters/hotcrp/index.ts +1 -0
  57. package/src/adapters/hotcrp/portal.io.ts +22 -2
  58. package/src/adapters/hotcrp/portal.test.ts +103 -2
  59. package/src/adapters/hotcrp/response.ts +45 -4
  60. package/src/adapters/hotcrp/site.ts +2 -3
  61. package/src/cli.ts +6 -1
  62. package/src/domain/submission-fields.test.ts +183 -0
  63. package/src/domain/submission-fields.ts +190 -0
  64. package/src/domain/submission.ts +11 -0
  65. package/src/new-paper.test.ts +1 -0
  66. package/src/paper-settings.test.ts +6 -0
  67. package/src/paper-settings.ts +11 -3
  68. package/src/ports/submission-portal.ts +3 -0
  69. package/src/presets.ts +12 -2
  70. package/src/submission-fields-run.test.ts +247 -0
  71. package/src/submission-new.test.ts +4 -4
  72. package/src/submission-update.test.ts +7 -1
  73. package/src/submission.test.ts +1 -1
  74. package/src/submission.ts +207 -54
  75. package/src/tex-requirements.test.ts +21 -0
  76. package/src/tex-requirements.ts +67 -2
@@ -0,0 +1,190 @@
1
+ /**
2
+ * A VENUE'S OWN SUBMISSION FIELDS — what its portal's form asks beyond the title, the abstract, the
3
+ * authors and the PDF: topics, PC conflicts, a corresponding author …
4
+ *
5
+ * Two declarations, each in the file that owns the fact:
6
+ *
7
+ * venue preset `submission_fields` what the edition's form asks, as read: a kind per field
8
+ * paper `fields` what this paper answers
9
+ *
10
+ * The preset is DATA: it names a kind from the fixed set below, never a schema. The one schema of a
11
+ * paper's answers is built here from those kinds, so an unknown topic is refused before anything is
12
+ * sent — the portal itself would drop it without a word (HotCRP: measured 2026-10-20, a topic it
13
+ * does not know leaves `change_list` without `topics` and the submission with none).
14
+ */
15
+ import { z } from "zod";
16
+ import { err, ok, type Result } from "./result.ts";
17
+
18
+ /**
19
+ * The kinds a field can be, after the HotCRP form controls they stand for:
20
+ *
21
+ * checkboxes a list of option names (HotCRP's topics: `"Group: Topic"`, the group and the topic)
22
+ * text free text
23
+ * email an email address (a selector of authors that the API takes by email)
24
+ * pc_conflicts PC member's email → conflict type (`true` or a type name the portal checks)
25
+ */
26
+ export const FIELD_KINDS = [
27
+ "checkboxes",
28
+ "text",
29
+ "email",
30
+ "pc_conflicts",
31
+ ] as const;
32
+ export type FieldKind = (typeof FIELD_KINDS)[number];
33
+
34
+ /**
35
+ * The keys the submission object carries itself (`src/adapters/hotcrp/portal.io.ts`): a venue field
36
+ * of one of these names would be spread over it — `submission` would drop the PDF's upload.
37
+ */
38
+ export const RESERVED_FIELD_KEYS = [
39
+ "object",
40
+ "pid",
41
+ "title",
42
+ "abstract",
43
+ "authors",
44
+ "submission",
45
+ "status",
46
+ ] as const;
47
+
48
+ /** The first of `keys` that is reserved, or null. Pure. */
49
+ export const reservedKey = (keys: readonly string[]): string | null =>
50
+ keys.find((k) => RESERVED_FIELD_KEYS.some((r) => r === k)) ?? null;
51
+
52
+ /** One field of the form, as the preset records it. */
53
+ export interface FieldDeclaration {
54
+ readonly kind: FieldKind;
55
+ /** The form will not complete without it. */
56
+ readonly required: boolean;
57
+ /** The form's own label, when the API's key is not it. */
58
+ readonly label: string | null;
59
+ /** The choices, for `checkboxes`; empty for every other kind. */
60
+ readonly options: readonly string[];
61
+ }
62
+
63
+ /** A venue preset's `submission_fields`: the form's fields, and where and when they were read. */
64
+ export interface VenueFields {
65
+ /** `portal`: read through the portal's API; `form`: copied from its submission form. */
66
+ readonly source: "portal" | "form";
67
+ readonly url: string;
68
+ /** The day it was read, YYYY-MM-DD. */
69
+ readonly read: string;
70
+ /** The API's key → the field. */
71
+ readonly fields: Readonly<Record<string, FieldDeclaration>>;
72
+ }
73
+
74
+ /** A paper's answers, checked against its venue's fields: the API's key → the value to send. */
75
+ export type FieldValues = Readonly<Record<string, unknown>>;
76
+
77
+ const CONFLICT = z.union([z.literal(true), z.string().trim().min(1)]);
78
+
79
+ /** One field's value schema, from its kind. Pure. */
80
+ function valueSchema(d: FieldDeclaration): Readonly<z.ZodType> {
81
+ switch (d.kind) {
82
+ case "checkboxes":
83
+ return z
84
+ .array(
85
+ z.string().refine((v) => d.options.includes(v), {
86
+ error: (i) =>
87
+ `${JSON.stringify(i.input)} is not one of the form's options`,
88
+ }),
89
+ )
90
+ .min(d.required ? 1 : 0, {
91
+ error: "the form requires at least one",
92
+ })
93
+ .refine((l) => new Set(l).size === l.length, {
94
+ error: "an option is given twice",
95
+ });
96
+ case "text":
97
+ return z
98
+ .string()
99
+ .trim()
100
+ .min(d.required ? 1 : 0);
101
+ case "email":
102
+ return z.email();
103
+ case "pc_conflicts":
104
+ return z.record(z.email(), CONFLICT);
105
+ }
106
+ }
107
+
108
+ /** The schema of a paper's `fields` for these venue fields: every key declared, the required ones present. Pure. */
109
+ export const fieldValuesSchema = (
110
+ v: VenueFields,
111
+ ): Readonly<z.ZodType<FieldValues>> =>
112
+ z.strictObject(
113
+ Object.fromEntries(
114
+ Object.entries(v.fields).map(([key, d]) => {
115
+ const s = valueSchema(d);
116
+ return [key, d.required ? s : s.optional()];
117
+ }),
118
+ ),
119
+ );
120
+
121
+ const at = (path: readonly PropertyKey[]): string =>
122
+ path
123
+ .map((p) => (typeof p === "number" ? `[${String(p)}]` : `.${String(p)}`))
124
+ .join("");
125
+
126
+ /** The first problem of a refused `fields`, naming the key, and what the form offers when it is a choice. */
127
+ function problemOf(issue: z.core.$ZodIssue, v: VenueFields): string {
128
+ const key = issue.path[0];
129
+ const declared = typeof key === "string" ? v.fields[key] : undefined;
130
+ const offers =
131
+ declared !== undefined && declared.kind === "checkboxes"
132
+ ? ` — the form offers: ${declared.options.map((o) => JSON.stringify(o)).join(", ")}`
133
+ : "";
134
+ const known = Object.keys(v.fields).join(", ");
135
+ return issue.code === "unrecognized_keys"
136
+ ? `"fields" has ${issue.keys.map((k) => `"${k}"`).join(", ")}, which the venue's form does not ask (it asks: ${known})`
137
+ : `"fields"${at(issue.path)}: ${issue.message}${offers}`;
138
+ }
139
+
140
+ /**
141
+ * A paper's `fields` key, checked against its venue's form → the values to send, or one line saying
142
+ * what is wrong. Pure. A paper that gives none answers nothing: fine for a venue whose preset records
143
+ * no fields, refused when the venue's form requires one.
144
+ *
145
+ * @param raw the paper's `fields`, null when absent
146
+ * @param venue the venue preset's `submission_fields`; null when it records none
147
+ * @param where where the venue's fields were read from, for the message (the preset chain)
148
+ */
149
+ export function parsePaperFields(
150
+ raw: unknown,
151
+ venue: VenueFields | null,
152
+ where: string,
153
+ ): Result<FieldValues, string> {
154
+ if (venue === null)
155
+ return raw === null
156
+ ? ok({})
157
+ : err(
158
+ `"fields" is set, but the venue preset records no "submission_fields" (read: ${where}) — record the form's fields in the venue's preset first, or drop "fields"`,
159
+ );
160
+ const parsed = fieldValuesSchema(venue).safeParse(raw ?? {});
161
+ return parsed.success
162
+ ? ok(parsed.data)
163
+ : err(parsed.error.issues.map((i) => problemOf(i, venue)).join("; "));
164
+ }
165
+
166
+ /**
167
+ * The checkbox fields the paper sent that the portal did not take: sent non-empty, absent from the
168
+ * answer's changes, and named in a message of the portal's. That is a silent drop — the portal keeps
169
+ * an option it does not know as nothing. Pure.
170
+ */
171
+ export function droppedFields(
172
+ sent: FieldValues,
173
+ venue: VenueFields | null,
174
+ answer: {
175
+ readonly changes: readonly string[];
176
+ readonly messageFields: readonly (string | null)[];
177
+ },
178
+ ): readonly string[] {
179
+ if (venue === null) return [];
180
+ return Object.entries(sent)
181
+ .filter(
182
+ ([key, value]) =>
183
+ venue.fields[key]?.kind === "checkboxes" &&
184
+ Array.isArray(value) &&
185
+ value.length > 0 &&
186
+ !answer.changes.includes(key) &&
187
+ answer.messageFields.includes(key),
188
+ )
189
+ .map(([key]) => key);
190
+ }
@@ -12,6 +12,7 @@
12
12
  import { err, ok, type Result } from "./result.ts";
13
13
  import { isRecord } from "./record.ts";
14
14
  import type { Sha256 } from "./sha256.ts";
15
+ import type { FieldValues } from "./submission-fields.ts";
15
16
 
16
17
  /** The portal kinds an adapter exists for. Any other kind is refused by name. */
17
18
  export type PortalKind = "hotcrp";
@@ -100,6 +101,8 @@ export interface SubmissionChange {
100
101
  readonly abstract: string | null;
101
102
  /** Mark the submission submitted (ready for review). */
102
103
  readonly submit: boolean;
104
+ /** The venue's own form fields the paper answers, checked against the preset; empty sends none. */
105
+ readonly fields: FieldValues;
103
106
  }
104
107
 
105
108
  /** One message from the portal: its text, and the field it is about when it names one. */
@@ -207,6 +210,14 @@ export interface NewSubmission {
207
210
  readonly abstract: string;
208
211
  readonly authors: readonly Author[];
209
212
  readonly pdf: { readonly name: string; readonly bytes: Uint8Array };
213
+ /** The venue's own form fields the paper answers, checked against the preset; empty sends none. */
214
+ readonly fields: FieldValues;
215
+ }
216
+
217
+ /** What the portal lets an author read of its form's choices: only what an author's token can see. */
218
+ export interface PortalOptions {
219
+ /** The topics an author can choose, spelled as the portal takes them. */
220
+ readonly topics: readonly string[];
210
221
  }
211
222
 
212
223
  /** What the portal answered to a creation: an update's answer, and the id it chose when it saved. */
@@ -86,6 +86,7 @@ describe("paperlint new — paperlint.json", () => {
86
86
  talk: null,
87
87
  submission: null,
88
88
  authors: null,
89
+ fields: null,
89
90
  cycles: null,
90
91
  },
91
92
  });
@@ -34,6 +34,7 @@ describe("parsePaperSettings", () => {
34
34
  talk: null,
35
35
  submission: null,
36
36
  authors: null,
37
+ fields: null,
37
38
  cycles: null,
38
39
  },
39
40
  });
@@ -48,6 +49,7 @@ describe("parsePaperSettings", () => {
48
49
  talk: null,
49
50
  submission: null,
50
51
  authors: null,
52
+ fields: null,
51
53
  cycles: null,
52
54
  },
53
55
  });
@@ -65,6 +67,7 @@ describe("parsePaperSettings", () => {
65
67
  talk: null,
66
68
  submission: null,
67
69
  authors: null,
70
+ fields: null,
68
71
  cycles: null,
69
72
  },
70
73
  });
@@ -185,6 +188,7 @@ const UNSET = {
185
188
  talk: null,
186
189
  submission: null,
187
190
  authors: null,
191
+ fields: null,
188
192
  cycles: null,
189
193
  };
190
194
 
@@ -243,6 +247,7 @@ describe("readPaperSettings — the root paperlint.json's defaults, the paper's
243
247
  talk: null,
244
248
  submission: null,
245
249
  authors: null,
250
+ fields: null,
246
251
  cycles: null,
247
252
  });
248
253
  });
@@ -294,6 +299,7 @@ describe("paperRules — `rules` in paperlint.json", () => {
294
299
  talk: null,
295
300
  submission: null,
296
301
  authors: null,
302
+ fields: null,
297
303
  cycles: null,
298
304
  });
299
305
 
@@ -4,7 +4,7 @@
4
4
  * One file name at two levels, one schema (lib/paper-config.mjs → SETTINGS_KEYS):
5
5
  *
6
6
  * paperlint.json the project (optional): papersDir, rules, defaults
7
- * <paper>/paperlint.json this paper: { extends, kind, pdf, rules, identity, talk, submission, authors } —
7
+ * <paper>/paperlint.json this paper: { extends, kind, pdf, rules, identity, talk, submission, authors, fields } —
8
8
  * or `cycles`, from whose current attempt extends, kind and submission
9
9
  * are DERIVED (src/domain/cycle.ts); the two forms do not mix
10
10
  * a venue preset `paperlint:<name>` (shipped) or `./x.jsonc` (src/presets.ts)
@@ -73,6 +73,11 @@ export interface PaperSettings {
73
73
  readonly submission: PaperSubmission | null;
74
74
  /** The authors as the venue's portal should record them, in order; null when the paper declares none. Never the root's. */
75
75
  readonly authors: readonly Author[] | null;
76
+ /**
77
+ * The paper's answers to its venue's own form fields, as written: checked against the venue
78
+ * preset's `submission_fields` where both are known (`paperlint submission`); null when absent.
79
+ */
80
+ readonly fields: unknown;
76
81
  /**
77
82
  * The paper's attempts at venues and the current one, when the file declares `cycles`; null for a
78
83
  * file in the flat form. With cycles, `extends`, `kind` and `submission` above are the current
@@ -137,11 +142,11 @@ export function identityField(
137
142
  );
138
143
  }
139
144
 
140
- /** `rules` (checked for shape only), `talk`, `submission` and `authors`, each null when absent. */
145
+ /** `rules` (checked for shape only), `talk`, `submission` and `authors`, each null when absent; `fields` as written. */
141
146
  function rulesAndTalk(
142
147
  json: Readonly<Record<string, unknown>>,
143
148
  ): Result<
144
- Pick<PaperSettings, "rules" | "talk" | "submission" | "authors">,
149
+ Pick<PaperSettings, "rules" | "talk" | "submission" | "authors" | "fields">,
145
150
  string
146
151
  > {
147
152
  const rules = json["rules"];
@@ -160,6 +165,7 @@ function rulesAndTalk(
160
165
  talk: talk.value,
161
166
  submission: submission.value,
162
167
  authors: authors.value,
168
+ fields: json["fields"] ?? null,
163
169
  })
164
170
  : authors;
165
171
  }
@@ -334,6 +340,7 @@ function merge(
334
340
  talk: null,
335
341
  submission: null,
336
342
  authors: null,
343
+ fields: null,
337
344
  cycles: null,
338
345
  };
339
346
  const merged: PaperSettings = {
@@ -345,6 +352,7 @@ function merge(
345
352
  talk: p.talk,
346
353
  submission: p.submission,
347
354
  authors: p.authors,
355
+ fields: p.fields,
348
356
  cycles: p.cycles,
349
357
  };
350
358
  return paper === null && Object.values(merged).every((v) => v === null)
@@ -9,6 +9,7 @@ import type {
9
9
  CreateOutcome,
10
10
  NewSubmission,
11
11
  PortalFailure,
12
+ PortalOptions,
12
13
  SubmissionChange,
13
14
  SubmissionView,
14
15
  UpdateOutcome,
@@ -34,6 +35,8 @@ export interface SubmissionPortal {
34
35
  paper: NewSubmission,
35
36
  o: { readonly save: boolean },
36
37
  ): Promise<Result<CreateOutcome, PortalFailure>>;
38
+ /** What the form offers an author to choose: its topics. */
39
+ options(): Promise<Result<PortalOptions, PortalFailure>>;
37
40
  }
38
41
 
39
42
  /** How an author makes a token for a portal site, in the words the command prints. */
package/src/presets.ts CHANGED
@@ -26,7 +26,7 @@
26
26
  * format per key, the child wins; `kinds` by kind name, a child's kind replaces that kind
27
27
  * rules per rule id, the child wins; `ruleOrigins` keeps which file set each
28
28
  * template the child wins, with its `template_forbids`; so does `name`, and `required_sections`, `register`, `talk`,
29
- * `portal` and `deadlines` (each whole)
29
+ * `portal`, `deadlines` and `submission_fields` (each whole)
30
30
  * aliases union, with every `name` — what the venue is called along the chain
31
31
  *
32
32
  * ── THE ID AND THE LABEL ──────────────────────────────────────────────────────────
@@ -63,6 +63,7 @@ import { messageOf } from "./domain/text.ts";
63
63
  import type { RegisterAnchor } from "./domain/register.ts";
64
64
  import type { VenueTalk } from "./domain/talk.ts";
65
65
  import type { VenuePortal } from "./domain/submission.ts";
66
+ import type { VenueFields } from "./domain/submission-fields.ts";
66
67
  import type { Reading } from "./domain/deadline.ts";
67
68
 
68
69
  /** The prefix of a shipped preset's spec. */
@@ -129,6 +130,8 @@ export interface Preset {
129
130
  * workflow); empty when no file of the chain names any. A paper's current cycle derives them.
130
131
  */
131
132
  readonly deadlines: readonly Reading[];
133
+ /** The fields the edition's submission form asks (`paperlint submission`); null when no file of the chain records any. */
134
+ readonly submissionFields: VenueFields | null;
132
135
  }
133
136
 
134
137
  /** Why a spec does not resolve. */
@@ -300,6 +303,7 @@ const NOTHING_MERGED: Merging = {
300
303
  talk: null,
301
304
  portal: null,
302
305
  deadlines: [],
306
+ submissionFields: null,
303
307
  };
304
308
 
305
309
  /** The blocks a child replaces whole: the child's when it names one, else its parents'. Pure. */
@@ -308,13 +312,19 @@ const wholeBlocks = (
308
312
  p: PresetFile,
309
313
  ): Pick<
310
314
  Merging,
311
- "requiredSections" | "registerAnchors" | "talk" | "portal" | "deadlines"
315
+ | "requiredSections"
316
+ | "registerAnchors"
317
+ | "talk"
318
+ | "portal"
319
+ | "deadlines"
320
+ | "submissionFields"
312
321
  > => ({
313
322
  requiredSections: p.requiredSections ?? acc.requiredSections,
314
323
  registerAnchors: p.registerAnchors ?? acc.registerAnchors,
315
324
  talk: p.talk ?? acc.talk,
316
325
  portal: p.portal ?? acc.portal,
317
326
  deadlines: p.deadlines ?? acc.deadlines,
327
+ submissionFields: p.submissionFields ?? acc.submissionFields,
318
328
  });
319
329
 
320
330
  /** One file of the chain, `file`, merged over what its parents gave. Pure. */
@@ -0,0 +1,247 @@
1
+ /** `paperlint submission` with a venue whose preset records its form's own fields: checked, sent, a dropped option said. */
2
+ import { expect, test } from "vitest";
3
+ import { ok } from "./domain/result.ts";
4
+ import {
5
+ PAPER,
6
+ SITE,
7
+ PDF,
8
+ files,
9
+ fakePortal,
10
+ run,
11
+ SUBMISSION_FIELDS,
12
+ } from "../test/submission-fixtures.ts";
13
+
14
+ const FIELDS = {
15
+ topics: ["Group: Topic A"],
16
+ pc_conflicts: { "pc@example.org": "collaborator" },
17
+ ACMCorAut: "ada@example.org",
18
+ };
19
+
20
+ const paperWith = (fields: unknown) =>
21
+ files({
22
+ submissionFields: SUBMISSION_FIELDS,
23
+ paper: { extends: "../../venue.jsonc", submission: { id: 7 }, fields },
24
+ });
25
+
26
+ test("update: the paper's fields are checked and sent with the change, and printed first", async () => {
27
+ const portal = fakePortal({
28
+ update: ok({
29
+ httpStatus: 200,
30
+ valid: true,
31
+ changes: ["topics", "pc_conflicts", "ACM corresponding author"],
32
+ messages: [],
33
+ dryRun: true,
34
+ }),
35
+ });
36
+ const r = await run({ sub: "update" }, { files: paperWith(FIELDS), portal });
37
+ expect(r.code).toBe(0);
38
+ expect(r.seen[0]?.calls).toStrictEqual([
39
+ [
40
+ "update",
41
+ 7,
42
+ {
43
+ pdf: { name: "paper.pdf", bytes: PDF },
44
+ abstract: null,
45
+ submit: false,
46
+ fields: FIELDS,
47
+ },
48
+ { save: false },
49
+ ],
50
+ ]);
51
+ expect(r.out.slice(1, 4)).toStrictEqual([
52
+ 'field topics: ["Group: Topic A"]',
53
+ 'field pc_conflicts: {"pc@example.org":"collaborator"}',
54
+ 'field ACMCorAut: "ada@example.org"',
55
+ ]);
56
+ });
57
+
58
+ test("🔴 update: a topic the portal did not take — said, exit 1 (HotCRP drops an unknown one without an error)", async () => {
59
+ const portal = fakePortal({
60
+ update: ok({
61
+ httpStatus: 200,
62
+ valid: true,
63
+ changes: [],
64
+ messages: [
65
+ {
66
+ message: "At least one selection required",
67
+ field: "topics",
68
+ status: 2,
69
+ },
70
+ ],
71
+ dryRun: true,
72
+ }),
73
+ });
74
+ const r = await run({ sub: "update" }, { files: paperWith(FIELDS), portal });
75
+ expect(r.code).toBe(1);
76
+ expect(r.out.at(-1)).toBe(
77
+ 'NOT TAKEN topics: the portal kept none of ["Group: Topic A"] — an option it does not know is dropped without an error; `paperlint submission topics` lists what it offers',
78
+ );
79
+ });
80
+
81
+ test("🔴 a topic the venue's form does not offer: refused before anything is sent, exit 2", async () => {
82
+ const r = await run(
83
+ { sub: "update" },
84
+ { files: paperWith({ topics: ["Topic A"] }) },
85
+ );
86
+ expect(r.code).toBe(2);
87
+ expect(r.seen).toStrictEqual([]);
88
+ expect(r.errs).toStrictEqual([
89
+ `${PAPER}/paperlint.json: "fields".topics[0]: "Topic A" is not one of the form's options — the form offers: "Group: Topic A", "Topic B"`,
90
+ ]);
91
+ });
92
+
93
+ test("new: the fields go with the creation; the venue's fields the paper left out are named as still to do", async () => {
94
+ const fs = files({
95
+ submissionFields: SUBMISSION_FIELDS,
96
+ paper: {
97
+ extends: "../../venue.jsonc",
98
+ authors: [{ name: "Ada", email: "ada@example.org" }],
99
+ fields: { topics: ["Topic B"] },
100
+ },
101
+ extra: {
102
+ [`${PAPER}/paper.tex`]:
103
+ "\\title{T}\\begin{document}\\begin{abstract}An abstract.\\end{abstract}\\end{document}",
104
+ },
105
+ });
106
+ const portal = fakePortal({});
107
+ const r = await run({ sub: "new" }, { files: fs, portal });
108
+ expect(r.code).toBe(0);
109
+ const call = r.seen[0]?.calls[0];
110
+ expect(Array.isArray(call) ? call[1] : null).toMatchObject({
111
+ fields: { topics: ["Topic B"] },
112
+ });
113
+ expect(r.out).toContain('field topics: ["Topic B"]');
114
+ expect(r.out).toContain(
115
+ `still to do for ${SITE}/paper/<its number> — paperlint sent the title, the abstract, the authors and the PDF, and topics:`,
116
+ );
117
+ expect(r.out).toContain(
118
+ ` - answer pc_conflicts in the paper's paperlint.json "fields" (the venue preset records it), then: npx paperlint submission update papers/p (a dry run; --save after your yes)`,
119
+ );
120
+ });
121
+
122
+ test("topics: the portal's list against the preset's — agreeing exit 0, differing exit 1 with each difference marked", async () => {
123
+ const same = await run(
124
+ { sub: "topics" },
125
+ {
126
+ files: paperWith(undefined),
127
+ portal: fakePortal({
128
+ options: ok({ topics: ["Group: Topic A", "Topic B"] }),
129
+ }),
130
+ },
131
+ );
132
+ expect(same.code).toBe(0);
133
+ expect(same.out).toStrictEqual([
134
+ `topics on ${SITE}: 2; the preset records 2 (read 2026-10-20)`,
135
+ " ✓ Group: Topic A",
136
+ " ✓ Topic B",
137
+ ]);
138
+ const differs = await run(
139
+ { sub: "topics" },
140
+ {
141
+ files: paperWith(undefined),
142
+ portal: fakePortal({
143
+ options: ok({ topics: ["Group: Topic A", "Topic C"] }),
144
+ }),
145
+ },
146
+ );
147
+ expect(differs.code).toBe(1);
148
+ expect(differs.out).toStrictEqual([
149
+ `topics on ${SITE}: 2; the preset records 2 (read 2026-10-20)`,
150
+ " ✓ Group: Topic A",
151
+ " + not in the preset: Topic C",
152
+ " − in the preset, not offered: Topic B",
153
+ ]);
154
+ });
155
+
156
+ test("topics: a preset that records none — the portal's list, and what to record; exit 1", async () => {
157
+ const r = await run(
158
+ { sub: "topics" },
159
+ { portal: fakePortal({ options: ok({ topics: ["Topic B"] }) }) },
160
+ );
161
+ expect(r.code).toBe(1);
162
+ expect(r.out).toStrictEqual([
163
+ `topics on ${SITE}: 1`,
164
+ " Topic B",
165
+ 'the venue preset records no "submission_fields" with "topics" — record these, spelled as listed, before a paper can send any',
166
+ ]);
167
+ });
168
+
169
+ test("🔴 show and topics read past a paper's invalid fields — the commands that diagnose the drift", async () => {
170
+ const bad = paperWith({ topics: ["Topic A"] });
171
+ const shown = await run({ sub: "show" }, { files: bad });
172
+ expect(shown.code).toBe(0);
173
+ const topics = await run(
174
+ { sub: "topics" },
175
+ {
176
+ files: bad,
177
+ portal: fakePortal({
178
+ options: ok({ topics: ["Group: Topic A", "Topic B"] }),
179
+ }),
180
+ },
181
+ );
182
+ expect(topics.code).toBe(0);
183
+ });
184
+
185
+ test("🔴 update on a venue whose form requires a topic, the paper giving no fields: refused, nothing sent", async () => {
186
+ const r = await run({ sub: "update" }, { files: paperWith(undefined) });
187
+ expect(r.code).toBe(2);
188
+ expect(r.seen).toStrictEqual([]);
189
+ expect(r.errs[0]).toMatch(/paperlint\.json: "fields"\.topics: /);
190
+ });
191
+
192
+ test("🔴 new: a topic the portal did not take — said, and exit 1 even though it created the submission", async () => {
193
+ const fs = files({
194
+ submissionFields: SUBMISSION_FIELDS,
195
+ paper: {
196
+ extends: "../../venue.jsonc",
197
+ authors: [{ name: "Ada", email: "ada@example.org" }],
198
+ fields: { topics: ["Topic B"] },
199
+ },
200
+ extra: {
201
+ [`${PAPER}/paper.tex`]:
202
+ "\\title{T}\\begin{document}\\begin{abstract}An abstract.\\end{abstract}\\end{document}",
203
+ },
204
+ });
205
+ const portal = fakePortal({
206
+ create: ok({
207
+ httpStatus: 200,
208
+ valid: true,
209
+ changes: ["new", "title"],
210
+ messages: [
211
+ {
212
+ message: "At least one selection required",
213
+ field: "topics",
214
+ status: 2,
215
+ },
216
+ ],
217
+ dryRun: true,
218
+ id: null,
219
+ }),
220
+ });
221
+ const r = await run({ sub: "new" }, { files: fs, portal });
222
+ expect(r.code).toBe(1);
223
+ expect(r.out).toContain(
224
+ 'NOT TAKEN topics: the portal kept none of ["Topic B"] — an option it does not know is dropped without an error; `paperlint submission topics` lists what it offers',
225
+ );
226
+ });
227
+
228
+ test("topics: a writing flag is refused — topics reads", async () => {
229
+ const r = await run({ sub: "topics", save: true });
230
+ expect(r.code).toBe(2);
231
+ expect(r.errs).toStrictEqual([
232
+ "--save: only `submission new` and `submission update` change anything; `topics` reads",
233
+ ]);
234
+ });
235
+
236
+ test("topics: a failure in the portal's words, exit 1", async () => {
237
+ const r = await run(
238
+ { sub: "topics" },
239
+ {
240
+ portal: fakePortal({
241
+ options: { ok: false, error: { kind: "unreachable", detail: "down" } },
242
+ }),
243
+ },
244
+ );
245
+ expect(r.code).toBe(1);
246
+ expect(r.errs[0]).toBe("the portal cannot be reached: down");
247
+ });
@@ -21,6 +21,7 @@ import {
21
21
  DEFAULT_TEX,
22
22
  newFiles,
23
23
  WANT,
24
+ ON_THE_SITE,
24
25
  } from "../test/submission-fixtures.ts";
25
26
 
26
27
  test("new: a dry run by default — title from \\title, abstract from \\begin{abstract} with the author's macro expanded, the declared authors, the PDF", async () => {
@@ -40,9 +41,8 @@ test("new: a dry run by default — title from \\title, abstract from \\begin{ab
40
41
  "HTTP 200",
41
42
  "valid yes",
42
43
  "changes new, title, abstract, authors, submission",
43
- `do on the site, ${SITE}/paper/<its number> — paperlint sends only the title, the abstract, the authors and the PDF:`,
44
- " - PC conflicts (HotCRP's API takes them as pc_conflicts; paperlint does not send them)",
45
- " - topics, and every field the venue adds (paper type, artifact, consent boxes …)",
44
+ `still to do for ${SITE}/paper/<its number> — paperlint sent the title, the abstract, the authors and the PDF:`,
45
+ ON_THE_SITE,
46
46
  " - then mark it submitted: npx paperlint submission update papers/p --submit (a dry run; --save after your yes)",
47
47
  ]);
48
48
  // A dry run writes nothing.
@@ -67,7 +67,7 @@ test("new --save: the id the portal chose is written into paperlint.json, and `s
67
67
  `next npx paperlint submission show papers/p — it should say "match yes"`,
68
68
  ]);
69
69
  expect(r.out).toContain(
70
- `do on the site, ${SITE}/paper/42 — paperlint sends only the title, the abstract, the authors and the PDF:`,
70
+ `still to do for ${SITE}/paper/42 — paperlint sent the title, the abstract, the authors and the PDF:`,
71
71
  );
72
72
  const written = new TextDecoder().decode(
73
73
  fs.readBytes(absolutePath(`${PAPER}/paperlint.json`)) ?? new Uint8Array(),