Skip to content

fix: treat a behind-only .docket copy as healthy and fast-forward it in place (0523) - #394

Merged
danielhanold merged 17 commits into
mainfrom
fix/repository-check-reports-a-behind-only-docket-copy-as-diverg
Oct 5, 2026
Merged

danielhanold merged 17 commits into
mainfrom
fix/repository-check-reports-a-behind-only-docket-copy-as-diverg

Conversation

@danielhanold

@danielhanold danielhanold commented Oct 5, 2026 •

Copy link
Copy Markdown
Owner

↩ Change 0523 — Treat a behind-only .docket copy as healthy and make prepare fast-forward it in place

↩ Change 0523 — Treat a behind-only .docket copy as healthy and make prepare fast-forward it in place

Summary

  • docket repository check now classifies the local .docket copy by ancestry. A clean copy that is only behind origin/docket is healthy. Ahead, diverged, and unknown each get their own finding.
  • Check and prepare share one relationship computation, and their refusal texts match.
  • Prepare fast-forwards .docket in place with a compare-and-swap and hooks off, instead of removing and re-adding the worktree. It refuses over local edits, untracked files in the way, and unfinished Git operations, and rolls back on failure. An ignored file at a newly tracked path follows Git's checkout rule.
  • An interrupted fast-forward gets a dedicated finding whose remedy is git -C .docket reset --merge HEAD, never commit.
  • Attach attaches at the current tip and then fast-forwards, so Git's own checked-out, rebase, and bisect guard decides. A stale .docket registration gets a remedy that names git worktree prune. The attach runs with hooks off.
  • The primary-checkout finding is split by relationship, and the upgrade guide drops its re-run-prepare workaround.

Results: docs/results/2026-10-05-repository-check-reports-a-behind-only-docket-copy-as-diverg-results.md

Review

Whole-branch review, deep tier: 7 findings (0 blocker, 1 important, 6 minor).

# Severity Finding State
1 important The interrupted fast-forward got a "Commit" remedy, which would record a revert of the remote fixed e4a6847
2 minor A current branch held elsewhere was not routed to a refusal; a stale registration should name git worktree prune fixed 506d543
3 minor The branch moved before Git's checked-out, rebase, and bisect guard ran fixed b5ddc9f (attach, then fast-forward; AdvanceBranchChecked removed)
4 minor The holder probe had no real-Git test fixed 506d543
5 minor The fast-forward primitive did not refuse an unfinished operation; no test covered a modified tracked file fixed 506d543
6 minor The upgrade guide's "next docket command" claim was inaccurate fixed 0f5eb7c
7 minor Prepare's attach ran the repository's hooks fixed 506d543

command: go run ./cmd/docket development test
result: green
head_sha: 1649e4f
ran_at: 2026-10-05T13:32:23Z

Docket-Plan-Path: docs/superpowers/plans/2026-10-05-repository-check-reports-a-behind-only-docket-copy-as-diverg.md
The gitcli repo shard (prefix ^TestIntegrationRepo, budget 30s) measured
36s solo on this branch (29s on main) after the new in-place fast-forward,
checked-advance, and replace-blind ancestry tests landed. Per tests/README.md
the shard is split rather than its ceiling raised: the five branch-tip
movement tests move to prefix ^TestIntegrationBranchTip in a new
tests/test_go_integration_gitcli_branchtip.sh shard.

Measured solo after the split (two runs each): gitcli_repo 29s / 28s,
gitcli_branchtip 10s / 9s. The branchtip ceiling is 15s (10s rounded up to
the next multiple of 5 plus the 5s margin, per the runtime-budgets.tsv
seeding rule).

Also names the unfinished-merge and primary ahead/behind scenarios in the
reposynccheck shard header.
…t finish

Review finding: after an in-place fast-forward is killed between update-ref and
read-tree, check and prepare gave the generic metadata-worktree-dirty remedy
beginning "Commit", which would record a revert of remote metadata (spec §3
property 5). worktreeCleanState now detects that state (the branch's newest
reflog entry is the fast-forward's own and the index equals the previous tip's
tree) via gitcli InterruptedFastForward, carries it on WorktreeFact, and both
commands share one message and remedy naming git -C .docket reset --merge HEAD,
never commit.
…s guard decides

Review finding: AdvanceBranchChecked's holder check read only `git worktree
list`, which reports a worktree rebasing or bisecting `docket` as detached and
races a concurrent `worktree add`, so prepare's behind-attach path moved the
branch before Git's own checked-out guard ran -- breaking spec section 5's
"refuse and touch nothing".

prepareAttachFresh now attaches the branch where it stands first (Git's
checked-out/rebase/bisect guard refuses a held branch before anything moves),
applies hooks-off, then advances it in place with FastForwardCheckedOutBranch
(hooks-off compare-and-swap from the observed tip). AdvanceBranchChecked had no
other caller and is removed with its tests; the branchtip shard header no longer
names it. New regression test: a behind docket branch held by a worktree
mid-rebase leaves the branch untouched and .docket unattached.
…in-place fast-forward

- F2: the absent-.docket attach row checks the holder probe for a current
  branch too, not only a behind one, so a held branch refuses with
  docket-worktree-ambiguous-registration instead of applying and failing the
  attach. A holder that is .docket's own leftover registration (directory
  deleted) or one Git lists as prunable names `git worktree prune` in the
  remedy; WorktreeInfo now carries Git's prunable annotation.
- F4: real-git test for prepareAugment's ListWorktrees holder probe
  (TestIntegrationRepoInPlaceFFAttachBehindHeldElsewhereRefuses), plus the
  deleted-.docket prune case.
- F5: FastForwardCheckedOutBranch refuses an unfinished Git operation before
  the compare-and-swap; subtests pin that refusal and the roll-back over a
  modified tracked file on a changed path.
- F7: prepare's attach runs `git worktree add` with docket's empty hooks dir
  (AddBranchWorktreeNoHooks / AttachBranchWorktreeNoHooks), so a failing
  post-checkout hook neither runs nor breaks the attach.
@danielhanold
danielhanold force-pushed the fix/repository-check-reports-a-behind-only-docket-copy-as-diverg branch from 570d7ba to 1649e4f Compare October 5, 2026 13:32
@danielhanold
danielhanold merged commit 13e0a5a into main Oct 5, 2026
1 check passed
@danielhanold
danielhanold deleted the fix/repository-check-reports-a-behind-only-docket-copy-as-diverg branch October 5, 2026 13:33
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