{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://proofscaling.org/schema/0.2/proof-record.schema.json",
  "title": "Proof Record",
  "description": "The shared envelope for every Proof Dimension record. One Proof Cycle, one dimension, one record. Stub for Proofscaling version 0.2.",
  "type": "object",
  "properties": {
    "dimension": {
      "description": "The Proof Dimension this record reports.",
      "enum": [
        "form",
        "playbook",
        "conversion",
        "streak",
        "stats"
      ]
    },
    "standardVersion": { "const": "0.2" },
    "pinnedThesis": {
      "description": "The Domain Thesis this record is reported under, pinned by content hash. Optional for base reporting.",
      "type": "string",
      "pattern": "^sha256:[0-9a-fA-F]{64}$"
    },
    "proofCycle": { "$ref": "#/$defs/proofCycle" },
    "asOf": { "$ref": "#/$defs/asOf" },
    "visibility": { "$ref": "#/$defs/visibility" },
    "provenance": { "$ref": "#/$defs/provenance" }
  },
  "required": ["dimension", "standardVersion", "proofCycle", "asOf", "visibility"],
  "additionalProperties": false,
  "$defs": {
    "proofCycle": {
      "title": "Proof Cycle",
      "description": "The quarterly cadence. One cycle, all dimensions.",
      "type": "object",
      "properties": {
        "year": { "type": "integer", "minimum": 2000 },
        "quarter": { "enum": ["Q1", "Q2", "Q3", "Q4"] }
      },
      "required": ["year", "quarter"],
      "additionalProperties": false
    },
    "asOf": {
      "description": "The date this record holds for.",
      "type": "string",
      "format": "date"
    },
    "visibility": {
      "description": "Scoped reporting. Operating metrics are universal, capital facts are permissioned.",
      "enum": ["Public", "Investor", "Layer", "Internal"]
    },
    "provenance": {
      "title": "Provenance",
      "description": "Where a metric came from. Every metric carries provenance.",
      "type": "object",
      "properties": {
        "source": {
          "type": "string",
          "description": "The source system that produced the value."
        },
        "meter": {
          "type": ["string", "null"],
          "description": "The location meter the value was read at, where applicable."
        },
        "asOf": { "$ref": "#/$defs/asOf" }
      },
      "required": ["source", "asOf"],
      "additionalProperties": false
    },
    "amount": {
      "title": "Amount",
      "description": "A quantity in a stated unit. The unit may be a currency or a system unit of account.",
      "type": "object",
      "properties": {
        "value": { "type": "number" },
        "unit": { "type": "string", "examples": ["USD", "REV", "kWh"] }
      },
      "required": ["value", "unit"],
      "additionalProperties": false
    },
    "measure": {
      "title": "Measure",
      "description": "A measured value with an optional method.",
      "type": "object",
      "properties": {
        "value": { "type": "number" },
        "unit": { "type": "string" },
        "method": { "type": "string" }
      },
      "required": ["value", "unit"],
      "additionalProperties": false
    }
  }
}
