AI Agents SDE Task Viewer
      • Context
      • Plan
      • Prd
  1. Home
  2. AgentSDE
  3. agent-core
  4. gh-236
  5. plan
  6. plan.md
plan.md(2.1 KB)· Apr 2, 2026· 2 min read
  • Summary
  • Files
  • Steps
  • Verification
  • Risks

Plan: Fix MetricsSummary successRate and add inProgressCount#

Summary#

The computeSummary method in MetricsService already uses a terminal-only denominator (complete + failed + stopped + stuck), but the MetricsSummary interface lacks an inProgressCount field for in-flight tasks (blocked + gated). This plan adds that field, adds the required code comment at the zero-denominator guard, and extends tests to cover the corrected formula and edge cases.

Files#

FileActionDescription
src/metrics/metrics.types.tsmodifyAdd inProgressCount: number to MetricsSummary interface
src/metrics/metrics.service.tsmodifyCompute inProgressCount from blocked + gated, add code comment at zero-denominator guard
src/metrics/metrics.service.spec.tsmodifyAdd tests for inProgressCount, zero-terminal edge case, and the issue's exact scenario (27/45 ≈ 0.60)

Steps#

  1. Add inProgressCount: number field to the MetricsSummary interface in metrics.types.ts.
  2. In metrics.service.ts computeSummary(), compute inProgressCount as (byStatus['blocked'] ?? 0) + (byStatus['gated'] ?? 0) and include it in the return object.
  3. Add inline comment // successRate is 0.0 when no terminal tasks exist at the zero-denominator guard (line 89).
  4. In metrics.service.spec.ts, add test: given 27 complete, 10 failed, 5 stopped, 3 stuck, 23 blocked, 15 gated → successRate ≈ 0.60 and inProgressCount === 38.
  5. Add test: when all tasks are blocked/gated (zero terminal), successRate === 0.0 and inProgressCount equals total task count.
  6. Update the existing zero-tasks test to assert inProgressCount === 0.

Verification#

  • npm run test passes with all new and existing tests green.
  • npm run lint passes with zero warnings.
  • npm run build compiles without errors.

Risks#

  • Status string mismatch: The code uses byStatus['complete'] (not 'completed'). The acceptance criteria says "completed" — need to verify the actual DB status string is complete. The existing test on line 91 confirms 'complete' is correct.
ContextPrd