{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://law.arxo.io/schema/change-set.schema.json",
  "title": "Arxo normative change set 0.1",
  "description": "A normative change as an object for the Arxo Change Protocol: pairs of states of packages or case releases (before/after), the dependency world, the commencement regime, the declared intent, and the producer artifacts a change dossier is assembled from. Host-level composition over existing producer runs (impact, impact-editions, goals, comparison, measure); it carries no semantics and is not executed. The same schema reads a reform over corpus packages and a change package of a case project.",
  "$comment": "DECISION-0364; NORMATIVE-CHANGE-PLAN §3 N1; SPEC §33.1; DECISION-0362",
  "type": "object",
  "additionalProperties": false,
  "required": ["schemaVersion", "id", "kind", "title", "legalStatus", "units", "world", "producers"],
  "properties": {
    "schemaVersion": {
      "const": "law.change-set/0.1"
    },
    "id": {
      "description": "Stable identifier of the change set (URN).",
      "type": "string",
      "minLength": 1
    },
    "kind": {
      "description": "draft-amendment: pinned edition against a draft model; edition-change: two dated editions of the same act; case-release: two releases of a case package (change package of a project).",
      "$comment": "SPEC §168.4",
      "enum": ["draft-amendment", "edition-change", "case-release"]
    },
    "title": {
      "$ref": "#/$defs/LocalizedText"
    },
    "jurisdiction": {
      "type": "string",
      "minLength": 1
    },
    "legalStatus": {
      "description": "Legal status of the AFTER state, not of the model: a draft is not law.",
      "$ref": "#/$defs/LegalStatus"
    },
    "units": {
      "type": "array",
      "minItems": 1,
      "items": {
        "$ref": "#/$defs/ChangeUnit"
      }
    },
    "world": {
      "$ref": "#/$defs/World"
    },
    "commencement": {
      "$ref": "#/$defs/Commencement"
    },
    "intent": {
      "$ref": "#/$defs/Intent"
    },
    "goalsDeclared": {
      "description": "Goals evaluated on both sides, by StableId.",
      "$comment": "DECISION-0089",
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1
      }
    },
    "producers": {
      "description": "Artifacts of existing tools the dossier is assembled from. The dossier builder reads them and never re-executes anything.",
      "type": "array",
      "minItems": 1,
      "items": {
        "$ref": "#/$defs/Producer"
      }
    },
    "composition": {
      "$ref": "#/$defs/Composition"
    },
    "coverageProfile": {
      "$ref": "#/$defs/CoverageProfile"
    },
    "readings": {
      "$ref": "#/$defs/Readings"
    },
    "objections": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/Objection"
      }
    },
    "notes": {
      "type": "array",
      "items": {
        "type": "string"
      }
    }
  },
  "$defs": {
    "Digest": {
      "type": "string",
      "pattern": "^sha256:[0-9a-f]{64}$"
    },
    "Date": {
      "type": "string",
      "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$"
    },
    "LocalizedText": {
      "description": "Language tag → text.",
      "type": "object",
      "minProperties": 1,
      "propertyNames": {
        "pattern": "^[a-z]{2}(-[A-Z]{2})?$"
      },
      "additionalProperties": {
        "type": "string",
        "minLength": 1
      }
    },
    "LegalStatus": {
      "enum": ["draft", "adopted", "in-force", "superseded"]
    },
    "StateKind": {
      "enum": ["edition", "draft", "case-release"]
    },
    "SourceRef": {
      "description": "A pinned publication or document: bytes named by hash.",
      "$comment": "SPEC §194",
      "type": "object",
      "additionalProperties": false,
      "required": ["file", "sha256"],
      "properties": {
        "file": {
          "type": "string",
          "minLength": 1
        },
        "label": {
          "type": "string"
        },
        "url": {
          "type": "string"
        },
        "sha256": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$"
        },
        "sizeBytes": {
          "type": "integer",
          "minimum": 0
        }
      }
    },
    "State": {
      "description": "One side of a unit: a dated edition of a package, a draft model over it, or a case release.",
      "type": "object",
      "additionalProperties": false,
      "required": ["kind", "label"],
      "properties": {
        "kind": {
          "$ref": "#/$defs/StateKind"
        },
        "label": {
          "type": "string",
          "minLength": 1
        },
        "edition": {
          "description": "Edition identifier inside the package (e.g. TAX_CODE_2025).",
          "type": "string"
        },
        "editionDate": {
          "$ref": "#/$defs/Date"
        },
        "programHash": {
          "description": "programHash of the executed program, as recorded by the producer.",
          "$comment": "manifest SPEC §170",
          "$ref": "#/$defs/Digest"
        },
        "artifactHash": {
          "description": "artifactHash of the committed CLIR file, when the state is a corpus package.",
          "$ref": "#/$defs/Digest"
        },
        "lockfileHash": {
          "$ref": "#/$defs/Digest"
        },
        "sources": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/SourceRef"
          }
        },
        "draftUnits": {
          "description": "Draft files applied over the base package (kind = draft).",
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "caseRelease": {
          "description": "Release label of the case package (kind = case-release).",
          "type": "string"
        }
      }
    },
    "ChangeUnit": {
      "type": "object",
      "additionalProperties": false,
      "required": ["subject", "before", "after"],
      "properties": {
        "subject": {
          "enum": ["package", "case"]
        },
        "package": {
          "description": "Package name (subject = package) or case package name (subject = case).",
          "type": "string",
          "minLength": 1
        },
        "before": {
          "$ref": "#/$defs/State"
        },
        "after": {
          "$ref": "#/$defs/State"
        }
      }
    },
    "PackageRef": {
      "type": "object",
      "additionalProperties": false,
      "required": ["name", "version"],
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1
        },
        "version": {
          "type": "string",
          "minLength": 1
        },
        "contentHash": {
          "$ref": "#/$defs/Digest"
        }
      }
    },
    "World": {
      "description": "Dependency world of the change: the import closure of the root. Anything outside the closure is outside the dossier by construction.",
      "$comment": "DECISION-0193",
      "type": "object",
      "additionalProperties": false,
      "required": ["closure", "boundary"],
      "properties": {
        "root": {
          "type": "string"
        },
        "closure": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/PackageRef"
          }
        },
        "lockfileHash": {
          "$ref": "#/$defs/Digest"
        },
        "resolutionHash": {
          "$ref": "#/$defs/Digest"
        },
        "boundary": {
          "description": "Human-readable statement of what the world does not contain.",
          "type": "string",
          "minLength": 1
        }
      }
    },
    "Commencement": {
      "description": "Transition regime as read from the act: general date and closed exceptions. Transitional provisions themselves are rules of the package, not host logic.",
      "$comment": "SPEC part XII",
      "type": "object",
      "additionalProperties": false,
      "required": ["general"],
      "properties": {
        "general": {
          "$ref": "#/$defs/Date"
        },
        "exceptions": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": ["address", "effectiveFrom"],
            "properties": {
              "address": {
                "type": "string",
                "minLength": 1
              },
              "effectiveFrom": {
                "$ref": "#/$defs/Date"
              }
            }
          }
        },
        "readingDecision": {
          "description": "Decision that fixed the reading of the dates and its status.",
          "type": "string"
        }
      }
    },
    "Outcome": {
      "description": "Scenario outcome as printed by impact (NEITHER, TRUE_ONLY, FALSE_ONLY, BOTH, or a calc outcome).",
      "type": "string",
      "minLength": 1
    },
    "Intent": {
      "description": "Declared boundary of the reform: expected outcome changes, goals that must hold, and the area that must not change. Absent in a dossier built without a declaration; then every observed difference is classified observed, never expected.",
      "$comment": "NORMATIVE-CHANGE-PLAN N2",
      "type": "object",
      "additionalProperties": false,
      "required": ["expectedChanges", "protectedGoals", "protectedScope"],
      "properties": {
        "declaredBy": {
          "type": "string"
        },
        "declaredOn": {
          "$ref": "#/$defs/Date"
        },
        "expectedChanges": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": ["scenario", "before", "after"],
            "properties": {
              "scenario": {
                "type": "string",
                "minLength": 1
              },
              "before": {
                "$ref": "#/$defs/Outcome"
              },
              "after": {
                "$ref": "#/$defs/Outcome"
              }
            }
          }
        },
        "protectedGoals": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "protectedScope": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": ["kind", "id"],
            "properties": {
              "kind": {
                "enum": ["predicate", "subject", "stage", "article"]
              },
              "id": {
                "type": "string",
                "minLength": 1
              }
            }
          }
        }
      }
    },
    "Readings": {
      "description": "Two readings of the same source: the adopted one (the AFTER state of the units) and an alternative built from the same draft; the producer is an impact report between the two AFTER worlds, and the dossier names the scenario classes on which they diverge.",
      "$comment": "NORMATIVE-CHANGE-PLAN N9",
      "type": "object",
      "additionalProperties": false,
      "required": ["adopted", "alternative", "producer"],
      "properties": {
        "adopted": {
          "type": "string",
          "minLength": 1
        },
        "alternative": {
          "type": "string",
          "minLength": 1
        },
        "basis": {
          "type": "string"
        },
        "producer": {
          "description": "Path of the impact artifact adopted → alternative, as listed in producers (role reading).",
          "type": "string",
          "minLength": 1
        },
        "objectionsProducer": {
          "description": "Path of the impact artifact adopted → alternative over the objection scenarios only.",
          "type": "string"
        }
      }
    },
    "ObjectionClass": {
      "description": "expert: a scenario by an expert or a party, no legal force; approved-criterion: adopted by the owner of the formalization as a check; binding-decision: grounded in a court decision or an official clarification. Entering the bank gives a scenario no legal force.",
      "enum": ["expert", "approved-criterion", "binding-decision"]
    },
    "Objection": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "scenario", "class", "claim", "source", "filedOn", "status", "history"],
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1
        },
        "scenario": {
          "description": "Scenario name in the objections bank (file stem--NNN).",
          "type": "string",
          "minLength": 1
        },
        "class": {
          "$ref": "#/$defs/ObjectionClass"
        },
        "claim": {
          "type": "string",
          "minLength": 1
        },
        "source": {
          "type": "string",
          "minLength": 1
        },
        "filedOn": {
          "$ref": "#/$defs/Date"
        },
        "status": {
          "enum": ["open", "accepted", "rejected", "superseded"]
        },
        "history": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": ["on", "event", "note"],
            "properties": {
              "on": {
                "$ref": "#/$defs/Date"
              },
              "event": {
                "type": "string",
                "minLength": 1
              },
              "note": {
                "type": "string",
                "minLength": 1
              }
            }
          }
        }
      }
    },
    "ProducerTool": {
      "enum": [
        "impact",
        "impact-editions",
        "goals",
        "differential",
        "measure",
        "population-impact",
        "sources",
        "scenarios",
        "package-info",
        "lockfile",
        "institutional-dependencies",
        "delivery-channels",
        "computations-index",
        "bank-health",
        "other"
      ]
    },
    "ProducerRole": {
      "description": "root: the report about the changed package itself; consumer: the same pair re-run over a package that imports it (section 8); step / end-to-end: legs of a composition of successive changes (section 3, composition).",
      "enum": ["root", "consumer", "step", "end-to-end", "reading", "objections"]
    },
    "CompositionLeg": {
      "type": "object",
      "additionalProperties": false,
      "required": ["label", "from", "to", "producer"],
      "properties": {
        "label": {
          "type": "string",
          "minLength": 1
        },
        "from": {
          "$ref": "#/$defs/Date"
        },
        "to": {
          "$ref": "#/$defs/Date"
        },
        "producer": {
          "description": "Path of the impact-editions artifact of this leg, as listed in producers.",
          "type": "string",
          "minLength": 1
        }
      }
    },
    "Composition": {
      "description": "A chain of successive changes of the same root: every step and the end-to-end pair are separate producers; the dossier reports transient changes (present in a step, absent end-to-end) and interactions.",
      "$comment": "NORMATIVE-CHANGE-PLAN N3",
      "type": "object",
      "additionalProperties": false,
      "required": ["steps", "endToEnd"],
      "properties": {
        "steps": {
          "type": "array",
          "minItems": 2,
          "items": {
            "$ref": "#/$defs/CompositionLeg"
          }
        },
        "endToEnd": {
          "$ref": "#/$defs/CompositionLeg"
        }
      }
    },
    "CoverageAxis": {
      "type": "object",
      "additionalProperties": false,
      "required": ["name", "predicate", "argIndex", "values"],
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1
        },
        "predicate": {
          "description": "Local name of the case-input predicate that fixes this axis.",
          "type": "string",
          "minLength": 1
        },
        "argIndex": {
          "type": "integer",
          "minimum": 0
        },
        "values": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "cap": {
          "description": "Integer axes: values at or above this bound fold into the last declared value.",
          "type": "integer"
        }
      }
    },
    "CoverageProfile": {
      "description": "Finite product of axes read from the scenario bank: which cells of the product at least one scenario fixes. A coverage statement about the bank, not a legal answer.",
      "$comment": "DECISION-0179",
      "type": "object",
      "additionalProperties": false,
      "required": ["axes"],
      "properties": {
        "axes": {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/$defs/CoverageAxis"
          }
        },
        "note": {
          "type": "string"
        }
      }
    },
    "Producer": {
      "type": "object",
      "additionalProperties": false,
      "required": ["tool", "path", "sha256"],
      "properties": {
        "tool": {
          "$ref": "#/$defs/ProducerTool"
        },
        "path": {
          "description": "Path of the artifact relative to the repository root.",
          "type": "string",
          "minLength": 1
        },
        "sha256": {
          "description": "sha256 of the artifact bytes as read by the builder.",
          "$ref": "#/$defs/Digest"
        },
        "schemaVersion": {
          "type": "string"
        },
        "role": {
          "$ref": "#/$defs/ProducerRole"
        },
        "package": {
          "description": "For role = consumer: the importing package the artifact is about.",
          "type": "string"
        },
        "concat": {
          "description": "Packages added to the world beyond the import closure, as the package's own test families do (`concat` in law.toml): a replay, not a dependency world.",
          "$comment": "DECISION-0193",
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "label": {
          "type": "string"
        },
        "note": {
          "type": "string"
        }
      }
    }
  }
}
