rungate 0.8.13 → 0.8.14
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/README.md +82 -0
- package/gates/.gate-salt +1 -1
- package/hooks/VerifyPhaseLock.hook.ts +3 -3
- package/lib/ai-review-rounds.ts +99 -0
- package/lib/ai-review-suppression.ts +200 -21
- package/lib/bash-write-guard.ts +50 -5
- package/lib/board-flow.ts +235 -0
- package/lib/board-lane-health.ts +381 -0
- package/lib/board-mirror.ts +53 -35
- package/lib/board-ready-fanout.ts +56 -13
- package/lib/board-ready-rule.ts +545 -0
- package/lib/board-throughput.ts +136 -0
- package/lib/board-walkthrough.ts +240 -0
- package/lib/body-evidence.ts +203 -0
- package/lib/branch-protection.ts +399 -9
- package/lib/conformity.ts +95 -2
- package/lib/filing-compliance.ts +367 -0
- package/lib/finding-arbiter.ts +79 -5
- package/lib/generators/agents-md.ts +149 -0
- package/lib/github.ts +79 -0
- package/lib/graphql-cursor.ts +80 -0
- package/lib/issue-create-override.ts +415 -3
- package/lib/issue-decomposition.ts +33 -3
- package/lib/issue-file-overlap.ts +340 -0
- package/lib/issue-filing-gate.ts +173 -8
- package/lib/issue-repair.ts +13 -9
- package/lib/issue-shape.ts +196 -0
- package/lib/scaffold/ai-review-findings.ts +9 -1
- package/lib/scaffold/ai-review-step.ts +35 -1
- package/lib/source-census.ts +108 -0
- package/lib/spec-deps.ts +34 -11
- package/lib/spec-placement.ts +108 -0
- package/lib/stage-ladder.ts +28 -3
- package/lib/work-status.ts +423 -0
- package/package.json +1 -1
- package/scripts/ai-review-findings.ts +8 -13
- package/scripts/ai-review-threads.ts +16 -17
- package/scripts/board-mirror.ts +221 -8
- package/scripts/generate-code-map.ts +1 -1
- package/scripts/plan-spec.ts +79 -1
|
@@ -0,0 +1,423 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The two decisions `scripts/work-status.ts` makes, as functions, so they can
|
|
3
|
+
* be mutated and watched to fail.
|
|
4
|
+
*
|
|
5
|
+
* Both exist because of the same defect: a status reading that is wrong while
|
|
6
|
+
* looking healthy. Jason, 2026-11-03 — *"we get hallucinated status readings
|
|
7
|
+
* at all times"* — and the first draft of that script proved the point by
|
|
8
|
+
* being wrong about 44 issues.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type { LaneReading } from "./board-lane-health";
|
|
12
|
+
import { readyOccupancy, undispatchableRemedy } from "./board-ready-rule";
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Is this issue something anybody may pick up right now?
|
|
16
|
+
*
|
|
17
|
+
* **Takes the blockers, never a search qualifier.** One query string,
|
|
18
|
+
* `is:open -is:blocked no:assignee`, measured against this repository on
|
|
19
|
+
* 2026-11-03 across three transports:
|
|
20
|
+
*
|
|
21
|
+
* | transport | returned |
|
|
22
|
+
* |---|---|
|
|
23
|
+
* | `gh issue list --search` | 33 — correct |
|
|
24
|
+
* | GraphQL `search` | 77 — `-is:blocked` dropped |
|
|
25
|
+
* | REST `/search/issues` | 77 — `-is:blocked` dropped |
|
|
26
|
+
*
|
|
27
|
+
* Neither wrong path errors; both return a larger set that reads as fine. The
|
|
28
|
+
* ground truth is `GET /issues/{n}/dependencies/blocked_by` per issue, and
|
|
29
|
+
* that is what the caller must hand to this function.
|
|
30
|
+
*
|
|
31
|
+
* A CLOSED blocker does not block. That is the distinction the qualifier gets
|
|
32
|
+
* right and a naive `blockers.length > 0` gets wrong — an issue whose one
|
|
33
|
+
* dependency has already landed is pickable, and treating it otherwise parks
|
|
34
|
+
* finished chains forever.
|
|
35
|
+
*/
|
|
36
|
+
export function isPickable(issue: {
|
|
37
|
+
readonly state: string;
|
|
38
|
+
readonly assignees: readonly unknown[];
|
|
39
|
+
readonly blockers: readonly { readonly state: string }[];
|
|
40
|
+
}): boolean {
|
|
41
|
+
if (issue.state !== "open") return false;
|
|
42
|
+
if (issue.assignees.length > 0) return false;
|
|
43
|
+
return !issue.blockers.some(b => b.state === "open");
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** What a row of the agreed order can honestly say about itself. */
|
|
47
|
+
export type OrderReading = "DONE" | "OPEN" | "ABANDONED" | "UNMEASURED" | "RECORDED";
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* What the tracker object actually is. `closed` is deliberately NOT a
|
|
51
|
+
* boolean: **closed and done are different facts**, and collapsing them is
|
|
52
|
+
* the defect a reviewer caught in the first version of this file.
|
|
53
|
+
*
|
|
54
|
+
* - a pull request is done when it **merged**; one closed unmerged is not
|
|
55
|
+
* - an issue closed `not_planned` is closed and was never completed
|
|
56
|
+
*/
|
|
57
|
+
export type TrackerFacts =
|
|
58
|
+
| { readonly kind: "pr"; readonly state: "open" | "closed"; readonly merged: boolean }
|
|
59
|
+
| {
|
|
60
|
+
readonly kind: "issue";
|
|
61
|
+
readonly state: "open" | "closed";
|
|
62
|
+
readonly stateReason: string | null;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* An order item with no issue and no pull request is **UNMEASURED**, never
|
|
67
|
+
* done and never open.
|
|
68
|
+
*
|
|
69
|
+
* This is the whole reason the report exists. Items 2 and 7 of the agreed
|
|
70
|
+
* order have no tracker object, so nothing can observe their state — and the
|
|
71
|
+
* failure mode this guards is reporting such an item as DONE because a
|
|
72
|
+
* session remembered it that way. That happened on 2026-11-03: items 1 and 2
|
|
73
|
+
* were reported ticked to Jason while `PROJECT-STATE.md` said all three of
|
|
74
|
+
* 1, 2 and 3 were untouched, and item 1 was an open pull request.
|
|
75
|
+
*
|
|
76
|
+
* **ABANDONED is a fourth reading, not a flavour of DONE.** A pull request
|
|
77
|
+
* closed without merging and an issue closed `not_planned` both end with
|
|
78
|
+
* `state: "closed"` while the work they stood for did not happen. Reporting
|
|
79
|
+
* either as DONE is the same class of wrong-but-healthy reading as the
|
|
80
|
+
* search qualifier above, arriving by a different route.
|
|
81
|
+
*
|
|
82
|
+
* `.claude/rules/config-access.md`: a reading that could not be taken is not
|
|
83
|
+
* one that passed.
|
|
84
|
+
*/
|
|
85
|
+
export function orderReading(item: {
|
|
86
|
+
readonly tracker: string | null;
|
|
87
|
+
readonly facts?: TrackerFacts;
|
|
88
|
+
/**
|
|
89
|
+
* **Where a human wrote that this is finished** — not whether they did.
|
|
90
|
+
*
|
|
91
|
+
* A `boolean` here would be the 2026-11-03 defect above with an extra
|
|
92
|
+
* field: a session's memory reaching the report through a flag nobody can
|
|
93
|
+
* check. A non-empty string has to say WHERE, so a reader can go and
|
|
94
|
+
* disagree with it. Empty, blank and `null` are all the absence of a
|
|
95
|
+
* citation and read UNMEASURED.
|
|
96
|
+
*
|
|
97
|
+
* Only consulted when there is no tracker object at all. An item with an
|
|
98
|
+
* issue or a pull request is answered by the tracker, and a stale note
|
|
99
|
+
* does not get to contradict a PR that is sitting open.
|
|
100
|
+
*/
|
|
101
|
+
readonly recordedDone?: string | null;
|
|
102
|
+
}): OrderReading {
|
|
103
|
+
if (item.tracker === null) return item.recordedDone?.trim() ? "RECORDED" : "UNMEASURED";
|
|
104
|
+
if (item.facts === undefined) return "UNMEASURED";
|
|
105
|
+
const f = item.facts;
|
|
106
|
+
if (f.state === "open") return "OPEN";
|
|
107
|
+
if (f.kind === "pr") return f.merged ? "DONE" : "ABANDONED";
|
|
108
|
+
// CLOSED FAILS CLOSED. This was `stateReason === "not_planned" ?
|
|
109
|
+
// ABANDONED : DONE`, which handed DONE to every reason it did not know —
|
|
110
|
+
// including `null`, what GitHub returns for an issue closed before the
|
|
111
|
+
// field existed or by a client that does not set it. That is a tick for a
|
|
112
|
+
// closure nobody confirmed as completion, which is the reading this whole
|
|
113
|
+
// file exists to stop, arriving through its own default. Caught in review
|
|
114
|
+
// of #1740.
|
|
115
|
+
if (f.stateReason === "completed") return "DONE";
|
|
116
|
+
if (f.stateReason === "not_planned" || f.stateReason === "duplicate") return "ABANDONED";
|
|
117
|
+
// `reopened` on a closed issue is a contradiction; `null` is the absence
|
|
118
|
+
// of a reason; anything else is a value added after this was written.
|
|
119
|
+
// Introspected 2026-11-04: `IssueStateReason` is REOPENED, NOT_PLANNED,
|
|
120
|
+
// COMPLETED, DUPLICATE, and REST adds `null` — so the set is closed today
|
|
121
|
+
// and will not stay closed. UNMEASURED is the only honest default.
|
|
122
|
+
return "UNMEASURED";
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* The bucket for issues carrying no milestone — A LANE, NOT A GAP.
|
|
127
|
+
*
|
|
128
|
+
* Measured on this repository 2026-11-06: of 82 open issues, **26 carry no
|
|
129
|
+
* milestone at all**. They are maintenance and backlog work, they are real,
|
|
130
|
+
* and a report that groups by milestone and silently omits them loses the
|
|
131
|
+
* single largest group it has. Jason, 2026-11-06: *"not all issues will have
|
|
132
|
+
* milestones right, like there's stuff that's just maintenance stuff in the
|
|
133
|
+
* backlog — how do we track that"*.
|
|
134
|
+
*
|
|
135
|
+
* So it is a named row with its own count, and `--milestone none` focuses on
|
|
136
|
+
* it exactly as a title does. The parenthesis is deliberate: GitHub cannot
|
|
137
|
+
* have a milestone of this name, so the row can never collide with a real
|
|
138
|
+
* one.
|
|
139
|
+
*/
|
|
140
|
+
export const NO_MILESTONE = "(no milestone)";
|
|
141
|
+
|
|
142
|
+
/** One milestone's standing, in the numbers that decide what to do next. */
|
|
143
|
+
export type MilestoneRow = {
|
|
144
|
+
readonly milestone: string;
|
|
145
|
+
readonly open: number;
|
|
146
|
+
/**
|
|
147
|
+
* Closed `completed`. **NOT every closed issue** — `orderReading` three
|
|
148
|
+
* docblocks up exists entirely to stop that conflation, and the first
|
|
149
|
+
* version of this table reintroduced it one function later: it printed
|
|
150
|
+
* `closed` under a header reading `done`, so a lane that abandoned four of
|
|
151
|
+
* ten closures reported ten completed. Caught in review of #1825.
|
|
152
|
+
*/
|
|
153
|
+
readonly done: number;
|
|
154
|
+
/** Closed for any other reason, or none: `not_planned`, `duplicate`, null. */
|
|
155
|
+
readonly dropped: number;
|
|
156
|
+
/** Open AND assigned — somebody says they are on it. */
|
|
157
|
+
readonly claimed: number;
|
|
158
|
+
/** Open with at least one OPEN blocker. A closed blocker does not block. */
|
|
159
|
+
readonly blocked: number;
|
|
160
|
+
/** Open, unclaimed, unblocked — anybody may start it today. */
|
|
161
|
+
readonly pickable: number;
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
/** An issue as this module needs it: the five fields, and nothing else. */
|
|
165
|
+
export type RollupIssue = {
|
|
166
|
+
readonly number: number;
|
|
167
|
+
readonly state: string;
|
|
168
|
+
readonly milestone?: { readonly title?: string | null } | null;
|
|
169
|
+
readonly assignees?: readonly unknown[] | null;
|
|
170
|
+
readonly pull_request?: unknown;
|
|
171
|
+
/** REST's `state_reason`. Absent and `null` both mean nobody said. */
|
|
172
|
+
readonly state_reason?: string | null;
|
|
173
|
+
/** From `GET /issues/{n}/dependencies/blocked_by` — never a search qualifier. */
|
|
174
|
+
readonly blockers: readonly { readonly state: string }[];
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
/** The milestone an issue belongs to, with absence spelled as a lane. */
|
|
178
|
+
export function milestoneOf(issue: RollupIssue): string {
|
|
179
|
+
const t = issue.milestone?.title;
|
|
180
|
+
return typeof t === "string" && t.trim() !== "" ? t : NO_MILESTONE;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Every milestone's standing, including the one that is not a milestone.
|
|
185
|
+
*
|
|
186
|
+
* Pull requests are dropped: `/issues` returns them too, and a PR counted as
|
|
187
|
+
* an issue inflates every lane it touches. `isPickable` is reused rather
|
|
188
|
+
* than re-derived — "what may anybody start" has one owner, and a second
|
|
189
|
+
* spelling here would be two deciders over one question with nothing
|
|
190
|
+
* comparing them.
|
|
191
|
+
*
|
|
192
|
+
* Sorted by open count descending, then by name, so the biggest pile of
|
|
193
|
+
* unfinished work is the first thing read. `NO_MILESTONE` sorts with the
|
|
194
|
+
* rest rather than being pinned anywhere: it is a lane.
|
|
195
|
+
*/
|
|
196
|
+
export function milestoneRollup(issues: readonly RollupIssue[]): MilestoneRow[] {
|
|
197
|
+
type Counts = { open: number; done: number; dropped: number; claimed: number; blocked: number; pickable: number };
|
|
198
|
+
const rows = new Map<string, Counts>();
|
|
199
|
+
for (const i of issues) {
|
|
200
|
+
if (i.pull_request) continue;
|
|
201
|
+
const key = milestoneOf(i);
|
|
202
|
+
const r = rows.get(key) ?? { open: 0, done: 0, dropped: 0, claimed: 0, blocked: 0, pickable: 0 };
|
|
203
|
+
if (i.state === "open") {
|
|
204
|
+
r.open += 1;
|
|
205
|
+
if ((i.assignees?.length ?? 0) > 0) r.claimed += 1;
|
|
206
|
+
if (i.blockers.some(b => b.state === "open")) r.blocked += 1;
|
|
207
|
+
if (isPickable({ state: i.state, assignees: i.assignees ?? [], blockers: i.blockers })) {
|
|
208
|
+
r.pickable += 1;
|
|
209
|
+
}
|
|
210
|
+
} else if (i.state_reason === "completed") {
|
|
211
|
+
r.done += 1;
|
|
212
|
+
} else {
|
|
213
|
+
// CLOSED FAILS CLOSED, the same direction `orderReading` takes it: an
|
|
214
|
+
// unknown reason and a `null` one are NOT completions. Over-reporting
|
|
215
|
+
// `done` is the reading that makes a lane look finished.
|
|
216
|
+
r.dropped += 1;
|
|
217
|
+
}
|
|
218
|
+
rows.set(key, r);
|
|
219
|
+
}
|
|
220
|
+
return [...rows]
|
|
221
|
+
.map(([milestone, r]) => ({ milestone, ...r }))
|
|
222
|
+
.sort((a, b) => b.open - a.open || a.milestone.localeCompare(b.milestone));
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/** What `--milestone` resolved to, including the two ways it can fail. */
|
|
226
|
+
export type Focus =
|
|
227
|
+
| { readonly kind: "all" }
|
|
228
|
+
| { readonly kind: "one"; readonly title: string }
|
|
229
|
+
| { readonly kind: "unknown"; readonly asked: string; readonly known: readonly string[] };
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Resolve `--milestone`, and REFUSE a name that matches nothing.
|
|
233
|
+
*
|
|
234
|
+
* This is the whole reason it is a function. A focus that quietly selects
|
|
235
|
+
* zero issues prints a correct-looking report with an empty body, and a typo
|
|
236
|
+
* is then indistinguishable from a milestone whose work is finished — the
|
|
237
|
+
* *Silent Default Substitution* shape in `.claude/rules/config-access.md`,
|
|
238
|
+
* in a tool whose entire purpose is that the status is not hallucinated.
|
|
239
|
+
*
|
|
240
|
+
* `unknown` carries the names that DO exist, because a refusal that does not
|
|
241
|
+
* say what was available is a refusal nobody can act on.
|
|
242
|
+
*
|
|
243
|
+
* Absent means `all`. That is the change of 2026-11-06: the default used to
|
|
244
|
+
* be one hardcoded title, `"Issue intake"`, which on that day was 1 open
|
|
245
|
+
* issue of 82 — so 81 were invisible in the report the status was read from.
|
|
246
|
+
*/
|
|
247
|
+
export function resolveFocus(asked: string | undefined, known: readonly string[]): Focus {
|
|
248
|
+
// **Absent is `all`. Present-and-empty is a REFUSAL.** The condition used
|
|
249
|
+
// to read `asked === undefined || asked.trim() === ""`, and `--milestone`
|
|
250
|
+
// typed as the last argument arrives here as the empty string — a mistake
|
|
251
|
+
// that then printed the unpinned report and read as if the pin had been
|
|
252
|
+
// honoured.
|
|
253
|
+
//
|
|
254
|
+
// Nothing more is needed: an empty name matches no milestone and neither
|
|
255
|
+
// keyword, so it falls through to the refusal at the bottom like any other
|
|
256
|
+
// name that does not exist. A branch of its own here WAS written, and a
|
|
257
|
+
// mutant deleting it left the suite 45 pass / 0 fail — a second decider
|
|
258
|
+
// over a question this function already answers
|
|
259
|
+
// (`.claude/rules/checks-must-be-able-to-fail.md`).
|
|
260
|
+
if (asked === undefined) return { kind: "all" };
|
|
261
|
+
|
|
262
|
+
// **A REAL milestone wins over the keyword that spells it.** GitHub titles
|
|
263
|
+
// are free text, so a milestone named `all` or `none` is legal, and
|
|
264
|
+
// checking the keywords first made one permanently unreachable — the
|
|
265
|
+
// keyword answered, the real lane was never consulted, and nothing said
|
|
266
|
+
// so. Caught in review of #1825.
|
|
267
|
+
if (known.includes(asked)) return { kind: "one", title: asked };
|
|
268
|
+
|
|
269
|
+
// `none` and the rendered label both reach the unmilestoned lane, so a
|
|
270
|
+
// reader can copy the name out of the table and pass it straight back.
|
|
271
|
+
if (asked === "none" || asked === NO_MILESTONE) return { kind: "one", title: NO_MILESTONE };
|
|
272
|
+
if (asked === "all") return { kind: "all" };
|
|
273
|
+
return { kind: "unknown", asked, known: [...known].sort() };
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/** What a Ready reading means for whether the script may exit 0 — #1842. */
|
|
277
|
+
export type ReadyVerdict =
|
|
278
|
+
/** The lane is below its depth, or empty while its depth is positive. */
|
|
279
|
+
| "REFUSE"
|
|
280
|
+
/** The lane's state could not be established. NEVER the same as fine. */
|
|
281
|
+
| "UNMEASURED";
|
|
282
|
+
|
|
283
|
+
export interface ReadyRefusal {
|
|
284
|
+
readonly verdict: ReadyVerdict;
|
|
285
|
+
readonly count: number;
|
|
286
|
+
readonly against: number | null;
|
|
287
|
+
readonly why: string;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Whether the Ready lane's reading lets this run exit 0 — #1842.
|
|
292
|
+
*
|
|
293
|
+
* The ONE decider. The script restates its answer and spells no condition of
|
|
294
|
+
* its own: a second condition there would be two deciders over one input, and
|
|
295
|
+
* a mutation of either would leave the other holding every case up
|
|
296
|
+
* (`.claude/rules/checks-must-be-able-to-fail.md`).
|
|
297
|
+
*
|
|
298
|
+
* ## UNWRITTEN refuses, and the first version of this missed it
|
|
299
|
+
*
|
|
300
|
+
* `laneHealth` returns `UNWRITTEN`, not `SHORT`, when `count === 0` and the
|
|
301
|
+
* denominator is positive — so **the SHORT branch is unreachable at zero**
|
|
302
|
+
* and a gate keyed on SHORT alone exits 0 on a completely empty Ready lane,
|
|
303
|
+
* which is the single case it exists for. Worse, the first control written
|
|
304
|
+
* for this asserted that pass as correct, which is the "case that goes green
|
|
305
|
+
* under the wrong fix" shape: it would have certified the bypass.
|
|
306
|
+
*
|
|
307
|
+
* Caught by the automated security review of the pushed commit, not by the
|
|
308
|
+
* battery — the battery varied the health value and never asked which value
|
|
309
|
+
* the producer emits at the boundary.
|
|
310
|
+
*
|
|
311
|
+
* ## UNMEASURED is its own answer, not silence
|
|
312
|
+
*
|
|
313
|
+
* A census that could not be taken is not a lane that is fine, and returning
|
|
314
|
+
* `null` for it would make those two states the same bytes — the exact
|
|
315
|
+
* confusion this whole report exists to remove. It gets its own verdict and
|
|
316
|
+
* its own exit code at the call site.
|
|
317
|
+
*
|
|
318
|
+
* `NO_TARGET` is different and is NOT a refusal: it means no denominator
|
|
319
|
+
* exists, so there is nothing the lane could be short OF. `OK` and `OVER` are
|
|
320
|
+
* the lane working and the lane over-full; neither leaves a session with
|
|
321
|
+
* nothing to start.
|
|
322
|
+
*
|
|
323
|
+
* ## The switch is exhaustive on purpose
|
|
324
|
+
*
|
|
325
|
+
* `LaneHealth` is the producer's own type and the `never` arm makes adding a
|
|
326
|
+
* member a COMPILE error here rather than a silent pass. A `!==` test, or a
|
|
327
|
+
* `Set` of strings, would let a seventh health value default to "fine" — and
|
|
328
|
+
* that is precisely how UNWRITTEN slipped through the first time.
|
|
329
|
+
*/
|
|
330
|
+
export function readyRefusal(
|
|
331
|
+
readings: readonly LaneReading[],
|
|
332
|
+
/**
|
|
333
|
+
* Open issues in the Ready column — the SAME number the report prints as
|
|
334
|
+
* startable.
|
|
335
|
+
*
|
|
336
|
+
* The lane's own count is every board item in the column, closed ones
|
|
337
|
+
* included, so a Ready holding three closed cards read `3 of 3 OK` while
|
|
338
|
+
* the startable list showed nothing. The gate passed with no work to
|
|
339
|
+
* start, which is the state it exists to catch. The count and the list
|
|
340
|
+
* must come from one number or the report can disagree with itself inside
|
|
341
|
+
* one page.
|
|
342
|
+
*/
|
|
343
|
+
openInReady: number,
|
|
344
|
+
/**
|
|
345
|
+
* Cards in Ready this board reading could NOT see as issues — a draft, a
|
|
346
|
+
* pull request. **Required, and there is no default** (ai-review round 1 of
|
|
347
|
+
* #1857).
|
|
348
|
+
*
|
|
349
|
+
* `readyOccupancy`'s `cards` means every physical card in the lane, and the
|
|
350
|
+
* only number this file had was issues-only: `boardStatus()` keeps items
|
|
351
|
+
* whose content is an Issue and buckets the rest into `unseenByLane`, which
|
|
352
|
+
* never reached here. So the gate read the live 2026-11-07 lane — one open
|
|
353
|
+
* issue and one draft at a depth of 2 — as `1 of 2, one free slot, ROOM`,
|
|
354
|
+
* while `scripts/board-ready.ts`, counting every card, read it as full.
|
|
355
|
+
* **The exact disagreement #1852 exists to end survived inside the fix.**
|
|
356
|
+
*
|
|
357
|
+
* A default of `0` would have let a caller stay silent and be wrong, which
|
|
358
|
+
* is how it was wrong in the first place. A caller that genuinely cannot
|
|
359
|
+
* take the count must say so by other means; it may not say zero.
|
|
360
|
+
*/
|
|
361
|
+
unseenInReady: number,
|
|
362
|
+
): ReadyRefusal | null {
|
|
363
|
+
const ready = readings.find(r => r.lane === "Ready");
|
|
364
|
+
// A board with no Ready row cannot be judged, and must not read as fine.
|
|
365
|
+
if (ready === undefined) {
|
|
366
|
+
return {
|
|
367
|
+
verdict: "UNMEASURED",
|
|
368
|
+
count: 0,
|
|
369
|
+
against: null,
|
|
370
|
+
why: "the board reading contains no Ready lane at all",
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
// **The subtraction is `readyOccupancy`'s, not this file's** (#1852). It
|
|
374
|
+
// used to be spelled here as `ready.count - openInReady`, which made this
|
|
375
|
+
// the SECOND place that decided how full Ready is — and the two then
|
|
376
|
+
// disagreed in production: on 2026-11-07 the writer read `2 of 2, full`
|
|
377
|
+
// over every card while this read `1 of 2, SHORT` over open issues, and
|
|
378
|
+
// no single site a mutation could move said which was right.
|
|
379
|
+
//
|
|
380
|
+
// Named rather than silently subtracted, as before: the lane disagreeing
|
|
381
|
+
// with itself is a board defect somebody has to clear, and a gate that
|
|
382
|
+
// quietly corrects for it hides the thing to fix.
|
|
383
|
+
// **`ready.count` is issues only; the lane is not.** The sum is the whole
|
|
384
|
+
// of the lane, and it is taken here rather than in the caller so the one
|
|
385
|
+
// thing `readyOccupancy` is handed is the population its contract names.
|
|
386
|
+
const occ = readyOccupancy(ready.count + unseenInReady, openInReady, ready.against);
|
|
387
|
+
const why =
|
|
388
|
+
occ.undispatchable > 0
|
|
389
|
+
? `${ready.why} — and ${occ.undispatchable} of the ${occ.cards} card(s) in this lane ` +
|
|
390
|
+
`${occ.undispatchable === 1 ? "is" : "are"} not an open issue, so only ` +
|
|
391
|
+
`${occ.dispatchable} can be started` +
|
|
392
|
+
// The REMEDY, which is the half a count cannot carry. NOT
|
|
393
|
+
// `heldReason` — that one answers the promoters' question, and its
|
|
394
|
+
// ROOM arm says "Ready is at its depth", which is false of a lane
|
|
395
|
+
// this gate is refusing for being SHORT. One reading, two renderings.
|
|
396
|
+
`. ${undispatchableRemedy(occ)}`
|
|
397
|
+
: ready.why;
|
|
398
|
+
const seen = { count: openInReady, against: ready.against, why };
|
|
399
|
+
// Judged on the OPEN count, so a lane filled with closed cards cannot
|
|
400
|
+
// clear the gate on a number nobody can act on.
|
|
401
|
+
if (ready.against !== null && openInReady < ready.against && ready.health !== "UNMEASURED") {
|
|
402
|
+
return { verdict: "REFUSE", ...seen };
|
|
403
|
+
}
|
|
404
|
+
switch (ready.health) {
|
|
405
|
+
case "SHORT":
|
|
406
|
+
case "UNWRITTEN":
|
|
407
|
+
return { verdict: "REFUSE", ...seen };
|
|
408
|
+
case "UNMEASURED":
|
|
409
|
+
return { verdict: "UNMEASURED", ...seen };
|
|
410
|
+
case "OK":
|
|
411
|
+
case "OVER":
|
|
412
|
+
case "NO_TARGET":
|
|
413
|
+
return null;
|
|
414
|
+
default: {
|
|
415
|
+
const unhandled: never = ready.health;
|
|
416
|
+
throw new Error(
|
|
417
|
+
`readyRefusal: unclassified lane health ${JSON.stringify(unhandled)}. ` +
|
|
418
|
+
"Every LaneHealth must be sorted into refuse, unmeasured or fine — " +
|
|
419
|
+
"defaulting a new one to fine is how UNWRITTEN bypassed this gate.",
|
|
420
|
+
);
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
}
|
package/package.json
CHANGED
|
@@ -92,11 +92,7 @@
|
|
|
92
92
|
* `specs/CODE-REVIEW-CONVERGENCE-SPEC.md`.
|
|
93
93
|
*/
|
|
94
94
|
import { aiReviewJuryGate } from "../lib/ai-review-jury";
|
|
95
|
-
import {
|
|
96
|
-
aiReviewSuppressionGate,
|
|
97
|
-
checkoutLineText,
|
|
98
|
-
readOrNull,
|
|
99
|
-
} from "../lib/ai-review-suppression";
|
|
95
|
+
import { productionSuppression } from "../lib/ai-review-suppression";
|
|
100
96
|
import { main } from "../lib/scaffold/ai-review-findings";
|
|
101
97
|
import { AI_REVIEW_BALLOT_DIR_ENV, AI_REVIEW_THREADS_PATH_VAR } from "../lib/scaffold/ai-review-step";
|
|
102
98
|
|
|
@@ -106,14 +102,13 @@ const jury =
|
|
|
106
102
|
? null
|
|
107
103
|
: (blocking: readonly unknown[]) => aiReviewJuryGate(blocking, ballotDir);
|
|
108
104
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
});
|
|
105
|
+
// Assembled in `lib/`, not here. This command and `ai-review-threads.ts` must
|
|
106
|
+
// form the SAME gate from the same file, and two hand-written literals is how
|
|
107
|
+
// `anchorOccurrences` reached one of them and not the other (#1861 round 4).
|
|
108
|
+
const { gate: suppress } = productionSuppression(
|
|
109
|
+
process.env[AI_REVIEW_THREADS_PATH_VAR],
|
|
110
|
+
process.cwd(),
|
|
111
|
+
);
|
|
117
112
|
|
|
118
113
|
// One line, and `process.exit(main(` is load-bearing text: AC-4 in
|
|
119
114
|
// `test/ai-review-findings-command.test.ts` reads it to prove this file
|
|
@@ -43,11 +43,7 @@ import {
|
|
|
43
43
|
readAiReviewFindingsFile,
|
|
44
44
|
} from "../lib/scaffold/ai-review-findings";
|
|
45
45
|
import { carryKey } from "../lib/ai-review-rounds";
|
|
46
|
-
import {
|
|
47
|
-
aiReviewSuppressionGate,
|
|
48
|
-
checkoutLineText,
|
|
49
|
-
readOrNull,
|
|
50
|
-
} from "../lib/ai-review-suppression";
|
|
46
|
+
import { productionSuppression } from "../lib/ai-review-suppression";
|
|
51
47
|
import { AI_REVIEW_THREADS_PATH_VAR } from "../lib/scaffold/ai-review-step";
|
|
52
48
|
|
|
53
49
|
const COMMAND = "ai-review-threads";
|
|
@@ -132,14 +128,17 @@ if (!parsed.ok) {
|
|
|
132
128
|
// agree until they do not. This step runs BEFORE the adjudicator in the
|
|
133
129
|
// emitted job, so it cannot be handed the adjudicator's answer — it has to
|
|
134
130
|
// form its own from the same input.
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
131
|
+
//
|
|
132
|
+
// That sentence was true of the FUNCTION and false of its INPUTS while each
|
|
133
|
+
// command wrote its own object literal: #1861 added `anchorOccurrences` to
|
|
134
|
+
// the adjudicator alone, and the whole anchor rule was dead here — in the
|
|
135
|
+
// command that posts the threads, which is the half #1616's 11-threads-for-3
|
|
136
|
+
// measurement is about. `productionSuppression` is now the only assembly
|
|
137
|
+
// site, and AS-15 holds it that way.
|
|
138
|
+
const { gate: suppress, lineTextFor } = productionSuppression(
|
|
139
|
+
process.env[AI_REVIEW_THREADS_PATH_VAR],
|
|
140
|
+
process.cwd(),
|
|
141
|
+
);
|
|
143
142
|
|
|
144
143
|
const reading = readAiReviewFindingsFile(
|
|
145
144
|
parsed.findings,
|
|
@@ -175,12 +174,12 @@ const post: AiReviewThreadPoster = async request => {
|
|
|
175
174
|
|
|
176
175
|
// THE KEY-SYMMETRY HALF, on the producing side. The thread carries the key
|
|
177
176
|
// a later round's suppression gate will form for the same finding, so the
|
|
178
|
-
// text anchor must be read the same way both sides read it
|
|
179
|
-
// this is `checkoutLineText` and not a second line reader. A caller that
|
|
177
|
+
// text anchor must be read the same way both sides read it. A caller that
|
|
180
178
|
// supplied no text would key `n:<line>` while the gate keys `t:<text>`, and
|
|
181
179
|
// the two namespaces never collide: the gate would suppress nothing and
|
|
182
|
-
// every round would re-post every thread.
|
|
183
|
-
|
|
180
|
+
// every round would re-post every thread. `lineTextFor` comes off the SAME
|
|
181
|
+
// reader the gate above was built from, so it is the same cache and the same
|
|
182
|
+
// normalisation rather than a second one that happens to agree.
|
|
184
183
|
const result = await postReviewThreads(reading, post, f => carryKey(f, lineTextFor(f)));
|
|
185
184
|
for (const line of result.detail) console.log(`${COMMAND}: ${line}`);
|
|
186
185
|
console.log(
|