@feigi/fleet-ctl 3.145.0 → 3.146.0
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/board-gather.mjs +8 -8
- package/scripts/closeout.mjs +3 -2
- package/scripts/compute-board.mjs +4 -1
- package/scripts/compute-cell-evidence.mjs +71 -50
- package/scripts/ledger-grammar.mjs +3 -1
- package/scripts/metrics-refresh.mjs +49 -40
- package/scripts/ticket-router.mjs +41 -6
- package/skills/run-team/references/close-out.md +4 -5
- package/skills/run-team/references/phase-0.md +9 -4
- package/skills/run-team/references/pull.md +8 -3
package/package.json
CHANGED
package/scripts/board-gather.mjs
CHANGED
|
@@ -40,7 +40,7 @@ import { repoIdentity } from "./compute-cell-evidence.mjs";
|
|
|
40
40
|
import { readCostGuard } from "./fleet-tick.mjs";
|
|
41
41
|
import { parseFrontmatter } from "./tier-roles.mjs";
|
|
42
42
|
import { isImplementer } from "./member-outcomes.mjs";
|
|
43
|
-
import { validateTable } from "./ticket-router.mjs";
|
|
43
|
+
import { FIT_FILE, validateTable } from "./ticket-router.mjs";
|
|
44
44
|
import { LabelMapUnreadable, readLabelMap } from "./label-map.mjs";
|
|
45
45
|
import { FleetDirUnresolvable } from "./fleet-dir.mjs";
|
|
46
46
|
// The heartbeat's liveness mark and the controller record beside it, read here
|
|
@@ -858,17 +858,17 @@ export function readCheckoutTable(stateDir) {
|
|
|
858
858
|
return table instanceof Error ? { status: "unreadable", why: table.message } : { status: "ok", table };
|
|
859
859
|
}
|
|
860
860
|
|
|
861
|
-
// The
|
|
862
|
-
// `.fleet/router-
|
|
861
|
+
// The Fit metrics-refresh.mjs writes beside the guard,
|
|
862
|
+
// `.fleet/router-fit.json`: `{ status: "ok", fit }`, `{ status: "missing" }`
|
|
863
863
|
// or `{ status: "unreadable", why }`. Its `table` is read through `validateTable`,
|
|
864
864
|
// as the installed one is, and its `n_rows`, which `validateTable` does not check
|
|
865
865
|
// and the tab prints, must be a count; `computed_at` and `guard_computed_at` must
|
|
866
866
|
// be strings, and `tsv_blobs` and `prior` objects, their values checked where the
|
|
867
867
|
// tab reads them.
|
|
868
|
-
export function
|
|
868
|
+
export function readFitFile(stateDir) {
|
|
869
869
|
let text;
|
|
870
870
|
try {
|
|
871
|
-
text = readFileSync(join(stateDir,
|
|
871
|
+
text = readFileSync(join(stateDir, FIT_FILE), "utf8");
|
|
872
872
|
} catch (e) {
|
|
873
873
|
return e.code === "ENOENT" ? { status: "missing" } : { status: "unreadable", why: e.code ?? e.message };
|
|
874
874
|
}
|
|
@@ -884,7 +884,7 @@ export function readPreviewFile(stateDir) {
|
|
|
884
884
|
const table = validateTable(p.table);
|
|
885
885
|
if (table instanceof Error) return { status: "unreadable", why: table.message };
|
|
886
886
|
if (!Number.isInteger(table.n_rows) || table.n_rows < 0) return { status: "unreadable", why: "router table: `n_rows` is not a count" };
|
|
887
|
-
return { status: "ok",
|
|
887
|
+
return { status: "ok", fit: { computed_at: p.computed_at, guard_computed_at: p.guard_computed_at, tsv_blobs: p.tsv_blobs, prior: p.prior, table } };
|
|
888
888
|
}
|
|
889
889
|
|
|
890
890
|
// A receipt's `metrics` step, `{ status, at, output }`, or null: no receipt, one
|
|
@@ -1342,7 +1342,7 @@ export async function gather({ ledgerFile, prevFile, stateFile = null, stateDir
|
|
|
1342
1342
|
// either (a guard that reads as missing, no receipts, the read carried as it was).
|
|
1343
1343
|
const guard = stateDir === null ? { status: "missing" } : readGuardFile(stateDir);
|
|
1344
1344
|
const guardJson = stateDir === null ? null : readGuardJson(stateDir);
|
|
1345
|
-
const
|
|
1345
|
+
const fit = stateDir === null ? { status: "missing" } : readFitFile(stateDir);
|
|
1346
1346
|
const closeoutPr = stateDir === null ? null : readCloseoutPr(stateDir);
|
|
1347
1347
|
const checkoutTable = stateDir === null ? { status: "missing" } : readCheckoutTable(stateDir);
|
|
1348
1348
|
const receipts = stateDir === null
|
|
@@ -1358,6 +1358,6 @@ export async function gather({ ledgerFile, prevFile, stateFile = null, stateDir
|
|
|
1358
1358
|
: await Promise.all([carryModelRoles(prev?.modelRoles, now), carryMainMetrics(prev?.mainMetrics, now, repoUrl)]);
|
|
1359
1359
|
return { ledger, issues, prs, merged, closed, closedIssues, ci, prev, repo, repoUrl, workspace, port, spend, beat, ticked, acted, controller, stallOwner: stallOwnerOf, poolOk,
|
|
1360
1360
|
roles, labelMapError,
|
|
1361
|
-
poolCapped, prsOk, prsCapped, guard, guardJson,
|
|
1361
|
+
poolCapped, prsOk, prsCapped, guard, guardJson, fit, receipts, closeoutPr, agents, modelRoles, mainMetrics, install, objective, implementers: [...implementers.values()], routerTable, checkoutTable,
|
|
1362
1362
|
now, interval };
|
|
1363
1363
|
}
|
package/scripts/closeout.mjs
CHANGED
|
@@ -37,7 +37,8 @@
|
|
|
37
37
|
// `NEED tier-outcomes append <n>`, and the step is pending.
|
|
38
38
|
// The verdicts come from `tier-outcomes.mjs append`, which
|
|
39
39
|
// works them out from the Charges; this script never writes one.
|
|
40
|
-
// metrics `metrics-refresh.mjs
|
|
40
|
+
// metrics `metrics-refresh.mjs --no-fit`: close-out computes no Fit,
|
|
41
|
+
// the next run's phase 0 does. Any non-zero exit is a failed step.
|
|
41
42
|
// gather run-records.mjs's gather(): every run archive `ledger.mjs
|
|
42
43
|
// rotate` left in `.fleet/` (`ledger.<stamp>.md`,
|
|
43
44
|
// `phase0.<stamp>.json`, `closeout.<stamp>.json`) into
|
|
@@ -349,7 +350,7 @@ function stepTierOutcomes({ cwd }) {
|
|
|
349
350
|
}
|
|
350
351
|
|
|
351
352
|
function stepMetrics({ cwd }) {
|
|
352
|
-
const r = node("metrics-refresh.mjs", [], { cwd });
|
|
353
|
+
const r = node("metrics-refresh.mjs", ["--no-fit"], { cwd });
|
|
353
354
|
return r.status === 0 ? ok(r.stdout) : failed(`metrics-refresh.mjs failed: ${detail(r)}`);
|
|
354
355
|
}
|
|
355
356
|
|
|
@@ -369,6 +369,9 @@ function reasonWords(r, table) {
|
|
|
369
369
|
case "guard-missing": return [part("no cost guard yet: default Cell only")];
|
|
370
370
|
case "no-issue-json": return [part("issue unreadable when routed")];
|
|
371
371
|
case "no-sizing": return [part("no sizing")];
|
|
372
|
+
case "fit-missing": return [part("no Fit: starting table")];
|
|
373
|
+
case "fit-unreadable": return [part("Fit unreadable: starting table")];
|
|
374
|
+
case "fit-invalid": return [part("Fit invalid: starting table")];
|
|
372
375
|
default: return [part(`recorded as ${r.reason}`)];
|
|
373
376
|
}
|
|
374
377
|
}
|
|
@@ -867,7 +870,7 @@ export function computeBoard(inputs) {
|
|
|
867
870
|
cellEvidence: computeCellEvidence({
|
|
868
871
|
guard: inputs.guard,
|
|
869
872
|
guardJson: inputs.guardJson,
|
|
870
|
-
|
|
873
|
+
fit: inputs.fit,
|
|
871
874
|
receipts: inputs.receipts,
|
|
872
875
|
closeoutPr: inputs.closeoutPr,
|
|
873
876
|
openPrs: inputs.prsOk === false ? null : { numbers: (inputs.prs ?? []).map((p) => p.number), capped: inputs.prsCapped === true },
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// The cockpit's Cell evidence tab, as a value: computeCellEvidence() turns what
|
|
2
2
|
// gather() read (the cost guard, the receipts' `metrics` steps, the installed
|
|
3
3
|
// definitions, the installed router table and package, the carried `modelRoles`
|
|
4
|
-
// read, the
|
|
4
|
+
// read, the Fit) into the model the page lays out.
|
|
5
5
|
// Pure, like compute-board.mjs, which calls it and puts the answer in
|
|
6
6
|
// `board.json` as `cellEvidence`: no file, no process, no clock. Every word the
|
|
7
7
|
// tab shows is built here, so a test pins it where it is made and the page only
|
|
@@ -14,11 +14,16 @@
|
|
|
14
14
|
// routes-now side the Cell the installed router table plus the workspace's guard
|
|
15
15
|
// route to, why, and how a Pull on that row is dispatched (ticket-router.mjs's
|
|
16
16
|
// rowDispatch, the function `route` itself calls), and on the evidence-favours
|
|
17
|
-
// side the same for the
|
|
18
|
-
// metrics-refresh.mjs writes beside the guard), marked where its Cell
|
|
19
|
-
// The
|
|
20
|
-
//
|
|
21
|
-
//
|
|
17
|
+
// side the same for the Fit's table (`.fleet/router-fit.json`, which
|
|
18
|
+
// metrics-refresh.mjs writes beside the guard at phase 0), marked where its Cell
|
|
19
|
+
// differs. The installed table is the starting table: `route` with no `--table`
|
|
20
|
+
// routes by the Fit beside its `--guard`, and by the installed table only when
|
|
21
|
+
// that Fit is missing, unreadable or invalid, so routes now lays out the
|
|
22
|
+
// installed table, not always the one `route` routes by.
|
|
23
|
+
// The receipts' newest `metrics` step is what the guard section quotes when there
|
|
24
|
+
// is no guard; the newest one that tried a refit feeds the evidence-favours side:
|
|
25
|
+
// a refit that step says failed, with no fit written after it, is said in that
|
|
26
|
+
// side's heading.
|
|
22
27
|
// Figures show only from a guard `readCostGuard` (fleet-tick.mjs, the reader
|
|
23
28
|
// the tick judges the file by) accepts; `guard` here is that reader's own
|
|
24
29
|
// answer, `{ status: "ok", guard }` or
|
|
@@ -119,19 +124,30 @@ function tierRoute(role, level, generation, modelRoles) {
|
|
|
119
124
|
|
|
120
125
|
// ---------------------------------------------------------------------------
|
|
121
126
|
// The newest `metrics` step of the phase 0 and close-out receipts: the guard
|
|
122
|
-
// section quotes it when there is no guard
|
|
127
|
+
// section quotes it when there is no guard. Evidence favours reads a failed
|
|
128
|
+
// refit off the newest one that tried a refit instead.
|
|
123
129
|
// ---------------------------------------------------------------------------
|
|
124
130
|
|
|
125
131
|
// `step` is `{ status, at, output }` or null. A step that has not run carries no
|
|
126
132
|
// refresh to quote.
|
|
127
133
|
const ran = (step) => step != null && step.status !== "pending" && Number.isFinite(Date.parse(step.at));
|
|
128
134
|
|
|
135
|
+
// The newest of `steps` by `at`; on equal times, the first. Null for none.
|
|
136
|
+
const newest = (steps) => (steps.length === 0 ? null : steps.reduce((a, b) => (Date.parse(b.at) > Date.parse(a.at) ? b : a)));
|
|
137
|
+
|
|
129
138
|
// The newest `metrics` step of the two receipts that has run, by `at`; on equal
|
|
130
139
|
// times, phase 0's. Null when neither receipt has run one.
|
|
131
140
|
function newestStep(receipts) {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
141
|
+
return newest([receipts?.phase0, receipts?.closeout].filter(ran));
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// The newest `metrics` step of the two receipts that tried a refit — its output
|
|
145
|
+
// carries a `metrics-refresh: fit:` line — picked as newestStep picks. A
|
|
146
|
+
// close-out's step, which runs with `--no-fit` and computes no Fit, and a step
|
|
147
|
+
// that stopped before its refit tried none, so neither hides an earlier
|
|
148
|
+
// failure. Null when neither receipt's step tried one.
|
|
149
|
+
function newestRefit(receipts) {
|
|
150
|
+
return newest([receipts?.phase0, receipts?.closeout].filter((s) => ran(s) && /metrics-refresh: fit: /.test(String(s.output ?? ""))));
|
|
135
151
|
}
|
|
136
152
|
|
|
137
153
|
// metrics-refresh's own line from a step's output: the cost-guard duty's, else
|
|
@@ -156,11 +172,11 @@ function newestRefresh(step) {
|
|
|
156
172
|
return { verb, at: step.at, why };
|
|
157
173
|
}
|
|
158
174
|
|
|
159
|
-
// Why the
|
|
160
|
-
// metrics-refresh's `
|
|
175
|
+
// Why the Fit failed, off a `metrics` step's output: the rest of
|
|
176
|
+
// metrics-refresh's `fit: failed — ` line, trimmed, or null when the output
|
|
161
177
|
// has none. Found anywhere in a line, as refreshLine finds its own.
|
|
162
178
|
export function refitFailure(output) {
|
|
163
|
-
const m = /metrics-refresh:
|
|
179
|
+
const m = /metrics-refresh: fit: failed — ([^\n]*)/.exec(String(output ?? ""));
|
|
164
180
|
return m === null ? null : m[1].trim();
|
|
165
181
|
}
|
|
166
182
|
|
|
@@ -485,7 +501,7 @@ function routesSource(table, install, repoUrl) {
|
|
|
485
501
|
|
|
486
502
|
// The Cells short of `MIN_N` merged PRs in the table's `guard.n`, in the table's
|
|
487
503
|
// order, as one phrase: past tense for an installed table, whose counts are what
|
|
488
|
-
// its fit saw ("had"), present for the
|
|
504
|
+
// its fit saw ("had"), present for the Fit, whose counts are the
|
|
489
505
|
// workspace's own now ("has", "have").
|
|
490
506
|
function shortWords(table, tense = "past") {
|
|
491
507
|
const short = table.cells.filter((c) => (table.guard.n[c] ?? 0) < MIN_N).map((c) => [c, table.guard.n[c] ?? 0]);
|
|
@@ -549,7 +565,7 @@ function intervalWords(range, objective) {
|
|
|
549
565
|
}
|
|
550
566
|
|
|
551
567
|
// One row of a table under the guard — the installed table for routes now, the
|
|
552
|
-
//
|
|
568
|
+
// Fit's for evidence favours: the Cell it routes to and why, its
|
|
553
569
|
// dispatch, and each candidate's n (null where the table carries no count),
|
|
554
570
|
// verdict and interval.
|
|
555
571
|
function rowEntry(table, guard, modelRoles, objective, stratum) {
|
|
@@ -620,22 +636,23 @@ function routesNow({ table, guard, modelRoles, install, repoUrl, checkout }) {
|
|
|
620
636
|
}
|
|
621
637
|
|
|
622
638
|
// ---------------------------------------------------------------------------
|
|
623
|
-
// Policy rows: what the evidence favours — the
|
|
639
|
+
// Policy rows: what the evidence favours — the Fit, `.fleet/router-fit.json`.
|
|
624
640
|
// ---------------------------------------------------------------------------
|
|
625
641
|
|
|
626
642
|
const FAVOURS = "evidence favours";
|
|
627
643
|
|
|
628
|
-
// The evidence-favours side with no
|
|
644
|
+
// The evidence-favours side with no Fit to lay out: its heading says
|
|
629
645
|
// why, and its column is empty — nothing is unknown there, there is nothing to show.
|
|
630
646
|
const noFit = (heading, labels = []) => ({
|
|
631
|
-
title: FAVOURS, source: { text: "
|
|
647
|
+
title: FAVOURS, source: { text: "Fit", check: null }, heading, labels, footnotes: [], rows: null, unread: null,
|
|
632
648
|
});
|
|
633
649
|
|
|
634
|
-
// The newest refit failed: `step` is the receipts' newest `metrics` step
|
|
635
|
-
// the
|
|
636
|
-
// the failed line and no fit was written after
|
|
637
|
-
// step's `at`, or one that is no time. A later
|
|
638
|
-
// one, or the receipt no
|
|
650
|
+
// The newest refit failed: `step` is the receipts' newest `metrics` step that
|
|
651
|
+
// tried a refit, newestRefit's pick, `p` the Fit read, null when none was. Said
|
|
652
|
+
// while that step's output holds the failed line and no fit was written after
|
|
653
|
+
// it — a `computed_at` before the step's `at`, or one that is no time. A later
|
|
654
|
+
// step that tried a refit, a fit written after this one, or the receipt no
|
|
655
|
+
// longer read clears it; a close-out step, which tries none, does not.
|
|
639
656
|
function refitLabel(step, p) {
|
|
640
657
|
if (step === null) return [];
|
|
641
658
|
const why = refitFailure(step.output);
|
|
@@ -645,7 +662,7 @@ function refitLabel(step, p) {
|
|
|
645
662
|
return [`the newest refit failed at ${when(step.at)}: ${why}`];
|
|
646
663
|
}
|
|
647
664
|
|
|
648
|
-
// The
|
|
665
|
+
// The Fit's heading labels, against `raw`, the guard on disk, `routed`,
|
|
649
666
|
// readGuard's answer for it, `table`, the installed one, and `records`, whether
|
|
650
667
|
// the fit read the guard's files: fitted beside another guard, on other records,
|
|
651
668
|
// or against another prior. The prior is
|
|
@@ -653,7 +670,7 @@ function refitLabel(step, p) {
|
|
|
653
670
|
// `splits`, and `window_start` when the guard gives none — so a release that changes only
|
|
654
671
|
// what the fit recomputes, or `fitted_commit` and `version`, raises nothing: the
|
|
655
672
|
// next phase 0's refit would come out the same.
|
|
656
|
-
function
|
|
673
|
+
function fitLabels(p, raw, routed, table, records) {
|
|
657
674
|
const labels = [];
|
|
658
675
|
if (p.guard_computed_at !== raw.computed_at) labels.push(`fitted beside the guard of ${when(p.guard_computed_at)}, not this one`);
|
|
659
676
|
if (records === null) labels.push("fitted on the guard's records: not checked: this guard predates the blob ids it needs");
|
|
@@ -685,19 +702,19 @@ function nDiffers(p, raw, records) {
|
|
|
685
702
|
}).map((e) => e.cell);
|
|
686
703
|
}
|
|
687
704
|
|
|
688
|
-
// The evidence-favours side: the
|
|
705
|
+
// The evidence-favours side: the Fit's table laid out row by row under
|
|
689
706
|
// the workspace's guard, as routes now lays out the installed one, each row's
|
|
690
|
-
// Cell marked where it differs from the Cell routes now gives that row. `
|
|
691
|
-
// is gather's read, `{ status: "ok",
|
|
707
|
+
// Cell marked where it differs from the Cell routes now gives that row. `fit`
|
|
708
|
+
// is gather's read, `{ status: "ok", fit } | { status: "missing" } | {
|
|
692
709
|
// status: "unreadable", why }`; `guard` readCostGuard's answer and `routed`
|
|
693
710
|
// readGuard's for the same file, null when the router reads none; `step` the
|
|
694
|
-
// receipts' newest `metrics` step,
|
|
711
|
+
// receipts' newest `metrics` step that tried a refit, newestRefit's pick; `mark` the footnote mark
|
|
695
712
|
// its n footnote takes.
|
|
696
|
-
function evidenceFavours({
|
|
697
|
-
if (routed === null) return noFit("no
|
|
698
|
-
if (
|
|
699
|
-
if (
|
|
700
|
-
const p =
|
|
713
|
+
function evidenceFavours({ fit: read, guard, routed, table, modelRoles, step, mark }) {
|
|
714
|
+
if (routed === null) return noFit("no Fit: it is written only beside a cost guard");
|
|
715
|
+
if (read?.status === "unreadable") return noFit(`no Fit read: ${read.why}`, refitLabel(step, null));
|
|
716
|
+
if (read?.status !== "ok") return noFit("no Fit yet: the next phase 0 writes one", refitLabel(step, null));
|
|
717
|
+
const p = read.fit;
|
|
701
718
|
const fit = p.table;
|
|
702
719
|
const raw = guard.guard;
|
|
703
720
|
// Whether the fit read the guard's files: null when the guard names no blob
|
|
@@ -715,9 +732,9 @@ function evidenceFavours({ preview, guard, routed, table, modelRoles, step, mark
|
|
|
715
732
|
};
|
|
716
733
|
return {
|
|
717
734
|
title: FAVOURS,
|
|
718
|
-
source: { text: ["
|
|
735
|
+
source: { text: ["Fit", "this repository's runs", `computed ${when(p.computed_at)}`, plural(fit.n_rows, "Pull")].join(" · "), check: null },
|
|
719
736
|
heading: fit.burn_in ? `stage ${fit.stage}: ${shortWords(fit, "present") ?? "every Cell has its merged PRs"}` : null,
|
|
720
|
-
labels: [...refitLabel(step, p), ...
|
|
737
|
+
labels: [...refitLabel(step, p), ...fitLabels(p, raw, routed, table, records)],
|
|
721
738
|
footnotes: differ.length === 0 ? [] : [{ mark, text: `${list(differ)}: the guard counts merges by GitHub's state, the fit by Rulings, and the fit admits only drawn or rule-sized Pulls` }],
|
|
722
739
|
rows: Object.fromEntries(OBJECTIVES.map((o) => [o,
|
|
723
740
|
Object.fromEntries(Object.keys(fit.rows[o]).map((s) => [s, entry(o, s)])),
|
|
@@ -820,14 +837,18 @@ function prIsOpen(pr, openPrs) {
|
|
|
820
837
|
return openPrs.capped === true ? null : false;
|
|
821
838
|
}
|
|
822
839
|
|
|
823
|
-
// The guard's and the
|
|
840
|
+
// The guard's and the Fit's TSV blob ids against main's. `alert` is the
|
|
824
841
|
// alert while the records are not on main, else null; `note`, in its place, is
|
|
825
842
|
// a note under the guard section's heading: a check that could not run is never
|
|
826
843
|
// an alert, so an offline cockpit raises none. `main` is the carried read of
|
|
827
844
|
// `docs/metrics`, `{ value: { blobs }, readAt, error }`, `blobs` null for a 404.
|
|
828
845
|
// A guard that names no blob ids has nothing to compare, and neither has one
|
|
829
|
-
// whose cockpit read nothing (`main` null).
|
|
830
|
-
|
|
846
|
+
// whose cockpit read nothing (`main` null). The Fit is compared only while it
|
|
847
|
+
// was fitted beside this guard: a guard written after it — a close-out's,
|
|
848
|
+
// which computes no Fit, or one whose refit failed — moves on alone, and
|
|
849
|
+
// evidence favours' heading already says the Fit was fitted beside another
|
|
850
|
+
// guard.
|
|
851
|
+
function recordsAgainstMain({ read, fit, main, closeoutPr, openPrs }) {
|
|
831
852
|
const none = { alert: null, note: null };
|
|
832
853
|
if (main == null || read?.status !== "ok") return none;
|
|
833
854
|
const g = read.guard;
|
|
@@ -840,7 +861,7 @@ function recordsAgainstMain({ read, preview, main, closeoutPr, openPrs }) {
|
|
|
840
861
|
if (blobs === null) return { alert: null, note: "records against main: main holds no metrics yet" };
|
|
841
862
|
if (!isRecord(blobs)) return unchecked("main's docs/metrics not read yet");
|
|
842
863
|
|
|
843
|
-
const mine =
|
|
864
|
+
const mine = fit?.status === "ok" && fit.fit.guard_computed_at === g.computed_at ? fit.fit : null;
|
|
844
865
|
const held = (ids, path) => (isRecord(ids) && Object.hasOwn(ids, path) ? ids[path] : undefined);
|
|
845
866
|
const paths = [...new Set([...Object.keys(g.tsv_blobs), ...(mine === null ? [] : Object.keys(mine.tsv_blobs))])].sort();
|
|
846
867
|
const lines = [];
|
|
@@ -855,14 +876,14 @@ function recordsAgainstMain({ read, preview, main, closeoutPr, openPrs }) {
|
|
|
855
876
|
if (!gd && !fd) continue;
|
|
856
877
|
guardDiffers ||= gd;
|
|
857
878
|
fitDiffers ||= fd;
|
|
858
|
-
const said = [guardId === undefined ? null : fitId === guardId ? `the guard and the
|
|
859
|
-
fitId === undefined || fitId === guardId ? null : `the
|
|
879
|
+
const said = [guardId === undefined ? null : fitId === guardId ? `the guard and the Fit read ${blob8(guardId)}` : `the guard read ${blob8(guardId)}`,
|
|
880
|
+
fitId === undefined || fitId === guardId ? null : `the Fit read ${blob8(fitId)}`].filter(Boolean);
|
|
860
881
|
lines.push(`${path}: ${said.join(", ")}; main holds ${onMain === undefined ? "none" : blob8(onMain)}`);
|
|
861
882
|
}
|
|
862
883
|
if (lines.length === 0) return none;
|
|
863
884
|
|
|
864
885
|
const both = guardDiffers && fitDiffers;
|
|
865
|
-
const subject = both ? "the guard and the
|
|
886
|
+
const subject = both ? "the guard and the Fit" : guardDiffers ? "the guard" : "the Fit";
|
|
866
887
|
const pr = Number.isInteger(closeoutPr?.number) ? closeoutPr.number : null;
|
|
867
888
|
const open = prIsOpen(pr, openPrs);
|
|
868
889
|
const computed = guardDiffers ? g.computed_at : mine.computed_at;
|
|
@@ -876,7 +897,7 @@ function recordsAgainstMain({ read, preview, main, closeoutPr, openPrs }) {
|
|
|
876
897
|
const committed = Date.parse(closeoutPr.at);
|
|
877
898
|
if (!Number.isFinite(committed)) return unchecked(`the close-out receipt records no time for PR #${pr}'s commit step`);
|
|
878
899
|
const built = Date.parse(computed);
|
|
879
|
-
if (!Number.isFinite(built)) return unchecked(`the ${guardDiffers ? "guard" : "
|
|
900
|
+
if (!Number.isFinite(built)) return unchecked(`the ${guardDiffers ? "guard" : "Fit"} records no time it was computed`);
|
|
880
901
|
sentence = built <= committed
|
|
881
902
|
? `${subject} ${both ? "count" : "counts"} the rows of open PR #${pr}, not on main yet`
|
|
882
903
|
: `${subject} ${both ? "lack" : "lacks"} the rows of open PR #${pr}`;
|
|
@@ -928,20 +949,20 @@ function readersAlert(json) {
|
|
|
928
949
|
* cellLine). `table` is the installed router table `validateTable` accepted or
|
|
929
950
|
* null, `install` the install's `{ name, version, repository, error }`
|
|
930
951
|
* (`repository` its url), `repoUrl` the workspace's, `objective` the live
|
|
931
|
-
* run's Objective or null between runs, and `
|
|
932
|
-
* read `.fleet/router-
|
|
952
|
+
* run's Objective or null between runs, and `fit` the Fit as gather
|
|
953
|
+
* read `.fleet/router-fit.json`: `{ status: "ok", fit: { computed_at,
|
|
933
954
|
* guard_computed_at, tsv_blobs, prior, table } }`, `{ status: "missing" }` or
|
|
934
955
|
* `{ status: "unreadable", why }`. An input left out reads as nothing
|
|
935
956
|
* read: a missing guard, no receipt, no definitions, no `modelRoles` read, no
|
|
936
|
-
* Pull, no table, no install, no Objective, no
|
|
957
|
+
* Pull, no table, no install, no Objective, no Fit.
|
|
937
958
|
*/
|
|
938
|
-
export function computeCellEvidence({ guard, receipts, agents, modelRoles = null, pulls = [], table = null, install = null, repoUrl = null, objective = null,
|
|
959
|
+
export function computeCellEvidence({ guard, receipts, agents, modelRoles = null, pulls = [], table = null, install = null, repoUrl = null, objective = null, fit = null,
|
|
939
960
|
guardJson = null, mainMetrics = null, closeoutPr = null, openPrs = null, checkoutTable = null }) {
|
|
940
961
|
const routed = guard?.status === "ok" ? readGuard(guard.guard) : null;
|
|
941
962
|
const routes = routesNow({ table, guard: routed, modelRoles, install, repoUrl, checkout: checkoutTable });
|
|
942
963
|
const step = newestStep(receipts);
|
|
943
|
-
const favours = evidenceFavours({
|
|
944
|
-
const records = recordsAgainstMain({ read: guard,
|
|
964
|
+
const favours = evidenceFavours({ fit, guard, routed, table, modelRoles, step: newestRefit(receipts), mark: superscript(routes.footnotes.length + 1) });
|
|
965
|
+
const records = recordsAgainstMain({ read: guard, fit, main: mainMetrics, closeoutPr, openPrs });
|
|
945
966
|
return {
|
|
946
967
|
alerts: [records.alert, noRulingAlert(guard), readersAlert(guardJson)].filter((a) => a !== null),
|
|
947
968
|
policy: policyRowsView({ sides: [routes, favours], objective }),
|
|
@@ -910,7 +910,9 @@ export const isRulePath = (x) => typeof x === "string" && RULE_PATH.test(x);
|
|
|
910
910
|
// receipt, and every Routing names the one it routed by.
|
|
911
911
|
export const OBJECTIVES = Object.freeze(["cost", "speed"]);
|
|
912
912
|
const DRAWN_BY = Object.freeze(["burn-in", "every-5th"]);
|
|
913
|
-
export const ROUTING_REASONS = Object.freeze([
|
|
913
|
+
export const ROUTING_REASONS = Object.freeze([
|
|
914
|
+
"ok", "no-issue-json", "no-sizing", "guard-missing", "guard-tripped", "table-cell-tripped", "fit-missing", "fit-unreadable", "fit-invalid",
|
|
915
|
+
]);
|
|
914
916
|
const SIZINGS = Object.freeze(["light", "heavy"]);
|
|
915
917
|
const ROUTING_KEYS = Object.freeze(["POLICY", "CELL", "DRAW", "BY", "STRATUM", "BRIEF", "CRITERIA", "PARENT", "SIZED", "OBJECTIVE", "TRIPPED", "REASON"]);
|
|
916
918
|
const PARENT_AT = ROUTING_KEYS.indexOf("PARENT");
|
|
@@ -2,13 +2,15 @@
|
|
|
2
2
|
// The run's metrics duties that keep the router's inputs current: move the
|
|
3
3
|
// pending ticket-features rows into the tracked corpus, widen a member-outcomes
|
|
4
4
|
// corpus written before its latest columns, refresh the cost guard over it, then
|
|
5
|
-
// write the
|
|
5
|
+
// write the Fit beside that guard.
|
|
6
6
|
//
|
|
7
|
-
// metrics-refresh.mjs [--repo <dir>]
|
|
7
|
+
// metrics-refresh.mjs [--repo <dir>] [--no-fit]
|
|
8
8
|
//
|
|
9
9
|
// --repo the workspace whose `.fleet/` and `docs/metrics/` the duties read
|
|
10
10
|
// and write; default the main checkout of the repository the cwd is
|
|
11
11
|
// in, where the router script appends its pending rows
|
|
12
|
+
// --no-fit the duties only, no Fit: close-out passes it, so a run computes
|
|
13
|
+
// one Fit, at its phase 0, and each close-out's rows route the next run
|
|
12
14
|
//
|
|
13
15
|
// DRAIN. `ticket-router.mjs route` appends one row per Pull to
|
|
14
16
|
// `.fleet/ticket-features.pending.tsv`; this moves them into
|
|
@@ -59,28 +61,34 @@
|
|
|
59
61
|
// (no verdict yet — the baseline cell has too few merged PRs) are verdicts the
|
|
60
62
|
// router and `fleet-tick.mjs` consume, not failures; any other non-zero exit is.
|
|
61
63
|
//
|
|
62
|
-
//
|
|
63
|
-
//
|
|
64
|
-
//
|
|
65
|
-
//
|
|
66
|
-
//
|
|
67
|
-
//
|
|
68
|
-
// `
|
|
69
|
-
//
|
|
70
|
-
//
|
|
71
|
-
//
|
|
72
|
-
//
|
|
73
|
-
//
|
|
74
|
-
//
|
|
75
|
-
//
|
|
76
|
-
//
|
|
77
|
-
//
|
|
78
|
-
//
|
|
64
|
+
// FIT. After the cost guard wrote a guard, and only then, the Router's fit
|
|
65
|
+
// (`ticket-router.mjs`'s fitTable) runs in-process over the working-tree TSVs
|
|
66
|
+
// the guard just read and the guard just written, with the starting table
|
|
67
|
+
// (`router-table.json` beside the scripts) as its prior and no commit. It
|
|
68
|
+
// writes the Fit, `.fleet/router-fit.json`, through a temp file and a rename:
|
|
69
|
+
// `computed_at`, `guard_computed_at` (the guard's own `computed_at`),
|
|
70
|
+
// `guard` (the guard it used, as the router reads it: its `computed_at`,
|
|
71
|
+
// `tripped`, per-Cell `n` and `window_start`), `tsv_blobs` (the git blob id of
|
|
72
|
+
// each TSV it read, keyed by path as the guard keys its own), `prior` (the
|
|
73
|
+
// starting table's `fitted_commit`, `stage`, `cells`, `classifier`, `splits`
|
|
74
|
+
// and `window_start`, and the install's `package.json` `version`) and the
|
|
75
|
+
// fitted `table`. `ticket-router.mjs route` routes by that `table`, read
|
|
76
|
+
// beside the guard; nothing commits the file. The Fit is a pure function of
|
|
77
|
+
// those records: the TSVs at the recorded blob ids, the guard and the prior
|
|
78
|
+
// fit to the same table again. With no records it is the starting table's
|
|
79
|
+
// fit, as any other. It is called in-process because a fit has no verdict
|
|
80
|
+
// for an exit status to carry, and the `fit` CLI reads the TSVs only as
|
|
81
|
+
// committed. It never fails the run: an error prints `metrics-refresh: fit:
|
|
82
|
+
// failed — <why>`, leaves the old file in place, so the run routes by the
|
|
83
|
+
// last Fit that computed, and leaves the exit status as the other duties set
|
|
84
|
+
// it. That line stays on stdout: the cockpit reads it off the receipts'
|
|
85
|
+
// `metrics` step, and close-out's receipt keeps only stdout from a run that
|
|
86
|
+
// exits 0.
|
|
79
87
|
//
|
|
80
88
|
// One `metrics-refresh: <duty>: …` line per duty on stdout. Exit 0 when no
|
|
81
89
|
// duty failed; 1 when one failed — named on stderr, and the duties after
|
|
82
90
|
// it did not run (each is safe to run again); 2 on a usage error. The
|
|
83
|
-
//
|
|
91
|
+
// Fit is not one of those duties: it never sets the exit status.
|
|
84
92
|
|
|
85
93
|
import { spawnSync } from "node:child_process";
|
|
86
94
|
import { existsSync, mkdirSync, readFileSync, renameSync, unlinkSync, writeFileSync } from "node:fs";
|
|
@@ -94,7 +102,7 @@ import { COLUMNS as MEMBER_COLUMNS, ENDINGS, isImplementer, parseTsv as parseMem
|
|
|
94
102
|
import { blobId } from "./pr-cost.mjs";
|
|
95
103
|
import { FEATURE_COLUMNS, parseFeatures } from "./pull-attribution.mjs";
|
|
96
104
|
import { REPORT_STATUSES } from "./report-files.mjs";
|
|
97
|
-
import { DEFAULT_TABLE, INSTALL_PACKAGE, fitTable, installVersion, readGuard, validateTable } from "./ticket-router.mjs";
|
|
105
|
+
import { DEFAULT_TABLE, FIT_FILE, INSTALL_PACKAGE, fitTable, installVersion, readGuard, validateTable } from "./ticket-router.mjs";
|
|
98
106
|
import { parseTierOutcomes } from "./tier-outcomes.mjs";
|
|
99
107
|
|
|
100
108
|
const NAME = "metrics-refresh";
|
|
@@ -105,7 +113,7 @@ const MEMBERS = join("docs", "metrics", "member-outcomes.tsv");
|
|
|
105
113
|
const TIERS = join("docs", "metrics", "tier-outcomes.tsv");
|
|
106
114
|
const CORPUS = [MEMBERS, TIERS, FEATURES];
|
|
107
115
|
const GUARD = join(".fleet", "cost-guard.json");
|
|
108
|
-
const
|
|
116
|
+
const FIT = join(".fleet", FIT_FILE);
|
|
109
117
|
// pr-cost.mjs --guard: 0 no cell tripped, 3 a cell tripped, 4 no verdict yet —
|
|
110
118
|
// all three are verdicts its readers consume; anything else is a failure.
|
|
111
119
|
const GUARD_VERDICT_EXITS = new Set([0, 3, 4]);
|
|
@@ -276,19 +284,19 @@ function costGuard(repo) {
|
|
|
276
284
|
return g;
|
|
277
285
|
}
|
|
278
286
|
|
|
279
|
-
// The
|
|
287
|
+
// The Fit over `repo`'s working-tree TSVs and `written`, the guard file the
|
|
280
288
|
// guard duty just wrote (parsed), with the router table at `tablePath` as its
|
|
281
|
-
// prior, written to `.fleet/router-
|
|
282
|
-
//
|
|
283
|
-
//
|
|
284
|
-
export function
|
|
289
|
+
// prior, written to `.fleet/router-fit.json` through a temp file and a rename.
|
|
290
|
+
// Throws on anything it cannot read, fit or write, before the rename, so the
|
|
291
|
+
// old file stays as it was.
|
|
292
|
+
export function writeFit(repo, written, { tablePath = DEFAULT_TABLE, packagePath = INSTALL_PACKAGE, now = new Date() } = {}) {
|
|
285
293
|
const guard = readGuard(written);
|
|
286
294
|
if (guard === null) throw new Error(`${GUARD} is not a guard the router reads`);
|
|
287
295
|
let prior;
|
|
288
296
|
try {
|
|
289
297
|
prior = validateTable(JSON.parse(readFileSync(tablePath, "utf8")));
|
|
290
298
|
} catch (e) {
|
|
291
|
-
throw new Error(`cannot read the
|
|
299
|
+
throw new Error(`cannot read the starting router table ${tablePath}: ${e.code ?? e.message}`);
|
|
292
300
|
}
|
|
293
301
|
if (prior instanceof Error) throw new Error(`${tablePath}: ${prior.message}`);
|
|
294
302
|
// Keyed by the path as the guard keys its own (pr-cost.mjs reads these, relative to the workspace).
|
|
@@ -302,9 +310,10 @@ export function writePreview(repo, written, { tablePath = DEFAULT_TABLE, package
|
|
|
302
310
|
const verdicts = read(TIERS, parseTierOutcomes);
|
|
303
311
|
const features = read(FEATURES, parseFeatures);
|
|
304
312
|
const table = fitTable({ prior, features, members, verdicts, guard, commit: null });
|
|
305
|
-
const
|
|
313
|
+
const record = {
|
|
306
314
|
computed_at: now.toISOString(),
|
|
307
315
|
guard_computed_at: written.computed_at,
|
|
316
|
+
guard: { computed_at: written.computed_at, tripped: guard.tripped, n: guard.n, window_start: guard.window_start },
|
|
308
317
|
tsv_blobs: Object.fromEntries(Object.entries(tsvBlobs).sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))),
|
|
309
318
|
prior: {
|
|
310
319
|
fitted_commit: prior.fitted_commit,
|
|
@@ -317,28 +326,28 @@ export function writePreview(repo, written, { tablePath = DEFAULT_TABLE, package
|
|
|
317
326
|
},
|
|
318
327
|
table,
|
|
319
328
|
};
|
|
320
|
-
const file = join(repo,
|
|
321
|
-
writeFileSync(`${file}.tmp`, `${JSON.stringify(
|
|
329
|
+
const file = join(repo, FIT);
|
|
330
|
+
writeFileSync(`${file}.tmp`, `${JSON.stringify(record, null, 2)}\n`);
|
|
322
331
|
renameSync(`${file}.tmp`, file);
|
|
323
|
-
return
|
|
332
|
+
return record;
|
|
324
333
|
}
|
|
325
334
|
|
|
326
|
-
// The
|
|
335
|
+
// The Fit as the run calls it: only beside a guard the guard duty wrote, and
|
|
327
336
|
// never a failure of the run — its error is a line, and the exit stays as it was.
|
|
328
|
-
function
|
|
329
|
-
if (written === null) return say(`
|
|
337
|
+
function fit(repo, written) {
|
|
338
|
+
if (written === null) return say(`fit: skipped, no guard written — ${FIT} left as it is`);
|
|
330
339
|
let p;
|
|
331
340
|
try {
|
|
332
|
-
p =
|
|
341
|
+
p = writeFit(repo, written);
|
|
333
342
|
} catch (e) {
|
|
334
|
-
return say(`
|
|
343
|
+
return say(`fit: failed — ${e.message}`);
|
|
335
344
|
}
|
|
336
|
-
say(`
|
|
345
|
+
say(`fit: fitted ${p.table.n_rows} Pull${p.table.n_rows === 1 ? "" : "s"}, stage ${p.table.stage}${p.table.burn_in ? ", in burn-in" : ""}; ${FIT} computed ${p.computed_at}`);
|
|
337
346
|
}
|
|
338
347
|
|
|
339
348
|
function main() {
|
|
340
349
|
const die = makeDie(NAME);
|
|
341
|
-
const F = defineFlags(die, { flags: { repo: "value" } });
|
|
350
|
+
const F = defineFlags(die, { flags: { repo: "value", "no-fit": "bool" } });
|
|
342
351
|
F.sweep();
|
|
343
352
|
F.stray();
|
|
344
353
|
let repo = F.arg("repo") === null ? null : resolve(F.arg("repo"));
|
|
@@ -361,7 +370,7 @@ function main() {
|
|
|
361
370
|
return;
|
|
362
371
|
}
|
|
363
372
|
}
|
|
364
|
-
|
|
373
|
+
if (!F.has("no-fit")) fit(repo, written);
|
|
365
374
|
}
|
|
366
375
|
|
|
367
376
|
if (isCLI(import.meta.url)) main();
|
|
@@ -16,6 +16,12 @@
|
|
|
16
16
|
// routing by the objective's row set, and appends the Pull's
|
|
17
17
|
// ticket-features row to the pending TSV (by default
|
|
18
18
|
// `ticket-features.pending.tsv` beside `--guard`, in the run's `.fleet/`).
|
|
19
|
+
// With no `--table` it routes by the Fit, `router-fit.json` beside
|
|
20
|
+
// `--guard`, which metrics-refresh.mjs writes at phase 0. A Fit that is
|
|
21
|
+
// absent, unreadable, unparseable or fails validateTable routes by the
|
|
22
|
+
// starting table beside the script instead, and `REASON` names why:
|
|
23
|
+
// `fit-missing`, `fit-unreadable` or `fit-invalid`. A missing guard routes
|
|
24
|
+
// the default cell whatever the table, so it names no Fit there.
|
|
19
25
|
// The paths its brief names are looked up under the working directory,
|
|
20
26
|
// the checkout, for `named_lines`. Exit 0 on every data degradation — a
|
|
21
27
|
// missing or unreadable issue, sizing or guard file degrades the line,
|
|
@@ -430,6 +436,27 @@ export function readGuard(raw) {
|
|
|
430
436
|
return r.ok ? r.guard : null;
|
|
431
437
|
}
|
|
432
438
|
|
|
439
|
+
/** The Fit's file name: metrics-refresh.mjs writes it beside the cost guard, and `route` reads it there. */
|
|
440
|
+
export const FIT_FILE = "router-fit.json";
|
|
441
|
+
|
|
442
|
+
/**
|
|
443
|
+
* The table the Fit beside `guardPath` holds, `{ table, fallback: null }`, or `{ table: null, fallback }` when
|
|
444
|
+
* there is none to route by: `fallback` is the Routing `REASON` that names why — `fit-missing` for no file,
|
|
445
|
+
* `fit-unreadable` for one that will not read or parse, `fit-invalid` for one whose `table` validateTable refuses.
|
|
446
|
+
*/
|
|
447
|
+
export function readFitBeside(guardPath) {
|
|
448
|
+
let text;
|
|
449
|
+
try {
|
|
450
|
+
text = readFileSync(join(dirname(guardPath), FIT_FILE), "utf8");
|
|
451
|
+
} catch (e) {
|
|
452
|
+
return { table: null, fallback: e.code === "ENOENT" ? "fit-missing" : "fit-unreadable" };
|
|
453
|
+
}
|
|
454
|
+
let fit;
|
|
455
|
+
try { fit = JSON.parse(text); } catch { return { table: null, fallback: "fit-unreadable" }; }
|
|
456
|
+
const table = validateTable(fit?.table);
|
|
457
|
+
return table instanceof Error ? { table: null, fallback: "fit-invalid" } : { table, fallback: null };
|
|
458
|
+
}
|
|
459
|
+
|
|
433
460
|
/** The sizing verdict on a live B Pull: `{ src, label, usd }`, or null when it is unusable. */
|
|
434
461
|
function readSizing(raw, classifier) {
|
|
435
462
|
if (raw === null || typeof raw !== "object" || raw.source !== classifier.b) return null;
|
|
@@ -456,15 +483,18 @@ export function sessionDate(session) {
|
|
|
456
483
|
* it leaves out the cell the `cost` set routes the group to, whichever set
|
|
457
484
|
* routes the Pull, so a Pull draws the same cell under both. A live B Pull
|
|
458
485
|
* records its sizing verdict and routes as an A Pull does: a label names no
|
|
459
|
-
* group of the tree.
|
|
486
|
+
* group of the tree. `fallback` is readFitBeside's REASON when `table` is the
|
|
487
|
+
* starting table standing in for a Fit, else null: it is the first thing that
|
|
488
|
+
* went wrong, except beside no guard, where the table routes nothing.
|
|
460
489
|
* @returns {{ line: string, row: Record<string,string> }}
|
|
461
490
|
*/
|
|
462
491
|
export function route({
|
|
463
492
|
session, ticket, arm, implRow, chainHead = false, issue, sizing = null, guard, table, objective, now = Date.now(),
|
|
464
|
-
root = process.cwd(), version = installVersion(),
|
|
493
|
+
root = process.cwd(), version = installVersion(), fallback = null,
|
|
465
494
|
}) {
|
|
466
495
|
let reason = null;
|
|
467
496
|
const degrade = (r) => { reason ??= r; };
|
|
497
|
+
if (fallback !== null && guard !== null) degrade(fallback);
|
|
468
498
|
|
|
469
499
|
const metrics = issueMetrics(issue, now);
|
|
470
500
|
if (metrics === null) degrade("no-issue-json");
|
|
@@ -898,11 +928,15 @@ function main() {
|
|
|
898
928
|
if (foreign) die(`--${foreign} does not apply to ${mode === "check" ? "--check" : mode}`);
|
|
899
929
|
const need = (name) => F.arg(name) ?? die(`${mode === "check" ? "--check" : mode} needs --${name}`);
|
|
900
930
|
|
|
931
|
+
// `route` with no `--table` routes by the Fit beside `--guard`, else by the starting table.
|
|
932
|
+
const fit = mode === "route" && F.arg("table") === null && F.arg("guard") !== null ? readFitBeside(F.arg("guard")) : null;
|
|
901
933
|
const tablePath = mode === "route" ? (F.arg("table") ?? DEFAULT_TABLE) : need("table");
|
|
902
|
-
let table;
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
934
|
+
let table = fit?.table ?? null;
|
|
935
|
+
if (table === null) {
|
|
936
|
+
try { table = JSON.parse(readFileSync(tablePath, "utf8")); } catch (e) { die(`cannot read the router table ${tablePath}: ${e.message}`); }
|
|
937
|
+
const valid = validateTable(table);
|
|
938
|
+
if (valid instanceof Error) die(`${tablePath}: ${valid.message}`);
|
|
939
|
+
}
|
|
906
940
|
|
|
907
941
|
if (mode === "route") {
|
|
908
942
|
const ticket = need("ticket");
|
|
@@ -938,6 +972,7 @@ function main() {
|
|
|
938
972
|
const { line, row } = route({
|
|
939
973
|
session, ticket: Number(ticket), arm, implRow: Number(implRowArg), chainHead: F.has("chain-head"),
|
|
940
974
|
issue: readJson(issuePath), sizing: readJson(F.arg("sizing")), guard: readGuard(readJson(guardPath)), table, objective, root, version,
|
|
975
|
+
fallback: fit?.fallback ?? null,
|
|
941
976
|
});
|
|
942
977
|
const pending = F.arg("pending") ?? join(dirname(guardPath), "ticket-features.pending.tsv");
|
|
943
978
|
// The header decision and the append are not atomic and take no lock. That is
|
|
@@ -104,7 +104,7 @@ issue number among the reasons — comes before that PR's WARNING and says why.
|
|
|
104
104
|
|
|
105
105
|
**Drain the pending ticket-features rows and refresh the cost guard, after
|
|
106
106
|
the member-outcomes scrape and every `tier-outcomes.mjs append`, before the
|
|
107
|
-
metrics files are committed.** `~/.omp/plugins/node_modules/@feigi/fleet-ctl/scripts/fleet-run metrics-refresh.mjs`
|
|
107
|
+
metrics files are committed.** `~/.omp/plugins/node_modules/@feigi/fleet-ctl/scripts/fleet-run metrics-refresh.mjs --no-fit`
|
|
108
108
|
moves `.fleet/ticket-features.pending.tsv` — the row the router script
|
|
109
109
|
appended for each Pull at dispatch — into `docs/metrics/ticket-features.tsv`,
|
|
110
110
|
deduped on `session`+`agent`, so this run's own rows are in the file that gets
|
|
@@ -112,10 +112,9 @@ committed; that file is a run artifact too and is committed with the other
|
|
|
112
112
|
two. It then widens a `docs/metrics/member-outcomes.tsv` written before the
|
|
113
113
|
newest columns, as at phase 0 — a file already at the current width is left
|
|
114
114
|
as it is — and then runs `pr-cost.mjs --guard`, which rewrites
|
|
115
|
-
`.fleet/cost-guard.json` from all three files.
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
leaves the exit as it was. Exit 0: every duty ran. The guard's
|
|
115
|
+
`.fleet/cost-guard.json` from all three files. `--no-fit` computes no Fit:
|
|
116
|
+
one Fit per run, at phase 0, so the rows this close-out commits route the
|
|
117
|
+
next run, and `.fleet/router-fit.json` is left as it is. Exit 0: every duty ran. The guard's
|
|
119
118
|
own exit 3 (a cell tripped) and 4 (no verdict yet, baseline too thin) are
|
|
120
119
|
verdicts the router and `fleet-tick.mjs` read, never failures; the script
|
|
121
120
|
absorbs them. Exit 1 names the duty that failed on stderr and the duties after it
|
|
@@ -247,10 +247,15 @@ and the guard the script also widens a `docs/metrics/member-outcomes.tsv`
|
|
|
247
247
|
written before the newest columns: each row gains them, `ending` reads
|
|
248
248
|
`unknown` on an implementer's row, and nothing else changes. Without that,
|
|
249
249
|
phase 0, the close-out scrape and `tier-outcomes.mjs append` refuse the file.
|
|
250
|
-
After a guard it wrote, the script
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
250
|
+
After a guard it wrote, the script computes the Fit — the router's table fitted
|
|
251
|
+
over the three metrics files and that guard, with the starting table beside the
|
|
252
|
+
scripts as its prior — and writes it to `.fleet/router-fit.json`, which every
|
|
253
|
+
Pull of this run routes by. Nothing commits it. One Fit per run: close-out
|
|
254
|
+
computes none, so each close-out's rows route the next run. A
|
|
255
|
+
`metrics-refresh: fit: failed — <why>` line leaves the previous file as it
|
|
256
|
+
was and the exit at 0, so it never stops the run: the run routes by the last
|
|
257
|
+
Fit that computed, else by the starting table. A skipped guard skips the Fit
|
|
258
|
+
too, and both files are left as they are.
|
|
254
259
|
|
|
255
260
|
## Launch the cockpit
|
|
256
261
|
|
|
@@ -276,8 +276,13 @@ one; a B Pull routes exactly as an A one until the table opens arm B.
|
|
|
276
276
|
row set of the run's Objective, `OBJECTIVE`, which it reads off the phase-0
|
|
277
277
|
receipt. The printed line is the
|
|
278
278
|
whole routing decision — never re-derive `CELL` from the table, the guard or
|
|
279
|
-
this paragraph.
|
|
280
|
-
|
|
279
|
+
this paragraph. The table it routes by is the Fit phase 0 wrote,
|
|
280
|
+
`.fleet/router-fit.json` beside `--guard`; a Fit that is absent, unreadable,
|
|
281
|
+
unparseable or not a valid table routes by the starting table beside the
|
|
282
|
+
script, and `REASON` says so (`fit-missing`, `fit-unreadable`, `fit-invalid`).
|
|
283
|
+
A missing or unreadable `.fleet/cost-guard.json` routes the
|
|
284
|
+
default cell only (`REASON=guard-missing`), burn-in included, whatever the Fit
|
|
285
|
+
holds. On the ledger the
|
|
281
286
|
whole line, `REASON` with it, is the Pull's `## Routed` entry; a row carries no
|
|
282
287
|
`route=` (an older row's `route=<REASON>` still reads).
|
|
283
288
|
|
|
@@ -441,7 +446,7 @@ controller's probe could not look.
|
|
|
441
446
|
**Every 5th Pull by ledger count goes at an exploration cell.** Count the `impl-`
|
|
442
447
|
rows in `.fleet/ledger.md` at Pull time; the Pull that creates row 5, 10, 15 …
|
|
443
448
|
is an Exploration Pull, and the router draws its cell: `k = 1 +
|
|
444
|
-
(sha256("<session>\t<ticket>")[0:8] mod K)` over
|
|
449
|
+
(sha256("<session>\t<ticket>")[0:8] mod K)` over the routing table's
|
|
445
450
|
`cells` minus the policy cell, in token order. Under either Objective that
|
|
446
451
|
policy cell is the `cost` row set's, so the draw is the same under both. While the table's `burn_in` is
|
|
447
452
|
true every Pull draws, over every cell, the policy cell included. An
|