{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/currents-dev/json-schema/currents-dev-instance-response-schema.json",
  "title": "InstanceResponse",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/currents-dev-instances-api-openapi.yml#/components/schemas/InstanceResponse",
  "type": "object",
  "required": [
    "status",
    "data"
  ],
  "properties": {
    "status": {
      "type": "string",
      "enum": [
        "OK"
      ]
    },
    "data": {
      "$ref": "#/$defs/Instance"
    }
  },
  "$defs": {
    "Instance": {
      "type": "object",
      "properties": {
        "instanceId": {
          "type": "string",
          "description": "Unique identifier for the instance"
        },
        "runId": {
          "type": "string"
        },
        "groupId": {
          "type": "string"
        },
        "spec": {
          "type": "string",
          "description": "Spec file path"
        },
        "machineId": {
          "type": "string"
        },
        "claimedAt": {
          "type": "string",
          "format": "date-time"
        },
        "completedAt": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "results": {
          "type": [
            "object",
            "null"
          ],
          "properties": {
            "stats": {
              "type": "object",
              "description": "Instance-level totals. Uses `RecordedTestOutcome` (see components/schemas).",
              "properties": {
                "tests": {
                  "type": "integer"
                },
                "passes": {
                  "type": "integer"
                },
                "failures": {
                  "type": "integer"
                },
                "pending": {
                  "type": "integer",
                  "description": "**pending** outcomes (intentional skips)."
                },
                "skipped": {
                  "type": "integer",
                  "description": "**skipped** outcomes (runner skip / interrupted)."
                }
              }
            },
            "exception": {
              "type": [
                "string",
                "null"
              ]
            },
            "flaky": {
              "type": "integer"
            },
            "tests": {
              "type": "array",
              "items": {
                "$ref": "#/$defs/InstanceTest"
              }
            }
          }
        }
      }
    },
    "InstanceTest": {
      "type": "object",
      "properties": {
        "testId": {
          "type": "string"
        },
        "title": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "state": {
          "$ref": "#/$defs/RecordedTestOutcome"
        },
        "displayError": {
          "type": [
            "string",
            "null"
          ]
        },
        "attempts": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "attemptId": {
                "type": "string"
              },
              "state": {
                "type": "string"
              },
              "wallClockStartedAt": {
                "type": "string",
                "format": "date-time"
              },
              "wallClockDuration": {
                "type": "integer"
              },
              "error": {
                "type": [
                  "object",
                  "null"
                ],
                "properties": {
                  "message": {
                    "type": "string"
                  },
                  "stack": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      }
    },
    "RecordedTestOutcome": {
      "type": "string",
      "description": "Final per-test outcome stored in Currents.\n\n- **passed** — Runner reported success.\n- **failed** — Runner reported failure (assertions, errors, timeouts, etc.).\n- **pending** — Intentional skip or disabled test (e.g. `test.skip()` / `it.skip()`). In **Tests Explorer** (`GET /tests/{projectId}`) this increments `metrics.ignored` and does **not** increment `metrics.failures`.\n- **skipped** — Runner reported a skip without a normal pass/fail (often interrupted or never executed as pass/fail). In **Tests Explorer** this increments `metrics.failures` together with `failed` (there is no separate `skipped` counter in that response). On **run and spec** payloads, `stats.skipped` is still reported separately from `stats.failures` and `stats.pending`.",
      "enum": [
        "passed",
        "failed",
        "pending",
        "skipped"
      ]
    }
  }
}