{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:orbiplex:schema:nse-middleware-evidence:v1",
  "title": "NSE Middleware Evidence V1",
  "type": "object",
  "additionalProperties": false,
  "required": ["schema", "schema/v", "invocation/ref", "hook/id", "hook/v", "module/ref", "package/digest", "grant/refs", "input/schema", "output/schema", "timeout/ms", "input/max-bytes", "output/max-bytes", "causal/ref", "offer/fields", "evidence"],
  "properties": {
    "schema": {"const": "nse-middleware-evidence.v1"},
    "schema/v": {"const": 1},
    "invocation/ref": {"type": "string", "minLength": 1, "maxLength": 256},
    "hook/id": {"type": "string", "minLength": 1, "maxLength": 256},
    "hook/v": {"type": "integer", "minimum": 1},
    "module/ref": {"type": "string", "minLength": 1, "maxLength": 256},
    "package/digest": {"type": "string", "pattern": "^sha256:[0-9a-f]{64}$"},
    "grant/refs": {"type": "array", "maxItems": 16, "uniqueItems": true, "items": {"type": "string", "minLength": 1, "maxLength": 256}},
    "input/schema": {"type": "string", "minLength": 1, "maxLength": 256},
    "output/schema": {"const": "nse-middleware-evidence.v1"},
    "timeout/ms": {"type": "integer", "minimum": 1},
    "input/max-bytes": {"type": "integer", "minimum": 1},
    "output/max-bytes": {"type": "integer", "minimum": 1},
    "causal/ref": {"type": "string", "minLength": 1, "maxLength": 256},
    "offer/fields": {"type": "array", "minItems": 1, "uniqueItems": true, "items": {"$ref": "#/$defs/target"}},
    "evidence": {"type": "array", "maxItems": 32, "items": {"$ref": "#/$defs/evidence_item"}}
  },
  "$defs": {
    "target": {"type": "string", "enum": ["candidate-provider", "candidate-transport-kind", "candidate-location", "candidate-parameter-count", "candidate-runtime-ref", "candidate-capability"]},
    "value": {"oneOf": [{"type": "boolean"}, {"type": "integer"}, {"type": "string", "minLength": 1, "maxLength": 512}]},
    "candidate_ref": {"type": "string", "minLength": 1, "maxLength": 256},
    "evidence_item": {
      "oneOf": [
        {"type": "object", "additionalProperties": false, "required": ["kind", "candidate/ref", "target", "value"], "properties": {"kind": {"const": "annotation"}, "candidate/ref": {"$ref": "#/$defs/candidate_ref"}, "target": {"$ref": "#/$defs/target"}, "value": {"$ref": "#/$defs/value"}}},
        {"type": "object", "additionalProperties": false, "required": ["kind", "candidate/ref", "score/millis"], "properties": {"kind": {"const": "score"}, "candidate/ref": {"$ref": "#/$defs/candidate_ref"}, "score/millis": {"type": "integer", "minimum": -1000, "maximum": 1000}}},
        {"type": "object", "additionalProperties": false, "required": ["kind", "candidate/ref", "feature", "value"], "properties": {"kind": {"const": "feature"}, "candidate/ref": {"$ref": "#/$defs/candidate_ref"}, "feature": {"type": "string", "enum": ["locality-match", "cost-rank", "latency-rank", "capability-match", "policy-match"]}, "value": {"$ref": "#/$defs/value"}}},
        {"type": "object", "additionalProperties": false, "required": ["kind", "candidate/ref", "reason"], "properties": {"kind": {"const": "candidate-suggestion"}, "candidate/ref": {"$ref": "#/$defs/candidate_ref"}, "reason": {"type": "string", "minLength": 1, "maxLength": 512}}}
      ]
    }
  },
  "x-dia-status": "accepted",
  "x-dia-basis": ["doc/project/40-proposals/085-operator-sovereign-extensibility-and-experiment-packages.md"]
}
