{
"meta": {
"agent": "planner",
"task_id": "233",
"title": "Fix /agent refine directive no-op for non-gated tasks",
"created_at": "2026-04-02T12:00:00Z"
},
"inputs": [
{
"name": "issue-233",
"type": "context",
"ref": "https://github.com/AgentSDE/agent-core/issues/233",
"notes": "Bug: /agent refine posts misleading confirmation when task is not gated"
},
{
"name": "directive.service.ts",
"type": "file",
"ref": "src/directive/directive.service.ts",
"notes": "Current refine falls through to generic handler — no status validation"
},
{
"name": "phase-router.service.ts",
"type": "file",
"ref": "src/phase-router/phase-router.service.ts",
"notes": "resolvePhase returns null for refine on non-gated tasks (line 506)"
},
{
"name": "AGENTS.md",
"type": "context",
"ref": "AGENTS.md",
"notes": "Directive system rules — two wiring points, transient directives preserve task.directive"
}
],
"outputs": [
{
"name": "plan",
"type": "plan",
"format": "md",
"content": "plan.md"
}
],
"files": [
{
"path": "src/directive/directive.service.ts",
"action": "modify",
"reason": "Add refine pre-validation block with gated-only guard and rejection comments"
},
{
"path": "src/directive/directive.service.spec.ts",
"action": "modify",
"reason": "Add unit tests for refine gated/non-gated/terminal scenarios"
}
],
"steps": [
{
"id": "S1",
"summary": "Add refine pre-validation guard in DirectiveService.applyDirective()",
"acceptance": [
"Refine on gated task: clears gate, enqueues refine phase, posts confirmation comment",
"Refine on non-gated task (active/paused/stuck/blocked): posts rejection comment with task status",
"Refine on terminal task (succeeded/failed): posts terminal rejection comment",
"Refine does not overwrite task.directive — preserves existing auto/careful/quick",
"No dispatch event created for rejected refine directives"
],
"depends_on": []
},
{
"id": "S2",
"summary": "Add unit tests for refine directive validation in directive.service.spec.ts",
"acceptance": [
"Test: gated task routes to refine phase (clearGate called, enqueuePhase called with 'refine')",
"Test: active task posts rejection, no dispatch/enqueue",
"Test: succeeded task posts terminal rejection, no dispatch/enqueue",
"Test: failed task posts terminal rejection",
"Test: refine preserves existing task.directive value",
"All existing tests continue to pass"
],
"depends_on": [
"S1"
]
}
],
"risks": [
{
"risk": "Gate not cleared before enqueue could cause re-gating in phase-router",
"mitigation": "Call taskStateService.clearGate(task) before enqueuePhase, matching retry/restart pattern"
}
],
"assumptions": [
"clearGate sets status='active' and nulls gatePhase/gateReason — consistent with existing usage in tests",
"internalAdapterService.enqueuePhase('refine') produces a phase_refine event that resolves to 'refine' phase in phase-router (confirmed at line 436)"
],
"open_questions": []
}