@feigi/fleet-ctl 3.26.0 → 3.28.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/commands/review-and-fix.md +1 -0
- package/package.json +1 -1
- package/scripts/dispositions-check.mjs +48 -24
- package/scripts/inflight.sh +59 -281
- package/scripts/net.sh +2 -2
- package/scripts/no-undo-audit.sh +27 -27
- package/scripts/reap.sh +49 -227
- package/scripts/release-ticket.sh +92 -428
- package/scripts/worktree.sh +498 -1
- package/skills/run-team/references/reaping.md +1 -1
|
@@ -13,6 +13,7 @@ argument-hint: [pr-number]
|
|
|
13
13
|
3. **Run `testCmd` before you commit**, from the worktree, copied verbatim — not a runner you picked. `testCmd` is the command your dispatcher handed you; **standalone, with no dispatcher to hand you one, it is the repo's own test command**, the Test entrypoint in the repo's Recipe cache (`derive-testcmd.sh <repo> test` prints it). Read it off the repo, never invent one: "not a runner you picked" is what this step forbids, and on the standalone path nothing else defines the referent. With no usable Recipe cache (`derive-testcmd.sh` refuses), 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 both commands in a throwaway worktree and writes the cache only on proof, and its `RECIPE NOT PROVEN` is a stop, reported with its reason. 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. The number drifts; that is the safe direction, because a stale one produces a loud false red while its absence produces a silent false green. Red, zero-test, or either no-work count → fix it or move the finding to defer; never commit over it. Then commit and push — `git push origin HEAD:<branch>`, the explicit refspec: 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`) and 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 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. Measured twice in one run — one body kept asserting a calibration its own fix had just deleted as false, another kept claiming a hunk the fix had removed as "this diff owns it" — both caught by a finisher's reading rather than by any rule, and both would otherwise have merged intact. `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`.** 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 — 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.
|
|
14
14
|
4. **Under the fleet, do not hold this wait.** The controller owns a persistent CI Monitor and dispatches a finisher once your report has arrived and CI is green — so push, then report to the controller a **final verdict** (every specialist you dispatched + its outcome + your apply/defer adjudication + the pushed SHA) and stop. A specialist that has neither reported nor been relayed to you is not a verdict line — ask the controller for it by name before ruling; see **Specialists**. The controller keys "review complete" on that verdict, **never on you merely going idle** — a slow specialist can still be running when your turn ends, and finishing off idle-alone ships a premature label (observed: a PR labelled while its contract-test specialist was still running and about to surface a vacuous pin). A turn-based reviewer re-reading `gh pr checks` each idle cycle rebuilds its whole context for nothing the Monitor lacks. **Standalone (no controller): watch** the run until the diff-validating jobs are green (bind via `ci-state.mjs` below); fix a **genuine** failure and repeat from 3. **Staleness is not a failure:** a `rebase-check` red or heavy jobs `skipped` **solely from a non-zero behind-count** never clears by waiting and must not be rebased away here — see **`skipped` is not `passed`** and **Do NOT rebase to label** below for what it looks like and why. Stop watching and go to 6. A turn-based reviewer that "waits for green" on a behind PR stalls forever and ends its turn without labelling. **`ci-state.mjs` returns `verdict: "no-ci"`** → there is no run to watch, so don't: go straight to 6 and let that step's `--declare-no-ci` branch decide.
|
|
15
15
|
5. File each deferred finding: `gh issue create --label <ready-for-agent|needs-triage>` with the finding, `file:line`, why deferred, `Deferred from PR #<pr> review`, and **the finding's `dimension` in the issue body** — the review returns it on every finding, and a backlog that does not carry it cannot be attributed to the specialist that generated it. **The label follows the finding's state, not this step** — but it is never omitted; an unlabelled issue is invisible to both `candidates.mjs --require-label` and the cockpit's pool query, reachable only by a human. **The bar here is whether the DEFECT is confirmed — never whether the remedy is settled.** Confirmed defect with the remedy still open → `ready-for-agent`, and say in the body that the remedy is open. Torn → `needs-triage`, narrowed: torn means **unsure anything is broken**, not unsure how to fix it. **A finding a refuter CHECKED and did not survive is neither** — it is not a confirmed defect, and you are not unsure whether anything is broken: you measured that nothing is. Refutations go as **one issue per review, titled `PR #<pr> review: the suggestion band, checked`, labelled `wontfix`, and CLOSED** — a run that files them open instead has to be corrected afterwards, as one was on 2026-08-27. Left open they read as queued agent work and rot into filing artifacts; a measured triage pass found a quarter of its `needs-triage` backlog was refuted records, bulk-closable by title shape. Closed is still a durable home — `check` reads the tracker at `--state all`, so a future run re-deriving the finding lands on the evidence rather than re-litigating it. Split the band only where an entry is **not** a refutation: a residual the refuter surfaced, or a finding refused as out of scope and never checked, is real deferred work — and real deferred work earns its own open issue only past a second bar. **Worth a claim: a finding whose own claim is that correct code could be shaped better — style, naming, layout, redundancy, a micro-simplification — never gets its own open issue.** Its only open question is "is this worth doing?", which answers itself under the repriced triage bar: measured 2026-08-15→31, 133 issues were triage-closed `wontfix` in sixteen days, 121 of them review deferrals, mostly this shape. Append it to the same closed record issue under a `Below the claim bar` heading — `file:line`, dimension, the claim, and a re-open trigger per entry. Closed is a durable home for these too: `check` reads `--state all`, so a run re-deriving the finding lands on the record instead of re-filing — and a later review returning the same finding as `survived`, or a maintainer hitting it, is the promotion signal: file it open then, citing the record. **An in-scope rediscovery step 2 applied is that same promotion signal, and it files nothing** — so the record carries no mark unless you write one: run `check` over each finding step 2 applied as well, and where its tracker rows put one on a `Below the claim bar` entry, comment on that record issue, opening `Promoted — applied, not filed`, and name the entry, that its refuter let it through, and the commit carrying the fix. That comment is the promotion mark this path leaves, and it is **not** a cross-reference — measured on this tracker, a comment mints `cross-referenced` on the issue its own text *names*, never on the issue it sits under (a comment citing a second issue landed on that issue's timeline and nowhere else), so the fixed opening is what carries the signal instead. **The bar reads the finding's claim, never its review band** — a finding that alleges wrong behavior, whatever band it sat in, `unverified`-with-crashed-refuters included, is above this bar and files open under the confirmed/torn split, which is why a band cannot carry this decision. Do **not** reach for phase 0's **decided?** test here. That is a *consumption* gate, priced for a seat where implementer divergence costs a claim, a worktree and a dispatch; at filing time divergence costs one PR review the maintainer already runs. Same test, two seats, opposite correct answers — and reading it in this seat took `needs-triage` from 11 to 135 before it was repriced (ruled 2026-08-18). **Dedupe through `~/.fleet/bin/fleet-run ledger.mjs check "<subject>"`, never a bare `gh issue list --search`** — the duplicate class that guard exists to catch was filed from *here*: the ledger row for the finding rediscovered five times in one measured run carries a reviewer's own source tag, `(review-pr-108)`. `check` reads this run's filed list *and* the tracker at `--state all`, so a closed duplicate still counts. Exit **1** is already filed in this run; exit **3** is a clean ledger with matching tracker rows that score against the subject — read the ones it prints and comment on the existing follow-up rather than filing a second issue. **Exit 0 is not automatically "safe to file"**: it covers `clean`, `soft-hit` and `unverified` alike, and an unreachable `gh` degrades to a ledger-only answer that says `TRACKER NOT CHECKED`, so read the stdout `verdict` to tell a tracker that was searched and clean from one nobody read — under `unverified`, search it yourself before filing — or, for the applied-promotion comment above, before treating a tracker nobody could read as a reason to skip it. **`soft-hit` is the answer that costs most to misread**: it means related rows were found and none of them was established as a duplicate — a near-miss above the floor, or tracker rows the scorer rates 0.00 — so read the rows it printed and decide, and never treat that exit 0 as permission. Exit **2** is a usage error, meaning nothing was checked at all: fix the invocation and re-run, never read it as a duplicate. Full exit-code and `verdict` semantics live in `$(~/.fleet/bin/fleet-run --root)/skills/run-team/SKILL.md`'s **Run ledger** section — read them there rather than restating them here. **The guard dedupes, it never drops:** a duplicate becomes a comment on the issue that already covers it, never a dropped finding. **Record every issue you create, at once:** immediately after each `gh issue create`, run `~/.fleet/bin/fleet-run ledger.mjs filed <N> "<subject>"` — `<N>` the number `gh issue create` printed, and **the same subject string you passed to `check`**, so the next `check` for that finding meets it in the filed list instead of scoring a rewording. Without it the guard's ledger half never holds a row, and its exit **1** can never fire. If `filed` fails, retry it once; if it fails again, leave the issue alone — it exists and is correct — and report it as `unrecorded: #N <subject>`, so the controller runs `filed` for it. Report `filed: #N <subject>` for every issue you created — under the fleet, in your report to the controller. **The one window the guard cannot see:** `check` → `gh issue create` → `filed` is three commands, and the ledger's lock covers each alone, so two filers can both read `clean` in the seconds before either records. That gap is accepted, never a reason to skip `filed`. Post the numbers as one PR comment.
|
|
16
|
+
**A duplicate that should hold an open deferral is relabelled up, never down.** Where the guard lands a finding whose home is an open issue on an existing one that is open and labelled `needs-triage` while the finding's state calls for `ready-for-agent` — a defect its refuters confirmed — relabel it with `gh issue edit <N> --remove-label needs-triage --add-label ready-for-agent`, and cite the refuters' verdict in the comment you leave there. Never relabel `ready-for-agent` down to `needs-triage`: a `ready-for-agent` issue already holds a `needs-triage` finding, and a later run's crashed refuters are no reason to send a confirmed defect back to triage. A closed one cannot hold it: file a new open issue citing it, as the promotion rule above does for the closed record.
|
|
16
17
|
**Name where each deferral went, in the disposition record.** Every entry you defer carries `issue`: the number of the issue you filed it to, commented it onto, or appended it to — the closed `PR #<pr> review: the suggestion band, checked` record included. An in-scope `suggestion`'s entry — an `unverified` finding with `refutersDispatched` of zero — also carries `verdictPath`, applied or deferred: the absolute path of a file holding its refuter's verdict as JSON, `{"refuted": <boolean>, "reason": "<string>"}`, under your own `<scratch>/pr<N>/fix-XXXXXXXX/<finding>/` run root. `dispositions-check.mjs` reads each named issue back through `gh issue view --json labels,state,title` and each verdict file off disk; a mismatch names the row of its filing table the entry broke, so move or relabel that filing to the home the row names and run the check again. With `gh` unreachable, or an issue it cannot read, that filing goes unchecked: with nothing else broken the verdict is `unchecked` — never `ok`, and it exits 1 — so run the check again once `gh` answers.
|
|
17
18
|
6. Diff-check green (run-bound per `ci-state.mjs`; under staleness see **`skipped` is not `passed`** for what the label then rests on) **and** deferrals filed **and** the PR carrying exactly one release label (`patch`/`minor`/`major`, counting only those three; **required on every PR** — `release-label.yml` auto-adds `patch` when none is present and hard-fails on more than one, so this never needs to check whether the repo defines the gate at all, and `gh label list` settles nothing here any more) **and** `dispositions-check.mjs --member fix-pr-<pr> --scratch <scratch>` run over your own record exiting 0 (standalone that is yours to run, from the worktree, after step 2 writes `<scratch>/dispositions-<pr>.json`; it reads the review file beside it, which you write yourself from the findings step 1 collected, in the shape **The review result file** describes — `pr`, `head`, `snapshot`, `counts` and the `survived`, `refuted` and `unverified` buckets; standalone you pass `--no-ledger`, so it writes no token and the exit status is the verdict — a `.fleet/ledger.md` the repository already holds is a previous run's, and without the flag it exits 2 for a ledger with no row for you; under the fleet `ledger.mjs dispatch` has already refused a finisher without it) → `gh pr edit <pr> --add-label ready-to-merge`. Do not merge. A non-zero dispositions exit halts you before the label, and you report the violations it printed. Zero or more than one release label halts you before the label, naming which you found — a timed-out `gh pr create` opens the PR with its `--label` unapplied and no exit status to react to, and nothing after this step re-derives the release label. **Under the fleet a finisher does this** — a fresh small agent the controller dispatches (after your final verdict, never on your bare idle). Gate it on the diff-validating **`check`** job, **not** on `ci-state --quiet` exit 0, which a behind PR — the normal case once any sibling merges — never reaches: a `rebase-check` red or heavy jobs `skipped` off the behind-count hold it short of full green, so an exit-0 gate strands every behind PR unlabelled. Label when `check` is present and green **and no heavy job (the diff-validating suites — *not* the `rebase-check` currency gate) is in `failure`** — a `skipped` heavy job is behind-count staleness and fine — **solely** off that count, which is a condition to establish rather than infer, see the five-condition note in `$(~/.fleet/bin/fleet-run --root)/skills/run-team/SKILL.md`'s fix-applier prompt block. A `failure` is the diff's own fault and blocks the label, else a genuinely broken PR gets labelled off a green `check` and burns a merge-bot rebase+CI cycle before the failure resurfaces. Read per-job state for this: run `ci-state.mjs` **without** `--quiet`, or read its `jobs` — the `--quiet` payload drops the per-job `jobs`/`missing` and the `dropped` list, keeping `reasons` (which still distinguishes `is failure` from `is skipped`). You reach step 6 yourself only when green is already in hand at push time.
|
|
18
19
|
|
package/package.json
CHANGED
|
@@ -79,24 +79,28 @@
|
|
|
79
79
|
// mismatch names the row the entry broke:
|
|
80
80
|
//
|
|
81
81
|
// row finding home
|
|
82
|
-
// 1 survived, deferred for an allowed
|
|
83
|
-
// than false-rationale
|
|
84
|
-
// 2 survived, deferred false-rationale
|
|
82
|
+
// 1 survived, in scope, deferred for an allowed open, ready-for-agent
|
|
83
|
+
// reason other than false-rationale
|
|
84
|
+
// 2 survived, in scope, deferred false-rationale closed suggestion-band record
|
|
85
85
|
// 3 unverified, its refuters dispatched and crashed open, needs-triage
|
|
86
86
|
// 4 in-scope suggestion, its refuter refuted it closed suggestion-band record
|
|
87
87
|
// 5 in-scope suggestion, its refuter let it survive applied, or deferred as row 1
|
|
88
88
|
// 6 out-of-scope suggestion alleging wrong behavior open, needs-triage
|
|
89
89
|
// 7 claimKind shape, below the claim bar closed suggestion-band record
|
|
90
|
+
// 8 survived, out of scope, whatever its reason open, ready-for-agent
|
|
90
91
|
//
|
|
91
92
|
// Row 4 outranks row 7, and row 7 every other row. A row-5 deferral is
|
|
92
93
|
// held to row 1's reasons: one of ALLOWED_DEFER other than
|
|
93
|
-
// false-rationale, `remedy-outside-diff` under the rule above.
|
|
94
|
-
//
|
|
95
|
-
//
|
|
96
|
-
//
|
|
97
|
-
//
|
|
98
|
-
//
|
|
99
|
-
//
|
|
94
|
+
// false-rationale, `remedy-outside-diff` under the rule above. A row-8
|
|
95
|
+
// deferral is held to no reason and escalates nothing, whatever its
|
|
96
|
+
// severity. An open home carries exactly one triage label, its row's or
|
|
97
|
+
// a stronger one: `ready-for-agent` answers a `needs-triage` row, and
|
|
98
|
+
// `needs-triage` never answers a `ready-for-agent` one. The closed
|
|
99
|
+
// suggestion-band record is the closed issue titled `PR #<pr> review:
|
|
100
|
+
// the suggestion band, checked`, labelled `wontfix`. `claimKind` is
|
|
101
|
+
// trusted: the script never judges whether a claim is about shape. A
|
|
102
|
+
// deferral no row holds — a reversed refutation whose claim is about
|
|
103
|
+
// behavior — is a mismatch naming no filing-table row.
|
|
100
104
|
//
|
|
101
105
|
// Unchecked: `gh` unreachable, or a deferral's issue it cannot read, leaves
|
|
102
106
|
// that entry's filing unjudged. With no rule broken and nothing escalated the
|
|
@@ -151,29 +155,47 @@ const BUCKETS = [...COVERED, "refuted"];
|
|
|
151
155
|
const ENUMS = { scope: ["in", "out"], claimKind: ["behavior", "shape"], disposition: ["apply", "defer"] };
|
|
152
156
|
|
|
153
157
|
// The filing table: a deferral's home by its finding's state. `record` is the
|
|
154
|
-
// closed suggestion-band record; `open` the triage label an open home
|
|
158
|
+
// closed suggestion-band record; `open` the weakest triage label an open home may carry.
|
|
155
159
|
export const FILING_ROWS = Object.freeze({
|
|
156
|
-
1: { finding: "
|
|
157
|
-
2: { finding: "
|
|
160
|
+
1: { finding: "an in-scope survived finding deferred for an allowed reason other than false-rationale", open: "ready-for-agent" },
|
|
161
|
+
2: { finding: "an in-scope survived finding deferred false-rationale", record: true },
|
|
158
162
|
3: { finding: "an unverified finding whose refuters crashed", open: "needs-triage" },
|
|
159
163
|
4: { finding: "an in-scope suggestion its refuter refuted", record: true },
|
|
160
164
|
5: { finding: "an in-scope suggestion its refuter let survive", open: "ready-for-agent" },
|
|
161
165
|
6: { finding: "an out-of-scope suggestion alleging wrong behavior", open: "needs-triage" },
|
|
162
166
|
7: { finding: "a finding whose claim is about shape, below the claim bar", record: true },
|
|
167
|
+
8: { finding: "an out-of-scope survived finding, whatever its reason", open: "ready-for-agent" },
|
|
163
168
|
});
|
|
169
|
+
// Strongest first: an open home may carry a label above its row's, never below.
|
|
164
170
|
const TRIAGE_LABELS = ["ready-for-agent", "needs-triage"];
|
|
165
171
|
// Row 1's reasons, which a row-5 deferral is held to.
|
|
166
172
|
const ROW_1_DEFER = ALLOWED_DEFER.filter((r) => r !== "false-rationale");
|
|
167
173
|
export const recordTitle = (pr) => `PR #${pr} review: the suggestion band, checked`;
|
|
168
174
|
|
|
169
175
|
function homeText(row, pr) {
|
|
170
|
-
|
|
176
|
+
if (row.record) return `the closed "${recordTitle(pr)}" issue, labelled wontfix`;
|
|
177
|
+
return `an open issue labelled ${TRIAGE_LABELS.slice(0, TRIAGE_LABELS.indexOf(row.open) + 1).reverse().join(" or ")}`;
|
|
171
178
|
}
|
|
172
179
|
|
|
173
180
|
// Whether an issue `{state, title, labels}` is `row`'s home on PR `pr`.
|
|
174
181
|
function homeHolds(row, { state, title, labels }, pr) {
|
|
175
182
|
if (row.record) return state === "CLOSED" && title.trim() === recordTitle(pr) && labels.includes("wontfix");
|
|
176
|
-
|
|
183
|
+
const triage = labels.filter((l) => TRIAGE_LABELS.includes(l));
|
|
184
|
+
return state === "OPEN" && triage.length === 1 && TRIAGE_LABELS.indexOf(triage[0]) <= TRIAGE_LABELS.indexOf(row.open);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// The row a deferral's finding state puts it on, by precedence, or null when
|
|
188
|
+
// no row holds it: only a reversed refutation (the refuted bucket) whose claim
|
|
189
|
+
// is not about shape. `refuted` is an in-scope suggestion's refuter verdict,
|
|
190
|
+
// null for any other finding.
|
|
191
|
+
function filingRow({ bucket, inScope, crashed, refuted, shape, reason }) {
|
|
192
|
+
if (refuted === true) return 4;
|
|
193
|
+
if (shape) return 7;
|
|
194
|
+
if (bucket === "refuted") return null;
|
|
195
|
+
if (crashed) return 3;
|
|
196
|
+
if (!inScope) return bucket === "survived" ? 8 : 6;
|
|
197
|
+
if (bucket === "unverified") return 5;
|
|
198
|
+
return reason === "false-rationale" ? 2 : 1;
|
|
177
199
|
}
|
|
178
200
|
|
|
179
201
|
function describeIssue({ state, title, labels }) {
|
|
@@ -402,15 +424,14 @@ export function checkDispositions({ review, record, recordProblem = null, touche
|
|
|
402
424
|
at(bucket, index, `malformed entry — ${errors.join("; ")}`);
|
|
403
425
|
return;
|
|
404
426
|
}
|
|
405
|
-
if (bucket === "refuted") {
|
|
406
|
-
|
|
427
|
+
if (bucket === "refuted" && !e.reason?.trim()) {
|
|
428
|
+
at(bucket, index, "a reversed refutation names its evidence in reason, and this one names none");
|
|
407
429
|
return;
|
|
408
430
|
}
|
|
409
|
-
if (bucket
|
|
431
|
+
if (bucket !== "unverified" && e.disposition !== "defer") return;
|
|
410
432
|
const finding = review[bucket][index];
|
|
411
433
|
const presumed = presumedInScope(finding, touched, roots);
|
|
412
434
|
const inScope = presumed !== null || e.scope === "in";
|
|
413
|
-
if (bucket === "survived" && !inScope) return;
|
|
414
435
|
const why = presumed === null ? "its entry declares scope in" : `${presumed}, so it is in scope whatever its entry declares`;
|
|
415
436
|
const crashed = bucket === "unverified" && finding.refutersDispatched > 0;
|
|
416
437
|
// An in-scope suggestion's refuter verdict is the evidence a refuter ran.
|
|
@@ -435,8 +456,9 @@ export function checkDispositions({ review, record, recordProblem = null, touche
|
|
|
435
456
|
const shape = e.claimKind === "shape";
|
|
436
457
|
// A finding that stands defers only for a reason: an in-scope survivor
|
|
437
458
|
// for one of ALLOWED_DEFER, a suggestion its refuter let through for one
|
|
438
|
-
// of row 1's — unless row 7 takes it.
|
|
439
|
-
|
|
459
|
+
// of row 1's — unless row 7 takes it. An out-of-scope survivor defers for
|
|
460
|
+
// any reason, and escalates nothing.
|
|
461
|
+
if ((bucket === "survived" && inScope) || (refuted === false && !shape)) {
|
|
440
462
|
const allowed = bucket === "survived" ? ALLOWED_DEFER : ROW_1_DEFER;
|
|
441
463
|
if (!allowed.includes(e.reason)) {
|
|
442
464
|
const reason = e.reason === undefined || e.reason === "" ? "no reason" : `reason ${JSON.stringify(e.reason)}`;
|
|
@@ -460,9 +482,11 @@ export function checkDispositions({ review, record, recordProblem = null, touche
|
|
|
460
482
|
}
|
|
461
483
|
}
|
|
462
484
|
// Where the deferral must be filed. `claimKind` is trusted, never judged.
|
|
463
|
-
const rowNo =
|
|
464
|
-
|
|
465
|
-
|
|
485
|
+
const rowNo = filingRow({ bucket, inScope, crashed, refuted, shape, reason: e.reason });
|
|
486
|
+
if (rowNo === null) {
|
|
487
|
+
at(bucket, index, `no filing-table row holds a deferred ${bucket} finding, scope ${inScope ? "in" : "out"}, claimKind ${e.claimKind} — the table names no home for it`);
|
|
488
|
+
return;
|
|
489
|
+
}
|
|
466
490
|
const row = FILING_ROWS[rowNo];
|
|
467
491
|
const { pr, issue: readIssue } = filingOf();
|
|
468
492
|
if (e.issue === undefined) {
|
package/scripts/inflight.sh
CHANGED
|
@@ -135,6 +135,19 @@ net_lib="$(dirname "$0")/net.sh"
|
|
|
135
135
|
# shellcheck source=net.sh
|
|
136
136
|
. "$net_lib" || die "$net_lib failed to load"
|
|
137
137
|
|
|
138
|
+
# The worktree readers and the Registration probe. worktree.sh's header holds
|
|
139
|
+
# the sourcing contract and the measurements behind it, and json.sh's holds the
|
|
140
|
+
# `[ -r ]` reasoning all three guards share: exit 1 from this script means
|
|
141
|
+
# `taken`, so a library that merely went missing must refuse before the `.`
|
|
142
|
+
# can kill the shell. Below json.sh, so a lone copy of this script still blames
|
|
143
|
+
# json.sh, the name its missing-library test pins. The listing reader owns its
|
|
144
|
+
# own temp file, so it adds nothing to the EXIT trap below.
|
|
145
|
+
wt_lib="$(dirname "$0")/worktree.sh"
|
|
146
|
+
[ -r "$wt_lib" ] || die "cannot read $wt_lib — refusing to answer without the worktree readers"
|
|
147
|
+
# shellcheck source-path=SCRIPTDIR
|
|
148
|
+
# shellcheck source=worktree.sh
|
|
149
|
+
. "$wt_lib" || die "$wt_lib failed to load"
|
|
150
|
+
|
|
138
151
|
[ $# -eq 1 ] || die "usage: inflight.sh <issue-number>"
|
|
139
152
|
n=$1
|
|
140
153
|
case "$n" in ''|*[!0-9]*|0?*) die "issue must be a number, got '$n'";; esac
|
|
@@ -162,14 +175,13 @@ remote=""
|
|
|
162
175
|
local_b=""
|
|
163
176
|
wt=""
|
|
164
177
|
|
|
165
|
-
# The
|
|
178
|
+
# The temp files, and the ONE EXIT trap that removes them. `sh` keeps a
|
|
166
179
|
# single EXIT trap, so a second `trap … EXIT` further down does not add a
|
|
167
180
|
# handler — it REPLACES this one, silently leaking whatever the first was going
|
|
168
|
-
# to remove.
|
|
181
|
+
# to remove. Each is therefore declared here and cleaned here rather
|
|
169
182
|
# than each probe installing its own. Declared empty, too, so the trap can run
|
|
170
183
|
# under `set -u` after a `die` that fired before any was created.
|
|
171
184
|
errfile=""
|
|
172
|
-
wtfile=""
|
|
173
185
|
wdfile=""
|
|
174
186
|
# `${…:+}` so a file that was never created contributes no argument at all
|
|
175
187
|
# rather than an empty one, and `rm -f` with no operands is specified to exit 0.
|
|
@@ -186,8 +198,8 @@ wdfile=""
|
|
|
186
198
|
# in one. It returns 0 just as `echo` did, so the status argument above is
|
|
187
199
|
# unchanged. Format string double-quoted because the trap body is already
|
|
188
200
|
# single-quoted.
|
|
189
|
-
trap 'rm -f ${errfile:+"$errfile"} ${
|
|
190
|
-
printf "%s: could not remove %s %s
|
|
201
|
+
trap 'rm -f ${errfile:+"$errfile"} ${wdfile:+"$wdfile"} ||
|
|
202
|
+
printf "%s: could not remove %s %s\n" "$NAME" "$errfile" "$wdfile" >&2' EXIT
|
|
191
203
|
|
|
192
204
|
# Probe 1 — a PR that is actually ABOUT this ticket.
|
|
193
205
|
#
|
|
@@ -530,9 +542,10 @@ probe_remote || :
|
|
|
530
542
|
# admin dir, and both lookups below report nothing, at rc 0, for a ticket that
|
|
531
543
|
# has a live branch or worktree — the same wrong "free" this script exists to rule out,
|
|
532
544
|
# one probe down. Establish each storage was readable before trusting an empty
|
|
533
|
-
# result from it — the same rule
|
|
534
|
-
#
|
|
535
|
-
# must be established, never
|
|
545
|
+
# result from it — the same rule worktree.sh's `wt_count_registry` applies with
|
|
546
|
+
# its `-d`/`-r`/`-x` guard on `$wt_root`, the worktree registry this probe's
|
|
547
|
+
# worktree half reads through `wt_counts` — absence must be established, never
|
|
548
|
+
# inferred.
|
|
536
549
|
#
|
|
537
550
|
# Ceiling, left open on purpose: a single loose ref git skips as corrupt
|
|
538
551
|
# (`warning: ignoring broken ref refs/heads/x`, still rc 0) passes a
|
|
@@ -671,281 +684,46 @@ if [ -n "$local_b" ]; then
|
|
|
671
684
|
add_hit "local"
|
|
672
685
|
fi
|
|
673
686
|
|
|
674
|
-
# The worktree
|
|
675
|
-
#
|
|
676
|
-
#
|
|
677
|
-
# and
|
|
678
|
-
#
|
|
679
|
-
#
|
|
680
|
-
#
|
|
681
|
-
#
|
|
682
|
-
#
|
|
683
|
-
#
|
|
684
|
-
#
|
|
685
|
-
#
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
# through worktree.sh's `wt_listing`, this one through the single EXIT trap's
|
|
694
|
-
# `$wtfile` — a difference in plumbing, same as before. What is no longer true
|
|
695
|
-
# is that the recount ITSELF is: release-ticket.sh's copy is bounded at up
|
|
696
|
-
# to two recount passes (`recount_tries`) to close a residual third-mutation
|
|
697
|
-
# race window that this script's own still-single-pass recount does not
|
|
698
|
-
# close.
|
|
699
|
-
#
|
|
700
|
-
# A directory-level read+execute test alone is not enough
|
|
701
|
-
# here: naming a registry entry needs read+execute on the PARENT only, so a
|
|
702
|
-
# `gitdir` file chmod'd 000 INSIDE one entry passes every test on the entry
|
|
703
|
-
# itself while `worktree list --porcelain` still drops it, at rc 0
|
|
704
|
-
# (measured). Count registry entries on disk against what git reported instead —
|
|
705
|
-
# that catches a silent drop whichever file inside the entry was unreadable.
|
|
706
|
-
wtroot="$common/worktrees"
|
|
707
|
-
# A function because the count is taken twice — see the recount below. Absent
|
|
708
|
-
# entirely is fine and answers nothing here: a repo that never had a linked
|
|
709
|
-
# worktree has no registry directory at all, and that emptiness is real, not a
|
|
710
|
-
# permission problem.
|
|
711
|
-
count_registry() {
|
|
712
|
-
registered=0
|
|
713
|
-
[ -e "$wtroot" ] || return 0
|
|
714
|
-
[ -r "$wtroot" ] && [ -x "$wtroot" ] ||
|
|
715
|
-
{ add_unknown "local" "worktree registry $wtroot could not be read — whether #$n has a worktree is unknown"; return 1; }
|
|
716
|
-
for entry in "$wtroot"/*; do
|
|
717
|
-
[ -d "$entry" ] || continue
|
|
718
|
-
# Skip only an EMPTY directory. That is an operator's stray `mkdir`, which
|
|
719
|
-
# git ignores — and counting one fails this probe closed forever, on every
|
|
720
|
-
# ticket in the repo, over something git is right to ignore (measured: git
|
|
721
|
-
# lists 2, a bare `-d` count said 3). A stray FILE was already skipped by
|
|
722
|
-
# the `-d` above; a stray directory was not.
|
|
723
|
-
#
|
|
724
|
-
# Emptiness, NOT the absence of a `gitdir` file: git drops an entry whose
|
|
725
|
-
# `gitdir` was deleted, so keying the skip on that file over-skips into the
|
|
726
|
-
# wrong "free" spelled out below (measured: rc 0, `taken=false`). A corrupt
|
|
727
|
-
# entry still holds git's own files — commondir, HEAD, index, logs, refs —
|
|
728
|
-
# so emptiness separates it from a stray and the missing `gitdir` does not.
|
|
729
|
-
#
|
|
730
|
-
# `ls`'s STATUS, not just its output: an entry we could not LIST is not an
|
|
731
|
-
# empty one, and `2>/dev/null` hides the difference. An entry chmod'd 000
|
|
732
|
-
# (unsearchable) OR 0111 (searchable, so an `-x` test passes it, but not
|
|
733
|
-
# readable) fails EACCES and prints exactly what a stray `mkdir` prints.
|
|
734
|
-
# Over-skip on the missing `gitdir` or on the output alone, and git has
|
|
735
|
-
# dropped the entry too, so the counts AGREE (measured: 2 listed, then 1,
|
|
736
|
-
# and an output-only skip counts 0 to match), no mismatch fires, and the
|
|
737
|
-
# probe answers `taken=false` for a ticket whose checkout is still on disk.
|
|
738
|
-
# Could not read it, so we cannot tell → count it and let the mismatch
|
|
739
|
-
# below fire.
|
|
740
|
-
if contents=$(ls -A "$entry" 2>/dev/null) && [ -z "$contents" ]; then continue; fi
|
|
741
|
-
registered=$((registered + 1))
|
|
742
|
-
done
|
|
743
|
-
return 0
|
|
744
|
-
}
|
|
745
|
-
count_registry || return 1
|
|
687
|
+
# The worktree half reads git's listing, and an rc-0 listing can be silently
|
|
688
|
+
# incomplete: when the registry under `<git-common-dir>/worktrees` — or any
|
|
689
|
+
# file git needs inside one of its entries — cannot be read, git drops the
|
|
690
|
+
# entry and still exits 0, and a dropped entry here is a live checkout read as
|
|
691
|
+
# FREE, the one answer this script must never invent. worktree.sh's
|
|
692
|
+
# `wt_counts` establishes the listing is complete before its absences are
|
|
693
|
+
# trusted — the registry entries on disk counted against the linked worktrees
|
|
694
|
+
# git listed, recounted before refusing, the direction of a standing
|
|
695
|
+
# disagreement named — and leaves that listing in `$wt_list` for the filter
|
|
696
|
+
# below. Every refusal is this probe's unknown, never a `die`: probes 1 and 2
|
|
697
|
+
# may already have established a verdict. A listing git could not produce at
|
|
698
|
+
# all is named as one, with git's own cause.
|
|
699
|
+
if wt_counts; then :; else
|
|
700
|
+
case $? in
|
|
701
|
+
2) add_unknown "local" "could not read the worktree list for #$n: $wt_why" ;;
|
|
702
|
+
*) add_unknown "local" "$wt_why" ;;
|
|
703
|
+
esac
|
|
704
|
+
return 1
|
|
705
|
+
fi
|
|
746
706
|
|
|
747
707
|
# Match on the worktree's basename, not its full path — matching the whole
|
|
748
708
|
# absolute path would false-hit on any checkout whose directory happens to
|
|
749
709
|
# contain the ticket number as an earlier path segment (e.g. a home dir or
|
|
750
|
-
# a sibling directory named with digits), matching every ticket.
|
|
751
|
-
#
|
|
752
|
-
#
|
|
753
|
-
#
|
|
754
|
-
#
|
|
755
|
-
#
|
|
756
|
-
#
|
|
757
|
-
#
|
|
758
|
-
#
|
|
759
|
-
#
|
|
760
|
-
#
|
|
761
|
-
#
|
|
762
|
-
#
|
|
763
|
-
#
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
# probes 1 and 2 may already have established.
|
|
767
|
-
add_unknown "local" "could not create a temporary file to hold the worktree list, so whether #$n has a worktree is unknown"
|
|
768
|
-
return 1
|
|
769
|
-
fi
|
|
770
|
-
# A function, not inline, because the recount below needs this whole pair —
|
|
771
|
-
# git's own read of the listing and the count derived from it — re-taken
|
|
772
|
-
# TOGETHER rather than one of them re-assigned on its own. `worktrees` and
|
|
773
|
-
# `linked` are this function's OUTPUT, exactly as `registered` is
|
|
774
|
-
# `count_registry`'s — `listed` is scratch the count derives `linked` from and
|
|
775
|
-
# the `-ge 1` guard below checks, never read outside this function, matching
|
|
776
|
-
# release-ticket.sh's own `count_linked`, whose comment (line 383) likewise
|
|
777
|
-
# names only `linked` and `wt_list`/`wt_err`. Mirrors that same extraction over
|
|
778
|
-
# the same pair for the same recount.
|
|
779
|
-
#
|
|
780
|
-
# The `mktemp` stays ABOVE this function rather than moving inside it, where
|
|
781
|
-
# release-ticket.sh's `wt_listing` creates and removes one of its own: the temp
|
|
782
|
-
# files here are the ONE EXIT trap's at the top of this file, and it holds a
|
|
783
|
-
# single slot per file, so a second `mktemp` in here would overwrite `$wtfile`
|
|
784
|
-
# and leak the first path with nothing said. The re-take truncates the same
|
|
785
|
-
# inode instead — the reason probe 1's second `2>"$errfile"` does, spelled out
|
|
786
|
-
# there.
|
|
787
|
-
#
|
|
788
|
-
# `return 1` inside returns from THIS function now, not from `probe_local`, so
|
|
789
|
-
# every call site carries its own `|| return 1` exactly as `count_registry`'s
|
|
790
|
-
# do. Without it a listing that could not be read would be recorded by
|
|
791
|
-
# `add_unknown` and then walked straight past, and the probe would answer
|
|
792
|
-
# `taken=false` off a listing it never had — the one answer this script must
|
|
793
|
-
# never invent.
|
|
794
|
-
count_linked() {
|
|
795
|
-
# Two operands, one status: the redirect is new here (the base ran this as a
|
|
796
|
-
# command substitution, which had nothing to write to), so a `git` that could
|
|
797
|
-
# not run and a `$wtfile` that could not be written are indistinguishable at
|
|
798
|
-
# this `if`. The message names both rather than blaming git for a write it never
|
|
799
|
-
# reached — the shell prints its own "Permission denied" naming the path when it
|
|
800
|
-
# is the redirect, which is the half a reader can tell apart.
|
|
801
|
-
if ! git worktree list --porcelain -z >"$wtfile"; then
|
|
802
|
-
add_unknown "local" "git worktree list failed, or its output could not be written to $wtfile, so whether #$n has a worktree is unknown"
|
|
803
|
-
return 1
|
|
804
|
-
fi
|
|
805
|
-
# NOT `awk -v RS='\0'`. That is a gawk/BWK extension, and the awk this script
|
|
806
|
-
# actually runs on macOS — /usr/bin/awk, BWK awk 20200816 — does not merely
|
|
807
|
-
# ignore it: it stops dead at the first NUL and reports ONE record for a
|
|
808
|
-
# listing of any length. Measured, all three spellings, `-v RS='\0'`,
|
|
809
|
-
# `-v RS='\000'` and `BEGIN{RS="\0"}`, every one of them `count=1`. No awk
|
|
810
|
-
# program here can hold a NUL byte, so the swap has to happen before awk sees
|
|
811
|
-
# the stream at all.
|
|
812
|
-
#
|
|
813
|
-
# One `tr` pass does it: NUL becomes the newline awk already splits on, and a
|
|
814
|
-
# newline inside a path becomes \001. `tr` translates simultaneously from one
|
|
815
|
-
# table, so the two mappings cannot feed each other the way two piped stages
|
|
816
|
-
# would. Both awks below then read the listing unchanged.
|
|
817
|
-
#
|
|
818
|
-
# Ceiling, deliberate: jstr renders that \001 as a space rather than as `\n`,
|
|
819
|
-
# so a path containing a newline is reported WHOLE but with the newline
|
|
820
|
-
# neutralised — the treatment every C0 byte WITHOUT a JSON short form gets. Not
|
|
821
|
-
# the tab in `…/fix-88-a<TAB>b`: \011 is one of the five RFC 8259 gives a short
|
|
822
|
-
# form, jstr's `sed` escapes it to `\t` before this `tr` stage runs at all, and
|
|
823
|
-
# jrewritten's delete set skips it — so a tab round-trips byte-identical and
|
|
824
|
-
# reports `worktreeRewritten: false`, which is what the probe-3 tab case pins.
|
|
825
|
-
# Swapping the byte back would restore `\n` here at the cost of corrupting the
|
|
826
|
-
# opposite case — a path that really contains \001 — for a diagnostic field
|
|
827
|
-
# whose verdict is already correct either way. One failure mode is better than
|
|
828
|
-
# two.
|
|
829
|
-
if ! worktrees=$(LC_ALL=C tr '\n\000' '\001\n' <"$wtfile"); then
|
|
830
|
-
add_unknown "local" "could not read the worktree list for #$n"
|
|
831
|
-
return 1
|
|
832
|
-
fi
|
|
833
|
-
# The main worktree is always listed first and has no registry entry of its
|
|
834
|
-
# own, hence the -1.
|
|
835
|
-
#
|
|
836
|
-
# awk, not `grep -c … || true`, for exactly the reason probe 2's filter above
|
|
837
|
-
# is one awk. `grep -c` exits 1 on zero matches — legitimate, and `set -e`
|
|
838
|
-
# would read it as fatal — so a `|| true` has to absorb it, and that same
|
|
839
|
-
# `|| true` absorbs a grep that could not RUN AT ALL. Then the count is the
|
|
840
|
-
# empty string, `$((listed - 1))` is -1, and the mismatch report below blames
|
|
841
|
-
# `git worktree list` for a count no listing can produce. awk needs no such
|
|
842
|
-
# case separated out: the program contains no `exit`, so it returns 0 whether
|
|
843
|
-
# or not anything matched and every non-zero status is a real failure.
|
|
844
|
-
listed=$(printf '%s\n' "$worktrees" | LC_ALL=C awk '/^worktree /{c++} END{print c+0}') ||
|
|
845
|
-
{ add_unknown "local" "could not count the worktrees git listed for #$n"; return 1; }
|
|
846
|
-
# The guard above closes only the route where awk could not RUN. An empty but
|
|
847
|
-
# SUCCESSFUL listing reaches the same -1: awk exits 0 printing `0`, the guard
|
|
848
|
-
# cannot fire, and the mismatch report below blames `git worktree list` for the
|
|
849
|
-
# very count that guard exists to keep out of an operator's face. One comparison
|
|
850
|
-
# closes it for every branch below at once, the recount included. `-ge 1`, not
|
|
851
|
-
# `-gt 1`: `listed=1` is the main checkout alone, `linked=0`, the ordinary repo
|
|
852
|
-
# with no linked worktree — a guard that refused that would make every probe in
|
|
853
|
-
# a clean repo unknown. Real `git worktree list --porcelain` always prints the
|
|
854
|
-
# main worktree, so reaching this needs a broken or shimmed git; the refusal
|
|
855
|
-
# direction was already right, only the number was nonsense.
|
|
856
|
-
[ "$listed" -ge 1 ] ||
|
|
857
|
-
{ add_unknown "local" "git listed no worktrees at all for #$n — not even the main checkout, so the listing cannot be trusted"; return 1; }
|
|
858
|
-
linked=$((listed - 1))
|
|
859
|
-
}
|
|
860
|
-
count_linked || return 1
|
|
861
|
-
# Recount before refusing. The two reads happen at different instants, and the
|
|
862
|
-
# gap is not theoretical: measured at ~10ms (two independent methods agreeing —
|
|
863
|
-
# the fork+exec of git, which is almost the whole cost of `worktree list`, and
|
|
864
|
-
# the observed hit rate under churn). A sibling agent's `git worktree add` or
|
|
865
|
-
# `remove` landing in it makes the counts disagree with nothing wrong, which in
|
|
866
|
-
# THIS fleet is routine rather than exotic: measured 1.99% of probes aborting
|
|
867
|
-
# spuriously at λ = 2 mutations/s, 56.6% under saturation.
|
|
710
|
+
# a sibling directory named with digits), matching every ticket. This is a
|
|
711
|
+
# different question from worktree.sh's `wt_find_branch` — which listed path
|
|
712
|
+
# names this ticket, not which path holds a given branch — so it stays here,
|
|
713
|
+
# over the probe's `$wt_list`.
|
|
714
|
+
#
|
|
715
|
+
# Ceiling, deliberate: `wt_listing` swaps a newline inside a path for \001,
|
|
716
|
+
# and jstr renders that \001 as a space rather than as `\n`, so a path
|
|
717
|
+
# containing a newline is reported WHOLE but with the newline neutralised —
|
|
718
|
+
# the treatment every C0 byte WITHOUT a JSON short form gets. Not the tab in
|
|
719
|
+
# `…/fix-88-a<TAB>b`: \011 is one of the five RFC 8259 gives a short form,
|
|
720
|
+
# jstr's `sed` escapes it to `\t`, and jrewritten's delete set skips it — so a
|
|
721
|
+
# tab round-trips byte-identical and reports `worktreeRewritten: false`, which
|
|
722
|
+
# is what the probe-3 tab case pins. Swapping the byte back would restore `\n`
|
|
723
|
+
# here at the cost of corrupting the opposite case — a path that really
|
|
724
|
+
# contains \001 — for a diagnostic field whose verdict is already correct
|
|
725
|
+
# either way. One failure mode is better than two.
|
|
868
726
|
#
|
|
869
|
-
# One recount closes it rather than moving it: a mutation landing between the
|
|
870
|
-
# FIRST count and git's listing is already reflected in that listing, so the
|
|
871
|
-
# second count agrees with it — the invariant the ORIGINAL pair above relies
|
|
872
|
-
# on. Escaping still needs a SECOND mutation inside the recount's own window.
|
|
873
|
-
# The two rates measured for recounting at all — 1.99% → 0.00% at
|
|
874
|
-
# λ = 2/s, 56.6% → 1.29% saturated — were taken on the registered-only
|
|
875
|
-
# recount this replaces, so that 1.29% residual bounds what narrowing the
|
|
876
|
-
# window below can still leave rather than describing it; it was not
|
|
877
|
-
# re-measured after that change. A real dropped entry is a standing state,
|
|
878
|
-
# not a moment, so it survives the recount and still refuses (verified: an
|
|
879
|
-
# unreadable `gitdir` still aborts).
|
|
880
|
-
#
|
|
881
|
-
# BOTH counts, not `registered` alone, which is what that invariant costs.
|
|
882
|
-
# Re-taking the registry by itself leaves `linked` pinned to the FIRST
|
|
883
|
-
# listing, so a second sibling mutation landing after that listing returned
|
|
884
|
-
# but before the recount re-scans the registry moves one count and not the
|
|
885
|
-
# other. Reproduced in both directions, and they fail differently. Two
|
|
886
|
-
# `git worktree add`s straddling the listing call FLIP the disagreement:
|
|
887
|
-
# `linked -gt registered` on the first pair becomes `linked -lt registered`
|
|
888
|
-
# on the recount, reported as "git listed 1 worktrees for 2 registry entries
|
|
889
|
-
# … the listing is incomplete" — a corruption report for two ordinary adds.
|
|
890
|
-
# A remove then an add makes it PERSIST instead: the registry count comes
|
|
891
|
-
# back to the same 1 for a different entry while `linked` stays at the 0 it
|
|
892
|
-
# read before the add, and the same message fires at 0 against 1. Neither run
|
|
893
|
-
# had anything wrong with it.
|
|
894
|
-
# Re-taking `registered` and `linked` together, in the same order the pair
|
|
895
|
-
# above takes them, hands the RECOUNT pair the invariant too: the window an
|
|
896
|
-
# escape needs is the narrow gap these two calls open between themselves, not
|
|
897
|
-
# the whole span back to the first listing. Both directions pinned in
|
|
898
|
-
# the test suite. Mirrors release-ticket.sh's copy of this recount, which
|
|
899
|
-
# is fixed the same way.
|
|
900
|
-
#
|
|
901
|
-
# The retake pair above is still two reads, not one, and the gap it opens
|
|
902
|
-
# between ITSELF — after `count_registry` has already re-scanned but before
|
|
903
|
-
# `count_linked` re-lists — is narrower than the window this recount closes,
|
|
904
|
-
# not zero. A mutation landing there still escapes: `registered` is re-taken
|
|
905
|
-
# first, so an ADD landing in this gap is missed by the registry scan that
|
|
906
|
-
# already ran and IS seen by the git listing still to come — `linked -gt
|
|
907
|
-
# registered`, "the registry read missed entries git can see" — while a
|
|
908
|
-
# REMOVE the same way lands `linked -lt registered`, "the listing is
|
|
909
|
-
# incomplete", indistinguishable from the fault that message exists to name
|
|
910
|
-
# even though nothing here is actually wrong. Pinned in the test suite.
|
|
911
|
-
# Reordering to `count_linked && count_registry` does not remove this
|
|
912
|
-
# residual, it only moves the ADD case's false report onto the
|
|
913
|
-
# `linked -lt registered` branch instead — the direction the comment below
|
|
914
|
-
# calls out by name as sending an operator hunting a permissions fault that
|
|
915
|
-
# is not there. `count_registry` first, `count_linked` second, mirrors
|
|
916
|
-
# release-ticket.sh's own recount ordering (count_registry before
|
|
917
|
-
# count_linked) — kept fixed for the reason that copy's own comment gives:
|
|
918
|
-
# not because a different order would be wrong, but so the reasoning above
|
|
919
|
-
# stays about one order instead of two.
|
|
920
|
-
#
|
|
921
|
-
# `&&`, not `;`, between the two: `count_registry` reports an unreadable
|
|
922
|
-
# registry through `add_unknown` and a non-zero return, and under `;` the
|
|
923
|
-
# group's status would be `count_linked`'s alone, so this probe would walk
|
|
924
|
-
# past a refusal it had already recorded. Measured, that is belt-and-braces
|
|
925
|
-
# and not a behaviour difference: every state that fails `count_registry`'s
|
|
926
|
-
# `[ -r ] && [ -x ]` guard also stops git enumerating $wtroot, so `linked`
|
|
927
|
-
# collapses to 0 alongside `registered` and the comparison below matches
|
|
928
|
-
# either way — checked at mode 000 landed inside this very window, under both
|
|
929
|
-
# spellings, and the registry message is the only one reported by both. The
|
|
930
|
-
# `&&` stays because the status of a count that refused is not
|
|
931
|
-
# `count_linked`'s to overwrite, not because a case turns on it today.
|
|
932
|
-
[ "$linked" -eq "$registered" ] || { count_registry && count_linked; } || return 1
|
|
933
|
-
# Name the direction actually observed. The two disagreements have opposite
|
|
934
|
-
# causes and send the reader to opposite places, so one message cannot serve
|
|
935
|
-
# both: FEWER listed than registered is git silently dropping an entry it could
|
|
936
|
-
# not read, which is the fault this whole check exists to catch. MORE listed
|
|
937
|
-
# than registered is the opposite — the on-disk count is the stale read, a
|
|
938
|
-
# sibling agent's `git worktree add` having landed between the two, which in a
|
|
939
|
-
# parallel fleet is routine rather than exotic. Calling that "the listing is
|
|
940
|
-
# incomplete" sends an operator hunting a permissions fault that is not there.
|
|
941
|
-
if [ "$linked" -lt "$registered" ]; then
|
|
942
|
-
add_unknown "local" "git listed $linked worktrees for $registered registry entries in $wtroot — the listing is incomplete, so no absence it reports can be trusted"
|
|
943
|
-
return 1
|
|
944
|
-
elif [ "$linked" -gt "$registered" ]; then
|
|
945
|
-
add_unknown "local" "git listed $linked worktrees but only $registered registry entries were counted in $wtroot — the registry read missed entries git can see, so no absence it reports can be trusted"
|
|
946
|
-
return 1
|
|
947
|
-
fi
|
|
948
|
-
|
|
949
727
|
# substr($0,10), never $2, exactly as release-ticket.sh's own substr($0,10) awks
|
|
950
728
|
# read the same field: the porcelain prints the path raw, so a checkout under a
|
|
951
729
|
# directory with a space in it — plain enough on macOS — truncates at the space
|
|
@@ -957,8 +735,8 @@ fi
|
|
|
957
735
|
# one level down: a failed fork there yields an empty first field and a silent
|
|
958
736
|
# non-match, and `$(…)` discards the status that would have said so.
|
|
959
737
|
#
|
|
960
|
-
# `\001` counts as a separator for the MATCH, and for the match only.
|
|
961
|
-
#
|
|
738
|
+
# `\001` counts as a separator for the MATCH, and for the match only.
|
|
739
|
+
# `wt_listing` turned every newline inside a path into `\001`, and `\001` is not in
|
|
962
740
|
# `([-/]|$)` — so `…/wt/fix-33<LF>slug` arrives as `fix-33\001slug`, the number
|
|
963
741
|
# stops matching, and a live checkout reads FREE. Measured on real repos with
|
|
964
742
|
# real linked worktrees: plain porcelain `taken=true` rc 1, `--porcelain -z`
|
|
@@ -967,7 +745,7 @@ fi
|
|
|
967
745
|
# leaf and `…/wt/fix<LF>33-slug`, which the plain form never matched either.
|
|
968
746
|
# `b` is the throwaway copy: `p` is untouched, so the evidence this probe
|
|
969
747
|
# reports — and `worktreeRewritten` with it — still carries the raw bytes.
|
|
970
|
-
wt=$(printf '%s\n' "$
|
|
748
|
+
wt=$(printf '%s\n' "$wt_list" | LC_ALL=C awk -v n="$n" '
|
|
971
749
|
/^worktree / { p = substr($0,10); b = p; sub(".*/", "", b); gsub(/\001/, "/", b)
|
|
972
750
|
if (b ~ "(^|[/-])" n "([-/]|$)") { out = out sep p; sep = "," } }
|
|
973
751
|
END { printf "%s", out }') ||
|
package/scripts/net.sh
CHANGED
|
@@ -385,8 +385,8 @@ net_git() {
|
|
|
385
385
|
# that fault, fetched through this function unmodified, loses the
|
|
386
386
|
# registry entry between the fetch returning and the caller's own next
|
|
387
387
|
# read of it — a worktree whose fault is seconds old, not months.
|
|
388
|
-
# reap.sh's registry recount (`
|
|
389
|
-
#
|
|
388
|
+
# reap.sh's registry recount (worktree.sh's `wt_counts`) reads the very
|
|
389
|
+
# corruption this detached run erases:
|
|
390
390
|
# with the entry gone, the registry count drops to match the listing's
|
|
391
391
|
# linked count, in lockstep, and the guard a stray `git worktree add`
|
|
392
392
|
# mid-run is built to catch sees no mismatch to refuse on — both branches
|