fix(#1995): widen worktree branch regex to accept agent-<id> namespace (#2548)

* test(#1995): regression test for agent-<id> branch namespace

Add failing-first tests proving that normalizeCleanupManifestEntry and
planWorktreeRecordAgent reject Claude Code's current agent-<id> isolation
branches (only worktree-agent-<id> is accepted). Boundary tests cover both
namespaces plus rejection cases.

* fix(#1995): widen worktree branch regex to accept agent-<id> namespace

Claude Code's isolation="worktree" branch naming changed from
worktree-agent-<id> to agent-<id>. Widen the regex in all 7 locations
from ^worktree-agent-[A-Za-z0-9._/-]+$ to ^(worktree-)?agent-[A-Za-z0-9._/-]+$
so both namespaces are accepted. Introduce a shared WORKTREE_AGENT_BRANCH_RE
constant in src/worktree-safety.cts to prevent future drift.

Closes #1995

* fix(#1995): update workflow guards, test assertions, and baselines

Widen the branch-check regex in execute-phase.md and execute-plan.md.
Update all test assertions that checked for ^worktree-agent- to expect
the widened ^(worktree-)?agent- pattern. Regenerate golden-install-parity
fixtures, agent-size-baseline, and workflow-size-baseline.

Closes #1995

* fix(#1995): update extractCwdGuardBash sanity check for widened regex

The e2e test's sanity check verified the extracted bash block contained
'worktree-agent-'. After widening to '(worktree-)?agent-', update the
check to match the new pattern.

* fix(#1995): widen missed workflow-guard branch check + changeset + lint fixes

- hooks/gsd-workflow-guard.js: widen startsWith('worktree-agent-') to
  /^(worktree-)?agent-/ regex — same defect class, was missed in prior commit
- tests/worktree.test.cjs: fix indentation regression from prior edit
- Add .changeset/1995-worktree-agent-branch-namespace.md (pr:0 placeholder)

Found by orthogonal code review (Step 4).

* fix(#1995): regenerate golden + size baselines for workflow-guard change

* docs(#1995): backfill changeset PR number (2548)
This commit is contained in:
Tom Boucher
2026-07-23 07:36:53 -04:00
committed by GitHub
parent 4fc89497d0
commit 77bf21b3a6
33 changed files with 254 additions and 140 deletions

View File

@@ -102,8 +102,8 @@
"agents/gsd-eval-auditor.toml": "9b81d61b3c5f722d",
"agents/gsd-eval-planner.md": "73f2ad2ff2797a51",
"agents/gsd-eval-planner.toml": "09468ad1a34ac468",
"agents/gsd-executor.md": "45442cc002be7052",
"agents/gsd-executor.toml": "bfb08e9397bcc358",
"agents/gsd-executor.md": "697b7ed099fff17d",
"agents/gsd-executor.toml": "9a8aa31bbde42448",
"agents/gsd-framework-selector.md": "ebae32430887d2e0",
"agents/gsd-framework-selector.toml": "637e4e021b7ec380",
"agents/gsd-integration-checker.md": "9cc875676cf7d741",
@@ -267,7 +267,7 @@
"gsd-core/references/verification-patterns.md": "ac45d99076067f17",
"gsd-core/references/verify-mvp-mode.md": "78faa99df1668aab",
"gsd-core/references/workstream-flag.md": "c764d9cbdf6faff4",
"gsd-core/references/worktree-branch-check.md": "21d9c31bf6542b93",
"gsd-core/references/worktree-branch-check.md": "161547f45f78c2bd",
"gsd-core/references/worktree-path-safety.md": "3c8d74756f9b16a8",
"gsd-core/templates/AI-SPEC.md": "6411a4789f481c15",
"gsd-core/templates/DEBUG.md": "0be1256352e79375",
@@ -353,13 +353,13 @@
"gsd-core/workflows/docs-update.md": "bf32efe90219d3dd",
"gsd-core/workflows/edit-phase.md": "e592a4d85ce5380f",
"gsd-core/workflows/eval-review.md": "c89a63285ead961e",
"gsd-core/workflows/execute-phase.md": "4528ce2e8ac92566",
"gsd-core/workflows/execute-phase.md": "e5b9fb391a90d7fb",
"gsd-core/workflows/execute-phase/steps/codebase-drift-gate.md": "cd8678d082d6e191",
"gsd-core/workflows/execute-phase/steps/per-plan-worktree-gate.md": "7ebb7d1af6082028",
"gsd-core/workflows/execute-phase/steps/post-merge-gate.md": "7b2d9a4a4013fd6a",
"gsd-core/workflows/execute-phase/steps/regression-gate.md": "7a49bc47da5411ea",
"gsd-core/workflows/execute-phase/steps/worktree-recovery-policy.md": "be84efbd71e1513e",
"gsd-core/workflows/execute-plan.md": "13bc99f22bc5ec10",
"gsd-core/workflows/execute-plan.md": "e4723e1669f7c508",
"gsd-core/workflows/explore.md": "d12f68770c65093a",
"gsd-core/workflows/extract-learnings.md": "f716aa03fcb5f8da",
"gsd-core/workflows/fast.md": "e4ed60f96a7b3ac8",