@feigi/fleet-ctl 3.144.2 → 3.144.4
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/cell-readout.mjs +1 -118
- package/scripts/fleet-tick.mjs +30 -8
- package/scripts/ledger.mjs +18 -6
- package/scripts/pull-attribution.mjs +1 -12
package/package.json
CHANGED
package/scripts/cell-readout.mjs
CHANGED
|
@@ -43,42 +43,6 @@
|
|
|
43
43
|
// Only the refusal of conflicting ticket-features rows names a session and an
|
|
44
44
|
// agent, and it prints nothing on stdout.
|
|
45
45
|
//
|
|
46
|
-
// STOPPING RULE (exported as `stoppingRule`, not printed by this CLI). A
|
|
47
|
-
// ticket's RULING is its last tier-outcomes.tsv row in file order (a
|
|
48
|
-
// `+`-joined `ticket` field rules each ticket it names); a row with both
|
|
49
|
-
// verdict columns blank was never ruled, so it is skipped. Its CARRIER is
|
|
50
|
-
// the ticket's last Pull in file order, at any cell, slow-high included,
|
|
51
|
-
// dated on or before the ruling. Dates only set that floor: a ruling counts
|
|
52
|
-
// for a Pull only when dated on or after it, and neither pick is the
|
|
53
|
-
// latest-dated row. A Pull's GENERATION is pull-attribution.mjs's
|
|
54
|
-
// (`pullGenerations`): the `dispatch_model` of its first Admissible
|
|
55
|
-
// implementer row in dispatch order, over every implementer row booked to
|
|
56
|
-
// the Pull, its retries included, so the guard and this rule never name two
|
|
57
|
-
// generations for one Pull. A Pull is admissible here when it has one. A Pull at X is
|
|
58
|
-
// COUNTABLE when X is a cell other than slow-high whose definition is live
|
|
59
|
-
// and the Pull is admissible and dated on or after the day X's
|
|
60
|
-
// `fleet-implementer-<cell>` definition was most recently added. The ruling
|
|
61
|
-
// is a VERDICT for the carrier's cell only, and only when the carrier is
|
|
62
|
-
// countable. Otherwise it is no verdict for any cell, never one for an
|
|
63
|
-
// earlier Pull of the ticket. A ticket with no ruling, or no Pull dated on or
|
|
64
|
-
// before it, is no verdict. A ticket counts once however many Pulls it took,
|
|
65
|
-
// at however many cells. A verdict FAILS the quality floor on
|
|
66
|
-
// `minted_false_claim=yes` or `closed_own_ticket=no`. For a ticket with a
|
|
67
|
-
// countable Pull, a ruling holding anything but `yes` or `no` in either
|
|
68
|
-
// column, one blank included, is refused rather than read as a pass. So is a
|
|
69
|
-
// non-blank ruling row of such a ticket whose `run_date` is not `YYYY-MM-DD`,
|
|
70
|
-
// and, once it is ruled, a Pull of it at any cell whose `run_date` is not
|
|
71
|
-
// `YYYY-MM-DD`: either cannot be placed to find the carrier, and dropping it
|
|
72
|
-
// could move the verdict to another cell or uncount it. So is an admissible
|
|
73
|
-
// Pull at X whose `run_date` is not `YYYY-MM-DD`: it cannot be placed against
|
|
74
|
-
// the day X's definition was added, and dropping it would uncount its ruling.
|
|
75
|
-
// X is to be withdrawn once its newest generation has at least STOP.verdicts
|
|
76
|
-
// verdicts and floor failures ÷ verdicts is at least STOP.failRate. A ruling
|
|
77
|
-
// counts for its carrier's generation; a cell's newest generation is that of
|
|
78
|
-
// its latest admissible Pull, by session id, then file order. An older
|
|
79
|
-
// generation's verdicts are returned beside the newest's and never withdraw
|
|
80
|
-
// the cell.
|
|
81
|
-
//
|
|
82
46
|
// Exit 0 whatever the counts; 2 on a usage error or an unreadable or
|
|
83
47
|
// malformed input, with nothing on stdout.
|
|
84
48
|
|
|
@@ -87,12 +51,10 @@ import { makeDie, defineFlags } from "./arg.mjs";
|
|
|
87
51
|
import { isCLI } from "./is-cli.mjs";
|
|
88
52
|
import { POLICY_CELL } from "./ledger-grammar.mjs";
|
|
89
53
|
import { formatTsv as formatMemberTsv, parseTsv as parseMemberTsv } from "./member-outcomes.mjs";
|
|
90
|
-
import { admissibleRow,
|
|
91
|
-
import { DATE, rulingFor, rulingsByTicket } from "./tier-outcomes.mjs";
|
|
54
|
+
import { admissibleRow, parseFeatures } from "./pull-attribution.mjs";
|
|
92
55
|
|
|
93
56
|
const NAME = "cell-readout";
|
|
94
57
|
export const GATE = Object.freeze({ comparisons: 10, runDates: 5 });
|
|
95
|
-
export const STOP = Object.freeze({ verdicts: 10, failRate: 0.8 });
|
|
96
58
|
|
|
97
59
|
const key = (session, agent) => `${session}\0${agent}`;
|
|
98
60
|
|
|
@@ -175,85 +137,6 @@ export function readout({ features, members }) {
|
|
|
175
137
|
return { cells: out, unjoined };
|
|
176
138
|
}
|
|
177
139
|
|
|
178
|
-
/**
|
|
179
|
-
* One entry per cell named in `added` (cell → the `YYYY-MM-DD` its definition
|
|
180
|
-
* was most recently added) other than the policy cell, sorted by cell:
|
|
181
|
-
* `{ cell, since, generation, verdicts, failures, stop, older }`. `verdicts` is
|
|
182
|
-
* `[{ ticket, pr, run_date, closed_own_ticket, minted_false_claim, failed }]`
|
|
183
|
-
* sorted by ticket, `run_date` the ruling's; `stop` is whether the stopping
|
|
184
|
-
* rule withdraws the cell. `verdicts` are parsed tier-outcomes.tsv rows.
|
|
185
|
-
* A ticket's ruling is its last ruling row in file order, charged to the cell
|
|
186
|
-
* of its carrier, the ticket's last Pull in file order at any cell dated on or
|
|
187
|
-
* before the ruling, and only when that Pull is
|
|
188
|
-
* countable: admissible (it has a generation, pull-attribution.mjs's
|
|
189
|
-
* `pullGenerations`), at a cell named in `added` other than the policy
|
|
190
|
-
* cell, and dated on or after the day that cell's definition was added.
|
|
191
|
-
* A ruling is charged to its carrier's generation too, and `generation`,
|
|
192
|
-
* `verdicts`, `failures` and `stop` are the cell's newest generation's alone
|
|
193
|
-
* (pull-attribution.mjs's `generations`, over the cell's admissible Pulls;
|
|
194
|
-
* null when it has none). `older` holds `{ generation, verdicts, failures }`
|
|
195
|
-
* for each other generation with at least one verdict, newest first, and
|
|
196
|
-
* never a stop.
|
|
197
|
-
* Throws on a non-blank ruling row of a ticket with a countable Pull whose
|
|
198
|
-
* `closed_own_ticket` or `minted_false_claim` is not `yes` or `no` or whose
|
|
199
|
-
* `run_date` is not `YYYY-MM-DD`,
|
|
200
|
-
* on an admissible Pull at a cell named in `added` whose `run_date` is not
|
|
201
|
-
* `YYYY-MM-DD`, on any Pull of a ruled ticket with a countable Pull whose
|
|
202
|
-
* `run_date` is not `YYYY-MM-DD`, and on a member-outcomes session+agent
|
|
203
|
-
* repeated with different fields.
|
|
204
|
-
*/
|
|
205
|
-
export function stoppingRule({ features, members, verdicts, added }) {
|
|
206
|
-
indexMembers(members); // refuses a session+agent repeated with different fields
|
|
207
|
-
const rulings = rulingsByTicket(verdicts);
|
|
208
|
-
const charged = new Map(Object.keys(added).filter((c) => c !== POLICY_CELL).map((c) => [c, new Map()]));
|
|
209
|
-
const dated = (p) => {
|
|
210
|
-
if (!DATE.test(p.run_date)) throw new Error(`ticket #${p.ticket} (Pull ${p.agent} at ${p.chosen_cell}): run_date is '${p.run_date}', expected YYYY-MM-DD`);
|
|
211
|
-
return p.run_date;
|
|
212
|
-
};
|
|
213
|
-
// A Pull's generation is pull-attribution's, read over all of its implementer
|
|
214
|
-
// rows; a Pull with none is not admitted.
|
|
215
|
-
const generationOf = pullGenerations(features, members);
|
|
216
|
-
const countable = new Map(); // Pull -> its generation
|
|
217
|
-
const admitted = []; // every Pull with a generation at a judged cell, as generations() reads one
|
|
218
|
-
const pullsByTicket = new Map();
|
|
219
|
-
for (const p of features) {
|
|
220
|
-
(pullsByTicket.get(p.ticket) ?? pullsByTicket.set(p.ticket, []).get(p.ticket)).push(p);
|
|
221
|
-
const g = charged.has(p.chosen_cell) ? generationOf.get(p) : null;
|
|
222
|
-
if (!g) continue;
|
|
223
|
-
admitted.push({ cell: p.chosen_cell, generation: g, pull: p });
|
|
224
|
-
if (dated(p) >= added[p.chosen_cell]) countable.set(p, g);
|
|
225
|
-
}
|
|
226
|
-
for (const [ticket, pulls] of pullsByTicket) {
|
|
227
|
-
if (!pulls.some((p) => countable.has(p))) continue;
|
|
228
|
-
// The ticket's ruling: its last ruling row in file order (every date clears a "" floor).
|
|
229
|
-
const v = rulingFor(rulings, ticket, "");
|
|
230
|
-
if (!v) continue;
|
|
231
|
-
// Its carrier: the ticket's last Pull in file order dated on or before the ruling.
|
|
232
|
-
let carrier = null;
|
|
233
|
-
for (const p of pulls) if (dated(p) <= v.run_date) carrier = p;
|
|
234
|
-
if (!carrier || !countable.has(carrier)) continue;
|
|
235
|
-
const byGeneration = charged.get(carrier.chosen_cell);
|
|
236
|
-
const g = countable.get(carrier);
|
|
237
|
-
(byGeneration.get(g) ?? byGeneration.set(g, []).get(g)).push({
|
|
238
|
-
ticket: carrier.ticket, pr: v.pr, run_date: v.run_date,
|
|
239
|
-
closed_own_ticket: v.closed_own_ticket, minted_false_claim: v.minted_false_claim,
|
|
240
|
-
failed: v.minted_false_claim === "yes" || v.closed_own_ticket === "no",
|
|
241
|
-
});
|
|
242
|
-
}
|
|
243
|
-
const order = generations(admitted);
|
|
244
|
-
const tallied = (list = []) => {
|
|
245
|
-
list.sort((a, b) => Number(a.ticket) - Number(b.ticket));
|
|
246
|
-
return { verdicts: list, failures: list.filter((v) => v.failed).length };
|
|
247
|
-
};
|
|
248
|
-
return [...charged].sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0)).map(([cell, byGeneration]) => {
|
|
249
|
-
const [generation = null, ...rest] = order.get(cell) ?? [];
|
|
250
|
-
const { verdicts: list, failures } = tallied(byGeneration.get(generation));
|
|
251
|
-
const stop = list.length >= STOP.verdicts && failures / list.length >= STOP.failRate;
|
|
252
|
-
const older = rest.filter((g) => byGeneration.has(g)).map((g) => ({ generation: g, ...tallied(byGeneration.get(g)) }));
|
|
253
|
-
return { cell, since: added[cell], generation, verdicts: list, failures, stop, older };
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
|
-
|
|
257
140
|
// Only a gated cell is formatted, and a comparison needs an admissible row at
|
|
258
141
|
// the cell, so `models` is never empty here.
|
|
259
142
|
function formatModels(models) {
|
package/scripts/fleet-tick.mjs
CHANGED
|
@@ -845,6 +845,20 @@ export function foldLedger({ rows, dispatched }, open, { lenient = false } = {})
|
|
|
845
845
|
// retry suffix sorts after every landed one's. `killed` and live members
|
|
846
846
|
// are not in it, and a `reviewed=` empties it, as it resets `reviewFixed`.
|
|
847
847
|
// `reviewedHead`/`reviewedRun`: the latest `reviewed=<head>:…:<run>`.
|
|
848
|
+
// `fleetHead`: the head the PR's branch stands at as the ledger knows it,
|
|
849
|
+
// lowercase. A `reviewed=` sets it to that review's head; after it, the
|
|
850
|
+
// fix-applier that landed `applied:<head>` (`fixLanded` decides which
|
|
851
|
+
// landed after it, by row position, once per member however many copies
|
|
852
|
+
// of its token the rows carry) with the greatest retry suffix
|
|
853
|
+
// ("" < "b" < "c" …) sets it to that head — never the one whose token sits
|
|
854
|
+
// last in the row text: `dispatch` refuses a second live fix-applier on a
|
|
855
|
+
// PR, so a later suffix landed later, and a row rewrite can put a `-b`
|
|
856
|
+
// retry's token before the older one's. `fleetRetry` is the retry suffix
|
|
857
|
+
// of the fix-applier that set it, null while a `reviewed=` did. A `no-op`
|
|
858
|
+
// landing pushed nothing, and a member settled `failed` or `killed`, or
|
|
859
|
+
// still live, never lands: none of them moves it.
|
|
860
|
+
// `ledger.mjs settle --from-report` checks a fix-applier's `no-op`
|
|
861
|
+
// against it.
|
|
848
862
|
// `pastPinHalt`: the latest
|
|
849
863
|
// finisher since that review settled `halted:past-pin` — any
|
|
850
864
|
// later finisher attempt, live or settled, replaces it, and a later
|
|
@@ -858,7 +872,7 @@ export function foldLedger({ rows, dispatched }, open, { lenient = false } = {})
|
|
|
858
872
|
const st = (pr !== null && byPr.get(pr)) || {
|
|
859
873
|
inFlight: false, reviewedAny: false, survived: 0, unverified: 0, reviewFixed: false,
|
|
860
874
|
fixMembers: new Set(), fixLanded: new Set(), conflictLanded: new Set(), fixFailed: new Set(),
|
|
861
|
-
conflictOpen: false, reviewedHead: null, reviewedRun: null, pastPinHalt: false, dispositions: [], workers: new Set(),
|
|
875
|
+
conflictOpen: false, reviewedHead: null, reviewedRun: null, fleetHead: null, fleetRetry: null, pastPinHalt: false, dispositions: [], workers: new Set(),
|
|
862
876
|
finishers: new Set(), parked: [],
|
|
863
877
|
};
|
|
864
878
|
// The finisher-pr token currently deciding `pastPinHalt`, picked by
|
|
@@ -915,6 +929,10 @@ export function foldLedger({ rows, dispatched }, open, { lenient = false } = {})
|
|
|
915
929
|
const placed = t.outcome !== null || !settledInRow.has(t.name);
|
|
916
930
|
if ((o === "no-op" || /^applied:/.test(o)) && !st.fixLanded.has(t.name) && placed) {
|
|
917
931
|
st.fixLanded.add(t.name);
|
|
932
|
+
if (o !== "no-op" && (st.fleetRetry === null || (t.retry ?? "") > st.fleetRetry)) {
|
|
933
|
+
st.fleetHead = o.slice("applied:".length).toLowerCase();
|
|
934
|
+
st.fleetRetry = t.retry ?? "";
|
|
935
|
+
}
|
|
918
936
|
if (st.conflictOpen) {
|
|
919
937
|
st.conflictOpen = false;
|
|
920
938
|
st.conflictLanded.add(t.name);
|
|
@@ -955,9 +973,10 @@ export function foldLedger({ rows, dispatched }, open, { lenient = false } = {})
|
|
|
955
973
|
}
|
|
956
974
|
if (!m) throw new LedgerError(`${where}: '${tok}' is not reviewed=<head>:<survived>/<refuted>/<unverified>:<run>`);
|
|
957
975
|
latestFinisher = null;
|
|
976
|
+
const head = m[1].toLowerCase();
|
|
958
977
|
Object.assign(st, {
|
|
959
978
|
inFlight: false, reviewedAny: true, survived: Number(m[2]), unverified: Number(m[4]), reviewFixed: false,
|
|
960
|
-
reviewedHead:
|
|
979
|
+
reviewedHead: head, reviewedRun: m[5], fleetHead: head, fleetRetry: null, pastPinHalt: false, fixFailed: new Set(),
|
|
961
980
|
});
|
|
962
981
|
} else if (labelOffMember(tok) === null) {
|
|
963
982
|
if (!lenient) throw new LedgerError(`${where}: '${tok}' is not label-off=<finisher-pr member> — fix the row with \`ledger.mjs row\``);
|
|
@@ -1263,16 +1282,19 @@ export function deriveRun({ rows, dispatched, drain, retired = [] }, prs, queued
|
|
|
1263
1282
|
conflicts: conflicting.filter((p) => !treadmill(p)).map((p) => p.number).sort(asc),
|
|
1264
1283
|
conflictEscalate: conflicting.filter(treadmill).map((p) => p.number).sort(asc),
|
|
1265
1284
|
// Every PR, open or not, with a returned review: its latest `reviewed=`
|
|
1266
|
-
// head
|
|
1267
|
-
//
|
|
1268
|
-
//
|
|
1285
|
+
// head and the head its branch stands at as the ledger knows it
|
|
1286
|
+
// (`fleetHead`), run and counts, the dispositions verdict currently
|
|
1287
|
+
// answering that run, and every fix-applier on the PR still unsettled
|
|
1288
|
+
// (`fixLive`) — a re-review would otherwise read the earlier
|
|
1269
1289
|
// fix-applier's verdict while the one answering it is still working.
|
|
1270
1290
|
// `ledger.mjs dispatch` gates a finisher off this, read from the same
|
|
1271
|
-
// per-PR fold as everything above,
|
|
1272
|
-
//
|
|
1291
|
+
// per-PR fold as everything above, `ledger.mjs settle --from-report`
|
|
1292
|
+
// checks a fix-applier's `no-op` against `fleetHead`, and
|
|
1293
|
+
// dispositions-check.mjs reads the review file it judges against off
|
|
1294
|
+
// `run`. Nothing in this tick acts on it.
|
|
1273
1295
|
reviewed: [...byPr.entries()].filter(([, st]) => st.reviewedHead !== null)
|
|
1274
1296
|
.map(([n, st]) => ({
|
|
1275
|
-
pr: n, head: st.reviewedHead, run: st.reviewedRun, survived: st.survived, unverified: st.unverified,
|
|
1297
|
+
pr: n, head: st.reviewedHead, fleetHead: st.fleetHead, run: st.reviewedRun, survived: st.survived, unverified: st.unverified,
|
|
1276
1298
|
dispositions: currentDispositions(st.dispositions, st.reviewedRun),
|
|
1277
1299
|
fixLive: [...st.fixMembers].filter((name) => members.get(name).outcome === null).sort(),
|
|
1278
1300
|
}))
|
package/scripts/ledger.mjs
CHANGED
|
@@ -2711,8 +2711,12 @@ function recordFiled(id, subject) {
|
|
|
2711
2711
|
// fix-pr-M=applied:<head> origin's refs/heads/<branch> is <head>, fetched
|
|
2712
2712
|
// by verify-sha.sh; the Check-step record (below)
|
|
2713
2713
|
// holds for <head>
|
|
2714
|
-
// fix-pr-M=no-op origin's refs/heads/<branch> is
|
|
2715
|
-
//
|
|
2714
|
+
// fix-pr-M=no-op origin's refs/heads/<branch> is PR M's fleet
|
|
2715
|
+
// head, as the tick folds it: the head of the
|
|
2716
|
+
// applied:<head> the fix-applier with the
|
|
2717
|
+
// greatest retry suffix landed since PR M's
|
|
2718
|
+
// latest reviewed=, else the head that reviewed=
|
|
2719
|
+
// names
|
|
2716
2720
|
// finisher-pr-M=labelled PR M's labels carry ready-to-merge, and so does
|
|
2717
2721
|
// the report's labelsReadBack
|
|
2718
2722
|
// finisher-pr-M=halted:<c> cause is in the halted:<cause> vocabulary and
|
|
@@ -2912,13 +2916,21 @@ async function runSettleFromReport() {
|
|
|
2912
2916
|
if (!(e instanceof LedgerError)) throw e;
|
|
2913
2917
|
die(`${where}: ${e.message} — fleet-tick.mjs refuses this ledger, so PR #${live.number}'s latest reviewed= cannot be read off it; nothing written`);
|
|
2914
2918
|
}
|
|
2915
|
-
|
|
2916
|
-
|
|
2919
|
+
// An earlier fix-applier's push moved the branch past the head the latest
|
|
2920
|
+
// review names, so the head required is the fold's `fleetHead`, which
|
|
2921
|
+
// is that review's head until an `applied:` lands after it. The fold
|
|
2922
|
+
// writes it lowercase, so only origin's head needs lowercasing.
|
|
2923
|
+
const review = fold.reviewed.find((r) => r.pr === live.number);
|
|
2924
|
+
if (review === undefined) {
|
|
2917
2925
|
check(`PR #${live.number}'s row names a reviewed= head`, false);
|
|
2918
2926
|
} else {
|
|
2919
2927
|
const head = remoteHead(report.branch);
|
|
2920
|
-
|
|
2921
|
-
|
|
2928
|
+
const required = review.fleetHead;
|
|
2929
|
+
const why = required === review.head
|
|
2930
|
+
? `the head PR #${live.number}'s latest reviewed= names`
|
|
2931
|
+
: `the head PR #${live.number}'s latest applied: names, landed since its latest reviewed= ${review.head}`;
|
|
2932
|
+
check(`origin refs/heads/${report.branch} is ${required}, ${why}`,
|
|
2933
|
+
head !== null && head.toLowerCase().startsWith(required));
|
|
2922
2934
|
}
|
|
2923
2935
|
} else {
|
|
2924
2936
|
outcome = "failed";
|
|
@@ -267,20 +267,9 @@ function bookImplementers(pulls, omp) {
|
|
|
267
267
|
}
|
|
268
268
|
|
|
269
269
|
// A Pull's generation from its implementer rows: its first Admissible row's dispatch model, else null.
|
|
270
|
+
// Only `attribute` derives it, so the guard and the fit, which read its units, never name two generations for one Pull.
|
|
270
271
|
const generationOf = (own, cell) => dispatchOrder(own).find((m) => admissibleRow(m, cell))?.dispatchModel ?? null;
|
|
271
272
|
|
|
272
|
-
/**
|
|
273
|
-
* Each of `pulls` (ticket-features rows) to its generation, `attribute`'s
|
|
274
|
-
* rule over `members`: the dispatch model of the Pull's first Admissible
|
|
275
|
-
* implementer row in dispatch order, or null when it has none. Every caller
|
|
276
|
-
* that names a Pull's generation reads it here, so the guard, the fit and the
|
|
277
|
-
* stopping rule never derive two generations for one Pull.
|
|
278
|
-
*/
|
|
279
|
-
export function pullGenerations(pulls, members) {
|
|
280
|
-
const { impls } = bookImplementers(pulls, ompRows(members));
|
|
281
|
-
return new Map(pulls.map((p) => [p, generationOf(impls.get(p), p.chosen_cell)]));
|
|
282
|
-
}
|
|
283
|
-
|
|
284
273
|
// A booked row's recorded number in `column` (`field` on the parsed row; `column` defaults to `field` where the two names agree): null when blank; refused, naming the row, when neither blank nor a number.
|
|
285
274
|
function numberOf(row, field, column = field) {
|
|
286
275
|
const c = String(row[field] ?? "");
|