{
"meta": {
"agent": "planner",
"task_id": "267",
"title": "Return main repo to master after phase execution",
"created_at": "2026-04-03T12:00:00Z"
},
"inputs": [
{
"name": "issue-267",
"type": "context",
"ref": "https://github.com/AgentSDE/agent-core/issues/267",
"notes": "Post-phase cleanup to reset main repo branch"
},
{
"name": "phase-router.service.ts",
"type": "file",
"ref": "src/phase-router/phase-router.service.ts",
"notes": "Contains executePhase() finally block (lines 427-438) — cleanup target"
},
{
"name": "worktree.service.ts",
"type": "file",
"ref": "src/worktree/worktree.service.ts",
"notes": "Has exec() helper and REPOS_DIR resolution — host for new resetToMaster method"
}
],
"outputs": [
{
"name": "plan",
"type": "spec",
"format": "md",
"content": "plan.md"
}
],
"files": [
{
"path": "src/worktree/worktree.service.ts",
"action": "modify",
"reason": "Add resetToMaster(repo) method"
},
{
"path": "src/phase-router/phase-router.service.ts",
"action": "modify",
"reason": "Call resetToMaster in finally block when !worktreePath"
},
{
"path": "src/phase-router/phase-router.service.spec.ts",
"action": "modify",
"reason": "Test resetToMaster integration in executePhase"
},
{
"path": "src/worktree/worktree.service.spec.ts",
"action": "modify",
"reason": "Test resetToMaster unit behavior"
}
],
"steps": [
{
"id": "S1",
"summary": "Add resetToMaster() method to WorktreeService",
"acceptance": [
"WorktreeService has a public resetToMaster(repo: string) method",
"Method runs git checkout master in the main repo path (REPOS_DIR/repoName)",
"Method catches errors and logs a warning — never throws"
],
"depends_on": []
},
{
"id": "S2",
"summary": "Call resetToMaster in PhaseRouterService finally block when no worktree",
"acceptance": [
"executePhase finally block calls worktree.resetToMaster(task.repo) when !worktreePath",
"Call is wrapped in try/catch — failure logs warning, does not mask phase result",
"Existing worktree cleanup for isolated worktrees is unchanged"
],
"depends_on": [
"S1"
]
},
{
"id": "S3",
"summary": "Add unit tests for reset-to-master behavior",
"acceptance": [
"phase-router spec: resetToMaster called after non-worktree phase completes",
"phase-router spec: resetToMaster error is caught and logged, not thrown",
"worktree spec: resetToMaster calls git checkout master with correct cwd",
"worktree spec: resetToMaster failure logs warning and does not throw",
"npm run test passes",
"npm run lint passes"
],
"depends_on": [
"S1",
"S2"
]
}
],
"risks": [
{
"risk": "git checkout master fails due to uncommitted changes in main repo",
"mitigation": "Error is caught and logged as warning — does not mask original phase result"
}
],
"assumptions": [
"The main repo default branch is master (consistent with CLAUDE.md and worktree.service.ts origin/master references)",
"WorktreeService.exec() is the appropriate helper for running git commands"
],
"open_questions": []
}