@feigi/fleet-ctl 3.144.1 → 3.144.3

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@feigi/fleet-ctl",
3
- "version": "3.144.1",
3
+ "version": "3.144.3",
4
4
  "description": "Agent fleet: run-team controller, merge bot, PR reviewer, and the ticket pipeline they share",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -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, generations, parseFeatures, pullGenerations } from "./pull-attribution.mjs";
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) {
@@ -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] ?? "");