Fix /agent refine no-op for non-gated tasks#
Problem#
/agent refine was falling through to the generic directive handler, which dispatched an event and posted a misleading confirmation comment even when the task was not in a gated state (where refine has no effect).
Task / Link#
Closes #233
Changes#
- Added
refinepre-validation block inDirectiveService.applyDirective()before the generic handler - Terminal tasks (
succeeded/failed): post rejection comment, no dispatch/enqueue - Non-gated tasks: post rejection comment with current status, no dispatch/enqueue
- Gated tasks only: clear gate, save, enqueue
refinephase, post confirmation - Replaced single
refinetest withdescribe('refine directive')block covering 5 scenarios
Notes#
task.directiveis not overwritten — preservesauto/careful/quickthrough the refine flowclearGateis called beforeenqueuePhase, matching the existing retry/restart pattern
Testing#
- Unit tests: new
describe('refine directive')block with 5 tests (gated ✓, active ✗, succeeded ✗, failed ✗, directive-preserved ✓) - Full suite: 665 tests pass
- Lint: zero errors in changed files
- Build: compiles cleanly