{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://aips.kivanura.org/spec/aips/pdep/0.1/aips-pdep-spec-c-0.1.schema.json",
  "title": "AIPS PDEP Spec C Lifecycle Record 0.1",
  "description": "Informative authoring/validation profile binding HDIP AI Product PDEP lifecycle evidence to a version-specific AI Product candidate.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "@context",
    "id",
    "type",
    "profile",
    "productIdentity",
    "candidateProductVersion",
    "currentStage",
    "stageStatus",
    "gateDecisions"
  ],
  "properties": {
    "@context": {
      "type": [
        "string",
        "object",
        "array"
      ]
    },
    "id": {
      "type": "string",
      "format": "uri"
    },
    "type": {
      "const": "PDEPLifecycleRecord"
    },
    "profile": {
      "const": "https://aips.kivanura.org/spec/aips/pdep/0.1/"
    },
    "productIdentity": {
      "type": "string",
      "format": "uri"
    },
    "candidateProductVersion": {
      "type": "string",
      "format": "uri"
    },
    "currentStage": {
      "type": "integer",
      "minimum": 0,
      "maximum": 11
    },
    "stageStatus": {
      "enum": [
        "IN_PROGRESS",
        "COMPLETED",
        "BLOCKED",
        "REVALIDATION_REQUIRED"
      ]
    },
    "preliminaryQualification": {
      "$ref": "#/$defs/PreliminaryQualification"
    },
    "authorityDecisionRef": {
      "type": "string",
      "format": "uri"
    },
    "constitutionProfile": {
      "$ref": "#/$defs/ConstitutionProfile"
    },
    "riskDecisionRef": {
      "type": "string",
      "format": "uri"
    },
    "constraintReportRef": {
      "type": "string",
      "format": "uri"
    },
    "behaviorContractRef": {
      "type": "string",
      "format": "uri"
    },
    "definitiveQualification": {
      "$ref": "#/$defs/DefinitiveQualification"
    },
    "governanceProfileRef": {
      "type": "string",
      "format": "uri"
    },
    "aiprodRef": {
      "type": "string",
      "format": "uri"
    },
    "aipdsRef": {
      "type": "string",
      "format": "uri"
    },
    "deploymentRegistration": {
      "$ref": "#/$defs/DeploymentRegistration"
    },
    "dppRef": {
      "type": "string",
      "format": "uri"
    },
    "trustCurrentness": {
      "$ref": "#/$defs/TrustCurrentness"
    },
    "continuousAssurance": {
      "$ref": "#/$defs/ContinuousAssurance"
    },
    "gateDecisions": {
      "type": "array",
      "minItems": 1,
      "items": {
        "$ref": "#/$defs/GateDecision"
      }
    }
  },
  "$defs": {
    "PassFail": {
      "enum": [
        "PASS",
        "FAIL"
      ]
    },
    "GateStatus": {
      "enum": [
        "PASS",
        "CONDITIONAL",
        "FAIL"
      ]
    },
    "Currentness": {
      "enum": [
        "CURRENT",
        "STALE",
        "REVALIDATION_REQUIRED",
        "INVALID"
      ]
    },
    "PreliminaryQualification": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "status",
        "productQualification",
        "intelligencePrimacy",
        "distinctIntelligenceProposition",
        "aiPrimitiveHypothesis",
        "evaluatedAt"
      ],
      "properties": {
        "status": {
          "$ref": "#/$defs/GateStatus"
        },
        "productQualification": {
          "$ref": "#/$defs/PassFail"
        },
        "intelligencePrimacy": {
          "$ref": "#/$defs/PassFail"
        },
        "distinctIntelligenceProposition": {
          "$ref": "#/$defs/PassFail"
        },
        "aiPrimitiveHypothesis": {
          "enum": [
            "DIRECT",
            "TRANSITIVE",
            "UNRESOLVED",
            "NONE"
          ]
        },
        "rationale": {
          "type": "string",
          "minLength": 1
        },
        "evaluatedAt": {
          "type": "string",
          "format": "date-time"
        }
      }
    },
    "CandidateDependency": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "ref",
        "role",
        "versionBinding"
      ],
      "properties": {
        "ref": {
          "type": "string",
          "format": "uri"
        },
        "role": {
          "enum": [
            "AI_PRIMITIVE",
            "MODEL_PRODUCT",
            "AI_PRODUCT",
            "DATA_PRODUCT",
            "KNOWLEDGE",
            "RULES",
            "TOOL",
            "SERVICE",
            "OTHER"
          ]
        },
        "versionBinding": {
          "enum": [
            "EXACT",
            "CONSTRAINED",
            "UNRESOLVED"
          ]
        },
        "material": {
          "type": "boolean"
        }
      }
    },
    "ConstitutionProfile": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "intelligenceCapabilities",
        "intelligenceEffects",
        "agencyAutonomy",
        "embodiment",
        "topologyScope",
        "candidateDependencies"
      ],
      "properties": {
        "intelligenceCapabilities": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "intelligenceEffects": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "agencyAutonomy": {
          "type": "string",
          "minLength": 1
        },
        "embodiment": {
          "type": "string",
          "minLength": 1
        },
        "topologyScope": {
          "type": "string",
          "minLength": 1
        },
        "candidateDependencies": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/CandidateDependency"
          }
        }
      }
    },
    "DefinitiveQualification": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "qualificationEvidenceRef",
        "status",
        "apt",
        "compiledAt"
      ],
      "properties": {
        "qualificationEvidenceRef": {
          "type": "string",
          "format": "uri"
        },
        "status": {
          "$ref": "#/$defs/Currentness"
        },
        "apt": {
          "enum": [
            "Primary",
            "Derived"
          ]
        },
        "derivationTopology": {
          "enum": [
            "SingleUpstream",
            "Composite"
          ]
        },
        "compiledAt": {
          "type": "string",
          "format": "date-time"
        },
        "compilationMethod": {
          "type": "string",
          "minLength": 1
        }
      },
      "allOf": [
        {
          "if": {
            "properties": {
              "apt": {
                "const": "Derived"
              }
            },
            "required": [
              "apt"
            ]
          },
          "then": {
            "required": [
              "derivationTopology"
            ]
          }
        },
        {
          "if": {
            "properties": {
              "apt": {
                "const": "Primary"
              }
            },
            "required": [
              "apt"
            ]
          },
          "then": {
            "not": {
              "required": [
                "derivationTopology"
              ]
            }
          }
        }
      ]
    },
    "DeploymentRegistration": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "deploymentRef",
        "catalogEntryRef",
        "marketplaceEntryRef",
        "deployedAt"
      ],
      "properties": {
        "deploymentRef": {
          "type": "string",
          "format": "uri"
        },
        "catalogEntryRef": {
          "type": "string",
          "format": "uri"
        },
        "marketplaceEntryRef": {
          "type": "string",
          "format": "uri"
        },
        "deployedAt": {
          "type": "string",
          "format": "date-time"
        }
      }
    },
    "TrustCurrentness": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "qualification",
        "dependencies",
        "governance",
        "assurance",
        "evaluatedAt"
      ],
      "properties": {
        "qualification": {
          "$ref": "#/$defs/Currentness"
        },
        "dependencies": {
          "$ref": "#/$defs/Currentness"
        },
        "governance": {
          "$ref": "#/$defs/Currentness"
        },
        "assurance": {
          "$ref": "#/$defs/Currentness"
        },
        "evaluatedAt": {
          "type": "string",
          "format": "date-time"
        }
      }
    },
    "ContinuousAssurance": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "status",
        "lastEvaluatedAt",
        "evidenceRefs"
      ],
      "properties": {
        "status": {
          "enum": [
            "HEALTHY",
            "ATTENTION_REQUIRED",
            "REVALIDATION_REQUIRED",
            "SUSPENDED"
          ]
        },
        "lastEvaluatedAt": {
          "type": "string",
          "format": "date-time"
        },
        "evidenceRefs": {
          "type": "array",
          "items": {
            "type": "string",
            "format": "uri"
          }
        },
        "earliestReentryStage": {
          "type": "integer",
          "minimum": 1,
          "maximum": 10
        },
        "reason": {
          "type": "string"
        },
        "covpObservationSetRefs": {
          "type": "array",
          "items": {
            "type": "string",
            "format": "uri"
          },
          "uniqueItems": true
        },
        "fitnessCurrentness": {
          "enum": [
            "CURRENT",
            "STALE",
            "REASSESSMENT_REQUIRED",
            "INSUFFICIENT"
          ]
        },
        "valueEvidenceCurrentness": {
          "enum": [
            "CURRENT",
            "STALE",
            "INSUFFICIENT"
          ]
        },
        "valueReviewRequired": {
          "type": "boolean"
        }
      }
    },
    "GateDecision": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "gate",
        "stage",
        "status",
        "evaluatedAt"
      ],
      "properties": {
        "gate": {
          "enum": [
            "Preconditions",
            "PreliminaryAIQualification",
            "Authority",
            "ConstitutionTopology",
            "RiskTier",
            "Constraints",
            "IntelligenceBehaviorContract",
            "DefinitiveAIQualification",
            "GovernanceCompilation",
            "AIPRODFinalization",
            "AIPDSGeneration",
            "Promotion",
            "ContinuousAssurance"
          ]
        },
        "stage": {
          "type": "integer",
          "minimum": 0,
          "maximum": 11
        },
        "status": {
          "$ref": "#/$defs/GateStatus"
        },
        "evaluatedAt": {
          "type": "string",
          "format": "date-time"
        },
        "evidenceRefs": {
          "type": "array",
          "items": {
            "type": "string",
            "format": "uri"
          }
        },
        "reason": {
          "type": "string"
        }
      }
    }
  },
  "allOf": [
    {
      "if": {
        "properties": {
          "currentStage": {
            "minimum": 1
          }
        }
      },
      "then": {
        "required": [
          "preliminaryQualification"
        ]
      }
    },
    {
      "if": {
        "properties": {
          "currentStage": {
            "minimum": 2
          }
        }
      },
      "then": {
        "required": [
          "authorityDecisionRef"
        ]
      }
    },
    {
      "if": {
        "properties": {
          "currentStage": {
            "minimum": 3
          }
        }
      },
      "then": {
        "required": [
          "constitutionProfile"
        ]
      }
    },
    {
      "if": {
        "properties": {
          "currentStage": {
            "minimum": 4
          }
        }
      },
      "then": {
        "required": [
          "riskDecisionRef"
        ]
      }
    },
    {
      "if": {
        "properties": {
          "currentStage": {
            "minimum": 5
          }
        }
      },
      "then": {
        "required": [
          "constraintReportRef"
        ]
      }
    },
    {
      "if": {
        "properties": {
          "currentStage": {
            "minimum": 6
          }
        }
      },
      "then": {
        "required": [
          "behaviorContractRef"
        ]
      }
    },
    {
      "if": {
        "properties": {
          "currentStage": {
            "minimum": 7
          }
        }
      },
      "then": {
        "required": [
          "definitiveQualification",
          "governanceProfileRef"
        ]
      }
    },
    {
      "if": {
        "properties": {
          "currentStage": {
            "minimum": 8
          }
        }
      },
      "then": {
        "required": [
          "aiprodRef"
        ]
      }
    },
    {
      "if": {
        "properties": {
          "currentStage": {
            "minimum": 9
          }
        }
      },
      "then": {
        "required": [
          "aipdsRef"
        ]
      }
    },
    {
      "if": {
        "properties": {
          "currentStage": {
            "const": 10
          }
        }
      },
      "then": {
        "required": [
          "deploymentRegistration",
          "dppRef",
          "trustCurrentness"
        ],
        "properties": {
          "definitiveQualification": {
            "properties": {
              "status": {
                "const": "CURRENT"
              }
            }
          },
          "trustCurrentness": {
            "properties": {
              "qualification": {
                "const": "CURRENT"
              },
              "dependencies": {
                "const": "CURRENT"
              },
              "governance": {
                "const": "CURRENT"
              },
              "assurance": {
                "const": "CURRENT"
              }
            }
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "currentStage": {
            "const": 11
          }
        }
      },
      "then": {
        "required": [
          "deploymentRegistration",
          "dppRef",
          "trustCurrentness",
          "continuousAssurance"
        ]
      }
    }
  ]
}
