{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://sediment.so/schemas/training-rows/recovery-row/v1.json",
  "title": "RecoveryRow",
  "description": "One recovery training row.",
  "type": "object",
  "properties": {
    "org_id": {
      "type": "string",
      "description": "The deployment's tenant id, normalized. Bound to the server."
    },
    "recipe_id": {
      "const": "recovery_ci",
      "type": "string",
      "description": "The closed evidence recipe that produced this training row."
    },
    "recipe_version": {
      "const": 1,
      "type": "integer",
      "description": "The version of the evidence recipe; increment it when recipe semantics change."
    },
    "repo": {
      "type": "string",
      "description": "`owner/repo`, lowercased. Empty string when the sender omitted it."
    },
    "branch": {
      "type": "string",
      "description": "The branch the run or commit belongs to."
    },
    "workflow_name": {
      "type": "string",
      "description": "The workflow that failed and then passed."
    },
    "workflow_path": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "description": "The workflow definition's repo-relative path — the stable identity a display name does not give you. Null when unreported."
    },
    "failed_commit_sha": {
      "type": "string",
      "description": "The commit whose run failed."
    },
    "fixed_commit_sha": {
      "type": "string",
      "description": "The commit whose run passed."
    },
    "failed_outcome_id": {
      "type": "string",
      "description": "Id of the failing CI outcome."
    },
    "fixed_outcome_id": {
      "type": "string",
      "description": "Id of the passing CI outcome."
    },
    "recovery_diff": {
      "type": "string",
      "description": "The unified diff from the failing commit to the fixing one."
    },
    "failed_inference_call_ids": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Inference calls attributed to the failing commit."
    },
    "fixed_inference_call_ids": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Inference calls attributed to the fixing commit."
    },
    "provenance": {
      "$ref": "#/$defs/Provenance",
      "description": "The structured provenance for this artifact."
    },
    "split": {
      "enum": [
        "train",
        "eval"
      ],
      "type": "string",
      "description": "Which side of the deterministic eval split this row is on, hashed on `session_id` so a session never straddles both."
    },
    "schema_id": {
      "const": "https://sediment.so/schemas/training-rows/recovery-row/v1.json",
      "type": "string",
      "description": "The canonical wire-shape contract for this row."
    },
    "schema_version": {
      "const": 1,
      "type": "integer",
      "description": "The positive integer version of the canonical row schema."
    }
  },
  "additionalProperties": false,
  "required": [
    "org_id",
    "recipe_id",
    "recipe_version",
    "repo",
    "branch",
    "workflow_name",
    "workflow_path",
    "failed_commit_sha",
    "fixed_commit_sha",
    "failed_outcome_id",
    "fixed_outcome_id",
    "recovery_diff",
    "failed_inference_call_ids",
    "fixed_inference_call_ids",
    "provenance",
    "split",
    "schema_id",
    "schema_version"
  ],
  "$defs": {
    "Provenance": {
      "type": "object",
      "properties": {
        "policy_version": {
          "type": "string",
          "description": "The derivation implementation policy version."
        },
        "quarantine_revision": {
          "type": "integer",
          "description": "The integer quarantine-log high-water mark used for the derivation."
        },
        "policy_digest": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "SHA-256 of the fully resolved derivation policy when available."
        }
      },
      "additionalProperties": false,
      "required": [
        "policy_version",
        "quarantine_revision",
        "policy_digest"
      ]
    }
  }
}
