@feigi/fleet-ctl 3.23.44 → 3.24.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.
|
@@ -242,15 +242,7 @@ For each labeled PR clearing the hold rule, lowest first:
|
|
|
242
242
|
|
|
243
243
|
**A `rebase-fallback-#<pr>` merge is expected to disprove here.** Step 1's fallback never lands a rebased head on the remote, so `pre == post` and `headWasCurrent` reads false — `prove-merge.sh` exits **1**, correctly (`prove-merge.test.mjs`'s `ATTACK: un-rebased head that merged cleanly still proves false` pins exactly this shape). That is the honest answer, not a script fault. Report the merge as **argued** — backed by the fallback's four checks — and never as `proved`; a merge whose ancestry was not proved is never reported as proved.
|
|
244
244
|
|
|
245
|
-
**
|
|
246
|
-
|
|
247
|
-
```bash
|
|
248
|
-
~/.fleet/bin/fleet-run drop-merged-label.sh <pr> --apply
|
|
249
|
-
```
|
|
250
|
-
|
|
251
|
-
Exit 0 done or nothing to close, **1 a removal failed — report it as `label-drop-failed-#<issue>`, never swallow it**: a merged ticket that keeps the label is invisible the moment it is reopened. Exit 2 means the PR was not actually MERGED yet — call this only after the merge is confirmed at the top of this step.
|
|
252
|
-
|
|
253
|
-
**Delete the head branch from `origin`** — this bot owns that step, and no repo setting does it for you (#2196). Without it a merged branch is never `[gone]`, so `reap.sh` never reaps it or its worktree:
|
|
245
|
+
**Delete the head branch from `origin`** — this bot owns that step, and no repo setting does it for you. Without it a merged branch is never `[gone]`, so `reap.sh` never reaps it or its worktree. The same step also drops `in-progress` from every issue this PR closes: the merge is the only point where the ticket number and the fact of completion are known together, and nothing else clears it.
|
|
254
246
|
|
|
255
247
|
```bash
|
|
256
248
|
~/.fleet/bin/fleet-run delete-merged-branch.sh <pr>
|
|
@@ -258,7 +250,9 @@ For each labeled PR clearing the hold rule, lowest first:
|
|
|
258
250
|
|
|
259
251
|
Exit 0 the branch is gone from `origin` — `deleted`, `alreadyGone` (a repo that still auto-deletes), or `skipped` for a fork PR, whose branch is not ours. **1 the branch is still on `origin` — report it as `branch-delete-failed-#<pr>`, never swallow it**: either a push landed on it after the merge (the delete is leased to the merged head, so it refuses rather than destroy commits `main` never received) or the push failed. The script reads the deletion back from `origin` rather than trusting the push's exit status. Exit 2 could not tell what to delete — the PR is not MERGED, a `gh` or `ls-remote` read failed, or the lookup for other open PRs on the branch failed (nothing is deleted then); call this only after the merge is confirmed at the top of this step. **Exit 3 the branch is kept on purpose — another open PR uses it as its head or its base** (#2295): deleting it would close the PRs headed by it, and may close rather than retarget the PRs based on it. Nothing was pushed. Its stdout is one `branch-kept-#<pr>` line per such PR, naming that open PR, not the merged one — report each line as printed. A deliberate keep, not a failure: never retry it, and never report it as `branch-delete-failed`. The branch stays on `origin`, so it is not `[gone]` and `reap.sh` leaves it and its worktree in place.
|
|
260
252
|
|
|
261
|
-
|
|
253
|
+
**Exit 4 the branch half succeeded but the label half did not — report every token line the step printed on stdout, never swallow one.** `label-drop-failed-#<issue>` is one issue whose removal failed: a merged ticket that keeps the label is invisible the moment it is reopened. `label-read-failed-#<pr>` means what the PR closes could not be determined — never read it as "nothing to drop". When the branch half exits 1, 2 or 3 that code wins, and the same token lines are still printed ahead of the branch output. On any non-zero exit, report every token line; never retry.
|
|
254
|
+
|
|
255
|
+
The branch half deletes the **remote** ref only, and that is why it exists instead of `gh pr merge --delete-branch`: that flag's local cleanup dies with `fatal: 'main' is already used by worktree at <path>` whenever the branch is checked out in a worktree — which every fleet-claimed branch is, at `.worktrees/<issue>-<slug>` — or strands the feature worktree on `main`, after the remote merge already succeeded. The local branch and its worktree are left `[gone]` for `reap.sh`, which removes the worktree before deleting the branch and keeps either when it holds anything unmerged.
|
|
262
256
|
|
|
263
257
|
Then re-fetch and **re-evaluate the queue from scratch** — labels and numbers move while CI runs, and a merge newly unblocks or blocks others.
|
|
264
258
|
|
|
@@ -268,7 +262,7 @@ Measured over one three-merge pass: the next queue member went 0 → 2 → 7 →
|
|
|
268
262
|
|
|
269
263
|
**A PR whose heavy jobs have only ever `skipped` is getting its first real verification from your rebase.** Reviewers may legitimately have labelled on the checks that did run plus local evidence, saying so explicitly. When your post-rebase run finally executes those suites, treat a red there as a **genuine first result**, not a regression you caused — read the failing job before concluding, and do not hand it back as "the rebase broke it".
|
|
270
264
|
|
|
271
|
-
Report merged / skipped-unlabeled / held-behind-#X / worktree-diverged-#X / head-moved-after-label-#X / label-drop-failed-#X / branch-delete-failed-#X / branch-kept-#X (X the open PR that keeps the merged branch — a keep, not a failure) / rebase-fallback-#X / instrument-set-changed-#X / `<reason>-#X` for any other gate refusal / blocked after the pass — a dispatched bot once, at exit, after its grace (**Grace, then one report**, below).
|
|
265
|
+
Report merged / skipped-unlabeled / held-behind-#X / worktree-diverged-#X / head-moved-after-label-#X / label-drop-failed-#X / label-read-failed-#X / branch-delete-failed-#X / branch-kept-#X (X the open PR that keeps the merged branch — a keep, not a failure) / rebase-fallback-#X / instrument-set-changed-#X / `<reason>-#X` for any other gate refusal / blocked after the pass — a dispatched bot once, at exit, after its grace (**Grace, then one report**, below).
|
|
272
266
|
|
|
273
267
|
## No-undo audit (before every rebase)
|
|
274
268
|
|
package/package.json
CHANGED
|
@@ -39,6 +39,21 @@
|
|
|
39
39
|
# The lookups run only when there is a delete to guard — a branch already gone
|
|
40
40
|
# has none, and is exit 0 whatever they would say.
|
|
41
41
|
#
|
|
42
|
+
# THE LABEL HALF. The same step also drops `in-progress` from every issue the
|
|
43
|
+
# merged PR closes, by running its sibling `drop-merged-label.sh <pr> --apply`
|
|
44
|
+
# through `sh`, resolved beside this file. It runs right after the MERGED gate,
|
|
45
|
+
# before any branch-half validation, so every later exit already carries its
|
|
46
|
+
# outcome; a PR that is not MERGED is refused (exit 2) with no `issue edit`. A
|
|
47
|
+
# missing or unreadable sibling is exit 2 at startup, nothing touched. Its JSON
|
|
48
|
+
# line and stderr go to this script's stderr; stdout carries only these failure
|
|
49
|
+
# tokens, one per line, printed before the branch half's output:
|
|
50
|
+
# label-drop-failed-#<issue> one per issue whose removal failed
|
|
51
|
+
# label-read-failed-#<pr> the outcome could not be determined: the sibling
|
|
52
|
+
# exited 2, exited 1 naming no issue, or ended any
|
|
53
|
+
# other way (stderr names the raw exit code) —
|
|
54
|
+
# never read as "nothing to drop"
|
|
55
|
+
# A label failure never stops the branch delete from running.
|
|
56
|
+
#
|
|
42
57
|
# Exit 0: the branch is gone from origin (deleted here, already gone, or a fork
|
|
43
58
|
# PR's branch, which lives in another repository and is not ours to
|
|
44
59
|
# delete — `"skipped":"cross-repository"`).
|
|
@@ -55,6 +70,10 @@
|
|
|
55
70
|
# such PR (that PR's number, not the merged one's) instead of the JSON
|
|
56
71
|
# payload; stderr says which role each plays. A deliberate keep, not a
|
|
57
72
|
# failure: report the lines, never retry.
|
|
73
|
+
# Exit 4: the branch half succeeded (what would be exit 0) but the label half
|
|
74
|
+
# printed at least one token. When the branch half exits 1, 2 or 3 that
|
|
75
|
+
# code wins and the tokens are still printed. Report every token line
|
|
76
|
+
# on any non-zero exit; never retry.
|
|
58
77
|
set -eu
|
|
59
78
|
|
|
60
79
|
# Ambient GIT_DIR/GIT_WORK_TREE would point `ls-remote origin` and the push at
|
|
@@ -77,6 +96,13 @@ net_lib="$(dirname "$0")/net.sh"
|
|
|
77
96
|
# shellcheck source=net.sh
|
|
78
97
|
. "$net_lib" || die "$net_lib failed to load"
|
|
79
98
|
|
|
99
|
+
# The label half is a sibling script, resolved from this file's own location —
|
|
100
|
+
# not PATH, not the caller's cwd. Checked with the helper libraries, before
|
|
101
|
+
# anything is touched: a partial install must never delete branches while
|
|
102
|
+
# silently skipping the label.
|
|
103
|
+
label_script="$(dirname "$0")/drop-merged-label.sh"
|
|
104
|
+
[ -r "$label_script" ] || die "cannot read $label_script — refusing to delete a branch without the label drop that belongs to it"
|
|
105
|
+
|
|
80
106
|
[ $# -eq 1 ] || die "usage: delete-merged-branch.sh <pr>"
|
|
81
107
|
pr=$1
|
|
82
108
|
case "$pr" in ''|*[!0-9]*|0?*) die "pr must be a number, got '$pr'";; esac
|
|
@@ -99,6 +125,55 @@ EOF
|
|
|
99
125
|
|
|
100
126
|
# MERGED, not just closed: a PR closed unmerged still holds work nowhere else.
|
|
101
127
|
[ "$state" = "MERGED" ] || die "PR #$pr is not merged (state=$state) — refusing to delete its branch"
|
|
128
|
+
|
|
129
|
+
# The label half runs HERE — right after the MERGED gate and before any
|
|
130
|
+
# branch-half validation — so every later exit (deleted, already gone, skipped,
|
|
131
|
+
# kept, delete failed, a read that dies) already carries its outcome. A PR that
|
|
132
|
+
# is not MERGED never reaches it. Its JSON line and stderr stay on stderr:
|
|
133
|
+
# stdout carries only the tokens below and the branch half's own output, and a
|
|
134
|
+
# label failure never stops the branch delete from running.
|
|
135
|
+
label_failed=false
|
|
136
|
+
label_token() { printf '%s\n' "$1"; label_failed=true; }
|
|
137
|
+
|
|
138
|
+
echo "\$ sh $label_script $pr --apply" >&2
|
|
139
|
+
label_rc=0
|
|
140
|
+
label_out=$(sh "$label_script" "$pr" --apply) || label_rc=$?
|
|
141
|
+
[ -z "$label_out" ] || printf '%s\n' "$label_out" >&2
|
|
142
|
+
case "$label_rc" in
|
|
143
|
+
0) echo "$NAME: in-progress dropped from every issue PR #$pr closes (or none carried it)" >&2 ;;
|
|
144
|
+
1)
|
|
145
|
+
# The label script's own exit 1 is "one or more removals failed"; its
|
|
146
|
+
# `failed` array names them. Exit 1 with no number to extract is not an
|
|
147
|
+
# answer about any issue, so it reads as undetermined, never as clear.
|
|
148
|
+
if ! failed_issues=$(printf '%s\n' "$label_out" | sed -n 's/.*"failed":\[\([0-9][0-9,]*\)\].*/\1/p'); then
|
|
149
|
+
failed_issues=""
|
|
150
|
+
fi
|
|
151
|
+
if [ -z "$failed_issues" ]; then
|
|
152
|
+
echo "$NAME: $label_script exited 1 but named no failed issue — the label outcome is unknown" >&2
|
|
153
|
+
label_token "label-read-failed-#$pr"
|
|
154
|
+
else
|
|
155
|
+
for n in $(printf '%s\n' "$failed_issues" | tr ',' ' '); do
|
|
156
|
+
label_token "label-drop-failed-#$n"
|
|
157
|
+
done
|
|
158
|
+
fi
|
|
159
|
+
;;
|
|
160
|
+
*)
|
|
161
|
+
echo "$NAME: $label_script exited $label_rc — the label outcome could not be determined" >&2
|
|
162
|
+
label_token "label-read-failed-#$pr"
|
|
163
|
+
;;
|
|
164
|
+
esac
|
|
165
|
+
|
|
166
|
+
# Exit 4: the branch half succeeded but a label token was printed. The branch
|
|
167
|
+
# half's own 1, 2 and 3 win; this only lifts a would-be 0.
|
|
168
|
+
lift_exit_to_label_failure() {
|
|
169
|
+
exit_rc=$?
|
|
170
|
+
trap - EXIT
|
|
171
|
+
if [ "$exit_rc" -eq 0 ]; then exit 4; fi
|
|
172
|
+
exit "$exit_rc"
|
|
173
|
+
}
|
|
174
|
+
if [ "$label_failed" = true ]; then
|
|
175
|
+
trap lift_exit_to_label_failure EXIT
|
|
176
|
+
fi
|
|
102
177
|
[ -n "$branch" ] && [ -n "$oid" ] || die "gh pr view $pr returned no head branch or head commit"
|
|
103
178
|
case "$oid" in *[!0-9a-f]*) die "gh pr view $pr returned a head commit that is not a hex SHA: '$oid'";; esac
|
|
104
179
|
[ "$branch" != "$base" ] || die "PR #$pr's head branch is its base branch '$base' — refusing to delete it"
|
|
@@ -9,8 +9,9 @@
|
|
|
9
9
|
# Single writer, per the #170 ruling: the merge is the only moment the ticket
|
|
10
10
|
# number and the fact of completion are known together, so only a PROVEN merge
|
|
11
11
|
# triggers this — never reap (branches, not tickets), never a repo automation
|
|
12
|
-
# (no attribution).
|
|
13
|
-
#
|
|
12
|
+
# (no attribution). The merge bot's branch-delete step, delete-merged-branch.sh,
|
|
13
|
+
# calls this script as a sibling with --apply, after its own MERGED gate: the
|
|
14
|
+
# claim has not ended until the merge lands. Direct use is manual repair.
|
|
14
15
|
#
|
|
15
16
|
# #1617: `closingIssuesReferences` reflects `Closes #N` syntax in the PR's own
|
|
16
17
|
# title/body, but NOT a commit-message-only reference — GitHub's real
|
package/skills/run-team/SKILL.md
CHANGED
|
@@ -3408,6 +3408,8 @@ the deletion back; `reap.sh` takes the `[gone]` local branch and its worktree.
|
|
|
3408
3408
|
No repo setting is relied on to do it (#2196). A branch another open PR still
|
|
3409
3409
|
uses as its head or base is kept instead — `branch-kept-#<that PR>` in the bot's
|
|
3410
3410
|
report, a deliberate keep and not a failure (#2295).
|
|
3411
|
+
The branch-delete step also releases the claim label: it drops `in-progress` from
|
|
3412
|
+
every issue the PR closes.
|
|
3411
3413
|
|
|
3412
3414
|
**Never force a rebase to start.** No `git clean`, `git checkout .`,
|
|
3413
3415
|
`git reset --hard`, `git stash`. Uncommitted changes may exist nowhere else.
|