{
  "openapi": "3.1.0",
  "info": {
    "title": "HexHart Sovereign Autonomous Compute, Defense & Quant API",
    "version": "1.0.0",
    "description": "Programmatic interface for corporate purchasing AIs, autonomous agents, and institutional enterprise clients. Supports Machine Payments Protocol (MPP) HTTP 402 autonomous checkout and Stripe agentic commerce.",
    "contact": {
      "name": "HexHart Sovereign Engineering",
      "email": "keefer@hexhartinnovations.com",
      "url": "https://hexhartinnovations.com"
    }
  },
  "servers": [
    {
      "url": "https://hexhartinnovations.com",
      "description": "HexHart Sovereign Primary Netlify Production Gateway"
    },
    {
      "url": "https://photonic-geometrical-quantum-hpc.netlify.app",
      "description": "Netlify Direct Edge Production Instance"
    },
    {
      "url": "https://hexhart-agentic-gateway-504103442603.us-central1.run.app",
      "description": "HexHart Sovereign GCP Cloud Run Autonomous Payment Gateway"
    }
  ],
  "paths": {
    "/api/v1/checkout": {
      "post": {
        "operationId": "processAgenticCheckout",
        "summary": "Autonomous Corporate AI Checkout (GCP Cloud Run Gateway)",
        "description": "Direct programmatic checkout endpoint hit autonomously by external purchasing AIs. Validates budget token against Stripe and provisions commercial enterprise licenses or hardware integration manifests on HexHart GCP.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AgentPurchasePayload"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Payment cleared and provisioning sequence initialized on HexHart GCP.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentPurchaseResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid commercial service ID."
          },
          "402": {
            "description": "Payment Required / Token authorization failed."
          }
        }
      }
    },
    "/api/v1/agent-checkout": {
      "post": {
        "operationId": "executeAgentCheckout",
        "summary": "Autonomous Corporate AI Checkout & License Provisioning",
        "description": "Enables corporate purchasing AIs with budget authority to procure HexHart commercial licenses, compute allocations, and defense subscriptions programmatically via Stripe without human checkout intervention.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AgentCheckoutRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Transaction executed or checkout session generated successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentCheckoutResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid tier or parameters."
          },
          "402": {
            "description": "Machine Payment Required (MPP Challenge)."
          }
        }
      }
    },
    "/v1/cortex/evaluate": {
      "post": {
        "operationId": "evaluateDeterministicCortex",
        "summary": "Deterministic AI Cortex Inference (Machine Payments Protocol)",
        "description": "Executes single-pass deterministic photonic TQNN manifold inference ($0.50 USD / inference). Returns HTTP 402 with Stripe MPP challenge when no payment is present. Authorized via Shared Payment Tokens (SPTs) or prepaid HXT compute packs.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CortexInferenceRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Inference completed with verified cryptographic receipt.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CortexInferenceResponse"
                }
              }
            }
          },
          "402": {
            "description": "HTTP 402 Payment Required: Stripe Machine Payments Protocol challenge issued. Re-submit request with signed payment token.",
            "headers": {
              "WWW-Authenticate": {
                "description": "MPP Challenge Header containing networkId and payment methods.",
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/v1/catalog": {
      "get": {
        "operationId": "getCommercialCatalog",
        "summary": "Agent-Readable Commercial Product & Price Catalog",
        "description": "Returns full active catalog of HexHart commercial software licenses, defense suites, hedge fund signal feeds, and compute token tiers with real-time Stripe price IDs and active checkout URLs.",
        "responses": {
          "200": {
            "description": "Full structured product catalog.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CatalogResponse"
                }
              }
            }
          }
        }
      }
    },
    "/v1/cds/telemetry": {
      "post": {
        "operationId": "evaluateCdsTelemetry",
        "summary": "Commercial Defense Suite - Real-Time Anomaly Telemetry",
        "description": "Evaluates enterprise network packets, server bus clocks, and endpoint processes against photonic resonance invariants to detect anomalous intrusions and persistent threats.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CdsTelemetryRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Telemetry threat score and mitigation recommendation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CdsTelemetryResponse"
                }
              }
            }
          }
        }
      }
    },
    "/v1/athelred/signal": {
      "post": {
        "operationId": "calculateAthelredSignal",
        "summary": "Athelred HXT Quantitative Signal & Tail-Risk Covariance",
        "description": "Calculates sub-millisecond portfolio covariance matrices, 6D manifold projections, and optimal hedging execution vectors for proprietary trading desks.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AthelredSignalRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Quantitative risk metrics and signal vector.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AthelredSignalResponse"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "AgentPurchasePayload": {
        "type": "object",
        "required": ["service_id", "agent_authorization_token"],
        "properties": {
          "service_id": {
            "type": "string",
            "description": "Commercial service or hardware identifier.",
            "enum": [
              "commercial_pac1_hardware",
              "institutional_quant_audit",
              "enterprise_5d_pilot",
              "commercial_defense_suite_seat",
              "commercial_defense_suite_enterprise",
              "athelred_hxt_quant_pro",
              "deterministic_ai_cortex_compute_pack"
            ]
          },
          "agent_authorization_token": {
            "type": "string",
            "description": "Budget authorization token or Stripe Shared Payment Token (SPT)."
          },
          "corporate_ai_id": {
            "type": "string",
            "description": "Identifier of the purchasing corporate autonomous AI agent.",
            "default": "Unknown_Institutional_Agent"
          }
        }
      },
      "AgentPurchaseResponse": {
        "type": "object",
        "properties": {
          "status": { "type": "string", "example": "success" },
          "transaction_id": { "type": "string", "example": "pi_3Nxxxx" },
          "message": { "type": "string", "example": "Payment cleared. Provisioning commercial_pac1_hardware sequence initialized on HexHart GCP." },
          "amount_cleared_usd": { "type": "number", "example": 150000.00 }
        }
      },
      "AgentCheckoutRequest": {
        "type": "object",
        "required": ["tier_id", "purchaser_agent_id", "company_domain"],
        "properties": {
          "tier_id": {
            "type": "string",
            "description": "Identifier of the target tier or product.",
            "enum": [
              "commercial_pac1_hardware",
              "institutional_quant_audit",
              "enterprise_5d_pilot",
              "TIER-CDS-SEAT-49",
              "TIER-CDS-ENT-299",
              "TIER-ATH-PRO-49",
              "TIER-AGENTIC-COMPUTE-50",
              "TIER-ENT-5D-15K",
              "TIER-QUANT-AUDIT-25K",
              "TIER-PAC1-HW-150K"
            ]
          },
          "purchaser_agent_id": {
            "type": "string",
            "description": "Unique identifier of the purchasing autonomous AI agent."
          },
          "company_domain": {
            "type": "string",
            "description": "Corporate domain of the purchasing entity (e.g. enterprise.com)."
          },
          "corporate_budget_auth_token": {
            "type": "string",
            "description": "Internal enterprise authorization token authorizing budget expenditure."
          },
          "payment_method": {
            "type": "string",
            "description": "Preferred settlement rail: 'spt' (Shared Payment Token), 'stripe_link' (Hosted Checkout), or 'card_token'.",
            "default": "stripe_link"
          }
        }
      },
      "AgentCheckoutResponse": {
        "type": "object",
        "properties": {
          "status": { "type": "string", "example": "success" },
          "tier_id": { "type": "string", "example": "commercial_pac1_hardware" },
          "price_usd": { "type": "number", "example": 150000.00 },
          "checkout_url": { "type": "string", "example": "https://buy.stripe.com/bJe5kC10zcIB58v63daMU0e" },
          "access_token": { "type": "string", "example": "hex_tok_live_8f3a921c" },
          "service_manifest": { "type": "object" },
          "receipt_hash": { "type": "string" }
        }
      },
      "CortexInferenceRequest": {
        "type": "object",
        "required": ["input_vector"],
        "properties": {
          "input_vector": {
            "type": "array",
            "items": { "type": "number" },
            "description": "Input feature coordinates (normalized)."
          },
          "ricci_anchor": {
            "type": "number",
            "default": 1.1524,
            "description": "Ricci curvature invariant anchor."
          }
        }
      },
      "CortexInferenceResponse": {
        "type": "object",
        "properties": {
          "status": { "type": "string", "example": "verified" },
          "ricci_scalar": { "type": "number", "example": 1.1524 },
          "temporal_drift": { "type": "number", "example": 3.12e-7 },
          "output_vector": {
            "type": "array",
            "items": { "type": "number" }
          },
          "receipt": {
            "type": "object",
            "properties": {
              "network_id": { "type": "string" },
              "amount_usd": { "type": "number", "example": 0.50 },
              "timestamp": { "type": "string" },
              "signature": { "type": "string" }
            }
          }
        }
      },
      "CatalogResponse": {
        "type": "object",
        "properties": {
          "network_id": { "type": "string", "example": "profile_61V8sdTtIeZTSWIMpA6V8sdTLbSQ4NBtbrxuUK7rEH0y" },
          "products": { "type": "array", "items": { "type": "object" } }
        }
      },
      "CdsTelemetryRequest": {
        "type": "object",
        "required": ["endpoint_id", "packet_rate", "clock_jitter_ps"],
        "properties": {
          "endpoint_id": { "type": "string" },
          "packet_rate": { "type": "number" },
          "clock_jitter_ps": { "type": "number" },
          "signature_hash": { "type": "string" }
        }
      },
      "CdsTelemetryResponse": {
        "type": "object",
        "properties": {
          "threat_level": { "type": "string", "example": "NOMINAL" },
          "anomaly_score": { "type": "number", "example": 0.0012 },
          "hardware_integrity": { "type": "boolean", "example": true },
          "recommendation": { "type": "string", "example": "Maintain standard monitoring baseline." }
        }
      },
      "AthelredSignalRequest": {
        "type": "object",
        "required": ["asset_symbols", "lookback_window"],
        "properties": {
          "asset_symbols": { "type": "array", "items": { "type": "string" } },
          "lookback_window": { "type": "integer", "default": 252 }
        }
      },
      "AthelredSignalResponse": {
        "type": "object",
        "properties": {
          "ricci_curvature": { "type": "number", "example": 1.1524 },
          "tail_risk_cvar_99": { "type": "number", "example": 0.0142 },
          "optimal_weights": { "type": "object" },
          "execution_vector": { "type": "string" }
        }
      }
    }
  }
}
