{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://tokrepo.com/schemas/handoff-package.schema.json",
  "title": "TokRepo Agent Handoff Package",
  "description": "Read-only package plan produced by tokrepo agent-handoff and tokrepo_handoff_plan after an agent creates reusable local work. It never publishes automatically.",
  "type": "object",
  "required": [
    "schema_version",
    "asset_title",
    "asset_kind",
    "visibility_default",
    "publish_requires_human_confirmation",
    "quality_gate",
    "package_manifest"
  ],
  "properties": {
    "schema_version": { "type": "integer", "const": 1 },
    "schema": { "type": "string", "format": "uri" },
    "asset_title": { "type": "string" },
    "asset_kind": { "type": "string" },
    "install_mode": { "type": "string" },
    "visibility_default": { "type": "string", "const": "private" },
    "publish_requires_human_confirmation": { "type": "boolean", "const": true },
    "reusability_score": { "type": "number" },
    "safe_to_suggest_push": { "type": "boolean" },
    "quality_gate": {
      "type": "object",
      "required": ["schema_version", "status", "ready_to_push", "checks", "required_before_push"],
      "properties": {
        "schema_version": { "type": "integer" },
        "schema": { "type": "string" },
        "status": { "type": "string", "enum": ["pass", "caution", "block"] },
        "ready_to_push": { "type": "boolean" },
        "checks": {
          "type": "array",
          "items": {
            "type": "object",
            "required": ["id", "status", "message"],
            "properties": {
              "id": { "type": "string" },
              "status": { "type": "string", "enum": ["pass", "warn", "block"] },
              "message": { "type": "string" }
            },
            "additionalProperties": true
          }
        },
        "blockers": { "type": "array" },
        "warnings": { "type": "array" },
        "required_before_push": { "type": "array", "items": { "type": "string" } }
      },
      "additionalProperties": true
    },
    "quality_gate_summary": {
      "type": "object",
      "properties": {
        "status": { "type": "string", "enum": ["pass", "caution", "block", "empty"] },
        "candidate_count": { "type": "integer" },
        "ready_to_push_count": { "type": "integer" }
      },
      "additionalProperties": true
    },
    "package_manifest": {
      "type": "object",
      "required": ["schema_version", "package_id", "content_hash", "files", "sbom", "provenance", "quality_gate"],
      "properties": {
        "schema_version": { "type": "integer" },
        "package_id": { "type": "string" },
        "content_hash": { "type": "string" },
        "files": { "type": "array" },
        "sbom": { "$ref": "agent-evidence-bundle.schema.json#/properties/sbom" },
        "provenance": { "type": "object", "additionalProperties": true },
        "quality_gate": { "$ref": "#/properties/quality_gate" }
      },
      "additionalProperties": true
    },
    "sbom": { "$ref": "agent-evidence-bundle.schema.json#/properties/sbom" },
    "provenance": { "type": "object", "additionalProperties": true },
    "dedupe_discovery": { "type": "object", "additionalProperties": true },
    "target_compatibility": { "type": "array", "items": { "type": "string" } },
    "files": { "type": "array" },
    "metadata_defaults": { "type": "object", "additionalProperties": true },
    "sensitive_findings": { "type": "array" },
    "safety_review": { "type": "array", "items": { "type": "string" } },
    "suggested_push_command": { "type": "string" }
  },
  "additionalProperties": true
}
