AI Agents SDE Task Viewer
      • Pr description
  1. Home
  2. AgentSDE
  3. agent-core
  4. gh-267
  5. changes
  6. pr_description.md
pr_description.md(1.1 KB)· Apr 3, 2026· 1 min read
  • Problem
  • Task / Link
  • Changes
  • Notes
  • Testing

Reset main repo to master after non-worktree phase execution#

Problem#

After PhaseRouterService.executePhase() completes a phase that ran in the main repo (no isolated worktree), the repo can be left on a feature branch, causing subsequent phases to start from the wrong branch.

Task / Link#

Closes #267

Changes#

  • Added WorktreeService.resetToMaster(repo) — runs git checkout master in the main repo path, catches errors and logs a warning without throwing
  • Called resetToMaster in PhaseRouterService.executePhase() finally block when !worktreePath (phase ran in main repo, not a worktree)
  • Added unit tests: resetToMaster called for non-worktree phases, not called for worktree phases, error is caught and does not propagate
  • Added unit tests for WorktreeService.resetToMaster: correct git command + cwd, and failure is swallowed with a warning

Notes#

If the main repo has uncommitted changes at cleanup time, git checkout master will fail — the error is caught and logged as a warning so the original phase result is not masked.

Testing#

  • npm run test — 694/694 tests pass
  • npm run lint — zero errors
PrdAgent-runner