{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "schemas/checkpoint_turn_boundary_sweep.schema.json",
  "title": "Checkpoint Turn-Boundary Sweep — read-only output + wiring-candidate schema (task-2553+43 / STEP 3)",
  "description": "Static contract for anu_v3.checkpoint_turn_boundary_sweep PURE READ-ONLY output and the operational-wiring CANDIDATE enumeration. 9-R.1 Layer A: side-effect-0 / idempotent deliverable; the §8 executor completion callback cron is Layer B (separate process-lifecycle signal, not validated here).",
  "type": "object",
  "required": [
    "schema",
    "task_id",
    "sweep",
    "mode",
    "candidates",
    "by_candidate_type",
    "actionable_candidates",
    "recovery_invariant",
    "zero_side_effect_proof"
  ],
  "additionalProperties": true,
  "properties": {
    "schema": {
      "const": "anu_v3.checkpoint_turn_boundary_sweep.result.v1"
    },
    "task_id": { "const": "task-2553+43" },
    "sweep": { "const": "CHECKPOINT_TURN_BOUNDARY_SWEEP" },
    "mode": { "const": "READ_ONLY" },
    "layer": { "type": "string" },
    "generated_ts_kst": { "type": "string" },
    "source_fixture": { "type": "string" },
    "consumes_plus31": {
      "type": "object",
      "required": ["module", "entrypoint", "recovery_layer"],
      "properties": {
        "module": { "type": "string" },
        "entrypoint": { "type": "string", "pattern": "emit=False" },
        "recovery_layer": { "type": "string" }
      },
      "additionalProperties": true
    },
    "candidates": {
      "type": "array",
      "items": { "$ref": "#/$defs/sweepCandidate" }
    },
    "by_candidate_type": {
      "type": "object",
      "additionalProperties": {
        "type": "array",
        "items": { "type": "string" }
      }
    },
    "actionable_candidates": {
      "type": "array",
      "items": { "type": "string" }
    },
    "actionable_count": { "type": "integer", "minimum": 0 },
    "tracks_total": { "type": "integer", "minimum": 0 },
    "recovery_invariant": { "$ref": "#/$defs/recoveryInvariant" },
    "zero_side_effect_proof": { "$ref": "#/$defs/zeroSideEffectProof" }
  },
  "$defs": {
    "sweepCandidate": {
      "type": "object",
      "required": [
        "task_id",
        "classification",
        "candidate_type",
        "actionable",
        "recovery_eligible",
        "terminal",
        "recommended_signal"
      ],
      "additionalProperties": false,
      "properties": {
        "task_id": { "type": "string", "minLength": 1 },
        "classification": { "type": "string", "minLength": 1 },
        "candidate_type": {
          "type": "string",
          "enum": [
            "NO_CRON_DONE_CANDIDATE",
            "RECOVERY_CANDIDATE",
            "STALE_CANDIDATE",
            "DRIFT_CANDIDATE",
            "BENIGN_NORMAL_COMPLETED",
            "BENIGN_DUPLICATE_IGNORED",
            "INFLIGHT_FALLBACK_PENDING",
            "INFLIGHT_RUNNING",
            "UNKNOWN"
          ]
        },
        "actionable": { "type": "boolean" },
        "recovery_eligible": { "type": "boolean" },
        "terminal": { "type": "boolean" },
        "recommended_signal": { "type": "string" }
      }
    },
    "recoveryInvariant": {
      "type": "object",
      "required": [
        "recovery_not_primary_ok",
        "violations",
        "replaces_callback_primary_path",
        "discards_fallback_safety_path",
        "contract"
      ],
      "additionalProperties": true,
      "properties": {
        "recovery_not_primary_ok": { "const": true },
        "violations": {
          "type": "array",
          "maxItems": 0,
          "items": { "type": "string" }
        },
        "replaces_callback_primary_path": { "const": false },
        "discards_fallback_safety_path": { "const": false },
        "contract": { "type": "object" }
      }
    },
    "zeroSideEffectProof": {
      "type": "object",
      "required": [
        "write",
        "cron_register",
        "cron_remove",
        "merge",
        "pr",
        "dispatch",
        "closeout_confirm",
        "callback_collector_path_touched",
        "frozen_plus31_mutation",
        "emit_true_reached"
      ],
      "additionalProperties": true,
      "properties": {
        "write": { "const": 0 },
        "cron_register": { "const": 0 },
        "cron_remove": { "const": 0 },
        "merge": { "const": 0 },
        "pr": { "const": 0 },
        "dispatch": { "const": 0 },
        "closeout_confirm": { "const": 0 },
        "callback_collector_path_touched": { "const": 0 },
        "frozen_plus31_mutation": { "const": 0 },
        "emit_true_reached": { "const": false }
      }
    },
    "wiringCandidateDoc": {
      "type": "object",
      "required": ["schema", "task_id", "applied", "candidates"],
      "additionalProperties": true,
      "properties": {
        "schema": {
          "const": "anu_v3.checkpoint_turn_boundary_sweep.wiring_candidate.v1"
        },
        "task_id": { "const": "task-2553+43" },
        "applied": { "const": false },
        "candidates": {
          "type": "array",
          "minItems": 1,
          "items": { "$ref": "#/$defs/wiringCandidate" }
        }
      }
    },
    "wiringCandidate": {
      "type": "object",
      "required": [
        "id",
        "hook_point",
        "call_site",
        "read_only_guarantee",
        "side_effect_zero_proof",
        "conflict",
        "risk_tier"
      ],
      "additionalProperties": false,
      "properties": {
        "id": { "type": "string", "minLength": 1 },
        "hook_point": { "type": "string", "minLength": 1 },
        "call_site": { "type": "string", "minLength": 1 },
        "read_only_guarantee": { "type": "string", "minLength": 1 },
        "side_effect_zero_proof": { "type": "string", "minLength": 1 },
        "conflict": { "type": "string", "minLength": 1 },
        "risk_tier": {
          "type": "string",
          "enum": ["LOW", "MEDIUM", "HIGH"]
        }
      }
    }
  }
}
