{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/currents-dev/json-schema/currents-dev-project-insights-response-schema.json",
  "title": "ProjectInsightsResponse",
  "x-generated": "2026-11-04",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/currents-dev-openapi.yml#/components/schemas/ProjectInsightsResponse",
  "type": "object",
  "required": [
    "status",
    "data"
  ],
  "properties": {
    "status": {
      "type": "string",
      "enum": [
        "OK"
      ]
    },
    "data": {
      "type": "object",
      "required": [
        "projectId",
        "orgId",
        "results",
        "metrics"
      ],
      "properties": {
        "projectId": {
          "type": "string"
        },
        "orgId": {
          "type": "string"
        },
        "dateStart": {
          "type": "string",
          "format": "date-time"
        },
        "dateEnd": {
          "type": "string",
          "format": "date-time"
        },
        "resolution": {
          "type": "string"
        },
        "results": {
          "type": "object",
          "properties": {
            "overall": {
              "type": "object",
              "properties": {
                "runs": {
                  "$ref": "#/$defs/RunMetrics"
                },
                "tests": {
                  "$ref": "#/$defs/TestMetrics"
                }
              }
            },
            "timeline": {
              "type": "array",
              "items": {
                "type": "object",
                "additionalProperties": {
                  "type": "object",
                  "properties": {
                    "runs": {
                      "$ref": "#/$defs/RunMetrics"
                    },
                    "tests": {
                      "$ref": "#/$defs/TestMetrics"
                    }
                  }
                }
              }
            }
          }
        },
        "metrics": {
          "type": "object",
          "description": "Duration and health of the project's tests and spec files over the date range, each against the range of the same length before it. Filters are applied to each execution, not to the run it belongs to, so these numbers are not derivable from the run counts in `results`.",
          "required": [
            "tests",
            "specs"
          ],
          "properties": {
            "tests": {
              "$ref": "#/$defs/MetricsSummary"
            },
            "specs": {
              "$ref": "#/$defs/MetricsSummary"
            }
          }
        }
      }
    }
  },
  "$defs": {
    "MetricsSummary": {
      "type": "object",
      "description": "Duration percentiles and outcome rates for a selection of tests or spec files, plus the duration histogram.",
      "required": [
        "current",
        "previous",
        "minMs",
        "maxMs",
        "distribution"
      ],
      "properties": {
        "current": {
          "$ref": "#/$defs/PeriodMetrics"
        },
        "previous": {
          "allOf": [
            {
              "$ref": "#/$defs/PeriodMetrics"
            }
          ],
          "description": "The range of the same length before the one asked for."
        },
        "minMs": {
          "type": [
            "number",
            "null"
          ],
          "description": "Shortest execution in the current range."
        },
        "maxMs": {
          "type": [
            "number",
            "null"
          ],
          "description": "Longest execution in the current range."
        },
        "distribution": {
          "type": "array",
          "description": "Executions per duration bucket, in the current range. Buckets widen with duration; empty buckets between the first and last are included.",
          "items": {
            "type": "object",
            "required": [
              "minMs",
              "maxMs",
              "executions"
            ],
            "properties": {
              "minMs": {
                "type": "number"
              },
              "maxMs": {
                "type": "number"
              },
              "executions": {
                "type": "number"
              }
            }
          }
        }
      }
    },
    "PeriodMetrics": {
      "type": "object",
      "required": [
        "executions",
        "overallExecutions",
        "avgMs",
        "p50Ms",
        "p90Ms",
        "p95Ms",
        "passRate",
        "failureRate",
        "flakinessRate",
        "suiteSize",
        "testsPerExecution"
      ],
      "properties": {
        "executions": {
          "type": "number",
          "description": "Executions the duration metrics are calculated over. Narrower than `overallExecutions` when the average-duration metric setting excludes a status."
        },
        "overallExecutions": {
          "type": "number",
          "description": "Executions the rates are calculated over."
        },
        "avgMs": {
          "type": [
            "number",
            "null"
          ]
        },
        "p50Ms": {
          "type": [
            "number",
            "null"
          ]
        },
        "p90Ms": {
          "type": [
            "number",
            "null"
          ]
        },
        "p95Ms": {
          "type": [
            "number",
            "null"
          ]
        },
        "passRate": {
          "type": [
            "number",
            "null"
          ],
          "description": "Rate as a 0-1 float. Tests only."
        },
        "failureRate": {
          "type": [
            "number",
            "null"
          ],
          "description": "Rate as a 0-1 float. Failures are failed and interrupted executions together."
        },
        "flakinessRate": {
          "type": [
            "number",
            "null"
          ]
        },
        "suiteSize": {
          "type": [
            "number",
            "null"
          ],
          "description": "Tests in the most recent execution of a spec file. Null unless the metrics describe a single spec file."
        },
        "testsPerExecution": {
          "type": [
            "number",
            "null"
          ],
          "description": "Average tests per spec execution. Spec files only."
        }
      }
    },
    "RunMetrics": {
      "type": "object",
      "properties": {
        "total": {
          "type": "integer",
          "description": "Total number of runs"
        },
        "cancelled": {
          "type": "integer",
          "description": "Cancelled runs"
        },
        "timeouts": {
          "type": "integer",
          "description": "Timed out runs"
        },
        "completed": {
          "type": "integer",
          "description": "Fully completed runs"
        },
        "failed": {
          "type": "integer",
          "description": "Failed runs"
        },
        "passed": {
          "type": "integer",
          "description": "Passed runs"
        },
        "nonFullyReported": {
          "type": "integer",
          "description": "Runs that did not fully report"
        },
        "avgDurationSeconds": {
          "type": [
            "number",
            "null"
          ],
          "description": "Average duration of fully reported runs in seconds. Null when no run in the period is fully reported."
        },
        "avgSuccessRate": {
          "type": [
            "number",
            "null"
          ],
          "description": "Average success rate of fully reported runs (0-1). Null when no run in the period is fully reported."
        }
      }
    },
    "TestMetrics": {
      "type": "object",
      "properties": {
        "total": {
          "type": "integer",
          "description": "Total test executions"
        },
        "failed": {
          "type": "integer",
          "description": "Failed tests"
        },
        "passed": {
          "type": "integer",
          "description": "Passed tests"
        },
        "pending": {
          "type": "integer",
          "description": "**pending** outcomes (intentional skips). See `RecordedTestOutcome`."
        },
        "skipped": {
          "type": "integer",
          "description": "**skipped** outcomes (runner skip / interrupted). See `RecordedTestOutcome`."
        },
        "flaky": {
          "type": "integer",
          "description": "Flaky tests"
        }
      }
    }
  }
}