{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "schemas/durable_success_writeback.schema.json",
  "title": "durable_success_writeback.v1",
  "description": "task-2553+53 §3.2 — durable-success (COMPLETED) write-back record appended (additive, append-only) to the +44 callback_4tuple_index.jsonl ledger when an INDEPENDENT ANU collector produces a terminal AUTHORITATIVE_PASS / PASS / ACCEPTED verdict. executor self-chain verdicts are NEVER written back (§3.3).",
  "type": "object",
  "required": [
    "schema",
    "task_id",
    "track_id",
    "dispatch_id",
    "normal_collector_cron_id",
    "collector_key",
    "collector_role",
    "authoritative_verdict",
    "terminal_status",
    "completed_at",
    "source_result_path",
    "batch_id"
  ],
  "properties": {
    "schema": {"const": "durable_success_writeback.v1"},
    "task_id": {"type": "string", "minLength": 1},
    "track_id": {"type": "string", "minLength": 1},
    "dispatch_id": {"type": "string", "minLength": 1},
    "dispatch_id_source": {
      "type": "string",
      "enum": ["source_recorded", "derived_from_task_id"],
      "description": "Provenance of dispatch_id — transparent, never a silent fabrication."
    },
    "normal_collector_cron_id": {"type": "string", "minLength": 1},
    "normal_collector_cron_id_source": {
      "type": "string",
      "enum": ["source_recorded", "derived_from_collector_key"]
    },
    "collector_key": {
      "type": "string",
      "description": "MUST be a configured independent ANU key and MUST NOT equal the executor key (§3.3)."
    },
    "collector_role": {"const": "ANU"},
    "authoritative_verdict": {
      "type": "string",
      "enum": ["AUTHORITATIVE_PASS", "PASS", "ACCEPTED"]
    },
    "terminal_status": {"const": "COMPLETED"},
    "completed_at": {
      "type": "string",
      "minLength": 1,
      "description": "Source-recorded terminal ts (deterministic — NOT wall-clock; keeps repeated write-back idempotent §3.8)."
    },
    "source_result_path": {"type": "string", "minLength": 1},
    "batch_id": {"type": "string", "minLength": 1},
    "executor_key": {
      "type": "string",
      "description": "Recorded for provenance / mismatch detection only; self-chain origin is excluded upstream by the +49 authoritative_verdict_selector."
    },
    "chat_id": {"type": "string"},
    "fallback_callback_cron_id": {"type": ["string", "null"]},
    "writeback_classification": {
      "type": "string",
      "enum": [
        "DURABLE_SUCCESS_WRITTEN",
        "WRITEBACK_IDEMPOTENT_SKIP",
        "WRITEBACK_BINDING_CONFLICT",
        "TRACK_MISMATCH",
        "SELF_CHAIN_NO_WRITEBACK"
      ]
    },
    "writeback_id": {
      "type": "string",
      "description": "Deterministic idempotency key = sha256(task_id|track_id|dispatch_id|collector_key|authoritative_verdict|batch_id)."
    }
  },
  "additionalProperties": true
}
