{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://sediment.so/schemas/training-rows/sediment-rlvr-rollout/v4.json",
  "title": "SedimentRolloutRow",
  "description": "One Sediment RLVR rollout segment.",
  "type": "object",
  "properties": {
    "instance_id": {
      "type": "string",
      "pattern": "^[^\\u0000\\uD800-\\uDFFF]*$",
      "description": "Stable target-row identity derived from recorded facts."
    },
    "recipe_id": {
      "const": "rlvr_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."
    },
    "reward_source": {
      "enum": [
        "resolved_ci_pass",
        "resolved_ci_fail"
      ],
      "type": "string",
      "description": "The closed source of the directional reward; absent without a verdict."
    },
    "ci_resolution": {
      "$ref": "#/$defs/CIResolution",
      "description": "The selected attempt-aware CI resolution for this row."
    },
    "org_id": {
      "type": "string",
      "pattern": "^[^\\u0000\\uD800-\\uDFFF]*$",
      "description": "The deployment's tenant id, normalized. Bound to the server."
    },
    "session_id": {
      "type": "string",
      "pattern": "^[^\\u0000\\uD800-\\uDFFF]*$",
      "description": "The coding-agent session this belongs to (ADR 0002)."
    },
    "segment_index": {
      "type": "integer",
      "description": "Zero-based position of this contiguous segment."
    },
    "turns": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/RLVRTurnRow"
      },
      "description": "The captured turns in this contiguous rollout segment."
    },
    "verifier_results": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/CIOutcome"
      },
      "description": "The exact recorded CI outcomes that support this row."
    },
    "ci_resolutions": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/CIResolution"
      },
      "description": "The attempt-aware CI resolutions visible to this row."
    },
    "attribution_source": {
      "enum": [
        "git_notes",
        "jaccard"
      ],
      "type": "string",
      "description": "How the underlying attribution was established."
    },
    "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."
    },
    "provenance": {
      "$ref": "#/$defs/Provenance",
      "description": "The structured provenance for this artifact."
    },
    "session_commit_observation_ids": {
      "type": "array",
      "items": {
        "type": "string",
        "pattern": "^[^\\u0000\\uD800-\\uDFFF]*$"
      },
      "description": "Sorted unique observation IDs matching emitted CI resolutions and source Rollout Session."
    },
    "repository_identity": {
      "anyOf": [
        {
          "$ref": "#/$defs/RepositoryIdentity"
        },
        {
          "type": "null"
        }
      ],
      "description": "Qualified provider, host, and repository ID; null for an unambiguous legacy repository."
    },
    "schema_id": {
      "const": "https://sediment.so/schemas/training-rows/sediment-rlvr-rollout/v4.json",
      "type": "string",
      "description": "The canonical wire-shape contract for this row."
    },
    "schema_version": {
      "const": 4,
      "type": "integer",
      "description": "The positive integer version of the canonical row schema."
    }
  },
  "additionalProperties": false,
  "required": [
    "instance_id",
    "recipe_id",
    "recipe_version",
    "org_id",
    "session_id",
    "segment_index",
    "turns",
    "verifier_results",
    "ci_resolutions",
    "attribution_source",
    "split",
    "provenance",
    "session_commit_observation_ids",
    "repository_identity",
    "schema_id",
    "schema_version"
  ],
  "$defs": {
    "CIResolution": {
      "type": "object",
      "properties": {
        "org_id": {
          "type": "string",
          "pattern": "^[^\\u0000\\uD800-\\uDFFF]*$",
          "description": "The deployment's tenant id, normalized. Bound to the server."
        },
        "repo": {
          "type": "string",
          "pattern": "^[^\\u0000\\uD800-\\uDFFF]*$",
          "description": "`owner/repo`, lowercased. Empty string when the sender omitted it."
        },
        "commit_sha": {
          "type": "string",
          "description": "Full-length commit sha, lowercased."
        },
        "verdict": {
          "anyOf": [
            {
              "enum": [
                "passed",
                "failed",
                "error",
                "timed_out",
                "cancelled",
                "skipped",
                "neutral",
                "unknown"
              ],
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "The resolved pass or failure; null means no directional verdict."
        },
        "reliability": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "description": "Trust in the resolved verdict, bounded to [0, 1]."
        },
        "suspected_flake": {
          "type": "boolean",
          "description": "Whether the lineage contains both passing and failing verdict attempts."
        },
        "workflow_resolutions": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/CIWorkflowResolution"
          },
          "description": "Attempt-aware resolutions for the commit's workflows."
        },
        "source_outcome_ids": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^[^\\u0000\\uD800-\\uDFFF]*$"
          },
          "description": "Every CI outcome id that contributed to the resolution."
        },
        "verdict_outcome_ids": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^[^\\u0000\\uD800-\\uDFFF]*$"
          },
          "description": "The final semantic verdict outcome id from each workflow lineage."
        },
        "non_verdict_outcome_ids": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^[^\\u0000\\uD800-\\uDFFF]*$"
          },
          "description": "The infrastructure, timeout, cancellation, skip, neutral, or unknown evidence."
        },
        "provenance": {
          "$ref": "#/$defs/Provenance",
          "description": "The structured provenance for this artifact."
        },
        "repository_identity": {
          "anyOf": [
            {
              "$ref": "#/$defs/RepositoryIdentity"
            },
            {
              "type": "null"
            }
          ],
          "description": "Qualified provider, host, and repository ID; null for an unambiguous legacy repository."
        }
      },
      "additionalProperties": false,
      "required": [
        "org_id",
        "repo",
        "commit_sha",
        "verdict",
        "reliability",
        "suspected_flake",
        "workflow_resolutions",
        "source_outcome_ids",
        "verdict_outcome_ids",
        "non_verdict_outcome_ids",
        "provenance",
        "repository_identity"
      ]
    },
    "CIWorkflowResolution": {
      "type": "object",
      "properties": {
        "provider": {
          "enum": [
            "github_actions",
            "jenkins",
            "gitlab_ci",
            "circleci",
            "buildkite",
            "other"
          ],
          "type": "string",
          "description": "Which system this fact came from."
        },
        "run_id": {
          "type": "string",
          "pattern": "^[^\\u0000\\uD800-\\uDFFF]*$",
          "description": "The provider-issued pipeline-run identity."
        },
        "workflow_id": {
          "anyOf": [
            {
              "type": "string",
              "pattern": "^[^\\u0000\\uD800-\\uDFFF]*$"
            },
            {
              "type": "null"
            }
          ],
          "description": "The provider-issued workflow definition identity, when supplied."
        },
        "workflow_name": {
          "type": "string",
          "description": "The CI workflow's display name."
        },
        "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."
        },
        "branch": {
          "type": "string",
          "pattern": "^[^\\u0000\\uD800-\\uDFFF]*$",
          "description": "The branch the run or commit belongs to."
        },
        "verdict": {
          "anyOf": [
            {
              "enum": [
                "passed",
                "failed",
                "error",
                "timed_out",
                "cancelled",
                "skipped",
                "neutral",
                "unknown"
              ],
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "The resolved pass or failure; null means no directional verdict."
        },
        "reliability": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "description": "Trust in the resolved verdict, bounded to [0, 1]."
        },
        "suspected_flake": {
          "type": "boolean",
          "description": "Whether the lineage contains both passing and failing verdict attempts."
        },
        "source_outcome_ids": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^[^\\u0000\\uD800-\\uDFFF]*$"
          },
          "description": "Every CI outcome id that contributed to the resolution."
        },
        "verdict_outcome_id": {
          "anyOf": [
            {
              "type": "string",
              "pattern": "^[^\\u0000\\uD800-\\uDFFF]*$"
            },
            {
              "type": "null"
            }
          ],
          "description": "The final semantic pass or failure outcome id."
        },
        "non_verdict_outcome_ids": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^[^\\u0000\\uD800-\\uDFFF]*$"
          },
          "description": "The infrastructure, timeout, cancellation, skip, neutral, or unknown evidence."
        }
      },
      "additionalProperties": false,
      "required": [
        "provider",
        "run_id",
        "workflow_id",
        "workflow_name",
        "workflow_path",
        "branch",
        "verdict",
        "reliability",
        "suspected_flake",
        "source_outcome_ids",
        "verdict_outcome_id",
        "non_verdict_outcome_ids"
      ]
    },
    "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"
      ]
    },
    "RepositoryIdentity": {
      "type": "object",
      "properties": {
        "provider": {
          "const": "github",
          "type": "string",
          "description": "The forge provider that assigns the immutable repository ID."
        },
        "host": {
          "type": "string",
          "pattern": "^[^\\u0000\\uD800-\\uDFFF]*$",
          "description": "The lowercase configured forge host."
        },
        "repository_id": {
          "type": "string",
          "pattern": "^[^\\u0000\\uD800-\\uDFFF]*$",
          "description": "Immutable provider repository ID within its forge host."
        }
      },
      "additionalProperties": false,
      "required": [
        "provider",
        "host",
        "repository_id"
      ]
    },
    "RLVRTurnRow": {
      "type": "object",
      "properties": {
        "inference_call_id": {
          "type": "string",
          "pattern": "^[^\\u0000\\uD800-\\uDFFF]*$",
          "description": "Id of the inference call this record belongs to."
        },
        "new_messages": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/RLVRInferenceMessageRow"
          },
          "description": "Only the structured messages this turn added to the trajectory."
        },
        "completion": {
          "type": "string",
          "description": "The model's response text."
        },
        "tool_calls": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/ToolCallPart"
          },
          "description": "Structured function calls requested by the assistant."
        },
        "decisions": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/RLVRDecisionRow"
          },
          "description": "The developer decisions recorded against this completion."
        }
      },
      "additionalProperties": false,
      "required": [
        "inference_call_id",
        "new_messages",
        "completion",
        "tool_calls",
        "decisions"
      ]
    },
    "RLVRInferenceMessageRow": {
      "type": "object",
      "properties": {
        "role": {
          "type": "string",
          "description": "The trainer-facing message role."
        },
        "parts": {
          "type": "array",
          "items": {
            "anyOf": [
              {
                "$ref": "#/$defs/TextPart"
              },
              {
                "$ref": "#/$defs/ReasoningPart"
              },
              {
                "$ref": "#/$defs/ToolCallPart"
              },
              {
                "$ref": "#/$defs/ToolCallResponsePart"
              }
            ]
          },
          "description": "Ordered text, reasoning, tool-call, or tool-response parts."
        },
        "finish_reason": {
          "type": "string",
          "description": "The model service's finish reason; omitted when unreported."
        }
      },
      "additionalProperties": false,
      "required": [
        "role",
        "parts"
      ]
    },
    "TextPart": {
      "type": "object",
      "properties": {
        "type": {
          "const": "text",
          "type": "string",
          "description": "The message-part discriminator."
        },
        "content": {
          "type": "string",
          "description": "Plain text, without JSON encoding around it."
        }
      },
      "additionalProperties": false,
      "required": [
        "type",
        "content"
      ]
    },
    "ReasoningPart": {
      "type": "object",
      "properties": {
        "type": {
          "const": "reasoning",
          "type": "string",
          "description": "The message-part discriminator."
        },
        "content": {
          "type": "string",
          "description": "Readable model reasoning. Opaque provider state remains on the fact's `raw` payload."
        }
      },
      "additionalProperties": false,
      "required": [
        "type",
        "content"
      ]
    },
    "ToolCallPart": {
      "type": "object",
      "properties": {
        "type": {
          "const": "tool_call",
          "type": "string",
          "description": "The message-part discriminator."
        },
        "id": {
          "type": "string",
          "pattern": "^[^\\u0000\\uD800-\\uDFFF]*$",
          "description": "The agent-visible tool-call id. It is separate from `model_call_id`."
        },
        "name": {
          "type": "string",
          "description": "The tool the model requested."
        },
        "arguments": {
          "type": "object",
          "additionalProperties": {},
          "description": "The parsed argument object. Malformed wire arguments become `{}`; the original stays on `InferenceCall.raw`."
        }
      },
      "additionalProperties": false,
      "required": [
        "type",
        "id",
        "name",
        "arguments"
      ]
    },
    "ToolCallResponsePart": {
      "type": "object",
      "properties": {
        "type": {
          "const": "tool_call_response",
          "type": "string",
          "description": "The message-part discriminator."
        },
        "id": {
          "type": "string",
          "pattern": "^[^\\u0000\\uD800-\\uDFFF]*$",
          "description": "The tool-call id this result answers."
        },
        "result": {
          "description": "The structured tool result supplied to the model."
        }
      },
      "additionalProperties": false,
      "required": [
        "type",
        "id",
        "result"
      ]
    },
    "RLVRDecisionRow": {
      "type": "object",
      "properties": {
        "accepted": {
          "type": "boolean",
          "description": "Whether the developer took the change."
        },
        "explicit": {
          "type": "boolean",
          "description": "Whether a real human gesture produced this decision."
        },
        "agent_harness": {
          "enum": [
            "claude-code",
            "copilot",
            "codex",
            "cursor",
            "pi"
          ],
          "type": "string",
          "description": "Which coding agent harness produced this fact."
        },
        "interaction_mode": {
          "enum": [
            "agent",
            "inline"
          ],
          "type": "string",
          "description": "Whether the edit interaction was `agent` or `inline`."
        },
        "file_path": {
          "type": "string",
          "description": "Repo-relative path of the file the record concerns."
        }
      },
      "additionalProperties": false,
      "required": [
        "accepted",
        "explicit",
        "agent_harness",
        "interaction_mode",
        "file_path"
      ]
    },
    "CIOutcome": {
      "type": "object",
      "properties": {
        "schema_version": {
          "enum": [
            1,
            2
          ],
          "type": "integer",
          "description": "The Fact payload contract: 1 for stored legacy payloads, 2 for identity-capable payloads."
        },
        "repository_provider": {
          "anyOf": [
            {
              "const": "github",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "Captured forge provider."
        },
        "repository_host": {
          "anyOf": [
            {
              "type": "string",
              "pattern": "^[^\\u0000\\uD800-\\uDFFF]*$"
            },
            {
              "type": "null"
            }
          ],
          "description": "Configured lowercase forge host."
        },
        "repository_id": {
          "anyOf": [
            {
              "type": "string",
              "pattern": "^[^\\u0000\\uD800-\\uDFFF]*$"
            },
            {
              "type": "null"
            }
          ],
          "description": "Immutable provider repository ID within its forge host."
        },
        "outcome_id": {
          "type": "string",
          "pattern": "^[^\\u0000\\uD800-\\uDFFF]*$",
          "description": "Stable id for this outcome."
        },
        "org_id": {
          "type": "string",
          "pattern": "^[^\\u0000\\uD800-\\uDFFF]*$",
          "description": "The deployment's tenant id, normalized. Bound to the server."
        },
        "provider": {
          "enum": [
            "github_actions",
            "jenkins",
            "gitlab_ci",
            "circleci",
            "buildkite",
            "other"
          ],
          "type": "string",
          "description": "The normalized CI system selected by a capture adapter or declared by the bearer-authenticated vendor integration."
        },
        "run_id": {
          "type": "string",
          "pattern": "^[^\\u0000\\uD800-\\uDFFF]*$",
          "description": "The provider-issued pipeline-run id, unique within the deployment organization and provider namespace."
        },
        "run_attempt": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "minimum": 1,
          "maximum": 9223372036854775807,
          "description": "The positive provider attempt number. Null when the provider omits it."
        },
        "repo": {
          "type": "string",
          "pattern": "^[^\\u0000\\uD800-\\uDFFF]*$",
          "description": "`owner/repo`, lowercased. Empty string when the sender omitted it."
        },
        "commit_sha": {
          "type": "string",
          "description": "Full-length commit sha, lowercased."
        },
        "branch": {
          "type": "string",
          "pattern": "^[^\\u0000\\uD800-\\uDFFF]*$",
          "description": "The branch the run or commit belongs to."
        },
        "result": {
          "enum": [
            "passed",
            "failed",
            "error",
            "timed_out",
            "cancelled",
            "skipped",
            "neutral",
            "unknown"
          ],
          "type": "string",
          "description": "Sediment's normalized terminal result."
        },
        "workflow_name": {
          "type": "string",
          "description": "The CI workflow's display name."
        },
        "workflow_id": {
          "anyOf": [
            {
              "type": "string",
              "pattern": "^[^\\u0000\\uD800-\\uDFFF]*$"
            },
            {
              "type": "null"
            }
          ],
          "description": "The provider's stable workflow or pipeline-definition identity."
        },
        "workflow_path": {
          "anyOf": [
            {
              "type": "string",
              "pattern": "^[^\\u0000\\uD800-\\uDFFF]*$"
            },
            {
              "type": "null"
            }
          ],
          "description": "The workflow definition's repo-relative path — the stable identity a display name does not give you. Null when unreported."
        },
        "run_url": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "Link to the run in the CI system. Null when unreported; never run identity."
        },
        "provider_result": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "The exact terminal value reported by the provider before normalization."
        },
        "error_type": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "A structured, low-cardinality provider error type. Null when absent."
        },
        "reason": {
          "anyOf": [
            {
              "type": "string",
              "maxLength": 4096
            },
            {
              "type": "null"
            }
          ],
          "description": "A bounded, Basic-redacted provider reason. Null when absent."
        },
        "source_event_type": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "The source contract and event type. Null when unreported."
        },
        "source_spec_version": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "The source contract version. Null when unreported."
        },
        "source_event_id": {
          "anyOf": [
            {
              "type": "string",
              "pattern": "^[^\\u0000\\uD800-\\uDFFF]*$"
            },
            {
              "type": "null"
            }
          ],
          "description": "The provider or standard source event identity. Null when unreported."
        },
        "pr_number": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "minimum": 1,
          "maximum": 9223372036854775807,
          "description": "The pull request the run belongs to, when there is one."
        },
        "captured_at": {
          "type": "string",
          "format": "date-time",
          "description": "When Sediment stored the fact, stamped server-side. Windows and ordering anchor on this, never on a client clock."
        },
        "raw": {
          "type": "object",
          "additionalProperties": {},
          "description": "The source payload after Basic redaction, kept so a translator defect stays recoverable. Shape varies by provider; never join on it."
        }
      },
      "additionalProperties": false,
      "required": [
        "schema_version",
        "repository_provider",
        "repository_host",
        "repository_id",
        "outcome_id",
        "org_id",
        "provider",
        "run_id",
        "run_attempt",
        "repo",
        "commit_sha",
        "branch",
        "result",
        "workflow_name",
        "workflow_id",
        "workflow_path",
        "run_url",
        "provider_result",
        "error_type",
        "reason",
        "source_event_type",
        "source_spec_version",
        "source_event_id",
        "pr_number",
        "captured_at",
        "raw"
      ]
    }
  }
}
