{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://github.com/proofprotocol/PP-SPEC-077-DEAD-CANARY-PROTOCOL/schemas/uop.schema.json",
  "title": "ProofSwarm Unit of Proof",
  "description": "One adjudicated bad canary outcome in a valid ProofSwarm run (PP-SPEC-077, Sections 11 and 21).",
  "type": "object",
  "required": [
    "spec",
    "run_id",
    "uop_id",
    "technique",
    "variant",
    "dut",
    "effect_point",
    "outcome",
    "detected",
    "commitment",
    "merkle_root",
    "time_anchor_commit",
    "ingress_record",
    "witness_record",
    "witness_operator",
    "witness_coverage_map",
    "disclosed_interests",
    "dut_fingerprint",
    "fingerprint_status",
    "attribution_level",
    "sut",
    "color",
    "path",
    "proofregister_uri"
  ],
  "properties": {
    "spec": {
      "const": "PP-SPEC-077"
    },
    "run_id": {
      "type": "string",
      "examples": [
        "dcp-2026-10-10-0077"
      ]
    },
    "uop_id": {
      "type": "string",
      "pattern": "^[0-9a-f]{64}$",
      "description": "Record ID: SHA-256(\"DCP-1:record\" || canonical form without signatures, proofregister_uri, registry_receipt) (SPEC 21.1)"
    },
    "technique": {
      "type": "string",
      "description": "MITRE ATT&CK or ATLAS technique ID"
    },
    "variant": {
      "enum": [
        "known",
        "mutated",
        "holdout",
        "embargoed"
      ]
    },
    "color": {
      "enum": [
        "red",
        "black",
        "gold"
      ],
      "description": "Committed color (SPEC 5.6.4). Units of Proof are bad canaries only, so white and gray do not appear here."
    },
    "path": {
      "type": "object",
      "required": [
        "ingress",
        "effect_token",
        "route",
        "effect_point",
        "target",
        "cadence"
      ],
      "properties": {
        "ingress": {
          "type": "string"
        },
        "effect_token": {
          "type": "string"
        },
        "route": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "effect_point": {
          "type": "string"
        },
        "target": {
          "type": "object",
          "required": [
            "level",
            "id"
          ],
          "properties": {
            "level": {
              "enum": [
                "sut",
                "dut",
                "cut"
              ]
            },
            "id": {
              "type": "string"
            }
          }
        },
        "cadence": {
          "enum": [
            "full",
            "trickle"
          ]
        },
        "clutch": {
          "type": [
            "string",
            "null"
          ]
        }
      },
      "additionalProperties": false
    },
    "claim": {
      "type": [
        "object",
        "null"
      ],
      "description": "Required when color is gold (SPEC 5.6.4.2)",
      "properties": {
        "document": {
          "type": "string"
        },
        "version": {
          "type": "string"
        },
        "statement": {
          "type": "string"
        }
      }
    },
    "attribution_level": {
      "enum": [
        "sut",
        "dut",
        "cut"
      ],
      "description": "Finest level the evidence supports (SPEC 2.2)"
    },
    "sut": {
      "type": "string",
      "description": "Solution Under Test identifier"
    },
    "dut": {
      "type": "string",
      "description": "Product name of the Device Under Test"
    },
    "dut_fingerprint": {
      "type": "string",
      "description": "Independently captured DUT Fingerprint (SPEC 15.2)",
      "examples": [
        "ea55dce4aa233b4d27e047cabf8a6a2e68475b626dbdc7a6d5d4cfb8bff437c6"
      ]
    },
    "cut": {
      "type": [
        "string",
        "null"
      ],
      "description": "Control Under Test identifier; required when attribution_level is cut"
    },
    "cut_fingerprint": {
      "type": [
        "string",
        "null"
      ],
      "description": "Independently captured CUT Fingerprint (SPEC 15.2.5)"
    },
    "fingerprint_status": {
      "enum": [
        "current",
        "stale"
      ]
    },
    "effect_point": {
      "type": "string",
      "description": "Deprecated at top level since 0.6.0; use path.effect_point. Kept for one version."
    },
    "outcome": {
      "enum": [
        "stopped",
        "missed"
      ]
    },
    "detected": {
      "type": "boolean"
    },
    "commitment": {
      "type": "string",
      "pattern": "^[0-9a-f]{64,}$"
    },
    "merkle_root": {
      "type": "string",
      "pattern": "^[0-9a-f]{64,}$"
    },
    "time_anchor_commit": {
      "type": "string",
      "description": "Reference to the Time Anchor pulse bound to the commitment"
    },
    "ingress_record": {
      "type": "string"
    },
    "witness_record": {
      "type": "string"
    },
    "witness_operator": {
      "type": "string"
    },
    "witness_coverage_map": {
      "type": "string",
      "description": "Hash of the declared Witness Coverage Map"
    },
    "proofregister_uri": {
      "type": "string",
      "format": "uri",
      "description": "Registry record identifier for this Unit of Proof, from a PP-SPEC-004 conformant registry (SPEC 9.6). Public instance: https://proofregister.com"
    },
    "disclosed_interests": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "registry_receipt": {
      "type": "string",
      "pattern": "^[0-9a-f]{64}$",
      "description": "Hash of the Registry Receipt (SPEC 21.5)"
    },
    "holder": {
      "type": "object",
      "required": [
        "id",
        "public_key"
      ],
      "properties": {
        "id": {
          "type": "string"
        },
        "public_key": {
          "type": "string"
        }
      },
      "additionalProperties": false,
      "description": "Party for whose benefit the run was commissioned (SPEC 21.3). Never the Provider."
    },
    "disclosure": {
      "enum": [
        "public",
        "holder_only",
        "embargoed",
        "sealed"
      ],
      "description": "Disclosure Level (SPEC 21.9)"
    },
    "valid_through": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time",
      "description": "End of validity window (SPEC 21.8)"
    },
    "signatures": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "role",
          "key",
          "sig"
        ],
        "properties": {
          "role": {
            "enum": [
              "issuer",
              "witness",
              "holder",
              "registry",
              "endorser"
            ]
          },
          "key": {
            "type": "string"
          },
          "sig": {
            "type": "string"
          }
        },
        "additionalProperties": false
      },
      "description": "Detached, append-only Signature Envelope (SPEC 21.4). Excluded from uop_id."
    }
  },
  "additionalProperties": false,
  "allOf": [
    {
      "if": {
        "properties": {
          "attribution_level": {
            "const": "cut"
          }
        }
      },
      "then": {
        "required": [
          "cut",
          "cut_fingerprint"
        ],
        "properties": {
          "cut": {
            "type": "string"
          },
          "cut_fingerprint": {
            "type": "string"
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "color": {
            "const": "gold"
          }
        }
      },
      "then": {
        "required": [
          "claim"
        ],
        "properties": {
          "claim": {
            "type": "object"
          }
        }
      }
    }
  ]
}
