{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$ref": "#/definitions/SetupAgentsDashboardResult",
  "definitions": {
    "SetupAgentsDashboardResult": {
      "type": "object",
      "properties": {
        "metrics": {
          "$ref": "#/definitions/SetupAgentsDashboardMetrics"
        },
        "outputPath": {
          "type": ["string", "null"]
        },
        "format": {
          "type": "string",
          "enum": ["html", "json"]
        },
        "cwd": {
          "type": "string"
        }
      },
      "required": ["metrics", "outputPath", "format", "cwd"],
      "additionalProperties": false
    },
    "SetupAgentsDashboardMetrics": {
      "type": "object",
      "properties": {
        "generatedAt": {
          "type": "string"
        },
        "dataAsOf": {
          "type": "string",
          "description": "Latest mtime among the state inputs used to build this dashboard."
        },
        "projectName": {
          "type": "string"
        },
        "tasks": {
          "type": "object",
          "properties": {
            "total": {
              "type": "number"
            },
            "done": {
              "type": "number"
            },
            "claimed": {
              "type": "number"
            },
            "open": {
              "type": "number"
            },
            "cancelled": {
              "type": "number"
            }
          },
          "required": ["total", "done", "claimed", "open", "cancelled"],
          "additionalProperties": false
        },
        "phaseTasks": {
          "type": "object",
          "properties": {
            "total": {
              "type": "number"
            },
            "done": {
              "type": "number"
            }
          },
          "required": ["total", "done"],
          "additionalProperties": false,
          "description": "Workflow phase subtasks ([pm]/[ba]/…), counted apart from stories so the task totals reflect real work, not per-phase inflation (GH-602)."
        },
        "effort": {
          "type": "object",
          "properties": {
            "aiAutonomousHours": {
              "type": "number"
            },
            "aiSupervisedHours": {
              "type": "number"
            },
            "humanReviewHours": {
              "type": "number"
            },
            "humanManualHours": {
              "type": "number"
            },
            "manualHours": {
              "type": "number",
              "description": "Back-compat alias = humanManualHours (was the fabricated bucket)."
            },
            "totalHours": {
              "type": "number"
            },
            "aiRatioPct": {
              "type": "number"
            },
            "estimated": {
              "type": "boolean",
              "description": "True when any mode is an estimate (no recorded evidence), so the UI shows ★."
            }
          },
          "required": [
            "aiAutonomousHours",
            "aiSupervisedHours",
            "humanReviewHours",
            "humanManualHours",
            "manualHours",
            "totalHours",
            "aiRatioPct",
            "estimated"
          ],
          "additionalProperties": false
        },
        "sizingEstimate": {
          "anyOf": [
            {
              "type": "object",
              "properties": {
                "totalSoloDays": {
                  "type": "number"
                },
                "totalAiUnguidedDays": {
                  "type": "number"
                },
                "storiesEstimated": {
                  "type": "number"
                }
              },
              "required": ["totalSoloDays", "totalAiUnguidedDays", "storiesEstimated"],
              "additionalProperties": false
            },
            {
              "type": "null"
            }
          ]
        },
        "tokenCost": {
          "anyOf": [
            {
              "$ref": "#/definitions/TokenCostSummary"
            },
            {
              "type": "null"
            }
          ]
        },
        "velocity": {
          "type": "object",
          "additionalProperties": {
            "type": "number"
          }
        },
        "byProfile": {
          "type": "object",
          "additionalProperties": {
            "type": "object",
            "properties": {
              "total": {
                "type": "number"
              },
              "done": {
                "type": "number"
              }
            },
            "required": ["total", "done"],
            "additionalProperties": false
          }
        },
        "storyCycleTimes": {
          "type": "object",
          "additionalProperties": {
            "type": "number"
          }
        },
        "phaseCycleTimes": {
          "type": "object",
          "additionalProperties": {
            "type": "number"
          }
        },
        "recentHandoffs": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/DashboardHandoffEntry"
          }
        },
        "sizingEstimateDetails": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/WorkflowEstimateRecord"
          }
        }
      },
      "required": [
        "generatedAt",
        "dataAsOf",
        "projectName",
        "tasks",
        "phaseTasks",
        "effort",
        "sizingEstimate",
        "tokenCost",
        "velocity",
        "byProfile",
        "storyCycleTimes",
        "phaseCycleTimes",
        "recentHandoffs",
        "sizingEstimateDetails"
      ],
      "additionalProperties": false
    },
    "TokenCostSummary": {
      "type": "object",
      "properties": {
        "totalCostUsd": {
          "type": "number"
        },
        "byMode": {
          "type": "object",
          "properties": {
            "ai_autonomous": {
              "type": "object",
              "properties": {
                "costUsd": {
                  "type": "number"
                },
                "phases": {
                  "type": "number"
                }
              },
              "required": ["costUsd", "phases"],
              "additionalProperties": false
            },
            "ai_supervised": {
              "type": "object",
              "properties": {
                "costUsd": {
                  "type": "number"
                },
                "phases": {
                  "type": "number"
                }
              },
              "required": ["costUsd", "phases"],
              "additionalProperties": false
            },
            "ai_calibration_baseline": {
              "type": "object",
              "properties": {
                "costUsd": {
                  "type": "number"
                },
                "phases": {
                  "type": "number"
                }
              },
              "required": ["costUsd", "phases"],
              "additionalProperties": false
            },
            "human_manual": {
              "type": "object",
              "properties": {
                "costUsd": {
                  "type": "number"
                },
                "phases": {
                  "type": "number"
                }
              },
              "required": ["costUsd", "phases"],
              "additionalProperties": false
            },
            "human_review": {
              "type": "object",
              "properties": {
                "costUsd": {
                  "type": "number"
                },
                "phases": {
                  "type": "number"
                }
              },
              "required": ["costUsd", "phases"],
              "additionalProperties": false
            }
          },
          "additionalProperties": false
        },
        "byStory": {
          "type": "object",
          "additionalProperties": {
            "type": "number"
          }
        }
      },
      "required": ["totalCostUsd", "byMode", "byStory"],
      "additionalProperties": false
    },
    "DashboardHandoffEntry": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "from": {
          "type": "string"
        },
        "to": {
          "type": "string"
        },
        "summary": {
          "type": "string"
        },
        "createdAt": {
          "type": "string"
        },
        "taskId": {
          "type": ["string", "null"]
        }
      },
      "required": ["id", "from", "to", "summary", "createdAt", "taskId"],
      "additionalProperties": false
    },
    "WorkflowEstimateRecord": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "storyId": {
          "type": "string"
        },
        "sizingLabel": {
          "$ref": "#/definitions/WorkflowSizingLabel"
        },
        "soloEstimateDays": {
          "type": "number"
        },
        "aiUnguidedEstimateDays": {
          "type": "number"
        },
        "aiGuidedDays": {
          "type": "number"
        },
        "confidence": {
          "$ref": "#/definitions/WorkflowEstimateConfidence"
        },
        "declaredBy": {
          "type": "string"
        },
        "declaredAt": {
          "type": "string"
        }
      },
      "required": [
        "id",
        "storyId",
        "sizingLabel",
        "soloEstimateDays",
        "aiUnguidedEstimateDays",
        "confidence",
        "declaredBy",
        "declaredAt"
      ],
      "additionalProperties": false
    },
    "WorkflowSizingLabel": {
      "type": "string",
      "enum": ["xxs", "xs", "s", "m", "l", "xl", "xxl"]
    },
    "WorkflowEstimateConfidence": {
      "type": "string",
      "enum": ["low", "medium", "high"]
    }
  }
}
