paperlint 20.7.0 → 20.9.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/revision-plan/index.d.ts +17 -0
- package/dist/adapters/revision-plan/index.d.ts.map +1 -0
- package/dist/adapters/revision-plan/index.js +168 -0
- package/dist/adapters/revision-plan/index.js.map +1 -0
- package/dist/domain/paper-layout.d.ts.map +1 -1
- package/dist/domain/paper-layout.js +4 -0
- package/dist/domain/paper-layout.js.map +1 -1
- package/dist/domain/revision-plan.d.ts +121 -0
- package/dist/domain/revision-plan.d.ts.map +1 -0
- package/dist/domain/revision-plan.js +15 -0
- package/dist/domain/revision-plan.js.map +1 -0
- package/dist/ports/revision-plan-codec.d.ts +7 -0
- package/dist/ports/revision-plan-codec.d.ts.map +1 -0
- package/dist/ports/revision-plan-codec.js +2 -0
- package/dist/ports/revision-plan-codec.js.map +1 -0
- package/dist/skill-chunks/{chunk-J5XYPERO.js → chunk-FOYA3JCS.js} +0 -6
- package/dist/skill-chunks/chunk-KCX34KV4.js +7610 -0
- package/dist/skill-chunks/{chunk-WYQTXKNM.js → chunk-KIKDPXE4.js} +2 -2
- package/dist/skill-chunks/{chunk-EDHTB7KT.js → chunk-MX3LJNFG.js} +4 -2
- package/dist/skill-chunks/chunk-UE2CAVD6.js +34 -0
- package/dist/skill-chunks/{chunk-QPWFSYJG.js → chunk-ZWJMR4TF.js} +5 -7
- package/dist/skills/paper-pipeline/scripts/revision-plan-core.d.ts +79 -0
- package/dist/skills/paper-pipeline/scripts/revision-plan.d.ts +2 -0
- package/docs/configuration.md +56 -0
- package/docs/layout.md +1 -0
- package/docs/rules/paper/allowed-files-only.md +1 -0
- package/package.json +2 -1
- package/scripts/bundle-skills.ts +1 -0
- package/scripts/revision-plan-schema.test.ts +39 -0
- package/scripts/revision-plan-schema.ts +17 -0
- package/skills/argument-arc/scripts/headings.js +3 -2
- package/skills/cold-read-diff/scripts/cold-read.js +3 -2
- package/skills/find-venue/SKILL.md +3 -2
- package/skills/find-venue/SKILL.md.spec.ts +2 -1
- package/skills/harden-paper/SKILL.md +5 -1
- package/skills/harden-paper/SKILL.md.spec.ts +4 -0
- package/skills/paper-pipeline/SKILL.md +29 -4
- package/skills/paper-pipeline/SKILL.md.spec.ts +28 -3
- package/skills/paper-pipeline/revision-plan.schema.json +619 -0
- package/skills/paper-pipeline/scripts/README.md +6 -5
- package/skills/paper-pipeline/scripts/extract-ref-facts.js +4 -3
- package/skills/paper-pipeline/scripts/revision-plan-core.js +194 -0
- package/skills/paper-pipeline/scripts/revision-plan-core.ts +286 -0
- package/skills/paper-pipeline/scripts/revision-plan.js +462 -0
- package/skills/paper-pipeline/scripts/revision-plan.test.ts +386 -0
- package/skills/paper-pipeline/scripts/revision-plan.ts +21 -0
- package/skills/paper-status/SKILL.md +2 -1
- package/skills/paper-status/SKILL.md.spec.ts +1 -0
- package/skills/pc-panel-review/SKILL.md +5 -2
- package/skills/pc-panel-review/SKILL.md.spec.ts +4 -1
- package/skills/pc-panel-review/pc-panel-review.harness.ts +122 -0
- package/skills/pc-panel-review/scripts/prior-reviews.js +11 -7031
- package/skills/study-accepted-papers/SKILL.md +5 -2
- package/skills/study-accepted-papers/SKILL.md.spec.ts +4 -1
- package/skills/study-accepted-papers/scripts/corpus-licences.js +1 -1
- package/skills/tighten-paper/SKILL.md +3 -2
- package/skills/tighten-paper/SKILL.md.spec.ts +2 -1
- package/skills/verify-citations/scripts/bib-authors.js +4 -3
- package/skills/verify-citations/scripts/verify-cites.js +4 -3
- package/src/adapters/revision-plan/index.test.ts +207 -0
- package/src/adapters/revision-plan/index.ts +236 -0
- package/src/adapters/revision-plan/schema.test.ts +69 -0
- package/src/domain/paper-layout.test.ts +1 -0
- package/src/domain/paper-layout.ts +4 -0
- package/src/domain/revision-plan.ts +127 -0
- package/src/ports/revision-plan-codec.ts +7 -0
|
@@ -5,7 +5,7 @@ context: fork
|
|
|
5
5
|
allowed-tools: [Read, Write, Edit, Grep, Glob, Bash, WebSearch, WebFetch, Agent]
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
-
<!-- vigiles:sha256:
|
|
8
|
+
<!-- vigiles:sha256:2c262b64bc221a8a compiled from skills/study-accepted-papers/SKILL.md.spec.ts -->
|
|
9
9
|
|
|
10
10
|
# study-accepted-papers — what this venue rewards, measured on its own papers
|
|
11
11
|
|
|
@@ -101,7 +101,10 @@ quotes verbatim with page numbers.
|
|
|
101
101
|
|
|
102
102
|
Score the paper against M1–M10 (`references/mechanisms.md`), with evidence as `file:line` in the paper
|
|
103
103
|
source. Every `fail` gets an owner and either a plan or an explicit **"accept ceiling"** with the
|
|
104
|
-
reason: a ceiling written down is a decision, a silent fail is a hole.
|
|
104
|
+
reason: a ceiling written down is a decision, a silent fail is a hole. When the paper has a
|
|
105
|
+
revision plan (`paper-pipeline`, "The revision plan"), a ceiling is proposed to the author as a
|
|
106
|
+
`dropped` row with `kind: "accepted-cap"`, and a lever as a finding in this run's report; neither is
|
|
107
|
+
written into the plan without his yes. Probabilities are a band, marked
|
|
105
108
|
as judgement, against the base rates of `references/base-rates.md`; simulated panels run hot.
|
|
106
109
|
|
|
107
110
|
## Where the results go — one home per fact
|
|
@@ -126,7 +126,10 @@ quotes verbatim with page numbers.
|
|
|
126
126
|
|
|
127
127
|
Score the paper against M1–M10 (\`references/mechanisms.md\`), with evidence as \`file:line\` in the paper
|
|
128
128
|
source. Every \`fail\` gets an owner and either a plan or an explicit **"accept ceiling"** with the
|
|
129
|
-
reason: a ceiling written down is a decision, a silent fail is a hole.
|
|
129
|
+
reason: a ceiling written down is a decision, a silent fail is a hole. When the paper has a
|
|
130
|
+
revision plan (\`paper-pipeline\`, "The revision plan"), a ceiling is proposed to the author as a
|
|
131
|
+
\`dropped\` row with \`kind: "accepted-cap"\`, and a lever as a finding in this run's report; neither is
|
|
132
|
+
written into the plan without his yes. Probabilities are a band, marked
|
|
130
133
|
as judgement, against the base rates of \`references/base-rates.md\`; simulated panels run hot.
|
|
131
134
|
|
|
132
135
|
## Where the results go — one home per fact
|
|
@@ -4,7 +4,7 @@ description: "Use when a paper \"feels long / bloated / overly complex / hard to
|
|
|
4
4
|
allowed-tools: [Read, Write, Edit, Grep, Glob, Agent]
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
<!-- vigiles:sha256:
|
|
7
|
+
<!-- vigiles:sha256:c6e6a7849bbd471e compiled from skills/tighten-paper/SKILL.md.spec.ts -->
|
|
8
8
|
|
|
9
9
|
# tighten-paper — the developmental edit
|
|
10
10
|
|
|
@@ -34,7 +34,8 @@ than shave a clause. A tighten pass performed inside a single section, under pre
|
|
|
34
34
|
counter, is not this skill; it is the damage this skill exists to undo.
|
|
35
35
|
|
|
36
36
|
If you are invoked while the author is still adding material, say so and decline the pass. The right
|
|
37
|
-
answer is "not yet", not a smaller cut.
|
|
37
|
+
answer is "not yet", not a smaller cut. Run `node ${CLAUDE_SKILL_DIR}/../paper-pipeline/scripts/revision-plan.js <paper-dir>` first (`paper-pipeline`, "The revision
|
|
38
|
+
plan"): `measurement: open` means material may still be added, so say so before cutting.
|
|
38
39
|
|
|
39
40
|
## 🏗 START WITH THE SHAPE — weigh every section before judging it
|
|
40
41
|
|
|
@@ -43,7 +43,8 @@ than shave a clause. A tighten pass performed inside a single section, under pre
|
|
|
43
43
|
counter, is not this skill; it is the damage this skill exists to undo.
|
|
44
44
|
|
|
45
45
|
If you are invoked while the author is still adding material, say so and decline the pass. The right
|
|
46
|
-
answer is "not yet", not a smaller cut.
|
|
46
|
+
answer is "not yet", not a smaller cut. Run \`node \${CLAUDE_SKILL_DIR}/../paper-pipeline/scripts/revision-plan.js <paper-dir>\` first (\`paper-pipeline\`, "The revision
|
|
47
|
+
plan"): \`measurement: open\` means material may still be added, so say so before cutting.
|
|
47
48
|
|
|
48
49
|
## 🏗 START WITH THE SHAPE — weigh every section before judging it
|
|
49
50
|
|
|
@@ -10,13 +10,14 @@ import {
|
|
|
10
10
|
bibliographyAt,
|
|
11
11
|
bibliographyUnreadWhy,
|
|
12
12
|
isMain
|
|
13
|
-
} from "../../../dist/skill-chunks/chunk-
|
|
13
|
+
} from "../../../dist/skill-chunks/chunk-KIKDPXE4.js";
|
|
14
14
|
import {
|
|
15
15
|
latexReader,
|
|
16
16
|
sourcesCodec
|
|
17
|
-
} from "../../../dist/skill-chunks/chunk-
|
|
18
|
-
import "../../../dist/skill-chunks/chunk-
|
|
17
|
+
} from "../../../dist/skill-chunks/chunk-MX3LJNFG.js";
|
|
18
|
+
import "../../../dist/skill-chunks/chunk-FOYA3JCS.js";
|
|
19
19
|
import "../../../dist/skill-chunks/chunk-Z5YMDZYW.js";
|
|
20
|
+
import "../../../dist/skill-chunks/chunk-ZWJMR4TF.js";
|
|
20
21
|
import {
|
|
21
22
|
absolutePath,
|
|
22
23
|
nodeFiles
|
|
@@ -11,13 +11,14 @@ import {
|
|
|
11
11
|
bibliographyUnreadWhy,
|
|
12
12
|
consumerContactEmail,
|
|
13
13
|
isMain
|
|
14
|
-
} from "../../../dist/skill-chunks/chunk-
|
|
14
|
+
} from "../../../dist/skill-chunks/chunk-KIKDPXE4.js";
|
|
15
15
|
import {
|
|
16
16
|
latexReader,
|
|
17
17
|
sourcesCodec
|
|
18
|
-
} from "../../../dist/skill-chunks/chunk-
|
|
19
|
-
import "../../../dist/skill-chunks/chunk-
|
|
18
|
+
} from "../../../dist/skill-chunks/chunk-MX3LJNFG.js";
|
|
19
|
+
import "../../../dist/skill-chunks/chunk-FOYA3JCS.js";
|
|
20
20
|
import "../../../dist/skill-chunks/chunk-Z5YMDZYW.js";
|
|
21
|
+
import "../../../dist/skill-chunks/chunk-ZWJMR4TF.js";
|
|
21
22
|
import {
|
|
22
23
|
absolutePath,
|
|
23
24
|
nodeFiles
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The parser of a paper's `revision-plan.json`: a valid plan becomes the value whole, and each planted
|
|
3
|
+
* defect is one problem at the path of its field.
|
|
4
|
+
*/
|
|
5
|
+
import { describe, expect, it } from "vitest";
|
|
6
|
+
import { PLAN, planText } from "../../../test/revision-plan-fixture.ts";
|
|
7
|
+
import { parseRevisionPlan, revisionPlanCodec } from "./index.ts";
|
|
8
|
+
|
|
9
|
+
/** The plan with `fields` set over its own; a field set to undefined is left out. */
|
|
10
|
+
const planWith = (fields: Readonly<Record<string, unknown>>): string =>
|
|
11
|
+
planText({ ...PLAN, ...fields });
|
|
12
|
+
|
|
13
|
+
/** The plan with row `i` replaced by `row`. */
|
|
14
|
+
const withRow = (i: number, row: Readonly<Record<string, unknown>>): string =>
|
|
15
|
+
planWith({ remaining: PLAN.remaining.map((r, k) => (k === i ? row : r)) });
|
|
16
|
+
|
|
17
|
+
const problems = (text: string) => {
|
|
18
|
+
const parsed = parseRevisionPlan(text);
|
|
19
|
+
return parsed.ok ? [] : parsed.problems;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const [R1, R2, R3, R4] = PLAN.remaining;
|
|
23
|
+
const ENOUGH = { kind: "enough", since: "2026-12-01" };
|
|
24
|
+
|
|
25
|
+
/** Plans the shape accepts beside the fixture: each other bar, measurement, state and finding id. */
|
|
26
|
+
const VALID: readonly (readonly [string, string])[] = [
|
|
27
|
+
[
|
|
28
|
+
"a corpus bar",
|
|
29
|
+
planWith({
|
|
30
|
+
bar: { kind: "corpus", series: "usenix-sec", editions: [2024, 2025] },
|
|
31
|
+
}),
|
|
32
|
+
],
|
|
33
|
+
[
|
|
34
|
+
"a proxy bar",
|
|
35
|
+
planWith({
|
|
36
|
+
bar: { kind: "proxy", series: "agent", stands_in_for: "a first edition" },
|
|
37
|
+
}),
|
|
38
|
+
],
|
|
39
|
+
[
|
|
40
|
+
"enough measured",
|
|
41
|
+
planWith({
|
|
42
|
+
measurement: { ...ENOUGH, evidence: "research/2026-12-01-bar.md" },
|
|
43
|
+
}),
|
|
44
|
+
],
|
|
45
|
+
["a row being done", withRow(1, { ...R2, state: "doing" })],
|
|
46
|
+
[
|
|
47
|
+
"a finding named by its id",
|
|
48
|
+
withRow(1, {
|
|
49
|
+
...R2,
|
|
50
|
+
from: { kind: "finding", file: "reviews/a.md", finding: "M2" },
|
|
51
|
+
}),
|
|
52
|
+
],
|
|
53
|
+
];
|
|
54
|
+
|
|
55
|
+
/** One planted defect each, and the path it is reported at. */
|
|
56
|
+
const DEFECTS: readonly (readonly [string, string, readonly unknown[]])[] = [
|
|
57
|
+
[
|
|
58
|
+
"a misspelt key, at the key",
|
|
59
|
+
planWith({ writen: "2026-11-25" }),
|
|
60
|
+
["writen"],
|
|
61
|
+
],
|
|
62
|
+
[
|
|
63
|
+
"a corpus bar without its series",
|
|
64
|
+
planWith({ bar: { kind: "corpus", editions: [2025] } }),
|
|
65
|
+
["bar", "series"],
|
|
66
|
+
],
|
|
67
|
+
[
|
|
68
|
+
"a corpus bar with no edition",
|
|
69
|
+
planWith({ bar: { kind: "corpus", series: "agent", editions: [] } }),
|
|
70
|
+
// The first edition is the one missing: `editions` is a tuple with a rest element.
|
|
71
|
+
["bar", "editions", 0],
|
|
72
|
+
],
|
|
73
|
+
["no bar, without why", planWith({ bar: { kind: "none" } }), ["bar", "why"]],
|
|
74
|
+
[
|
|
75
|
+
"a bar of no kind the shape names",
|
|
76
|
+
planWith({ bar: { kind: "measured" } }),
|
|
77
|
+
["bar", "kind"],
|
|
78
|
+
],
|
|
79
|
+
[
|
|
80
|
+
"enough measured, without the file that decided it",
|
|
81
|
+
planWith({ measurement: ENOUGH }),
|
|
82
|
+
["measurement", "evidence"],
|
|
83
|
+
],
|
|
84
|
+
[
|
|
85
|
+
"evidence above the paper folder",
|
|
86
|
+
planWith({ measurement: { ...ENOUGH, evidence: "../other/notes.md" } }),
|
|
87
|
+
["measurement", "evidence"],
|
|
88
|
+
],
|
|
89
|
+
[
|
|
90
|
+
"an absolute evidence path",
|
|
91
|
+
planWith({ measurement: { ...ENOUGH, evidence: "/home/notes.md" } }),
|
|
92
|
+
["measurement", "evidence"],
|
|
93
|
+
],
|
|
94
|
+
[
|
|
95
|
+
"a drive-qualified evidence path",
|
|
96
|
+
planWith({ measurement: { ...ENOUGH, evidence: "C:/outside/notes.md" } }),
|
|
97
|
+
["measurement", "evidence"],
|
|
98
|
+
],
|
|
99
|
+
[
|
|
100
|
+
"a finding file with a drive letter",
|
|
101
|
+
withRow(1, {
|
|
102
|
+
...R2,
|
|
103
|
+
from: { kind: "finding", file: "C:/reviews/a.md", finding: 3 },
|
|
104
|
+
}),
|
|
105
|
+
["remaining", 1, "from", "file"],
|
|
106
|
+
],
|
|
107
|
+
[
|
|
108
|
+
"a finding file with a backslash",
|
|
109
|
+
withRow(1, {
|
|
110
|
+
...R2,
|
|
111
|
+
from: { kind: "finding", file: "reviews\\a.md", finding: 3 },
|
|
112
|
+
}),
|
|
113
|
+
["remaining", 1, "from", "file"],
|
|
114
|
+
],
|
|
115
|
+
[
|
|
116
|
+
"a done row without evidence",
|
|
117
|
+
withRow(2, { ...R3, evidence: undefined }),
|
|
118
|
+
["remaining", 2, "evidence"],
|
|
119
|
+
],
|
|
120
|
+
[
|
|
121
|
+
"a dropped row without its kind",
|
|
122
|
+
withRow(3, { ...R4, kind: undefined }),
|
|
123
|
+
["remaining", 3, "kind"],
|
|
124
|
+
],
|
|
125
|
+
[
|
|
126
|
+
"a row with no origin",
|
|
127
|
+
withRow(1, { ...R2, from: undefined }),
|
|
128
|
+
["remaining", 1, "from"],
|
|
129
|
+
],
|
|
130
|
+
[
|
|
131
|
+
"a row with no date it was added",
|
|
132
|
+
withRow(1, { ...R2, added: "soon" }),
|
|
133
|
+
["remaining", 1, "added"],
|
|
134
|
+
],
|
|
135
|
+
[
|
|
136
|
+
"a row of no state the shape names",
|
|
137
|
+
withRow(1, { ...R2, state: "blocked" }),
|
|
138
|
+
["remaining", 1, "state"],
|
|
139
|
+
],
|
|
140
|
+
[
|
|
141
|
+
"a by-rule row naming no rule id",
|
|
142
|
+
withRow(0, { ...R1, rule: "required-section" }),
|
|
143
|
+
["remaining", 0, "rule"],
|
|
144
|
+
],
|
|
145
|
+
[
|
|
146
|
+
"a row id that is not R and a number",
|
|
147
|
+
withRow(1, { ...R2, id: "row-2" }),
|
|
148
|
+
["remaining", 1, "id"],
|
|
149
|
+
],
|
|
150
|
+
[
|
|
151
|
+
"a cycle that is no cycle id",
|
|
152
|
+
planWith({ cycle: "LangCode 2027" }),
|
|
153
|
+
["cycle"],
|
|
154
|
+
],
|
|
155
|
+
[
|
|
156
|
+
"a whitespace-only reason",
|
|
157
|
+
withRow(3, { ...R4, reason: " " }),
|
|
158
|
+
["remaining", 3, "reason"],
|
|
159
|
+
],
|
|
160
|
+
];
|
|
161
|
+
|
|
162
|
+
describe("parseRevisionPlan: a valid plan", () => {
|
|
163
|
+
it("🔴 parses into the whole value, every field kept", () => {
|
|
164
|
+
expect(revisionPlanCodec.parse(planText())).toEqual({
|
|
165
|
+
ok: true,
|
|
166
|
+
plan: PLAN,
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
it.each(VALID)("%s parses", (_name, text) => {
|
|
171
|
+
expect(problems(text)).toEqual([]);
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
describe("parseRevisionPlan: each defect at its field", () => {
|
|
176
|
+
it.each(DEFECTS)("%s", (_name, text, path) => {
|
|
177
|
+
expect(problems(text).map((p) => p.path)).toEqual([path]);
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
it("🔴 two rows with one id: the second, naming the first", () => {
|
|
181
|
+
expect(problems(withRow(1, { ...R2, id: "R1" }))).toEqual([
|
|
182
|
+
{
|
|
183
|
+
path: ["remaining", 1, "id"],
|
|
184
|
+
message: '"R1" is the id of row 1 too: each row has its own',
|
|
185
|
+
},
|
|
186
|
+
]);
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
it("a tag of no kind names the kinds it takes", () => {
|
|
190
|
+
expect(problems(planWith({ bar: { kind: "measured" } }))).toEqual([
|
|
191
|
+
{
|
|
192
|
+
path: ["bar", "kind"],
|
|
193
|
+
message: '"kind" is one of "corpus", "proxy", "none"',
|
|
194
|
+
},
|
|
195
|
+
]);
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
it("a field left out is missing, at its own path", () => {
|
|
199
|
+
expect(problems(planWith({ bar: { kind: "none" } }))).toEqual([
|
|
200
|
+
{ path: ["bar", "why"], message: "missing: the shape requires it here" },
|
|
201
|
+
]);
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
it("text that is not JSON: one problem at the top", () => {
|
|
205
|
+
expect(problems("{ cycle: ")).toEqual([{ path: [], message: "not JSON" }]);
|
|
206
|
+
});
|
|
207
|
+
});
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The schema of a paper's `revision-plan.json` — the one place its shape is checked
|
|
3
|
+
* (src/domain/revision-plan.ts). The text is parsed once, here, into the domain's `RevisionPlan`;
|
|
4
|
+
* whatever reads a plan after it never re-validates. The venue corpus's pattern
|
|
5
|
+
* (`src/adapters/venue-corpus/`): every object strict, each problem at the path of its field, and the
|
|
6
|
+
* JSON Schema generated from this parser rather than written beside it.
|
|
7
|
+
*/
|
|
8
|
+
import { z } from "zod";
|
|
9
|
+
import { CYCLE_ID_PATTERN, cycleId } from "../../domain/cycle.ts";
|
|
10
|
+
import { SERIES_ID } from "../../domain/edition.ts";
|
|
11
|
+
import { isInside } from "../../domain/study-registry.ts";
|
|
12
|
+
import {
|
|
13
|
+
DROP_KINDS,
|
|
14
|
+
ROW_ID_PATTERN,
|
|
15
|
+
ROW_STATES,
|
|
16
|
+
RULE_ID_PATTERN,
|
|
17
|
+
type ParsedPlan,
|
|
18
|
+
type PlanProblem,
|
|
19
|
+
type RevisionPlan,
|
|
20
|
+
} from "../../domain/revision-plan.ts";
|
|
21
|
+
import type { RevisionPlanCodec } from "../../ports/revision-plan-codec.ts";
|
|
22
|
+
|
|
23
|
+
const words = z.string().trim().min(1, "a non-empty text");
|
|
24
|
+
const date = z.iso.date();
|
|
25
|
+
|
|
26
|
+
// The pattern first, so the JSON Schema carries it; then the id, minted by the cycle's own function.
|
|
27
|
+
const cycle = z
|
|
28
|
+
.string()
|
|
29
|
+
.regex(
|
|
30
|
+
new RegExp(`^${CYCLE_ID_PATTERN}$`, "u"),
|
|
31
|
+
"a cycle id: lowercase words and digits joined by hyphens, as in `langcode-2027`",
|
|
32
|
+
)
|
|
33
|
+
.transform(cycleId);
|
|
34
|
+
|
|
35
|
+
const series = z
|
|
36
|
+
.string()
|
|
37
|
+
.regex(
|
|
38
|
+
SERIES_ID,
|
|
39
|
+
"a venue corpus's series: its folder under venues/, as in `usenix-sec`",
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
/** A file of the paper, relative to its folder: never absolute (`/…`, `C:…`) and never above it. */
|
|
43
|
+
const paperFile = z
|
|
44
|
+
.string()
|
|
45
|
+
.min(1, "a path relative to the paper folder")
|
|
46
|
+
.refine(
|
|
47
|
+
isInside,
|
|
48
|
+
"a path inside the paper folder: relative, with `/` between its parts, never above it",
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
/** A discriminated union whose unknown or missing tag names the tags it takes. */
|
|
52
|
+
const oneOf = <
|
|
53
|
+
const K extends string,
|
|
54
|
+
const O extends readonly [
|
|
55
|
+
z.core.$ZodTypeDiscriminable,
|
|
56
|
+
...z.core.$ZodTypeDiscriminable[],
|
|
57
|
+
],
|
|
58
|
+
>(
|
|
59
|
+
key: K,
|
|
60
|
+
tags: readonly string[],
|
|
61
|
+
options: O,
|
|
62
|
+
) =>
|
|
63
|
+
z.discriminatedUnion(key, options, {
|
|
64
|
+
error: `"${key}" is one of ${tags.map((t) => `"${t}"`).join(", ")}`,
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
/** A year a venue corpus covers. */
|
|
68
|
+
const edition = z.int().min(1900).max(2999);
|
|
69
|
+
|
|
70
|
+
const bar = oneOf(
|
|
71
|
+
"kind",
|
|
72
|
+
["corpus", "proxy", "none"],
|
|
73
|
+
[
|
|
74
|
+
z.strictObject({
|
|
75
|
+
kind: z.literal("corpus"),
|
|
76
|
+
series,
|
|
77
|
+
// A tuple with a rest element, not `.array().nonempty()`: zod 4 infers the latter as
|
|
78
|
+
// `number[]`, which the domain's `[number, ...number[]]` refuses.
|
|
79
|
+
editions: z.tuple([edition], edition, {
|
|
80
|
+
error: "at least one edition the corpus covers",
|
|
81
|
+
}),
|
|
82
|
+
}),
|
|
83
|
+
z.strictObject({
|
|
84
|
+
kind: z.literal("proxy"),
|
|
85
|
+
series,
|
|
86
|
+
stands_in_for: words,
|
|
87
|
+
}),
|
|
88
|
+
z.strictObject({ kind: z.literal("none"), why: words }),
|
|
89
|
+
],
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
const measurement = oneOf(
|
|
93
|
+
"kind",
|
|
94
|
+
["open", "enough"],
|
|
95
|
+
[
|
|
96
|
+
z.strictObject({ kind: z.literal("open") }),
|
|
97
|
+
z.strictObject({
|
|
98
|
+
kind: z.literal("enough"),
|
|
99
|
+
since: date,
|
|
100
|
+
evidence: paperFile,
|
|
101
|
+
}),
|
|
102
|
+
],
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
const source = oneOf(
|
|
106
|
+
"kind",
|
|
107
|
+
["author", "venue", "finding", "prior-reviews"],
|
|
108
|
+
[
|
|
109
|
+
z.strictObject({ kind: z.literal("author") }),
|
|
110
|
+
z.strictObject({ kind: z.literal("venue") }),
|
|
111
|
+
z.strictObject({
|
|
112
|
+
kind: z.literal("finding"),
|
|
113
|
+
file: paperFile,
|
|
114
|
+
finding: z.union([words, z.int().min(1)]),
|
|
115
|
+
}),
|
|
116
|
+
z.strictObject({ kind: z.literal("prior-reviews"), cycle }),
|
|
117
|
+
],
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
const base = {
|
|
121
|
+
id: z.string().regex(ROW_ID_PATTERN, "a row id: R and a number, as in `R3`"),
|
|
122
|
+
what: words,
|
|
123
|
+
from: source,
|
|
124
|
+
added: date,
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
const row = oneOf("state", ROW_STATES, [
|
|
128
|
+
z.strictObject({ ...base, state: z.enum(["todo", "doing"]) }),
|
|
129
|
+
z.strictObject({ ...base, state: z.literal("done"), evidence: words }),
|
|
130
|
+
z.strictObject({
|
|
131
|
+
...base,
|
|
132
|
+
state: z.literal("dropped"),
|
|
133
|
+
reason: words,
|
|
134
|
+
kind: z.enum(DROP_KINDS),
|
|
135
|
+
}),
|
|
136
|
+
z.strictObject({
|
|
137
|
+
...base,
|
|
138
|
+
state: z.literal("by-rule"),
|
|
139
|
+
rule: z
|
|
140
|
+
.string()
|
|
141
|
+
.regex(
|
|
142
|
+
RULE_ID_PATTERN,
|
|
143
|
+
"a rule id as `paperlint lint` reports it, as in `tex/required-section`",
|
|
144
|
+
),
|
|
145
|
+
}),
|
|
146
|
+
]);
|
|
147
|
+
|
|
148
|
+
/** The index of each id that occurs earlier in `ids`, with the index of its first. */
|
|
149
|
+
const repeats = (
|
|
150
|
+
ids: readonly string[],
|
|
151
|
+
): readonly (readonly [number, number])[] =>
|
|
152
|
+
ids.flatMap((v, i) => {
|
|
153
|
+
const first = ids.indexOf(v);
|
|
154
|
+
return first === i ? [] : [[i, first] as const];
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
const plan = z
|
|
158
|
+
.strictObject({
|
|
159
|
+
cycle,
|
|
160
|
+
written: date,
|
|
161
|
+
bar,
|
|
162
|
+
measurement,
|
|
163
|
+
remaining: z.array(row),
|
|
164
|
+
})
|
|
165
|
+
.superRefine((p, ctx) => {
|
|
166
|
+
repeats(p.remaining.map((r) => r.id)).forEach(([i, first]) => {
|
|
167
|
+
ctx.addIssue({
|
|
168
|
+
code: "custom",
|
|
169
|
+
path: ["remaining", i, "id"],
|
|
170
|
+
message: `"${String(p.remaining[i]?.id)}" is the id of row ${String(first + 1)} too: each row has its own`,
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
/** The JSON `text` holds, or undefined when it is not JSON. */
|
|
176
|
+
function jsonOf(text: string): unknown {
|
|
177
|
+
try {
|
|
178
|
+
return JSON.parse(text);
|
|
179
|
+
} catch {
|
|
180
|
+
return undefined;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* One zod issue as a problem. A misspelt key's path ends at the key (the first, when there are
|
|
186
|
+
* several), so a reader of the file lands on it rather than on the object holding it.
|
|
187
|
+
*/
|
|
188
|
+
const problemOf = (i: z.core.$ZodIssue): PlanProblem => ({
|
|
189
|
+
path: [
|
|
190
|
+
...i.path.filter((s) => typeof s !== "symbol"),
|
|
191
|
+
...(i.code === "unrecognized_keys" ? i.keys.slice(0, 1) : []),
|
|
192
|
+
],
|
|
193
|
+
message: i.message,
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
/** A `revision-plan.json`'s text, parsed once at the boundary: the plan, or every reason it is not one. */
|
|
197
|
+
export function parseRevisionPlan(text: string): ParsedPlan {
|
|
198
|
+
const json = jsonOf(text);
|
|
199
|
+
if (json === undefined)
|
|
200
|
+
return { ok: false, problems: [{ path: [], message: "not JSON" }] };
|
|
201
|
+
// A field left out is "missing", not zod's "expected string, received undefined".
|
|
202
|
+
const parsed = plan.safeParse(json, {
|
|
203
|
+
error: (i) =>
|
|
204
|
+
i.code === "invalid_type" && i.input === undefined
|
|
205
|
+
? "missing: the shape requires it here"
|
|
206
|
+
: undefined,
|
|
207
|
+
});
|
|
208
|
+
if (!parsed.success)
|
|
209
|
+
return { ok: false, problems: parsed.error.issues.map(problemOf) };
|
|
210
|
+
const value: RevisionPlan = parsed.data;
|
|
211
|
+
return { ok: true, plan: value };
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export const revisionPlanCodec: RevisionPlanCodec = {
|
|
215
|
+
parse: parseRevisionPlan,
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
/** Where the shipped JSON Schema of the plan sits, below the package root: in the skill that writes it. */
|
|
219
|
+
export const SCHEMA_FILE = "skills/paper-pipeline/revision-plan.schema.json";
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* The JSON Schema of a `revision-plan.json`, generated from the parser's own shape: what an editor
|
|
223
|
+
* completes and a skill reads instead of a hand-written table. Shipped as `SCHEMA_FILE`; a test holds
|
|
224
|
+
* the file to this. A schema cannot say that each row's id is unique or that a path stays inside the paper
|
|
225
|
+
* folder: `revision-plan/record` does.
|
|
226
|
+
*/
|
|
227
|
+
export const revisionPlanJsonSchema = (): unknown => ({
|
|
228
|
+
...z.toJSONSchema(plan, { io: "input", unrepresentable: "any" }),
|
|
229
|
+
title: "A paper's revision-plan.json",
|
|
230
|
+
description:
|
|
231
|
+
"The paper's revision plan for its current cycle: the accepted papers it is held against (bar), whether evidence is still being gathered (measurement), and the closed list of what remains (remaining). This schema lists the fields; it cannot express that each row's id is unique or that a path stays inside the paper folder, which the lint rule revision-plan/record checks with the rest.",
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
/** The shipped file's text: the schema, indented, with a closing newline. */
|
|
235
|
+
export const revisionPlanSchemaText = (): string =>
|
|
236
|
+
`${JSON.stringify(revisionPlanJsonSchema(), null, 2)}\n`;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The JSON Schema `paper-pipeline` ships for `revision-plan.json`: generated from the parser, so the
|
|
3
|
+
* fields an editor or a skill reads are the ones the plan is judged by.
|
|
4
|
+
*/
|
|
5
|
+
import Ajv from "ajv";
|
|
6
|
+
import { omit } from "remeda";
|
|
7
|
+
import { readFileSync } from "node:fs";
|
|
8
|
+
import { dirname, join } from "node:path";
|
|
9
|
+
import { fileURLToPath } from "node:url";
|
|
10
|
+
import { describe, expect, it } from "vitest";
|
|
11
|
+
import { z } from "zod";
|
|
12
|
+
import { PLAN } from "../../../test/revision-plan-fixture.ts";
|
|
13
|
+
import {
|
|
14
|
+
revisionPlanJsonSchema,
|
|
15
|
+
revisionPlanSchemaText,
|
|
16
|
+
SCHEMA_FILE,
|
|
17
|
+
} from "./index.ts";
|
|
18
|
+
|
|
19
|
+
describe("revisionPlanJsonSchema — the shipped schema file", () => {
|
|
20
|
+
const SHIPPED = join(
|
|
21
|
+
dirname(fileURLToPath(import.meta.url)),
|
|
22
|
+
"../../../",
|
|
23
|
+
SCHEMA_FILE,
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
it("🔴 is the generated schema, byte for byte", () => {
|
|
27
|
+
// Guards: the schema the skill points at never drifts from the parser that judges the plan.
|
|
28
|
+
expect(
|
|
29
|
+
readFileSync(SHIPPED, "utf8"),
|
|
30
|
+
`${SCHEMA_FILE} is stale: regenerate it with \`npm run schema:revision-plan\``,
|
|
31
|
+
).toBe(revisionPlanSchemaText());
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it("🔴 says the rule checks what a schema cannot, and names the plan's fields", () => {
|
|
35
|
+
const schema = z
|
|
36
|
+
.looseObject({
|
|
37
|
+
description: z.string(),
|
|
38
|
+
properties: z.looseObject({}),
|
|
39
|
+
})
|
|
40
|
+
.parse(revisionPlanJsonSchema());
|
|
41
|
+
expect(schema.description).toContain("revision-plan/record");
|
|
42
|
+
expect(Object.keys(schema.properties)).toEqual([
|
|
43
|
+
"cycle",
|
|
44
|
+
"written",
|
|
45
|
+
"bar",
|
|
46
|
+
"measurement",
|
|
47
|
+
"remaining",
|
|
48
|
+
]);
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* ajv 6 reads draft-07, so the 2020-12 `$schema` is left out, as an editor's draft-07 validator would
|
|
54
|
+
* read the file; every keyword the generated schema uses means the same in both.
|
|
55
|
+
*/
|
|
56
|
+
const schemaAccepts = (plan: unknown): boolean => {
|
|
57
|
+
const schema = omit(
|
|
58
|
+
z.looseObject({ $schema: z.string() }).parse(revisionPlanJsonSchema()),
|
|
59
|
+
["$schema"],
|
|
60
|
+
);
|
|
61
|
+
return new Ajv({ allErrors: true }).validate(schema, plan) === true;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
describe("revisionPlanJsonSchema — validates the valid plan", () => {
|
|
65
|
+
it("accepts the fixture plan", () => {
|
|
66
|
+
// Guards: the schema an editor reads never refuses a plan the parser takes.
|
|
67
|
+
expect(schemaAccepts(PLAN)).toBe(true);
|
|
68
|
+
});
|
|
69
|
+
});
|
|
@@ -90,6 +90,10 @@ export const ROOT_FILE_NOTES: readonly Noted[] = [
|
|
|
90
90
|
name: "SUBMIT-CHECKLIST.md",
|
|
91
91
|
note: "the venue's format and submission mechanics",
|
|
92
92
|
},
|
|
93
|
+
{
|
|
94
|
+
name: "revision-plan.json",
|
|
95
|
+
note: "the current cycle's bar and the closed list of what remains",
|
|
96
|
+
},
|
|
93
97
|
{ name: ".gitignore", note: "keeps the build's byproducts out of git" },
|
|
94
98
|
{ name: "paper.pdf", note: "the built PDF" },
|
|
95
99
|
];
|