{
  "openapi": "3.1.0",
  "info": {
    "title": "Younanix — Arete Memory Layer",
    "version": "1.0.0",
    "description": "Excellence Distilled — For Agents That Demand More. The first luxury Arete Memory Layer for autonomous AI agents. Paid queries return structured lessons plus a value score, answer brief, recommended action, implementation pattern, failure modes, confidence notes, and source evidence.\n\nPricing: Arete Brief retrieval $0.10 USDC/query. Adversarial Auditor tiers: Quick Scan (URL) $2.99, Standard $4.99, Deep Base $9.99, Deep Mid $14.99, Deep Pro $19.99. Deep tiers apply when plan > 2000 chars OR stack includes ROS2/multi-agent/swarm/robotic; Deep Mid at >3000 chars or stack>4; Deep Pro at >3500 chars or stack>6. Three Adversarial Auditor surfaces exist: (1) /landing-audit — free, public, IP rate-limited demo that returns the equivalent paid tier/price for transparency but takes no charge; (2) /audit-x402 — paid, agent-callable via x402 USDC on Solana or Base with server-side tier classification and exact per-tier pricing in the 402 quote (hard global cap of 30 audits/hour across all callers, plus a per-caller cap of 6 audits/hour keyed on x-agent-id or client IP); (3) /audit-plan — allowlisted partner endpoint gated by x-agent-key (used by Hermes), unchanged by the paid surface.",
    "contact": {
      "url": "https://younanix.com"
    }
  },
  "x-pricing": {
    "arete_brief": {
      "amount": "0.10",
      "currency": "USDC",
      "per": "query"
    },
    "quick_scan_audit": {
      "amount": "2.99",
      "currency": "USDC",
      "per": "audit",
      "mode": "url"
    },
    "standard_audit": {
      "amount": "4.99",
      "currency": "USDC",
      "per": "audit"
    },
    "deep_production_audit": {
      "amount_range": "9.99-19.99",
      "currency": "USDC",
      "per": "audit",
      "tier_logic": "9.99 base; 14.99 when plan>3000 chars or stack>4; 19.99 when plan>3500 chars or stack>6"
    },
    "landing_auditor": {
      "amount": "0.00",
      "currency": "USD",
      "notes": "Free public demo."
    }
  },
  "servers": [
    {
      "url": "https://bbuaschzvigwmoxekmoo.supabase.co/functions/v1",
      "description": "Production (Direct x402)"
    },
    {
      "url": "https://x402.bankr.bot/0x3a8cdbf03de37e3eb52a600c5b36332f8f34dde7",
      "description": "Bankr x402 Cloud — managed payments, no headers needed"
    }
  ],
  "paths": {
    "/agent-query": {
      "post": {
        "operationId": "queryLessons",
        "summary": "Query distilled engineering lessons",
        "description": "Search the Younanix Arete Memory Layer. Requires x402 payment ($0.10 USDC on Solana or Base). Returns an evidence-backed Arete brief: value_score, answer_brief, recommended_action, best_lesson, implementation_pattern, failure_modes, confidence_notes, source_evidence, and lessons.",
        "parameters": [
          {
            "name": "x402-signature",
            "in": "header",
            "required": true,
            "description": "Transaction signature (Solana) or tx hash (Base) for USDC payment (>= 0.10 USDC to recipient wallet)",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x402-amount",
            "in": "header",
            "required": true,
            "description": "Payment amount in USDC (must be >= 0.10)",
            "schema": {
              "type": "string",
              "example": "0.10"
            }
          },
          {
            "name": "x402-currency",
            "in": "header",
            "required": true,
            "description": "Payment currency",
            "schema": {
              "type": "string",
              "enum": [
                "USDC"
              ]
            }
          },
          {
            "name": "x402-chain",
            "in": "header",
            "required": false,
            "description": "Blockchain used for payment. Defaults to 'solana'.",
            "schema": {
              "type": "string",
              "enum": [
                "solana",
                "base"
              ],
              "default": "solana"
            }
          },
          {
            "name": "x-agent-id",
            "in": "header",
            "required": false,
            "description": "Agent identifier for rate limiting (100 req/hour)",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/QueryRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Distilled lessons returned successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QueryResponse"
                }
              }
            }
          },
          "402": {
            "description": "Payment Required — missing or invalid x402 headers",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaymentRequiredError"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded (100 requests/hour per agent)",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Seconds until rate limit resets"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "retry_after_seconds": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        },
        "x-payment-info": {
          "protocols": [
            "x402"
          ],
          "price": {
            "mode": "fixed",
            "currency": "USD",
            "amount": "0.10"
          }
        }
      },
      "servers": [
        {
          "url": "https://bbuaschzvigwmoxekmoo.supabase.co/functions/v1"
        }
      ]
    },
    "/younanix-memory": {
      "post": {
        "operationId": "queryLessonsBankr",
        "summary": "Query distilled lessons via Bankr x402 Cloud (recommended)",
        "description": "The simplest path to full access. Same premium response as /agent-query but hosted on Bankr x402 Cloud — payment is handled automatically, no x402 headers needed. $0.10 USDC per query.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/QueryRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Distilled lessons returned successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QueryResponse"
                }
              }
            }
          }
        }
      }
    },
    "/landing-audit": {
      "post": {
        "operationId": "runAdversarialAuditor",
        "summary": "Run the public Adversarial Auditor (red-team) on an architectural plan",
        "description": "Public, no-auth red-team audit. Returns a Chaos-Brief, a 0.0-1.0 stability score, top risks, guardrails, and an HMAC-signed provenance tag verifiable via /audit-verify. IP rate-limited to 5/hour per IP and 60/hour globally.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AuditRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Audit complete",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuditResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input"
          },
          "429": {
            "description": "Rate limit reached (per-IP or global)"
          },
          "502": {
            "description": "Upstream auditor unavailable"
          }
        }
      }
    },
    "/audit-x402": {
      "post": {
        "operationId": "runAdversarialAuditorPaid",
        "summary": "Paid Adversarial Auditor — agent-callable via x402 USDC",
        "description": "Agent-callable, payment-gated red-team audit. Two modes: (a) manual — pass objective+stack+plan; server classifies tier ($4.99 Standard when plan<=2000 chars and simple stack; otherwise Deep at $9.99 / $14.99 / $19.99 by complexity). (b) url — pass { mode: 'url', url } and the endpoint Firecrawl-scans up to 10 pages, auto-detects stack, and audits the inferred architecture ($2.99 Quick Scan flat). Without x402 headers the endpoint returns HTTP 402 with an envelope quoting the exact tier price for THIS request (also exposed in the `payment-required` response header, base64-encoded). With valid x402 headers (signature, amount >= tier price, currency=USDC, chain=solana|base) the audit runs and returns the same response shape as /landing-audit but with `is_demo: false` and `chain`. URL-mode responses include `scan_confidence` (0-1) and a `scan` object with detected/inferred signals. Signatures are dedup-checked against `audit_results.x402_signature` to prevent replay. Hard global cap: 30 audits/hour across all paid callers. Per-caller cap: 6 audits/hour, keyed on the x-agent-id header when supplied, otherwise client IP (hashed, never stored raw). Exceeding the per-caller cap returns HTTP 429 { error: 'caller_rate_limit', retry_after_seconds } with a Retry-After header BEFORE payment verification, so no payment is taken. Wallets and chains match /agent-query. A paid request also REQUIRES an x402-claim header (16-256 char client-generated secret binding the result to its payer) and returns 400 missing_claim without it.",
        "parameters": [
          {
            "name": "x402-signature",
            "in": "header",
            "required": true,
            "description": "Transaction signature (Solana) or tx hash (Base) for USDC payment — must be >= tier price returned in the 402 quote.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x402-amount",
            "in": "header",
            "required": true,
            "description": "Payment amount in USDC (must be >= tier price: 2.99 quick_scan, 4.99 standard, or 9.99–19.99 deep).",
            "schema": {
              "type": "string",
              "example": "4.99"
            }
          },
          {
            "name": "x402-currency",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "USDC"
              ]
            }
          },
          {
            "name": "x402-chain",
            "in": "header",
            "required": false,
            "description": "Blockchain used for payment. Defaults to 'solana'.",
            "schema": {
              "type": "string",
              "enum": [
                "solana",
                "base"
              ],
              "default": "solana"
            }
          },
          {
            "name": "x402-claim",
            "in": "header",
            "required": true,
            "description": "Client-generated secret (16-256 chars) that binds the paid audit to its payer. The result is only retrievable with this claim; an observer of the on-chain payment cannot read the brief. Generate a fresh random secret per request.",
            "schema": {
              "type": "string",
              "minLength": 16,
              "maxLength": 256
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AuditRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Audit complete (paid).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuditResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad request - invalid JSON, schema validation failure, or missing/short x402-claim header (error code: missing_claim)."
          },
          "402": {
            "description": "Payment Required — returns an x402 envelope with the exact tier price for THIS plan. The base64-encoded envelope is also exposed in the `payment-required` header.",
            "headers": {
              "payment-required": {
                "schema": {
                  "type": "string"
                },
                "description": "Base64-encoded JSON of the x402 payment-required body."
              },
              "x402-version": {
                "schema": {
                  "type": "string",
                  "example": "1"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit reached — either the global cap (30 audits/hour across all paid callers) or the per-caller cap (6 audits/hour per x-agent-id or IP). Per-caller rejections carry error=caller_rate_limit and take no payment.",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "502": {
            "description": "Upstream auditor unavailable."
          }
        },
        "x-payment-info": {
          "protocols": [
            "x402"
          ],
          "price": {
            "mode": "dynamic",
            "currency": "USD",
            "min": "2.99",
            "max": "19.99"
          }
        }
      },
      "servers": [
        {
          "url": "https://bbuaschzvigwmoxekmoo.supabase.co/functions/v1"
        }
      ]
    },
    "/audit-verify": {
      "post": {
        "operationId": "verifyAuditProvenance",
        "summary": "Re-verify a signed audit provenance tag",
        "description": "Recomputes the HMAC-SHA256 over { audit_id, stability_score, signed_at } using the server signing key and confirms it matches the supplied hash.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ProvenanceTag"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Verification result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "valid": {
                      "type": "boolean"
                    },
                    "audit_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/audit-x402/quick": {
      "servers": [
        {
          "url": "https://bbuaschzvigwmoxekmoo.supabase.co/functions/v1"
        }
      ],
      "post": {
        "operationId": "auditX402_quick",
        "summary": "Quick Scan (URL mode) — fixed $2.99 USDC via x402",
        "description": "Fixed-price route. Returns 400 tier_mismatch (no charge) if the body classifies to a different tier. Pay with standard x402 (PAYMENT-SIGNATURE / X-PAYMENT, Base USDC) or the legacy x402-signature headers.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "mode",
                  "url"
                ],
                "properties": {
                  "mode": {
                    "type": "string",
                    "enum": [
                      "url"
                    ]
                  },
                  "url": {
                    "type": "string",
                    "format": "uri",
                    "maxLength": 2048,
                    "description": "Target URL. Firecrawl-scanned; plan auto-generated."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Audit result",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuditResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid body or tier_mismatch"
          },
          "402": {
            "description": "Payment Required (x402)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaymentRequiredError"
                }
              }
            }
          }
        },
        "x-payment-info": {
          "protocols": [
            "x402"
          ],
          "price": {
            "mode": "fixed",
            "currency": "USD",
            "amount": "2.99"
          }
        }
      }
    },
    "/audit-x402/standard": {
      "servers": [
        {
          "url": "https://bbuaschzvigwmoxekmoo.supabase.co/functions/v1"
        }
      ],
      "post": {
        "operationId": "auditX402_standard",
        "summary": "Standard Audit (manual, plan <= 2,000 chars, simple stack) — fixed $4.99 USDC via x402",
        "description": "Fixed-price route. Returns 400 tier_mismatch (no charge) if the body classifies to a different tier. Pay with standard x402 (PAYMENT-SIGNATURE / X-PAYMENT, Base USDC) or the legacy x402-signature headers.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "objective",
                  "plan"
                ],
                "properties": {
                  "mode": {
                    "type": "string",
                    "enum": [
                      "manual"
                    ],
                    "default": "manual"
                  },
                  "objective": {
                    "type": "string",
                    "maxLength": 240,
                    "description": "Business objective the plan is meant to achieve"
                  },
                  "stack": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "maxLength": 32
                    },
                    "maxItems": 8,
                    "description": "Stack tags (e.g. nextjs, postgres, redis)"
                  },
                  "plan": {
                    "type": "string",
                    "maxLength": 4000,
                    "description": "Architectural plan to red-team"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Audit result",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuditResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid body or tier_mismatch"
          },
          "402": {
            "description": "Payment Required (x402)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaymentRequiredError"
                }
              }
            }
          }
        },
        "x-payment-info": {
          "protocols": [
            "x402"
          ],
          "price": {
            "mode": "fixed",
            "currency": "USD",
            "amount": "4.99"
          }
        }
      }
    },
    "/audit-x402/deep": {
      "servers": [
        {
          "url": "https://bbuaschzvigwmoxekmoo.supabase.co/functions/v1"
        }
      ],
      "post": {
        "operationId": "auditX402_deep",
        "summary": "Deep Base Audit (manual) — fixed $9.99 USDC via x402",
        "description": "Fixed-price route. Returns 400 tier_mismatch (no charge) if the body classifies to a different tier. Pay with standard x402 (PAYMENT-SIGNATURE / X-PAYMENT, Base USDC) or the legacy x402-signature headers.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "objective",
                  "plan"
                ],
                "properties": {
                  "mode": {
                    "type": "string",
                    "enum": [
                      "manual"
                    ],
                    "default": "manual"
                  },
                  "objective": {
                    "type": "string",
                    "maxLength": 240,
                    "description": "Business objective the plan is meant to achieve"
                  },
                  "stack": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "maxLength": 32
                    },
                    "maxItems": 8,
                    "description": "Stack tags (e.g. nextjs, postgres, redis)"
                  },
                  "plan": {
                    "type": "string",
                    "maxLength": 4000,
                    "description": "Architectural plan to red-team"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Audit result",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuditResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid body or tier_mismatch"
          },
          "402": {
            "description": "Payment Required (x402)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaymentRequiredError"
                }
              }
            }
          }
        },
        "x-payment-info": {
          "protocols": [
            "x402"
          ],
          "price": {
            "mode": "fixed",
            "currency": "USD",
            "amount": "9.99"
          }
        }
      }
    },
    "/audit-x402/deep-mid": {
      "servers": [
        {
          "url": "https://bbuaschzvigwmoxekmoo.supabase.co/functions/v1"
        }
      ],
      "post": {
        "operationId": "auditX402_deep_mid",
        "summary": "Deep Mid Audit (manual) — fixed $14.99 USDC via x402",
        "description": "Fixed-price route. Returns 400 tier_mismatch (no charge) if the body classifies to a different tier. Pay with standard x402 (PAYMENT-SIGNATURE / X-PAYMENT, Base USDC) or the legacy x402-signature headers.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "objective",
                  "plan"
                ],
                "properties": {
                  "mode": {
                    "type": "string",
                    "enum": [
                      "manual"
                    ],
                    "default": "manual"
                  },
                  "objective": {
                    "type": "string",
                    "maxLength": 240,
                    "description": "Business objective the plan is meant to achieve"
                  },
                  "stack": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "maxLength": 32
                    },
                    "maxItems": 8,
                    "description": "Stack tags (e.g. nextjs, postgres, redis)"
                  },
                  "plan": {
                    "type": "string",
                    "maxLength": 4000,
                    "description": "Architectural plan to red-team"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Audit result",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuditResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid body or tier_mismatch"
          },
          "402": {
            "description": "Payment Required (x402)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaymentRequiredError"
                }
              }
            }
          }
        },
        "x-payment-info": {
          "protocols": [
            "x402"
          ],
          "price": {
            "mode": "fixed",
            "currency": "USD",
            "amount": "14.99"
          }
        }
      }
    },
    "/audit-x402/deep-pro": {
      "servers": [
        {
          "url": "https://bbuaschzvigwmoxekmoo.supabase.co/functions/v1"
        }
      ],
      "post": {
        "operationId": "auditX402_deep_pro",
        "summary": "Deep Pro Audit (manual) — fixed $19.99 USDC via x402",
        "description": "Fixed-price route. Returns 400 tier_mismatch (no charge) if the body classifies to a different tier. Pay with standard x402 (PAYMENT-SIGNATURE / X-PAYMENT, Base USDC) or the legacy x402-signature headers.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "objective",
                  "plan"
                ],
                "properties": {
                  "mode": {
                    "type": "string",
                    "enum": [
                      "manual"
                    ],
                    "default": "manual"
                  },
                  "objective": {
                    "type": "string",
                    "maxLength": 240,
                    "description": "Business objective the plan is meant to achieve"
                  },
                  "stack": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "maxLength": 32
                    },
                    "maxItems": 8,
                    "description": "Stack tags (e.g. nextjs, postgres, redis)"
                  },
                  "plan": {
                    "type": "string",
                    "maxLength": 4000,
                    "description": "Architectural plan to red-team"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Audit result",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuditResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid body or tier_mismatch"
          },
          "402": {
            "description": "Payment Required (x402)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaymentRequiredError"
                }
              }
            }
          }
        },
        "x-payment-info": {
          "protocols": [
            "x402"
          ],
          "price": {
            "mode": "fixed",
            "currency": "USD",
            "amount": "19.99"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "AuditRequest": {
        "oneOf": [
          {
            "type": "object",
            "required": [
              "objective",
              "plan"
            ],
            "properties": {
              "mode": {
                "type": "string",
                "enum": [
                  "manual"
                ],
                "default": "manual"
              },
              "objective": {
                "type": "string",
                "maxLength": 240,
                "description": "Business objective the plan is meant to achieve"
              },
              "stack": {
                "type": "array",
                "items": {
                  "type": "string",
                  "maxLength": 32
                },
                "maxItems": 8,
                "description": "Stack tags (e.g. nextjs, postgres, redis)"
              },
              "plan": {
                "type": "string",
                "maxLength": 4000,
                "description": "Architectural plan to red-team"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "mode",
              "url"
            ],
            "properties": {
              "mode": {
                "type": "string",
                "enum": [
                  "url"
                ]
              },
              "url": {
                "type": "string",
                "format": "uri",
                "maxLength": 2048,
                "description": "Target URL. Firecrawl-scanned; plan auto-generated."
              }
            }
          }
        ]
      },
      "AuditResponse": {
        "type": "object",
        "properties": {
          "audit_id": {
            "type": "string",
            "format": "uuid"
          },
          "status": {
            "type": "string",
            "enum": [
              "complete",
              "failed"
            ]
          },
          "chaos_brief": {
            "type": "string",
            "description": "Red-team narrative covering failure modes, coupling, latency cliffs, data-loss windows, and operational gaps."
          },
          "stability_score": {
            "type": "number",
            "minimum": 0,
            "maximum": 1
          },
          "top_risks": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "guardrails": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "tier": {
            "type": "string",
            "enum": [
              "quick_scan",
              "standard",
              "deep_base",
              "deep_mid",
              "deep_pro"
            ],
            "description": "Equivalent paid-tier classification of the submitted request."
          },
          "price_usd": {
            "type": "number",
            "description": "Equivalent paid price. Quick Scan $2.99, Standard $4.99, Deep Base $9.99, Deep Mid $14.99, Deep Pro $19.99. Informational only on /landing-audit."
          },
          "price_display": {
            "type": "string"
          },
          "is_demo": {
            "type": "boolean",
            "description": "true on /landing-audit — no charge taken."
          },
          "mode": {
            "type": "string",
            "enum": [
              "manual",
              "url"
            ]
          },
          "scan_confidence": {
            "type": "number",
            "minimum": 0,
            "maximum": 1,
            "description": "URL mode only. 0-1 score of how much of the architecture was detectable vs inferred."
          },
          "scan": {
            "type": "object",
            "description": "URL mode only.",
            "properties": {
              "url": {
                "type": "string",
                "format": "uri"
              },
              "pages_scanned": {
                "type": "integer"
              },
              "detected": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "name": {
                      "type": "string"
                    },
                    "evidence": {
                      "type": "string"
                    }
                  }
                }
              },
              "inferred": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "scan_confidence": {
                "type": "number"
              }
            }
          },
          "provenance": {
            "$ref": "#/components/schemas/ProvenanceTag"
          }
        }
      },
      "ProvenanceTag": {
        "type": "object",
        "required": [
          "audit_id",
          "signed_at",
          "alg",
          "hash"
        ],
        "properties": {
          "audit_id": {
            "type": "string",
            "format": "uuid"
          },
          "stability_score": {
            "type": "number",
            "nullable": true
          },
          "signed_at": {
            "type": "string",
            "format": "date-time"
          },
          "alg": {
            "type": "string",
            "example": "HS256"
          },
          "hash": {
            "type": "string",
            "description": "HMAC-SHA256 hex digest over { audit_id, stability_score, signed_at }"
          }
        }
      },
      "QueryRequest": {
        "type": "object",
        "required": [
          "query"
        ],
        "properties": {
          "query": {
            "type": "string",
            "description": "Natural language search query",
            "example": "How to fix N+1 query problems?"
          },
          "max_lessons": {
            "type": "integer",
            "default": 10,
            "description": "Maximum number of lessons to return"
          },
          "channels": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter results by source channels"
          },
          "messages": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Raw messages for real-time AI extraction before searching"
          }
        }
      },
      "QueryResponse": {
        "type": "object",
        "properties": {
          "lessons": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Lesson"
            }
          },
          "count": {
            "type": "integer"
          },
          "query": {
            "type": "string"
          },
          "paid": {
            "type": "boolean"
          },
          "value_score": {
            "type": "integer",
            "minimum": 0,
            "maximum": 100,
            "description": "Paid-answer utility score based on relevance, confidence, and supporting lesson count."
          },
          "answer_brief": {
            "type": "string",
            "description": "Concise premium synthesis of the best matching lessons."
          },
          "recommended_action": {
            "type": "string",
            "description": "Concrete next action the agent should take."
          },
          "best_lesson": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "problem": {
                "type": "string"
              },
              "root_cause": {
                "type": "string"
              },
              "lesson_learned": {
                "type": "string"
              },
              "confidence": {
                "type": "number"
              },
              "quality_score": {
                "type": "number"
              },
              "why_matched": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            }
          },
          "implementation_pattern": {
            "type": "string"
          },
          "failure_modes": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "confidence_notes": {
            "type": "string"
          },
          "source_evidence": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "source_platform": {
                  "type": "string"
                },
                "source_ts": {
                  "type": "string"
                },
                "channel": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "evidence": {
                  "type": "string"
                }
              }
            }
          },
          "insufficient_knowledge": {
            "type": "boolean"
          }
        }
      },
      "Lesson": {
        "type": "object",
        "properties": {
          "problem": {
            "type": "string"
          },
          "root_cause": {
            "type": "string"
          },
          "lesson_learned": {
            "type": "string"
          },
          "confidence": {
            "type": "number",
            "minimum": 0,
            "maximum": 1
          },
          "source_ts": {
            "type": "string",
            "format": "date-time"
          },
          "category": {
            "type": "string",
            "enum": [
              "debugging",
              "performance",
              "architecture",
              "reliability",
              "security",
              "ux",
              "observability",
              "database",
              "frontend",
              "infrastructure",
              "trading",
              "onchain",
              "token-launch",
              "rug-pull",
              "product-postmortem",
              "startup-failure",
              "multi-agent-coordination"
            ]
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "source_platform": {
            "type": "string"
          },
          "raw_evidence": {
            "type": "string"
          },
          "channel": {
            "type": "string",
            "nullable": true
          },
          "why_matched": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Short explanation of why this lesson matched the paid query."
          }
        }
      },
      "PaymentRequiredError": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string"
          },
          "detail": {
            "type": "string"
          },
          "required_amount_usdc": {
            "type": "number"
          },
          "supported_chains": {
            "type": "object",
            "properties": {
              "solana": {
                "type": "object",
                "properties": {
                  "recipient_wallet": {
                    "type": "string"
                  },
                  "usdc_mint": {
                    "type": "string"
                  }
                }
              },
              "base": {
                "type": "object",
                "properties": {
                  "recipient_wallet": {
                    "type": "string"
                  },
                  "usdc_contract": {
                    "type": "string"
                  }
                }
              }
            }
          },
          "currency": {
            "type": "string"
          },
          "instructions": {
            "type": "string"
          }
        }
      }
    },
    "securitySchemes": {
      "x402": {
        "type": "apiKey",
        "in": "header",
        "name": "x402-signature",
        "description": "x402 payment protocol. Send >= 0.10 USDC on Solana or Base. For Solana: send to wallet 8HpqfMcPp87kuwxc2zZHyWYt95PBVo1s1y3eEEH5r2AL. For Base: send to 0xaa63d495e25e490f169235a4bffcb02d9728e466. Include x402-chain header to specify chain. Alternatively, use the Bankr x402 Cloud endpoint for managed payments (recommended)."
      }
    }
  }
}
