{
"meta": {
"agent": "planner",
"task_id": "276",
"title": "Fix worktree reuse path destroying committed agent work",
"created_at": "2026-04-03T17:10:00Z"
},
"inputs": [
{
"name": "issue-276",
"type": "context",
"ref": "https://github.com/AgentSDE/agent-core/issues/276",
"notes": "p0 data-loss bug: reset --hard in worktree reuse path destroys agent commits"
},
{
"name": "worktree.service.ts",
"type": "file",
"ref": "src/worktree/worktree.service.ts",
"notes": "Lines 97-106 contain the buggy reuse path with reset --hard"
},
{
"name": "worktree.service.spec.ts",
"type": "file",
"ref": "src/worktree/worktree.service.spec.ts",
"notes": "Line 145 test asserts reset --hard as correct — needs inversion"
}
],
"outputs": [
{
"name": "plan",
"type": "plan",
"format": "md",
"content": "plan.md"
}
],
"files": [
{
"path": "src/worktree/worktree.service.ts",
"action": "modify",
"reason": "Remove reset --hard from worktree reuse path"
},
{
"path": "src/worktree/worktree.service.spec.ts",
"action": "modify",
"reason": "Update test to assert reset --hard is NOT called on reuse"
}
],
"steps": [
{
"id": "S1",
"summary": "Remove git reset --hard from worktree reuse path and update the unit test to assert it is not called",
"acceptance": [
"git reset --hard origin/master is not called when worktreeReused is true",
"git fetch origin is still called in the reuse path",
"Unit test asserts reset --hard is NOT called on worktree reuse",
"npm run test passes",
"npm run lint passes"
],
"depends_on": []
}
],
"risks": [
{
"risk": "Minimal — 3-line deletion in a single code path",
"mitigation": "Existing tests for fresh-create and branch-attach paths remain unchanged"
}
],
"assumptions": [
"The reuse path should never reset to origin/master — the branch HEAD represents agent work that must be preserved"
],
"open_questions": []
}