Plan: Fix /agent refine no-op for non-gated tasks#
Summary#
Add pre-validation to the refine directive in DirectiveService.applyDirective() so it only executes for gated tasks and posts explicit rejection comments for all other states — eliminating the misleading confirmation comment that currently appears even when no phase transition occurs.
Files#
| File | Action | Description |
|---|---|---|
src/directive/directive.service.ts | modify | Add refine guard block before generic handler (lines 96–121) |
src/directive/directive.service.spec.ts | modify | Add tests for gated/non-gated/terminal refine scenarios |
Steps#
- Add
refinepre-validation block indirective.service.ts— Insert a newif (directive === 'refine')block after therestarthandler (line 89) and before the generic handler (line 96). Check terminal states (succeeded,failed) → post rejection with terminal message. Checktask.status !== 'gated'→ post rejection with status message. For gated tasks: clear gate viataskStateService.clearGate(task), save, enqueuerefinephase viainternalAdapterService.enqueuePhase(), post confirmation, return. - Update
directive.service.spec.tswith refine test cases — Replace the existingrefine: sets directive and dispatchestest (line 143) with adescribe('refine directive')block containing: (a) gated task succeeds — clears gate, enqueues refine phase, posts confirmation; (b) active task → posts rejection, no dispatch; (c) succeeded task → posts terminal rejection, no dispatch; (d) failed task → posts terminal rejection; (e) refine does not overwritetask.directive(preserves existingcareful/auto).
Verification#
npm run test— all unit tests pass including new refine scenariosnpm run lint— zero warningsnpm run build— compiles cleanly
Risks#
- The
clearGatemethod must be called before enqueuing to prevent re-gating; this mirrors the pattern used byresetForRetry/resetForRestartin the existing retry/restart handlers.