{
  "$defs": {
    "AlignedHunk": {
      "additionalProperties": false,
      "description": "One bounded correspondence or difference between two members.",
      "properties": {
        "hunk_id": {
          "minLength": 1,
          "title": "Hunk Id",
          "type": "string"
        },
        "kind": {
          "$ref": "#/$defs/HunkKind"
        },
        "left_digest": {
          "anyOf": [
            {
              "pattern": "^sha256:[0-9a-f]{64}$",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Left Digest"
        },
        "left_end_line": {
          "minimum": 1,
          "title": "Left End Line",
          "type": "integer"
        },
        "left_member": {
          "minimum": 0,
          "title": "Left Member",
          "type": "integer"
        },
        "left_start_line": {
          "minimum": 1,
          "title": "Left Start Line",
          "type": "integer"
        },
        "preview": {
          "anyOf": [
            {
              "maxLength": 2048,
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Preview"
        },
        "right_digest": {
          "anyOf": [
            {
              "pattern": "^sha256:[0-9a-f]{64}$",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Right Digest"
        },
        "right_end_line": {
          "minimum": 1,
          "title": "Right End Line",
          "type": "integer"
        },
        "right_member": {
          "minimum": 0,
          "title": "Right Member",
          "type": "integer"
        },
        "right_start_line": {
          "minimum": 1,
          "title": "Right Start Line",
          "type": "integer"
        }
      },
      "required": [
        "hunk_id",
        "kind",
        "left_member",
        "right_member",
        "left_start_line",
        "left_end_line",
        "right_start_line",
        "right_end_line"
      ],
      "title": "AlignedHunk",
      "type": "object"
    },
    "CandidateGranularity": {
      "enum": [
        "file",
        "definition",
        "block",
        "expression"
      ],
      "title": "CandidateGranularity",
      "type": "string"
    },
    "CandidateRegion": {
      "additionalProperties": false,
      "description": "One exact member coordinate in a candidate group.",
      "properties": {
        "content_digest": {
          "anyOf": [
            {
              "pattern": "^sha256:[0-9a-f]{64}$",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Content Digest"
        },
        "end_line": {
          "minimum": 1,
          "title": "End Line",
          "type": "integer"
        },
        "entity_id": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Entity Id"
        },
        "language": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Language"
        },
        "path": {
          "minLength": 1,
          "title": "Path",
          "type": "string"
        },
        "role": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Role"
        },
        "source_state_id": {
          "minLength": 1,
          "title": "Source State Id",
          "type": "string"
        },
        "start_line": {
          "minimum": 1,
          "title": "Start Line",
          "type": "integer"
        }
      },
      "required": [
        "source_state_id",
        "path",
        "start_line",
        "end_line"
      ],
      "title": "CandidateRegion",
      "type": "object"
    },
    "EvidenceStrength": {
      "description": "Strength claimed by one observation, never an aggregate score.",
      "enum": [
        "exact",
        "derived",
        "conservative",
        "heuristic",
        "declared",
        "unknown"
      ],
      "title": "EvidenceStrength",
      "type": "string"
    },
    "HunkKind": {
      "enum": [
        "equal",
        "replace",
        "insert",
        "delete"
      ],
      "title": "HunkKind",
      "type": "string"
    },
    "SimilarityCandidate": {
      "additionalProperties": false,
      "description": "A review candidate with method-native evidence and no decision verdict.",
      "properties": {
        "aligned_hunks": {
          "items": {
            "$ref": "#/$defs/AlignedHunk"
          },
          "title": "Aligned Hunks",
          "type": "array"
        },
        "candidate_id": {
          "minLength": 1,
          "title": "Candidate Id",
          "type": "string"
        },
        "configuration_digest": {
          "pattern": "^sha256:[0-9a-f]{64}$",
          "title": "Configuration Digest",
          "type": "string"
        },
        "granularity": {
          "$ref": "#/$defs/CandidateGranularity"
        },
        "limitations": {
          "items": {
            "type": "string"
          },
          "title": "Limitations",
          "type": "array"
        },
        "members": {
          "items": {
            "$ref": "#/$defs/CandidateRegion"
          },
          "minItems": 2,
          "title": "Members",
          "type": "array"
        },
        "method": {
          "$ref": "#/$defs/SimilarityMethod"
        },
        "method_version": {
          "minLength": 1,
          "title": "Method Version",
          "type": "string"
        },
        "provider_run_id": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Provider Run Id"
        },
        "rationale": {
          "minLength": 1,
          "title": "Rationale",
          "type": "string"
        },
        "source_state_id": {
          "minLength": 1,
          "title": "Source State Id",
          "type": "string"
        },
        "strength": {
          "$ref": "#/$defs/EvidenceStrength"
        },
        "threshold": {
          "anyOf": [
            {
              "minimum": 0,
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Threshold"
        },
        "token_count": {
          "anyOf": [
            {
              "minimum": 0,
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Token Count"
        },
        "unmatched_member_regions": {
          "items": {
            "$ref": "#/$defs/CandidateRegion"
          },
          "title": "Unmatched Member Regions",
          "type": "array"
        }
      },
      "required": [
        "candidate_id",
        "source_state_id",
        "granularity",
        "method",
        "method_version",
        "configuration_digest",
        "members",
        "strength",
        "rationale"
      ],
      "title": "SimilarityCandidate",
      "type": "object"
    },
    "SimilarityMethod": {
      "enum": [
        "exact",
        "normalized",
        "external_near_match"
      ],
      "title": "SimilarityMethod",
      "type": "string"
    },
    "SimilarityQuery": {
      "additionalProperties": false,
      "description": "Explicit candidate policy; values are acquisition bounds, not quality scores.",
      "properties": {
        "granularities": {
          "items": {
            "$ref": "#/$defs/CandidateGranularity"
          },
          "title": "Granularities",
          "type": "array"
        },
        "maximum_candidates": {
          "default": 1000,
          "maximum": 100000,
          "minimum": 1,
          "title": "Maximum Candidates",
          "type": "integer"
        },
        "methods": {
          "items": {
            "$ref": "#/$defs/SimilarityMethod"
          },
          "title": "Methods",
          "type": "array"
        },
        "minimum_lines": {
          "default": 3,
          "minimum": 1,
          "title": "Minimum Lines",
          "type": "integer"
        },
        "minimum_tokens": {
          "default": 50,
          "minimum": 1,
          "title": "Minimum Tokens",
          "type": "integer"
        },
        "roles": {
          "items": {
            "type": "string"
          },
          "title": "Roles",
          "type": "array"
        }
      },
      "title": "SimilarityQuery",
      "type": "object"
    }
  },
  "additionalProperties": false,
  "description": "Portable candidates from baseline or independently executed providers.",
  "properties": {
    "artifact_type": {
      "const": "anatomize.similarity",
      "default": "anatomize.similarity",
      "title": "Artifact Type",
      "type": "string"
    },
    "candidates": {
      "items": {
        "$ref": "#/$defs/SimilarityCandidate"
      },
      "title": "Candidates",
      "type": "array"
    },
    "limitations": {
      "items": {
        "type": "string"
      },
      "title": "Limitations",
      "type": "array"
    },
    "provider_artifact_digest": {
      "anyOf": [
        {
          "pattern": "^sha256:[0-9a-f]{64}$",
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Provider Artifact Digest"
    },
    "query": {
      "$ref": "#/$defs/SimilarityQuery"
    },
    "repository_id": {
      "minLength": 1,
      "title": "Repository Id",
      "type": "string"
    },
    "schema_version": {
      "const": "1.0.0",
      "default": "1.0.0",
      "title": "Schema Version",
      "type": "string"
    },
    "source_state_id": {
      "minLength": 1,
      "title": "Source State Id",
      "type": "string"
    }
  },
  "required": [
    "repository_id",
    "source_state_id",
    "query"
  ],
  "title": "SimilarityArtifact",
  "type": "object"
}
