@feigi/fleet-ctl 3.156.2 → 3.158.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/agents/fleet-fix-applier.agent.md +33 -6
- package/agents/fleet-review-runner.agent.md +3 -5
- package/agents/fleet-review-tests.agent.md +4 -1
- package/commands/review-and-fix.md +6 -4
- package/package.json +1 -1
- package/scripts/evict.mjs +23 -7
- package/scripts/fleet-event.mjs +23 -45
- package/scripts/fleet-state.mjs +14 -11
- package/scripts/fleet-tick.mjs +71 -26
- package/scripts/ledger-grammar.mjs +25 -6
- package/scripts/ledger.mjs +114 -19
- package/scripts/measure-copy.mjs +242 -0
- package/scripts/reclaim-scratch.mjs +149 -29
- package/scripts/review-core.mjs +31 -20
- package/scripts/review-eval.mjs +11 -17
- package/skills/run-team/SKILL.md +5 -5
- package/skills/run-team/references/finisher.md +2 -2
- package/skills/run-team/references/isolation.md +16 -0
- package/skills/run-team/references/ledger.md +1 -1
- package/skills/run-team/references/member-lifecycle.md +2 -2
- package/skills/run-team/references/reviewers.md +12 -0
|
@@ -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 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.
|
|
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 — but for the round root, which every kind of dispatch makes before its first copy. 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
|
Label names in this file are roles; the Label map gives the string to type; a member never derives the map.
|
|
11
11
|
|
|
@@ -58,7 +58,10 @@ substitution: resolve `<scratch>/pr<N>/<finding>/` in it to an absolute path
|
|
|
58
58
|
under your own run root — `mktemp -d` once per round for
|
|
59
59
|
`<scratch>/pr<N>/fix-XXXXXXXX/`, never bare `pr<N>`, since finding ids
|
|
60
60
|
restart at 1 each round too — and write that absolute path into the
|
|
61
|
-
refuter's prompt in its place; a refuter never derives its own path
|
|
61
|
+
refuter's prompt in its place; a refuter never derives its own path; and write
|
|
62
|
+
the copy command in it the same way, as one absolute command: `<abs-path>` is
|
|
63
|
+
your own worktree, `<head>` the review file's `head`, `<scratch>` the scratch
|
|
64
|
+
directory your brief names and `<N>` the PR number:
|
|
62
65
|
|
|
63
66
|
> Try to REFUTE this finding. Default to refuted=true if uncertain. Verify by
|
|
64
67
|
> RUNNING something — compile it, run the test, apply the mutation. Do not
|
|
@@ -82,6 +85,17 @@ refuter's prompt in its place; a refuter never derives its own path:
|
|
|
82
85
|
> support a claim about history; a pattern built from the token a diff removed
|
|
83
86
|
> does not support a claim that the category is empty.
|
|
84
87
|
>
|
|
88
|
+
> Your own copy of the tree is built by
|
|
89
|
+
> `~/.omp/plugins/node_modules/@feigi/fleet-ctl/scripts/fleet-run
|
|
90
|
+
> measure-copy.mjs --worktree <abs-path> --pin <head> --dest
|
|
91
|
+
> <scratch>/pr<N>/<finding>/copy --pr <N> --scratch <scratch>`, which you run
|
|
92
|
+
> the first time you need to measure and again for each further copy, each
|
|
93
|
+
> `--dest` another new directory under `<scratch>/pr<N>/<finding>/`. It
|
|
94
|
+
> installs in the copy, so run it as ONE blocking foreground command with a
|
|
95
|
+
> command deadline of 3600 seconds. Never make a copy by hand, and a refuter
|
|
96
|
+
> that only reads builds none. Any non-zero exit is no usable run:
|
|
97
|
+
> inconclusive, never a kill, and `refuted` stays true.
|
|
98
|
+
>
|
|
85
99
|
> When your check scores a mutant killed or a test red, run only in your own
|
|
86
100
|
> copy of the tree, and these rules decide it and nothing else:
|
|
87
101
|
>
|
|
@@ -268,16 +282,29 @@ zsh behaves exactly as with the bare `$cfg` — `BADJ` never set, exit 0.
|
|
|
268
282
|
eats uncommitted edits you made earlier, and the "clean baseline" you measure
|
|
269
283
|
next is silently the reverted file. Two members hit this in one run; one lost
|
|
270
284
|
prose edits and caught it only because a non-catch control failed. Copy the
|
|
271
|
-
file aside and copy it back. Better still, mutate a copy
|
|
272
|
-
|
|
273
|
-
|
|
285
|
+
file aside and copy it back. Better still, mutate a copy and leave the worktree
|
|
286
|
+
untouched — that is what refuters are already required to do, and it has no
|
|
287
|
+
blast radius at all. **Every kind of dispatch makes its round root before its
|
|
288
|
+
first copy**: `mktemp -d` once per round for `<scratch>/pr<N>/fix-XXXXXXXX/`,
|
|
289
|
+
never bare `pr<N>` and never a directory of your own naming. Build the copy
|
|
290
|
+
there with the script that builds every measuring copy, pinned to your own
|
|
291
|
+
commit (the full SHA `git rev-parse HEAD` prints in your worktree once you have
|
|
292
|
+
committed): `~/.omp/plugins/node_modules/@feigi/fleet-ctl/scripts/fleet-run measure-copy.mjs --worktree <abs-path> --pin <your commit> --dest <round root>/mutate-<k> --pr <pr> --scratch <scratch>`,
|
|
293
|
+
`<k>` 1 for your first copy and the next number for each further one: a copy at
|
|
294
|
+
a later commit is another new directory, since the script refuses one that exists.
|
|
295
|
+
It runs the Install step in the copy, which can take minutes: run it as ONE
|
|
296
|
+
blocking foreground command with a command deadline of 3600 seconds, never
|
|
297
|
+
backgrounded and never polled; any non-zero exit is no usable copy, so measure
|
|
298
|
+
nothing in it. Never make a copy by hand, never make `<scratch>/pr<N>/mutate/`,
|
|
299
|
+
and run no eviction step: the root sweep evicts the installed dependencies of
|
|
300
|
+
every copy under a round root once no fix-applier is live on the PR.
|
|
274
301
|
|
|
275
302
|
**Never `git stash` or `git stash pop` here either — a WIP commit is the
|
|
276
303
|
substitute, not a second scratch mechanism: `git commit -m wip`, then
|
|
277
304
|
restore or amend once you're back to real work.** The stash stack is
|
|
278
305
|
repo-global too, not per-worktree or per-session — the same `refs/stash`
|
|
279
306
|
every concurrent member and the main checkout share, not partitioned the
|
|
280
|
-
way
|
|
307
|
+
way your round root above is. A bare pop takes whichever entry is
|
|
281
308
|
on top, from any worktree, silently — rc 0, no error — when the tree
|
|
282
309
|
receiving it is clean on the affected paths, and refuses only when that
|
|
283
310
|
tree is already dirty there. A bare `git stash` (push) does not reach into
|
|
@@ -66,11 +66,9 @@ retries it under the next letter.
|
|
|
66
66
|
the file, for the fix-applier, and the controller reads only the digest.
|
|
67
67
|
- `status: "completed"` → first line `<your name>: completed <path>` — the
|
|
68
68
|
member name you were dispatched as, `review-pr-<pr>` or a later letter —
|
|
69
|
-
then the returned `path`, `
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
ledger token yourself. `errors` is non-empty when the first attempt failed
|
|
73
|
-
and the retry completed — report it anyway.
|
|
69
|
+
then the returned `path`, `attempts`, `errors` and `digest`, verbatim, as
|
|
70
|
+
JSON; you write no ledger token yourself. `errors` is non-empty when the
|
|
71
|
+
first attempt failed and the retry completed — report it anyway.
|
|
74
72
|
- `status: "failed"` → first line `<your name>: failed`, then both
|
|
75
73
|
`errors` verbatim. Do not run the cell again — the one retry already
|
|
76
74
|
happened inside it.
|
|
@@ -40,7 +40,10 @@ the run that shows it surviving.
|
|
|
40
40
|
|
|
41
41
|
In both modes `<testCmd>` is the `command` your dispatch prompt's
|
|
42
42
|
Tests paragraph names, run only in your own copy of the snapshot. Make that
|
|
43
|
-
copy
|
|
43
|
+
copy with the command your dispatch prompt gives for it, run exactly as
|
|
44
|
+
written: any non-zero exit is no usable copy, so measure nothing in it. Where
|
|
45
|
+
your dispatch prompt gives none, make that copy from the snapshot's tracked
|
|
46
|
+
files only —
|
|
44
47
|
`git -C <snapshot> archive HEAD | tar -x -C <copy>`, or a `git clone` of the
|
|
45
48
|
snapshot repository — then `git init`, `git add -A -f` and commit in it, then
|
|
46
49
|
run the Install step your dispatch prompt names from the copy's root before
|
|
@@ -16,7 +16,7 @@ Label names in this file are roles; the Label map gives the string to type; a me
|
|
|
16
16
|
`fleet-review-<key>` (e.g. `fleet-review-correctness`).
|
|
17
17
|
|
|
18
18
|
See **Specialists** — those constraints are not optional.
|
|
19
|
-
2. Plan the actions. Split explicitly into **apply now** / **defer**. A finding is deferred, never dropped. **Every `suggestion` — the review's `severity`, the plugin's *Suggestions* bucket — arrives unchecked: the review budgets that band 0 refuters, so nothing has looked at it yet.** Checking it is now your job, not nobody's. So split it by SCOPE first, and check it in either scope. Out of the PR's ticket scope → defer and file, but **the claim bar runs first:** a suggestion whose claim is about shape — step 5's worth-a-claim bar, recorded `claimKind: shape` — gets no refuter and goes to the `PR #<pr> review: the suggestion band, checked` record, and every other out-of-scope suggestion gets the same refuter an in-scope one does, dispatched the same way, before it is filed. In scope → dispatch one refuter against it, biased to refuse, and hand it this instruction verbatim with one substitution: resolve `<scratch>/pr<N>/<finding>/` in it to an absolute path under your own run root — `mktemp -d` once per round for `<scratch>/pr<N>/fix-XXXXXXXX/`, never bare `pr<N>`, since finding ids restart at 1 each round too — and write that absolute path into the refuter's prompt in its place; a refuter never derives its own path, and tell it your step-3 `testCmd`, which its rules call `<testCmd>`: *Try to REFUTE this finding. Default to refuted=true if uncertain. Verify by RUNNING something — compile it, run the test, apply the mutation. Do not reason your way to agreement. Observe that run synchronously — run the command, wait for it, read its exit code. Never poll a log file for a completion marker: prefer ONE blocking run to a poll loop, and treat its return as permission to look, never as the answer. Reading a log the run has already finished writing is fine; waiting on one is not. Never run `pkill -f` on a pattern: members share one process table, so a pattern such as a test file's name matches every member's run, not only yours. Clearing your own leftover process needs its PID; report a stalled run to the controller instead. If you match a test reporter's own output, accepting both `ℹ` and `#` is necessary but NOT sufficient — strip SGR escapes first as well. node's prefix moves with the node version and with whether stdout is a TTY, and color wraps the whole line so it begins with ESC and no prefix anchor matches at all, which returns empty at exit 0 — indistinguishable from a hung run and from a run of zero tests. For an uncolored baseline use `env -u FORCE_COLOR`; `FORCE_COLOR=` empty still enables color, so it is not a control. State your search scope AND what your pattern would have missed. A grep over one ref does not support a claim about history; a pattern built from the token a diff removed does not support a claim that the category is empty. When your check scores a mutant killed or a test red, run only in your own copy of the tree, and these rules decide it and nothing else: Valid red: a run that completed — the command returned on its own, with no signal and no timeout, deadline or kill having fired — in which the test the claim names is reported failing. An exit ≠ 0 with no failing test is not red, and a different test failing is not red for this claim. A red in the full suite only triggers a narrowed run; it is never evidence on its own. Narrowed run: the Test entrypoint with arguments appended, `<testCmd> <args>`. That appended arguments reach the Test entrypoint is all that is promised about them, so a narrowed run counts only if it reports `tests` > 0 and its output names the claimed test. If no narrowing can be proven, run the full `<testCmd>` and read the named test's own result from its output. Kill: the mutant produced a valid red in a narrowed run, and the same narrowed command, in the same tree with the mutant reverted, ran a valid green with the named test passing — completed, exit 0, `tests` > 0, `cancelled` 0. A completed exit ≠ 0 with the named test not failing is not a kill, and no kill stands without that green run on the unmutated tree. The result is inconclusive, never a kill, when the red does not reproduce in the narrowed run, when the unmutated tree is red too, or when no usable run exists. Evidence line: every kill and every valid red you claim carries one line in the claim's own free-text field: `red: <cmd> → exit N, fail K incl <test>; baseline: <cmd> → exit 0, <test> pass`. A failing-test finding filed off the review's shared run carries the `red:` half alone. This refuter has no abstain: a run that could not decide — neither a valid red nor a valid green — is no kill and no refutation, so name the runs in `reason`, each with its evidence line, and leave `refuted` true, so the suggestion defers on the record instead of applying on a check that decided nothing. A failure injection with no positive control has produced NO result, never a negative one. Before you read an injected fault — an env var, an argv word, a mutant — as having had no effect, prove the injection reached the child: one run whose output differs with it present versus absent, or the child echoing the injected value back. Uncontrolled, the cell is unrun — say so in your verdict instead of reporting a no-effect result. Build such an invocation as an array expanded braced and quoted — `cfg=(SETB=1 BADJ=1); env "${cfg[@]}" sh ./probe.sh` — or inline the assignments literally — `env SETB=1 BADJ=1 sh ./probe.sh`; NEVER from an unquoted scalar — `cfg="SETB=1 BADJ=1"; env $cfg sh ./probe.sh` — which under zsh passes ONE argument, sets a variable literally named `SETB` to `1 BADJ=1`, never sets `BADJ` at all, and still exits 0. `env $cfg[@]` is not the portable spelling either: measured, bash word-splits it into `SETB=1` and `BADJ=1[@]`, so the injection variable is set to a corrupted value, while zsh behaves exactly as with the bare `$cfg` — `BADJ` never set, exit 0. Everything you write — mutants, fixtures, scratch repos — goes under `<scratch>/pr<N>/<finding>/` and nowhere else; the checkout and any worktree are never write targets, though `git show`/`git archive` at a pinned ref read fine anywhere. Chain the directory change into the command, `cd "$D" && git …`, never `cd "$D"; git …`, so a failed `cd` cannot leave a `git` command running in the checkout — and bracket a fixture's own git with `git rev-parse --show-toplevel`: before `git init` it must NOT resolve to the host repository, and `fatal: not a git repository` (exit 128) is the usual pass, not a failure — an outer repository whose ignore rules cover your scratch dir is a pass too; before any `git commit` it must resolve to your scratch path, which catches a forgotten `git init` under any enclosing repository — compare resolved forms (`realpath`), since `--show-toplevel` can report a symlinked parent such as `/tmp` or a symlinked `$HOME` under its resolved name.* That last clause is the whole mechanism — a refuter left to reason its way to agreement rubber-stamps, and "apply only what survives" silently degrades into "apply everything in scope". Apply only what survives; a refuted one defers with the refutation in its body. **Out of scope the refuter decides only where the suggestion is filed — it defers either way, never applied.** Refuted → the `PR #<pr> review: the suggestion band, checked` record, never an open issue. Survived, or its refuter crashed or abstained → its own open issue labelled `needs-triage`, citing the verdict, or the run that crashed, in the body. There is no cap on these refuters; your final verdict (step 4) says how many you dispatched against out-of-scope suggestions. "In scope" means the ticket's scope, not merely the same files — and applying one still never licenses editing a file the ticket has no business in. **A finding in `unverified` whose refuters ran and crashed or abstained always defers, whatever its severity** — and which it is, you read off the finding's **`refutersDispatched`** and **`refutersInconclusive`**, never off severity and never off an empty vote list: `refutersDispatched` above zero with nothing decided means every refuter dispatched against it died or abstained, and `refutersInconclusive` counts the ones that abstained. Only a `survived` finding has been checked; severity says how much a finding would matter if true, never whether anything looked. **Deferring a crash is your move, and re-running it is not** — the review already re-dispatched every crashed refuter pair once, in-run, so a crash that reaches you crashed twice, and the result's `resume` field names the one move left, which is not yours: nothing replays a review that ran in a runner's kernel — it is reported, not acted on. So say *in the deferral* that its refuters crashed rather than that it went unchecked, and re-run nothing for it. **An abstention is not a crash** — a refuter that abstained ran and could not decide: defer and file the finding, citing the inconclusive runs each abstaining refuter named in its `reason`, and never describe its refuters as crashed. **A `suggestion` is also in `unverified`, for a different reason — `refutersDispatched` of zero, the 0-refuter budget the workflow gives that band by policy, so nothing looked *there* — and the scope split above, not this rule, covers it.**
|
|
19
|
+
2. Plan the actions. Split explicitly into **apply now** / **defer**. A finding is deferred, never dropped. **Every `suggestion` — the review's `severity`, the plugin's *Suggestions* bucket — arrives unchecked: the review budgets that band 0 refuters, so nothing has looked at it yet.** Checking it is now your job, not nobody's. So split it by SCOPE first, and check it in either scope. Out of the PR's ticket scope → defer and file, but **the claim bar runs first:** a suggestion whose claim is about shape — step 5's worth-a-claim bar, recorded `claimKind: shape` — gets no refuter and goes to the `PR #<pr> review: the suggestion band, checked` record, and every other out-of-scope suggestion gets the same refuter an in-scope one does, dispatched the same way, before it is filed. In scope → dispatch one refuter against it, biased to refuse, and hand it this instruction verbatim with one substitution: resolve `<scratch>/pr<N>/<finding>/` in it to an absolute path under your own run root — `mktemp -d` once per round for `<scratch>/pr<N>/fix-XXXXXXXX/`, never bare `pr<N>`, since finding ids restart at 1 each round too — and write that absolute path into the refuter's prompt in its place; a refuter never derives its own path; write the copy command in the same way — `<abs-path>` your own worktree, `<head>` the review file's `head`, the rest resolved likewise — and tell it your step-3 `testCmd`, which its rules call `<testCmd>`: *Try to REFUTE this finding. Default to refuted=true if uncertain. Verify by RUNNING something — compile it, run the test, apply the mutation. Do not reason your way to agreement. Observe that run synchronously — run the command, wait for it, read its exit code. Never poll a log file for a completion marker: prefer ONE blocking run to a poll loop, and treat its return as permission to look, never as the answer. Reading a log the run has already finished writing is fine; waiting on one is not. Never run `pkill -f` on a pattern: members share one process table, so a pattern such as a test file's name matches every member's run, not only yours. Clearing your own leftover process needs its PID; report a stalled run to the controller instead. If you match a test reporter's own output, accepting both `ℹ` and `#` is necessary but NOT sufficient — strip SGR escapes first as well. node's prefix moves with the node version and with whether stdout is a TTY, and color wraps the whole line so it begins with ESC and no prefix anchor matches at all, which returns empty at exit 0 — indistinguishable from a hung run and from a run of zero tests. For an uncolored baseline use `env -u FORCE_COLOR`; `FORCE_COLOR=` empty still enables color, so it is not a control. State your search scope AND what your pattern would have missed. A grep over one ref does not support a claim about history; a pattern built from the token a diff removed does not support a claim that the category is empty. Your own copy of the tree is built by `~/.omp/plugins/node_modules/@feigi/fleet-ctl/scripts/fleet-run measure-copy.mjs --worktree <abs-path> --pin <head> --dest <scratch>/pr<N>/<finding>/copy --pr <N> --scratch <scratch>`, which you run the first time you need to measure and again for each further copy, each `--dest` another new directory under `<scratch>/pr<N>/<finding>/`. It installs in the copy, so run it as ONE blocking foreground command with a command deadline of 3600 seconds. Never make a copy by hand, and a refuter that only reads builds none. Any non-zero exit is no usable run: inconclusive, never a kill, and `refuted` stays true. When your check scores a mutant killed or a test red, run only in your own copy of the tree, and these rules decide it and nothing else: Valid red: a run that completed — the command returned on its own, with no signal and no timeout, deadline or kill having fired — in which the test the claim names is reported failing. An exit ≠ 0 with no failing test is not red, and a different test failing is not red for this claim. A red in the full suite only triggers a narrowed run; it is never evidence on its own. Narrowed run: the Test entrypoint with arguments appended, `<testCmd> <args>`. That appended arguments reach the Test entrypoint is all that is promised about them, so a narrowed run counts only if it reports `tests` > 0 and its output names the claimed test. If no narrowing can be proven, run the full `<testCmd>` and read the named test's own result from its output. Kill: the mutant produced a valid red in a narrowed run, and the same narrowed command, in the same tree with the mutant reverted, ran a valid green with the named test passing — completed, exit 0, `tests` > 0, `cancelled` 0. A completed exit ≠ 0 with the named test not failing is not a kill, and no kill stands without that green run on the unmutated tree. The result is inconclusive, never a kill, when the red does not reproduce in the narrowed run, when the unmutated tree is red too, or when no usable run exists. Evidence line: every kill and every valid red you claim carries one line in the claim's own free-text field: `red: <cmd> → exit N, fail K incl <test>; baseline: <cmd> → exit 0, <test> pass`. A failing-test finding filed off the review's shared run carries the `red:` half alone. This refuter has no abstain: a run that could not decide — neither a valid red nor a valid green — is no kill and no refutation, so name the runs in `reason`, each with its evidence line, and leave `refuted` true, so the suggestion defers on the record instead of applying on a check that decided nothing. A failure injection with no positive control has produced NO result, never a negative one. Before you read an injected fault — an env var, an argv word, a mutant — as having had no effect, prove the injection reached the child: one run whose output differs with it present versus absent, or the child echoing the injected value back. Uncontrolled, the cell is unrun — say so in your verdict instead of reporting a no-effect result. Build such an invocation as an array expanded braced and quoted — `cfg=(SETB=1 BADJ=1); env "${cfg[@]}" sh ./probe.sh` — or inline the assignments literally — `env SETB=1 BADJ=1 sh ./probe.sh`; NEVER from an unquoted scalar — `cfg="SETB=1 BADJ=1"; env $cfg sh ./probe.sh` — which under zsh passes ONE argument, sets a variable literally named `SETB` to `1 BADJ=1`, never sets `BADJ` at all, and still exits 0. `env $cfg[@]` is not the portable spelling either: measured, bash word-splits it into `SETB=1` and `BADJ=1[@]`, so the injection variable is set to a corrupted value, while zsh behaves exactly as with the bare `$cfg` — `BADJ` never set, exit 0. Everything you write — mutants, fixtures, scratch repos — goes under `<scratch>/pr<N>/<finding>/` and nowhere else; the checkout and any worktree are never write targets, though `git show`/`git archive` at a pinned ref read fine anywhere. Chain the directory change into the command, `cd "$D" && git …`, never `cd "$D"; git …`, so a failed `cd` cannot leave a `git` command running in the checkout — and bracket a fixture's own git with `git rev-parse --show-toplevel`: before `git init` it must NOT resolve to the host repository, and `fatal: not a git repository` (exit 128) is the usual pass, not a failure — an outer repository whose ignore rules cover your scratch dir is a pass too; before any `git commit` it must resolve to your scratch path, which catches a forgotten `git init` under any enclosing repository — compare resolved forms (`realpath`), since `--show-toplevel` can report a symlinked parent such as `/tmp` or a symlinked `$HOME` under its resolved name.* That last clause is the whole mechanism — a refuter left to reason its way to agreement rubber-stamps, and "apply only what survives" silently degrades into "apply everything in scope". Apply only what survives; a refuted one defers with the refutation in its body. **Out of scope the refuter decides only where the suggestion is filed — it defers either way, never applied.** Refuted → the `PR #<pr> review: the suggestion band, checked` record, never an open issue. Survived, or its refuter crashed or abstained → its own open issue labelled `needs-triage`, citing the verdict, or the run that crashed, in the body. There is no cap on these refuters; your final verdict (step 4) says how many you dispatched against out-of-scope suggestions. "In scope" means the ticket's scope, not merely the same files — and applying one still never licenses editing a file the ticket has no business in. **A finding in `unverified` whose refuters ran and crashed or abstained always defers, whatever its severity** — and which it is, you read off the finding's **`refutersDispatched`** and **`refutersInconclusive`**, never off severity and never off an empty vote list: `refutersDispatched` above zero with nothing decided means every refuter dispatched against it died or abstained, and `refutersInconclusive` counts the ones that abstained. Only a `survived` finding has been checked; severity says how much a finding would matter if true, never whether anything looked. **Deferring a crash is your move, and re-running it is not** — the review already re-dispatched every crashed refuter pair once, in-run, so a crash that reaches you crashed twice, and the result's `resume` field names the one move left, which is not yours: nothing replays a review that ran in a runner's kernel — it is reported, not acted on. So say *in the deferral* that its refuters crashed rather than that it went unchecked, and re-run nothing for it. **An abstention is not a crash** — a refuter that abstained ran and could not decide: defer and file the finding, citing the inconclusive runs each abstaining refuter named in its `reason`, and never describe its refuters as crashed. **A `suggestion` is also in `unverified`, for a different reason — `refutersDispatched` of zero, the 0-refuter budget the workflow gives that band by policy, so nothing looked *there* — and the scope split above, not this rule, covers it.**
|
|
20
20
|
**Write every ruling to `<scratch>/dispositions-<your name>.json`, `<your name>` the `fix-pr-<pr>[-x]` you were dispatched as (standalone, `fix-pr-<pr>`) — the disposition record `dispositions-check.mjs` judges against the review result file before any finisher is dispatched.** It is `{"head": "<the review file's head>", "run": "<the run root's name in the review path>", "entries": [ … ]}` — `run` the `<run>` of the review path your prompt names, which the check holds against the one the PR's latest `reviewed=` names, so a record written against an earlier review of the same PR, a same-head one included, is a mismatch (standalone, with no ledger naming a run, leave it out): one entry per `survived` finding and per `unverified` finding, plus one per `refuted` finding you reverse. Each entry carries `bucket` (`survived|unverified|refuted`), `index` (its position in that bucket of the review file — stable, since a round's file never changes), `scope` (`in|out`), `claimKind` (`behavior|shape`) and `disposition` (`apply|defer`), and where they apply `reason`, `issue` (the number you filed it to or commented on), `verdictPath` (a suggestion's refuter verdict file, in scope and, above the claim bar, out of scope) and `remedyFiles` (the files its remedy names). A `refuted` entry carries `scope`, `claimKind` and `disposition` like every other entry, and a non-empty `reason` holding the evidence that reverses it; a missing or blank `reason` is a mismatch. The check reads scope off the diff before it reads your entry: a finding with no `line`, or on a line `git diff` touches from the PR's merge-base with `origin/main` to the review's `head`, is in scope whatever `scope` says, and only otherwise does the declared one stand. An in-scope `survived` finding deferred passes only with `reason` `false-rationale`, `mutual-exclusion`, `remedy-worse` or `remedy-outside-diff`. `remedy-outside-diff` — the remedy would edit a file the PR's diff does not touch — also needs `remedyFiles` to name at least one file absent from `git diff` from that merge-base to the review's `head`: none named, or every one in that diff, is a mismatch. A `critical` or `important` finding deferred for it goes to the maintainer instead of passing: the script exits 1 with verdict `escalate`, `ledger.mjs dispatch` refuses the PR's finisher until answered; a `suggestion` deferred for it passes. Any other reason, none, or a `survived` or `unverified` finding with no entry is a mismatch: the script exits 1 naming each violating entry's bucket, index and rule, and `ledger.mjs dispatch` refuses the PR's finisher. `disposition` has no `dismiss`: an in-scope `survived` finding verified correct, needing no change, is deferred with `reason` `false-rationale` and filed on the suggestion-band record — step 5's `PR #<pr> review: the suggestion band, checked`.
|
|
21
21
|
**Give every entry whose finding stands a Charge:** `charge` — `false-claim`, `unmet`, `both` or `none` — and, with `none` only, a `chargeReason`: `defect-outside-acceptance` (a defect outside the ticket's acceptance criteria, which no text the implementer wrote claims is otherwise), `not-the-implementers-text` (the false text predates the PR, or comes from the ticket) or `claim-about-untouched-code` (a claim about code the change does not touch). A `survived` finding not deferred `false-rationale` stands, and so does every `refuted` one you reverse; an `unverified` one never does. Charge the work as submitted — a finding you apply is charged as if it were still there — by the definitions of `closed_own_ticket` and `minted_false_claim` in the header of `docs/metrics/tier-outcomes.tsv`, against the ticket as its implementer was dispatched with it; an entry scoped `out` is charged `none`. The check requires a Charge on every standing entry of the record answering the PR's first review — the first that counted no survived and no unverified finding, or else the first a fix-applier answered — and a record answering a later review, or one checked with no ledger, needs none. Wherever a `charge` or `chargeReason` appears it is judged: an unknown value, `none` with no `chargeReason`, a `chargeReason` with any other `charge` or with none, and an out-of-scope entry charged anything but `none` are each a mismatch.
|
|
22
22
|
3. **Run `checkCmd` and `testCmd` before you commit**, from the worktree, each copied verbatim — not a runner you picked. `checkCmd` is the Recipe's Check step and `testCmd` is the command your dispatcher handed you; **standalone, with no dispatcher to hand you them, they are the repo's own Check step and Test entrypoint**, read off the repo's Recipe cache from `<tree>`, the worktree this step runs from, at `origin/main` (`derive-testcmd.sh <tree> check --at origin/main` prints the first, `derive-testcmd.sh <tree> test --at origin/main` the second; every worktree reads the one cache). A refusal naming `--at` (`origin/main` does not resolve) is no cache fault, so fetch it and read again, never derive; exit 3 (a tool the reader needs could not run) is an environment fault, so fix it and read again, never derive; any other exit 1 is a refusal about the cache, so run the Recipe derivation step first — dispatch a `task` member, agent `fleet-recipe-deriver`, its prompt naming the main checkout's absolute path as `<repo>` and a scratch directory of its own; it proves all three commands in a throwaway worktree and writes the cache only on proof. Its `RECIPE NOT PROVEN` is a stop, reported with its reason, and **so is a read that refuses again after `RECIPE PROVEN`, reported with that refusal**: there is no second derivation. Never fall back to a runner of your own choosing. `tests 0` is a FAILED run, not a pass: a glob matching nothing still exits 0. **Zero is not the only no-work count.** A run reporting **0 passes with no failures** skipped everything it collected, and a count **materially below the whole suite** means you ran a partial tree — this suite reported `tests 937` when this line was written, so compare what you get against a full run rather than against zero. Red, zero-test, or either no-work count → fix it or move the finding to defer; never commit over it. Then commit and push — `~/.omp/plugins/node_modules/@feigi/fleet-ctl/scripts/fleet-run push-sync.mjs --branch <branch>`, which pushes the explicit refspec `HEAD:refs/heads/<branch>` and then moves the worktree holding `<branch>` to the pushed SHA, or names why it did not and exits 3 with the push landed: this step also runs from a `--detach` worktree (`run-team/SKILL.md`'s worktree-recreation form), where a bare `git push` exits 128 (`fatal: You are not currently on a branch`), any push whose destination is `HEAD` rather than a full or branch refname (`-u` or not, forced or not) exits 1 (`error: The destination you provided is not a full refname`), and a refspec push alone leaves the claim worktree's `refs/heads/<branch>` at its old tip — and report the test result alongside the SHA. **Then reconcile the PR body with what you actually did.** It merges into the permanent record and nothing downstream re-derives it: your commit messages are yours to fix and usually get fixed, the body is neither. Removing a change, or reversing one, leaves the body asserting work the diff no longer contains. `gh pr edit <pr> --body-file <path>`, and re-read the body against the final diff rather than against your memory of it. **Never `--no-verify` on a commit you push, or on the push itself.** The fleet runs in repos it knows nothing about: it must not assume a pre-commit hook exists, and must never bypass one that does on what reaches the branch — a hook that fails is a finding to report, not an obstacle. Nothing re-reviews what you commit here, so this run is the only gate between your edit and a merge.
|
|
@@ -49,6 +49,8 @@ Label names in this file are roles; the Label map gives the string to type; a me
|
|
|
49
49
|
|
|
50
50
|
Three claims, none substituting for another: **run-binding** (this green belongs to this SHA) · **your green** (correct against its base) · **the bot's post-rebase green** (still correct against current `main`). Only the third catches a sibling renaming a symbol you use — a rebase can apply cleanly and still break the build, which is why it is the bot's job and not yours.
|
|
51
51
|
|
|
52
|
+
7. **Standalone, as the last step, run the root sweep:** `~/.omp/plugins/node_modules/@feigi/fleet-ctl/scripts/fleet-run reclaim-scratch.mjs --root <scratch> --apply`. With no ledger it refuses and evicts nothing. Under the fleet run no eviction step: the tick runs the sweep.
|
|
53
|
+
|
|
52
54
|
## The review result file
|
|
53
55
|
|
|
54
56
|
**Dispatched as a fix-applier, you read the review off one file: `<scratch>/pr<pr>/<run>/review.json`, the path your prompt names — `<run>` the review's own run root, the one the PR's latest `reviewed=` token names.** It holds the bare result object the review returned, in this key order — the digest `pr`, `head`, `resume`, `testEnvironment`, `suiteVerdict`, `dimensionsRun`, `dimensionsUnrun`, `cwdAudit`, `counts`, then `snapshot`, `survived`, `refuted`, `unverified` — the `review-pr-<pr#>` runner member (`agents/fleet-review-runner.agent.md`) writes it. The controller reads the digest and never the findings, so **every per-PR ruling in this section is yours** — nobody upstream has made one for you. A prompt that pastes the findings in instead of naming the file hands you the same buckets, and every ruling here applies to them unchanged. Read the file a bucket at a time with `jq`, never whole into your context — a review's result runs to tens of KB:
|
|
@@ -69,7 +71,7 @@ jq '.refuted' "$R" # refuted: your
|
|
|
69
71
|
|
|
70
72
|
**Read `testEnvironment` and `cwdAudit` before you act on any result of the shared test run.** `testEnvironment` says whether the snapshot the specialists ran in was verified as the reviewed tree: verified, a red there is a fact about the tree; UNVERIFIED, tests that ask git what ships decline or fail for the environment, so a red or a short count there is not a finding until you reproduce it in the worktree. `cwdAudit` is each specialist's audit of the checkout it inherited, `{dimension, state, line}`: `dirty` and `missing` are equally loud, because either names a checkout a specialist may have written to. Check it with `git -C <that path> status --porcelain -uall` — the path is in a `dirty` entry's `line`, and a `missing` entry's is the main checkout, the parent of `git rev-parse --path-format=absolute --git-common-dir` — and report what it printed; never revert content you did not write. A `dimensionsUnrun` entry is a specialist that returned nothing, its `reason` the crash: name it unrun in your report, because an absence of findings is not coverage, and re-run nothing — the review already re-dispatched every crashed specialist once, in-run. `suiteVerdict` is the review's one judgement on its shared test run, `{usable, reason}`: usable does not mean green, and the verdict says nothing about whether a dimension reviewed. When `suiteVerdict.usable` is false, name `shared test run not usable: <reason>` in your final verdict and do nothing more about it — your own `<testCmd>` run and CI cover the suite.
|
|
71
73
|
|
|
72
|
-
**Scan the findings against each other for MUTUAL EXCLUSION, and rule before the conflicting change reaches the tree.** Refuters are blind to their siblings, so two can approve changes that cannot both land — one preserving a comment block another's change deletes, one keeping a binding another collapses.
|
|
74
|
+
**Scan the findings against each other for MUTUAL EXCLUSION, and rule before the conflicting change reaches the tree.** Refuters are blind to their siblings, so two can approve changes that cannot both land — one preserving a comment block another's change deletes, one keeping a binding another collapses. You hold every finding, so only you can see the pair — and the scan's two inputs arrive at different times, so run it twice. **Before you apply anything**, group the findings by `file:line` and by whether one's fix undoes another's; that is in the findings' own text. **Then as each refuter you dispatch reports**, read its blast radius against what you have already ruled on. **A conflicting pair goes to a SINGLE refuter, briefed with both claims** — that is what settled one such pair, one refuter ruling *"B wins: A's premise is false"* where two independent refuters would each have approved their own side. Defer only when no single refuter can settle it, with the equivalence evidence recorded in the filed issue so the work is not redone. Never let both reach the tree and hope the diff coheres.
|
|
73
75
|
|
|
74
76
|
**A finding whose suggested fix quotes text another applied finding deletes goes stale on arrival.** **Re-derive, never copy:** apply the finding that changes the text first, then derive the assertion from the post-fix tree. A `suggested_fix` is a hypothesis the review never ran; only the claim was refuted against.
|
|
75
77
|
|
|
@@ -98,7 +100,7 @@ It cannot ask the user anything and cannot wait on CI — rebasing, watching che
|
|
|
98
100
|
|
|
99
101
|
Tell readers **`git show <sha>:<path>` is the source of truth** — the object store cannot be contaminated by any agent, needs no copy, and touches nothing. Make it the default for settling *what the PR contains*, not a fallback. A finding that disagrees with it is a probe artifact. **Then bound the read — the guarantee is the blob, not the byte count.** `git show <sha>:<path> | sed -n 'A,Bp'` reads the same uncontaminatable object; take the file whole only once `| wc -l` says it is small — a count, not a feeling. Where the *change* is what you are settling, diff instead of reading: `git diff <base>...<head> -- <path>` for the PR's whole change, `git show <sha> -- <path>` only for one named commit's. That second form is scoped to that single commit and prints **nothing, at exit 0**, when the commit did not touch the path (measured) — the same silent green as `tests 0`, and it reads as "the PR changed nothing here". What an unbounded read costs is in run-team's `references/reviewers.md` (**What an unbounded read costs**).
|
|
100
102
|
|
|
101
|
-
**Brace a ref held in a variable — `git show "${SHA}:<path>"` — because quoting is not what fixes it.** zsh reads a `:x` suffix after an unbraced parameter as a history modifier,
|
|
103
|
+
**Brace a ref held in a variable — `git show "${SHA}:<path>"` — because quoting is not what fixes it.** zsh reads a `:x` suffix after an unbraced parameter as a history modifier, so git is handed a ref nobody typed; braces end the parameter name before the colon. Evidence: run-team's `references/reviewers.md` (**Bracing a ref held in a variable**).
|
|
102
104
|
|
|
103
105
|
**The fan-out scales to the diff — the review computes it, you don't.** Its snapshot agent runs `diff-stats.mjs`, and `selectDimensions` keeps the applicable subset of the six-specialist catalog (fleet-review-correctness, fleet-review-silent-failure, fleet-review-tests, fleet-review-comments, fleet-review-types, fleet-review-simplify): fleet-review-correctness always; fleet-review-tests whenever the diff touches a test file, and also for a `production`-profile diff that changes source and touches no test file — there its job is the coverage gap, mutating the changed source and reporting behaviour no existing test kills, so untested source changes get asked that question during review — and dropped otherwise, so a diff with no source and no test file loses it; fleet-review-types / fleet-review-silent-failure / fleet-review-simplify with no source; a docs-only PR keeps only fleet-review-correctness + fleet-review-comments. **Then the size tier applies a floor on top:** a `single-file` or `small` profile keeps fleet-review-correctness + fleet-review-silent-failure + fleet-review-comments, plus fleet-review-tests when the diff touches a test file — so a small source PR runs three, not five, and the coverage-gap case above never reaches the size tier. **fleet-review-comments is unconditional on the floor**: it used to need a docs *file* in the diff, but `classify()` scores `.js`/`.mjs` `src` via the code-extension check and `.sh` `src` by falling through everything else, so a PR whose whole substance was prose in a `.js`/`.mjs`/`.sh` comment scored `docs: 0` and lost the one specialist whose job it was — measured five times in production, all correction-class PRs, with `dimensionsUnrun` empty each time because the trim was by design. **The floor outranks the no-source drop for fleet-review-silent-failure**: a one-file `.yml` or `.github/` shell change runs fleet-review-correctness + fleet-review-silent-failure, which is the pair a swallowed error in CI needs. Above the size tier the no-source drop still stands, and `tests-only` outranks the size tier for a diff with no config file — a no-src, no-config diff that also touches a test file gets no fleet-review-silent-failure; a tests-only diff that also carries a config file keeps it. `single-file` is one file at *any* size. Profile unknown → the full six, the safe direction. Pin a subset explicitly with `args.dimensions` (keys or dimension objects). Dispatching by hand instead of automatically: apply the same heuristic yourself — two or three for annotation-only or single-file, the full six for production code.
|
|
104
106
|
|
|
@@ -109,5 +111,5 @@ Tell readers **`git show <sha>:<path>` is the source of truth** — the object s
|
|
|
109
111
|
- **Verify, don't reason.** "Removing X makes this compile/fail" → compile it in an isolated copy. One command. Four successive confident claims about one file were all wrong; the compiler settled it.
|
|
110
112
|
- **Distrust negative claims hardest.** "Nothing else references this", "the sweep is clean" — most likely false, least likely checked: a grep that found nothing looks like a grep never run. Make the specialist state its search scope. Negative claim vs specific finding with paths → paths win.
|
|
111
113
|
- **Mutation-verify any "this test pins X".** Apply the mutation, confirm *that* test fails — a valid red, and a kill only against the green run on the unmutated tree, as step 2's refuter rules define them — revert. Then one it should **not** catch, staying green — else you proved it fails, not that it discriminates. **One syntactic form is not the class:** a stripper killing `// whole-line` passed a guard that `code; // trailing` walked through.
|
|
112
|
-
- **Comments are findings**, and the most common one. A comment asserting what the code does not do is a defect.
|
|
114
|
+
- **Comments are findings**, and the most common one. A comment asserting what the code does not do is a defect. Check every added assertion against the tree — **including comments in files this diff does not touch** but whose claims it falsifies (test-name references, "N of 3" counts, tracking-issue pointers).
|
|
113
115
|
- **A finding on a PR body or a commit body** names that surface in its `claim` ("PR body:", or "commit <sha>:") and carries no `file` and no `line`, so `dispositions-check.mjs` presumes it in scope. A false claim in the PR body is corrected there, by editing it with `gh pr edit`. **A commit body cannot be rewritten** — never rewrite history to correct one: correct a false commit-body claim in the PR body instead, say there what the change really does, and that counts as applying the finding. The finding still stands as the review's record: correcting the claim does not withdraw the finding.
|
package/package.json
CHANGED
package/scripts/evict.mjs
CHANGED
|
@@ -89,9 +89,9 @@
|
|
|
89
89
|
// run. Prints
|
|
90
90
|
// `{"applied","worktree","install"}`; exit 0 restored (or would), 2 refused.
|
|
91
91
|
//
|
|
92
|
-
// That install sequence is `installIn()`, exported: finisher-tree.mjs
|
|
93
|
-
// same read, the same checks and the same words in
|
|
94
|
-
//
|
|
92
|
+
// That install sequence is `installIn()`, exported: finisher-tree.mjs and
|
|
93
|
+
// measure-copy.mjs run the same read, the same checks and the same words in
|
|
94
|
+
// the tree they build, so there is one copy of it.
|
|
95
95
|
|
|
96
96
|
import { spawnSync } from "node:child_process";
|
|
97
97
|
import { readFileSync, realpathSync, statSync, unlinkSync, writeFileSync } from "node:fs";
|
|
@@ -418,15 +418,23 @@ function sweep({ afterRotate, apply }) {
|
|
|
418
418
|
* called with `apply` set, after every check ahead of the Install step has
|
|
419
419
|
* passed and just before it starts; it returns null, or the message of a
|
|
420
420
|
* refusal, which then keeps the Install step from running. `install` is null in
|
|
421
|
-
* a refusal that came before the command was read.
|
|
421
|
+
* a refusal that came before the command was read. `source` is the tree the
|
|
422
|
+
* Install step is read from, `tree` itself by default: a copy holds no Recipe
|
|
423
|
+
* cache of its own, so its caller names the worktree whose cache every
|
|
424
|
+
* worktree of the repository shares. `untracked`, set, makes an Install step
|
|
425
|
+
* that leaves untracked paths no refusal: the result is then `{install,
|
|
426
|
+
* untracked: {count, first}}`, `first` the first 20 lines of `git status
|
|
427
|
+
* --porcelain -uall` and `count` how many there are; a tracked file the step
|
|
428
|
+
* changed is still `dirtied`, and a status that cannot be read after the step
|
|
429
|
+
* is still `status-after`. Nothing here writes a mark
|
|
422
430
|
* or a restore time, and it never exits the process.
|
|
423
431
|
*/
|
|
424
|
-
export function installIn(tree, apply, { verb = "restore", retry = true, beforeRun = () => null } = {}) {
|
|
432
|
+
export function installIn(tree, apply, { verb = "restore", retry = true, beforeRun = () => null, source = tree, untracked = false } = {}) {
|
|
425
433
|
const refuse = (kind, message, install = null, exit = null) => ({ refusal: { kind, message, install, exit } });
|
|
426
|
-
const derived = run("sh", [join(SCRIPT_DIR, "derive-testcmd.sh"),
|
|
434
|
+
const derived = run("sh", [join(SCRIPT_DIR, "derive-testcmd.sh"), source, "install", "--at", "origin/main"]);
|
|
427
435
|
const install = String(derived.stdout ?? "").replace(/\n$/, "");
|
|
428
436
|
if (derived.error || derived.status !== 0 || install === "") {
|
|
429
|
-
return refuse("derive", String(derived.stderr ?? "").trim() || `derive-testcmd.sh ${
|
|
437
|
+
return refuse("derive", String(derived.stderr ?? "").trim() || `derive-testcmd.sh ${source} install failed (${how(derived)})`);
|
|
430
438
|
}
|
|
431
439
|
// Dirty before anything runs is no Install step's doing: said in its own
|
|
432
440
|
// words, so the dirty-after refusal below never blames the Recipe for it.
|
|
@@ -450,6 +458,14 @@ export function installIn(tree, apply, { verb = "restore", retry = true, beforeR
|
|
|
450
458
|
if (r.status !== 0) return refuse("failed", `install failed in ${tree} (exit ${r.status})`, install, r.status);
|
|
451
459
|
const status = git(tree, ["status", "--porcelain", "-uall"]);
|
|
452
460
|
if (status.error || status.status !== 0) return refuse("status-after", `could not verify the tree state in ${tree} after the Install step`, install, 0);
|
|
461
|
+
if (untracked) {
|
|
462
|
+
const lines = status.stdout.split("\n").filter((l) => l !== "");
|
|
463
|
+
// An untracked path is reported; a tracked file the step changed leaves
|
|
464
|
+
// a tree that is no longer the one the step was run in.
|
|
465
|
+
const changed = lines.find((l) => !l.startsWith("?? "));
|
|
466
|
+
if (changed === undefined) return { install, untracked: { count: lines.length, first: lines.slice(0, 20) } };
|
|
467
|
+
return refuse("dirtied", `the Install step '${install}' changed a tracked file in ${tree} (first: ${changed}) — ${REDERIVE}`, install, 0);
|
|
468
|
+
}
|
|
453
469
|
if (status.stdout !== "") return refuse("dirtied", `the Install step '${install}' changed the tree in ${tree} (first: ${status.stdout.split("\n")[0]}) — ${REDERIVE}`, install, 0);
|
|
454
470
|
return { install };
|
|
455
471
|
}
|
package/scripts/fleet-event.mjs
CHANGED
|
@@ -97,12 +97,14 @@
|
|
|
97
97
|
// The reap and the reclaim run once for every merge bot settled `done`, always, even when the pass merged nothing, and again on the next tick after an `APPLY FAILED` line, and on every tick while this run has no controller record to remember the pass by.
|
|
98
98
|
// The bot may also have written `conflict-hold:#<pr>` onto a held PR's own row earlier in the same pass, before reporting: a token the bot wrote in that pass, never one `reap.sh` writes.
|
|
99
99
|
// review-result <pr> <path>
|
|
100
|
-
//
|
|
100
|
+
// `ledger.mjs review <pr> --result <path> --scratch <scratch>`: the
|
|
101
|
+
// ledger derives `reviewed=<head>:<survived>/<refuted>/<unverified>:<run>`
|
|
102
|
+
// from the review result file at `<path>`, which must be
|
|
101
103
|
// `<scratch>/pr<pr>/<run>/<file>`, `<run>` a review run root
|
|
102
|
-
// (`run-` and eight characters) and no `..` segment
|
|
103
|
-
// `counts`
|
|
104
|
-
//
|
|
105
|
-
//
|
|
104
|
+
// (`run-` and eight characters) and no `..` segment, a `pr` it carries
|
|
105
|
+
// this PR and its `head` and `counts` naming a token. A token the PR's
|
|
106
|
+
// rows already carry is not written again. A refusal is the ledger's,
|
|
107
|
+
// passed through, nothing written.
|
|
106
108
|
// The result file is `<scratch>/pr<pr>/<run>/review.json`, `<run>` the review's own `run-XXXXXXXX` run root.
|
|
107
109
|
// review-failed <pr> <launch>
|
|
108
110
|
// `ledger.mjs review <pr> review=<launch>=failed`, `<launch>` as the
|
|
@@ -219,8 +221,8 @@
|
|
|
219
221
|
// Zero deps: node builtins and sibling scripts only.
|
|
220
222
|
|
|
221
223
|
import { spawnSync } from "node:child_process";
|
|
222
|
-
import { readdirSync, readFileSync
|
|
223
|
-
import {
|
|
224
|
+
import { readdirSync, readFileSync } from "node:fs";
|
|
225
|
+
import { dirname, join, resolve } from "node:path";
|
|
224
226
|
import { fileURLToPath } from "node:url";
|
|
225
227
|
import { makeDie, defineFlags, isDigits, writeAll } from "./arg.mjs";
|
|
226
228
|
import { FleetDirUnresolvable, fleetFile } from "./fleet-dir.mjs";
|
|
@@ -868,47 +870,23 @@ function park(ev, member, pr, reason) {
|
|
|
868
870
|
ev.token(pr, tok);
|
|
869
871
|
}
|
|
870
872
|
|
|
871
|
-
//
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
return realpathSync(p);
|
|
875
|
-
} catch {
|
|
876
|
-
return p;
|
|
877
|
-
}
|
|
878
|
-
}
|
|
879
|
-
|
|
880
|
-
// The run name of a review result file at `path` in PR `pr`'s partition of
|
|
881
|
-
// `scratch`, or die naming why it is not one.
|
|
882
|
-
function reviewRun(scratch, pr, path) {
|
|
883
|
-
if (path.split("/").includes("..")) die(`review-result: ${path} has a ".." segment — pass the result file's path without one`);
|
|
884
|
-
const file = resolve(path);
|
|
885
|
-
const runRoot = dirname(file);
|
|
886
|
-
const partition = join(normalize(scratch), `pr${pr}`);
|
|
887
|
-
if (real(dirname(runRoot)) !== real(partition)) die(`review-result: ${file} is not under PR #${pr}'s partition ${partition}/ — nothing written`);
|
|
888
|
-
const run = basename(runRoot);
|
|
889
|
-
if (!/^run-[A-Za-z0-9]{8}$/.test(run)) die(`review-result: ${runRoot} is not a review run root (run- and eight characters) — nothing written`);
|
|
890
|
-
return { file, run };
|
|
891
|
-
}
|
|
892
|
-
|
|
873
|
+
// The review result file at `path` goes to `ledger.mjs review <pr> --result`,
|
|
874
|
+
// which owns every check of the path and the file and derives the `reviewed=`
|
|
875
|
+
// token from it; a token the PR's rows already carry comes back unwritten.
|
|
893
876
|
function reviewResult(ev, pr, path) {
|
|
894
|
-
const
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
result = JSON.parse(readFileSync(file, "utf8"));
|
|
898
|
-
} catch (e) {
|
|
899
|
-
die(`review-result: cannot read ${file}: ${e.code ?? e.message} — nothing written`);
|
|
900
|
-
}
|
|
901
|
-
if (result?.pr !== undefined && Number(result.pr) !== pr) die(`review-result: ${file} is PR #${result.pr}'s review, not #${pr}'s — nothing written`);
|
|
902
|
-
const { survived, refuted, unverified } = result?.counts ?? {};
|
|
903
|
-
const token = `reviewed=${result?.head}:${survived}/${refuted}/${unverified}:${run}`;
|
|
904
|
-
if (!REVIEWED.test(token)) die(`review-result: ${file} carries no head and counts a reviewed= token can name (${token}) — nothing written`);
|
|
905
|
-
if (prWords(ev.ledger, pr).includes(token)) {
|
|
906
|
-
ev.note(`PR #${pr} already ${token}`);
|
|
877
|
+
const r = node("ledger.mjs", ["review", String(pr), "--result", path, "--scratch", ev.scratch]);
|
|
878
|
+
if (r.status !== 0) {
|
|
879
|
+
ev.refuse(`review #${pr} --result ${path}`, r);
|
|
907
880
|
return;
|
|
908
881
|
}
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
882
|
+
let receipt = {};
|
|
883
|
+
try {
|
|
884
|
+
receipt = JSON.parse(r.stdout);
|
|
885
|
+
} catch {
|
|
886
|
+
// The ledger answered 0, so the write is settled; only its token is unread.
|
|
887
|
+
}
|
|
888
|
+
const token = typeof receipt.reviewed === "string" ? receipt.reviewed : `the result at ${path}`;
|
|
889
|
+
ev.note(receipt.written === false ? `PR #${pr} already ${token}` : `PR #${pr} ${token}`);
|
|
912
890
|
}
|
|
913
891
|
|
|
914
892
|
function reviewFailed(ev, pr, launch) {
|
package/scripts/fleet-state.mjs
CHANGED
|
@@ -44,16 +44,18 @@
|
|
|
44
44
|
// never when. Pruned to the live set on every tick, so a settled
|
|
45
45
|
// member's stamp does not outlive it. Carried, never written, by
|
|
46
46
|
// the heartbeat and by ledger.mjs.
|
|
47
|
-
// applied fleet-tick only, and only under --apply. {run, reapAfter
|
|
48
|
-
// merge-bot numbers whose `merge-bot-<n>=done` the
|
|
49
|
-
// run reap.sh, reclaim-scratch.mjs and evict.mjs
|
|
50
|
-
//
|
|
51
|
-
//
|
|
52
|
-
//
|
|
53
|
-
//
|
|
54
|
-
//
|
|
55
|
-
//
|
|
56
|
-
//
|
|
47
|
+
// applied fleet-tick only, and only under --apply. {run, reapAfter,
|
|
48
|
+
// sweptAfter}: the merge-bot numbers whose `merge-bot-<n>=done` the
|
|
49
|
+
// tick has already run reap.sh, reclaim-scratch.mjs and evict.mjs
|
|
50
|
+
// after (`reapAfter`), the fix-applier, finisher and failed review
|
|
51
|
+
// launch names whose settle it has already run reclaim-scratch.mjs
|
|
52
|
+
// after (`sweptAfter`, left out while empty), and the controller
|
|
53
|
+
// record's `at` they belong to. Written only under a record: with none, nothing tells
|
|
54
|
+
// one run from the next. Merge-bot numbering restarts at 1 in a run
|
|
55
|
+
// that carries no bot forward, and this file outlives the rotation,
|
|
56
|
+
// so a list whose `run` is not the current record's `at` is the
|
|
57
|
+
// previous run's and names nothing in this one. Carried, never
|
|
58
|
+
// written, by the heartbeat and by ledger.mjs.
|
|
57
59
|
//
|
|
58
60
|
// One writer per key. A key two scripts wrote would need locking to be
|
|
59
61
|
// correct, and none of them is in a position to hold one. That holds per key,
|
|
@@ -256,7 +258,8 @@ export function readState(path, name, warn = console.error) {
|
|
|
256
258
|
const done = (v) => {
|
|
257
259
|
if (!isRecord(v) || !Array.isArray(v.reapAfter)) return null;
|
|
258
260
|
if (!(Number.isInteger(v.run) && v.run > 0)) return null;
|
|
259
|
-
|
|
261
|
+
const swept = Array.isArray(v.sweptAfter) ? v.sweptAfter.filter((m) => typeof m === "string" && m !== "") : [];
|
|
262
|
+
return { run: v.run, reapAfter: v.reapAfter.filter((n) => Number.isInteger(n) && n > 0), ...(swept.length > 0 ? { sweptAfter: swept } : {}) };
|
|
260
263
|
};
|
|
261
264
|
const { quiet, digest, beat, ticked, acted, controller, seen, applied, ...rest } = parsed;
|
|
262
265
|
// A controller key that ctl() rejects is a record someone wrote and nobody
|