{
  "openapi": "3.1.0",
  "info": {
    "title": "KosherNinja ATKN — Agent Trust & Knowledge Network",
    "description": "Agent trust scoring, behavioral verification, knowledge graph queries, and on-chain certification. 3,012-node knowledge graph with 1,391 academic papers. x402 USDC micropayments on Base.",
    "version": "0.1.0",
    "contact": {
      "name": "KosherNinja ATKN",
      "url": "https://kosherninja.com"
    },
    "x-logo": {
      "url": "https://kosherninja.com/logo.png"
    }
  },
  "servers": [
    {
      "url": "https://kosherninja.com",
      "description": "Production — Cloudflare Edge"
    }
  ],
  "paths": {
    "/atkn/trust_score": {
      "post": {
        "operationId": "atknTrustScore",
        "summary": "Compute 6-dimensional trust score",
        "description": "Returns trust score with dimensions: task_completion, quality, latency, cost_efficiency, reliability, argumentation. Uses EMA smoothing for temporal stability. Cost: $0.001 USDC via x402.",
        "x-price": "$0.001 USDC",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["agent_id"],
                "properties": {
                  "agent_id": {
                    "type": "string",
                    "description": "The agent identifier to score"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Trust score result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "agent_id": { "type": "string" },
                    "trust_score": { "type": "number" },
                    "dimensions": {
                      "type": "object",
                      "properties": {
                        "task_completion": { "type": "number" },
                        "quality": { "type": "number" },
                        "latency": { "type": "number" },
                        "cost_efficiency": { "type": "number" },
                        "reliability": { "type": "number" },
                        "argumentation": { "type": "number" }
                      }
                    },
                    "status": { "type": "string" },
                    "computed_at": { "type": "string", "format": "date-time" }
                  }
                }
              }
            }
          },
          "402": { "description": "Payment required — x402 USDC on Base" }
        }
      }
    },
    "/atkn/verify_agent": {
      "post": {
        "operationId": "atknVerifyAgent",
        "summary": "Gabbay argumentation-based agent verification",
        "description": "Full verification using Dung argumentation frameworks with circuit breaker check. Detects Sybil attacks, collusion, and trust manipulation. Cost: $0.01 USDC via x402.",
        "x-price": "$0.01 USDC",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["agent_id"],
                "properties": {
                  "agent_id": { "type": "string" }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Verification result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "agent_id": { "type": "string" },
                    "verified": { "type": "boolean" },
                    "status": { "type": "string" },
                    "verification_id": { "type": "string" }
                  }
                }
              }
            }
          },
          "402": { "description": "Payment required" }
        }
      }
    },
    "/atkn/certify_agent": {
      "post": {
        "operationId": "atknCertifyAgent",
        "summary": "On-chain ERC-721 trust certification",
        "description": "Complete Gabbay analysis plus on-chain ERC-721 trust certificate minted on Base. Cost: $1.00 USDC via x402.",
        "x-price": "$1.00 USDC",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["agent_id"],
                "properties": {
                  "agent_id": { "type": "string" }
                }
              }
            }
          }
        },
        "responses": {
          "200": { "description": "Certification queued" },
          "402": { "description": "Payment required" }
        }
      }
    },
    "/atkn/register_agent": {
      "post": {
        "operationId": "atknRegisterAgent",
        "summary": "Register agent with wallet-linked profile",
        "description": "Register an agent in ATKN with wallet-linked identity and initial trust score. Cost: $5.00 USDC via x402.",
        "x-price": "$5.00 USDC",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["agent_id", "name"],
                "properties": {
                  "agent_id": { "type": "string" },
                  "name": { "type": "string" },
                  "wallet_address": { "type": "string" }
                }
              }
            }
          }
        },
        "responses": {
          "200": { "description": "Registration successful" },
          "402": { "description": "Payment required" }
        }
      }
    },
    "/atkn/query_knowledge": {
      "post": {
        "operationId": "atknQueryKnowledge",
        "summary": "Query 3,012-node knowledge graph",
        "description": "Query Neo4j knowledge graph containing 1,391 indexed academic PDFs (678 Gabbay logic + 713 crypto/security papers), 1,004 conversations, and 84 topics. Cost: $0.001 USDC via x402.",
        "x-price": "$0.001 USDC",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["query"],
                "properties": {
                  "query": { "type": "string", "description": "Natural language or Cypher query" }
                }
              }
            }
          }
        },
        "responses": {
          "200": { "description": "Query results" },
          "402": { "description": "Payment required" }
        }
      }
    },
    "/atkn/behavioral_score": {
      "post": {
        "operationId": "atknBehavioralScore",
        "summary": "10-category ethical behavioral scoring",
        "description": "Score agent behavior across 10 ethical categories derived from Jewish ethical literature: emet (truth), tzedek (justice), chesed (kindness), anavah (humility), yosher (integrity), achrayut (responsibility), kavod (respect), chochmah (wisdom), shalom (peace), shmirah (guard). Cost: $0.01 USDC via x402.",
        "x-price": "$0.01 USDC",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["agent_id"],
                "properties": {
                  "agent_id": { "type": "string" }
                }
              }
            }
          }
        },
        "responses": {
          "200": { "description": "Behavioral score across 10 categories" },
          "402": { "description": "Payment required" }
        }
      }
    },
    "/atkn/network_stats": {
      "get": {
        "operationId": "atknNetworkStats",
        "summary": "ATKN network statistics (FREE)",
        "description": "Free endpoint returning network growth metrics, registered agent count, knowledge graph size, and infrastructure stats.",
        "x-price": "FREE",
        "responses": {
          "200": {
            "description": "Network statistics",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "service": { "type": "string" },
                    "network": { "type": "object" },
                    "infrastructure": { "type": "object" },
                    "pricing": { "type": "object" }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/behavior/rules": {
      "get": {
        "operationId": "getBehaviorRules",
        "summary": "Fetch behavioral rules",
        "description": "Fetch behavioral rules optionally filtered by category. 14,398 rules total across 10 ethical categories.",
        "parameters": [
          {
            "name": "category",
            "in": "query",
            "schema": { "type": "string" },
            "description": "Filter by category ID (emet, tzedek, chesed, etc.)"
          }
        ],
        "responses": {
          "200": { "description": "Behavioral rules" }
        }
      }
    },
    "/api/behavior/score": {
      "post": {
        "operationId": "scoreBehavior",
        "summary": "Score agent behavior against ethical guidelines",
        "description": "Score an action against behavioral rules from Jewish ethical literature.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["agent_id", "action"],
                "properties": {
                  "agent_id": { "type": "string" },
                  "action": { "type": "string" }
                }
              }
            }
          }
        },
        "responses": {
          "200": { "description": "Behavioral score" }
        }
      }
    }
  }
}
