@feigi/fleet-ctl 3.158.33 → 3.158.34
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/metrics-refresh.mjs +2 -2
- package/scripts/ticket-router.mjs +105 -218
package/package.json
CHANGED
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
// FIT. After the cost guard wrote a guard, and only then, the Router's fit
|
|
65
65
|
// (`ticket-router.mjs`'s fitTree) runs in-process over the working-tree TSVs
|
|
66
66
|
// the guard just read and the guard just written, with the starting table
|
|
67
|
-
// (`router-table.json` beside the scripts) as its prior
|
|
67
|
+
// (`router-table.json` beside the scripts) as its prior. It
|
|
68
68
|
// writes the Fit, `.fleet/router-fit.json`, through a temp file and a rename:
|
|
69
69
|
// `computed_at`, `guard_computed_at` (the guard's own `computed_at`),
|
|
70
70
|
// `guard` (the guard it used, as the router reads it: its `computed_at`,
|
|
@@ -341,7 +341,7 @@ export function writeFit(repo, written, { tablePath = DEFAULT_TABLE, packagePath
|
|
|
341
341
|
const members = read(MEMBERS, parseMemberTsv);
|
|
342
342
|
const verdicts = read(TIERS, parseTierOutcomes);
|
|
343
343
|
const features = read(FEATURES, parseFeatures);
|
|
344
|
-
const { table, gate } = fitTree({ prior, features, members, verdicts, guard,
|
|
344
|
+
const { table, gate } = fitTree({ prior, features, members, verdicts, guard, previous });
|
|
345
345
|
// The tree the gate grew is the one `route` will read it through.
|
|
346
346
|
const valid = validateTable(table);
|
|
347
347
|
if (valid instanceof Error) throw valid;
|
|
@@ -40,34 +40,21 @@
|
|
|
40
40
|
// within OMP_READ_TIMEOUT_MS, warns and leaves the Pull no Cell to draw;
|
|
41
41
|
// a read that leaves a role no level to run at, or finds no implementer
|
|
42
42
|
// definition, warns too.
|
|
43
|
-
// --check --table <json> --features <tsv> --members <tsv> --verdicts <tsv>
|
|
44
|
-
// Re-fits from the commit the table records as `fitted_commit` (an empty
|
|
45
|
-
// corpus while it is null), against the guard snapshot the table itself
|
|
46
|
-
// records, and exits 1 when the result is not the table: the table is a
|
|
47
|
-
// code carrier, never hand-edited. A `fitted_commit` this repository does
|
|
48
|
-
// not hold exits 2 naming the `git fetch` that brings it.
|
|
49
|
-
//
|
|
50
43
|
// The script never touches the network: the issue, the sizing verdict and
|
|
51
|
-
// the guard are files the caller wrote,
|
|
52
|
-
// caller, and the install reads ask the local `omp`.
|
|
44
|
+
// the guard are files the caller wrote, and the install reads ask the local `omp`.
|
|
53
45
|
|
|
54
46
|
import { createHash } from "node:crypto";
|
|
55
47
|
import { readFileSync, readdirSync, appendFileSync, mkdirSync, statSync, realpathSync } from "node:fs";
|
|
56
|
-
import { spawnSync } from "node:child_process";
|
|
57
48
|
import { basename, dirname, isAbsolute, join, posix, relative, resolve, sep } from "node:path";
|
|
58
49
|
import { fileURLToPath } from "node:url";
|
|
59
|
-
import { isDeepStrictEqual } from "node:util";
|
|
60
50
|
import { isCLI } from "./is-cli.mjs";
|
|
61
|
-
import { gitEnv } from "./git-env.mjs";
|
|
62
51
|
import { makeDie, defineFlags, isDigits } from "./arg.mjs";
|
|
63
52
|
import { CELL, OBJECTIVES, POLICY_CELL, STARTING_CELLS, drawCell, formatRouting, isRulePath, parseMember } from "./ledger-grammar.mjs";
|
|
64
53
|
import { objectiveFromReceipt, sessionFromReceipt } from "./phase0-receipt.mjs";
|
|
65
|
-
import { parseTsv as parseMemberTsv } from "./member-outcomes.mjs";
|
|
66
54
|
import {
|
|
67
|
-
AttributionError, FEATURE_COLUMNS, OPTIONAL_COLUMNS, TRIP_POINTS, attribute, compareCells, generations,
|
|
55
|
+
AttributionError, FEATURE_COLUMNS, OPTIONAL_COLUMNS, TRIP_POINTS, attribute, compareCells, generations, tally,
|
|
68
56
|
} from "./pull-attribution.mjs";
|
|
69
57
|
import { searchSplits, standing } from "./split-gate.mjs";
|
|
70
|
-
import { RulingError, parseTierOutcomes } from "./tier-outcomes.mjs";
|
|
71
58
|
import { LINE_REF, briefPaths, briefText } from "./ticket-text.mjs";
|
|
72
59
|
import { catalogEntry, implementerCell, readOmpConfigValue, readOmpModelCatalog, resolveRole } from "./tier-roles.mjs";
|
|
73
60
|
|
|
@@ -671,9 +658,8 @@ const round4 = (x) => Math.round(x * 1e4) / 1e4;
|
|
|
671
658
|
* routed, each to its own row's cell — restricted to rows the free classifier
|
|
672
659
|
* routed plus exploration rows: a row a live B classifier routed is the A/B's
|
|
673
660
|
* test set, not the fit's. The fit sees no PR state, so a Pull with
|
|
674
|
-
* a Ruling is merged. A fit reads everything
|
|
675
|
-
* is cut by date,
|
|
676
|
-
* re-cutting the working tree's files. `order` ranks each cell's generations
|
|
661
|
+
* a Ruling is merged. A fit reads everything it is given: no row
|
|
662
|
+
* is cut by date, whatever the working tree's files hold. `order` ranks each cell's generations
|
|
677
663
|
* over every Pull in the window, the restriction aside, so the fit names the
|
|
678
664
|
* same newest generation the guard does. No unit is in a group yet: `book`
|
|
679
665
|
* puts each where a tree walks its features row.
|
|
@@ -814,7 +800,7 @@ function judge(objective, pulls = {}, cells, tripped, baseCell) {
|
|
|
814
800
|
const mergedOf = (c) => pullsOf(c).filter((u) => u.merged).length;
|
|
815
801
|
// A default cell or base short of MIN_N merged PRs has none to give any candidate, whichever stretches they share.
|
|
816
802
|
if (mergedOf(POLICY_CELL) < MIN_N || mergedOf(baseCell) < MIN_N) return record;
|
|
817
|
-
// JSON writes −0 as 0, so a recorded end is 0 either way
|
|
803
|
+
// JSON writes −0 as 0, so a recorded end is 0 either way: normalise it here.
|
|
818
804
|
const range = (m) => m.range(metric)?.map((x) => x + 0) ?? null;
|
|
819
805
|
const reliablyBelow = (r) => r !== null && r[1] < 0;
|
|
820
806
|
// A matched figure as the table prints one, four places; none is unknown, past every figure that is known.
|
|
@@ -888,8 +874,7 @@ function judgeSpeedRow(pulls, cells, tripped, costCell) {
|
|
|
888
874
|
/**
|
|
889
875
|
* The re-fit table, over the tree `prior.splits` holds: this makes no split
|
|
890
876
|
* and takes none away (fitTree grows the tree). `guard` is `{ tripped, n, window_start }` (readGuard's
|
|
891
|
-
* shape)
|
|
892
|
-
* for the empty corpus before any fit. `rows` and `reasons` hold one set per
|
|
877
|
+
* shape). `rows` and `reasons` hold one set per
|
|
893
878
|
* objective, and each a row or record for every node. `reasons.cost` holds
|
|
894
879
|
* `judgeRow()`'s record, its `cell` the cell the node's `cost` row holds: a
|
|
895
880
|
* node whose record has no cell holds its parent's `cost` row, as a ticket
|
|
@@ -902,13 +887,13 @@ function judgeSpeedRow(pulls, cells, tripped, costCell) {
|
|
|
902
887
|
* (`guard.n`, which starts again at 0 when a role's model changes): no other
|
|
903
888
|
* Cell the table holds ends it or holds it, whatever its merged PRs.
|
|
904
889
|
*/
|
|
905
|
-
export function fitTable({ prior, features, members, verdicts, guard
|
|
890
|
+
export function fitTable({ prior, features, members, verdicts, guard }) {
|
|
906
891
|
const window = guard.window_start ?? prior.window_start ?? null;
|
|
907
|
-
return tableOver({ prior, ...fitPulls({ features, members, verdicts, window }), guard,
|
|
892
|
+
return tableOver({ prior, ...fitPulls({ features, members, verdicts, window }), guard, window });
|
|
908
893
|
}
|
|
909
894
|
|
|
910
895
|
// The table over the tree `prior.splits` holds, from the fit's Pulls (fitPulls') booked to its groups.
|
|
911
|
-
function tableOver({ prior, units: unbooked, order, guard,
|
|
896
|
+
function tableOver({ prior, units: unbooked, order, guard, window }) {
|
|
912
897
|
const nodes = treeNodes(prior.splits);
|
|
913
898
|
const units = book(unbooked, prior);
|
|
914
899
|
const { estimates, pulls } = estimate(units, order, nodes);
|
|
@@ -931,7 +916,7 @@ function tableOver({ prior, units: unbooked, order, guard, commit, window }) {
|
|
|
931
916
|
}
|
|
932
917
|
return {
|
|
933
918
|
window_start: window,
|
|
934
|
-
fitted_commit:
|
|
919
|
+
fitted_commit: null,
|
|
935
920
|
n_rows: units.length,
|
|
936
921
|
cells: prior.cells,
|
|
937
922
|
burn_in: shortStartingCells(guard.n).length > 0,
|
|
@@ -1045,45 +1030,11 @@ function growTree({ prior, units, order, tripped, previous }) {
|
|
|
1045
1030
|
* first Fit it fails; that Fit's `gate` is the whole of what the next one reads of this.
|
|
1046
1031
|
* @returns {{ table: object, gate: { records: string, scored: number, left_out: number, best: object|null, passed: string[], stands: string[] } }}
|
|
1047
1032
|
*/
|
|
1048
|
-
export function fitTree({ prior, features, members, verdicts, guard,
|
|
1033
|
+
export function fitTree({ prior, features, members, verdicts, guard, previous = null }) {
|
|
1049
1034
|
const window = guard.window_start ?? prior.window_start ?? null;
|
|
1050
1035
|
const fitted = fitPulls({ features, members, verdicts, window });
|
|
1051
1036
|
const { gate, splits } = growTree({ prior, ...fitted, tripped: new Set(guard.tripped), previous });
|
|
1052
|
-
return { table: tableOver({ prior: { ...prior, splits }, ...fitted, guard,
|
|
1053
|
-
}
|
|
1054
|
-
|
|
1055
|
-
// ---------------------------------------------------------------------------
|
|
1056
|
-
// the commit a fit reads
|
|
1057
|
-
// ---------------------------------------------------------------------------
|
|
1058
|
-
|
|
1059
|
-
const SHA = /^(?:[0-9a-f]{40}|[0-9a-f]{64})$/;
|
|
1060
|
-
|
|
1061
|
-
// `git` run in the directory holding `path`, so `path` names a file of the
|
|
1062
|
-
// repository around it whichever directory the caller is in.
|
|
1063
|
-
function gitBeside(path, args) {
|
|
1064
|
-
const r = spawnSync("git", ["-C", dirname(resolve(path)), ...args], { encoding: "utf8", env: gitEnv(), maxBuffer: 1 << 30 });
|
|
1065
|
-
if (r.error) throw r.error;
|
|
1066
|
-
return r;
|
|
1067
|
-
}
|
|
1068
|
-
|
|
1069
|
-
/**
|
|
1070
|
-
* The full sha `rev` names as a commit in the repository holding `path`, or null when it names none there.
|
|
1071
|
-
* Throws when git itself fails (not a repository, unreadable config, no git): that is not an answer about `rev`.
|
|
1072
|
-
*/
|
|
1073
|
-
export function resolveCommit(path, rev) {
|
|
1074
|
-
if (rev.startsWith("-")) return null;
|
|
1075
|
-
const r = gitBeside(path, ["rev-parse", "--verify", "--quiet", `${rev}^{commit}`]);
|
|
1076
|
-
if (r.status === 0) return r.stdout.trim();
|
|
1077
|
-
// `--verify --quiet` exits 1, silently, for a rev that names no commit; any other status is git failing.
|
|
1078
|
-
if (r.status === 1) return null;
|
|
1079
|
-
throw new Error(r.stderr.trim() || `git rev-parse exited ${r.status}`);
|
|
1080
|
-
}
|
|
1081
|
-
|
|
1082
|
-
/** `path` as committed at `sha`; throws when the commit does not hold it. */
|
|
1083
|
-
export function showAt(sha, path) {
|
|
1084
|
-
const r = gitBeside(path, ["show", `${sha}:./${basename(path)}`]);
|
|
1085
|
-
if (r.status !== 0) throw new Error(r.stderr.trim() || `git show exited ${r.status}`);
|
|
1086
|
-
return r.stdout;
|
|
1037
|
+
return { table: tableOver({ prior: { ...prior, splits }, ...fitted, guard, window }), gate };
|
|
1087
1038
|
}
|
|
1088
1039
|
|
|
1089
1040
|
// ---------------------------------------------------------------------------
|
|
@@ -1096,29 +1047,17 @@ function main() {
|
|
|
1096
1047
|
flags: {
|
|
1097
1048
|
session: "value", objective: "value", ticket: "value", arm: "value", "impl-row": "value", issue: "value",
|
|
1098
1049
|
sizing: "value", guard: "value", table: "value", pending: "value", "chain-head": "bool", "model-roles": "value", catalog: "value", agents: "value",
|
|
1099
|
-
features: "value", members: "value", verdicts: "value", check: "bool",
|
|
1100
1050
|
},
|
|
1101
1051
|
positionals: ["route"],
|
|
1102
1052
|
});
|
|
1103
1053
|
F.sweep();
|
|
1104
1054
|
F.stray();
|
|
1105
|
-
|
|
1106
|
-
const
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
const
|
|
1111
|
-
route: ["session", "objective", "ticket", "arm", "impl-row", "issue", "sizing", "guard", "table", "pending", "chain-head", "model-roles", "catalog", "agents"],
|
|
1112
|
-
check: ["check", "table", "features", "members", "verdicts"],
|
|
1113
|
-
}[mode];
|
|
1114
|
-
const given = argv.filter((a) => a.startsWith("--")).map((a) => a.slice(2).split("=")[0]);
|
|
1115
|
-
const foreign = given.find((g) => !allowed.includes(g));
|
|
1116
|
-
if (foreign) die(`--${foreign} does not apply to ${mode === "check" ? "--check" : mode}`);
|
|
1117
|
-
const need = (name) => F.arg(name) ?? die(`${mode === "check" ? "--check" : mode} needs --${name}`);
|
|
1118
|
-
|
|
1119
|
-
// `route` with no `--table` routes by the Fit beside `--guard`, else by the starting table.
|
|
1120
|
-
const fit = mode === "route" && F.arg("table") === null && F.arg("guard") !== null ? readFitBeside(F.arg("guard")) : null;
|
|
1121
|
-
const tablePath = mode === "route" ? (F.arg("table") ?? DEFAULT_TABLE) : need("table");
|
|
1055
|
+
if (!process.argv.slice(2).includes("route")) die("usage: ticket-router.mjs route …");
|
|
1056
|
+
const need = (name) => F.arg(name) ?? die(`route needs --${name}`);
|
|
1057
|
+
|
|
1058
|
+
// With no `--table`, routes by the Fit beside `--guard`, else by the starting table.
|
|
1059
|
+
const fit = F.arg("table") === null && F.arg("guard") !== null ? readFitBeside(F.arg("guard")) : null;
|
|
1060
|
+
const tablePath = F.arg("table") ?? DEFAULT_TABLE;
|
|
1122
1061
|
let table = fit?.table ?? null;
|
|
1123
1062
|
if (table === null) {
|
|
1124
1063
|
try { table = JSON.parse(readFileSync(tablePath, "utf8")); } catch (e) { die(`cannot read the router table ${tablePath}: ${e.message}`); }
|
|
@@ -1126,153 +1065,101 @@ function main() {
|
|
|
1126
1065
|
if (valid instanceof Error) die(`${tablePath}: ${valid.message}`);
|
|
1127
1066
|
}
|
|
1128
1067
|
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
}
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
const kind = (v) => (v === undefined ? "absent" : v === null ? "null" : Array.isArray(v) ? "an array" : `a ${typeof v}`);
|
|
1171
|
-
try {
|
|
1172
|
-
const modelRoles = F.arg("model-roles") === null
|
|
1173
|
-
? readOmpConfigValue("modelRoles", { timeout: OMP_READ_TIMEOUT_MS })
|
|
1174
|
-
: JSON.parse(readFileSync(F.arg("model-roles"), "utf8"));
|
|
1175
|
-
const catalog = F.arg("catalog") === null
|
|
1176
|
-
? readOmpModelCatalog({ timeout: OMP_READ_TIMEOUT_MS })
|
|
1177
|
-
: JSON.parse(readFileSync(F.arg("catalog"), "utf8"));
|
|
1178
|
-
if (typeof modelRoles !== "object" || modelRoles === null || Array.isArray(modelRoles)) {
|
|
1179
|
-
throw new Error(`modelRoles is ${kind(modelRoles)}, not a record of role to model`);
|
|
1180
|
-
}
|
|
1181
|
-
if (!Array.isArray(catalog?.models)) throw new Error(`omp's model catalog has no models list (models: ${kind(catalog?.models)})`);
|
|
1182
|
-
install = installOf({ modelRoles, catalog, definitions: readdirSync(agents) });
|
|
1183
|
-
} catch (e) {
|
|
1184
|
-
warn(`cannot read what this install runs: ${e.message} — no exploration Cell is drawn`);
|
|
1185
|
-
}
|
|
1186
|
-
if (install !== null) {
|
|
1187
|
-
const unrun = ROLES_BY_PRICE.filter((role) => install.ladders[role].length === 0);
|
|
1188
|
-
if (unrun.length > 0) {
|
|
1189
|
-
warn(`this install runs ${unrun.join(", ")} at no level (modelRoles names no model for it, or one omp's catalog lists at none) — no exploration Cell of ${unrun.length === 1 ? "that role" : "those roles"} is drawn`);
|
|
1190
|
-
}
|
|
1191
|
-
if (install.defined.size === 0) warn(`${agents} holds no implementer definition — no exploration Cell is drawn`);
|
|
1192
|
-
}
|
|
1193
|
-
}
|
|
1194
|
-
const { line, row } = route({
|
|
1195
|
-
session, ticket: Number(ticket), arm, implRow: Number(implRowArg), chainHead,
|
|
1196
|
-
issue: readJson(issuePath), sizing: readJson(F.arg("sizing")), guard, table, objective, root, version,
|
|
1197
|
-
fallback: fit?.fallback ?? null, install,
|
|
1198
|
-
});
|
|
1199
|
-
const pending = F.arg("pending") ?? join(dirname(guardPath), "ticket-features.pending.tsv");
|
|
1200
|
-
// The header decision and the append are not atomic and take no lock. That is
|
|
1201
|
-
// safe only while the run's controller is the only process that routes or
|
|
1202
|
-
// drains on a checkout, doing both serially: one controller per checkout is
|
|
1203
|
-
// the rule, and neither this append nor the drain checks it. A pending file
|
|
1204
|
-
// already begun keeps its header's columns, so a plugin updated mid-run
|
|
1205
|
-
// never appends a row wider or narrower than the file. A first line that is
|
|
1206
|
-
// no features header — a required column missing, or a name no features
|
|
1207
|
-
// file carries — is refused, not appended against.
|
|
1068
|
+
const ticket = need("ticket");
|
|
1069
|
+
if (!/^[1-9][0-9]*$/.test(ticket)) die(`--ticket ${ticket} is not an issue number`);
|
|
1070
|
+
const arm = need("arm");
|
|
1071
|
+
if (arm !== "A" && arm !== "B") die(`--arm ${arm} is not A or B`);
|
|
1072
|
+
const implRowArg = need("impl-row");
|
|
1073
|
+
if (!/^[1-9][0-9]*$/.test(implRowArg)) die(`--impl-row ${implRowArg} is not a positive row count`);
|
|
1074
|
+
const issuePath = need("issue");
|
|
1075
|
+
const guardPath = need("guard");
|
|
1076
|
+
// `--session` omitted is the session directory the phase-0 receipt
|
|
1077
|
+
// records; a receipt that records none is a usage error naming it.
|
|
1078
|
+
let sessionArg = F.arg("session");
|
|
1079
|
+
if (sessionArg === null) {
|
|
1080
|
+
try { sessionArg = sessionFromReceipt(); } catch (e) { die(e.message); }
|
|
1081
|
+
}
|
|
1082
|
+
const session = basename(sessionArg.replace(/\/+$/, ""));
|
|
1083
|
+
// `--objective` omitted is the one the receipt records, likewise.
|
|
1084
|
+
let objective = F.arg("objective");
|
|
1085
|
+
if (objective === null) {
|
|
1086
|
+
try { objective = objectiveFromReceipt(); } catch (e) { die(e.message); }
|
|
1087
|
+
} else if (!OBJECTIVES.includes(objective)) {
|
|
1088
|
+
die(`--objective ${objective} is not ${OBJECTIVES.join(" or ")}`);
|
|
1089
|
+
}
|
|
1090
|
+
// A working directory removed under the run, or an install `package.json`
|
|
1091
|
+
// with no readable version, degrades the row and warns, never the exit.
|
|
1092
|
+
let root = null;
|
|
1093
|
+
try { root = process.cwd(); } catch (e) {
|
|
1094
|
+
process.stderr.write(`${NAME}: WARNING cannot resolve the working directory: ${e.message} — every named path reads \`-\`\n`);
|
|
1095
|
+
}
|
|
1096
|
+
const version = installVersion();
|
|
1097
|
+
if (version === null) process.stderr.write(`${NAME}: WARNING ${INSTALL_PACKAGE} names no readable version — plugin_version is blank\n`);
|
|
1098
|
+
const guard = readGuard(readJson(guardPath));
|
|
1099
|
+
const chainHead = F.has("chain-head");
|
|
1100
|
+
// Only a Pull past burn-in that may explore reads what the install runs: its draw, or the share it ran at, needs
|
|
1101
|
+
// the group's exploration Cells. A read that fails or does not answer in OMP_READ_TIMEOUT_MS, a `modelRoles` that
|
|
1102
|
+
// is no record and a catalog with no `models` list leave the Pull no Cell to draw, and warn, never the exit; so
|
|
1103
|
+
// does a read that holds nothing to draw: a role that runs at no level, or no implementer definition.
|
|
1104
|
+
let install = null;
|
|
1105
|
+
if (guard !== null && !table.burn_in && !chainHead) {
|
|
1106
|
+
const warn = (what) => process.stderr.write(`${NAME}: WARNING ${what}\n`);
|
|
1107
|
+
const agents = F.arg("agents") ?? join(SCRIPT_DIR, "..", "agents");
|
|
1108
|
+
const kind = (v) => (v === undefined ? "absent" : v === null ? "null" : Array.isArray(v) ? "an array" : `a ${typeof v}`);
|
|
1208
1109
|
try {
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
}
|
|
1110
|
+
const modelRoles = F.arg("model-roles") === null
|
|
1111
|
+
? readOmpConfigValue("modelRoles", { timeout: OMP_READ_TIMEOUT_MS })
|
|
1112
|
+
: JSON.parse(readFileSync(F.arg("model-roles"), "utf8"));
|
|
1113
|
+
const catalog = F.arg("catalog") === null
|
|
1114
|
+
? readOmpModelCatalog({ timeout: OMP_READ_TIMEOUT_MS })
|
|
1115
|
+
: JSON.parse(readFileSync(F.arg("catalog"), "utf8"));
|
|
1116
|
+
if (typeof modelRoles !== "object" || modelRoles === null || Array.isArray(modelRoles)) {
|
|
1117
|
+
throw new Error(`modelRoles is ${kind(modelRoles)}, not a record of role to model`);
|
|
1218
1118
|
}
|
|
1219
|
-
|
|
1220
|
-
|
|
1119
|
+
if (!Array.isArray(catalog?.models)) throw new Error(`omp's model catalog has no models list (models: ${kind(catalog?.models)})`);
|
|
1120
|
+
install = installOf({ modelRoles, catalog, definitions: readdirSync(agents) });
|
|
1221
1121
|
} catch (e) {
|
|
1222
|
-
|
|
1122
|
+
warn(`cannot read what this install runs: ${e.message} — no exploration Cell is drawn`);
|
|
1123
|
+
}
|
|
1124
|
+
if (install !== null) {
|
|
1125
|
+
const unrun = ROLES_BY_PRICE.filter((role) => install.ladders[role].length === 0);
|
|
1126
|
+
if (unrun.length > 0) {
|
|
1127
|
+
warn(`this install runs ${unrun.join(", ")} at no level (modelRoles names no model for it, or one omp's catalog lists at none) — no exploration Cell of ${unrun.length === 1 ? "that role" : "those roles"} is drawn`);
|
|
1128
|
+
}
|
|
1129
|
+
if (install.defined.size === 0) warn(`${agents} holds no implementer definition — no exploration Cell is drawn`);
|
|
1223
1130
|
}
|
|
1224
|
-
process.stdout.write(`${line}\n`);
|
|
1225
|
-
return;
|
|
1226
1131
|
}
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
try { return parse(showAt(sha, p)); } catch (e) { die(`cannot read --${flag} ${p} at commit ${short(sha)}: ${e.message}`); }
|
|
1232
|
-
};
|
|
1233
|
-
// The three TSVs as committed at `sha`, never the working tree's copies.
|
|
1234
|
-
const corpusAt = (sha) => ({
|
|
1235
|
-
features: fileAt(sha, "features", parseFeatures),
|
|
1236
|
-
members: fileAt(sha, "members", parseMemberTsv),
|
|
1237
|
-
verdicts: fileAt(sha, "verdicts", parseTierOutcomes),
|
|
1132
|
+
const { line, row } = route({
|
|
1133
|
+
session, ticket: Number(ticket), arm, implRow: Number(implRowArg), chainHead,
|
|
1134
|
+
issue: readJson(issuePath), sizing: readJson(F.arg("sizing")), guard, table, objective, root, version,
|
|
1135
|
+
fallback: fit?.fallback ?? null, install,
|
|
1238
1136
|
});
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
//
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
}
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
try { return fit(); } catch (e) {
|
|
1259
|
-
if (!(e instanceof RulingError || e instanceof AttributionError)) throw e;
|
|
1260
|
-
die(`cannot join --features ${need("features")}, --members ${need("members")} and --verdicts ${need("verdicts")}: ${e.message}`);
|
|
1137
|
+
const pending = F.arg("pending") ?? join(dirname(guardPath), "ticket-features.pending.tsv");
|
|
1138
|
+
// The header decision and the append are not atomic and take no lock. That is
|
|
1139
|
+
// safe only while the run's controller is the only process that routes or
|
|
1140
|
+
// drains on a checkout, doing both serially: one controller per checkout is
|
|
1141
|
+
// the rule, and neither this append nor the drain checks it. A pending file
|
|
1142
|
+
// already begun keeps its header's columns, so a plugin updated mid-run
|
|
1143
|
+
// never appends a row wider or narrower than the file. A first line that is
|
|
1144
|
+
// no features header — a required column missing, or a name no features
|
|
1145
|
+
// file carries — is refused, not appended against.
|
|
1146
|
+
try {
|
|
1147
|
+
mkdirSync(dirname(pending), { recursive: true });
|
|
1148
|
+
const had = statSync(pending, { throwIfNoEntry: false })?.size > 0 ? readFileSync(pending, "utf8").split("\n", 1)[0].split("\t") : null;
|
|
1149
|
+
if (had !== null) {
|
|
1150
|
+
const missing = FEATURE_COLUMNS.filter((c) => !had.includes(c) && !OPTIONAL_COLUMNS.has(c));
|
|
1151
|
+
const unknown = had.filter((c) => !FEATURE_COLUMNS.includes(c));
|
|
1152
|
+
if (missing.length || unknown.length) {
|
|
1153
|
+
const why = [missing.length ? `lacks ${missing.join(", ")}` : "", unknown.length ? `names ${unknown.map((c) => JSON.stringify(c)).join(", ")}` : ""];
|
|
1154
|
+
throw new Error(`its first line is no ticket-features header: it ${why.filter(Boolean).join(" and ")}`);
|
|
1155
|
+
}
|
|
1261
1156
|
}
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
const { features, members, verdicts } = fitted === null ? { features: [], members: [], verdicts: [] } : corpusAt(fitted);
|
|
1267
|
-
const refit = joined(() => fitTable({ prior: table, features, members, verdicts, guard: { ...table.guard, window_start: table.window_start }, commit: fitted }));
|
|
1268
|
-
const differ = Object.keys({ ...refit, ...table }).filter((k) => !isDeepStrictEqual(refit[k], table[k]));
|
|
1269
|
-
if (differ.length) {
|
|
1270
|
-
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`);
|
|
1271
|
-
// exitCode, not exit(): a piped stderr is written asynchronously and exit() can cut the payload off.
|
|
1272
|
-
process.exitCode = 1;
|
|
1273
|
-
return;
|
|
1157
|
+
const header = had === null ? `${FEATURE_COLUMNS.join("\t")}\n` : "";
|
|
1158
|
+
appendFileSync(pending, `${header}${formatFeatureRow(row, had ?? FEATURE_COLUMNS)}\n`);
|
|
1159
|
+
} catch (e) {
|
|
1160
|
+
process.stderr.write(`${NAME}: WARNING could not append to ${pending}: ${e.message} — this Pull's ticket-features row is not recorded\n`);
|
|
1274
1161
|
}
|
|
1275
|
-
process.stdout.write(`${
|
|
1162
|
+
process.stdout.write(`${line}\n`);
|
|
1276
1163
|
}
|
|
1277
1164
|
|
|
1278
1165
|
if (isCLI(import.meta.url)) main();
|