{
  "$defs": {
    "AssessmentStatus": {
      "enum": [
        "pass",
        "warn",
        "fail",
        "not_assessed"
      ],
      "title": "AssessmentStatus",
      "type": "string"
    },
    "CandidateDecision": {
      "additionalProperties": false,
      "properties": {
        "actor_id": {
          "maxLength": 128,
          "minLength": 1,
          "pattern": "^[a-z][a-z0-9]*(?:[._:-][a-z0-9]+)*$",
          "title": "Actor Id",
          "type": "string"
        },
        "candidate_id": {
          "maxLength": 128,
          "minLength": 1,
          "pattern": "^[a-z][a-z0-9]*(?:[._:-][a-z0-9]+)*$",
          "title": "Candidate Id",
          "type": "string"
        },
        "decided_at_utc": {
          "maxLength": 40,
          "minLength": 20,
          "title": "Decided At Utc",
          "type": "string"
        },
        "decision_id": {
          "maxLength": 128,
          "minLength": 1,
          "pattern": "^[a-z][a-z0-9]*(?:[._:-][a-z0-9]+)*$",
          "title": "Decision Id",
          "type": "string"
        },
        "evaluation_selection": {
          "anyOf": [
            {
              "$ref": "#/$defs/EvaluationSelectionReceipt"
            },
            {
              "type": "null"
            }
          ],
          "default": null
        },
        "rationale": {
          "maxLength": 2000,
          "minLength": 1,
          "title": "Rationale",
          "type": "string"
        },
        "sequence": {
          "minimum": 1,
          "title": "Sequence",
          "type": "integer"
        },
        "status": {
          "$ref": "#/$defs/DecisionStatus"
        }
      },
      "required": [
        "decision_id",
        "sequence",
        "candidate_id",
        "status",
        "actor_id",
        "decided_at_utc",
        "rationale"
      ],
      "title": "CandidateDecision",
      "type": "object"
    },
    "CandidateDelta": {
      "additionalProperties": false,
      "properties": {
        "field_path": {
          "maxLength": 512,
          "minLength": 1,
          "pattern": "^[a-z][a-z0-9_]*(?:\\.[a-z0-9_]+|\\[[0-9]+\\])*$",
          "title": "Field Path",
          "type": "string"
        },
        "value": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "integer"
            },
            {
              "type": "number"
            },
            {
              "type": "string"
            }
          ],
          "title": "Value"
        }
      },
      "required": [
        "field_path",
        "value"
      ],
      "title": "CandidateDelta",
      "type": "object"
    },
    "CandidateLifecycle": {
      "enum": [
        "defined",
        "generated",
        "evaluated",
        "rejected",
        "eligible",
        "ranked",
        "proposed",
        "selected",
        "approved"
      ],
      "title": "CandidateLifecycle",
      "type": "string"
    },
    "CandidateRecord": {
      "additionalProperties": false,
      "properties": {
        "candidate_id": {
          "maxLength": 128,
          "minLength": 1,
          "pattern": "^[a-z][a-z0-9]*(?:[._:-][a-z0-9]+)*$",
          "title": "Candidate Id",
          "type": "string"
        },
        "changes": {
          "default": [],
          "items": {
            "$ref": "#/$defs/CandidateDelta"
          },
          "title": "Changes",
          "type": "array"
        },
        "evaluation_binding": {
          "anyOf": [
            {
              "$ref": "#/$defs/EvaluationCandidateBinding"
            },
            {
              "type": "null"
            }
          ],
          "default": null
        },
        "feasibility": {
          "$ref": "#/$defs/AssessmentStatus",
          "default": "not_assessed"
        },
        "issues": {
          "default": [],
          "items": {
            "$ref": "#/$defs/IssueRecord"
          },
          "title": "Issues",
          "type": "array"
        },
        "lifecycle": {
          "$ref": "#/$defs/CandidateLifecycle"
        },
        "objective_values": {
          "default": [],
          "items": {
            "$ref": "#/$defs/ObjectiveValue"
          },
          "title": "Objective Values",
          "type": "array"
        },
        "parent_candidate_id": {
          "anyOf": [
            {
              "maxLength": 128,
              "minLength": 1,
              "pattern": "^[a-z][a-z0-9]*(?:[._:-][a-z0-9]+)*$",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Parent Candidate Id"
        },
        "rank": {
          "anyOf": [
            {
              "minimum": 1,
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Rank"
        },
        "result_ids": {
          "default": [],
          "items": {
            "maxLength": 128,
            "minLength": 1,
            "pattern": "^[a-z][a-z0-9]*(?:[._:-][a-z0-9]+)*$",
            "type": "string"
          },
          "title": "Result Ids",
          "type": "array"
        }
      },
      "required": [
        "candidate_id",
        "lifecycle"
      ],
      "title": "CandidateRecord",
      "type": "object"
    },
    "CandidateTransition": {
      "additionalProperties": false,
      "properties": {
        "actor_id": {
          "maxLength": 128,
          "minLength": 1,
          "pattern": "^[a-z][a-z0-9]*(?:[._:-][a-z0-9]+)*$",
          "title": "Actor Id",
          "type": "string"
        },
        "candidate_id": {
          "maxLength": 128,
          "minLength": 1,
          "pattern": "^[a-z][a-z0-9]*(?:[._:-][a-z0-9]+)*$",
          "title": "Candidate Id",
          "type": "string"
        },
        "from_lifecycle": {
          "$ref": "#/$defs/CandidateLifecycle"
        },
        "occurred_at_utc": {
          "maxLength": 40,
          "minLength": 20,
          "title": "Occurred At Utc",
          "type": "string"
        },
        "rationale": {
          "maxLength": 2000,
          "minLength": 1,
          "title": "Rationale",
          "type": "string"
        },
        "sequence": {
          "minimum": 1,
          "title": "Sequence",
          "type": "integer"
        },
        "to_lifecycle": {
          "$ref": "#/$defs/CandidateLifecycle"
        },
        "transition_id": {
          "maxLength": 128,
          "minLength": 1,
          "pattern": "^[a-z][a-z0-9]*(?:[._:-][a-z0-9]+)*$",
          "title": "Transition Id",
          "type": "string"
        }
      },
      "required": [
        "transition_id",
        "sequence",
        "candidate_id",
        "from_lifecycle",
        "to_lifecycle",
        "actor_id",
        "occurred_at_utc",
        "rationale"
      ],
      "title": "CandidateTransition",
      "type": "object"
    },
    "DecisionStatus": {
      "enum": [
        "proposed",
        "selected",
        "approved",
        "rejected"
      ],
      "title": "DecisionStatus",
      "type": "string"
    },
    "EvaluationCandidateBinding": {
      "additionalProperties": false,
      "properties": {
        "assessment_sha256": {
          "pattern": "^[0-9a-f]{64}$",
          "title": "Assessment Sha256",
          "type": "string"
        },
        "selectable": {
          "title": "Selectable",
          "type": "boolean"
        },
        "source": {
          "$ref": "#/$defs/EvaluationSource"
        },
        "warning_check_ids": {
          "default": [],
          "items": {
            "maxLength": 128,
            "minLength": 1,
            "pattern": "^[a-z][a-z0-9]*(?:[._:-][a-z0-9]+)*$",
            "type": "string"
          },
          "title": "Warning Check Ids",
          "type": "array"
        }
      },
      "required": [
        "source",
        "assessment_sha256",
        "selectable"
      ],
      "title": "EvaluationCandidateBinding",
      "type": "object"
    },
    "EvaluationDecisionScope": {
      "additionalProperties": false,
      "properties": {
        "candidate_ids": {
          "items": {
            "maxLength": 128,
            "minLength": 1,
            "pattern": "^[a-z][a-z0-9]*(?:[._:-][a-z0-9]+)*$",
            "type": "string"
          },
          "maxItems": 100,
          "minItems": 1,
          "title": "Candidate Ids",
          "type": "array"
        },
        "comparison_sha256": {
          "pattern": "^[0-9a-f]{64}$",
          "title": "Comparison Sha256",
          "type": "string"
        },
        "context_sha256": {
          "pattern": "^[0-9a-f]{64}$",
          "title": "Context Sha256",
          "type": "string"
        },
        "evaluation_id": {
          "maxLength": 128,
          "minLength": 1,
          "pattern": "^[a-z][a-z0-9]*(?:[._:-][a-z0-9]+)*$",
          "title": "Evaluation Id",
          "type": "string"
        },
        "manifest_sha256": {
          "pattern": "^[0-9a-f]{64}$",
          "title": "Manifest Sha256",
          "type": "string"
        },
        "policy_sha256": {
          "pattern": "^[0-9a-f]{64}$",
          "title": "Policy Sha256",
          "type": "string"
        },
        "recommended_candidate_ids": {
          "default": [],
          "items": {
            "maxLength": 128,
            "minLength": 1,
            "pattern": "^[a-z][a-z0-9]*(?:[._:-][a-z0-9]+)*$",
            "type": "string"
          },
          "title": "Recommended Candidate Ids",
          "type": "array"
        }
      },
      "required": [
        "evaluation_id",
        "manifest_sha256",
        "comparison_sha256",
        "policy_sha256",
        "context_sha256",
        "candidate_ids"
      ],
      "title": "EvaluationDecisionScope",
      "type": "object"
    },
    "EvaluationSelectionReceipt": {
      "additionalProperties": false,
      "properties": {
        "accepted_warning_check_ids": {
          "default": [],
          "items": {
            "maxLength": 128,
            "minLength": 1,
            "pattern": "^[a-z][a-z0-9]*(?:[._:-][a-z0-9]+)*$",
            "type": "string"
          },
          "title": "Accepted Warning Check Ids",
          "type": "array"
        },
        "expected_ledger_sha256": {
          "pattern": "^[0-9a-f]{64}$",
          "title": "Expected Ledger Sha256",
          "type": "string"
        },
        "request_id": {
          "maxLength": 128,
          "minLength": 1,
          "pattern": "^[a-z][a-z0-9]*(?:[._:-][a-z0-9]+)*$",
          "title": "Request Id",
          "type": "string"
        }
      },
      "required": [
        "request_id",
        "expected_ledger_sha256"
      ],
      "title": "EvaluationSelectionReceipt",
      "type": "object"
    },
    "EvaluationSource": {
      "additionalProperties": false,
      "properties": {
        "artifact_index_sha256": {
          "pattern": "^[0-9a-f]{64}$",
          "title": "Artifact Index Sha256",
          "type": "string"
        },
        "candidate_id": {
          "maxLength": 128,
          "minLength": 1,
          "pattern": "^[a-z][a-z0-9]*(?:[._:-][a-z0-9]+)*$",
          "title": "Candidate Id",
          "type": "string"
        },
        "contract_version": {
          "const": "1.0.0",
          "default": "1.0.0",
          "title": "Contract Version",
          "type": "string"
        },
        "input_snapshot_sha256": {
          "pattern": "^[0-9a-f]{64}$",
          "title": "Input Snapshot Sha256",
          "type": "string"
        },
        "manifest_sha256": {
          "pattern": "^[0-9a-f]{64}$",
          "title": "Manifest Sha256",
          "type": "string"
        },
        "result_index_sha256": {
          "pattern": "^[0-9a-f]{64}$",
          "title": "Result Index Sha256",
          "type": "string"
        },
        "run_id": {
          "maxLength": 128,
          "minLength": 1,
          "pattern": "^[a-z][a-z0-9]*(?:[._:-][a-z0-9]+)*$",
          "title": "Run Id",
          "type": "string"
        }
      },
      "required": [
        "candidate_id",
        "run_id",
        "manifest_sha256",
        "input_snapshot_sha256",
        "result_index_sha256",
        "artifact_index_sha256"
      ],
      "title": "EvaluationSource",
      "type": "object"
    },
    "IssueRecord": {
      "additionalProperties": false,
      "properties": {
        "action_hint": {
          "anyOf": [
            {
              "maxLength": 1000,
              "minLength": 1,
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Action Hint"
        },
        "code": {
          "maxLength": 128,
          "minLength": 1,
          "pattern": "^[a-z][a-z0-9]*(?:[._:-][a-z0-9]+)*$",
          "title": "Code",
          "type": "string"
        },
        "issue_id": {
          "maxLength": 128,
          "minLength": 1,
          "pattern": "^[a-z][a-z0-9]*(?:[._:-][a-z0-9]+)*$",
          "title": "Issue Id",
          "type": "string"
        },
        "message": {
          "maxLength": 2000,
          "minLength": 1,
          "title": "Message",
          "type": "string"
        },
        "severity": {
          "$ref": "#/$defs/IssueSeverity"
        },
        "source_path": {
          "anyOf": [
            {
              "maxLength": 512,
              "minLength": 1,
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Source Path"
        },
        "statement_ids": {
          "default": [],
          "items": {
            "maxLength": 128,
            "minLength": 1,
            "pattern": "^[a-z][a-z0-9]*(?:[._:-][a-z0-9]+)*$",
            "type": "string"
          },
          "title": "Statement Ids",
          "type": "array"
        }
      },
      "required": [
        "issue_id",
        "code",
        "severity",
        "message"
      ],
      "title": "IssueRecord",
      "type": "object"
    },
    "IssueSeverity": {
      "enum": [
        "info",
        "warning",
        "error"
      ],
      "title": "IssueSeverity",
      "type": "string"
    },
    "ObjectiveValue": {
      "additionalProperties": false,
      "properties": {
        "direction": {
          "enum": [
            "minimize",
            "maximize"
          ],
          "title": "Direction",
          "type": "string"
        },
        "metric_id": {
          "maxLength": 128,
          "minLength": 1,
          "pattern": "^[a-z][a-z0-9]*(?:[._:-][a-z0-9]+)*$",
          "title": "Metric Id",
          "type": "string"
        },
        "normalized_score": {
          "anyOf": [
            {
              "maximum": 1.0,
              "minimum": 0.0,
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Normalized Score"
        },
        "value": {
          "title": "Value",
          "type": "number"
        }
      },
      "required": [
        "metric_id",
        "value",
        "direction"
      ],
      "title": "ObjectiveValue",
      "type": "object"
    },
    "StudyDecisionScope": {
      "additionalProperties": false,
      "properties": {
        "candidate_ids": {
          "items": {
            "maxLength": 128,
            "minLength": 1,
            "pattern": "^[a-z][a-z0-9]*(?:[._:-][a-z0-9]+)*$",
            "type": "string"
          },
          "maxItems": 1024,
          "minItems": 1,
          "title": "Candidate Ids",
          "type": "array"
        },
        "comparison_sha256": {
          "pattern": "^[0-9a-f]{64}$",
          "title": "Comparison Sha256",
          "type": "string"
        },
        "context_sha256": {
          "pattern": "^[0-9a-f]{64}$",
          "title": "Context Sha256",
          "type": "string"
        },
        "evaluation_id": {
          "maxLength": 128,
          "minLength": 1,
          "pattern": "^[a-z][a-z0-9]*(?:[._:-][a-z0-9]+)*$",
          "title": "Evaluation Id",
          "type": "string"
        },
        "manifest_sha256": {
          "pattern": "^[0-9a-f]{64}$",
          "title": "Manifest Sha256",
          "type": "string"
        },
        "policy_sha256": {
          "pattern": "^[0-9a-f]{64}$",
          "title": "Policy Sha256",
          "type": "string"
        },
        "recommended_candidate_ids": {
          "default": [],
          "items": {
            "maxLength": 128,
            "minLength": 1,
            "pattern": "^[a-z][a-z0-9]*(?:[._:-][a-z0-9]+)*$",
            "type": "string"
          },
          "title": "Recommended Candidate Ids",
          "type": "array"
        },
        "scope_kind": {
          "const": "study",
          "default": "study",
          "title": "Scope Kind",
          "type": "string"
        },
        "shortlist_candidate_ids": {
          "items": {
            "maxLength": 128,
            "minLength": 1,
            "pattern": "^[a-z][a-z0-9]*(?:[._:-][a-z0-9]+)*$",
            "type": "string"
          },
          "maxItems": 4,
          "minItems": 1,
          "title": "Shortlist Candidate Ids",
          "type": "array"
        }
      },
      "required": [
        "evaluation_id",
        "manifest_sha256",
        "comparison_sha256",
        "policy_sha256",
        "context_sha256",
        "candidate_ids",
        "shortlist_candidate_ids"
      ],
      "title": "StudyDecisionScope",
      "type": "object"
    }
  },
  "$id": "urn:sindri:contracts:1.0.0:candidate-ledger",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "additionalProperties": false,
  "properties": {
    "candidates": {
      "default": [],
      "items": {
        "$ref": "#/$defs/CandidateRecord"
      },
      "title": "Candidates",
      "type": "array"
    },
    "contract_suite": {
      "const": "sindri.contracts",
      "default": "sindri.contracts",
      "title": "Contract Suite",
      "type": "string"
    },
    "contract_version": {
      "const": "1.0.0",
      "default": "1.0.0",
      "title": "Contract Version",
      "type": "string"
    },
    "decisions": {
      "default": [],
      "items": {
        "$ref": "#/$defs/CandidateDecision"
      },
      "title": "Decisions",
      "type": "array"
    },
    "evaluation_scope": {
      "anyOf": [
        {
          "$ref": "#/$defs/EvaluationDecisionScope"
        },
        {
          "$ref": "#/$defs/StudyDecisionScope"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Evaluation Scope"
    },
    "ledger_id": {
      "default": "ledger.design-candidates",
      "maxLength": 128,
      "minLength": 1,
      "pattern": "^[a-z][a-z0-9]*(?:[._:-][a-z0-9]+)*$",
      "title": "Ledger Id",
      "type": "string"
    },
    "schema_kind": {
      "const": "candidate_ledger",
      "default": "candidate_ledger",
      "title": "Schema Kind",
      "type": "string"
    },
    "study_id": {
      "maxLength": 128,
      "minLength": 1,
      "pattern": "^[a-z][a-z0-9]*(?:[._:-][a-z0-9]+)*$",
      "title": "Study Id",
      "type": "string"
    },
    "transitions": {
      "default": [],
      "items": {
        "$ref": "#/$defs/CandidateTransition"
      },
      "title": "Transitions",
      "type": "array"
    }
  },
  "required": [
    "study_id"
  ],
  "title": "CandidateLedger",
  "type": "object",
  "x-sindri-contract-suite": "sindri.contracts",
  "x-sindri-contract-version": "1.0.0"
}
