{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://sediment.so/schemas/training-rows/nemo-gym-rollout/v2.json",
  "title": "NemoGymRolloutRow",
  "description": "One NeMo Gym rollout mapping.",
  "type": "object",
  "properties": {
    "responses_create_params": {
      "$ref": "#/$defs/NemoGymResponsesCreateParams",
      "description": "The captured segment input in the NeMo Gym field."
    },
    "response": {
      "$ref": "#/$defs/NemoGymResponse",
      "description": "The captured segment turns in the NeMo Gym response field."
    },
    "reward": {
      "type": "number",
      "description": "Numeric reinforcement-learning value; absent without pass/fail evidence."
    },
    "metadata": {
      "$ref": "#/$defs/NemoGymMetadata",
      "description": "Sediment evidence excluded from trainer inputs."
    }
  },
  "additionalProperties": false,
  "required": [
    "responses_create_params",
    "response",
    "metadata"
  ],
  "$defs": {
    "NemoGymResponsesCreateParams": {
      "type": "object",
      "properties": {
        "input": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/RLVRInferenceMessageRow"
          },
          "description": "The structured messages at the start of this segment."
        }
      },
      "additionalProperties": false,
      "required": [
        "input"
      ]
    },
    "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",
          "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",
          "description": "The tool-call id this result answers."
        },
        "result": {
          "description": "The structured tool result supplied to the model."
        }
      },
      "additionalProperties": false,
      "required": [
        "type",
        "id",
        "result"
      ]
    },
    "NemoGymResponse": {
      "type": "object",
      "properties": {
        "turns": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/RLVRTurnRow"
          },
          "description": "The captured turns in this contiguous rollout segment."
        }
      },
      "additionalProperties": false,
      "required": [
        "turns"
      ]
    },
    "RLVRTurnRow": {
      "type": "object",
      "properties": {
        "inference_call_id": {
          "type": "string",
          "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"
      ]
    },
    "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"
      ]
    },
    "NemoGymMetadata": {
      "type": "object",
      "properties": {
        "instance_id": {
          "type": "string",
          "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."
        },
        "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)."
        },
        "segment_index": {
          "type": "integer",
          "description": "Zero-based position of this contiguous segment."
        },
        "verification": {
          "$ref": "#/$defs/Verification",
          "description": "Operator configuration for running the verifier again."
        },
        "verifier_results": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/CIOutcome"
          },
          "description": "The exact recorded CI outcomes that support this row."
        },
        "ci_resolution": {
          "$ref": "#/$defs/CIResolution",
          "description": "The selected attempt-aware CI resolution for 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."
        },
        "schema_id": {
          "const": "https://sediment.so/schemas/training-rows/nemo-gym-rollout/v2.json",
          "type": "string",
          "description": "The canonical wire-shape contract for this row."
        },
        "schema_version": {
          "const": 2,
          "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",
        "verifier_results",
        "attribution_source",
        "split",
        "provenance",
        "schema_id",
        "schema_version"
      ]
    },
    "Verification": {
      "type": "object",
      "properties": {
        "verification_command": {
          "type": "string",
          "description": "The opaque operator-configured verifier command."
        }
      },
      "additionalProperties": false,
      "required": [
        "verification_command"
      ]
    },
    "CIOutcome": {
      "type": "object",
      "properties": {
        "schema_version": {
          "const": 1,
          "type": "integer",
          "description": "The normalized fact-contract version. CI outcomes use 1."
        },
        "outcome_id": {
          "type": "string",
          "description": "Stable id for this outcome."
        },
        "org_id": {
          "type": "string",
          "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",
          "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",
          "description": "`owner/repo`, lowercased. Empty string when the sender omitted it."
        },
        "commit_sha": {
          "type": "string",
          "description": "Full-length commit sha, lowercased."
        },
        "branch": {
          "type": "string",
          "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"
            },
            {
              "type": "null"
            }
          ],
          "description": "The provider's stable workflow or pipeline-definition identity."
        },
        "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."
        },
        "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"
            },
            {
              "type": "null"
            }
          ],
          "maxLength": 4096,
          "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"
            },
            {
              "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",
        "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"
      ]
    },
    "CIResolution": {
      "type": "object",
      "properties": {
        "org_id": {
          "type": "string",
          "description": "The deployment's tenant id, normalized. Bound to the server."
        },
        "repo": {
          "type": "string",
          "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"
          },
          "description": "Every CI outcome id that contributed to the resolution."
        },
        "verdict_outcome_ids": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "The final semantic verdict outcome id from each workflow lineage."
        },
        "non_verdict_outcome_ids": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "The infrastructure, timeout, cancellation, skip, neutral, or unknown evidence."
        },
        "provenance": {
          "$ref": "#/$defs/Provenance",
          "description": "The structured provenance for this artifact."
        }
      },
      "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"
      ]
    },
    "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",
          "description": "The provider-issued pipeline-run identity."
        },
        "workflow_id": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "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",
          "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"
          },
          "description": "Every CI outcome id that contributed to the resolution."
        },
        "verdict_outcome_id": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "The final semantic pass or failure outcome id."
        },
        "non_verdict_outcome_ids": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "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"
      ]
    }
  }
}
