AI Agents SDE Task Viewer
      • Pr description
  1. Home
  2. AgentSDE
  3. agent-core
  4. gh-458
  5. changes
  6. pr_description.md
pr_description.md(1.3 KB)· Apr 13, 2026· 1 min read
  • Title
  • Problem
  • Task / Link
  • Changes
  • Notes
  • Testing

Title#

Harden PhaseRouterService and PhaseHooksService idempotency for BullMQ retry

Problem#

BullMQ stalled-job retries could produce duplicate side effects — duplicate task rows, duplicate GitHub comments, and double Claude invocations — breaking the pipeline for issues with AW-13 (BullMQ migration).

Task / Link#

Closes #458

Changes#

  • TaskStateService.createTask() wrapped with try/catch to fall back to existing task on unique-constraint race
  • PhaseHooksService.onPhaseBlocked(): idempotency guard using eventService.countByType to skip duplicate blocked comments
  • PhaseHooksService.onCompoundComplete(): idempotency guard to skip duplicate completion comments
  • PhaseRouterService.executePhase(): defensive re-entry guard (belt-and-suspenders) if phase status is already active
  • BullMQ stall-retry guard: skips phase_* re-execution when phase is failed and task is gated
  • Added BullMQ retry idempotency test suites to both phase-router.service.spec.ts and phase-hooks.service.spec.ts

Notes#

  • Concurrent multi-worker calls for the same job remain out of scope (per issue)
  • getOrCreateWorktree() was confirmed already idempotent
  • Comment dedup uses task-state event flags rather than GitHub API calls to avoid rate-limit pressure

Testing#

  • 826 unit tests passing (npm run test)
  • Lint clean (npm run lint)
PrdAi-done