{
  "$defs": {
    "BootstrapMethodDisclosure": {
      "additionalProperties": false,
      "properties": {
        "assumptions": {
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        "ci_level": {
          "type": "string"
        },
        "cluster_key": {
          "oneOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "method": {
          "enum": [
            "paired_percentile_bootstrap",
            "cluster_paired_percentile_bootstrap",
            "unavailable"
          ]
        },
        "resamples": {
          "oneOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ]
        },
        "sample_unit": {
          "enum": [
            "paired_trace_delta"
          ]
        },
        "seed": {
          "oneOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ]
        },
        "unavailable_reason": {
          "oneOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "assumptions",
        "ci_level",
        "cluster_key",
        "method",
        "resamples",
        "sample_unit",
        "seed"
      ],
      "type": "object"
    },
    "CachePolicySnapshot": {
      "additionalProperties": false,
      "properties": {
        "block_after_days": {
          "type": "integer"
        },
        "mode": {
          "enum": [
            "auto",
            "on",
            "off",
            "read_only",
            "refresh"
          ]
        },
        "storage_profile": {
          "enum": [
            "normalized_result_only",
            "full_judge_io"
          ]
        },
        "warn_after_days": {
          "type": "integer"
        }
      },
      "required": [
        "block_after_days",
        "mode",
        "storage_profile",
        "warn_after_days"
      ],
      "type": "object"
    },
    "CacheSummary": {
      "additionalProperties": false,
      "properties": {
        "corrupted_entries": {
          "type": "integer"
        },
        "hits": {
          "type": "integer"
        },
        "key_version": {
          "type": "string"
        },
        "misses": {
          "type": "integer"
        },
        "mode": {
          "enum": [
            "auto",
            "on",
            "off",
            "read_only",
            "refresh"
          ]
        },
        "models_distribution": {
          "additionalProperties": {
            "type": "integer"
          },
          "type": "object"
        },
        "oldest_hit_age_days": {
          "oneOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ]
        },
        "policy": {
          "$ref": "#/$defs/CachePolicySnapshot"
        },
        "policy_violations": {
          "items": {
            "$ref": "#/$defs/PolicyViolationRecord"
          },
          "type": "array"
        },
        "schema_version": {
          "type": "string"
        },
        "stale_hits": {
          "type": "integer"
        },
        "storage_path": {
          "type": "string"
        },
        "storage_profile": {
          "enum": [
            "normalized_result_only",
            "full_judge_io"
          ]
        },
        "writes": {
          "type": "integer"
        }
      },
      "required": [
        "corrupted_entries",
        "hits",
        "key_version",
        "misses",
        "mode",
        "policy",
        "schema_version",
        "stale_hits",
        "storage_path",
        "storage_profile",
        "writes"
      ],
      "type": "object"
    },
    "CohortResult": {
      "additionalProperties": false,
      "properties": {
        "ci_computable": {
          "type": "boolean"
        },
        "ci_lower": {
          "oneOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "ci_meaningful": {
          "type": "boolean"
        },
        "ci_unavailable_reason": {
          "oneOf": [
            {
              "enum": [
                "sample_too_small",
                "zero_variance",
                "computation_failed"
              ]
            },
            {
              "type": "null"
            }
          ]
        },
        "ci_upper": {
          "oneOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "floor_failures": {
          "items": {
            "$ref": "#/$defs/FloorFailure"
          },
          "type": "array"
        },
        "floor_passed": {
          "type": "boolean"
        },
        "improved_count": {
          "type": "integer"
        },
        "median_delta": {
          "oneOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "name": {
          "type": "string"
        },
        "regressed_count": {
          "type": "integer"
        },
        "replayed": {
          "type": "integer"
        },
        "scored": {
          "type": "integer"
        },
        "selected": {
          "type": "integer"
        },
        "unchanged_count": {
          "type": "integer"
        }
      },
      "required": [
        "ci_computable",
        "ci_lower",
        "ci_unavailable_reason",
        "ci_upper",
        "floor_passed",
        "median_delta",
        "name",
        "replayed",
        "scored",
        "selected"
      ],
      "type": "object"
    },
    "DecisionFinding": {
      "additionalProperties": false,
      "properties": {
        "code": {
          "type": "string"
        },
        "derived_from_failures": {
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        "details": {
          "additionalProperties": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "integer"
              },
              {
                "type": "number"
              },
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ]
          },
          "type": "object"
        },
        "message": {
          "type": "string"
        },
        "severity": {
          "enum": [
            "info",
            "degrades_trust",
            "blocks_ship",
            "blocks_all"
          ]
        }
      },
      "required": [
        "code",
        "message",
        "severity"
      ],
      "type": "object"
    },
    "DecisionPolicy": {
      "additionalProperties": false,
      "properties": {
        "max_baseline_regression_ratio": {
          "type": "number"
        },
        "max_ci_width": {
          "oneOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ]
        },
        "min_failure_improvement_ratio": {
          "type": "number"
        },
        "practical_delta_epsilon": {
          "type": "number"
        },
        "primary_endpoints": {
          "items": {
            "$ref": "#/$defs/PrimaryEndpoint"
          },
          "type": "array"
        },
        "require_baseline": {
          "type": "boolean"
        },
        "required_cohorts": {
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        "scorer_cache_block_after_days": {
          "type": "integer"
        },
        "scorer_cache_mode": {
          "enum": [
            "auto",
            "on",
            "off",
            "read_only",
            "refresh"
          ]
        },
        "scorer_cache_storage_profile": {
          "enum": [
            "normalized_result_only",
            "full_judge_io"
          ]
        },
        "scorer_cache_warn_after_days": {
          "type": "integer"
        }
      },
      "type": "object"
    },
    "EffectSizeDisclosure": {
      "additionalProperties": false,
      "properties": {
        "judge_noise_floor": {
          "oneOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "practical_delta": {
          "type": "string"
        },
        "practical_delta_source": {
          "enum": [
            "policy",
            "calibrated_from_judge_noise_floor",
            "unknown"
          ]
        },
        "warning": {
          "oneOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "judge_noise_floor",
        "practical_delta",
        "practical_delta_source"
      ],
      "type": "object"
    },
    "EnvironmentFingerprint": {
      "additionalProperties": false,
      "properties": {
        "dependencies": {
          "additionalProperties": {
            "type": "string"
          },
          "type": "object"
        },
        "platform": {
          "type": "string"
        },
        "python": {
          "type": "string"
        },
        "whatif_version": {
          "type": "string"
        }
      },
      "required": [
        "platform",
        "python",
        "whatif_version"
      ],
      "type": "object"
    },
    "FailureRecord": {
      "additionalProperties": false,
      "properties": {
        "aggregated_into": {
          "oneOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "code": {
          "type": "string"
        },
        "cohort": {
          "oneOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "details": {
          "additionalProperties": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "integer"
              },
              {
                "type": "number"
              },
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ]
          },
          "type": "object"
        },
        "id": {
          "type": "string"
        },
        "message": {
          "type": "string"
        },
        "retryable": {
          "type": "boolean"
        },
        "scope": {
          "enum": [
            "trace",
            "cohort",
            "run"
          ]
        },
        "stage": {
          "enum": [
            "ingest",
            "selection",
            "replay",
            "score",
            "diff",
            "decision",
            "report"
          ]
        },
        "trace_id": {
          "oneOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "code",
        "cohort",
        "id",
        "message",
        "retryable",
        "scope",
        "stage",
        "trace_id"
      ],
      "type": "object"
    },
    "FloorFailure": {
      "additionalProperties": false,
      "properties": {
        "observed": {
          "oneOf": [
            {
              "type": "number"
            },
            {
              "type": "integer"
            },
            {
              "type": "string"
            }
          ]
        },
        "rule": {
          "type": "string"
        },
        "severity": {
          "enum": [
            "blocks_ship",
            "blocks_all"
          ]
        },
        "threshold": {
          "oneOf": [
            {
              "type": "number"
            },
            {
              "type": "integer"
            }
          ]
        }
      },
      "required": [
        "observed",
        "rule",
        "severity",
        "threshold"
      ],
      "type": "object"
    },
    "JudgeMethodDisclosure": {
      "additionalProperties": false,
      "properties": {
        "bias_audit_measured": {
          "type": "boolean"
        },
        "calibration_measured": {
          "type": "boolean"
        },
        "judge_model": {
          "type": "string"
        },
        "judge_model_version": {
          "oneOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "judge_provider": {
          "oneOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "reliability_measured": {
          "type": "boolean"
        },
        "rendered_prompt_hash": {
          "type": "string"
        },
        "reproducibility_addressed": {
          "type": "boolean"
        },
        "rubric_hash": {
          "oneOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "scorer": {
          "type": "string"
        },
        "scorer_cache_enabled": {
          "type": "boolean"
        },
        "scorer_cache_hits": {
          "type": "integer"
        },
        "scorer_cache_misses": {
          "type": "integer"
        },
        "scorer_cache_mode": {
          "enum": [
            "off",
            "on",
            "read_only",
            "refresh",
            "auto"
          ]
        },
        "scorer_version": {
          "oneOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "validity_measured": {
          "type": "boolean"
        }
      },
      "required": [
        "bias_audit_measured",
        "calibration_measured",
        "judge_model",
        "judge_model_version",
        "judge_provider",
        "reliability_measured",
        "rendered_prompt_hash",
        "reproducibility_addressed",
        "rubric_hash",
        "scorer",
        "scorer_cache_enabled",
        "scorer_cache_hits",
        "scorer_cache_misses",
        "scorer_cache_mode",
        "scorer_version",
        "validity_measured"
      ],
      "type": "object"
    },
    "MethodologyDisclosure": {
      "additionalProperties": false,
      "properties": {
        "bootstrap": {
          "$ref": "#/$defs/BootstrapMethodDisclosure"
        },
        "causal_claim_scope": {
          "enum": [
            "associated_under_cached_tool_replay"
          ]
        },
        "cohorts": {
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        "effect_size": {
          "$ref": "#/$defs/EffectSizeDisclosure"
        },
        "judge": {
          "$ref": "#/$defs/JudgeMethodDisclosure"
        },
        "limitations": {
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        "multiplicity": {
          "$ref": "#/$defs/MultiplicityDisclosure"
        },
        "per_trace_inference": {
          "enum": [
            "descriptive_only"
          ]
        },
        "primary_endpoints": {
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        "primary_metric": {
          "type": "string"
        },
        "unit_of_analysis": {
          "enum": [
            "paired_trace_delta"
          ]
        }
      },
      "required": [
        "bootstrap",
        "causal_claim_scope",
        "cohorts",
        "effect_size",
        "judge",
        "multiplicity",
        "per_trace_inference",
        "primary_endpoints",
        "primary_metric",
        "unit_of_analysis"
      ],
      "type": "object"
    },
    "MultiplicityDisclosure": {
      "additionalProperties": false,
      "properties": {
        "correction": {
          "enum": [
            "none",
            "holm",
            "bonferroni",
            "bh_fdr"
          ]
        },
        "primary_endpoint_count": {
          "type": "integer"
        },
        "reason": {
          "type": "string"
        }
      },
      "required": [
        "correction",
        "primary_endpoint_count",
        "reason"
      ],
      "type": "object"
    },
    "PolicyViolationRecord": {
      "additionalProperties": false,
      "properties": {
        "observed": {
          "oneOf": [
            {
              "type": "integer"
            },
            {
              "type": "number"
            },
            {
              "type": "string"
            }
          ]
        },
        "rule": {
          "type": "string"
        },
        "threshold": {
          "oneOf": [
            {
              "type": "integer"
            },
            {
              "type": "number"
            }
          ]
        }
      },
      "required": [
        "observed",
        "rule",
        "threshold"
      ],
      "type": "object"
    },
    "PrimaryEndpoint": {
      "additionalProperties": false,
      "properties": {
        "cohort": {
          "type": "string"
        },
        "direction": {
          "enum": [
            "improvement_above_threshold",
            "non_regression_below_threshold"
          ]
        },
        "metric": {
          "type": "string"
        }
      },
      "required": [
        "cohort",
        "direction"
      ],
      "type": "object"
    },
    "RunManifest": {
      "additionalProperties": false,
      "properties": {
        "agent_identity": {
          "oneOf": [
            {
              "additionalProperties": {
                "type": "string"
              },
              "type": "object"
            },
            {
              "type": "null"
            }
          ]
        },
        "config_hash": {
          "type": "string"
        },
        "decision_policy": {
          "$ref": "#/$defs/DecisionPolicy"
        },
        "duration_ms": {
          "type": "integer"
        },
        "environment": {
          "$ref": "#/$defs/EnvironmentFingerprint"
        },
        "experiment_id": {
          "type": "string"
        },
        "finished_at": {
          "type": "string"
        },
        "redaction": {
          "additionalProperties": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "boolean"
              }
            ]
          },
          "type": "object"
        },
        "selection_seed": {
          "type": "integer"
        },
        "sensitive_unwraps": {
          "items": {
            "$ref": "#/$defs/SensitiveUnwrap"
          },
          "type": "array"
        },
        "source": {
          "type": "string"
        },
        "started_at": {
          "type": "string"
        },
        "target": {
          "type": "string"
        },
        "trust_floor": {
          "$ref": "#/$defs/TrustFloor"
        },
        "whatif_version": {
          "type": "string"
        }
      },
      "required": [
        "config_hash",
        "decision_policy",
        "duration_ms",
        "environment",
        "experiment_id",
        "finished_at",
        "selection_seed",
        "source",
        "started_at",
        "target",
        "trust_floor",
        "whatif_version"
      ],
      "type": "object"
    },
    "SensitiveUnwrap": {
      "additionalProperties": false,
      "properties": {
        "classification": {
          "type": "string"
        },
        "location": {
          "type": "string"
        },
        "reason": {
          "type": "string"
        }
      },
      "required": [
        "classification",
        "location",
        "reason"
      ],
      "type": "object"
    },
    "TrustFloor": {
      "additionalProperties": false,
      "properties": {
        "min_replay_validity_ratio_per_required_cohort": {
          "type": "number"
        },
        "min_replayed_per_required_cohort": {
          "type": "integer"
        },
        "min_scored_per_required_cohort": {
          "type": "integer"
        },
        "min_selected_per_required_cohort": {
          "type": "integer"
        },
        "source": {
          "type": "string"
        },
        "version": {
          "type": "string"
        }
      },
      "type": "object"
    }
  },
  "$id": "https://whatif.codes/schema/report/v0.1.json",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "additionalProperties": false,
  "description": "v0.1 wire-format report emitted by `whatifd fork`. Hand-written types in `whatifd/report/models_v01.py`; this schema is generated from them by `scripts/generate_schema.py`.",
  "properties": {
    "cache_summary": {
      "$ref": "#/$defs/CacheSummary",
      "x-deterministic": true
    },
    "cohort_results": {
      "items": {
        "$ref": "#/$defs/CohortResult"
      },
      "type": "array",
      "x-deterministic": true
    },
    "decision_findings": {
      "items": {
        "$ref": "#/$defs/DecisionFinding"
      },
      "type": "array",
      "x-deterministic": true
    },
    "decision_policy": {
      "$ref": "#/$defs/DecisionPolicy",
      "x-deterministic": true
    },
    "failures": {
      "items": {
        "$ref": "#/$defs/FailureRecord"
      },
      "type": "array",
      "x-deterministic": true
    },
    "methodology": {
      "$ref": "#/$defs/MethodologyDisclosure",
      "x-deterministic": true
    },
    "runtime": {
      "$ref": "#/$defs/RunManifest",
      "x-deterministic": false
    },
    "schema_uri": {
      "enum": [
        "https://whatif.codes/schema/report/v0.1.json"
      ],
      "x-deterministic": true
    },
    "schema_version": {
      "enum": [
        "0.1"
      ],
      "x-deterministic": true
    },
    "trust_floor": {
      "$ref": "#/$defs/TrustFloor",
      "x-deterministic": true
    },
    "verdict_state": {
      "enum": [
        "ship",
        "dont_ship",
        "inconclusive"
      ],
      "x-deterministic": true
    }
  },
  "required": [
    "cache_summary",
    "cohort_results",
    "decision_findings",
    "decision_policy",
    "failures",
    "methodology",
    "runtime",
    "schema_uri",
    "schema_version",
    "trust_floor",
    "verdict_state"
  ],
  "schema_version": "0.1",
  "title": "WhatifReportV01",
  "type": "object"
}
