Skip to content

feat(worktree): portable create-worktree.sh + Bug 1 base-ref fix (I-phase) - #300

Merged
artyhoo merged 1 commit into
stagingfrom
feat/create-worktree-portable
May 30, 2026
Merged

feat(worktree): portable create-worktree.sh + Bug 1 base-ref fix (I-phase)#300
artyhoo merged 1 commit into
stagingfrom
feat/create-worktree-portable

Conversation

@artyhoo

@artyhoo artyhoo commented May 30, 2026

Copy link
Copy Markdown
Owner

What

I-phase for the dual-channel worktree-create capability (verdict combo b+c, R-phase merged PR #297 / patch 2026-05-30-worktree-create-dual-channel.md).

  • (b) BUILD scripts/create-worktree.sh — portable, CLI/CI/non-CC-agent-callable worktree setup. <name> [<project-dir>] [<base-ref>]; mirrors the CC hook's semantic check, reads CLI args instead of JSON stdin, no jq dep. Symlinks node_modules per the D2 workspace-optimisation pattern.
  • Bug 1 fix in .claude/hooks/worktree-setup.shgit remote set-head origin --auto before the base-ref loop. A stale local origin/HEAD (frozen at main, pre the 2026-05-22 staging migration) silently based new worktrees on the wrong branch.
  • (c) REFERENCE Superpowers using-git-worktrees (SSOT feat(skill-drift): multi-channel drift detection from D-AuditC-5 #65) for the AI-session axis — unchanged; BUILD serves the orthogonal human/CI axis.

Cold-QA findings from the R-phase, addressed

  • Finding 1 (configurable trunk): base-ref resolution is explicit arg → $WORKTREE_BASE_REF → refreshed origin/HEAD → fallback chain. No hardcoded origin/staging — refreshing origin/HEAD resolves to whatever the remote's actual default is (staging here, main for a consumer), so it's portable without knowing the name.
  • Finding 2 (marker replace, not delete): hook's @cc-only-rationale@dual-pair: worktree-create-setup. A portable equivalent now exists, so @cc-only-rationale is factually wrong (dual-implementation-discipline.md §6). This is the first dual-channel pair in the repo.

Empirical evidence

Bug 1 reproduced live this session:

$ git symbolic-ref refs/remotes/origin/HEAD          → refs/remotes/origin/main   (stale)
$ git remote set-head origin --auto && git symbolic-ref refs/remotes/origin/HEAD → refs/remotes/origin/staging  (fixed)

Tests (paired-negative discipline, principle 02)

  • create-worktree.test.ts — 11 cases: happy path, both symlinks, branch naming, idempotency, single-line stdout, explicit base-ref, $WORKTREE_BASE_REF, default project-dir, + 2 paired-negatives (missing name, non-existent base-ref).
  • worktree-setup.test.ts — new BUG-1 regression building a temp repo with a deliberately-stale origin/HEAD; fails on the unfixed hook (worktree based on main), passes on the fix (staging).

Verification

  • npx vitest run worktree-setup + create-worktree + check-hook-marker → 29 passed
  • All principle meta-tests → 157 passed (also green in pre-push)
  • shellcheck both scripts → clean
  • Pre-existing baseline tsc error in audit-self/audit-ai-docs.ts:67 (remark types) is unrelated and present on origin/staging.

Scope-out / notes

  • scripts/create-worktree.sh is not shipped to consumers via install.sh (repo-internal dev tooling) and is outside packages/, so it's not a capability commit by the pre-push detector — the Prior-art: trailer is added per patch §5 mandate regardless.
  • The dual-implementation §5 drift-grep scans agents/ + .claude/skills/ for a @dual-pair counterpart, not scripts/. No CI gate exists for it (promotion deferred per §9), so no mechanical failure; flagging for awareness if that grep is ever promoted.

… base-ref fix

Implements the dual-channel worktree-create capability (verdict combo b+c) from
the 2026-05-30 R-phase. Two delivery channels share the `worktree-create-setup`
dual-pair anchor:

(b) BUILD scripts/create-worktree.sh — portable CLI/CI/agent-callable worktree
    setup. Accepts <name> [<project-dir>] [<base-ref>]; mirrors the hook's
    semantic check but reads CLI args instead of JSON stdin. No jq dependency.
    Base-ref is configurable (explicit arg → $WORKTREE_BASE_REF → refreshed
    origin/HEAD → fallback chain) — no hardcoded trunk name, per cold-QA
    Finding 1.

Bug 1 fix (.claude/hooks/worktree-setup.sh): `git remote set-head origin --auto`
before the base-ref candidate loop. A stale local origin/HEAD (frozen at main,
pre the 2026-05-22 staging migration) was silently basing new worktrees on the
wrong branch. Reproduced empirically this session: origin/HEAD pointed at
origin/main; --auto corrected it to origin/staging.

Marker: swapped the hook's @cc-only-rationale → @dual-pair worktree-create-setup
(a portable equivalent now exists; dual-implementation-discipline.md §6 + patch
§6.3 / cold-QA Finding 2). First dual-channel pair in the repo.

Tests (paired-negative discipline, principle 02): create-worktree.test.ts (11
cases incl. configurable base-ref + 2 paired-negatives); worktree-setup.test.ts
gains a BUG-1 regression that fails on the unfixed hook (stale origin/HEAD →
main) and passes on the fix (→ staging).

(c) REFERENCE Superpowers `using-git-worktrees` (SSOT #65) for the AI-session
    axis — unchanged; this BUILD serves the orthogonal human/CI axis.

Prior-art: docs/meta-factory/research-patches/2026-05-30-worktree-create-dual-channel.md (BUILD verdict for scripts/create-worktree.sh — BFR §3 6-layer survey, 4 candidates surveyed, no portable bash equivalent upstream) + SSOT #65 (Superpowers using-git-worktrees, ADOPT — AI-session axis only, REFERENCE here).
@artyhoo
artyhoo enabled auto-merge (squash) May 30, 2026 05:16
@artyhoo
artyhoo merged commit d297221 into staging May 30, 2026
22 checks passed
artyhoo added a commit that referenced this pull request May 30, 2026
…te + SSOT #87 (#301)

Follow-up to PR #300 (worktree-create dual-channel I-phase core). Wires the
shipped capability into the discipline surfaces that point at it:

- parallel-subwave-isolation.md §1: replace the raw `git worktree add ... main`
  block (a stale-base footgun since the 2026-05-22 staging migration — Bug 1's
  class) with `bash scripts/create-worktree.sh <name>`, plus a Bug 1 note on why
  base-ref must come from refreshed origin/HEAD, never a hard-coded branch.
- meta-kickoff.template.md §4: non-CC / unwired-hook fallback now points at the
  portable script instead of the manual git-worktree path.
- prior-art-evaluations.md: new SSOT row #87 (worktree-create dual-channel,
  verdict BUILD + REFERENCE #65; 4-candidate adversarial survey, T16 check,
  first dual-channel pair → dual-implementation-discipline.md §9 counter = 1).

Closes I-phase items 4/5/7 from the worktree-create-dual-channel umbrella.

Prior-art: skipped — doc-wiring only (rule/template/SSOT pointers to PR #300's already-evaluated capability), no new capability artifact in this commit.
artyhoo added a commit that referenced this pull request May 31, 2026
…acks

SKILL.md dispatch matrix (parallel-build fallback) + meta-orch I-phase
worktree step + references/placeholders.md DISPATCH_INSTRUCTIONS now name the
portable `bash scripts/create-worktree.sh <name>` (refreshes origin/HEAD —
Bug 1 fix, shipped PR #300) alongside the raw `git worktree add` manual
fallback. Closes the doc residual flagged in the Bug 1 I-phase backward-check.
Inline-code references only (no markdown links — dead-link checker clean).

Prior-art: skipped — doc edit wiring an existing capability (scripts/create-worktree.sh, PR #300), no new capability.
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