{"spec_id":"failed-task-diagnostics-contract","title":"Failed-Task Diagnostics Completeness Contract","summary":"**Idea**: `agent-failed-task-diagnostics` (sub-idea of `coherence-network-agent-pipeline`)","potential_value":0.0,"actual_value":1.0,"estimated_cost":0.0,"actual_cost":1.0,"value_gap":0.0,"cost_gap":1.0,"estimated_roi":0.0,"actual_roi":1.0,"idea_id":"pipeline-reliability","process_summary":"Error fields on model: Add `error_summary: Optional[str]` and `error_category: Optional[str]` to `AgentTask`, `AgentTaskListItem`, `AgentTaskUp; Require diagnostics on failure: When a task transitions to `status=failed` via PATCH, require at least one of `error_summary` or `output` to be non-empt; Diagnostics service: `classify_error(output: str | None) -> tuple[str, str]` returns `(error_summary, error_category)` by pattern-matching th; Auto-classify on PATCH: When PATCH sets `status=failed` and `error_summary` is not provided, call `classify_error(output)` to auto-populate both; Diagnostics completeness endpoint: `GET /api/agent/diagnostics-completeness` returns `{\"total_failed\": N, \"with_diagnostics\": M, \"missing_pct\": float, \"by_","pseudocode_summary":null,"implementation_summary":"api/app/services/failed_task_diagnostics_service.py (classify_error(), ensure_diagnostics()); api/app/models/agent.py (error_summary, error_category fields); api/app/services/agent_task_store_service.py (AgentTaskRecord.error_summary column)","created_by_contributor_id":null,"updated_by_contributor_id":null,"created_at":"2026-04-09T03:10:08.889551Z","updated_at":"2026-04-09T03:10:08.889551Z","content_path":"specs/failed-task-diagnostics-contract.md","content_hash":"46b8e395229791b5","workspace_id":"coherence-network"}