{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:orbiplex:schema:corpus-passage-evidence-manifest:v1",
  "title": "Corpus Passage Evidence Manifest v1",
  "description": "Immutable, host-made manifest of the evidence one Agent passage reads (P094-023a): the query, Room and reading Room subject, the passage's Corpus inference-Flow binding, each item (an execution record, an artifact a record names, a candidate publication, or a proposal, review or Chair decision of the Room) by exact ref and digest with the execution that names it, its step and source instance, whether it was included, and the projection that rendered them. The rendered content is kept by content address. Required items are always included; an optional item left out names why; nothing is cut. The manifest carries no timestamp, so equal evidence has one address. 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",
    "manifest/ref",
    "query/id",
    "room/id",
    "reader",
    "inference-flow-binding/ref",
    "projection",
    "bytes/max",
    "items",
    "class/key",
    "content/ref",
    "content/digest",
    "content/size-bytes"
  ],
  "properties": {
    "schema": {
      "const": "corpus-passage-evidence-manifest.v1"
    },
    "manifest/ref": {
      "type": "string",
      "pattern": "^corpus-evidence-manifest:sha256:[A-Za-z0-9_-]{43}$",
      "maxLength": 512
    },
    "query/id": {
      "type": "string",
      "pattern": "^query:[^\\s]+$",
      "maxLength": 512
    },
    "room/id": {
      "type": "string",
      "pattern": "^room:[^\\s]+$",
      "maxLength": 512
    },
    "reader": {
      "$ref": "corpus-reasoning-room-policy.v1.schema.json#/$defs/room-subject"
    },
    "inference-flow-binding/ref": {
      "type": "string",
      "pattern": "^[a-z][a-z0-9-]*:[^\\s]+$",
      "maxLength": 512
    },
    "projection": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "revision"
      ],
      "properties": {
        "id": {
          "const": "corpus-task-pack-evidence"
        },
        "revision": {
          "enum": [
            1,
            2
          ]
        }
      }
    },
    "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",
          "included"
        ],
        "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"
          },
          "included": {
            "type": "boolean"
          },
          "execution/ref": {
            "type": "string",
            "pattern": "^corpus-task-pack-execution:sha256:[A-Za-z0-9_-]{43}$",
            "maxLength": 512
          },
          "step/id": {
            "$ref": "operator-task-common.v1.schema.json#/$defs/name"
          },
          "source/instance": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9-]*:[^\\s]+$",
            "maxLength": 512
          },
          "omitted/reason": {
            "enum": [
              "exceeds-limit"
            ]
          }
        },
        "allOf": [
          {
            "if": {
              "properties": {
                "included": {
                  "const": false
                }
              },
              "required": [
                "included"
              ]
            },
            "then": {
              "required": [
                "omitted/reason"
              ],
              "properties": {
                "required": {
                  "const": false
                }
              }
            },
            "else": {
              "not": {
                "required": [
                  "omitted/reason"
                ]
              }
            }
          },
          {
            "if": {
              "properties": {
                "kind": {
                  "const": "artifact"
                }
              },
              "required": [
                "kind"
              ]
            },
            "then": {
              "required": [
                "execution/ref"
              ]
            }
          }
        ]
      }
    },
    "class/key": {
      "enum": [
        "Public",
        "Community",
        "Personal"
      ]
    },
    "content/ref": {
      "type": "string",
      "pattern": "^object-store:sha256:[A-Za-z0-9_-]{43}$"
    },
    "content/digest": {
      "type": "string",
      "pattern": "^sha256:[A-Za-z0-9_-]{43}$"
    },
    "content/size-bytes": {
      "type": "integer",
      "minimum": 1,
      "maximum": 262144
    },
    "review/target": {
      "$ref": "#/$defs/review-target"
    },
    "phase": {
      "$ref": "corpus-task-pack-phase.v1.schema.json"
    }
  },
  "$defs": {
    "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
          }
        },
        "not": {
          "required": [
            "phase"
          ]
        }
      },
      "else": {
        "required": [
          "phase"
        ]
      }
    }
  ]
}
