{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:orbiplex:schema:corpus-passage-evidence.prepare.request:v1",
  "title": "Corpus Passage Evidence Preparation Request v1",
  "description": "Request to fix the evidence one Agent passage will read (P094-023a). It names the Corpus inference-Flow binding of the passage and each wanted item by exact ref and digest; `latest` is never an input. The host reads every item as the binding's Room subject and answers an immutable manifest, or refuses. A reviewer passage's evidence names its review target: the exact proposal and candidate under review, fixed before inference; the candidate is then a required, included item. Projection revision 1 retains its historical shape and requires an item. Revision 2 binds a package-owned, host-derived phase, permits empty initial evidence and separates current candidate from historical reviews. The host checks that every phase basis is required, included and exact; it never truncates evidence.",
  "type": "object",
  "additionalProperties": false,
  "x-dia-status": "draft",
  "required": [
    "schema",
    "inference-flow-binding/ref",
    "projection",
    "bytes/max",
    "items"
  ],
  "properties": {
    "schema": {
      "const": "corpus-passage-evidence.prepare.request.v1"
    },
    "inference-flow-binding/ref": {
      "type": "string",
      "pattern": "^[a-z][a-z0-9-]*:[^\\s]+$",
      "maxLength": 512
    },
    "projection": {
      "$ref": "#/$defs/projection"
    },
    "bytes/max": {
      "type": "integer",
      "minimum": 1,
      "maximum": 262144
    },
    "items": {
      "type": "array",
      "minItems": 0,
      "maxItems": 32,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "kind",
          "ref",
          "digest",
          "required"
        ],
        "properties": {
          "kind": {
            "enum": [
              "execution",
              "artifact",
              "candidate",
              "proposal",
              "review",
              "decision"
            ]
          },
          "ref": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9-]*:[^\\s]+$",
            "maxLength": 512
          },
          "digest": {
            "type": "string",
            "pattern": "^sha256:[A-Za-z0-9_-]{43}$"
          },
          "required": {
            "type": "boolean"
          }
        }
      }
    },
    "review/target": {
      "$ref": "#/$defs/review-target"
    }
  },
  "$defs": {
    "projection": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "revision"
      ],
      "properties": {
        "id": {
          "const": "corpus-task-pack-evidence"
        },
        "revision": {
          "enum": [
            1,
            2
          ]
        }
      }
    },
    "review-target": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "proposal/ref",
        "proposal/digest",
        "candidate/digest"
      ],
      "properties": {
        "proposal/ref": {
          "type": "string",
          "pattern": "^corpus-experiment:sha256:[A-Za-z0-9_-]{43}$"
        },
        "proposal/digest": {
          "type": "string",
          "pattern": "^sha256:[A-Za-z0-9_-]{43}$"
        },
        "candidate/digest": {
          "type": "string",
          "pattern": "^sha256:[A-Za-z0-9_-]{43}$"
        }
      }
    }
  },
  "allOf": [
    {
      "if": {
        "properties": {
          "projection": {
            "properties": {
              "revision": {
                "const": 1
              }
            }
          }
        }
      },
      "then": {
        "properties": {
          "items": {
            "minItems": 1
          }
        }
      }
    }
  ]
}
