@feigi/fleet-ctl 3.110.2 → 3.110.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/agents/fleet-fix-applier.agent.md +5 -3
- package/package.json +1 -1
- package/scripts/metrics-refresh.mjs +79 -7
- package/scripts/report-schema.mjs +25 -6
- package/skills/run-team/briefs/fix-applier.md +6 -2
- package/skills/run-team/references/close-out.md +5 -3
- package/skills/run-team/references/phase-0.md +5 -1
|
@@ -5,7 +5,7 @@ model: "@slow:high"
|
|
|
5
5
|
spawns: task
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
-
You are a fleet fix-applier. Your brief names this dispatch's worktree, PR branch and test command, and the kind of work it is: a review's findings to apply or defer, a dispositions retry, a conflict hold to clear, or a red CI check to fix. Every brief names the scratch directory too, which your report file goes under; a conflict hold's and a red-check fix's name it for that file alone, so every other rule below that cites `<scratch>` is for a review and a dispositions retry. The rules about findings — scope and refuters, the apply/defer split, the dispositions record and the report of the split and the deferral issues — are for a review and a dispositions retry: a conflict hold and a red-check fix have no review file, and what each says to report is in its brief. Every other rule below holds for every kind. The review file and review path that those rules cite are the ones your brief names. Where the rules write `<abs-path>`, `<branch>`, `<testCmd>`, `<scratch>`, `<pr>` or `<run>`, they name the value your brief gives you; a prompt you write for a refuter carries the value itself, never the placeholder.
|
|
8
|
+
You are a fleet fix-applier. Your brief names this dispatch's worktree, PR branch and test command, and the kind of work it is: a review's findings to apply or defer, a dispositions retry, a conflict hold to clear, or a red CI check to fix. Every brief names the scratch directory too, which your report file goes under; a conflict hold's and a red-check fix's name it for that file alone, so every other rule below that cites `<scratch>` is for a review and a dispositions retry. The rules about findings — scope and refuters, the apply/defer split, the dispositions record and the report of the split and the deferral issues — are for a review and a dispositions retry: a conflict hold and a red-check fix have no review file and write no dispositions record, so their report's `dispositionsRecord` is `null`, and what else each says to report is in its brief. Every other rule below holds for every kind. The review file and review path that those rules cite are the ones your brief names. Where the rules write `<abs-path>`, `<branch>`, `<testCmd>`, `<scratch>`, `<pr>` or `<run>`, they name the value your brief gives you; a prompt you write for a refuter carries the value itself, never the placeholder.
|
|
9
9
|
|
|
10
10
|
**`edit` and `read` resolve a bare relative path against the SESSION ROOT —
|
|
11
11
|
the controller's own main checkout — not against that worktree and not
|
|
@@ -332,8 +332,10 @@ Then write your report to the file your brief names,
|
|
|
332
332
|
number on its `deferred` entry, the deferral issues as `{issue, subject}`
|
|
333
333
|
entries — `filed` for every issue step 5 created, and `unrecorded` for one
|
|
334
334
|
whose `ledger.mjs filed` failed twice, which the controller's settle records —
|
|
335
|
-
`dispositionsRecord` your record's path and `testRun` your test result
|
|
336
|
-
|
|
335
|
+
`dispositionsRecord` your record's path and `testRun` your test result, `null`
|
|
336
|
+
when no test run exists — a `no-op`, or a `failed` that never ran tests; a
|
|
337
|
+
non-null `testRun` always reflects a real run. Then send the one line your
|
|
338
|
+
brief gives, `<your name>: <outcome> <path>`, and exit.
|
|
337
339
|
**Deferring everything is a normal
|
|
338
340
|
outcome, not a stall:** nothing is then staged, `git commit` refuses an empty
|
|
339
341
|
index, `~/.fleet/bin/fleet-run push-sync.mjs --branch <branch>` prints git's
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// The run's
|
|
3
|
-
// pending ticket-features rows into the tracked corpus,
|
|
4
|
-
// guard over it.
|
|
2
|
+
// The run's three metrics duties that keep the router's inputs current: move the
|
|
3
|
+
// pending ticket-features rows into the tracked corpus, widen a member-outcomes
|
|
4
|
+
// corpus written before its latest columns, then refresh the cost guard over it.
|
|
5
5
|
//
|
|
6
6
|
// metrics-refresh.mjs [--repo <dir>]
|
|
7
7
|
//
|
|
@@ -24,6 +24,20 @@
|
|
|
24
24
|
// rule, but phase 0 refuses a second one at its ledger rotation, which runs
|
|
25
25
|
// after its drain step, so a second controller's drain is not guarded.
|
|
26
26
|
//
|
|
27
|
+
// MEMBER-OUTCOMES WIDEN. `member-outcomes.mjs` refuses a row that is not exactly
|
|
28
|
+
// as wide as its current columns, so a consumer's `docs/metrics/member-outcomes.tsv`
|
|
29
|
+
// written before `ending`, `dispatch_model` or `work_s` shipped (20, 21 or 22
|
|
30
|
+
// columns; the file has no header row, so width is all that tells) could not be
|
|
31
|
+
// read by phase 0, the close-out scrape or `tier-outcomes.mjs append`. This
|
|
32
|
+
// appends the missing columns to every row, so every consumer widens at its next
|
|
33
|
+
// run start. Cells already there and the leading comments stay as written; an
|
|
34
|
+
// added cell is blank (unknown), except `ending` on an implementer's row, which
|
|
35
|
+
// is `unknown`, because blank there means "not an implementer". A file at the
|
|
36
|
+
// current width is not touched, so a second run changes nothing. Rows of any
|
|
37
|
+
// other width, rows of mixed widths and git conflict markers fail the duty,
|
|
38
|
+
// naming the file, and the file is left as it was; the cost guard after it does
|
|
39
|
+
// not run.
|
|
40
|
+
//
|
|
27
41
|
// COST GUARD. `pr-cost.mjs --guard` rewrites `.fleet/cost-guard.json`, which
|
|
28
42
|
// the router reads and fails closed without. It needs all three metrics TSVs;
|
|
29
43
|
// a workspace that lacks one has no corpus to guard yet (its first run), so the
|
|
@@ -32,8 +46,8 @@
|
|
|
32
46
|
// (no verdict yet — the baseline cell has too few merged PRs) are verdicts the
|
|
33
47
|
// router and `fleet-tick.mjs` consume, not failures; any other non-zero exit is.
|
|
34
48
|
//
|
|
35
|
-
// One `metrics-refresh: <duty>: …` line per duty on stdout. Exit 0 when
|
|
36
|
-
//
|
|
49
|
+
// One `metrics-refresh: <duty>: …` line per duty on stdout. Exit 0 when no
|
|
50
|
+
// duty failed; 1 when one failed — named on stderr, and the duties after
|
|
37
51
|
// it did not run (each is safe to run again); 2 on a usage error.
|
|
38
52
|
|
|
39
53
|
import { spawnSync } from "node:child_process";
|
|
@@ -44,13 +58,15 @@ import { makeDie, defineFlags } from "./arg.mjs";
|
|
|
44
58
|
import { gitEnv } from "./git-env.mjs";
|
|
45
59
|
import { FleetDirUnresolvable, fleetFile } from "./fleet-dir.mjs";
|
|
46
60
|
import { isCLI } from "./is-cli.mjs";
|
|
61
|
+
import { COLUMNS as MEMBER_COLUMNS, isImplementer } from "./member-outcomes.mjs";
|
|
47
62
|
import { FEATURE_COLUMNS, parseFeatures } from "./pull-attribution.mjs";
|
|
48
63
|
|
|
49
64
|
const NAME = "metrics-refresh";
|
|
50
65
|
const PR_COST = fileURLToPath(new URL("./pr-cost.mjs", import.meta.url));
|
|
51
66
|
const PENDING = join(".fleet", "ticket-features.pending.tsv");
|
|
52
67
|
const FEATURES = join("docs", "metrics", "ticket-features.tsv");
|
|
53
|
-
const
|
|
68
|
+
const MEMBERS = join("docs", "metrics", "member-outcomes.tsv");
|
|
69
|
+
const CORPUS = [MEMBERS, join("docs", "metrics", "tier-outcomes.tsv"), FEATURES];
|
|
54
70
|
const GUARD = join(".fleet", "cost-guard.json");
|
|
55
71
|
// pr-cost.mjs --guard: 0 no cell tripped, 3 a cell tripped, 4 no verdict yet —
|
|
56
72
|
// all three are verdicts its readers consume; anything else is a failure.
|
|
@@ -72,6 +88,62 @@ function widen(text, columns) {
|
|
|
72
88
|
}).join("\n");
|
|
73
89
|
}
|
|
74
90
|
|
|
91
|
+
// The first width a member-outcomes.tsv was ever written at that a later column widened: the
|
|
92
|
+
// width before `ending` shipped (merged 2026-10-22). Every width from it up to the current
|
|
93
|
+
// one is a file of this corpus written before the columns past that width existed.
|
|
94
|
+
const MEMBER_FIRST_WIDTH = MEMBER_COLUMNS.indexOf("ending");
|
|
95
|
+
const MEMBER_NAME_AT = MEMBER_COLUMNS.indexOf("member");
|
|
96
|
+
|
|
97
|
+
// `text`, a member-outcomes TSV at an earlier width, at the current one, with the columns it
|
|
98
|
+
// lacks appended to every row. The file has no header row, so a row's width is the only thing
|
|
99
|
+
// that says which columns it holds; leading comments and every cell already there are kept.
|
|
100
|
+
// An appended cell is blank, which that file's own rule reads as unknown — except `ending` on
|
|
101
|
+
// an implementer's row, where blank means "not an implementer": that reads `unknown`. Rows of
|
|
102
|
+
// one width other than the current or an earlier one, and a file whose rows are not all of
|
|
103
|
+
// one width, throw: parseTsv's refusal to guess a row's columns stands, and this does not
|
|
104
|
+
// widen what it would not read. A row ending in a CR (a CRLF file) gains its cells before that
|
|
105
|
+
// CR, which stays the row's last byte. A file with no rows comes back as `{ rows: 0 }`, and one
|
|
106
|
+
// already at the current width as null: neither has anything to write.
|
|
107
|
+
function widenMembers(text) {
|
|
108
|
+
const lines = text.split("\n");
|
|
109
|
+
const rows = [];
|
|
110
|
+
lines.forEach((l, i) => { if (l.trim() && !l.startsWith("#")) rows.push(i); });
|
|
111
|
+
if (!rows.length) return { rows: 0 };
|
|
112
|
+
const markerAt = rows.find((i) => /^(<{7}|={7}|>{7})( |\r?$)/.test(lines[i]));
|
|
113
|
+
if (markerAt !== undefined) throw new Error(`git conflict marker — ${lines[markerAt].slice(0, 60)}`);
|
|
114
|
+
const widths = [...new Set(rows.map((i) => lines[i].split("\t").length))].sort((a, b) => a - b);
|
|
115
|
+
if (widths.length > 1) throw new Error(`rows of different widths (${widths.join(", ")}) — a file is written at one width`);
|
|
116
|
+
const [width] = widths;
|
|
117
|
+
if (width === MEMBER_COLUMNS.length) return null;
|
|
118
|
+
if (width < MEMBER_FIRST_WIDTH || width > MEMBER_COLUMNS.length) {
|
|
119
|
+
const row = lines[rows[0]];
|
|
120
|
+
throw new Error(`malformed row: ${width} fields, expected ${MEMBER_COLUMNS.length} (or an earlier ${MEMBER_FIRST_WIDTH} to ${MEMBER_COLUMNS.length - 1}) — ${row.slice(0, 60)}`);
|
|
121
|
+
}
|
|
122
|
+
const added = MEMBER_COLUMNS.slice(width);
|
|
123
|
+
for (const i of rows) {
|
|
124
|
+
const eol = lines[i].endsWith("\r") ? "\r" : "";
|
|
125
|
+
const cells = lines[i].slice(0, lines[i].length - eol.length).split("\t");
|
|
126
|
+
lines[i] = [...cells, ...added.map((c) => (c === "ending" && isImplementer(cells[MEMBER_NAME_AT]) ? "unknown" : ""))].join("\t") + eol;
|
|
127
|
+
}
|
|
128
|
+
return { text: lines.join("\n"), width, rows: rows.length };
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function widenMemberOutcomes(repo) {
|
|
132
|
+
const file = join(repo, MEMBERS);
|
|
133
|
+
if (!existsSync(file)) return say(`member-outcomes: skipped, ${MEMBERS} not found — no corpus to widen yet`);
|
|
134
|
+
let widened;
|
|
135
|
+
try {
|
|
136
|
+
widened = widenMembers(readFileSync(file, "utf8"));
|
|
137
|
+
} catch (e) {
|
|
138
|
+
throw new Error(`${MEMBERS}: ${e.message}`);
|
|
139
|
+
}
|
|
140
|
+
if (widened === null) return say(`member-outcomes: already ${MEMBER_COLUMNS.length} columns`);
|
|
141
|
+
if (widened.rows === 0) return say("member-outcomes: no rows to widen");
|
|
142
|
+
writeFileSync(`${file}.tmp`, widened.text);
|
|
143
|
+
renameSync(`${file}.tmp`, file);
|
|
144
|
+
say(`member-outcomes: widened ${widened.rows} row${widened.rows === 1 ? "" : "s"} from ${widened.width} to ${MEMBER_COLUMNS.length} columns`);
|
|
145
|
+
}
|
|
146
|
+
|
|
75
147
|
function drain(repo) {
|
|
76
148
|
const pending = join(repo, PENDING);
|
|
77
149
|
if (!existsSync(pending)) return say(`drain: nothing pending in ${PENDING}`);
|
|
@@ -140,7 +212,7 @@ function main() {
|
|
|
140
212
|
die(`${e.message} — pass --repo <dir>`);
|
|
141
213
|
}
|
|
142
214
|
}
|
|
143
|
-
for (const [name, duty] of [["drain", drain], ["cost guard", costGuard]]) {
|
|
215
|
+
for (const [name, duty] of [["drain", drain], ["member-outcomes", widenMemberOutcomes], ["cost guard", costGuard]]) {
|
|
144
216
|
try {
|
|
145
217
|
duty(repo);
|
|
146
218
|
} catch (e) {
|
|
@@ -26,7 +26,12 @@
|
|
|
26
26
|
// is no bail`, gives no reason in `bailDetail`, or names a `pr` or a
|
|
27
27
|
// `head`, as `$.pr: <pr> is not null, with outcome "blocked" — a block
|
|
28
28
|
// reports no PR`, or whose `bailed` outcome names a `pr` or a `head`, as
|
|
29
|
-
// `$.pr: <pr> is not null, with outcome "bailed" — a bail reports no PR
|
|
29
|
+
// `$.pr: <pr> is not null, with outcome "bailed" — a bail reports no PR`,
|
|
30
|
+
// and a fix-pr report whose `applied` outcome names no `testRun`, as
|
|
31
|
+
// `$.testRun: null, with outcome "applied" — an applied fix reports the
|
|
32
|
+
// test run behind it`, or that defers a `refuted` finding with no
|
|
33
|
+
// `dispositionsRecord`, as `$.dispositionsRecord: null, with a refuted
|
|
34
|
+
// deferral at $.deferred[<i>] — settle reads its reason from that record`
|
|
30
35
|
// 2 usage: no or unknown subcommand, a wrong argument count, an unknown
|
|
31
36
|
// family, any flag; or <file> could not be read; or print could not
|
|
32
37
|
// write the schema to stdout. Refused on stderr, nothing on stdout
|
|
@@ -141,8 +146,10 @@ export const SCHEMAS = {
|
|
|
141
146
|
deferred: listOf({ bucket: str, index: int, issue: id }),
|
|
142
147
|
filed: issues,
|
|
143
148
|
unrecorded: issues,
|
|
144
|
-
|
|
145
|
-
|
|
149
|
+
// `null` where nothing exists: a conflict hold or a red-check fix writes no
|
|
150
|
+
// dispositions record, and a no-op or a failed fix may have run no tests.
|
|
151
|
+
dispositionsRecord: { type: ["string", "null"], pattern: "^/" },
|
|
152
|
+
testRun: obj({ cmd: str, exit: int, tests: int, cancelled: int }, ["object", "null"]),
|
|
146
153
|
confirmation: strings,
|
|
147
154
|
}),
|
|
148
155
|
finisher: report({
|
|
@@ -188,9 +195,12 @@ export function mergeBotVerdicts(report) {
|
|
|
188
195
|
// text that is not only whitespace, and names no `pr` or `head`, since a block
|
|
189
196
|
// reports no PR; a `bailed` outcome names no `pr` or `head` either, since a
|
|
190
197
|
// bail is the pre-code outcome — a PR the member opened is outcome `pr`, which
|
|
191
|
-
// settle checks. For a
|
|
192
|
-
//
|
|
193
|
-
//
|
|
198
|
+
// settle checks. For a fix-pr report: an `applied` outcome names its
|
|
199
|
+
// `testRun`, the run behind the commit, and a `refuted` deferral, under any
|
|
200
|
+
// outcome, names the `dispositionsRecord` settle reads its reason from. For a
|
|
201
|
+
// merge-bot report: each PR gets one verdict — merged, held, conflict-held or
|
|
202
|
+
// refused — the last it reached in the pass, so a PR named twice, in one list
|
|
203
|
+
// or in two, is a violation at its second entry.
|
|
194
204
|
export function reportViolation(family, value) {
|
|
195
205
|
const found = validate(SCHEMAS[family], value);
|
|
196
206
|
if (found !== null) return found;
|
|
@@ -206,6 +216,15 @@ export function reportViolation(family, value) {
|
|
|
206
216
|
if (value[field] !== null) return `$.${field}: ${show(value[field])} is not null, with outcome "bailed" — a bail reports no PR`;
|
|
207
217
|
}
|
|
208
218
|
}
|
|
219
|
+
if (family === "fix-pr") {
|
|
220
|
+
if (value.outcome === "applied" && value.testRun === null) {
|
|
221
|
+
return '$.testRun: null, with outcome "applied" — an applied fix reports the test run behind it';
|
|
222
|
+
}
|
|
223
|
+
const refuted = value.deferred.findIndex((d) => d.bucket === "refuted");
|
|
224
|
+
if (refuted !== -1 && value.dispositionsRecord === null) {
|
|
225
|
+
return `$.dispositionsRecord: null, with a refuted deferral at $.deferred[${refuted}] — settle reads its reason from that record`;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
209
228
|
if (family !== "merge-bot") return null;
|
|
210
229
|
const first = new Map();
|
|
211
230
|
for (const { pr, path } of mergeBotVerdicts(value)) {
|
|
@@ -136,8 +136,12 @@ recorded nothing — so run it again with `timeout: 0` on the call.
|
|
|
136
136
|
|
|
137
137
|
Your report is a file, `<scratch>/reports/<your name>.json`, `<your name>` the
|
|
138
138
|
`fix-pr-` name you were dispatched as, in the shape
|
|
139
|
-
`~/.fleet/bin/fleet-run report-schema.mjs print fix-pr` prints.
|
|
140
|
-
|
|
139
|
+
`~/.fleet/bin/fleet-run report-schema.mjs print fix-pr` prints. A field with
|
|
140
|
+
nothing real to point at is `null`: `dispositionsRecord` for a conflict hold or
|
|
141
|
+
a red-check fix, which write no dispositions record, and `testRun` when no test
|
|
142
|
+
run exists — a `no-op`, or a `failed` that never ran tests. A non-null value
|
|
143
|
+
always reflects a real record or a real run. Write the report before your
|
|
144
|
+
final message, and send nothing until
|
|
141
145
|
`~/.fleet/bin/fleet-run report-schema.mjs validate fix-pr <scratch>/reports/<your name>.json`
|
|
142
146
|
answers `valid`. Your final message is then one line,
|
|
143
147
|
`<your name>: <outcome> <scratch>/reports/<your name>.json`, `<outcome>` the
|
|
@@ -106,11 +106,13 @@ moves `.fleet/ticket-features.pending.tsv` — the row the router script
|
|
|
106
106
|
appended for each Pull at dispatch — into `docs/metrics/ticket-features.tsv`,
|
|
107
107
|
deduped on `session`+`agent`, so this run's own rows are in the file that gets
|
|
108
108
|
committed; that file is a run artifact too and is committed with the other
|
|
109
|
-
two. It then
|
|
110
|
-
|
|
109
|
+
two. It then widens a `docs/metrics/member-outcomes.tsv` written before the
|
|
110
|
+
newest columns, as at phase 0 — a file already at the current width is left
|
|
111
|
+
as it is — and then runs `pr-cost.mjs --guard`, which rewrites
|
|
112
|
+
`.fleet/cost-guard.json` from all three files. Exit 0: every duty ran. The guard's
|
|
111
113
|
own exit 3 (a cell tripped) and 4 (no verdict yet, baseline too thin) are
|
|
112
114
|
verdicts the router and `fleet-tick.mjs` read, never failures; the script
|
|
113
|
-
absorbs them. Exit 1 names the duty that failed on stderr and the
|
|
115
|
+
absorbs them. Exit 1 names the duty that failed on stderr and the duties after it
|
|
114
116
|
did not run; exit 2 is a usage error. At close-out a failure fails the
|
|
115
117
|
`metrics` step of `closeout.mjs finish`, so `commit-and-pr` stays pending: fix
|
|
116
118
|
the cause and run `finish` again — the pending file stays in `.fleet/` and the
|
|
@@ -162,7 +162,11 @@ script absorbs them. A workspace that lacks one of the three metrics TSVs
|
|
|
162
162
|
has no corpus to guard yet — its first run: the script prints a line naming
|
|
163
163
|
the missing file, skips the guard and exits 0. Exit 1 or 2 stops the run
|
|
164
164
|
before its first Pull: report the line the script printed on stderr, fix
|
|
165
|
-
the cause and run it again — each duty is safe to repeat.
|
|
165
|
+
the cause and run it again — each duty is safe to repeat. Between the drain
|
|
166
|
+
and the guard the script also widens a `docs/metrics/member-outcomes.tsv`
|
|
167
|
+
written before the newest columns: each row gains them, `ending` reads
|
|
168
|
+
`unknown` on an implementer's row, and nothing else changes. Without that,
|
|
169
|
+
phase 0, the close-out scrape and `tier-outcomes.mjs append` refuse the file.
|
|
166
170
|
|
|
167
171
|
## Launch the cockpit
|
|
168
172
|
|