Skip to content

sweep: re-land PR #153's eight review fixes to the predecessor rescue, and one more (7.181.0) - #242

Merged
SSFSKIM merged 11 commits into
mainfrom
board-pr153-fixes
Oct 18, 2026
Merged

SSFSKIM merged 11 commits into
mainfrom
board-pr153-fixes

Conversation

@SSFSKIM

@SSFSKIM SSFSKIM commented Oct 18, 2026 •

Copy link
Copy Markdown
Owner

Board ticket #71. PR #153 (ticket #59) merged while its review was still in its first fix wave. The review found eight defects in _predecessor_work, the block a recovery tick writes into a fresh successor's bootstrap about its dead predecessor's worktree, and graded, drilled fixes for all eight. None of them reached the merged branch. They were parked on qa/59-review-wave-1-fixes (head a114651f), and the trail is in PR #153's review-trail comment. This PR re-lands them onto current main, plus one fix the re-land's own review found.

Two of the defects lose work:

  • A second reclaim of one ticket wipes the predecessor's uncommitted work. The successor seat name is deterministic (<ticket>-successor-<lane>), sminos retire removes no worktree, and the harness reuses an existing .claude/worktrees/<name>. Verified again on 2.1.302: Resuming existing worktree at:, and it resets a reused tree only when it is clean and fully upstream. So on a second reclaim the "predecessor's worktree" is the successor's own, and the emitted git fetch … && git reset --hard destroys the very changes the next paragraph asks the reader to judge.
  • A re-filled seat gets no rescue. cmd_fill still re-fills in place with an empty worktree argument (sminos.py cmd_fill, spawn_fresh writes "worktree": worktree or ""), and the seat record's cwd is by then the worktree path. The guard returned on the empty field.

Change (skills/issue-tracker/scripts/_sweep_api.sh and tests/claude-code/board-api/test-sweep-resume.sh only)

  • The eight commits from qa/59-review-wave-1-fixes, cherry-picked unchanged (-x) in their original order. All eight applied cleanly. The predecessor-rescue region on main was byte-identical to the fixes' base f77dabf6, apart from the newly added _gh_read_bounded, so every defect still existed as found:
    • W1-8 551ac760: status --no-optional-locks, so the tick never rewrites the index of a tree it does not own.
    • W1-7 b0d1bf42: push --no-follow-tags, so the refspec is the whole authority on what is published.
    • W1-5 23a951df: the push deadline kills the whole process group (ssh, credential helpers, hooks), and the note claims only "did not confirm".
    • W1-2 c2151acd: the predecessor's worktree is resolved from the path, not the field, and a main checkout is refused by asking git.
    • W1-3 c06d3e96: a detached HEAD still names the work and publishes nothing.
    • W1-4 6a8cbc68: with no base ref the tree is handed over as UNMEASURED, not as zero commits.
    • W1-1 469ab63b: when the successor lands in the predecessor's own worktree, the block says so and emits no command.
    • W1-6 eeda4a1f: the emitted reset pins the full sha the tick verified, not FETCH_HEAD.
  • b4ced77f (new, from this re-land's review): W1-1's check compared against --cwd as given. The harness hangs the worktree off the cwd's git toplevel, and off the main checkout's root when that toplevel is a linked worktree (2.1.302 Zs → Et/br). board-sweep.sh defaults LOCAL_REPO to $PWD, so a tick launched from a subdirectory or from a linked worktree still emitted the destructive reset on a genuine second reclaim. succdir now resolves that same root.
  • e0d62f7d (test only, from the second review round): the drill runs from two launch points, a subdirectory of the main checkout (the toplevel step) and a subdirectory of a linked worktree (the mapping). A single linked-worktree case masked the toplevel half.
  • Version 7.181.0, in b4ced77f. Board dispatch goes dormant: the board is a backlog (7.181.0) #241 has since landed the same number on main, so this needs a re-bump at merge. The only conflict is that one manifest line, in .codex-plugin/plugin.json.

Verification

  • ci-gate at e0d62f7d: GREEN, https://github.com/SSFSKIM/doperpowers/actions/runs/39151020119 (repo-checks, shell-lint, claude-code, issue-tracker, board-api).

  • test-sweep-resume.sh: PASS, 255 ok. That is the reviewed chain's 247 plus the new drill's 8.

  • Each drill fails against its own pre-fix code. For commit i, the test file at i was run with the script at i−1. The counts match the ones recorded in the commit messages:

    item assertions failing without its fix
    W1-8 index 1
    W1-7 followTags 1
    W1-5 process group 5
    W1-2 re-filled seat 5
    W1-3 detached HEAD 5
    W1-4 no base ref 4
    W1-1 second reclaim 5
    W1-6 pinned reset 4
    second reclaim from a linked-worktree subdir (b4ced77f) 3 of its 4 (the fourth shows the drill reaches the shape)
    second reclaim from a main-checkout subdir (e0d62f7d), under a mutation dropping only the toplevel step 3 of its 4, while the linked case stays green
  • Against main's script, the eight drills fail 30 assertions in all.

  • scripts/lint-shell.sh on both files: clean.

  • Independent review (reviewer-high), round 1 on the eight: one P1, the launch-root case, fixed in b4ced77f. Its other finding, the missing version bump, is fixed in the same commit. Round 2 on b4ced77f: the production change is correct against the harness's rule, and one P2 on drill coverage was fixed in e0d62f7d. That commit changes only the test, and its teeth are verified above, so the review stopped there.

Left open (from PR #153's trail, deferred there, not in this PR)

  • The registry claim authenticates its own branch: a stale or hand-edited predecessor record naming a sibling worktree of the same repo passes both guards.
  • remote.origin.pushurl redirection of the predecessor push. Its recovery-correctness half is W1-6.

A plain `git status --porcelain` refreshes the stat cache and REWRITES the
index of the worktree it reads. _predecessor_work makes that read against a
directory the tick does not own, on the strength of a record it explicitly
treats as a claim rather than a proof, while a live process may still be
using that tree and holding its index lock. Every other read in the function
is pure; this one was the exception.

`--no-optional-locks` turns it back into a pure read. The drill touches a
tracked file so the stat cache is genuinely stale (a refreshing read then has
no choice but to write), backdates the index mtime so a rewrite cannot hide
inside the same one-second stamp, and reads the mtime the instant the tick
returns — the suite's own dirty_still assertion runs an ordinary status on
that same tree a few lines later.

(cherry picked from commit e356965)
An explicit `refs/heads/X:refs/heads/X` is not by itself a bound on what the
push publishes. With `push.followTags` set — in the repo, or in the
operator's global config, which every tick on this host inherits — git also
sends the annotated tags reachable from that branch and missing on the
remote. Those tags never passed the "the dispatcher created this branch"
guard the caller takes such care over, and the push is not atomic, so a
REJECTED branch update can leave them published while _push_bounded reports
failure.

`--no-follow-tags` on the push. The ahead drill now sets push.followTags for
the length of that one tick, puts an annotated tag on the predecessor's HEAD,
and asserts the branch lands on origin while the tag does not.

(cherry picked from commit bc770fd)
…less

subprocess.run(timeout=…) kills only the direct `git` child, and git is
rarely the process actually holding the connection: an ssh push spawns `ssh`,
an https push may spawn a credential helper, a pre-push hook spawns whatever
it likes. All of them outlived the deadline — still talking to the sick
remote, still holding what the kill was meant to release — while the function
had already reported the push dead and the caller had moved on.

The child now starts in its own session, so its pid is the group id, and the
SIGKILL goes to the group.

Second half of the same fact: a non-zero result means "did not confirm", not
"did not land". A remote that accepts the update and then stalls is killed
here too and is indistinguishable from one that refused it, so the emitted
note no longer tells the successor "those commits exist only on this host" —
a statement about the remote this side cannot make, and one the recovery does
not need, since the local fetch works either way.

Drill: a pre-push hook that backgrounds a grandchild and then sleeps past a
5s bound (the floor _sweep_api.sh clamps to). Both the hook and its
grandchild are gone when the tick returns; without the group kill both
survive, which is the shape the two new assertions fail in. The nopush drill
now asserts the bounded wording.

(cherry picked from commit 16d92ea)
… field

`sminos fill` re-fills a seat in place and passes an EMPTY worktree argument
on purpose: the seat's cwd is by then the worktree path, so the fresh session
needs no --worktree to land there (sminos.py:1796-1799, spawn_fresh writes
`"worktree": worktree or ""`). The record that leaves behind carries
worktree:"" while sitting in a perfectly ordinary ticket worktree — and the
guard that returned on an empty field skipped its committed AND uncommitted
work entirely, contradicting the comment three lines under it. It is also the
shape a recovery tick meets most often: a seat being reclaimed has usually
been re-filled at least once.

So resolve from the path. A name still resolves through the harness's rule or
as the tail of cwd; an empty name means cwd IS the worktree. The guard's
other job — a seat that genuinely ran in a shared checkout must rescue
nothing — is now asked of git rather than of the field: a linked worktree
keeps its own git dir under the common dir, the main checkout's two are the
same path.

Two drills: a re-filled seat (worktree:"", cwd the worktree) whose branch and
dirty tree are rescued, and a main checkout with its own commits and the
operator's own WIP, which is refused by name in the tick's log and never
appears in the bootstrap. Restoring the old guard fails five assertions
across the two.

(cherry picked from commit 67bd53a)
…overy

Returning on a missing symbolic-ref decided the tree was not worth mentioning
because there was no ref on it to push. Those are different questions, and
the second one is the whole point of this function — the same gap the dirty
read was moved above the ahead-gate to close. A worker reclaimed mid-rebase,
mid-merge or mid-bisect, or one that committed with HEAD detached, had its
commits, its worktree path and its in-progress state all go unnamed, and its
successor started over.

The empty branch is now carried down to where the work has already been
measured. Clean and level still says nothing; dirty still gets the
uncommitted block; commits ahead of the base get a block of their own that
publishes nothing, names the head and the tree, and sends the reader to
`status` before `log` because the usual way into a detached HEAD is an
interruption. It emits no fetch: the common-dir check above has already
established that this worktree and the successor's are linked worktrees of
one repository, so the objects are in the successor's store already.

Drill: two commits on the branch, then --detach, a third commit, and a dirty
file. Restoring the early return fails five assertions.

(cherry picked from commit da7074c)
_base_ref resolves nothing in a repo whose default branch is neither `main`
nor `master` and which publishes no origin/HEAD. `ahead` stayed 0 there, the
gate read that as "level with the base", and a CLEAN worktree holding real
commits went down the silent path — the rescue lost outright and the ticket
redone from the top. The block's wording anticipated the case; the control
flow never reached it.

`ahead` is now empty when there is no yardstick, and the gate requires a
resolved base before it treats a zero as a zero. An unmeasurable tree gets a
handover of its own: the head, the branch if it has one, the uncommitted
state, and the reason there is no number — with nothing published, since a
tick that cannot say what would be published should not publish. It emits no
fetch; the worktrees share one object store.

A zero against a base that DID resolve stays a genuine zero: an empty
`base..HEAD` means every commit HEAD holds is reachable from the base,
whichever candidate won.

Drill: an adopter repo on `trunk` with no origin/HEAD and a clean worktree
one commit in. Restoring the 0 default fails four assertions.

(cherry picked from commit eb7c4fe)
…orktree

The successor seat name is deterministic ($tid-successor-$lane), `sminos
retire` removes neither worktree nor branch, and the harness REUSES an
existing .claude/worktrees/<name> — verified in the bundled CLI, whose create
path returns `existed: true` and cd's into the directory already there, with
no reset when the tree is dirty or carries unmerged commits. So the second
time one ticket is reclaimed, the tree this function describes is the tree
its reader is standing in, and the emitted block was wrong on three counts:
"you were spawned into a FRESH worktree", "checking that branch out will be
refused", and `git reset --hard`, which discards the very uncommitted changes
the next paragraph asks the reader to judge.

The successor's worktree name now rides in as the second argument — the same
value `--worktree` gets at the spawn — and is resolved through the harness's
own name-to-path rule against the same `--cwd`, so this is a comparison with
a known destination rather than a guess. When it matches, the block says the
work is already in the reader's tree, names the commits and the uncommitted
changes, and emits no command at all. The push still runs: durability off
this host is worth the round trip whichever tree the successor lands in.

The "how do you reach that tree" sentence is now one variable with two
values, so the uncommitted, detached and unmeasured blocks stop claiming
"none of it is in your tree" in the case where all of it is.

Drill: a predecessor worktree named exactly 12-successor-implementer with two
commits and a modified TRACKED file — tracked because `reset --hard` reverts
that where it would leave an untracked file alone, which is what makes the
destruction observable. A new run_emitted_whole runs the emitted line WITH
its `&& git reset --hard` tail, which run_emitted_fetch has always stripped;
with the detection disabled, the tracked edit is gone and five assertions
fail.

(cherry picked from commit 95ffa8a)
The block printed the predecessor's head in its prose and then told the
successor to reset onto FETCH_HEAD — whatever the source's branch points at
whenever that line finally runs. Two ways those differ: ordinary drift
between the tick's push and the successor reading its prompt, and a
`remote.origin.pushurl` that differs from `remote.origin.url`, which makes
_push_bounded publish to one repository while `via=origin` fetches from
another. A source carrying an older branch then reset the successor onto a
stale tree in silence.

The reset now names the full sha (full, not the short form: an abbreviation
is something git resolves, and the point of a pin is to be exact), so a
source that has moved on or is not the repository the push reached fails on
an unknown object instead.

Scope: this is the recovery-correctness half only. Whether publication should
follow a pushurl into a foreign repository at all is a separate, deferred
question, and nothing here makes the push conditional on the fetch source.

Drill: the branch is advanced on origin AFTER the tick has spoken, then the
emitted line is run whole in a successor worktree — it lands on the verified
commit, not the drifted one. emitted_fetch's pattern no longer hard-codes
FETCH_HEAD.

(cherry picked from commit a114651)
…e tick's cwd (7.181.0)

The second-reclaim check resolved the successor's destination as
`--cwd` plus .claude/worktrees/<name>, claiming to follow the harness's
own name-to-path rule. It did not: the harness (2.1.302's worktree
create, through its git-root mapping) takes the cwd's git TOPLEVEL and,
when that toplevel is a LINKED worktree whose .git file leads back
through commondir, the main checkout's root — the common dir with its
/.git dropped — and only then appends the worktree path. board-sweep.sh
defaults LOCAL_REPO to $PWD, so a tick launched from a subdirectory, or
from the operator's own linked worktree, passed a cwd that was neither:
`samewt` stayed empty on a genuine second reclaim, and the block emitted
`git fetch … && git reset --hard <sha>` into the very tree whose
uncommitted tracked changes it then asked the reader to judge.

`succdir` now starts from the root the harness would: the toplevel of
${LOCAL_REPO:-$BOARD_ROOT}, replaced by `govern` with its /.git dropped
when that cwd's git dir is not the common dir (the git-native mark of a
linked worktree; a bare repo's common dir is kept whole, as the harness
keeps it). Both canonicalized as before. Checked by hand against a main
checkout, a subdirectory of it, a linked worktree, a subdirectory of
that, and a linked worktree of a bare repo.

Drill: the existing second-reclaim shape, with the tick's LOCAL_REPO
set to a subdirectory of a second linked worktree of the same repo —
one launch point that differs from the root on both counts. predsetup
takes an optional origin name so the drill does not collide with the
first second-reclaim drill's origin. Against eeda4a1's _sweep_api.sh
three of its four assertions fail: the tick never sees the successor
lands in the predecessor's worktree, the emitted command is
`git fetch 'origin' 'worktree-12-successor-implementer' && git reset
--hard <sha>`, and running it leaves `git diff` empty — the tracked
edit is gone. The fourth, that the spawn was handed that cwd, passes
either way and shows the drill reaches the shape. Suite: 251 ok.
b4ced77's drill launched the tick from a subdirectory of a LINKED
worktree and claimed that was the one launch point catching either half
of the resolution going missing. It is not: for a linked worktree the
mapping (`sroot="${govern%/.git}"`) replaces whatever the toplevel step
produced, so with `--show-toplevel` swapped back for the cwd as given,
that launch point still resolves right while a tick launched beneath the
MAIN checkout resolves to <main>/sub/.claude/worktrees/<name>, misses the
match, and emits the destructive reset again — with the drill green.

The drill is now one function run from two launch points, each guarding
one half: a subdirectory of the main checkout (the toplevel step), and a
subdirectory of the operator's own linked worktree (the mapping). Each
asserts the same four things: the spawn was handed that cwd, the tick
sees the successor lands in the predecessor's own worktree, no command
is emitted, and the tracked edit survives.

Teeth: against b4ced77's _sweep_api.sh with only the toplevel step
dropped (sroot = the canonicalized ${LOCAL_REPO:-$BOARD_ROOT} as given,
the linked-worktree mapping kept), three assertions fail, all in the
main-subdir case — lands-in-own-worktree, NO-COMMAND-EMITTED, and the
edit surviving — while all four linked-subdir assertions pass, which is
the masking the single-case drill had. Suite: 255 ok.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant