{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://awoooi.wooo.work/schemas/ai_agent_task_result_audit_trail_v1.schema.json",
  "title": "AI Agent Task Result Audit Trail v1",
  "type": "object",
  "required": [
    "schema_version",
    "generated_at",
    "program_status",
    "source_refs",
    "result_audit_truth",
    "result_routes",
    "writeback_contracts",
    "audit_checkpoints",
    "operator_handoffs",
    "display_redaction_contract",
    "rollups"
  ],
  "properties": {
    "schema_version": { "const": "ai_agent_task_result_audit_trail_v1" },
    "generated_at": { "type": "string" },
    "program_status": {
      "type": "object",
      "required": [
        "overall_completion_percent",
        "current_priority",
        "current_task_id",
        "next_task_id",
        "read_only_mode",
        "runtime_authority",
        "status_note"
      ],
      "properties": {
        "overall_completion_percent": { "type": "integer", "minimum": 0, "maximum": 100 },
        "current_priority": { "enum": ["P0", "P1", "P2", "P3"] },
        "current_task_id": { "const": "P2-103" },
        "next_task_id": { "const": "P2-104" },
        "read_only_mode": { "const": true },
        "runtime_authority": { "const": "task_result_audit_trail_contract_only_no_live_writeback" },
        "status_note": { "type": "string" }
      },
      "additionalProperties": false
    },
    "source_refs": { "type": "array", "items": { "type": "string" }, "minItems": 1 },
    "result_audit_truth": {
      "type": "object",
      "required": [
        "p2_102_candidate_dry_run_loaded",
        "task_result_route_matrix_ready",
        "km_draft_contract_ready",
        "logbook_append_contract_ready",
        "audit_trail_contract_ready",
        "timeline_handoff_contract_ready",
        "operator_next_action_ready",
        "all_results_have_owner_and_next_step",
        "runtime_execution_enabled",
        "km_write_enabled",
        "logbook_runtime_write_enabled",
        "audit_db_write_enabled",
        "timeline_write_enabled",
        "playbook_trust_write_enabled",
        "gateway_queue_write_enabled",
        "telegram_send_enabled",
        "delivery_receipt_write_enabled",
        "production_write_enabled",
        "secret_value_read_enabled",
        "host_or_cluster_command_enabled",
        "destructive_operation_enabled",
        "work_window_transcript_display_allowed",
        "runtime_execution_count_24h",
        "km_write_count_24h",
        "logbook_runtime_write_count_24h",
        "audit_db_write_count_24h",
        "timeline_write_count_24h",
        "playbook_trust_write_count_24h",
        "gateway_queue_write_count_24h",
        "telegram_send_count_24h",
        "delivery_receipt_write_count_24h",
        "production_write_count_24h",
        "secret_value_read_count_24h",
        "host_or_cluster_command_count_24h",
        "destructive_operation_count_24h",
        "truth_note"
      ],
      "properties": {
        "p2_102_candidate_dry_run_loaded": { "const": true },
        "task_result_route_matrix_ready": { "const": true },
        "km_draft_contract_ready": { "const": true },
        "logbook_append_contract_ready": { "const": true },
        "audit_trail_contract_ready": { "const": true },
        "timeline_handoff_contract_ready": { "const": true },
        "operator_next_action_ready": { "const": true },
        "all_results_have_owner_and_next_step": { "const": true },
        "runtime_execution_enabled": { "const": false },
        "km_write_enabled": { "const": false },
        "logbook_runtime_write_enabled": { "const": false },
        "audit_db_write_enabled": { "const": false },
        "timeline_write_enabled": { "const": false },
        "playbook_trust_write_enabled": { "const": false },
        "gateway_queue_write_enabled": { "const": false },
        "telegram_send_enabled": { "const": false },
        "delivery_receipt_write_enabled": { "const": false },
        "production_write_enabled": { "const": false },
        "secret_value_read_enabled": { "const": false },
        "host_or_cluster_command_enabled": { "const": false },
        "destructive_operation_enabled": { "const": false },
        "work_window_transcript_display_allowed": { "const": false },
        "runtime_execution_count_24h": { "const": 0 },
        "km_write_count_24h": { "const": 0 },
        "logbook_runtime_write_count_24h": { "const": 0 },
        "audit_db_write_count_24h": { "const": 0 },
        "timeline_write_count_24h": { "const": 0 },
        "playbook_trust_write_count_24h": { "const": 0 },
        "gateway_queue_write_count_24h": { "const": 0 },
        "telegram_send_count_24h": { "const": 0 },
        "delivery_receipt_write_count_24h": { "const": 0 },
        "production_write_count_24h": { "const": 0 },
        "secret_value_read_count_24h": { "const": 0 },
        "host_or_cluster_command_count_24h": { "const": 0 },
        "destructive_operation_count_24h": { "const": 0 },
        "truth_note": { "type": "string" }
      },
      "additionalProperties": false
    },
    "result_routes": {
      "type": "array",
      "minItems": 8,
      "items": {
        "type": "object",
        "required": [
          "route_id",
          "display_name",
          "source_signal",
          "result_state",
          "owner_agent",
          "primary_owner",
          "km_target",
          "logbook_target",
          "audit_target",
          "timeline_target",
          "operator_next_action",
          "blocked_reason",
          "writes_live_state",
          "requires_owner_review",
          "ready_for_km_draft",
          "evidence_hash"
        ],
        "properties": {
          "route_id": { "type": "string" },
          "display_name": { "type": "string" },
          "source_signal": { "type": "string" },
          "result_state": {
            "enum": [
              "diagnostic_only",
              "owner_review_required",
              "execution_failed",
              "verified_no_change",
              "blocked_until_evidence",
              "blocked_by_policy",
              "correlation_gap",
              "report_quality_gap"
            ]
          },
          "owner_agent": { "enum": ["openclaw", "hermes", "nemotron"] },
          "primary_owner": { "type": "string" },
          "km_target": { "type": "string" },
          "logbook_target": { "type": "string" },
          "audit_target": { "type": "string" },
          "timeline_target": { "type": "string" },
          "operator_next_action": { "type": "string" },
          "blocked_reason": { "type": "string" },
          "writes_live_state": { "const": false },
          "requires_owner_review": { "type": "boolean" },
          "ready_for_km_draft": { "type": "boolean" },
          "evidence_hash": { "type": "string", "pattern": "^sha256:[a-f0-9]{64}$" }
        },
        "additionalProperties": false
      }
    },
    "writeback_contracts": {
      "type": "array",
      "minItems": 6,
      "items": {
        "type": "object",
        "required": [
          "contract_id",
          "display_name",
          "owner_agent",
          "target_system",
          "purpose",
          "allowed_mode",
          "write_enabled",
          "runtime_writer_enabled",
          "required_fields",
          "blocker_summary",
          "evidence_hash"
        ],
        "properties": {
          "contract_id": { "type": "string" },
          "display_name": { "type": "string" },
          "owner_agent": { "enum": ["openclaw", "hermes", "nemotron"] },
          "target_system": { "type": "string" },
          "purpose": { "type": "string" },
          "allowed_mode": {
            "enum": ["committed_snapshot_only", "gated_owner_review", "manual_append_plan"]
          },
          "write_enabled": { "const": false },
          "runtime_writer_enabled": { "const": false },
          "required_fields": { "type": "array", "items": { "type": "string" }, "minItems": 1 },
          "blocker_summary": { "type": "string" },
          "evidence_hash": { "type": "string", "pattern": "^sha256:[a-f0-9]{64}$" }
        },
        "additionalProperties": false
      }
    },
    "audit_checkpoints": {
      "type": "array",
      "minItems": 7,
      "items": {
        "type": "object",
        "required": [
          "checkpoint_id",
          "display_name",
          "required_for",
          "status",
          "failure_if_missing",
          "creates_runtime_action"
        ],
        "properties": {
          "checkpoint_id": { "type": "string" },
          "display_name": { "type": "string" },
          "required_for": { "type": "string" },
          "status": { "enum": ["ready", "needs_owner_review", "blocked_by_policy"] },
          "failure_if_missing": { "type": "string" },
          "creates_runtime_action": { "const": false }
        },
        "additionalProperties": false
      }
    },
    "operator_handoffs": {
      "type": "array",
      "minItems": 5,
      "items": {
        "type": "object",
        "required": [
          "handoff_id",
          "display_name",
          "owner_agent",
          "human_instruction",
          "creates_runtime_action",
          "requires_human_review"
        ],
        "properties": {
          "handoff_id": { "type": "string" },
          "display_name": { "type": "string" },
          "owner_agent": { "enum": ["openclaw", "hermes", "nemotron"] },
          "human_instruction": { "type": "string" },
          "creates_runtime_action": { "const": false },
          "requires_human_review": { "const": true }
        },
        "additionalProperties": false
      }
    },
    "display_redaction_contract": {
      "type": "object",
      "required": [
        "redaction_required",
        "raw_prompt_display_allowed",
        "private_reasoning_display_allowed",
        "secret_value_display_allowed",
        "raw_telegram_payload_display_allowed",
        "work_window_transcript_display_allowed",
        "allowed_display_fields",
        "blocked_display_fields"
      ],
      "properties": {
        "redaction_required": { "const": true },
        "raw_prompt_display_allowed": { "const": false },
        "private_reasoning_display_allowed": { "const": false },
        "secret_value_display_allowed": { "const": false },
        "raw_telegram_payload_display_allowed": { "const": false },
        "work_window_transcript_display_allowed": { "const": false },
        "allowed_display_fields": { "type": "array", "items": { "type": "string" }, "minItems": 1 },
        "blocked_display_fields": { "type": "array", "items": { "type": "string" }, "minItems": 1 }
      },
      "additionalProperties": false
    },
    "rollups": {
      "type": "object",
      "required": [
        "result_route_count",
        "owner_next_action_ready_count",
        "requires_owner_review_count",
        "ready_for_km_draft_count",
        "blocked_result_count",
        "writeback_contract_count",
        "audit_checkpoint_count",
        "operator_handoff_count",
        "runtime_execution_count",
        "km_write_count",
        "logbook_runtime_write_count",
        "audit_db_write_count",
        "timeline_write_count",
        "playbook_trust_write_count",
        "gateway_queue_write_count",
        "telegram_send_count",
        "production_write_count",
        "secret_value_read_count",
        "destructive_operation_count"
      ],
      "properties": {
        "result_route_count": { "type": "integer", "minimum": 0 },
        "owner_next_action_ready_count": { "type": "integer", "minimum": 0 },
        "requires_owner_review_count": { "type": "integer", "minimum": 0 },
        "ready_for_km_draft_count": { "type": "integer", "minimum": 0 },
        "blocked_result_count": { "type": "integer", "minimum": 0 },
        "writeback_contract_count": { "type": "integer", "minimum": 0 },
        "audit_checkpoint_count": { "type": "integer", "minimum": 0 },
        "operator_handoff_count": { "type": "integer", "minimum": 0 },
        "runtime_execution_count": { "const": 0 },
        "km_write_count": { "const": 0 },
        "logbook_runtime_write_count": { "const": 0 },
        "audit_db_write_count": { "const": 0 },
        "timeline_write_count": { "const": 0 },
        "playbook_trust_write_count": { "const": 0 },
        "gateway_queue_write_count": { "const": 0 },
        "telegram_send_count": { "const": 0 },
        "production_write_count": { "const": 0 },
        "secret_value_read_count": { "const": 0 },
        "destructive_operation_count": { "const": 0 }
      },
      "additionalProperties": false
    }
  },
  "additionalProperties": false
}
