@feigi/fleet-ctl 3.138.0 → 3.138.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@feigi/fleet-ctl",
3
- "version": "3.138.0",
3
+ "version": "3.138.1",
4
4
  "description": "Agent fleet: run-team controller, merge bot, PR reviewer, and the ticket pipeline they share",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -276,12 +276,26 @@ in_progress=$(node "$script_dir/label-map.mjs" show in-progress) \
276
276
 
277
277
  if [ "$apply" = false ]; then
278
278
  echo "$NAME: DRY RUN — nothing created. Pass --apply to act." >&2
279
+ printf ' would: git config --remove-section branch.%s — if one is left under that name\n' "$branch" >&2
279
280
  echo " would: gh issue edit $issue --add-label $in_progress" >&2
280
281
  printf ' would: git worktree add --no-track %s -b %s origin/main\n' "$wt" "$branch" >&2
281
282
  printf ' would: (cd %s && %s)\n' "$wt" "$install" >&2
282
283
  printf ' would: write %s and add it to .git/info/exclude — skipped if %s is\n' "$runner" "$runner" >&2
283
284
  printf ' already present, a repo-local runner checked out with the worktree\n' >&2
284
285
  else
286
+ # The branch does not exist yet (refused above), so any `[branch "$branch"]`
287
+ # config under its name is a leftover from an earlier branch of that name:
288
+ # `git update-ref -d` removes a ref and nothing else, and `git worktree add
289
+ # --no-track -b` does not clear what is there. Left in place, the new branch
290
+ # inherits the old upstream — a remote ref that no longer exists — and reads
291
+ # `[gone]` from its first moment, which is what reap.sh selects on. Before
292
+ # the label, for the reason the stamp is derived before it: a refusal here
293
+ # has nothing to clean up. A section that cannot be removed is a refusal,
294
+ # since claiming past it is the defect.
295
+ printf '$ git config --remove-section branch.%s\n' "$branch" >&2
296
+ wt_clear_branch_config "$branch" ||
297
+ die "could not remove the leftover config of branch.$branch — $wt_err"
298
+
285
299
  echo "\$ gh issue edit $issue --add-label $in_progress" >&2
286
300
  gh issue edit "$issue" --add-label "$in_progress" >/dev/null || die "could not label issue $issue"
287
301
 
@@ -1335,6 +1335,7 @@ if [ "$apply" = false ]; then
1335
1335
  [ "$has_label" = true ] && echo " would: gh issue edit $issue --remove-label $in_progress" >&2
1336
1336
  [ -n "$wt" ] && printf ' would: git worktree remove %s\n' "$wt" >&2
1337
1337
  [ "$has_branch" = true ] && echo " would: git update-ref -d refs/heads/$branch <its current tip>" >&2
1338
+ [ "$has_branch" = true ] && echo " would: git config --remove-section branch.$branch — if one is left behind" >&2
1338
1339
  if [ "$closed_pr" = true ]; then
1339
1340
  echo " PR states on $branch:$pr_seen" >&2
1340
1341
  echo " would: git push origin --delete refs/heads/$branch (origin read at $remote_sha)" >&2
@@ -1476,6 +1477,21 @@ else
1476
1477
  ;;
1477
1478
  *) halt "$branch $wt_restore_why — branch restored, not deleted" ;;
1478
1479
  esac
1480
+
1481
+ # The `[branch "$branch"]` config section, which `git update-ref -d` leaves
1482
+ # behind and `git branch -D` would have removed with the ref. Left, a later
1483
+ # claim of the same name inherits the upstream and reads `[gone]` at once,
1484
+ # and reap.sh then removes the live claim (claim-ticket.sh clears it too;
1485
+ # this is the deleter cleaning up after itself, as reap.sh's delete does).
1486
+ # The ref is already gone and the release otherwise complete, so a section
1487
+ # that stays is a note on stderr and never a halt — the housekeeping
1488
+ # `git worktree prune` below is the same shape. Unlike reap.sh, which also
1489
+ # puts that note in its stdout `warnings`, the receipt has no field for it:
1490
+ # the next claim of the name removes the section itself, and refuses when
1491
+ # it cannot. A claim that never pushed has no section, and that is not a
1492
+ # fault: `wt_clear_branch_config` tells the two apart.
1493
+ wt_clear_branch_config "$branch" ||
1494
+ echo "$NAME: $branch deleted, but its branch config section was left: $wt_err" >&2
1479
1495
  done_branch=true
1480
1496
  fi
1481
1497
 
@@ -1345,3 +1345,49 @@ wt_outcome() {
1345
1345
  fi
1346
1346
  return 0
1347
1347
  }
1348
+
1349
+ # Removes the `[branch "<name>"]` config section of a branch whose ref is gone
1350
+ # or has never existed. `git branch -D` takes the section with the ref;
1351
+ # `git update-ref -d` leaves it, and `git worktree add --no-track -b <name>` of
1352
+ # a later claim under the same name inherits the leftover upstream, which
1353
+ # names a remote ref that no longer exists and so reads `[gone]` at once
1354
+ # (measured, git 2.50.1). Calling it with the ref still present would unset the
1355
+ # live branch's upstream, so while `refs/heads/<name>` exists it removes
1356
+ # nothing and returns 1.
1357
+ #
1358
+ # Returns 0 when no key of that section is left, whether this call removed it
1359
+ # or there was none to remove, and 1 when one remains or the config could not
1360
+ # be read, with `$wt_err` naming the cause. `--remove-section` fails the same
1361
+ # way for a missing section as for a lock it could not take, so its status
1362
+ # cannot tell them apart: the keys are listed afterwards, the way reap.sh's
1363
+ # `branch_keys_left` does, and only a key of this branch's section left behind
1364
+ # is a failure. `${key%.*}` drops the variable name off `branch.<name>.<var>`;
1365
+ # the subsection may itself hold dots and slashes, so a regex built from the
1366
+ # name would misread them. Only the repository's own config file is cleared and
1367
+ # listed (`--local`): a section in an included file or in config.worktree is
1368
+ # neither removed nor reported, and its upstream still applies. Writes
1369
+ # `$wt_err`, and clobbers `$wt_cfg_out`, `$wt_cfg_keys` and `$wt_cfg_k`; call as
1370
+ # a bare `if`/`||` condition, never inside `$( )`.
1371
+ wt_clear_branch_config() {
1372
+ wt_err=
1373
+ if git show-ref --verify --quiet "refs/heads/$1"; then
1374
+ wt_err="branch $1 still exists"
1375
+ return 1
1376
+ fi
1377
+ if wt_cfg_out=$(git config --remove-section "branch.$1" 2>&1); then return 0; fi
1378
+ if wt_cfg_keys=$(git config --local --name-only --get-regexp '^branch\.' 2>&1); then :
1379
+ elif [ "$?" -eq 1 ]; then return 0
1380
+ else
1381
+ wt_err="could not list the branch config keys: $(printf '%s' "$wt_cfg_keys" | tr '\n' ' ')"
1382
+ return 1
1383
+ fi
1384
+ while IFS= read -r wt_cfg_k; do
1385
+ if [ "${wt_cfg_k%.*}" = "branch.$1" ]; then
1386
+ wt_err=$(printf '%s' "$wt_cfg_out" | tr '\n' ' ')
1387
+ return 1
1388
+ fi
1389
+ done <<EOK
1390
+ $wt_cfg_keys
1391
+ EOK
1392
+ return 0
1393
+ }
@@ -72,6 +72,8 @@ So nothing in the run cleans it up. Next run, the in-flight probe's local-worktr
72
72
 
73
73
  **A checkout that lands between that fresh check and the delete halts the release after it.** `git worktree add` of an existing branch does not move the ref, so the compare-and-swap succeeds under it. The same `wt_recheck_delete` reap uses then finds the worktree, recreates the branch at the tip, and the release halts with exit 2, `released:false` and a blocker naming that worktree — the shape of a holder caught before the delete. A restore that fails halts the same way, with the tip and the repair command in the blocker.
74
74
 
75
+ **The branch's config section goes after the delete, as reap's does.** `git update-ref -d` removes the ref and not `[branch "<name>"]`; a later claim of the same name would inherit the dead upstream and read `[gone]` at once. worktree.sh's `wt_clear_branch_config` removes it; a claim that never pushed has none, which is not a fault, and a section that cannot be removed is a note on stderr, never a halt — the ref is already deleted. claim-ticket.sh `--apply` clears the same section before `git worktree add`, since whatever deleted the branch, config under a name no branch holds is leftover; there, a section that cannot be removed refuses the claim.
76
+
75
77
  **`worktree remove` without `--force`** refuses on modified and untracked files and deletes ignored files silently (verified, git 2.50.1). Ignored-silently is what is wanted: `claim-ticket.sh` writes an `agent-test` into each fresh worktree it claims of a repository that tracks none, and ignores it through the repository's exclude file, so treating ignored files as dirt would strand every such release. The same asymmetry is why a claim never writes over a tracked `agent-test`: that write would leave a modified tracked path, which this refusal does not forgive. Its refusal is the dirty check recomputed by git at the moment of the delete — for the live-directory case ONLY. `worktree remove` gates that clean check on the same `stat` the guard does, so it is not an independent second opinion: where the path cannot be stat'ed git reaches the same "gone" by the same means, accepts the entry at rc 0 and deregisters a worktree whose files are still on disk (measured, git 2.50.1: an untracked file in a worktree under a `chmod 000` parent). There the `gone` guard is sole arbiter — which is why it establishes absence instead of inferring it from a failed `-e`, and why the fail-open fixed in `1e54bac` survived being reasoned about: guard and backstop fail on the same inputs.
76
78
 
77
79
  **A worktree that wandered off the branch blocks too.** The worktree is located by the branch it has checked out, and it does not stay there — an interrupted rebase leaves it detached, a member can switch it. The lookup then finds nothing, which reads as "no worktree of ours": the dirty check is skipped entirely and the release reports success while the worktree stands with the member's work in it, so the next run's probe still reads the ticket as taken. So a linked worktree at `claim-ticket.sh`'s `.worktrees/<issue>-<slug>` that is *not* on the branch is its own blocker — which remedy it names is the next paragraph, and is not always a hand-release. The path is read as the whole rest of the `worktree list --porcelain` line, never the first whitespace field, or every checkout under a directory with a space in its name reads as a different path.