{
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "$id": "https://qisfund.com/api/governed-quantity.schema.json",
 "title": "QIS Governed Quantity Record",
 "description": "The record format Part One of the Schedule Set (QIS-CL-005) defines for every schedule referenced by the QIS clause library's other four instruments: the agent authority grant, the kill-switch covenant, the model provenance representations, and the stressed conditions annex. Full commentary at https://qistrust.com/clause-library/schedule-set. This is an editorial schema, not a certification and not legal advice; retrieval, citation and non-commercial use are free with attribution, and commercial use requires a license: https://qistrust.com/license/",
 "version": "1.0.0",
 "type": "object",
 "required": [
  "scheduleId",
  "version",
  "effectiveDate",
  "attachesTo",
  "kind",
  "rows"
 ],
 "properties": {
  "scheduleId": {
   "type": "string",
   "minLength": 1,
   "description": "E.g. S-01-B. Instrument 03's Schedules A-J are the one recorded exception to the S-0n-X scheme \u2014 see the Schedule Set's drafting notes."
  },
  "version": {
   "type": "string"
  },
  "effectiveDate": {
   "type": "string",
   "format": "date"
  },
  "attachesTo": {
   "type": "object",
   "description": "The clause-library instrument this schedule completes.",
   "required": [
    "instrumentId",
    "instrumentVersion"
   ],
   "properties": {
    "instrumentId": {
     "type": "string",
     "description": "E.g. QIS-CL-001.",
     "pattern": "^QIS-CL-[0-9]{3}$"
    },
    "instrumentVersion": {
     "type": "string"
    }
   }
  },
  "kind": {
   "type": "string",
   "enum": [
    "governance",
    "disclosure"
   ],
   "description": "governance: omission of a row authorizes nothing (Part Three, 3.2). disclosure: a schedule referred to but not delivered is treated as delivered blank (Part Three, 3.3). Instrument 03's Schedules A-J are disclosure; every other schedule in the library is governance."
  },
  "rows": {
   "type": "array",
   "items": {
    "type": "object",
    "description": "One row. Every schedule in the QIS clause library uses this shape, per Part One of the Schedule Set.",
    "properties": {
     "identifier": {
      "type": "string",
      "minLength": 1,
      "description": "Stable within the schedule; does not change when the value changes."
     },
     "quantity": {
      "type": "string",
      "minLength": 1,
      "description": "The observable thing being measured, stated so two people would measure it identically."
     },
     "value": {
      "description": "A number, or an enumerated set of permitted members. Not a standard of judgment.",
      "oneOf": [
       {
        "type": "number"
       },
       {
        "type": "array",
        "items": {
         "type": "string"
        },
        "minItems": 1
       }
      ]
     },
     "unit": {
      "type": "string",
      "description": "Required where value is a number. Not applicable on a disclosure schedule."
     },
     "measurementWindow": {
      "type": "string",
      "description": "The period over which the quantity is evaluated. Not applicable on a disclosure schedule."
     },
     "dataSource": {
      "type": "string",
      "minLength": 1,
      "description": "Identified specifically enough that a substitution would be visible."
     },
     "enforcementPoint": {
      "type": "string",
      "minLength": 1,
      "description": "The control, service or gate that applies the value. Not applicable on a disclosure schedule. A row with no enforcement point records an intention, not a limit."
     },
     "consequence": {
      "type": "string",
      "minLength": 1,
      "description": "What occurs when the value is reached: halt, reserved-action escalation, notification, or no automated consequence, stated expressly. Not applicable on a disclosure schedule."
     },
     "setBy": {
      "type": "string",
      "minLength": 1,
      "description": "The natural person who set the value. Not a team, a committee, or a system."
     },
     "dateSet": {
      "type": "string",
      "format": "date"
     },
     "basis": {
      "type": "string",
      "minLength": 1,
      "description": "The reason the value is what it is. A value inherited from a prior configuration should say so."
     },
     "reviewDate": {
      "type": "string",
      "format": "date"
     },
     "supersedes": {
      "type": "object",
      "description": "Required where this row replaces an earlier one.",
      "properties": {
       "identifier": {
        "type": "string"
       },
       "version": {
        "type": "string"
       }
      },
      "required": [
       "identifier",
       "version"
      ]
     }
    },
    "required": [
     "identifier",
     "quantity",
     "value",
     "dataSource",
     "setBy",
     "dateSet",
     "basis",
     "reviewDate"
    ],
    "if": {
     "properties": {
      "value": {
       "type": "number"
      }
     },
     "required": [
      "value"
     ]
    },
    "then": {
     "required": [
      "unit"
     ]
    }
   }
  }
 },
 "if": {
  "properties": {
   "kind": {
    "const": "governance"
   }
  },
  "required": [
   "kind"
  ]
 },
 "then": {
  "properties": {
   "rows": {
    "items": {
     "required": [
      "measurementWindow",
      "enforcementPoint",
      "consequence"
     ]
    }
   }
  }
 }
}
