import type { Registry, RouteRegistryEntry } from "./schema";

/**
 * Seed of the versioned route registry. V2 entries encode the surface we must
 * preserve verbatim. V3 entries live under /api/v3/*. This is not the full
 * 132-route dump — the full dump is generated in generate-registry.ts from
 * baseline/extracted/v2_api_routes.txt and lib/abis/*.
 */

const v2Reads: RouteRegistryEntry[] = [
  {
    id: "v2-contracts",
    method: "GET",
    path: "/api/contracts",
    free: true,
    version: "v2",
    contractStatus: "active",
    requestSchema: "empty#",
    responseSchema: "v2/contracts#",
    idempotencyRule: "none",
    finality: "finalized",
    dataSource: "onchain",
    privacy: "public",
    description: "Live contract inventory across all supported chains.",
  },
  {
    id: "v2-well-known-x402",
    method: "GET",
    path: "/.well-known/x402.json",
    free: true,
    version: "v2",
    contractStatus: "active",
    requestSchema: "empty#",
    responseSchema: "x402-manifest#",
    idempotencyRule: "none",
    finality: "finalized",
    dataSource: "computed",
    privacy: "public",
    description: "x402 manifest generated from this registry.",
  },
];

const v2PricedTrust: RouteRegistryEntry[] = [
  {
    id: "v2-trust-bonds",
    method: "GET",
    path: "/api/x402/trust/bonds",
    free: false,
    price: { amount: "10000", asset: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", network: "eip155:8453", payee: "0xfA15Ee28939B222B0448261A22156070f0A7813C", scheme: "exact", x402Version: 2 },
    version: "v2",
    contractStatus: "active",
    requestSchema: "v2/trust-bonds.req#",
    responseSchema: "v2/trust-bonds.res#",
    idempotencyRule: "key-optional",
    finality: "safe",
    dataSource: "indexer",
    privacy: "priced-read",
    description: "Return open bonds for a given agent identity.",
  },
];

const v3Reads: RouteRegistryEntry[] = [
  {
    id: "contracts", method: "GET", path: "/api/v3/contracts", free: true,
    version: "v3", contractStatus: "read-only", requestSchema: "empty#", responseSchema: "https://theloopbreaker.com/schemas/v3-x402/contract-catalog.v1.schema.json",
    responseStatus: "200", responseContracts: "200=https://theloopbreaker.com/schemas/v3-x402/contract-catalog.v1.schema.json;503=https://theloopbreaker.com/schemas/v3-x402/release-gate.v1.schema.json",
    idempotencyRule: "none", finality: "soft", dataSource: "computed", privacy: "public",
    description: "Static V3 contract catalog with null addresses until independently verified.",
  },
  {
    id: "contract", method: "GET", path: "/api/v3/contracts/:name", free: true,
    version: "v3", contractStatus: "read-only", requestSchema: "empty#", responseSchema: "https://theloopbreaker.com/schemas/v3-x402/contract-result.v1.schema.json",
    responseStatus: "200", responseContracts: "200=https://theloopbreaker.com/schemas/v3-x402/contract-result.v1.schema.json;400=https://theloopbreaker.com/schemas/v3-x402/input-error.v1.schema.json;404=https://theloopbreaker.com/schemas/v3-x402/contract-result.v1.schema.json;503=https://theloopbreaker.com/schemas/v3-x402/release-gate.v1.schema.json",
    idempotencyRule: "none", finality: "soft", dataSource: "computed", privacy: "public",
    description: "Static V3 contract metadata by canonical name.",
  },
  {
    id: "bond-party", method: "GET", path: "/api/v3/bonds", free: true,
    version: "v3", contractStatus: "read-only", requestSchema: "empty#", responseSchema: "https://theloopbreaker.com/schemas/v3-x402/read-result.v1.schema.json",
    responseStatus: "503", responseContracts: "400=https://theloopbreaker.com/schemas/v3-x402/input-error.v1.schema.json;503=https://theloopbreaker.com/schemas/v3-x402/read-result.v1.schema.json|https://theloopbreaker.com/schemas/v3-x402/release-gate.v1.schema.json",
    idempotencyRule: "none", finality: "soft", dataSource: "computed", privacy: "public",
    description: "Fail-closed bond lookup by the required party query parameter.",
  },
  {
    id: "bond", method: "GET", path: "/api/v3/bonds/:bondId", free: true,
    version: "v3", contractStatus: "read-only", requestSchema: "empty#", responseSchema: "https://theloopbreaker.com/schemas/v3-x402/read-result.v1.schema.json",
    responseStatus: "503", responseContracts: "400=https://theloopbreaker.com/schemas/v3-x402/input-error.v1.schema.json;503=https://theloopbreaker.com/schemas/v3-x402/read-result.v1.schema.json|https://theloopbreaker.com/schemas/v3-x402/release-gate.v1.schema.json",
    idempotencyRule: "none", finality: "soft", dataSource: "computed", privacy: "public",
    description: "Fail-closed V3 bond lookup by unsigned identifier.",
  },
  {
    id: "dispute", method: "GET", path: "/api/v3/disputes/:disputeId", free: true,
    version: "v3", contractStatus: "read-only", requestSchema: "empty#", responseSchema: "https://theloopbreaker.com/schemas/v3-x402/read-result.v1.schema.json",
    responseStatus: "503", responseContracts: "400=https://theloopbreaker.com/schemas/v3-x402/input-error.v1.schema.json;503=https://theloopbreaker.com/schemas/v3-x402/read-result.v1.schema.json|https://theloopbreaker.com/schemas/v3-x402/release-gate.v1.schema.json",
    idempotencyRule: "none", finality: "soft", dataSource: "computed", privacy: "public",
    description: "Fail-closed objective dispute lookup.",
  },
  {
    id: "evidence", method: "GET", path: "/api/v3/evidence/:evidenceHash", free: true,
    version: "v3", contractStatus: "read-only", requestSchema: "empty#", responseSchema: "https://theloopbreaker.com/schemas/v3-x402/read-result.v1.schema.json",
    responseStatus: "503", responseContracts: "400=https://theloopbreaker.com/schemas/v3-x402/input-error.v1.schema.json;503=https://theloopbreaker.com/schemas/v3-x402/read-result.v1.schema.json|https://theloopbreaker.com/schemas/v3-x402/release-gate.v1.schema.json",
    idempotencyRule: "none", finality: "soft", dataSource: "computed", privacy: "public",
    description: "Deferred evidence lookup with no deployment claim.",
  },
  {
    id: "task", method: "GET", path: "/api/v3/tasks/:taskId", free: true,
    version: "v3", contractStatus: "read-only", requestSchema: "empty#", responseSchema: "https://theloopbreaker.com/schemas/v3-x402/read-result.v1.schema.json",
    responseStatus: "503", responseContracts: "400=https://theloopbreaker.com/schemas/v3-x402/input-error.v1.schema.json;503=https://theloopbreaker.com/schemas/v3-x402/read-result.v1.schema.json|https://theloopbreaker.com/schemas/v3-x402/release-gate.v1.schema.json",
    idempotencyRule: "none", finality: "soft", dataSource: "computed", privacy: "public",
    description: "Deferred task escrow read model.",
  },
  {
    id: "mandate", method: "GET", path: "/api/v3/mandates/:mandateHash", free: true,
    version: "v3", contractStatus: "read-only", requestSchema: "empty#", responseSchema: "https://theloopbreaker.com/schemas/v3-x402/read-result.v1.schema.json",
    responseStatus: "503", responseContracts: "400=https://theloopbreaker.com/schemas/v3-x402/input-error.v1.schema.json;503=https://theloopbreaker.com/schemas/v3-x402/read-result.v1.schema.json|https://theloopbreaker.com/schemas/v3-x402/release-gate.v1.schema.json",
    idempotencyRule: "none", finality: "soft", dataSource: "computed", privacy: "public",
    description: "Canonical plural V3 mandate lookup.",
  },
  {
    id: "mandate-compat", method: "GET", path: "/api/v3/mandate/:mandateHash", free: true,
    version: "v3", contractStatus: "read-only", requestSchema: "empty#", responseSchema: "https://theloopbreaker.com/schemas/v3-x402/read-result.v1.schema.json",
    responseStatus: "503", responseContracts: "400=https://theloopbreaker.com/schemas/v3-x402/input-error.v1.schema.json;503=https://theloopbreaker.com/schemas/v3-x402/read-result.v1.schema.json|https://theloopbreaker.com/schemas/v3-x402/release-gate.v1.schema.json",
    idempotencyRule: "none", finality: "soft", dataSource: "computed", privacy: "public",
    description: "Singular V3 compatibility wrapper over the plural route; no V2 fallback.",
  },
  {
    id: "governance-proposal", method: "GET", path: "/api/v3/governance/proposals/:proposalId", free: true,
    version: "v3", contractStatus: "read-only", requestSchema: "empty#", responseSchema: "https://theloopbreaker.com/schemas/v3-x402/read-result.v1.schema.json",
    responseStatus: "503", responseContracts: "400=https://theloopbreaker.com/schemas/v3-x402/input-error.v1.schema.json;503=https://theloopbreaker.com/schemas/v3-x402/read-result.v1.schema.json|https://theloopbreaker.com/schemas/v3-x402/release-gate.v1.schema.json",
    idempotencyRule: "none", finality: "soft", dataSource: "computed", privacy: "public",
    description: "Fail-closed governance proposal status lookup.",
  },
  {
    id: "pull-credit", method: "GET", path: "/api/v3/pull-credits", free: true,
    version: "v3", contractStatus: "read-only", requestSchema: "empty#", responseSchema: "https://theloopbreaker.com/schemas/v3-x402/read-result.v1.schema.json",
    responseStatus: "503", responseContracts: "400=https://theloopbreaker.com/schemas/v3-x402/input-error.v1.schema.json;503=https://theloopbreaker.com/schemas/v3-x402/read-result.v1.schema.json|https://theloopbreaker.com/schemas/v3-x402/release-gate.v1.schema.json",
    idempotencyRule: "none", finality: "soft", dataSource: "computed", privacy: "public",
    description: "Fail-closed pull credit query by contract, asset, and holder.",
  },
  {
    id: "migration", method: "GET", path: "/api/v3/migration/dispositions", free: true,
    version: "v3", contractStatus: "read-only", requestSchema: "empty#", responseSchema: "https://theloopbreaker.com/schemas/v3-x402/migration-dispositions.v1.schema.json",
    responseStatus: "200", responseContracts: "200=https://theloopbreaker.com/schemas/v3-x402/migration-dispositions.v1.schema.json;503=https://theloopbreaker.com/schemas/v3-x402/release-gate.v1.schema.json",
    idempotencyRule: "none", finality: "soft", dataSource: "computed", privacy: "public",
    description: "Static migration capability and safety dispositions.",
  },
  {
    id: "status", method: "GET", path: "/api/v3/protocol/status", free: true,
    version: "v3", contractStatus: "read-only", requestSchema: "empty#", responseSchema: "https://theloopbreaker.com/schemas/v3-x402/status.v1.schema.json",
    responseStatus: "503", responseContracts: "503=https://theloopbreaker.com/schemas/v3-x402/status.v1.schema.json|https://theloopbreaker.com/schemas/v3-x402/release-gate.v1.schema.json",
    idempotencyRule: "none", finality: "soft", dataSource: "computed", privacy: "public",
    description: "Unconfigured protocol readiness response.",
  },
  {
    id: "solvency", method: "GET", path: "/api/v3/protocol/solvency", free: true,
    version: "v3", contractStatus: "read-only", requestSchema: "empty#", responseSchema: "https://theloopbreaker.com/schemas/v3-x402/solvency.v1.schema.json",
    responseStatus: "503", responseContracts: "503=https://theloopbreaker.com/schemas/v3-x402/solvency.v1.schema.json|https://theloopbreaker.com/schemas/v3-x402/release-gate.v1.schema.json",
    idempotencyRule: "none", finality: "soft", dataSource: "computed", privacy: "public",
    description: "Unconfigured solvency readiness response.",
  },
  {
    id: "x402-discovery", method: "GET", path: "/api/v3/x402/discovery", free: true,
    version: "v3", contractStatus: "read-only", requestSchema: "empty#", responseSchema: "https://theloopbreaker.com/schemas/v3-x402/discovery.v1.schema.json",
    responseStatus: "200", responseContracts: "200=https://theloopbreaker.com/schemas/v3-x402/discovery.v1.schema.json;503=https://theloopbreaker.com/schemas/v3-x402/release-gate.v1.schema.json",
    idempotencyRule: "none", finality: "soft", dataSource: "computed", privacy: "public",
    description: "Fail-closed V3 x402 discovery with no payment candidates.",
  },
  {
    id: "x402-challenge-status", method: "GET", path: "/api/v3/x402/challenge-status", free: true,
    version: "v3", contractStatus: "read-only", requestSchema: "empty#", responseSchema: "https://theloopbreaker.com/schemas/v3-x402/challenge-status.v1.schema.json",
    responseStatus: "200", responseContracts: "200=https://theloopbreaker.com/schemas/v3-x402/challenge-status.v1.schema.json;503=https://theloopbreaker.com/schemas/v3-x402/release-gate.v1.schema.json",
    idempotencyRule: "none", finality: "soft", dataSource: "computed", privacy: "public",
    description: "Static unavailable V3 payment-challenge capability status.",
  },
  {
    id: "x402-challenge", method: "GET", path: "/api/v3/x402/challenges/:challengeId", free: true,
    version: "v3", contractStatus: "read-only", requestSchema: "empty#", responseSchema: "https://theloopbreaker.com/schemas/v3-x402/read-result.v1.schema.json",
    responseStatus: "503", responseContracts: "400=https://theloopbreaker.com/schemas/v3-x402/input-error.v1.schema.json;503=https://theloopbreaker.com/schemas/v3-x402/read-result.v1.schema.json|https://theloopbreaker.com/schemas/v3-x402/release-gate.v1.schema.json",
    idempotencyRule: "none", finality: "soft", dataSource: "computed", privacy: "public",
    description: "Fail-closed V3 challenge lookup.",
  },
  {
    id: "x402-receipt", method: "GET", path: "/api/v3/x402/receipts/:requestId", free: true,
    version: "v3", contractStatus: "read-only", requestSchema: "empty#", responseSchema: "https://theloopbreaker.com/schemas/v3-x402/receipt-status.v1.schema.json",
    responseStatus: "200", responseContracts: "200=https://theloopbreaker.com/schemas/v3-x402/receipt-status.v1.schema.json;400=https://theloopbreaker.com/schemas/v3-x402/input-error.v1.schema.json;404=https://theloopbreaker.com/schemas/v3-x402/receipt-error.v1.schema.json;503=https://theloopbreaker.com/schemas/v3-x402/receipt-error.v1.schema.json|https://theloopbreaker.com/schemas/v3-x402/release-gate.v1.schema.json",
    idempotencyRule: "none", finality: "soft", dataSource: "computed", privacy: "public",
    description: "Fail-closed durable receipt evidence lookup.",
  },
  {
    id: "solana-health", method: "GET", path: "/api/v3/solana/health", free: true,
    version: "v3", contractStatus: "read-only", requestSchema: "empty#", responseSchema: "https://theloopbreaker.com/schemas/v3-x402/solana-health.v1.schema.json",
    responseStatus: "200", responseContracts: "200=https://theloopbreaker.com/schemas/v3-x402/solana-health.v1.schema.json;503=https://theloopbreaker.com/schemas/v3-x402/release-gate.v1.schema.json",
    idempotencyRule: "none", finality: "soft", dataSource: "computed", privacy: "public",
    description: "Source-only Solana health without RPC or executable claims.",
  },
  {
    id: "retired-partnership-write", method: "POST", path: "/api/v3/x402/actions/create-partnership-bond", free: true,
    version: "v3", contractStatus: "read-only", requestSchema: "empty#", responseSchema: "https://theloopbreaker.com/schemas/v3-x402/retirement.v1.schema.json",
    responseStatus: "503", responseContracts: "503=https://theloopbreaker.com/schemas/v3-x402/retirement.v1.schema.json|https://theloopbreaker.com/schemas/v3-x402/release-gate.v1.schema.json",
    idempotencyRule: "none", finality: "soft", dataSource: "computed", privacy: "restricted",
    description: "Non-executing retired partnership-bond write tombstone.",
  },
];

const v3Writes: RouteRegistryEntry[] = [];

export const registry: Registry = {
  version: "3.0.0",
  generatedAt: new Date().toISOString(),
  routes: [...v2Reads, ...v2PricedTrust, ...v3Reads, ...v3Writes],
};
