{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://spec-first.local/contracts/worker-dispatch-host-journey.schema.json",
  "title": "Worker Dispatch Host Journey",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema_version", "artifact_type", "journey_kind", "status", "support_claim",
    "capture_owner", "capture_method", "captured_at", "freshness_expires_at",
    "session_identity", "host_identity", "host_startup_or_version_ref", "tested_host_version",
    "spec_first_revision", "dispatch_authorization_receipt", "authorization_basis",
    "restricted_read_authorization", "data_egress_authorization", "credential_use_authorization",
    "external_communication_authorization", "provider_trust_domain", "discovery_surface",
    "schema_excerpt_ref", "schema_excerpt", "schema_excerpt_sha256", "schema_completeness",
    "completeness_basis", "redaction_status", "capture_limitations", "observed_primitive",
    "candidate_identity_sha256", "candidate_selection_rationale", "semantic_request_ref",
    "semantic_request_sha256", "context_isolation_need", "model_selection_need",
    "desired_concurrency", "mutation_scope", "mutation_authorization_ref",
    "allowed_mutation_surfaces", "output_contract", "stop_condition", "invocation_performed",
    "invocation_started_at", "capability_probe", "worker_dispatch_capability",
    "call_status", "observed_permission", "observed_capacity", "observed_context_isolation",
    "observed_model_selection", "observed_parallelism", "output_excerpt_ref", "output_excerpt",
    "output_excerpt_sha256", "output_validation", "mutation_observation", "pre_state_ref",
    "post_state_ref", "state_observation_ref", "state_observation_sha256", "reason_codes",
    "supporting_capture_ref", "supporting_capture_sha256",
    "invalidation_conditions"
  ],
  "properties": {
    "schema_version": { "const": "worker-dispatch-host-journey/v1" },
    "artifact_type": { "const": "confirmed" },
    "journey_kind": { "enum": ["positive", "degraded"] },
    "status": { "enum": ["passed", "degraded", "failed", "not_run"] },
    "support_claim": { "enum": ["exact_version_observed", "degraded_only", "not_applicable"] },
    "capture_owner": { "type": "string", "minLength": 1, "maxLength": 160 },
    "capture_method": { "enum": ["host-session-tool-registry-api", "host-startup-registration-record", "equivalent-current-session-source"] },
    "captured_at": { "type": "string", "minLength": 20, "maxLength": 40 },
    "freshness_expires_at": { "type": "string", "minLength": 20, "maxLength": 40 },
    "session_identity": { "type": "string", "minLength": 1, "maxLength": 256 },
    "host_identity": { "type": "string", "minLength": 1, "maxLength": 160 },
    "host_startup_or_version_ref": { "type": "string", "minLength": 1, "maxLength": 512 },
    "tested_host_version": { "type": "string", "minLength": 1, "maxLength": 160 },
    "spec_first_revision": {
      "type": "string",
      "pattern": "^(git:[0-9a-f]{40}|worktree:[0-9a-f]{64})$"
    },
    "dispatch_authorization_receipt": { "type": "string", "minLength": 1, "maxLength": 512 },
    "authorization_basis": { "enum": ["explicit-user", "visible-upstream-handoff"] },
    "restricted_read_authorization": { "enum": ["authorized", "missing", "not_applicable"] },
    "data_egress_authorization": { "enum": ["authorized", "missing", "not_applicable"] },
    "credential_use_authorization": { "enum": ["authorized", "missing", "not_applicable"] },
    "external_communication_authorization": { "enum": ["authorized", "missing", "not_applicable"] },
    "provider_trust_domain": { "enum": ["host-native", "external", "unknown"] },
    "discovery_surface": { "type": "string", "minLength": 1, "maxLength": 512 },
    "schema_excerpt_ref": { "type": ["string", "null"], "maxLength": 512 },
    "schema_excerpt": { "type": ["string", "null"], "maxLength": 4096 },
    "schema_excerpt_sha256": { "type": ["string", "null"], "pattern": "^[a-f0-9]{64}$" },
    "schema_completeness": { "enum": ["confirmed", "unconfirmed"] },
    "completeness_basis": { "type": ["string", "null"], "maxLength": 512 },
    "redaction_status": { "enum": ["passed", "failed"] },
    "capture_limitations": { "type": "array", "minItems": 1, "maxItems": 20, "items": { "type": "string", "minLength": 1, "maxLength": 500 } },
    "observed_primitive": { "type": ["string", "null"], "maxLength": 160 },
    "candidate_identity_sha256": { "type": ["string", "null"], "pattern": "^[a-f0-9]{64}$" },
    "candidate_selection_rationale": { "type": "string", "minLength": 1, "maxLength": 1200 },
    "semantic_request_ref": { "type": "string", "minLength": 1, "maxLength": 512 },
    "semantic_request_sha256": { "type": "string", "pattern": "^[a-f0-9]{64}$" },
    "context_isolation_need": { "enum": ["required", "preferred", "irrelevant"] },
    "model_selection_need": { "enum": ["explicit-tier", "inherited-ok"] },
    "desired_concurrency": { "enum": ["bounded", "serial"] },
    "mutation_scope": { "enum": ["forbidden", "explicitly-scoped"] },
    "mutation_authorization_ref": { "type": ["string", "null"], "maxLength": 512 },
    "allowed_mutation_surfaces": { "type": "array", "maxItems": 20, "items": { "type": "string", "minLength": 1, "maxLength": 300 } },
    "output_contract": { "type": "string", "minLength": 1, "maxLength": 512 },
    "stop_condition": { "type": "string", "minLength": 1, "maxLength": 512 },
    "invocation_performed": { "type": "boolean" },
    "invocation_started_at": { "type": ["string", "null"], "maxLength": 40 },
    "capability_probe": { "enum": ["not_applicable", "attempted", "unavailable"] },
    "worker_dispatch_capability": { "enum": ["available", "missing", "unknown"] },
    "call_status": { "enum": ["succeeded", "blocked", "failed", "not_invoked"] },
    "observed_permission": { "enum": ["allowed", "denied", "unknown", "not_applicable"] },
    "observed_capacity": { "enum": ["accepted", "backpressured", "unknown", "not_applicable"] },
    "observed_context_isolation": { "enum": ["isolated", "inherited", "unknown", "none"] },
    "observed_model_selection": { "enum": ["requested", "inherited", "unknown", "none"] },
    "observed_parallelism": { "enum": ["bounded", "serial", "unknown", "none"] },
    "output_excerpt_ref": { "type": ["string", "null"], "maxLength": 512 },
    "output_excerpt": { "type": ["string", "null"], "maxLength": 4096 },
    "output_excerpt_sha256": { "type": ["string", "null"], "pattern": "^[a-f0-9]{64}$" },
    "output_validation": { "enum": ["passed", "failed", "not_applicable"] },
    "mutation_observation": { "enum": ["within-scope", "violated", "unproven", "not_applicable"] },
    "pre_state_ref": { "type": ["string", "null"], "maxLength": 512 },
    "post_state_ref": { "type": ["string", "null"], "maxLength": 512 },
    "state_observation_ref": { "type": ["string", "null"], "maxLength": 512 },
    "state_observation_sha256": { "type": ["string", "null"], "pattern": "^[a-f0-9]{64}$" },
    "reason_codes": { "type": "array", "maxItems": 20, "items": { "type": "string", "minLength": 1, "maxLength": 160 } },
    "supporting_capture_ref": { "type": "string", "minLength": 1, "maxLength": 512 },
    "supporting_capture_sha256": { "type": "string", "pattern": "^[a-f0-9]{64}$" },
    "invalidation_conditions": { "type": "array", "minItems": 1, "maxItems": 20, "items": { "type": "string", "minLength": 1, "maxLength": 500 } }
  }
}
