@feigi/fleet-ctl 3.24.0 → 3.24.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/cell-readout.mjs +3 -16
- package/scripts/ticket-router.mjs +31 -23
- package/scripts/tier-outcomes.mjs +32 -1
package/package.json
CHANGED
package/scripts/cell-readout.mjs
CHANGED
|
@@ -68,9 +68,7 @@ import { isCLI } from "./is-cli.mjs";
|
|
|
68
68
|
import { CELL, POLICY_CELL } from "./ledger-grammar.mjs";
|
|
69
69
|
import { formatTsv as formatMemberTsv, parseTsv as parseMemberTsv } from "./member-outcomes.mjs";
|
|
70
70
|
import { parseFeatures } from "./pr-cost.mjs";
|
|
71
|
-
import {
|
|
72
|
-
|
|
73
|
-
const ISO_DATE = /^\d{4}-\d{2}-\d{2}$/;
|
|
71
|
+
import { rulingFor, rulingsByTicket } from "./tier-outcomes.mjs";
|
|
74
72
|
|
|
75
73
|
const NAME = "cell-readout";
|
|
76
74
|
export const GATE = Object.freeze({ comparisons: 10, runDates: 5 });
|
|
@@ -175,11 +173,7 @@ export function readout({ features, members }) {
|
|
|
175
173
|
*/
|
|
176
174
|
export function stoppingRule({ features, members, verdicts, added }) {
|
|
177
175
|
const byKey = indexMembers(members);
|
|
178
|
-
const rulings =
|
|
179
|
-
for (const v of verdicts) {
|
|
180
|
-
if (VERDICT_COLUMNS.every((c) => v[c] === "")) continue;
|
|
181
|
-
for (const t of String(v.ticket).split("+")) (rulings.get(t) ?? rulings.set(t, []).get(t)).push(v);
|
|
182
|
-
}
|
|
176
|
+
const rulings = rulingsByTicket(verdicts);
|
|
183
177
|
// Per cell, each ticket's last admissible Pull: the one its ruling must follow.
|
|
184
178
|
const charged = new Map(Object.keys(added).filter((c) => c !== POLICY_CELL).map((c) => [c, new Map()]));
|
|
185
179
|
for (const p of features) {
|
|
@@ -190,15 +184,8 @@ export function stoppingRule({ features, members, verdicts, added }) {
|
|
|
190
184
|
return [...charged].sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0)).map(([cell, pulls]) => {
|
|
191
185
|
const list = [];
|
|
192
186
|
for (const p of pulls.values()) {
|
|
193
|
-
const
|
|
194
|
-
for (const r of own) {
|
|
195
|
-
if (!ISO_DATE.test(r.run_date)) throw new Error(`ticket #${p.ticket} (PR #${r.pr}): run_date is '${r.run_date}', expected YYYY-MM-DD`);
|
|
196
|
-
}
|
|
197
|
-
const v = own.findLast((r) => r.run_date >= p.run_date);
|
|
187
|
+
const v = rulingFor(rulings, p.ticket, p.run_date);
|
|
198
188
|
if (!v) continue;
|
|
199
|
-
for (const c of VERDICT_COLUMNS) {
|
|
200
|
-
if (!VERDICT.includes(v[c])) throw new Error(`ticket #${p.ticket} (PR #${v.pr}): ${c} is '${v[c]}', expected yes or no`);
|
|
201
|
-
}
|
|
202
189
|
list.push({
|
|
203
190
|
ticket: p.ticket, pr: v.pr, run_date: v.run_date,
|
|
204
191
|
closed_own_ticket: v.closed_own_ticket, minted_false_claim: v.minted_false_claim,
|
|
@@ -36,7 +36,7 @@ import { isCLI } from "./is-cli.mjs";
|
|
|
36
36
|
import { makeDie, defineFlags } from "./arg.mjs";
|
|
37
37
|
import { CELL, POLICY_CELL, drawCell, parseMember } from "./ledger-grammar.mjs";
|
|
38
38
|
import { parseTsv as parseMemberTsv } from "./member-outcomes.mjs";
|
|
39
|
-
import { parseTierOutcomes } from "./tier-outcomes.mjs";
|
|
39
|
+
import { DATE, parseTierOutcomes, rulingFor, rulingsByTicket } from "./tier-outcomes.mjs";
|
|
40
40
|
|
|
41
41
|
const NAME = "ticket-router";
|
|
42
42
|
const SCRIPT_DIR = dirname(fileURLToPath(import.meta.url));
|
|
@@ -280,26 +280,26 @@ export function parseFeatures(text) {
|
|
|
280
280
|
const UNBOOKED = (name) => name.startsWith("merge-bot-") || name === "memory" || name === "__advisor";
|
|
281
281
|
const round4 = (x) => Math.round(x * 1e4) / 1e4;
|
|
282
282
|
|
|
283
|
-
/**
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
}
|
|
291
|
-
return by;
|
|
283
|
+
/**
|
|
284
|
+
* The verdict on a ticket's Pull dated `pullDate`, `{ pr, fail }`, or null: the
|
|
285
|
+
* ruling `rulingFor` picks. A verdict is a ruled PR; the floor fails on a
|
|
286
|
+
* minted false claim or an unclosed ticket.
|
|
287
|
+
*/
|
|
288
|
+
function verdictOf(rulings, ticket, pullDate) {
|
|
289
|
+
const r = rulingFor(rulings, ticket, pullDate);
|
|
290
|
+
return r && { pr: String(r.pr ?? ""), fail: r.minted_false_claim === "yes" || r.closed_own_ticket === "no" };
|
|
292
291
|
}
|
|
293
292
|
|
|
294
293
|
/**
|
|
295
294
|
* Per-ticket input rows: the ticket's features rows inside [window, cutoff],
|
|
296
295
|
* attributed to its LAST row's cell and stratum, restricted to rows the
|
|
297
296
|
* free classifier routed plus exploration rows — a row a live B classifier
|
|
298
|
-
* routed is the A/B's test set, not the fit's.
|
|
299
|
-
* its latest features row's date;
|
|
300
|
-
* same date, so `--check`'s
|
|
301
|
-
*
|
|
302
|
-
* next fit instead of
|
|
297
|
+
* routed is the A/B's test set, not the fit's. Its verdict rules its last
|
|
298
|
+
* input row. A fit over everything cuts at its latest features row's date;
|
|
299
|
+
* the verdict and member rows are cut at that same date, so `--check`'s
|
|
300
|
+
* re-fit at the recorded `fitted_through` reads the rows the fit read and a
|
|
301
|
+
* verdict or member row that lands later waits for the next fit instead of
|
|
302
|
+
* failing CI.
|
|
303
303
|
*/
|
|
304
304
|
function fitTickets({ features, members, verdicts, window, cutoff }) {
|
|
305
305
|
const inRange = features.filter((r) => (!window || r.run_date >= window)
|
|
@@ -312,12 +312,15 @@ function fitTickets({ features, members, verdicts, window, cutoff }) {
|
|
|
312
312
|
if (!byTicket.has(r.ticket)) byTicket.set(r.ticket, []);
|
|
313
313
|
byTicket.get(r.ticket).push(r);
|
|
314
314
|
}
|
|
315
|
-
|
|
315
|
+
// A ruling whose date is not YYYY-MM-DD cannot be placed against the cut, and
|
|
316
|
+
// a string `<=` would drop 'abc' or '2027' unseen: it is left in, so `rulingFor`
|
|
317
|
+
// refuses it when its ticket is an input, as `fit --due` does.
|
|
318
|
+
const rulings = rulingsByTicket(verdicts.filter((r) => !DATE.test(r.run_date) || upToThrough(r)));
|
|
316
319
|
const out = [];
|
|
317
320
|
for (const [ticket, rows] of byTicket) {
|
|
318
321
|
const last = rows[rows.length - 1];
|
|
319
322
|
if (last.exploration_draw === "" && last.sizing_src !== "rule") continue;
|
|
320
|
-
const verdict =
|
|
323
|
+
const verdict = verdictOf(rulings, ticket, last.run_date);
|
|
321
324
|
const keys = new Set(rows.map((r) => `${r.session}\0${r.agent}`));
|
|
322
325
|
let cost = 0;
|
|
323
326
|
let costKnown = true;
|
|
@@ -434,11 +437,12 @@ export function fitTable({ prior, features, members, verdicts, guard, cutoff })
|
|
|
434
437
|
};
|
|
435
438
|
}
|
|
436
439
|
|
|
437
|
-
/** Merged PRs (tickets with a verdict) among the features rows dated after `fitted_through`. */
|
|
440
|
+
/** Merged PRs (tickets with a verdict on their last such row) among the features rows dated after `fitted_through`. */
|
|
438
441
|
export function mergedSince({ table, features, verdicts }) {
|
|
439
|
-
const
|
|
442
|
+
const rulings = rulingsByTicket(verdicts);
|
|
440
443
|
const after = features.filter((r) => (!table.window_start || r.run_date >= table.window_start) && (!table.fitted_through || r.run_date > table.fitted_through));
|
|
441
|
-
|
|
444
|
+
const pullDates = new Map(after.map((r) => [r.ticket, r.run_date]));
|
|
445
|
+
return [...pullDates].filter(([ticket, date]) => verdictOf(rulings, ticket, date)).length;
|
|
442
446
|
}
|
|
443
447
|
|
|
444
448
|
// ---------------------------------------------------------------------------
|
|
@@ -512,9 +516,13 @@ function main() {
|
|
|
512
516
|
const features = read("features", parseFeatures);
|
|
513
517
|
const members = read("members", parseMemberTsv);
|
|
514
518
|
const verdicts = read("verdicts", parseTierOutcomes);
|
|
519
|
+
// The verdict join throws on a ruling of an input ticket it cannot place.
|
|
520
|
+
const joined = (fit) => {
|
|
521
|
+
try { return fit(); } catch (e) { die(`cannot read --verdicts ${need("verdicts")}: ${e.message}`); }
|
|
522
|
+
};
|
|
515
523
|
|
|
516
524
|
if (mode === "check") {
|
|
517
|
-
const refit = fitTable({ prior: table, features, members, verdicts, guard: { ...table.guard, window_start: table.window_start }, cutoff: table.fitted_through });
|
|
525
|
+
const refit = joined(() => fitTable({ prior: table, features, members, verdicts, guard: { ...table.guard, window_start: table.window_start }, cutoff: table.fitted_through }));
|
|
518
526
|
const differ = Object.keys({ ...refit, ...table }).filter((k) => !isDeepStrictEqual(refit[k], table[k]));
|
|
519
527
|
if (differ.length) {
|
|
520
528
|
process.stderr.write(`${NAME}: ${tablePath} is not a re-fit of its own rows — differs in ${differ.map((k) => `\`${k}\``).join(", ")}; re-fitted:\n${JSON.stringify(refit, null, 2)}\n`);
|
|
@@ -530,11 +538,11 @@ function main() {
|
|
|
530
538
|
const guard = readGuard(readJson(guardPath));
|
|
531
539
|
if (guard === null) die(`cannot read --guard ${guardPath} as a cost guard — the fit needs its tripped cells and per-cell n`);
|
|
532
540
|
if (F.has("due")) {
|
|
533
|
-
const n = mergedSince({ table, features, verdicts });
|
|
541
|
+
const n = joined(() => mergedSince({ table, features, verdicts }));
|
|
534
542
|
process.stdout.write(`DUE=${n >= FIT_EVERY_MERGED ? "yes" : "no"} MERGED=${n}/${FIT_EVERY_MERGED}\n`);
|
|
535
543
|
return;
|
|
536
544
|
}
|
|
537
|
-
const next = fitTable({ prior: table, features, members, verdicts, guard });
|
|
545
|
+
const next = joined(() => fitTable({ prior: table, features, members, verdicts, guard }));
|
|
538
546
|
writeFileSync(`${tablePath}.tmp`, `${JSON.stringify(next, null, 2)}\n`);
|
|
539
547
|
renameSync(`${tablePath}.tmp`, tablePath);
|
|
540
548
|
process.stdout.write(`${NAME}: fitted ${next.n_rows} tickets through ${next.fitted_through ?? "no rows"}; rows ${JSON.stringify(next.rows)}; burn_in ${next.burn_in}; stage ${next.stage}\n`);
|
|
@@ -80,7 +80,7 @@ export const LEGACY_WIDTH = COLUMNS.length - 4;
|
|
|
80
80
|
// date of the header's switch note.
|
|
81
81
|
export const TIER_SWITCH_DATE = "2026-09-29";
|
|
82
82
|
|
|
83
|
-
const DATE = /^\d{4}-\d{2}-\d{2}$/;
|
|
83
|
+
export const DATE = /^\d{4}-\d{2}-\d{2}$/;
|
|
84
84
|
const BASE_DEFINITION = "fleet-implementer";
|
|
85
85
|
// The two quality-floor columns `append` writes. Every reader fails the floor
|
|
86
86
|
// on exactly `minted_false_claim=yes` or `closed_own_ticket=no`, so any other
|
|
@@ -132,6 +132,37 @@ export function formatRow(fields) {
|
|
|
132
132
|
return COLUMNS.map((c) => String(fields[c] ?? "")).join("\t");
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
+
// Each ticket's ruling rows of parsed tier-outcomes `rows`, in file order. A
|
|
136
|
+
// `+`-joined `ticket` field rules each ticket it names; a row with both
|
|
137
|
+
// verdict columns blank was never ruled, so it is skipped.
|
|
138
|
+
export function rulingsByTicket(rows) {
|
|
139
|
+
const by = new Map();
|
|
140
|
+
for (const r of rows) {
|
|
141
|
+
if (VERDICT_COLUMNS.every((c) => r[c] === "")) continue;
|
|
142
|
+
for (const t of String(r.ticket ?? "").split("+").filter(Boolean)) (by.get(t) ?? by.set(t, []).get(t)).push(r);
|
|
143
|
+
}
|
|
144
|
+
return by;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// The row ruling `ticket`'s Pull dated `pullDate`, from `rulingsByTicket`: its
|
|
148
|
+
// last ruling dated on or after the Pull, since a ruling never predates the
|
|
149
|
+
// Pull it rules — or null. Throws on a ruling of the ticket whose `run_date`
|
|
150
|
+
// is not YYYY-MM-DD, which cannot be placed against the Pull and whose drop
|
|
151
|
+
// would uncount the ticket, and on the ruling it picks holding anything but
|
|
152
|
+
// `yes` or `no` in a verdict column, which would otherwise read as a pass.
|
|
153
|
+
export function rulingFor(rulings, ticket, pullDate) {
|
|
154
|
+
const own = rulings.get(String(ticket)) ?? [];
|
|
155
|
+
for (const r of own) {
|
|
156
|
+
if (!DATE.test(r.run_date)) throw new Error(`ticket #${ticket} (PR #${r.pr}): run_date is '${r.run_date}', expected YYYY-MM-DD`);
|
|
157
|
+
}
|
|
158
|
+
const v = own.findLast((r) => r.run_date >= pullDate);
|
|
159
|
+
if (!v) return null;
|
|
160
|
+
for (const c of VERDICT_COLUMNS) {
|
|
161
|
+
if (!VERDICT.includes(v[c])) throw new Error(`ticket #${ticket} (PR #${v.pr}): ${c} is '${v[c]}', expected yes or no`);
|
|
162
|
+
}
|
|
163
|
+
return v;
|
|
164
|
+
}
|
|
165
|
+
|
|
135
166
|
// Every member-outcomes.tsv row for the ticket's implementer, of ANY agent
|
|
136
167
|
// type: a lone `task` row is still the ticket's one implementer, and the
|
|
137
168
|
// point of the check is to catch exactly that.
|