{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://agla.local/schemas/applicatio-trace-1.0.1.json",
  "title": "APPLICATIO Candidate Trace",
  "description": "Non-runtime control-plane record for an APPLICATIO candidate.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "applicatio_id",
    "version",
    "status",
    "domain",
    "purpose",
    "limits",
    "authority",
    "parent_refs",
    "source_refs",
    "real_data",
    "foundational_libri",
    "opera_bindings",
    "five_role_resolution",
    "capability_bindings",
    "operator_assignments",
    "term_assignments",
    "graph_binding",
    "validation",
    "failure_trace",
    "correction_trace",
    "stabilization_decision"
  ],
  "properties": {
    "applicatio_id": {
      "type": "string",
      "minLength": 1
    },
    "version": {
      "type": "string",
      "minLength": 1
    },
    "status": {
      "enum": [
        "DRAFT",
        "RESEARCHING",
        "BLOCKED",
        "PILOT",
        "REJECTED",
        "STABILIZATION_CANDIDATE"
      ]
    },
    "domain": {
      "type": "string",
      "minLength": 1
    },
    "purpose": {
      "type": "string",
      "minLength": 1
    },
    "limits": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "string",
        "minLength": 1
      }
    },
    "authority": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "authority_ref",
        "scope",
        "runtime_authority"
      ],
      "properties": {
        "authority_ref": {
          "type": "string",
          "minLength": 1
        },
        "scope": {
          "type": "string",
          "minLength": 1
        },
        "runtime_authority": {
          "const": false
        }
      }
    },
    "parent_refs": {
      "type": "array",
      "minItems": 1,
      "items": {
        "$ref": "#/$defs/parentRef"
      }
    },
    "source_refs": {
      "type": "array",
      "minItems": 1,
      "items": {
        "$ref": "#/$defs/evidenceRef"
      }
    },
    "real_data": {
      "$ref": "#/$defs/evidenceCollection"
    },
    "foundational_libri": {
      "type": "array",
      "minItems": 1,
      "items": {
        "$ref": "#/$defs/liberRef"
      }
    },
    "opera_bindings": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "core",
        "focal",
        "composite",
        "applied"
      ],
      "properties": {
        "core": {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/$defs/artifactRef"
          }
        },
        "focal": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/artifactRef"
          }
        },
        "composite": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/artifactRef"
          }
        },
        "applied": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/artifactRef"
          }
        }
      }
    },
    "five_role_resolution": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "TENET",
        "ROTAS",
        "AREPO",
        "OPERA",
        "SATOR"
      ],
      "properties": {
        "TENET": {
          "$ref": "#/$defs/roleResolutionSet"
        },
        "ROTAS": {
          "$ref": "#/$defs/roleResolutionSet"
        },
        "AREPO": {
          "$ref": "#/$defs/roleResolutionSet"
        },
        "OPERA": {
          "$ref": "#/$defs/singleOwnerRoleResolutionSet"
        },
        "SATOR": {
          "$ref": "#/$defs/singleOwnerRoleResolutionSet"
        }
      }
    },
    "capability_bindings": {
      "type": "array",
      "minItems": 1,
      "items": {
        "$ref": "#/$defs/capabilityBinding"
      }
    },
    "operator_assignments": {
      "type": "array",
      "minItems": 1,
      "items": {
        "$ref": "#/$defs/operatorAssignment"
      }
    },
    "term_assignments": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/termAssignment"
      }
    },
    "graph_binding": {
      "$ref": "#/$defs/graphBinding"
    },
    "validation": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "operator",
        "term",
        "reality"
      ],
      "properties": {
        "operator": {
          "$ref": "#/$defs/validationResult"
        },
        "term": {
          "$ref": "#/$defs/validationResult"
        },
        "reality": {
          "$ref": "#/$defs/validationResult"
        }
      }
    },
    "failure_trace": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/failureRecord"
      }
    },
    "correction_trace": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/correctionRecord"
      }
    },
    "stabilization_decision": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "decision",
        "authority_ref",
        "evidence_refs",
        "notes"
      ],
      "properties": {
        "decision": {
          "enum": [
            "REJECTED",
            "RESEARCH_CONTINUES",
            "BLOCKED",
            "PILOT_SUPPORTED",
            "HUMAN_PROMOTION_REVIEW_REQUESTED"
          ]
        },
        "authority_ref": {
          "type": "string",
          "minLength": 1
        },
        "evidence_refs": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "notes": {
          "type": "string"
        }
      }
    }
  },
  "$defs": {
    "artifactRef": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "artifact_ref",
        "version",
        "status"
      ],
      "properties": {
        "artifact_ref": {
          "type": "string",
          "minLength": 1
        },
        "version": {
          "type": "string",
          "minLength": 1
        },
        "status": {
          "type": "string",
          "minLength": 1
        }
      }
    },
    "parentRef": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "artifact_ref",
        "version",
        "status",
        "abstraction_relation",
        "inherited_invariants",
        "permitted_specialization",
        "unresolved_conflicts"
      ],
      "properties": {
        "artifact_ref": {
          "type": "string",
          "minLength": 1
        },
        "version": {
          "type": "string",
          "minLength": 1
        },
        "status": {
          "type": "string",
          "minLength": 1
        },
        "abstraction_relation": {
          "enum": [
            "general_parent",
            "method_parent",
            "source_parent",
            "structural_parent",
            "applied_predecessor"
          ]
        },
        "inherited_invariants": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "permitted_specialization": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "unresolved_conflicts": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        }
      }
    },
    "evidenceRef": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "evidence_ref",
        "relation",
        "provenance"
      ],
      "properties": {
        "evidence_ref": {
          "type": "string",
          "minLength": 1
        },
        "relation": {
          "type": "string",
          "minLength": 1
        },
        "provenance": {
          "type": "string",
          "minLength": 1
        }
      }
    },
    "evidenceCollection": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "resolution_status",
        "evidence_refs",
        "reason"
      ],
      "properties": {
        "resolution_status": {
          "enum": [
            "provided",
            "not_applicable",
            "unresolved",
            "blocked"
          ]
        },
        "evidence_refs": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/evidenceRef"
          }
        },
        "reason": {
          "type": "string"
        }
      }
    },
    "liberRef": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "artifact_ref",
        "version",
        "status",
        "relation",
        "provenance_recoverable",
        "failures_retained"
      ],
      "properties": {
        "artifact_ref": {
          "type": "string",
          "minLength": 1
        },
        "version": {
          "type": "string",
          "minLength": 1
        },
        "status": {
          "type": "string",
          "minLength": 1
        },
        "relation": {
          "type": "string",
          "minLength": 1
        },
        "provenance_recoverable": {
          "const": true
        },
        "failures_retained": {
          "const": true
        }
      }
    },
    "roleResolutionSet": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "providers",
        "composition_mode",
        "effective_provider_refs",
        "resolution_status"
      ],
      "properties": {
        "providers": {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/$defs/roleProvider"
          }
        },
        "composition_mode": {
          "enum": [
            "single",
            "cumulative",
            "alternative",
            "ordered",
            "composed",
            "overlay"
          ]
        },
        "effective_provider_refs": {
          "type": "array",
          "minItems": 1,
          "uniqueItems": true,
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "resolution_status": {
          "enum": [
            "resolved",
            "provisional",
            "unresolved",
            "blocked"
          ]
        }
      }
    },
    "roleProvider": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "provider_ref",
        "binding_mode",
        "provider_status",
        "provider_version",
        "source_trace"
      ],
      "properties": {
        "provider_ref": {
          "type": "string",
          "minLength": 1
        },
        "binding_mode": {
          "enum": [
            "dedicated",
            "inherited",
            "reused",
            "overlay",
            "composed"
          ]
        },
        "provider_status": {
          "type": "string",
          "minLength": 1
        },
        "provider_version": {
          "type": "string",
          "minLength": 1
        },
        "source_trace": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "string",
            "minLength": 1
          }
        }
      }
    },
    "singleOwnerRoleResolutionSet": {
      "allOf": [
        {
          "$ref": "#/$defs/roleResolutionSet"
        },
        {
          "properties": {
            "effective_provider_refs": {
              "maxItems": 1
            }
          }
        }
      ]
    },
    "capabilityBinding": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "capability_ref",
        "required",
        "resolved_provider_ids",
        "provider_status_at_resolution",
        "provider_version",
        "source_trace",
        "resolution_status",
        "reason"
      ],
      "properties": {
        "capability_ref": {
          "enum": [
            "CORE_RESEARCH_CAPABILITY",
            "SUBJECT_ANCHORING_CAPABILITY",
            "ANALOGICAL_CALIBRATION_CAPABILITY",
            "CONTEXTUAL_GRAPH_CAPABILITY",
            "LLULLIAN_MEDIATION_CAPABILITY"
          ]
        },
        "required": {
          "type": "boolean"
        },
        "resolved_provider_ids": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "provider_status_at_resolution": {
          "type": "string"
        },
        "provider_version": {
          "type": "string"
        },
        "source_trace": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "resolution_status": {
          "enum": [
            "resolved",
            "provisional",
            "not_required",
            "not_applicable",
            "unresolved",
            "blocked"
          ]
        },
        "reason": {
          "type": "string"
        }
      }
    },
    "operatorAssignment": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "assignment_id",
        "operator_ref",
        "evidence_refs",
        "scope",
        "tests",
        "result",
        "limits"
      ],
      "properties": {
        "assignment_id": {
          "type": "string",
          "minLength": 1
        },
        "operator_ref": {
          "type": "string",
          "minLength": 1
        },
        "evidence_refs": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "scope": {
          "type": "string",
          "minLength": 1
        },
        "tests": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "result": {
          "enum": [
            "PASS",
            "FAIL",
            "BLOCKED",
            "UNRESOLVED"
          ]
        },
        "limits": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        }
      }
    },
    "termAssignment": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "assignment_id",
        "operator_assignment_ref",
        "term",
        "evidence_refs",
        "eq_tests",
        "counterexamples",
        "result",
        "limits"
      ],
      "properties": {
        "assignment_id": {
          "type": "string",
          "minLength": 1
        },
        "operator_assignment_ref": {
          "type": "string",
          "minLength": 1
        },
        "term": {
          "type": "string",
          "minLength": 1
        },
        "evidence_refs": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "eq_tests": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "counterexamples": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "result": {
          "enum": [
            "PASS",
            "FAIL",
            "BLOCKED",
            "UNRESOLVED"
          ]
        },
        "limits": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        }
      }
    },
    "graphBinding": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "resolution_status",
        "reason",
        "provider_ref",
        "provider_status",
        "graph_instance_ref",
        "canonical_edge_set_ref",
        "carrier_assignments_ref",
        "traversal_owner",
        "visitation_signature",
        "executable_walk",
        "arepo_admission_ref",
        "state_model_ref",
        "source_trace",
        "nesting_trace"
      ],
      "properties": {
        "resolution_status": {
          "enum": [
            "not_applicable",
            "resolved",
            "provisional",
            "unresolved",
            "blocked"
          ]
        },
        "reason": {
          "type": "string"
        },
        "provider_ref": {
          "type": [
            "string",
            "null"
          ]
        },
        "provider_status": {
          "type": [
            "string",
            "null"
          ]
        },
        "graph_instance_ref": {
          "type": [
            "string",
            "null"
          ]
        },
        "canonical_edge_set_ref": {
          "type": [
            "string",
            "null"
          ]
        },
        "carrier_assignments_ref": {
          "type": [
            "string",
            "null"
          ]
        },
        "traversal_owner": {
          "type": [
            "string",
            "null"
          ]
        },
        "visitation_signature": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "executable_walk": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "arepo_admission_ref": {
          "type": [
            "string",
            "null"
          ]
        },
        "state_model_ref": {
          "type": [
            "string",
            "null"
          ]
        },
        "source_trace": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "nesting_trace": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      }
    },
    "validationResult": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "status",
        "evidence_refs",
        "failure_ids",
        "authority_ref",
        "notes"
      ],
      "properties": {
        "status": {
          "enum": [
            "PASS",
            "FAIL",
            "BLOCKED",
            "UNRESOLVED",
            "NOT_APPLICABLE"
          ]
        },
        "evidence_refs": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "failure_ids": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "authority_ref": {
          "type": "string",
          "minLength": 1
        },
        "notes": {
          "type": "string"
        }
      }
    },
    "failureRecord": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "failure_id",
        "failure_type",
        "affected_layer",
        "evidence_refs",
        "impact",
        "status"
      ],
      "properties": {
        "failure_id": {
          "type": "string",
          "minLength": 1
        },
        "failure_type": {
          "type": "string",
          "minLength": 1
        },
        "affected_layer": {
          "enum": [
            "OPERATOR",
            "TERM",
            "REALITY",
            "DEPENDENCY",
            "AUTHORITY",
            "TRACE"
          ]
        },
        "evidence_refs": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "impact": {
          "type": "string",
          "minLength": 1
        },
        "status": {
          "enum": [
            "OPEN",
            "CORRECTION_PROPOSED",
            "RETEST_REQUIRED",
            "RESOLVED_WITH_TRACE",
            "ACCEPTED_LIMIT"
          ]
        }
      }
    },
    "correctionRecord": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "correction_id",
        "prior_failure_ref",
        "ascensus_path",
        "changed_ref",
        "evidence_refs",
        "validation_result"
      ],
      "properties": {
        "correction_id": {
          "type": "string",
          "minLength": 1
        },
        "prior_failure_ref": {
          "type": "string",
          "minLength": 1
        },
        "ascensus_path": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "changed_ref": {
          "type": "string",
          "minLength": 1
        },
        "evidence_refs": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "validation_result": {
          "enum": [
            "PASS",
            "FAIL",
            "BLOCKED",
            "UNRESOLVED"
          ]
        }
      }
    }
  }
}
