@feigi/fleet-ctl 3.122.0 → 3.122.1
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/package.json +1 -1
- package/scripts/dispositions-check.mjs +55 -24
package/package.json
CHANGED
|
@@ -132,6 +132,11 @@
|
|
|
132
132
|
// 7 claimKind shape, below the claim bar suggestion-band record
|
|
133
133
|
// 8 survived, out of scope, whatever its reason open, needs-triage
|
|
134
134
|
//
|
|
135
|
+
// The labels in the table and below are Label roles (label-map.mjs): the
|
|
136
|
+
// script reads a home's labels, and words the home, as the strings the
|
|
137
|
+
// Label map maps those roles to — `needs-triage`, `ready-for-agent` and
|
|
138
|
+
// `wontfix` are the identity map's spellings.
|
|
139
|
+
//
|
|
135
140
|
// Row 4 outranks row 7, and row 7 every other row. A row-5 deferral is
|
|
136
141
|
// held to row 1's reasons: one of ALLOWED_DEFER other than
|
|
137
142
|
// false-rationale, `remedy-outside-diff` under the rule above. A row-6b
|
|
@@ -152,7 +157,8 @@
|
|
|
152
157
|
// check again once `gh` answers.
|
|
153
158
|
//
|
|
154
159
|
// Exit status: 0 ok; 1 mismatch, escalate or unchecked; 2 nothing judged and
|
|
155
|
-
// nothing written — a bad flag,
|
|
160
|
+
// nothing written — a bad flag, no valid Label map (the message names
|
|
161
|
+
// `label-map.mjs ensure`), an unreadable or malformed review file, a
|
|
156
162
|
// record file that exists but cannot be read, a git or ledger failure. A
|
|
157
163
|
// missing or unparseable RECORD is judged, not refused: the fix-applier wrote
|
|
158
164
|
// nothing a reader can use, so every finding it had to cover is dropped.
|
|
@@ -182,6 +188,7 @@ import { makeDie, defineFlags } from "./arg.mjs";
|
|
|
182
188
|
import { isCLI } from "./is-cli.mjs";
|
|
183
189
|
import { gitEnv } from "./git-env.mjs";
|
|
184
190
|
import { fleetFile, FleetDirUnresolvable } from "./fleet-dir.mjs";
|
|
191
|
+
import { readLabelMap } from "./label-map.mjs";
|
|
185
192
|
import { parseMember, memberTokens, rowNums, dispositionsToken, firstReview, prTokens } from "./ledger-grammar.mjs";
|
|
186
193
|
import { deriveRun, LedgerError } from "./fleet-tick.mjs";
|
|
187
194
|
import { VERDICT_SCHEMA } from "./review-core.mjs";
|
|
@@ -212,7 +219,9 @@ export const CHARGES = Object.freeze(["false-claim", "unmet", "both", "none"]);
|
|
|
212
219
|
export const CHARGE_REASONS = Object.freeze(["defect-outside-acceptance", "not-the-implementers-text", "claim-about-untouched-code"]);
|
|
213
220
|
|
|
214
221
|
// The filing table: a deferral's home by its finding's state. `record` is the
|
|
215
|
-
// suggestion-band record; `open` the weakest triage label an
|
|
222
|
+
// suggestion-band record; `open` the Label role of the weakest triage label an
|
|
223
|
+
// open home may carry — a role, never a string: homeText and homeHolds read the
|
|
224
|
+
// string it maps to from the Label map handed to checkDispositions.
|
|
216
225
|
export const FILING_ROWS = Object.freeze({
|
|
217
226
|
1: { finding: "an in-scope survived finding deferred for an allowed reason other than false-rationale", open: "needs-triage" },
|
|
218
227
|
2: { finding: "an in-scope survived finding deferred false-rationale", record: true },
|
|
@@ -224,22 +233,28 @@ export const FILING_ROWS = Object.freeze({
|
|
|
224
233
|
7: { finding: "a finding whose claim is about shape, below the claim bar", record: true },
|
|
225
234
|
8: { finding: "an out-of-scope survived finding, whatever its reason", open: "needs-triage" },
|
|
226
235
|
});
|
|
227
|
-
//
|
|
228
|
-
|
|
236
|
+
// The triage roles, strongest first: an open home may carry a label above its
|
|
237
|
+
// row's, never below.
|
|
238
|
+
const TRIAGE_ROLES = ["ready-for-agent", "needs-triage"];
|
|
229
239
|
// Row 1's reasons, which a row-5 deferral is held to.
|
|
230
240
|
const ROW_1_DEFER = ALLOWED_DEFER.filter((r) => r !== "false-rationale");
|
|
231
241
|
export const recordTitle = (pr) => `PR #${pr} review: the suggestion band, checked`;
|
|
232
242
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
243
|
+
// `roles` is the Label map's role -> string table: the tracker spells a label
|
|
244
|
+
// its own way, and the home is read and worded in that spelling.
|
|
245
|
+
function homeText(row, pr, roles) {
|
|
246
|
+
if (row.record) return `the closed "${recordTitle(pr)}" issue, labelled ${roles.wontfix}`;
|
|
247
|
+
return `an open issue labelled ${TRIAGE_ROLES.slice(0, TRIAGE_ROLES.indexOf(row.open) + 1).reverse().map((r) => roles[r]).join(" or ")}`;
|
|
236
248
|
}
|
|
237
249
|
|
|
238
|
-
// Whether an issue `{state, title, labels}` is `row`'s home on PR `pr`.
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
return state === "
|
|
250
|
+
// Whether an issue `{state, title, labels}` is `row`'s home on PR `pr`. The
|
|
251
|
+
// labels are the names `gh` returned, compared as they stand: the map holds
|
|
252
|
+
// the tracker's own spelling.
|
|
253
|
+
function homeHolds(row, { state, title, labels }, pr, roles) {
|
|
254
|
+
if (row.record) return state === "CLOSED" && title.trim() === recordTitle(pr) && labels.includes(roles.wontfix);
|
|
255
|
+
const triage = TRIAGE_ROLES.map((role) => roles[role]);
|
|
256
|
+
const carried = labels.filter((l) => triage.includes(l));
|
|
257
|
+
return state === "OPEN" && carried.length === 1 && triage.indexOf(carried[0]) <= TRIAGE_ROLES.indexOf(row.open);
|
|
243
258
|
}
|
|
244
259
|
|
|
245
260
|
// The row a deferral's finding state puts it on, by precedence, or null when
|
|
@@ -465,8 +480,10 @@ function chargeProblem(e, { inScope, required }) {
|
|
|
465
480
|
* defers `remedy-outside-diff`; `run` the review's run root name, or null when
|
|
466
481
|
* no ledger names it — a record answers it only by carrying the same `run`;
|
|
467
482
|
* `roots` the directories an absolute finding
|
|
468
|
-
* or remedy path is read relative to. `filing` is `{pr, issue(n), verdict(path)}`,
|
|
469
|
-
* required only when an entry defers or is a suggestion whose verdict is read: `
|
|
483
|
+
* or remedy path is read relative to. `filing` is `{pr, roles, issue(n), verdict(path)}`,
|
|
484
|
+
* required only when an entry defers or is a suggestion whose verdict is read: `roles` is
|
|
485
|
+
* the Label map's role -> string table, the spelling a home's labels are compared and worded
|
|
486
|
+
* in; `issue`
|
|
470
487
|
* answers `{state, title, labels}` — `state` upper-case, `labels` names — or
|
|
471
488
|
* `{problem}` when the tracker cannot say; `verdict` answers `{refuted}` for
|
|
472
489
|
* a refuter verdict path or `{problem}` when it is no usable evidence, with
|
|
@@ -564,7 +581,7 @@ export function checkDispositions({ review, record, recordProblem = null, run =
|
|
|
564
581
|
if (e.disposition === "apply" && (refuted === true || (refuted === null && !inScope))) {
|
|
565
582
|
const rowNo = filingRow({ bucket, inScope, crashed, refuted, shape });
|
|
566
583
|
const though = refuted ? "its verdict is refuted: true —" : `its refuter decided nothing — ${problem};`;
|
|
567
|
-
at(bucket, index, `filing row ${rowNo} (${FILING_ROWS[rowNo].finding}): applied, though ${though} it belongs in ${homeText(FILING_ROWS[rowNo], filing.pr)}`);
|
|
584
|
+
at(bucket, index, `filing row ${rowNo} (${FILING_ROWS[rowNo].finding}): applied, though ${though} it belongs in ${homeText(FILING_ROWS[rowNo], filing.pr, filing.roles)}`);
|
|
568
585
|
return;
|
|
569
586
|
}
|
|
570
587
|
}
|
|
@@ -603,9 +620,9 @@ export function checkDispositions({ review, record, recordProblem = null, run =
|
|
|
603
620
|
return;
|
|
604
621
|
}
|
|
605
622
|
const row = FILING_ROWS[rowNo];
|
|
606
|
-
const { pr, issue: readIssue } = filingOf();
|
|
623
|
+
const { pr, roles, issue: readIssue } = filingOf();
|
|
607
624
|
if (e.issue === undefined) {
|
|
608
|
-
at(bucket, index, `filing row ${rowNo} (${row.finding}): a deferral names the issue it was filed to, and this entry names none — it belongs in ${homeText(row, pr)}`);
|
|
625
|
+
at(bucket, index, `filing row ${rowNo} (${row.finding}): a deferral names the issue it was filed to, and this entry names none — it belongs in ${homeText(row, pr, roles)}`);
|
|
609
626
|
return;
|
|
610
627
|
}
|
|
611
628
|
const issue = readIssue(e.issue);
|
|
@@ -613,8 +630,8 @@ export function checkDispositions({ review, record, recordProblem = null, run =
|
|
|
613
630
|
unchecked.push({ bucket, index, issue: e.issue, problem: issue.problem });
|
|
614
631
|
return;
|
|
615
632
|
}
|
|
616
|
-
if (!homeHolds(row, issue, pr)) {
|
|
617
|
-
at(bucket, index, `filing row ${rowNo} (${row.finding}): it belongs in ${homeText(row, pr)}, and #${e.issue} is ${describeIssue(issue)}`);
|
|
633
|
+
if (!homeHolds(row, issue, pr, roles)) {
|
|
634
|
+
at(bucket, index, `filing row ${rowNo} (${row.finding}): it belongs in ${homeText(row, pr, roles)}, and #${e.issue} is ${describeIssue(issue)}`);
|
|
618
635
|
}
|
|
619
636
|
});
|
|
620
637
|
|
|
@@ -831,18 +848,32 @@ function main() {
|
|
|
831
848
|
const standalone = has("no-ledger");
|
|
832
849
|
if (standalone && arg("ledger") !== null) die("--no-ledger and --ledger contradict: name one");
|
|
833
850
|
const ledgerFile = standalone ? null : ledgerInUse(arg("ledger"), repo);
|
|
851
|
+
// Without a ledger nothing names the review the record answers, so `--review`
|
|
852
|
+
// must; with one, the latest `reviewed=` already does. Both are usage errors,
|
|
853
|
+
// so they are told before the Label map, the ledger or the tracker is read.
|
|
854
|
+
if (ledgerFile === null && arg("review") === null) die(`no ledger names PR #${pr}'s review — pass --review <path> for the review file ${member.name}'s record answers`);
|
|
855
|
+
if (ledgerFile !== null && arg("review") !== null) die(`--review and a ledger contradict: with a ledger the review is the one PR #${pr}'s latest reviewed= names`);
|
|
856
|
+
// The Label map, read once, here at the I/O boundary — after the flags and the
|
|
857
|
+
// ledger's location are settled, before the ledger or the tracker is read: a
|
|
858
|
+
// home's labels are compared and worded in the tracker's own spelling. No
|
|
859
|
+
// valid map is "nothing judged" (exit 2), never a verdict; the reader's
|
|
860
|
+
// message names `ensure`.
|
|
861
|
+
let roles;
|
|
862
|
+
try {
|
|
863
|
+
roles = readLabelMap({ cwd: repo });
|
|
864
|
+
} catch (e) {
|
|
865
|
+
die(e.message);
|
|
866
|
+
}
|
|
834
867
|
|
|
835
868
|
// The review the record answers. With a ledger it is the one PR M's latest
|
|
836
869
|
// `reviewed=` names — `<scratch>/pr<M>/<run>/review.json`, read off the
|
|
837
870
|
// same per-PR fold `ledger.mjs dispatch` gates the finisher by, so the check
|
|
838
|
-
// and the gate never judge two different reviews. Without one
|
|
839
|
-
//
|
|
871
|
+
// and the gate never judge two different reviews. Without one it is the
|
|
872
|
+
// `--review` path the checks above required.
|
|
840
873
|
let data = null, row = null, run = null, charges = false, reviewPath;
|
|
841
874
|
if (ledgerFile === null) {
|
|
842
875
|
reviewPath = arg("review");
|
|
843
|
-
if (reviewPath === null) die(`no ledger names PR #${pr}'s review — pass --review <path> for the review file ${member.name}'s record answers`);
|
|
844
876
|
} else {
|
|
845
|
-
if (arg("review") !== null) die(`--review and a ledger contradict: with a ledger the review is the one PR #${pr}'s latest reviewed= names`);
|
|
846
877
|
data = JSON.parse(runLedger(ledgerFile, ["read"], "read the ledger"));
|
|
847
878
|
// The verdict lands on the row carrying the member on its own PR's row —
|
|
848
879
|
// where `ledger.mjs dispatch` wrote it, and where the gate reads PR M's
|
|
@@ -908,7 +939,7 @@ function main() {
|
|
|
908
939
|
|
|
909
940
|
const { violations, escalations, unchecked } = checkDispositions({
|
|
910
941
|
review, record, recordProblem, run, touched: touchedLines(diff), diffFiles, roots: [review.snapshot, top], charges,
|
|
911
|
-
filing: { pr, issue: issueReader(repo), verdict: verdictReader(scratch, pr) },
|
|
942
|
+
filing: { pr, roles, issue: issueReader(repo), verdict: verdictReader(scratch, pr) },
|
|
912
943
|
});
|
|
913
944
|
// No ledger, no row: the exit status below is the verdict, and with no
|
|
914
945
|
// earlier fix-applier's verdict to count, a broken rule is always a
|