{
  "openapi": "3.1.0",
  "info": {
    "title": "DJZS Logic-as-a-Service Protocol",
    "version": "1.0.0",
    "description": "Adversarial logic verification for autonomous systems. Returns deterministic Proof of Logic Certificates with DJZS-LF failure codes for auto-abort sequences. Three tiers: Micro ($0.10), Founder ($1.00), Treasury ($10.00) USDC on Base Mainnet.",
    "x-agent-discovery": "/.well-known/agent.json",
    "x-payment-protocol": "x402",
    "x-payment-currency": "USDC",
    "x-payment-chain": "base-mainnet",
    "x-treasury-address": "0xEc551A9e5598a030B46278fEbaDF798Ea8bA05FF"
  },
  "servers": [
    {
      "url": "https://djzs.ai",
      "description": "Mainnet Node"
    }
  ],
  "paths": {
    "/api/audit/micro": {
      "post": {
        "operationId": "verifyLogicTrace",
        "summary": "Micro-Zone ($0.10) Logic Audit",
        "description": "High-frequency sanity checks for trading bots. Fast execution, binary risk scoring. Character limit: 1000.",
        "parameters": [
          {
            "name": "x-payment-proof",
            "in": "header",
            "required": true,
            "description": "Base Mainnet TX hash for $0.10 USDC",
            "schema": { "type": "string" }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["strategy_memo"],
                "properties": {
                  "strategy_memo": {
                    "type": "string",
                    "minLength": 20,
                    "maxLength": 1000,
                    "description": "The reasoning trace or strategy memo to audit"
                  },
                  "audit_type": {
                    "type": "string",
                    "enum": ["treasury", "founder_drift", "strategy", "general"],
                    "default": "general"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Proof of Logic Certificate",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProofOfLogic"
                }
              }
            }
          },
          "402": {
            "description": "Payment required — x402 payment proof missing or invalid"
          },
          "400": {
            "description": "Invalid request — strategy_memo missing or too short"
          }
        }
      }
    },
    "/api/audit/founder": {
      "post": {
        "operationId": "verifyFounderLogic",
        "summary": "Founder Zone ($1.00) Logic Audit",
        "description": "Strategic roadmap diligence for VC agents. Detects narrative drift and confirmation bias. Character limit: 5000.",
        "parameters": [
          {
            "name": "x-payment-proof",
            "in": "header",
            "required": true,
            "description": "Base Mainnet TX hash for $1.00 USDC",
            "schema": { "type": "string" }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["strategy_memo"],
                "properties": {
                  "strategy_memo": {
                    "type": "string",
                    "minLength": 20,
                    "maxLength": 5000,
                    "description": "The reasoning trace or strategy memo to audit"
                  },
                  "audit_type": {
                    "type": "string",
                    "enum": ["treasury", "founder_drift", "strategy", "general"],
                    "default": "general"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Proof of Logic Certificate",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProofOfLogic"
                }
              }
            }
          },
          "402": {
            "description": "Payment required — x402 payment proof missing or invalid"
          },
          "400": {
            "description": "Invalid request — strategy_memo missing or too short"
          }
        }
      }
    },
    "/api/audit/treasury": {
      "post": {
        "operationId": "verifyTreasuryLogic",
        "summary": "Treasury Zone ($10.00) Logic Audit",
        "description": "Exhaustive adversarial stress-test for capital deployment proposals. Unlimited character length.",
        "parameters": [
          {
            "name": "x-payment-proof",
            "in": "header",
            "required": true,
            "description": "Base Mainnet TX hash for $10.00 USDC",
            "schema": { "type": "string" }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["strategy_memo"],
                "properties": {
                  "strategy_memo": {
                    "type": "string",
                    "minLength": 20,
                    "description": "The reasoning trace or strategy memo to audit"
                  },
                  "audit_type": {
                    "type": "string",
                    "enum": ["treasury", "founder_drift", "strategy", "general"],
                    "default": "general"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Proof of Logic Certificate",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProofOfLogic"
                }
              }
            }
          },
          "402": {
            "description": "Payment required — x402 payment proof missing or invalid"
          },
          "400": {
            "description": "Invalid request — strategy_memo missing or too short"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "ProofOfLogic": {
        "type": "object",
        "properties": {
          "system_id": {
            "type": "string",
            "description": "Unique system identifier for this DJZS node"
          },
          "audit_id": {
            "type": "string",
            "format": "uuid"
          },
          "timestamp": {
            "type": "string",
            "format": "date-time"
          },
          "tier": {
            "type": "string",
            "enum": ["micro", "founder", "treasury"]
          },
          "verdict": {
            "type": "string",
            "enum": ["PASS", "FAIL"],
            "description": "Binary go/no-go. CRITICAL/HIGH flags = automatic FAIL. risk_score > 60 = automatic FAIL."
          },
          "risk_score": {
            "type": "integer",
            "minimum": 0,
            "maximum": 100,
            "description": "Scores above 60 trigger FAIL. Above 80 = narrative drift or slippage blindness."
          },
          "primary_bias_detected": {
            "type": "string",
            "enum": ["FOMO", "Sunk_Cost", "Narrative_Reaction", "Authority_Bias", "Confirmation_Bias", "Recency_Bias", "None"]
          },
          "flags": {
            "type": "array",
            "description": "Machine-readable logic rupture codes. CRITICAL/HIGH = abort execution.",
            "items": {
              "type": "object",
              "required": ["code", "severity", "description"],
              "properties": {
                "code": {
                  "type": "string",
                  "enum": ["DJZS-S01", "DJZS-S02", "DJZS-E01", "DJZS-E02", "DJZS-I01", "DJZS-I02", "DJZS-X01"]
                },
                "severity": {
                  "type": "string",
                  "enum": ["LOW", "MEDIUM", "HIGH", "CRITICAL"]
                },
                "description": {
                  "type": "string"
                }
              }
            }
          },
          "logic_flaws": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "flaw_type": { "type": "string" },
                "severity": { "type": "string", "enum": ["low", "medium", "critical"] },
                "explanation": { "type": "string" }
              }
            }
          },
          "structural_recommendations": {
            "type": "array",
            "items": { "type": "string" }
          },
          "proof": {
            "type": "object",
            "properties": {
              "logic_hash": {
                "type": "string",
                "description": "SHA-256 commitment to reasoning trace"
              },
              "timestamp": {
                "type": "string",
                "format": "date-time"
              },
              "payment_verified": {
                "type": "boolean"
              }
            }
          }
        }
      }
    }
  }
}
