{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/starwell-dev/json-schema/starwell-dev-observation-schema.json",
  "title": "Observation",
  "x-generated": "2026-11-26",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/starwell-dev-openapi.yml#/components/schemas/Observation",
  "type": "object",
  "required": [
    "period",
    "value",
    "provenance"
  ],
  "properties": {
    "period": {
      "type": "string",
      "format": "date"
    },
    "value": {
      "type": [
        "number",
        "null"
      ],
      "description": "Null only when status explains it."
    },
    "status": {
      "type": "string",
      "enum": [
        "normal",
        "missing",
        "suppressed",
        "terminated"
      ]
    },
    "decimals": {
      "type": [
        "integer",
        "null"
      ]
    },
    "revision": {
      "type": "integer",
      "description": "Bumps when the source revises the period; history is append-only."
    },
    "provenance": {
      "$ref": "#/$defs/Provenance"
    },
    "revisedSince": {
      "type": "boolean",
      "description": "asOf reads only: true when this period has been revised since the cutoff (the current value differs)."
    }
  },
  "$defs": {
    "Provenance": {
      "type": "object",
      "description": "Where this exact value came from — stored append-only, never inferred.",
      "required": [
        "sourceUrl",
        "retrievedAt",
        "connectorVersion"
      ],
      "properties": {
        "sourceUrl": {
          "type": "string",
          "description": "The exact source API request or table URL."
        },
        "retrievedAt": {
          "type": "string",
          "format": "date-time"
        },
        "connectorVersion": {
          "type": "string"
        },
        "releaseTime": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "storedAt": {
          "type": "string",
          "format": "date-time",
          "description": "asOf reads and /revisions only: when Starwell's store inserted this row (database-assigned, immutable) — the clock a point-in-time read keys on."
        }
      }
    }
  }
}