{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://sediment.so/schemas/training-rows/diff-sft-metadata/v1.json",
  "title": "DiffSFTMetadata",
  "description": "Sediment evidence for one diff-SFT sample.",
  "type": "object",
  "properties": {
    "org_id": {
      "type": "string",
      "description": "The deployment's tenant id, normalized. Bound to the server."
    },
    "session_id": {
      "type": "string",
      "description": "The coding-agent session this belongs to (ADR 0002)."
    },
    "repo": {
      "type": "string",
      "description": "`owner/repo`, lowercased. Empty string when the sender omitted it."
    },
    "commit_sha": {
      "type": "string",
      "description": "Full-length commit sha, lowercased."
    },
    "source_model": {
      "type": "string",
      "description": "The model that served the source inference call."
    },
    "completion_id": {
      "type": "string",
      "description": "The inference call that supplied the training target."
    },
    "recipe_id": {
      "enum": [
        "sft_curated",
        "sft_verified"
      ],
      "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."
    },
    "eligibility_source": {
      "enum": [
        "explicit_accept",
        "edit_retention",
        "resolved_ci_pass"
      ],
      "type": "string",
      "description": "The closed evidence source that made this supervised target eligible."
    },
    "label_confidence": {
      "type": "number",
      "description": "Trust in the derived training label, bounded to [0, 1]."
    },
    "ci_reliability": {
      "anyOf": [
        {
          "type": "number"
        },
        {
          "type": "null"
        }
      ],
      "description": "Trust in the resolved CI evidence, separate from the categorical label."
    },
    "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."
    },
    "source_ids": {
      "$ref": "#/$defs/SourceIds",
      "description": "The facts this row was assembled from."
    },
    "schema_id": {
      "const": "https://sediment.so/schemas/training-rows/diff-sft-sample/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",
    "session_id",
    "repo",
    "commit_sha",
    "source_model",
    "completion_id",
    "recipe_id",
    "recipe_version",
    "eligibility_source",
    "label_confidence",
    "ci_reliability",
    "provenance",
    "split",
    "source_ids",
    "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"
      ]
    },
    "SourceIds": {
      "type": "object",
      "properties": {
        "inference_call_id": {
          "type": "string",
          "description": "Id of the inference call this record belongs to."
        },
        "decision_ids": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Decisions that contributed to the row."
        },
        "ci_outcome_ids": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "CI outcomes that contributed to the row."
        }
      },
      "additionalProperties": false,
      "required": [
        "inference_call_id",
        "decision_ids",
        "ci_outcome_ids"
      ]
    }
  }
}
