{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://usedeed.app/contracts/deed.formal_runtime_state_contract.v1.schema.json",
  "title": "DEED formal runtime state contract v1",
  "type": "object",
  "required": ["$schema", "stateType", "sourceOfTruth", "questionKinds", "branchPositions", "runtimeAnchors", "custodyClasses", "custodyInvariant", "productionEmitterContract", "operationalFiniteness"],
  "properties": {
    "$schema": { "const": "https://usedeed.app/contracts/deed.formal_runtime_state_contract.v1.schema.json" },
    "stateType": { "const": "DEED.QAnamorphism.FrontierState" },
    "sourceOfTruth": { "type": "object", "minProperties": 1, "additionalProperties": { "type": "string", "minLength": 1 } },
    "questionKinds": { "type": "array", "items": { "type": "string", "minLength": 1 }, "minItems": 1, "uniqueItems": true },
    "branchPositions": { "const": ["observe", "constrain", "verify"] },
    "runtimeAnchors": { "type": "array", "items": { "type": "string", "minLength": 1 }, "minItems": 1, "uniqueItems": true },
    "custodyClasses": { "type": "array", "items": { "type": "string", "minLength": 1 }, "minItems": 1, "uniqueItems": true },
    "custodyInvariant": { "const": "self-custody only; DEED never holds keys; signing remains delegated off-system" },
    "productionEmitterContract": {
      "type": "object",
      "required": ["status", "contractVersion", "sharedModule", "contractGate", "recordShape", "signature", "note"],
      "properties": {
        "status": { "type": "string", "minLength": 1 },
        "contractVersion": { "type": "string", "minLength": 1 },
        "sharedModule": { "type": "string", "minLength": 1 },
        "contractGate": { "type": "string", "minLength": 1 },
        "recordShape": { "type": "array", "items": { "type": "string", "minLength": 1 }, "minItems": 1, "uniqueItems": true },
        "signature": { "type": "object", "required": ["alg", "signedPayload", "key"] },
        "note": { "type": "string", "minLength": 1 }
      },
      "additionalProperties": false
    },
    "operationalFiniteness": { "type": "string", "minLength": 1 }
  },
  "additionalProperties": false
}
