rungate 0.8.10 → 0.8.12
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/gates/.gate-salt +1 -1
- package/lib/config-readers.ts +30 -0
- package/lib/scaffold/ai-review-findings.ts +142 -2
- package/lib/scaffold/ai-review-step.ts +55 -4
- package/package.json +1 -1
- package/scripts/board-conformance.ts +65 -2
- package/scripts/board-snapshot.ts +10 -1
- package/scripts/plan-issues.ts +23 -3
package/gates/.gate-salt
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
0c470ba3039b3a05fb26683dbd8a3320accfa01e18c78aa33e014017a86366bf
|
package/lib/config-readers.ts
CHANGED
|
@@ -103,6 +103,36 @@ export function readBoardConfig(projectRoot: string): { projectId: string; crite
|
|
|
103
103
|
return { projectId, criteriaFieldId };
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
+
/**
|
|
107
|
+
* The label that marks an issue as being in the work queue, or `null`.
|
|
108
|
+
*
|
|
109
|
+
* **One binding, because the writer and the reading must not disagree.**
|
|
110
|
+
* `scripts/plan-issues.ts` applies it when it creates an issue and
|
|
111
|
+
* `scripts/board-conformance.ts`'s `queue-label` reading scores it, and
|
|
112
|
+
* before #1727 only the second knew the name. `--decompose --write` created
|
|
113
|
+
* seven issues on 2026-11-02 and the reading fell MET 12 of 12 → 5 of 12 on
|
|
114
|
+
* a command that never consulted it; the repair was seven `gh issue edit`
|
|
115
|
+
* calls by hand, which is what SC-2625 forbids.
|
|
116
|
+
*
|
|
117
|
+
* Spelling `"engine"` in the writer as well would have fixed that day and
|
|
118
|
+
* built the *two deciders that agree* shape — no behavioural case can tell
|
|
119
|
+
* them apart, and a mutation of either leaves the other holding every case
|
|
120
|
+
* up (`.claude/rules/checks-must-be-able-to-fail.md`).
|
|
121
|
+
*
|
|
122
|
+
* `null` for absent, blank or non-string, and callers must say UNMEASURED
|
|
123
|
+
* rather than substitute one: a tree that never configured a queue has not
|
|
124
|
+
* got an empty queue, it has no queue.
|
|
125
|
+
*/
|
|
126
|
+
export function readQueueLabel(projectRoot: string): string | null {
|
|
127
|
+
const config = tryLoadRungateConfig(projectRoot);
|
|
128
|
+
const board = (config as Record<string, unknown> | null)?.board;
|
|
129
|
+
if (!board || typeof board !== "object" || Array.isArray(board)) return null;
|
|
130
|
+
const raw = (board as Record<string, unknown>).queueLabel;
|
|
131
|
+
if (typeof raw !== "string") return null;
|
|
132
|
+
const label = raw.trim();
|
|
133
|
+
return label === "" ? null : label;
|
|
134
|
+
}
|
|
135
|
+
|
|
106
136
|
/**
|
|
107
137
|
* Pre-flight SSH hosts, keyed by name. `{}` when none are configured.
|
|
108
138
|
*
|
|
@@ -125,6 +125,7 @@ import {
|
|
|
125
125
|
AI_REVIEW_BLOCK_VERDICT,
|
|
126
126
|
AI_REVIEW_FINDING_FIELDS,
|
|
127
127
|
AI_REVIEW_FINDINGS_KEY,
|
|
128
|
+
AI_REVIEW_OPTIONAL_FINDING_FIELDS,
|
|
128
129
|
AI_REVIEW_OUTCOME_LINE,
|
|
129
130
|
AI_REVIEW_PASS_VERDICT,
|
|
130
131
|
AI_REVIEW_REQUIRED_EXIT,
|
|
@@ -140,6 +141,7 @@ export {
|
|
|
140
141
|
AI_REVIEW_BLOCK_VERDICT,
|
|
141
142
|
AI_REVIEW_FINDING_FIELDS,
|
|
142
143
|
AI_REVIEW_FINDINGS_KEY,
|
|
144
|
+
AI_REVIEW_OPTIONAL_FINDING_FIELDS,
|
|
143
145
|
AI_REVIEW_OUTCOME_LINE,
|
|
144
146
|
AI_REVIEW_PASS_VERDICT,
|
|
145
147
|
AI_REVIEW_SEVERITIES,
|
|
@@ -174,6 +176,107 @@ export function escapeAnnotation(value: unknown): string {
|
|
|
174
176
|
/** Annotation detail is capped: a megabyte of agent prose is not a message. */
|
|
175
177
|
export const AI_REVIEW_DETAIL_MAX = 300;
|
|
176
178
|
|
|
179
|
+
/** How many findings declared a class size, how many did not, and the total. */
|
|
180
|
+
export interface PopulationReading {
|
|
181
|
+
/** Findings carrying a readable population. */
|
|
182
|
+
declared: number;
|
|
183
|
+
/** Findings carrying none, or one this cannot read. UNMEASURED, not one. */
|
|
184
|
+
undeclared: number;
|
|
185
|
+
/** Instances claimed by the declared findings. Never includes a default. */
|
|
186
|
+
instances: number;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* One population value as a count, or `null`.
|
|
191
|
+
*
|
|
192
|
+
* ONE binding, so there is one thing to mutate and one place that decides
|
|
193
|
+
* what counts as a class size. `"3"`, `0`, `-1`, `1.5` and `true` are all
|
|
194
|
+
* things a model emits and none is a population; each returns `null` and the
|
|
195
|
+
* finding is UNMEASURED rather than contributing a number nobody measured.
|
|
196
|
+
*
|
|
197
|
+
* A string is refused rather than parsed on purpose. `duplicateOf` in
|
|
198
|
+
* `lib/filing-compliance.ts` went the other way for a good reason — it reads
|
|
199
|
+
* a ledger written by two writers over two days — but this field is being
|
|
200
|
+
* introduced now, with one producer and a contract, so accepting a second
|
|
201
|
+
* spelling on day one is how the contract stops meaning anything.
|
|
202
|
+
*/
|
|
203
|
+
function populationCount(value: unknown): number | null {
|
|
204
|
+
if (typeof value !== "number") return null;
|
|
205
|
+
return Number.isInteger(value) && value >= 1 ? value : null;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Did the reviewer say how big each defect class was?
|
|
210
|
+
*
|
|
211
|
+
* #1651's acceptance line is *"a finding payload carries the sibling sites it
|
|
212
|
+
* found, or states that it swept and found none"*, and this is the reading
|
|
213
|
+
* that makes it checkable. It judges nothing and blocks nothing — it reports,
|
|
214
|
+
* so the class instruction in `REVIEW.md` stops being prose with no
|
|
215
|
+
* instrument (`.claude/rules/checks-must-be-able-to-fail.md`).
|
|
216
|
+
*
|
|
217
|
+
* `declared + undeclared` is the payload size and `instances` is a different
|
|
218
|
+
* unit entirely. Do not add them, and do not render `instances` as though an
|
|
219
|
+
* undeclared finding contributed one to it.
|
|
220
|
+
*/
|
|
221
|
+
// The parameter is `reported` and not `findings` on purpose: AC-8a counts
|
|
222
|
+
// every `findings:` spelling across this module and `ai-review-step.ts` and
|
|
223
|
+
// requires exactly one, so that nothing reads the payload key except through
|
|
224
|
+
// `AI_REVIEW_FINDINGS_KEY`. A parameter name is indistinguishable from a key
|
|
225
|
+
// read to that census, and widening the census to exclude parameter names
|
|
226
|
+
// would weaken the check to buy a nicer identifier here.
|
|
227
|
+
/**
|
|
228
|
+
* #1651. The population reading, as the line a real run prints.
|
|
229
|
+
*
|
|
230
|
+
* `populationReading` without this was an instrument with no consumer — the
|
|
231
|
+
* aggregate existed, its tests passed, and no review run computed it. That is
|
|
232
|
+
* the defect this pull request describes, written into the fix for it, and it
|
|
233
|
+
* was caught on review rather than by me.
|
|
234
|
+
*
|
|
235
|
+
* Returns `null` for an empty payload, because "0 of 0 findings declared a
|
|
236
|
+
* class size" is not a reading anybody can act on and a notice on every clean
|
|
237
|
+
* review is a notice nobody reads.
|
|
238
|
+
*
|
|
239
|
+
* `instances` is printed only when something declared one, and it is NEVER
|
|
240
|
+
* added to the finding count: they are different units (see
|
|
241
|
+
* `PopulationReading`). An undeclared finding is reported as undeclared and
|
|
242
|
+
* contributes nothing — `.claude/rules/config-access.md`'s rule against
|
|
243
|
+
* substituting a default for a measurement nobody took.
|
|
244
|
+
*/
|
|
245
|
+
export function populationNotice(reported: readonly unknown[]): string | null {
|
|
246
|
+
if (reported.length === 0) return null;
|
|
247
|
+
const { declared, undeclared, instances } = populationReading(reported);
|
|
248
|
+
const head = `${declared} of ${reported.length} finding(s) declared how many instances their class has`;
|
|
249
|
+
const tail =
|
|
250
|
+
declared === 0
|
|
251
|
+
? ""
|
|
252
|
+
: `, covering ${instances} instance(s) in total`;
|
|
253
|
+
const rest =
|
|
254
|
+
undeclared === 0
|
|
255
|
+
? "."
|
|
256
|
+
: `. ${undeclared} did not, so for those the class size is UNMEASURED — not one. ` +
|
|
257
|
+
`REVIEW.md asks for the whole class in one finding; the cap counts classes, not instances.`;
|
|
258
|
+
return `${head}${tail}${rest}`;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
export function populationReading(reported: readonly unknown[]): PopulationReading {
|
|
262
|
+
let declared = 0;
|
|
263
|
+
let undeclared = 0;
|
|
264
|
+
let instances = 0;
|
|
265
|
+
for (const item of reported) {
|
|
266
|
+
const n =
|
|
267
|
+
item !== null && typeof item === "object"
|
|
268
|
+
? populationCount((item as Record<string, unknown>)[AI_REVIEW_FINDING_FIELDS.population])
|
|
269
|
+
: null;
|
|
270
|
+
if (n === null) {
|
|
271
|
+
undeclared++;
|
|
272
|
+
continue;
|
|
273
|
+
}
|
|
274
|
+
declared++;
|
|
275
|
+
instances += n;
|
|
276
|
+
}
|
|
277
|
+
return { declared, undeclared, instances };
|
|
278
|
+
}
|
|
279
|
+
|
|
177
280
|
/**
|
|
178
281
|
* One finding, rendered for an annotation — capped, naming file and summary.
|
|
179
282
|
*
|
|
@@ -210,7 +313,16 @@ export function renderFinding(
|
|
|
210
313
|
const line = `finding ${index} is ${String(finding[f.severity])} at ${where}: ${what}`;
|
|
211
314
|
const body =
|
|
212
315
|
line.length > AI_REVIEW_DETAIL_MAX ? `${line.slice(0, AI_REVIEW_DETAIL_MAX)}…` : line;
|
|
213
|
-
|
|
316
|
+
// The class size, AFTER the cap, for the same reason `tag` is: the finding
|
|
317
|
+
// whose class a reader most needs is the verbose one, and "this is 9 of a
|
|
318
|
+
// kind" truncated away reads as "this is one line". A finding that
|
|
319
|
+
// declared none renders nothing here — an invented "(1 instance)" is the
|
|
320
|
+
// default substitution `populationReading` exists to refuse.
|
|
321
|
+
const population = populationCount(finding[f.population]);
|
|
322
|
+
const sized = population === null
|
|
323
|
+
? body
|
|
324
|
+
: `${body} [${population} instance${population === 1 ? "" : "s"} of this shape]`;
|
|
325
|
+
return tag === null ? sized : `${sized} [${tag}]`;
|
|
214
326
|
}
|
|
215
327
|
|
|
216
328
|
/**
|
|
@@ -282,6 +394,16 @@ export const AI_REVIEW_SUPPRESSED_TITLE = "AI review repeats not reported again"
|
|
|
282
394
|
/** CRC-N4 (#1586). The history could not be compared — not "no repeats". */
|
|
283
395
|
export const AI_REVIEW_SUPPRESSED_UNMEASURED_TITLE = "AI review repeat check UNMEASURED";
|
|
284
396
|
|
|
397
|
+
/**
|
|
398
|
+
* #1651. How many of this round's findings said how big their class is.
|
|
399
|
+
*
|
|
400
|
+
* Its own title, for `AI_REVIEW_ADVISORY_TITLE`'s reason: this is not a
|
|
401
|
+
* finding and nobody has to act on it. It is the reading that tells us
|
|
402
|
+
* whether the class-naming instruction in `REVIEW.md` is being followed —
|
|
403
|
+
* which, before this, nothing anywhere computed.
|
|
404
|
+
*/
|
|
405
|
+
export const AI_REVIEW_POPULATION_TITLE = "AI review class sizes declared";
|
|
406
|
+
|
|
285
407
|
/**
|
|
286
408
|
* A stable identity for one finding, so an answer can name it.
|
|
287
409
|
*
|
|
@@ -502,12 +624,19 @@ export type AiReviewUnmeasuredReason =
|
|
|
502
624
|
* two reasons; a second check of it would be the fourth shape in
|
|
503
625
|
* `.claude/rules/checks-must-be-able-to-fail.md` — two deciders agreeing about
|
|
504
626
|
* one input, of which a mutation leaves either one holding the case up.
|
|
627
|
+
*
|
|
628
|
+
* `AI_REVIEW_OPTIONAL_FINDING_FIELDS` is subtracted rather than spelled out
|
|
629
|
+
* here. Optionality is a property of the contract, so it is declared once,
|
|
630
|
+
* beside the contract, and this module reads it — a second list of excluded
|
|
631
|
+
* names in this file would be a second decider about what a finding must
|
|
632
|
+
* carry, and the two would drift the first time either moved.
|
|
505
633
|
*/
|
|
506
634
|
export const AI_REVIEW_BLOCKING_REQUIRED_FIELDS: readonly string[] = Object.entries(
|
|
507
635
|
AI_REVIEW_FINDING_FIELDS,
|
|
508
636
|
)
|
|
509
637
|
.filter(([key]) => key !== "severity")
|
|
510
|
-
.map(([, name]) => name)
|
|
638
|
+
.map(([, name]) => name)
|
|
639
|
+
.filter(name => !AI_REVIEW_OPTIONAL_FINDING_FIELDS.includes(name));
|
|
511
640
|
|
|
512
641
|
/**
|
|
513
642
|
* The contract fields a blocking finding failed to supply, in contract order.
|
|
@@ -2230,6 +2359,17 @@ export function main(
|
|
|
2230
2359
|
console.log(`::notice title=${AI_REVIEW_ADVISORY_TITLE}::${escapeAnnotation(advisory)}`);
|
|
2231
2360
|
}
|
|
2232
2361
|
|
|
2362
|
+
// #1651's reading, on its own title. A `::notice`: it decides nothing and
|
|
2363
|
+
// `aiReviewExitCode` never sees it — an undeclared class size is a thing to
|
|
2364
|
+
// watch across rounds, not a reason to refuse a pull request today. Emitted
|
|
2365
|
+
// for EVERY round including a clean one with findings, because the whole
|
|
2366
|
+
// point is a series: a rate that only appears when it is bad is a rate
|
|
2367
|
+
// nobody can compare against anything.
|
|
2368
|
+
const population = populationNotice(reading.reported ?? []);
|
|
2369
|
+
if (population !== null) {
|
|
2370
|
+
console.log(`::notice title=${AI_REVIEW_POPULATION_TITLE}::${escapeAnnotation(population)}`);
|
|
2371
|
+
}
|
|
2372
|
+
|
|
2233
2373
|
// CRC-N4's reading, on its own title (#1586). A `::notice`, because a
|
|
2234
2374
|
// repeat that was dropped is the mechanism working and nothing about it
|
|
2235
2375
|
// is a problem with the pull request.
|
|
@@ -3808,8 +3808,42 @@ export const AI_REVIEW_FINDING_FIELDS = {
|
|
|
3808
3808
|
line: "line",
|
|
3809
3809
|
summary: "summary",
|
|
3810
3810
|
failureScenario: "failure_scenario",
|
|
3811
|
+
/**
|
|
3812
|
+
* How many instances of this defect's shape exist — #1651, CRC-N3.
|
|
3813
|
+
*
|
|
3814
|
+
* `REVIEW.md` has told the reviewer to name the CLASS since CRC-N3 landed,
|
|
3815
|
+
* and nothing read whether it did, so the instruction had no instrument
|
|
3816
|
+
* and could never be observed failing. This is where the answer goes.
|
|
3817
|
+
*
|
|
3818
|
+
* **Not required, and deliberately so.** A finding without it is
|
|
3819
|
+
* UNMEASURED about its class size, which `populationReading` counts and
|
|
3820
|
+
* names apart — never folded into 1, because "I swept and this is the only
|
|
3821
|
+
* one" and "I did not sweep" are the two readings this field exists to
|
|
3822
|
+
* separate, and defaulting collapses them at the one place it matters.
|
|
3823
|
+
*/
|
|
3824
|
+
population: "population",
|
|
3811
3825
|
} as const;
|
|
3812
3826
|
|
|
3827
|
+
/**
|
|
3828
|
+
* Members of the contract a finding may omit, declared HERE beside the
|
|
3829
|
+
* contract and nowhere else.
|
|
3830
|
+
*
|
|
3831
|
+
* `AI_REVIEW_BLOCKING_REQUIRED_FIELDS` derives the required set from
|
|
3832
|
+
* `AI_REVIEW_FINDING_FIELDS` minus `severity` (#1166), deliberately, so that
|
|
3833
|
+
* adding a member cannot leave the enforcement behind. Adding `population`
|
|
3834
|
+
* therefore made it REQUIRED on every blocking finding — which is wrong for
|
|
3835
|
+
* a field whose absence is a meaningful reading, and which turned 14 cases
|
|
3836
|
+
* red the moment it was added. That red is the derivation working.
|
|
3837
|
+
*
|
|
3838
|
+
* The fix is not a second exclusion list in the deriving module: optionality
|
|
3839
|
+
* is a property of the contract, so it is stated once, next to it, and the
|
|
3840
|
+
* derivation subtracts it. A name here that the contract does not declare is
|
|
3841
|
+
* refused by `test/finding-population.test.ts`.
|
|
3842
|
+
*/
|
|
3843
|
+
export const AI_REVIEW_OPTIONAL_FINDING_FIELDS: readonly string[] = [
|
|
3844
|
+
AI_REVIEW_FINDING_FIELDS.population,
|
|
3845
|
+
];
|
|
3846
|
+
|
|
3813
3847
|
/**
|
|
3814
3848
|
* The marker that carries a posted thread's identity, so a later round can
|
|
3815
3849
|
* ask the thread list whether a finding was already raised.
|
|
@@ -5797,15 +5831,32 @@ The payload is a single JSON object shaped exactly like this:
|
|
|
5797
5831
|
"${f.file}": "repo-relative path",
|
|
5798
5832
|
"${f.line}": 1,
|
|
5799
5833
|
"${f.summary}": "one sentence stating the defect",
|
|
5800
|
-
"${f.failureScenario}": "concrete inputs or state, then the wrong output"
|
|
5834
|
+
"${f.failureScenario}": "concrete inputs or state, then the wrong output",
|
|
5835
|
+
"${f.population}": 1
|
|
5801
5836
|
}
|
|
5802
5837
|
],
|
|
5803
5838
|
"${AI_REVIEW_VERDICT_KEY}": "${AI_REVIEW_VERDICTS.join(" or ")}"
|
|
5804
5839
|
}
|
|
5805
5840
|
|
|
5806
|
-
Every
|
|
5807
|
-
missing \`${f.file}\` or \`${f.summary}\` reaches a
|
|
5808
|
-
naming no code and no defect, which is the same
|
|
5841
|
+
Every member name above except \`${f.population}\` is required on every
|
|
5842
|
+
finding. A finding missing \`${f.file}\` or \`${f.summary}\` reaches a
|
|
5843
|
+
maintainer as an annotation naming no code and no defect, which is the same
|
|
5844
|
+
as not reporting it.
|
|
5845
|
+
|
|
5846
|
+
\`${f.population}\` is how many places have the shape you just described,
|
|
5847
|
+
counting the one you cited and the ones OUTSIDE the diff. Scope it to the
|
|
5848
|
+
PROPERTY and not to the spelling you matched: three unpaginated REST reads
|
|
5849
|
+
and two unpaginated GraphQL selections in one file are five, because they
|
|
5850
|
+
truncate for the same reason and the author fixes them in one edit.
|
|
5851
|
+
|
|
5852
|
+
It is the one optional member, and the only honest reason to omit it is that
|
|
5853
|
+
you did not sweep. Leave it off in that case — absent reads as unmeasured,
|
|
5854
|
+
which is true. Do not write \`1\` for a class you did not check: that says
|
|
5855
|
+
you looked and found nothing else, and a maintainer who believes it stops
|
|
5856
|
+
looking. The non-blocking cap counts CLASSES, so a finding carrying
|
|
5857
|
+
\`"${f.population}": 9\` costs the same one slot as a finding carrying 1 —
|
|
5858
|
+
there is never a reason to split a class across findings or to hold
|
|
5859
|
+
instances back for a later round.
|
|
5809
5860
|
|
|
5810
5861
|
On a finding whose severity BLOCKS, that requirement is now read back and
|
|
5811
5862
|
enforced: a blocking finding missing any of \`${f.file}\`, \`${f.line}\`,
|
package/package.json
CHANGED
|
@@ -102,6 +102,23 @@ export interface BoardSnapshot {
|
|
|
102
102
|
issues: BoardIssue[];
|
|
103
103
|
criteria: BoardCriterion[];
|
|
104
104
|
phases: BoardPhase[];
|
|
105
|
+
/**
|
|
106
|
+
* The project's work-queue label, carried as DATA rather than read here.
|
|
107
|
+
*
|
|
108
|
+
* It arrives on the snapshot for a mechanical reason as well as a design
|
|
109
|
+
* one. `test/board-conformance.test.ts` builds a mutant copy of this file
|
|
110
|
+
* in an `mkdtemp` directory, and a relative import makes that copy fail
|
|
111
|
+
* to load — which reads as a refusal on the merits and leaves every
|
|
112
|
+
* negative case witnessing nothing
|
|
113
|
+
* (`.claude/rules/self-referential-tests.md`). `scripts/board-snapshot.ts`
|
|
114
|
+
* already imports `readQueueLabel`, so the producer resolves it and this
|
|
115
|
+
* file stays import-free.
|
|
116
|
+
*
|
|
117
|
+
* **Absent means the producer never resolved one**, and `queue-label`
|
|
118
|
+
* goes UNMEASURED rather than counting 0 — same convention as
|
|
119
|
+
* {@link closedBlockers}.
|
|
120
|
+
*/
|
|
121
|
+
queueLabel?: string | null;
|
|
105
122
|
/**
|
|
106
123
|
* The CLOSED issues that at least one engine issue names as a blocker.
|
|
107
124
|
*
|
|
@@ -308,9 +325,27 @@ export const READINGS: readonly ReadingSpec[] = [
|
|
|
308
325
|
{
|
|
309
326
|
name: "queue-label",
|
|
310
327
|
item: "B6",
|
|
311
|
-
what: "every engine issue carries the
|
|
328
|
+
what: "every engine issue carries the queue label, so the queue is the label",
|
|
312
329
|
readsIssueRefs: false,
|
|
313
|
-
|
|
330
|
+
// The label is CONFIGURED, and this reading no longer knows its name on
|
|
331
|
+
// its own. Before #1727 it spelled `"engine"` and was the only thing
|
|
332
|
+
// that did, so `plan-issues --decompose --write` could create seven
|
|
333
|
+
// issues without it and take this reading MET 12 of 12 → 5 of 12 — a
|
|
334
|
+
// writer failing a reading it never consults. Both now go through
|
|
335
|
+
// `readQueueLabel`, so there is ONE answer to mutate rather than two
|
|
336
|
+
// that agree (`.claude/rules/checks-must-be-able-to-fail.md`).
|
|
337
|
+
unreadable: b =>
|
|
338
|
+
typeof b.queueLabel === "string" && b.queueLabel.trim() !== ""
|
|
339
|
+
? null
|
|
340
|
+
: "no queue label is in the snapshot — set `board.queueLabel` in .claude/rungate/config.json and " +
|
|
341
|
+
"re-take it. A tree that never named a queue has not got an empty one, so this is UNMEASURED " +
|
|
342
|
+
"rather than 0 of N.",
|
|
343
|
+
measure: b => {
|
|
344
|
+
// Non-null here: `unreadable` above refused every other case, and
|
|
345
|
+
// `takeReading` runs it first.
|
|
346
|
+
const label = b.queueLabel!;
|
|
347
|
+
return { measured: b.issues.filter(i => i.labels.includes(label)).length, target: b.issues.length };
|
|
348
|
+
},
|
|
314
349
|
},
|
|
315
350
|
];
|
|
316
351
|
|
|
@@ -538,12 +573,40 @@ export function readSnapshotText(text: string): SnapshotRead {
|
|
|
538
573
|
const closed = Array.isArray(raw.closedBlockers)
|
|
539
574
|
? { closedBlockers: raw.closedBlockers.filter((n): n is number => typeof n === "number") }
|
|
540
575
|
: {};
|
|
576
|
+
|
|
577
|
+
// TRIMMED here, which is the only place it can be. `readQueueLabel`
|
|
578
|
+
// trims at the config read, but that is the PRODUCER path — this function
|
|
579
|
+
// also accepts a hand-written or externally produced `--snapshot`, and
|
|
580
|
+
// copying `" engine "` through verbatim passed `unreadable` (non-blank
|
|
581
|
+
// after trim) and then had `measure` search issue labels for the literal
|
|
582
|
+
// `" engine "`, which no GitHub label can equal. The reading would have
|
|
583
|
+
// said 0 of N — a confident wrong number where UNMEASURED or the right
|
|
584
|
+
// count belonged. Found in review of #1727.
|
|
585
|
+
//
|
|
586
|
+
// Normalising at the boundary rather than re-trimming inside `measure`
|
|
587
|
+
// keeps ONE answer to *what is the label*: `unreadable` and `measure`
|
|
588
|
+
// then read the same bytes by construction, instead of two guards
|
|
589
|
+
// agreeing to trim and a third one later forgetting.
|
|
590
|
+
//
|
|
591
|
+
// `queueLabel` is carried the same way as `closedBlockers`, for the same
|
|
592
|
+
// reason — #1727.
|
|
593
|
+
// This function rebuilds the board from a NAMED list of fields rather
|
|
594
|
+
// than spreading `raw`, so a key nobody adds here is silently dropped on
|
|
595
|
+
// EVERY path: `--snapshot` as well as `--produce`. The producer wrote
|
|
596
|
+
// the label, the reading never saw it, and `queue-label` reported
|
|
597
|
+
// UNMEASURED against a snapshot that carried exactly what it asked for.
|
|
598
|
+
//
|
|
599
|
+
// Present-only, like `closedBlockers`: absence is the signal the reading
|
|
600
|
+
// reports on, so writing the key unconditionally would make a tree that
|
|
601
|
+
// never configured a queue indistinguishable from one that did.
|
|
602
|
+
const queue = typeof raw.queueLabel === "string" ? { queueLabel: raw.queueLabel.trim() } : {};
|
|
541
603
|
return {
|
|
542
604
|
board: {
|
|
543
605
|
issues: issues as BoardIssue[],
|
|
544
606
|
criteria: criteria as BoardCriterion[],
|
|
545
607
|
phases: phases as BoardPhase[],
|
|
546
608
|
...closed,
|
|
609
|
+
...queue,
|
|
547
610
|
},
|
|
548
611
|
why: null,
|
|
549
612
|
};
|
|
@@ -37,7 +37,7 @@ import { isAbsolute, join } from "path";
|
|
|
37
37
|
import { parseArgs } from "util";
|
|
38
38
|
import { openFrontier, phaseOf } from "../lib/board-mirror";
|
|
39
39
|
import { createGitHubClient, listMilestones } from "../lib/github";
|
|
40
|
-
import { readBoardConfig } from "../lib/config-readers";
|
|
40
|
+
import { readBoardConfig, readQueueLabel } from "../lib/config-readers";
|
|
41
41
|
import {
|
|
42
42
|
inMilestoneFamily,
|
|
43
43
|
readIssueStates,
|
|
@@ -190,6 +190,14 @@ export interface ProducedSnapshot {
|
|
|
190
190
|
* has a resolved edge.
|
|
191
191
|
*/
|
|
192
192
|
closedBlockers: number[];
|
|
193
|
+
/**
|
|
194
|
+
* The work-queue label from `board.queueLabel`, or `null` when the
|
|
195
|
+
* project configures none. Resolved HERE because `board-conformance`
|
|
196
|
+
* must stay free of relative imports — its mutation battery copies it
|
|
197
|
+
* into an `mkdtemp` and a relative import makes the mutant fail to load
|
|
198
|
+
* (`.claude/rules/self-referential-tests.md`).
|
|
199
|
+
*/
|
|
200
|
+
queueLabel: string | null;
|
|
193
201
|
/**
|
|
194
202
|
* The spec's criteria, and what the board says about each — item **B2**.
|
|
195
203
|
*
|
|
@@ -449,6 +457,7 @@ export async function main(argv: string[], gh: BoardSnapshotGitHub = LIVE_GITHUB
|
|
|
449
457
|
phases: actions.map(a => ({ phase: a.phase, criteria: a.criteria, milestoneState: a.action })),
|
|
450
458
|
issues: snapshotIssues,
|
|
451
459
|
closedBlockers: [...named].sort((a, b) => a - b),
|
|
460
|
+
queueLabel: readQueueLabel(root),
|
|
452
461
|
criteria: criterionCoverage(content, snapshotIssues, columnRead),
|
|
453
462
|
};
|
|
454
463
|
|
package/scripts/plan-issues.ts
CHANGED
|
@@ -40,6 +40,7 @@ import {
|
|
|
40
40
|
} from "../lib/issue-repair";
|
|
41
41
|
import type { RepairRow } from "../lib/issue-repair";
|
|
42
42
|
import { parseDecompositionPlan, planDecomposition } from "../lib/issue-decomposition";
|
|
43
|
+
import { readQueueLabel } from "../lib/config-readers";
|
|
43
44
|
|
|
44
45
|
/**
|
|
45
46
|
* THE one non-zero exit. One site, so `test/plan-issues.test.ts` can build a
|
|
@@ -165,7 +166,14 @@ export interface DecomposeGitHub {
|
|
|
165
166
|
milestones: (repo: string) => Promise<Set<string>>;
|
|
166
167
|
create: (
|
|
167
168
|
repo: string,
|
|
168
|
-
|
|
169
|
+
/**
|
|
170
|
+
* `label` is the work-queue label from `readQueueLabel`, or `null` when
|
|
171
|
+
* the project configures none. It is part of CREATION rather than a
|
|
172
|
+
* later edit because #1727 is what a later edit looks like: seven
|
|
173
|
+
* issues arrived on 2026-11-02 without it and `queue-label` fell MET
|
|
174
|
+
* 12 of 12 → 5 of 12, repaired by seven `gh issue edit` calls by hand.
|
|
175
|
+
*/
|
|
176
|
+
issue: { title: string; body: string; milestone: string | null; label: string | null },
|
|
169
177
|
) => Promise<number>;
|
|
170
178
|
addBlockedBy: (repo: string, blocked: number, blocker: number) => Promise<void>;
|
|
171
179
|
/**
|
|
@@ -244,6 +252,7 @@ const LIVE_DECOMPOSE: DecomposeGitHub = {
|
|
|
244
252
|
create: async (repo, issue) => {
|
|
245
253
|
const args = ["issue", "create", "--repo", repo, "--title", issue.title, "--body-file", "-"];
|
|
246
254
|
if (issue.milestone !== null) args.push("--milestone", issue.milestone);
|
|
255
|
+
if (issue.label !== null) args.push("--label", issue.label);
|
|
247
256
|
const url = gh(args, issue.body).trim();
|
|
248
257
|
const n = Number(url.split("/").pop());
|
|
249
258
|
// A URL whose last segment is not a number means `gh` printed something
|
|
@@ -329,6 +338,12 @@ async function decompose(
|
|
|
329
338
|
write: boolean,
|
|
330
339
|
json: boolean,
|
|
331
340
|
api: DecomposeGitHub,
|
|
341
|
+
/**
|
|
342
|
+
* The work-queue label to stamp on everything created, or `null`. Passed
|
|
343
|
+
* in rather than read here so a test can state both worlds without a
|
|
344
|
+
* config fixture on disk.
|
|
345
|
+
*/
|
|
346
|
+
queueLabel: string | null,
|
|
332
347
|
): Promise<number> {
|
|
333
348
|
const refuse = refusalReporter(json);
|
|
334
349
|
|
|
@@ -371,7 +386,12 @@ async function decompose(
|
|
|
371
386
|
for (const a of planned.actions) {
|
|
372
387
|
if (a.kind !== "create") continue;
|
|
373
388
|
try {
|
|
374
|
-
const n = await api.create(repo, {
|
|
389
|
+
const n = await api.create(repo, {
|
|
390
|
+
title: a.title,
|
|
391
|
+
body: a.body,
|
|
392
|
+
milestone: a.row.milestone,
|
|
393
|
+
label: queueLabel,
|
|
394
|
+
});
|
|
375
395
|
numbers.set(a.row.outcome, n);
|
|
376
396
|
created.push({ title: a.title, number: n });
|
|
377
397
|
} catch (e) {
|
|
@@ -534,7 +554,7 @@ export async function main(
|
|
|
534
554
|
const within = relative(root, planPath);
|
|
535
555
|
const escapes = within === ".." || within.startsWith(`..${sep}`);
|
|
536
556
|
const planLabel = within === "" || escapes ? planPath : within;
|
|
537
|
-
return await decompose(planPath, planLabel, repo, values.write, values.json, gh3);
|
|
557
|
+
return await decompose(planPath, planLabel, repo, values.write, values.json, gh3, readQueueLabel(root));
|
|
538
558
|
}
|
|
539
559
|
|
|
540
560
|
const reading = parseRepairPlan(readFileSync(planPath, "utf-8"));
|