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

@@ -16,7 +16,7 @@
"agents/gsd-domain-researcher.md": "049f588663814fa2",
"agents/gsd-eval-auditor.md": "54870d3b07433525",
"agents/gsd-eval-planner.md": "552e9fa164c51ce8",
"agents/gsd-executor.md": "1154cdd7b22f9754",
"agents/gsd-executor.md": "98424ccf4346c9d1",
"agents/gsd-framework-selector.md": "8a795f230436ad2e",
"agents/gsd-integration-checker.md": "c1760a0bbd4f7bf5",
"agents/gsd-intel-updater.md": "944f1d903e2e9e09",
@@ -232,7 +232,7 @@
"gsd-core/references/verification-patterns.md": "72f4d4814fdae9a8",
"gsd-core/references/verify-mvp-mode.md": "534bdc7f2432903a",
"gsd-core/references/workstream-flag.md": "ca99ca79e716f0f5",
"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": "efa1f8354bd3a24b",
"gsd-core/templates/DEBUG.md": "c8768312f4c1e438",
@@ -318,13 +318,13 @@
"gsd-core/workflows/docs-update.md": "a320371be70f43d8",
"gsd-core/workflows/edit-phase.md": "966a3eadd1bebc04",
"gsd-core/workflows/eval-review.md": "32d3d7e80ab2bfc7",
"gsd-core/workflows/execute-phase.md": "479ea9fcfe74e8f8",
"gsd-core/workflows/execute-phase.md": "0e1e8e5e3fa63587",
"gsd-core/workflows/execute-phase/steps/codebase-drift-gate.md": "f7782680c2b8ad6b",
"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": "beedb5ddff997b5a",
"gsd-core/workflows/execute-plan.md": "4f43b65cf80d8f2e",
"gsd-core/workflows/explore.md": "3f3b4f83e23349bc",
"gsd-core/workflows/extract-learnings.md": "b6f01ca3d8f58de4",
"gsd-core/workflows/fast.md": "11f5cd10ae5cc7d3",