{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://thruput.se/agents/schemas/review/rulebook.schema.json",
  "title": "Rulebook",
  "description": "The part of our rules one probe applies, read once by the reviewing context and handed over whole: the rules to probe, the principles that answer when the application of a rule is in doubt, and the glossary that defines their terms",
  "type": "object",
  "required": [
    "instructions",
    "rules",
    "principles",
    "definitions"
  ],
  "properties": {
    "instructions": {
      "description": "How a rulebook is read, said to the probe itself",
      "const": "Apply each rule with its [[term]]s as definitions defines them. When the application of a rule is in doubt, its parent in principles decides"
    },
    "rules": {
      "description": "The rules handed over, in order. A probe writes one ledger row for each rule of the rulebook it probes",
      "type": "array",
      "minItems": 1,
      "items": {
        "$ref": "../governance/rules.schema.json#/$defs/Rule"
      }
    },
    "principles": {
      "description": "The principle each listed rule names as its parent",
      "type": "array",
      "items": {
        "$ref": "../governance/principles.schema.json#/$defs/Principle"
      }
    },
    "definitions": {
      "description": "The glossary definition of every [[term]] a listed rule, principle, or definition names. A rule is applied as the glossary defines its terms",
      "type": "array",
      "items": {
        "$ref": "../governance/definitions.schema.json#/$defs/Definition"
      }
    }
  },
  "additionalProperties": false,
  "examples": [
    {
      "instructions": "Apply each rule with its [[term]]s as definitions defines them. When the application of a rule is in doubt, its parent in principles decides",
      "rules": [
        {
          "id": "No suppressed exit status",
          "marker": "MUST NOT",
          "group": "Failure Handling",
          "parent": "Fail fast",
          "body": "Discard a command's non-zero [[Exit status]] so that a failure passes as success."
        }
      ],
      "principles": [
        {
          "id": "Fail fast",
          "parent": "Crash, don't guess",
          "body": "A system fails loudly and at once on an unexpected state; it never continues on a guess."
        }
      ],
      "definitions": [
        {
          "id": "Exit status",
          "specification": "The number a process returns when it ends; zero means success, anything else failure."
        }
      ]
    }
  ]
}
