{
  "$id": "https://context-guard.local/schemas/receipt-diagnostics-report-v1.json",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "additionalProperties": false,
  "$defs": {
    "evidence_boundary": {
      "additionalProperties": false,
      "properties": {
        "evidence_class": {"const": "companion_local_receipt_only"}, "host_request_owned": {"const": false}, "provider_claim_authority": {"const": false}, "provider_join_status": {"const": "missing"}, "runtime_observer_present": {"const": false}, "schema_version": {"const": "contextguard-receipt-evidence-boundary/v1"}, "selected_branch": {"const": "S2-UNSUPPORTED"}, "selected_transport": {"const": "NONE"}, "stage1_evidence": {"const": false}, "stage2_evidence": {"const": false}
      },
      "required": ["evidence_class", "host_request_owned", "provider_claim_authority", "provider_join_status", "runtime_observer_present", "schema_version", "selected_branch", "selected_transport", "stage1_evidence", "stage2_evidence"],
      "type": "object"
    },
    "prefix_delta": {
      "additionalProperties": false,
      "properties": {
        "current_prefix_bytes": {"maximum": 900000, "minimum": 0, "type": "integer"}, "current_prefix_hmac_sha256": {"pattern": "^[0-9a-f]{64}$", "type": "string"}, "current_reuse_basis_points": {"maximum": 10000, "minimum": 0, "type": "integer"}, "current_sample_bytes": {"maximum": 65536, "minimum": 0, "type": "integer"}, "current_truncated": {"type": "boolean"}, "current_window_count": {"maximum": 1024, "minimum": 0, "type": "integer"}, "matched_window_count": {"maximum": 1024, "minimum": 0, "type": "integer"}, "prefix_delta_bytes": {"maximum": 900000, "minimum": -900000, "type": "integer"}, "previous_prefix_bytes": {"maximum": 900000, "minimum": 0, "type": "integer"}, "previous_prefix_hmac_sha256": {"pattern": "^[0-9a-f]{64}$", "type": "string"}, "previous_prefix_present": {"type": "boolean"}, "previous_retention_basis_points": {"maximum": 10000, "minimum": 0, "type": "integer"}, "previous_sample_bytes": {"maximum": 65536, "minimum": 0, "type": "integer"}, "previous_truncated": {"type": "boolean"}, "previous_window_count": {"maximum": 1024, "minimum": 0, "type": "integer"}, "rolling_status": {"enum": ["unavailable", "partial", "complete"], "type": "string"}
      },
      "required": ["current_prefix_bytes", "current_prefix_hmac_sha256", "current_reuse_basis_points", "current_sample_bytes", "current_truncated", "current_window_count", "matched_window_count", "prefix_delta_bytes", "previous_prefix_bytes", "previous_prefix_hmac_sha256", "previous_prefix_present", "previous_retention_basis_points", "previous_sample_bytes", "previous_truncated", "previous_window_count", "rolling_status"],
      "type": "object"
    },
    "route": {
      "additionalProperties": false,
      "oneOf": [
        {"properties": {"disposition": {"const": "defer"}, "reason": {"const": "beneficial"}}, "required": ["disposition", "reason"]},
        {"properties": {"disposition": {"const": "pass_through"}, "reason": {"enum": ["input_too_small", "savings_too_small", "savings_ratio_too_small", "mandatory_expansion_cost"]}}, "required": ["disposition", "reason"]}
      ],
      "properties": {
        "blueprint_bytes": {"maximum": 900000, "minimum": 0, "type": "integer"}, "disposition": {"enum": ["defer", "pass_through"], "type": "string"}, "handle_bytes": {"maximum": 900000, "minimum": 0, "type": "integer"}, "input_bytes": {"maximum": 900000, "minimum": 0, "type": "integer"}, "mandatory_expansion_bytes": {"maximum": 900000, "minimum": 0, "type": "integer"}, "policy_version": {"const": "contextguard-receipt-router/v1"}, "predicted_cost_bytes": {"maximum": 900000, "minimum": 0, "type": "integer"}, "predicted_savings_bytes": {"maximum": 900000, "minimum": -900000, "type": "integer"}, "reason": {"enum": ["beneficial", "input_too_small", "savings_too_small", "savings_ratio_too_small", "mandatory_expansion_cost"], "type": "string"}, "retained_wire_bytes": {"maximum": 900000, "minimum": 0, "type": "integer"}, "savings_basis_points": {"maximum": 10000, "minimum": -9000000000, "type": "integer"}, "wrapper_bytes": {"maximum": 900000, "minimum": 0, "type": "integer"}
      },
      "required": ["blueprint_bytes", "disposition", "handle_bytes", "input_bytes", "mandatory_expansion_bytes", "policy_version", "predicted_cost_bytes", "predicted_savings_bytes", "reason", "retained_wire_bytes", "savings_basis_points", "wrapper_bytes"],
      "type": "object"
    }
  },
  "properties": {
    "advisory": {"additionalProperties": false, "oneOf": [{"properties": {"lane": {"const": "none"}, "reason": {"enum": ["protection_refused", "exact_path_required"]}}, "required": ["lane", "reason"]}, {"properties": {"lane": {"const": "scout"}, "reason": {"enum": ["input_too_small", "savings_too_small", "savings_ratio_too_small", "mandatory_expansion_cost", "prefix_evidence_empty", "prior_prefix_missing", "rolling_sample_partial", "prefix_churn_high"]}}, "required": ["lane", "reason"]}, {"properties": {"lane": {"const": "surgeon"}, "reason": {"const": "bounded_stable_benefit"}}, "required": ["lane", "reason"]}], "properties": {"lane": {"enum": ["none", "scout", "surgeon"], "type": "string"}, "only": {"const": true}, "reason": {"enum": ["protection_refused", "exact_path_required", "input_too_small", "savings_too_small", "savings_ratio_too_small", "mandatory_expansion_cost", "prefix_evidence_empty", "prior_prefix_missing", "rolling_sample_partial", "prefix_churn_high", "bounded_stable_benefit"], "type": "string"}}, "required": ["lane", "only", "reason"], "type": "object"},
    "efficacy_claim_authority": {"const": false}, "evidence_boundary": {"$ref": "#/$defs/evidence_boundary"}, "firewall": {"$ref": "receipt-shadow-firewall-report-v1.json"}, "live_observation_authority": {"const": false}, "prefix_delta": {"$ref": "#/$defs/prefix_delta"}, "provider_claim_authority": {"const": false}, "provider_routing_authority": {"const": false}, "route": {"$ref": "#/$defs/route"}, "schema_version": {"const": "contextguard-receipt-diagnostics-report/v1"}, "state_scope": {"enum": ["process", "durable"], "type": "string"}, "subject_kind": {"enum": ["evidence", "evidence_pack", "blueprint", "tool_schema_catalog", "command_capture"], "type": "string"}
  },
  "required": ["advisory", "efficacy_claim_authority", "evidence_boundary", "firewall", "live_observation_authority", "prefix_delta", "provider_claim_authority", "provider_routing_authority", "route", "schema_version", "state_scope", "subject_kind"],
  "title": "Context Guard Receipt diagnostics report",
  "type": "object"
}
