{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/machinesignal-it/json-schema/machinesignal-it-artifact-response-schema.json",
  "title": "ArtifactResponse",
  "x-generated": "2026-10-30",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/api.machinesignal.it-openapi.json#/components/schemas/ArtifactResponse",
  "type": "object",
  "additionalProperties": true,
  "required": [
    "decision",
    "order_intent_id",
    "product_code",
    "artifact",
    "artifact_sha256"
  ],
  "properties": {
    "decision": {
      "enum": [
        "dec_artifact_retrieved",
        "act_campaign_retrieved"
      ]
    },
    "order_intent_id": {
      "type": "string",
      "pattern": "^order_intent_"
    },
    "product_code": {
      "enum": [
        "MS-DEC-250",
        "MS-ACT-25"
      ]
    },
    "artifact": {
      "oneOf": [
        {
          "$ref": "#/$defs/DecDecisionArtifact"
        },
        {
          "$ref": "#/$defs/ActCampaignArtifact"
        }
      ],
      "description": "Purchased machine-readable DEC decisions or the entitled ACT campaign, typed according to the existing production fulfillment contracts."
    },
    "artifact_sha256": {
      "type": "string",
      "pattern": "^[a-f0-9]{64}$"
    }
  },
  "$defs": {
    "ActCampaignArtifact": {
      "type": "object",
      "additionalProperties": true,
      "required": [
        "contract_version",
        "mode",
        "product_code",
        "campaign_id",
        "source_delivery_id",
        "delivery_scope",
        "campaign_summary",
        "action_packs",
        "shared_campaign_controls",
        "side_effects",
        "generated_at"
      ],
      "properties": {
        "contract_version": {
          "type": "string"
        },
        "mode": {
          "const": "production_real_fulfillment"
        },
        "product_code": {
          "const": "MS-ACT-25"
        },
        "campaign_id": {
          "type": "string",
          "pattern": "^campaign_"
        },
        "source_delivery_id": {
          "type": "string"
        },
        "delivery_scope": {
          "type": "object",
          "additionalProperties": true
        },
        "campaign_summary": {
          "type": "object",
          "additionalProperties": true
        },
        "action_packs": {
          "type": "array",
          "minItems": 25,
          "maxItems": 25,
          "items": {
            "type": "object",
            "additionalProperties": true
          }
        },
        "shared_campaign_controls": {
          "type": "object",
          "additionalProperties": true
        },
        "side_effects": {
          "type": "object",
          "additionalProperties": true
        },
        "generated_at": {
          "type": "string",
          "format": "date-time"
        }
      }
    },
    "DecDecisionArtifact": {
      "type": "object",
      "additionalProperties": true,
      "required": [
        "protocol",
        "job_id",
        "source_order_intent_id",
        "product_code",
        "record_count",
        "records",
        "scoring_version",
        "generated_at",
        "raw_html_retained",
        "provider_calls",
        "provider_writes"
      ],
      "properties": {
        "protocol": {
          "const": "machinesignal_evidence_result_v1"
        },
        "job_id": {
          "type": "string",
          "pattern": "^evidence_job_"
        },
        "source_order_intent_id": {
          "type": "string",
          "pattern": "^order_intent_"
        },
        "product_code": {
          "const": "MS-DEC-250"
        },
        "record_count": {
          "type": "integer",
          "minimum": 1,
          "maximum": 250
        },
        "records": {
          "type": "array",
          "minItems": 1,
          "maxItems": 250,
          "items": {
            "$ref": "#/$defs/DecisionRecord"
          }
        },
        "scoring_version": {
          "type": "string"
        },
        "generated_at": {
          "type": "string",
          "format": "date-time"
        },
        "raw_html_retained": {
          "const": false
        },
        "provider_calls": {
          "const": false
        },
        "provider_writes": {
          "const": false
        }
      }
    },
    "DecisionEvidence": {
      "type": "object",
      "additionalProperties": true,
      "required": [
        "fact_type",
        "observed",
        "source_url",
        "observed_at",
        "content_sha256"
      ],
      "properties": {
        "fact_type": {
          "type": "string"
        },
        "observed": {
          "type": "boolean"
        },
        "source_url": {
          "type": "string",
          "format": "uri"
        },
        "observed_at": {
          "type": "string",
          "format": "date-time"
        },
        "content_sha256": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        }
      }
    },
    "DecisionRecord": {
      "type": "object",
      "additionalProperties": true,
      "required": [
        "source_record_id",
        "company_name",
        "domain",
        "opportunity_score",
        "confidence",
        "decision",
        "reason",
        "suggested_route",
        "evidence",
        "scoring_version"
      ],
      "properties": {
        "source_record_id": {
          "type": "string"
        },
        "company_name": {
          "type": "string"
        },
        "domain": {
          "type": "string"
        },
        "opportunity_score": {
          "type": "integer",
          "minimum": 0,
          "maximum": 100
        },
        "confidence": {
          "type": "number",
          "minimum": 0,
          "maximum": 1
        },
        "decision": {
          "enum": [
            "needs_verification",
            "discard",
            "watchlist",
            "nurture",
            "buy_deep_analysis"
          ]
        },
        "reason": {
          "type": "string"
        },
        "suggested_route": {
          "type": "string"
        },
        "evidence": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/DecisionEvidence"
          }
        },
        "page_snapshots": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": true
          }
        },
        "collection_errors": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "scoring_version": {
          "type": "string"
        }
      }
    }
  }
}