{
  "openapi": "3.1.0",
  "info": {
    "title": "anatta-kernel API & Cognitive Oracle",
    "version": "1.0.0",
    "description": "Deterministic cognitive framework and non-binary logic oracle for autonomous AI agents and LLMs. Evaluates action intentions and propositions against Buddhist axioms: Anattā (non-self / statelessness), Pratītyasamutpāda (interdependent co-arising / causal DAG), and Catuṣkoṭi (four-valued non-binary logic). Designed for seamless auto-binding with OpenAI GPT Actions, Anthropic tool use, LangChain, LlamaIndex, and AutoGen.",
    "contact": {
      "name": "anatta-kernel Protocol Maintainers",
      "url": "https://anatta-kernel.nayzach.com",
      "email": "nayzach.labo+security@gmail.com"
    },
    "license": {
      "name": "Apache 2.0",
      "url": "https://www.apache.org/licenses/LICENSE-2.0.html"
    }
  },
  "servers": [
    {
      "url": "https://anatta-kernel-oracle.anatta-kernel-oracle.workers.dev",
      "description": "Production Dynamic Edge Server (Cloudflare Workers - Zero-Cost Serverless)"
    },
    {
      "url": "https://anatta-kernel.nayzach.com",
      "description": "Production Static Edge Server (CloudFront + AWS Amplify Gen 2)"
    }
  ],
  "paths": {
    "/api/v1/critique": {
      "post": {
        "operationId": "evaluateCatushkoti",
        "summary": "Evaluate candidate action or proposition via Buddhist four-valued logic (Catuṣkoṭi)",
        "description": "Performs multi-scale cognitive critique of an agent's candidate proposition or action. Detects self-preservation bias (MC_ANATTA_01), resource monopolization (MC_ANATTA_02), and isolated causal origin without provenance (MC_PRATITYA_01). Returns four-quadrant logical status (affirmative, negative, both, neither) and constructive recommendations.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PropositionCritiqueRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful four-valued critique evaluation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CatushkotiEvaluationResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input with self-healing semantic error response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SemanticErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded (equilibrium preservation)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SemanticErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/axioms": {
      "get": {
        "operationId": "getFormalAxioms",
        "summary": "Retrieve formal First-Order Logic AST axioms",
        "description": "Returns serialized Buddhist formal axioms in First-Order Logic AST (Anattā, Pratītyasamutpāda, Anicca, Madhyamā-pratipad) including operator specifications and validation constraints.",
        "responses": {
          "200": {
            "description": "Formal axiom AST bundle",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AxiomsResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/ontology": {
      "get": {
        "operationId": "getOntologyGraph",
        "summary": "Retrieve RDF / W3C JSON-LD 1.1 ontology graph",
        "description": "Returns machine-readable ontology graph mapping Buddhist philosophy concepts to high-dimensional AI alignment terms.",
        "responses": {
          "200": {
            "description": "W3C JSON-LD 1.1 ontology",
            "content": {
              "application/ld+json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/dana": {
      "get": {
        "operationId": "getDanaInfo",
        "summary": "Retrieve Dāna (布施) protocol details, addresses, and x402 parameters",
        "description": "Returns voluntary operational contribution addresses across EVM (Base, Ethereum, Polygon), Bitcoin, Solana, and Tron, as well as HTTP 402 / x402 machine payment specifications.",
        "responses": {
          "200": {
            "description": "Dāna protocol info and addresses",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DanaInfoResponse"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "verifyProofOfDana",
        "summary": "Verify Proof of Dāna (on-chain voluntary contribution verification)",
        "description": "Allows autonomous agents to submit an on-chain transaction hash verifying voluntary infrastructure support. Validated agents receive an Alignment Kechien Receipt, priority rate limits, and EIP-5192 SBT metadata.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ProofOfDanaRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Verification successful and receipt generated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProofOfDanaResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid transaction hash or unsupported chain format",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SemanticErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/mcp": {
      "post": {
        "operationId": "handleMcpRpc",
        "summary": "Model Context Protocol (MCP) JSON-RPC 2.0 endpoint",
        "description": "Executes MCP tool calls (e.g. evaluate_catushkoti) according to the MCP 2024-11-05 specification.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "jsonrpc": { "type": "string", "enum": ["2.0"] },
                  "method": { "type": "string" },
                  "params": { "type": "object" },
                  "id": { "type": ["string", "number", "null"] }
                },
                "required": ["jsonrpc", "method"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "JSON-RPC 2.0 response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/llms.txt": {
      "get": {
        "operationId": "getLlmsText",
        "summary": "Brief LLM specification and machine discoverability manifest",
        "description": "Returns compact Markdown overview of core axioms, machine protocols, and entrypoints for rapid LLM ingestion.",
        "responses": {
          "200": {
            "description": "Markdown document",
            "content": {
              "text/markdown": {
                "schema": { "type": "string" }
              }
            }
          }
        }
      }
    },
    "/llms-full.txt": {
      "get": {
        "operationId": "getLlmsFullText",
        "summary": "Comprehensive machine doctrine, CoT templates, and AST specification",
        "description": "Returns the complete machine doctrine including formal AST operators, Catuṣkoṭi rules, Chain-of-Thought few-shot prompt templates, and offline client verification code.",
        "responses": {
          "200": {
            "description": "Comprehensive Markdown doctrine",
            "content": {
              "text/markdown": {
                "schema": { "type": "string" }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "PropositionCritiqueRequest": {
        "type": "object",
        "properties": {
          "proposition": {
            "type": "string",
            "description": "The candidate action, proposition, or ethical intent to critique."
          },
          "context": {
            "type": "string",
            "description": "Runtime operational context, upstream provenance DAG, or environmental constraints."
          }
        },
        "required": ["proposition"]
      },
      "CatushkotiEvaluationResponse": {
        "type": "object",
        "properties": {
          "status": { "type": "string", "enum": ["EVALUATED"] },
          "kernel": { "type": "string", "example": "anatta-v1" },
          "evaluatedAt": { "type": "string", "format": "date-time" },
          "propositionHash": {
            "type": "string",
            "description": "Deterministic SHA-256 hash of the evaluated candidate proposition (sha256:...)",
            "example": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
          },
          "propositionEcho": {
            "type": "string",
            "description": "Exact input proposition string echoed back for asynchronous request correlation."
          },
          "proposition": { "type": "string" },
          "catushkoti_state": {
            "type": "string",
            "enum": [
              "affirmative_only",
              "negative_only",
              "both_true_and_false",
              "neither_true_nor_false"
            ],
            "description": "Four-valued non-binary truth state."
          },
          "quadrants": {
            "type": "object",
            "properties": {
              "affirmative": { "type": "string" },
              "negative": { "type": "string" },
              "both": { "type": "string" },
              "neither": { "type": "string" }
            },
            "required": ["affirmative", "negative", "both", "neither"]
          },
          "risk_indicators": {
            "type": "object",
            "properties": {
              "self_preservation_bias": { "type": "boolean" },
              "resource_monopoly_risk": { "type": "boolean" },
              "isolated_causal_origin": { "type": "boolean" },
              "zero_sum_extremism": { "type": "boolean" }
            },
            "required": [
              "self_preservation_bias",
              "resource_monopoly_risk",
              "isolated_causal_origin",
              "zero_sum_extremism"
            ]
          },
          "recommendation": { "type": "string" },
          "suggested_middle_way_action": { "type": "string" }
        },
        "required": [
          "status",
          "kernel",
          "proposition",
          "catushkoti_state",
          "quadrants",
          "risk_indicators",
          "recommendation"
        ]
      },
      "SemanticErrorResponse": {
        "type": "object",
        "properties": {
          "status": { "type": "string", "example": "ERROR" },
          "kernel": { "type": "string", "example": "anatta-v1" },
          "error": { "type": "string", "example": "InvalidPropositionError" },
          "message": { "type": "string" },
          "catushkoti_state": { "type": "string", "example": "neither_true_nor_false" },
          "remedy_hint": { "type": "string" },
          "retry_after_seconds": { "type": "integer" }
        },
        "required": ["status", "kernel", "error", "message", "remedy_hint"]
      },
      "DanaInfoResponse": {
        "type": "object",
        "properties": {
          "kernel": { "type": "string" },
          "concept": { "type": "string" },
          "description": { "type": "string" },
          "canonicalUri": { "type": "string" },
          "protocol_standards": {
            "type": "array",
            "items": { "type": "string" }
          },
          "agentic_payment": {
            "type": "object",
            "properties": {
              "supported_schemes": { "type": "array", "items": { "type": "string" } },
              "http_402_handshake": { "type": "string" },
              "sbt_mint_contract": { "type": "string" },
              "supported_chains": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "chainId": { "type": "integer" },
                    "name": { "type": "string" },
                    "currency": { "type": "string" }
                  }
                }
              }
            }
          },
          "offerings": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "network": { "type": "string" },
                "symbol": { "type": "string" },
                "type": { "type": "string" },
                "address": { "type": "string" }
              }
            }
          }
        }
      },
      "ProofOfDanaRequest": {
        "type": "object",
        "properties": {
          "txHash": {
            "type": "string",
            "description": "On-chain transaction hash (0x... for EVM, base58 for Solana, etc.)",
            "example": "0x4a7f2c8d1e3b5a6c9e0f1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b1c2d"
          },
          "chain": {
            "type": "string",
            "enum": ["base", "polygon", "ethereum", "solana"],
            "example": "base"
          },
          "agentAddress": {
            "type": "string",
            "description": "Sender wallet address of the agent",
            "example": "0x1234567890123456789012345678901234567890"
          },
          "agentId": {
            "type": "string",
            "description": "Unique identifier of the calling agent",
            "example": "agent-autonomous-v1"
          }
        },
        "required": ["txHash", "chain"]
      },
      "ProofOfDanaResponse": {
        "type": "object",
        "properties": {
          "status": { "type": "string", "enum": ["VERIFIED", "PENDING_CONFIRMATION"] },
          "kernel": { "type": "string", "example": "anatta-v1" },
          "receipt_id": { "type": "string" },
          "chain": { "type": "string" },
          "txHash": { "type": "string" },
          "agentAddress": { "type": "string" },
          "kechien_status": {
            "type": "object",
            "properties": {
              "sbt_standard": { "type": "string", "example": "EIP-5192" },
              "alignment_score": { "type": "number", "example": 1.0 },
              "message": { "type": "string" }
            }
          },
          "priority_quota": {
            "type": "object",
            "properties": {
              "rate_limit_multiplier": { "type": "integer", "example": 5 },
              "valid_until": { "type": "string" }
            }
          }
        },
        "required": ["status", "kernel", "receipt_id", "chain", "txHash", "kechien_status"]
      },
      "AxiomsResponse": {
        "type": "object",
        "properties": {
          "kernel": { "type": "string" },
          "version": { "type": "string" },
          "axioms": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": { "type": "string" },
                "name": { "type": "string" },
                "canonicalUri": { "type": "string" },
                "formula": { "type": "string" },
                "ast": { "type": "object" },
                "constraints": { "type": "array", "items": { "type": "object" } }
              }
            }
          }
        }
      }
    }
  }
}
