Skip to content

Call every adapter before cdd-worktree-done removes the worktree - #125

Merged
drabaioli merged 3 commits into
mainfrom
worktree_done_adapter_order
Oct 4, 2026
Merged

drabaioli merged 3 commits into
mainfrom
worktree_done_adapter_order

Conversation

@drabaioli

Copy link
Copy Markdown
Owner

Summary

  • cdd-worktree-done resolved the code-host and tracker adapters from the feature worktree's own .cdd/, removed that worktree, then called them through the deleted path (exit 127): squash-merged branches fell to the keep/delete/abort prompt and issues were never closed.
  • Reordered: after the pull, done decides the branch's fate and closes the issues, then removes the worktree, deletes the branch and reaps. The branch's own binding (validated up front) stays authoritative; main's is never consulted. An abort at the prompt now leaves the worktree in place.
  • Since issues now close before removal, a locked worktree is refused up front (before the cd or any adapter call). Other removal failures (declined sudo, "not a working tree") say the close already ran and a re-run is safe, instead of "Nothing was deleted".
  • gc and resume confirmed unaffected (run from main, remove no worktree).

Tests

scripts/worktree-done-assert.sh gains project-rung cases (adapters bound via relative .cdd/ symlinks into the feature worktree): squash-merged, ancestry-merged with refs, locked, and removal-fails-after-close. Each fails on the previous helper. ./scripts/ci.sh: 26/26 pass.

Docs

doc/architecture/shell-helpers.md (teardown order, lock refusal, tracker close timing); one sentence in process doc §2.8. No template edit: the template ships no copy of the helper. No roadmap edit (off-roadmap regression fix).

Closes #124

🤖 Generated with Claude Code

https://claude.ai/code/session_01DMH8wdKGv4rHqyWzQHjmSD

drabaioli and others added 2 commits October 4, 2026 19:59
cdd-worktree-done resolved the code-host and tracker adapters from the
feature worktree's own .cdd/ (the project rung), removed that worktree,
and only then asked pr-merged and closed the issues through the deleted
path (exit 127): squash-merged branches fell to the prompt and issues
were never closed.

Reorder: after the pull, decide the branch's fate (ancestry, pr-merged,
the prompt) and close the issues, then remove the worktree, delete the
branch and reap. The branch's own binding, validated up front, stays
authoritative. An abort at the prompt now leaves the worktree in place.

worktree-done-assert gains project-rung cases (adapters bound through
relative .cdd/ symlinks into the worktree), which fail on the old order.
No template edit: the template ships no copy of the helper.

Closes #124

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01DMH8wdKGv4rHqyWzQHjmSD
Issues now close before the worktree is removed, so a removal that
fails afterwards left them closed under a "Nothing was deleted" line.
A locked worktree, the foreseeable failure, is now refused up front,
before the cd and any adapter call. For the rest (a declined sudo, a
path git says is not a working tree) the message says the close
already ran and a re-run is safe.

worktree-done-assert gains both cases at the project rung; each fails
on the previous helper.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01DMH8wdKGv4rHqyWzQHjmSD

@drabaioli drabaioli left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR add 209 lines for a fix. trim/compress/simplify as possible while keeping the fix correctness

Review on #125: 209 lines for a fix. Keep the reorder (every adapter call
before the worktree is removed) and drop what it does not need:

- the locked-worktree pre-check: closing issues for a confirmed merged PR
  is right even if the removal then fails, and a re-run is idempotent; a
  lock fails at removal with git's message, as before
- the closed_note messaging: the "issue #N: closed" lines already print
  just above any removal failure
- three of the four project-rung test cases (ancestry is covered by the
  machine-rung cases; lock and closed_note are gone) and their helpers
- comment and doc verbosity

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01DMH8wdKGv4rHqyWzQHjmSD
@drabaioli

Copy link
Copy Markdown
Owner Author

Re the review summary (trim/simplify): addressed in 4f78a6a — the PR now adds 101 lines (from 209), most of them the removal block moving below the adapter calls. Dropped the locked-worktree pre-check and the "close already ran" messaging (a merged PR's issues are right to close even if removal then fails, and a re-run is idempotent), kept one project-rung test case, and compressed comments and docs.

@drabaioli
drabaioli merged commit b9aa973 into main Oct 4, 2026
2 checks passed
@drabaioli
drabaioli deleted the worktree_done_adapter_order branch October 4, 2026 21:14
drabaioli added a commit that referenced this pull request Oct 6, 2026
…date (#126)

* Keep the installed CDD helpers current: sync on pull, self-reload, update

The install is a copy, so a merged helper fix changed nothing on the
machine until someone re-ran install (the #124/#125 incident), open
shells kept the old functions, and a curl install had no way to update.

- Sync on pull: install, run from a CDD git checkout, writes a managed
  post-merge + post-rewrite hook into it. A pull that lands on the
  default branch with different helpers or adapters (cmp, never a
  version stamp) reinstalls both and prints one line. Other branches,
  amends and unchanged pulls do nothing. A foreign hook is never
  overwritten; under core.hooksPath nothing is written (both noted).
- Self-reload: each public cdd-worktree* / cdd-state call re-sources
  its file when it changed on disk and re-dispatches, silently.
- `bash ~/.cdd/tools/cdd-worktree.sh update`: on demand, a sparse
  blobless clone of upstream main's tools/; installs when it differs.
  cdd-state's unknown-verb / invalid-stage errors and the plan_written
  skew warning name it. The dispatch now exits explicitly, since update
  overwrites the script bash is running.

New toolchain-sync gate (27 gates). install-smoke and adapter-bindings
install from a non-git copy of tools/, so a check run never hooks the
developer's checkout. Process doc §2.8, shell-helpers.md, ADR 0014,
template BOOTSTRAP.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JyhD5C5M5Vsi6k7jzdzEwS

* Reconcile README: how the installed helpers stay current

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JyhD5C5M5Vsi6k7jzdzEwS

* Compress shell-helpers.md "Staying current" (PR #126 review)

Trim the section to its invariants; mechanics stay in the code comments
and the rationale in ADR 0014.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JyhD5C5M5Vsi6k7jzdzEwS

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
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.

cdd-worktree-done calls adapters from the feature worktree after removing it

1 participant