{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/lastping-dev/json-schema/lastping-dev-cirun-schema.json",
  "title": "CIRun",
  "description": "A single run entry — either a CI/CD run (structured failure context\ndecoded from `ci_meta`) or an agent/heartbeat run (only `rid` set, no\n`ci_meta`) — plus the nearest correlated incident. Designed for agent\nconsumption: all fields are flat (no nesting) so failure triage does not\nrequire link-following. Fields marked \"CI-only\" below are omitted\nentirely on an agent/heartbeat run.\n",
  "x-generated": "2026-11-15",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/lastping-dev-openapi.yaml#/components/schemas/CIRun",
  "type": "object",
  "required": [
    "id",
    "kind",
    "received_at",
    "incident_resolved",
    "span_count",
    "tokens_in",
    "tokens_out",
    "cost_usd",
    "cost_source"
  ],
  "properties": {
    "id": {
      "type": "string",
      "format": "uuid",
      "description": "Ping UUID that represents this CI run."
    },
    "kind": {
      "type": "string",
      "description": "Ping kind. One of `success`, `start`, `fail`, `log`, `cancel`,\n`blocked`, `note` (see the `Ping` schema); CI/CD webhooks\ntypically post `success` or `fail`.\n"
    },
    "received_at": {
      "type": "string",
      "format": "date-time",
      "description": "RFC 3339 UTC timestamp when the ping was received."
    },
    "rid": {
      "type": "string",
      "description": "Run id this ping carried (`?rid=`), omitted when the ping carried\nnone. It is the key `steps` are matched on.\n"
    },
    "title": {
      "type": "string",
      "description": "Title for this run, stored on the run's `/start` ping — distinct\nfrom `body_excerpt`. Matched on `rid`\nthe same way `steps` is — both pings of a run (its start and its\nterminal ping) carry it. Set by whichever call reaches it FIRST\nwith a non-empty title: the body of the run's own `/start` call,\nor a later `POST .../title?rid=<run-id>` sent any time while the\nrun is still open — same request shape as `/blocked` and `/note`,\nbut (unlike them) it records no ping of its own: it only\never sets `title` on the run's existing `/start` ping, so it\nnever appears as a `kind` in the `Ping` schema. Only the first\nnon-empty write counts; neither a later `/start` body nor a\nlater `/title` call can change a title once one is set. Omitted\nwhen nothing has set a title yet, which is the common case:\nevery existing monitor's runs are untitled until a caller starts\nsetting one.\n"
    },
    "steps": {
      "type": "array",
      "description": "Progress markers the run reported to `/<uuid>/step?rid=…`, in the\norder they happened. Omitted entirely when the run reported none —\nan absent `steps` means the run was not instrumented with steps, not\nthat it reported zero.\n\nSteps are matched on `rid`, so a CI run only carries them when the\njob posted `/step` with the same run id the CI webhook reports. The\ntwo pings of one run (its `start` and its terminal ping) share a rid\nand therefore both carry that run's timeline.\n\nAt most 100 steps are stored per run.\n",
      "items": {
        "$ref": "#/$defs/RunStep"
      }
    },
    "run_url": {
      "type": "string",
      "description": "CI-only. Direct URL to the CI/CD run page. Omitted when unavailable,\nand always omitted on an agent/heartbeat run.\n"
    },
    "commit_sha": {
      "type": "string",
      "description": "CI-only. Full or abbreviated commit SHA that triggered the run.\nOmitted when unavailable, and always omitted on an agent/heartbeat run.\n"
    },
    "branch": {
      "type": "string",
      "description": "CI-only. Branch name that triggered the run. Omitted when\nunavailable, and always omitted on an agent/heartbeat run.\n"
    },
    "actor": {
      "type": "string",
      "description": "CI-only. Username or identity that triggered the run. Omitted when\nunavailable, and always omitted on an agent/heartbeat run.\n"
    },
    "failing_stage": {
      "type": "string",
      "description": "CI-only. Name of the failing step or job (omitted when unavailable,\nand always omitted on an agent/heartbeat run).\n\nAvailability differs by provider:\n  * **GitLab CI** — always populated on a failed pipeline, from the\n    stage of the first failed entry in the hook's `builds[]`.\n  * **GitHub Actions** — requires the repository webhook to\n    subscribe to **Workflow jobs** (`workflow_job`) in addition to\n    **Workflow runs**. Only `workflow_job` carries per-step\n    conclusions; with `workflow_run` alone this field is always\n    omitted.\n  * **Jenkins** — never populated. The Notification Plugin payload\n    reports only the build's overall result and carries no\n    per-stage or per-step detail.\n"
    },
    "duration_s": {
      "type": "integer",
      "format": "int64",
      "description": "CI-only. Run duration in seconds. Omitted when unavailable or zero,\nand always omitted on an agent/heartbeat run.\n"
    },
    "duration_ms": {
      "type": "integer",
      "format": "int64",
      "description": "Wall-clock duration in milliseconds, measured by LastPing from the\nrun's `/start` -> success timing (`pings.duration_ms`). Present on\nANY completed run — CI or agent/heartbeat — whose success ping\npaired with a preceding start on the same `rid`; omitted otherwise.\n\nDistinct from `duration_s`: that field is CI-only and self-reported\nby the provider from `ci_meta`, this one is computed by LastPing\nfor every run kind. The two can each be present without the other\nand must not be treated as confirming each other.\n"
    },
    "outcome": {
      "type": "string",
      "description": "CI-only. Normalised run outcome string from the CI provider (e.g.\n`failure`, `success`). Always omitted on an agent/heartbeat run.\n"
    },
    "incident_cause": {
      "type": "string",
      "description": "Cause from the correlated incident (e.g. `silence`, `fail`,\n`overrun`, `never_started`, `runaway`, `stalled`, `blocked`,\n`upstream`) if\none was opened within ±10 minutes of this run. Empty when no\nincident correlates.\n"
    },
    "incident_detail": {
      "type": "string",
      "description": "Log excerpt attached to the correlated incident via the `/ci/{id}/detail`\nendpoint. Empty when no detail has been posted or no incident correlates.\n"
    },
    "incident_resolved": {
      "type": "boolean",
      "description": "True when the correlated incident has been closed (resolved). False when\nthe incident is still open or when no incident correlates.\n"
    },
    "span_count": {
      "type": [
        "integer",
        "null"
      ],
      "format": "int64",
      "description": "Number of OTLP spans recorded for this run. Null when the run was never traced."
    },
    "tokens_in": {
      "type": [
        "integer",
        "null"
      ],
      "format": "int64",
      "description": "Sum of `gen_ai.usage.input_tokens` across this run's GenAI spans. Null when the run was never traced."
    },
    "tokens_out": {
      "type": [
        "integer",
        "null"
      ],
      "format": "int64",
      "description": "Sum of `gen_ai.usage.output_tokens` across this run's GenAI spans. Null when the run was never traced."
    },
    "cost_usd": {
      "type": [
        "string",
        "null"
      ],
      "description": "Summed cost of this run's GenAI spans, as decimal text, never a\nJSON number. Each span's cost is the one its SDK reported\n(`gen_ai.usage.cost`) or, when it reported none, LastPing's\nestimate from the model's published price and the span's token\ncounts (`cost_source` says\nwhich). Null when the run was never traced, or when no\nspan has either: no reported cost and no known price for its\nmodel.\n"
    },
    "cost_source": {
      "type": "string",
      "description": "What `cost_usd` is made of. A plain string, not an enum, so a new\nvalue never breaks a client: `client` when every priced call's\ncost was reported by the client (the exporter's own figure, or\nClaude Code's per-call cost), `estimated` when LastPing priced\nevery call at API list prices, `mixed` when the sum holds both,\nempty when `cost_usd` is null.\n"
    }
  },
  "$defs": {
    "RunStep": {
      "type": "object",
      "description": "One progress marker reported inside an armed run via\n`GET|HEAD|POST https://ping.lastping.dev/<uuid>/step?rid=<run-id>&step=<name>`.\n\nA step resets the monitor's stall clock (`step_timeout_s`) and is\nrecorded on the run's timeline. It does **not** change the monitor's\nstatus, does not count as a ping for silence detection, and does not\nextend the run budget `COALESCE(max_runtime_s, grace_s)`.\n",
      "properties": {
        "seq": {
          "type": "integer",
          "format": "int32",
          "description": "1-based position of this step within its run."
        },
        "name": {
          "type": "string",
          "description": "Step label from `?step=`, trimmed and truncated to 200 characters.\nDefaults to `step` when the parameter is absent or blank.\n"
        },
        "at": {
          "type": "string",
          "format": "date-time",
          "description": "RFC 3339 UTC timestamp when the step ping was received."
        }
      }
    }
  }
}