{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://developer.reits.tech/schemas/runner-controller-dossier-store-owner-approval.v1.schema.json",
  "title": "Runner Controller D05 Dossier Store Owner Input and Approval Receipts",
  "type": "object",
  "additionalProperties": false,
  "required": ["schemaVersion", "status", "evaluatedAt", "mode", "program", "summary", "storePlan", "approvalContract", "ownerInputFields", "inputSubmissionContract", "approvalSeats", "approvalReceiptContract", "challengeLifecycle", "replayPolicy", "revocationPolicy", "decisionStates", "invariants", "safetyTruth", "discovery"],
  "properties": {
    "schemaVersion": { "const": "developer.reits.tech/runner-controller-dossier-store-owner-approval/v1" },
    "status": { "enum": ["STORE_PLAN_UNAVAILABLE_APPROVAL_CONTRACT_DENIED", "OWNER_INPUT_AND_APPROVAL_CONTRACT_READY_RECEIPTS_ABSENT", "OWNER_INPUT_RECEIPT_VALID_APPROVAL_CHAIN_INCOMPLETE", "APPROVAL_CHAIN_COMPLETE_MIGRATION_REVIEW_REQUIRED", "MIGRATION_REVIEWED_PROVISION_CONFIRMATION_REQUIRED"] },
    "evaluatedAt": { "type": "string", "format": "date-time" },
    "mode": { "const": "READ_ONLY_OWNER_INPUT_AND_SIGNATURE_RECEIPT_CONTRACT_NO_CHALLENGE_NO_SIGN_NO_PROVISION" },
    "program": { "$ref": "#/$defs/program" },
    "summary": { "$ref": "#/$defs/summary" },
    "storePlan": {
      "oneOf": [
        { "type": "null" },
        { "type": "object", "additionalProperties": false, "required": ["id", "contentDigest", "releaseId", "sourceRevision", "resourcesConfigured", "approved"], "properties": { "id": { "type": "string", "pattern": "^d05-store-plan@[0-9a-f]{12}-[0-9a-f]{12}$" }, "contentDigest": { "$ref": "#/$defs/digest" }, "releaseId": { "type": "string", "minLength": 1 }, "sourceRevision": { "type": "string", "pattern": "^[0-9a-f]{40}$" }, "resourcesConfigured": { "const": 0 }, "approved": { "const": false } } }
      ]
    },
    "approvalContract": {
      "oneOf": [
        { "type": "null" },
        { "type": "object", "additionalProperties": false, "required": ["id", "contentDigest", "canonicalBytes", "subject", "ownerInputReceipt", "valid", "executable"], "properties": { "id": { "type": "string", "pattern": "^d05-store-approval@[0-9a-f]{12}-[0-9a-f]{12}$" }, "contentDigest": { "$ref": "#/$defs/digest" }, "canonicalBytes": { "type": "integer", "minimum": 1 }, "subject": { "type": "object", "required": ["schemaVersion", "storePlanId", "storePlanDigest", "artifactContentDigest", "releaseId", "sourceRevision", "ownerInputFields", "inputSubmissionContract", "approvalSeats", "approvalReceiptContract", "replayPolicy", "revocationPolicy", "invariants" ], "additionalProperties": true }, "ownerInputReceipt": { "type": "null" }, "valid": { "const": false }, "executable": { "const": false } } }
      ]
    },
    "ownerInputFields": { "type": "array", "minItems": 8, "maxItems": 8, "items": { "$ref": "#/$defs/ownerInputField" } },
    "inputSubmissionContract": { "$ref": "#/$defs/inputContract" },
    "approvalSeats": { "type": "array", "minItems": 5, "maxItems": 5, "items": { "$ref": "#/$defs/approvalSeat" } },
    "approvalReceiptContract": { "$ref": "#/$defs/receiptContract" },
    "challengeLifecycle": { "type": "array", "minItems": 7, "maxItems": 7, "items": { "$ref": "#/$defs/challengeStep" } },
    "replayPolicy": { "type": "object", "required": ["nonceEntropyBits", "storeOnlyNonceDigest", "singleUse", "atomicReservationRequired", "receiptIdUnique", "challengeIdUnique", "planDigestMustMatch", "predecessorChainMustMatch", "replayDecision", "reservedNonces", "consumedNonces", "replaysObserved"], "additionalProperties": true },
    "revocationPolicy": { "type": "object", "required": ["registry", "revocableSubjects", "effectiveRule", "retroactiveProvisionRule", "unrevokePermitted", "revocationsObserved"], "additionalProperties": true },
    "decisionStates": { "type": "array", "minItems": 5, "maxItems": 5, "items": { "$ref": "#/$defs/decisionState" } },
    "invariants": { "type": "array", "minItems": 16, "maxItems": 16, "uniqueItems": true, "items": { "type": "string", "minLength": 1 } },
    "safetyTruth": { "$ref": "#/$defs/safetyTruth" },
    "discovery": {
      "type": "object",
      "additionalProperties": false,
      "required": ["workbench", "schema", "storeAuthorization", "artifactProjection", "liveIdentity"],
      "properties": {
        "workbench": { "const": "/release-foundation#runner-controller-dossier-store-owner-approval" },
        "schema": { "const": "/schemas/runner-controller-dossier-store-owner-approval.v1.schema.json" },
        "storeAuthorization": { "const": "/api/runner-controller/dossier-store-authorization" },
        "artifactProjection": { "const": "/api/runner-controller/dossier-artifact-projection" },
        "liveIdentity": { "const": "/api/release-unit" }
      }
    }
  },
  "$defs": {
    "digest": { "type": "string", "pattern": "^sha256:[0-9a-f]{64}$" },
    "program": {
      "type": "object",
      "additionalProperties": false,
      "required": ["acceptedKnives", "totalKnives", "currentKnife", "closeoutCut", "remainingIncludingCurrent", "remainingAfterAcceptance", "d05Accepted"],
      "properties": { "acceptedKnives": { "const": 4 }, "totalKnives": { "const": 36 }, "currentKnife": { "const": "D05" }, "closeoutCut": { "const": 13 }, "remainingIncludingCurrent": { "const": 32 }, "remainingAfterAcceptance": { "const": 31 }, "d05Accepted": { "const": false } }
    },
    "summary": {
      "type": "object",
      "additionalProperties": false,
      "required": ["storePlanAvailable", "ownerInputFieldsSpecified", "ownerInputValuesObserved", "ownerInputReceiptsObserved", "approvalSeatsRequired", "approvalSeatsEligible", "approvalReceiptsObserved", "keyRefsConfigured", "challengesIssued", "nonceReservationsCreated", "revocationsObserved", "provisioningPermitted", "migrationPermitted", "externalWritesExecuted", "decision"],
      "properties": { "storePlanAvailable": { "type": "boolean" }, "ownerInputFieldsSpecified": { "const": 8 }, "ownerInputValuesObserved": { "const": 0 }, "ownerInputReceiptsObserved": { "const": 0 }, "approvalSeatsRequired": { "const": 5 }, "approvalSeatsEligible": { "const": 0 }, "approvalReceiptsObserved": { "const": 0 }, "keyRefsConfigured": { "const": 0 }, "challengesIssued": { "const": 0 }, "nonceReservationsCreated": { "const": 0 }, "revocationsObserved": { "const": 0 }, "provisioningPermitted": { "const": false }, "migrationPermitted": { "const": false }, "externalWritesExecuted": { "const": 0 }, "decision": { "type": "string", "minLength": 1 } }
    },
    "ownerInputField": {
      "type": "object",
      "required": ["id", "field", "label", "valueType", "owner", "value", "observed"],
      "properties": { "id": { "type": "string", "pattern": "^OI-[0-9]{2}$" }, "field": { "type": "string" }, "label": { "type": "string" }, "valueType": { "type": "string" }, "owner": { "type": "string" }, "value": { "type": "null" }, "observed": { "const": false } },
      "additionalProperties": true
    },
    "inputContract": {
      "type": "object",
      "additionalProperties": false,
      "required": ["schemaVersion", "canonicalEncoding", "signatureAlgorithm", "requiredFields", "challengeTtlSeconds", "receiptTtlSeconds", "maxClockSkewSeconds", "keyRefRule", "submissionOrder", "observedReceipt"],
      "properties": { "schemaVersion": { "const": "developer.reits.tech/d05-dossier-store-owner-input-submission-receipt/v1" }, "canonicalEncoding": { "const": "RFC8785_JSON_UTF8" }, "signatureAlgorithm": { "const": "ECDSA_P256_SHA256" }, "requiredFields": { "type": "array", "minItems": 16, "maxItems": 16, "uniqueItems": true }, "challengeTtlSeconds": { "const": 900 }, "receiptTtlSeconds": { "const": 3600 }, "maxClockSkewSeconds": { "const": 30 }, "keyRefRule": { "type": "string" }, "submissionOrder": { "type": "string" }, "observedReceipt": { "type": "null" } }
    },
    "approvalSeat": {
      "type": "object",
      "additionalProperties": false,
      "required": ["ordinal", "id", "owner", "scope", "dependsOn", "keyRef", "eligible", "receipt", "status"],
      "properties": { "ordinal": { "type": "integer", "minimum": 1, "maximum": 5 }, "id": { "type": "string", "pattern": "^AS-[0-9]{2}$" }, "owner": { "type": "string" }, "scope": { "type": "string" }, "dependsOn": { "type": "array", "minItems": 1, "items": { "type": "string" } }, "keyRef": { "type": "null" }, "eligible": { "const": false }, "receipt": { "type": "null" }, "status": { "type": "string", "pattern": "^BLOCKED_" } }
    },
    "receiptContract": {
      "type": "object",
      "additionalProperties": false,
      "required": ["schemaVersion", "canonicalEncoding", "signatureAlgorithm", "decisions", "requiredFields", "challengeTtlSeconds", "receiptTtlSeconds", "maxClockSkewSeconds", "keyRefRule", "signatureVerification", "positiveDecisionRule"],
      "properties": { "schemaVersion": { "const": "developer.reits.tech/d05-dossier-store-approval-receipt/v1" }, "canonicalEncoding": { "const": "RFC8785_JSON_UTF8" }, "signatureAlgorithm": { "const": "ECDSA_P256_SHA256" }, "decisions": { "type": "array", "const": ["APPROVE", "DENY"] }, "requiredFields": { "type": "array", "minItems": 19, "maxItems": 19, "uniqueItems": true }, "challengeTtlSeconds": { "const": 900 }, "receiptTtlSeconds": { "const": 3600 }, "maxClockSkewSeconds": { "const": 30 }, "keyRefRule": { "type": "string" }, "signatureVerification": { "type": "string" }, "positiveDecisionRule": { "type": "string" } }
    },
    "challengeStep": {
      "type": "object",
      "additionalProperties": false,
      "required": ["ordinal", "action", "effect", "executed", "status"],
      "properties": { "ordinal": { "type": "integer", "minimum": 1, "maximum": 7 }, "action": { "type": "string" }, "effect": { "type": "string" }, "executed": { "const": false }, "status": { "type": "string", "pattern": "^BLOCKED_" } }
    },
    "decisionState": {
      "type": "object",
      "additionalProperties": false,
      "required": ["status", "condition", "challengePermitted", "signingPermitted", "provisioningPermitted"],
      "properties": { "status": { "type": "string" }, "condition": { "type": "string" }, "challengePermitted": { "const": false }, "signingPermitted": { "const": false }, "provisioningPermitted": { "const": false } }
    },
    "safetyTruth": {
      "type": "object",
      "additionalProperties": false,
      "required": ["ownerInputFieldsSpecified", "ownerInputValuesObserved", "ownerInputReceiptsObserved", "approvalSeatsSpecified", "approvalReceiptsObserved", "keyRefsConfigured", "challengesIssued", "nonceReservationsCreated", "revocationsObserved", "resourcesCreated", "migrationsGenerated", "migrationsApplied", "permissionGrantsIssued", "externalWritesExecuted", "controllerListenerStarts", "paidResourcesCreated", "provisioningPermitted", "d05Accepted"],
      "properties": { "ownerInputFieldsSpecified": { "const": 8 }, "ownerInputValuesObserved": { "const": 0 }, "ownerInputReceiptsObserved": { "const": 0 }, "approvalSeatsSpecified": { "const": 5 }, "approvalReceiptsObserved": { "const": 0 }, "keyRefsConfigured": { "const": 0 }, "challengesIssued": { "const": 0 }, "nonceReservationsCreated": { "const": 0 }, "revocationsObserved": { "const": 0 }, "resourcesCreated": { "const": 0 }, "migrationsGenerated": { "const": 0 }, "migrationsApplied": { "const": 0 }, "permissionGrantsIssued": { "const": 0 }, "externalWritesExecuted": { "const": 0 }, "controllerListenerStarts": { "const": 0 }, "paidResourcesCreated": { "const": false }, "provisioningPermitted": { "const": false }, "d05Accepted": { "const": false } }
    }
  }
}
