{
  "id": "sql-select-compile",
  "name": "Bound Single-table SELECT Compiler",
  "description": "Compile one strict single-table SELECT AST for SQLite3 or PostgreSQL18 into quoted SQL, ordered bindings and source paths, with bounded predicates and explicit pagination; never execute SQL.",
  "category": "structured",
  "priceUsd": "0.005",
  "pricingStatus": "proposed-unverified",
  "pricing": {
    "unit": "one successful operation call",
    "proposedNominalUsd": "0.005",
    "sixDecimalTokenBaseUnits": "5000",
    "subscription": false,
    "includesPayerWalletOrNetworkFees": false,
    "liveQuoteVerified": false,
    "condition": "Actual SDK challenge is authoritative only within the caller's explicit authorization; configured six-decimal token peg is an operator assertion, not a conversion guarantee."
  },
  "intents": [
    "Compile a bounded SELECT query and parameter bindings from a structured plan",
    "Build a single-table SQLite3 or PostgreSQL18 query handoff without interpolating literal values"
  ],
  "whenToUse": [
    "Compile a bounded SELECT query and parameter bindings from a structured plan",
    "Build a single-table SQLite3 or PostgreSQL18 query handoff without interpolating literal values"
  ],
  "whenNotToUse": [
    "Running SQL, database access, schema/type/permission checks or certifying safe execution",
    "Raw SQL, writes, joins, wildcard, aliases, expressions, functions, subqueries, arbitrary SQL dialects, floats or inferred types",
    "Uploading artifacts, executing database statements, sending invitations, accessing calendars or changing remote state"
  ],
  "capabilities": [
    "Declared profile: single-table-bound-select-v1",
    "Always double-quoted conservative identifiers; strings and safe integers bound separately from SQL",
    "Compare, IN, null checks, nested ALL/ANY/NOT; depth-first ordered binding paths including LIMIT/OFFSET",
    "Explicit SQLite3 ?N or PostgreSQL18 $N placeholders; no terminal semicolon or value interpolation",
    "Query syntax artifacts only; database collation, type affinity, cost and permissions are unverified",
    "Deterministic supplied-input-only artifact; no network, filesystem, database, shell, clock or randomness"
  ],
  "limits": {
    "inputBytes": 100000,
    "outputBytes": 400000,
    "jsonNodes": 12000,
    "depth": 20,
    "columns": 64,
    "orderBy": 8,
    "identifierBytes": 63,
    "predicateNodes": 128,
    "predicateDepth": 8,
    "membershipValues": 64,
    "parameters": 256,
    "bindingTextBytes": 60000,
    "sqlBytes": 16000,
    "limit": 10000,
    "offset": 1000000,
    "profile": "single-table-bound-select-v1"
  },
  "related": [
    "records-filter",
    "records-project",
    "json-schema-check"
  ],
  "errorCodes": [
    "INPUT_LIMIT",
    "OUTPUT_LIMIT",
    "COMPLEXITY_LIMIT",
    "INVALID_JSON",
    "INVALID_NUMBER",
    "INVALID_UNICODE",
    "UNSAFE_KEY",
    "INVALID_IDENTIFIER",
    "DUPLICATE_COLUMN",
    "INVALID_PARAMETER",
    "EMPTY_PREDICATE",
    "PARAMETER_LIMIT",
    "PARAMETER_TEXT_LIMIT",
    "PREDICATE_LIMIT",
    "SQL_OUTPUT_LIMIT"
  ],
  "requirementsProfile": {
    "format": "declared-requirements-v1",
    "facts": {
      "execution.suppliedCode": false,
      "execution.remoteMutation": false,
      "execution.llmInference": false,
      "execution.paidMcp": false,
      "verification.semanticTruth": false,
      "verification.sourceAuthenticity": false,
      "verification.liveVulnerabilities": false,
      "numbers.arbitraryPrecisionJson": false,
      "numbers.model": "ieee754-binary64",
      "privacy.requestBodyPersisted": false,
      "execution.deterministic": true,
      "execution.networkAccess": false,
      "privacy.resultBodyPersisted": false,
      "payment.x402": true,
      "payment.mpp": true,
      "operation.id": "sql-select-compile",
      "operation.category": "structured",
      "limit.httpRequestBytes": 131072,
      "limit.requestBytes": 100000,
      "limit.responseBytes": 524288,
      "limit.resultBytes": 400000,
      "limit.jsonDepth": 20,
      "limit.jsonNodes": 12000,
      "sqlSelect.profile": "single-table-bound-select-v1",
      "sqlSelect.dialects": "sqlite3,postgresql18",
      "sqlSelect.maxColumns": 64,
      "sqlSelect.maxSortEntries": 8,
      "sqlSelect.maxPredicateNodes": 128,
      "sqlSelect.maxPredicateDepth": 8,
      "sqlSelect.maxMembershipValues": 64,
      "sqlSelect.maxParameters": 256,
      "sqlSelect.maxBindingTextBytes": 60000,
      "sqlSelect.maxSqlBytes": 16000,
      "sqlSelect.bindingsIncludePagination": true,
      "sqlSelect.rawSqlInput": false,
      "sqlSelect.postgresql": true,
      "sqlSelect.databaseAccess": false,
      "sqlSelect.executesStatement": false,
      "sqlSelect.schemaCompatibilityVerified": false,
      "sqlSelect.executionSafetyCertified": false,
      "input.table.maxLength": 1000,
      "input.columns.maxItems": 64,
      "input.columns.minItems": 1,
      "input.orderBy.maxItems": 8,
      "input.limit.maximum": 10000,
      "input.limit.minimum": 1,
      "input.offset.maximum": 1000000,
      "input.offset.minimum": 0
    },
    "unknownPolicy": "Undeclared requirements are unknown, never compatible. Matching declared facts does not establish semantic fit or input validity.",
    "preflight": "/preflight"
  },
  "documentation": "/reference/tools/sql-select-compile.md",
  "serviceContract": "/reference/services/sql-select-compile.json",
  "errors": [
    {
      "status": 400,
      "meaning": "Malformed JSON, missing/invalid idempotency key, or payment identifier mismatch",
      "retry": "Correct the request before payment"
    },
    {
      "status": 402,
      "meaning": "Payment challenge or rejected payment",
      "retry": "Use official protocol SDK; inspect payment outcome before another payment"
    },
    {
      "status": 409,
      "meaning": "Idempotency conflict, duplicate proof, or PAYMENT_UNCERTAIN",
      "retry": "Keep original key, body, and proof; reconcile uncertainty with operator; never blindly repay"
    },
    {
      "status": 413,
      "meaning": "Input or generated output too large",
      "retry": "Reduce input; no payment attempted for validation failure"
    },
    {
      "status": 415,
      "meaning": "Unsupported media type or compression",
      "retry": "Send uncompressed application/json"
    },
    {
      "status": 422,
      "meaning": "Schema or service-specific semantic validation failure",
      "retry": "Correct input using returned error code; no payment attempted"
    },
    {
      "status": 429,
      "meaning": "Request/payment-attempt rate exceeded",
      "retry": "Wait for rate limit window; preserve existing payment identity"
    },
    {
      "status": 503,
      "meaning": "Payment configuration/provider/state unavailable, or live DNS preparation failed before settlement",
      "retry": "Check readiness; DNS preparation failures may retry the identical key/body/credential only; uncertainty requires reconciliation"
    }
  ],
  "numericPrecision": "JavaScript IEEE-754 numbers; use strings for large integer IDs/exact decimals where the schema accepts strings. No lossless numeric parsing.",
  "paymentWorkflow": {
    "discoveryOnly": false,
    "supportedProtocols": [
      "x402",
      "mpp"
    ],
    "x402": {
      "credentialHeader": "PAYMENT-SIGNATURE",
      "challengeHeader": "PAYMENT-REQUIRED",
      "receiptHeader": "PAYMENT-RESPONSE",
      "version": 2,
      "scheme": "exact",
      "paymentIdentifier": "payment-identifier extension MUST equal the HTTP Idempotency-Key",
      "sdk": "@x402/core with @x402/evm"
    },
    "mpp": {
      "supported": true,
      "credentialHeader": "Authorization",
      "challengeHeader": "WWW-Authenticate",
      "receiptHeader": "Payment-Receipt",
      "method": "tempo",
      "intent": "charge",
      "sdk": "mppx",
      "tokenDecimals": 6
    },
    "steps": [
      "Check configured readiness and the exact service schema",
      "Generate a fresh random Idempotency-Key for this operation; never use a discovery probe fixture for purchases",
      "Send valid input without a credential to obtain the official protocol challenge",
      "Use the official SDK and authorized wallet to fulfill the challenge",
      "Retry only with identical key, body, protocol and credential",
      "On PAYMENT_UNCERTAIN stop and request operator reconciliation; never blindly pay again"
    ],
    "versionedRetries": "Request fingerprint includes service release version. Retries across a version upgrade can conflict; coordinate upgrades outside the 24-hour replay window and reconcile pending attempts.",
    "docs": "/llms.txt"
  },
  "method": "POST",
  "paths": {
    "x402": "/v1/x402/sql-select-compile",
    "mpp": "/v1/mpp/sql-select-compile"
  },
  "inputSchema": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "description": "Declared profile: single-table-bound-select-v1",
    "type": "object",
    "properties": {
      "dialect": {
        "type": "string",
        "enum": [
          "sqlite3",
          "postgresql18"
        ]
      },
      "table": {
        "type": "string",
        "maxLength": 1000,
        "description": "1–63 ASCII letters/digits/underscores, starting with a letter or underscore; always double-quoted"
      },
      "columns": {
        "minItems": 1,
        "maxItems": 64,
        "type": "array",
        "items": {
          "type": "string",
          "maxLength": 1000,
          "description": "1–63 ASCII letters/digits/underscores, starting with a letter or underscore; always double-quoted"
        }
      },
      "where": {
        "$ref": "#/$defs/__schema0"
      },
      "orderBy": {
        "default": [],
        "maxItems": 8,
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "column": {
              "type": "string",
              "maxLength": 1000,
              "description": "1–63 ASCII letters/digits/underscores, starting with a letter or underscore; always double-quoted"
            },
            "direction": {
              "type": "string",
              "enum": [
                "asc",
                "desc"
              ]
            }
          },
          "required": [
            "column",
            "direction"
          ],
          "additionalProperties": false
        }
      },
      "limit": {
        "type": "integer",
        "minimum": 1,
        "maximum": 10000
      },
      "offset": {
        "type": "integer",
        "minimum": 0,
        "maximum": 1000000
      }
    },
    "required": [
      "dialect",
      "table",
      "columns",
      "limit",
      "offset"
    ],
    "additionalProperties": false,
    "$defs": {
      "__schema0": {
        "oneOf": [
          {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string",
                "const": "compare"
              },
              "column": {
                "type": "string",
                "maxLength": 1000,
                "description": "1–63 ASCII letters/digits/underscores, starting with a letter or underscore; always double-quoted"
              },
              "op": {
                "type": "string",
                "enum": [
                  "eq",
                  "ne",
                  "lt",
                  "lte",
                  "gt",
                  "gte"
                ]
              },
              "value": {
                "anyOf": [
                  {
                    "type": "string",
                    "maxLength": 60000
                  },
                  {
                    "type": "number"
                  }
                ],
                "description": "Literal NUL-free Unicode text or a safe integer; never raw SQL"
              }
            },
            "required": [
              "kind",
              "column",
              "op",
              "value"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string",
                "const": "in"
              },
              "column": {
                "type": "string",
                "maxLength": 1000,
                "description": "1–63 ASCII letters/digits/underscores, starting with a letter or underscore; always double-quoted"
              },
              "values": {
                "maxItems": 64,
                "type": "array",
                "items": {
                  "anyOf": [
                    {
                      "type": "string",
                      "maxLength": 60000
                    },
                    {
                      "type": "number"
                    }
                  ],
                  "description": "Literal NUL-free Unicode text or a safe integer; never raw SQL"
                }
              }
            },
            "required": [
              "kind",
              "column",
              "values"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string",
                "const": "is-null"
              },
              "column": {
                "type": "string",
                "maxLength": 1000,
                "description": "1–63 ASCII letters/digits/underscores, starting with a letter or underscore; always double-quoted"
              }
            },
            "required": [
              "kind",
              "column"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string",
                "const": "is-not-null"
              },
              "column": {
                "type": "string",
                "maxLength": 1000,
                "description": "1–63 ASCII letters/digits/underscores, starting with a letter or underscore; always double-quoted"
              }
            },
            "required": [
              "kind",
              "column"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string",
                "const": "all"
              },
              "items": {
                "maxItems": 128,
                "type": "array",
                "items": {
                  "$ref": "#/$defs/__schema0"
                }
              }
            },
            "required": [
              "kind",
              "items"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string",
                "const": "any"
              },
              "items": {
                "maxItems": 128,
                "type": "array",
                "items": {
                  "$ref": "#/$defs/__schema0"
                }
              }
            },
            "required": [
              "kind",
              "items"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string",
                "const": "not"
              },
              "item": {
                "$ref": "#/$defs/__schema0"
              }
            },
            "required": [
              "kind",
              "item"
            ],
            "additionalProperties": false
          }
        ]
      }
    }
  },
  "outputSchema": {
    "type": "object",
    "required": [
      "operation",
      "version",
      "result",
      "provenance"
    ],
    "properties": {
      "operation": {
        "const": "sql-select-compile",
        "type": "string"
      },
      "version": {
        "const": "0.29.0",
        "type": "string"
      },
      "result": {
        "$schema": "https://json-schema.org/draft/2020-12/schema",
        "type": "object",
        "properties": {
          "dialect": {
            "type": "string",
            "enum": [
              "sqlite3",
              "postgresql18"
            ]
          },
          "sql": {
            "type": "string"
          },
          "bindings": {
            "maxItems": 256,
            "type": "array",
            "items": {
              "anyOf": [
                {
                  "type": "string",
                  "maxLength": 60000
                },
                {
                  "type": "number"
                }
              ],
              "description": "Literal NUL-free Unicode text or a safe integer; never raw SQL"
            }
          },
          "bindingPaths": {
            "maxItems": 256,
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "statementCount": {
            "type": "number",
            "const": 1
          },
          "executed": {
            "type": "boolean",
            "const": false
          }
        },
        "required": [
          "dialect",
          "sql",
          "bindings",
          "bindingPaths",
          "statementCount",
          "executed"
        ],
        "additionalProperties": false,
        "description": "Artifact result for declared profile: single-table-bound-select-v1"
      },
      "provenance": {
        "type": "object",
        "required": [
          "inputSha256",
          "outputSha256",
          "deterministic",
          "externalRequests"
        ],
        "properties": {
          "inputSha256": {
            "type": "string",
            "pattern": "^[a-f0-9]{64}$"
          },
          "outputSha256": {
            "type": "string",
            "pattern": "^[a-f0-9]{64}$"
          },
          "deterministic": {
            "const": true
          },
          "externalRequests": {
            "const": 0
          }
        }
      }
    },
    "additionalProperties": false
  },
  "exampleInput": {
    "dialect": "postgresql18",
    "table": "tasks",
    "columns": [
      "id",
      "title"
    ],
    "where": {
      "kind": "all",
      "items": [
        {
          "kind": "compare",
          "column": "state",
          "op": "eq",
          "value": "ready"
        },
        {
          "kind": "compare",
          "column": "priority",
          "op": "gte",
          "value": 2
        }
      ]
    },
    "orderBy": [
      {
        "column": "id",
        "direction": "asc"
      }
    ],
    "limit": 10,
    "offset": 0
  },
  "exampleResponse": {
    "operation": "sql-select-compile",
    "version": "0.29.0",
    "result": {
      "dialect": "postgresql18",
      "sql": "SELECT \"id\", \"title\" FROM \"tasks\" WHERE (\"state\" = $1 AND \"priority\" >= $2) ORDER BY \"id\" ASC LIMIT $3 OFFSET $4",
      "bindings": [
        "ready",
        2,
        10,
        0
      ],
      "bindingPaths": [
        "/where/items/0/value",
        "/where/items/1/value",
        "/limit",
        "/offset"
      ],
      "statementCount": 1,
      "executed": false
    },
    "provenance": {
      "inputSha256": "c469154a069d55fbfdc51d35d602d488d2eadf160e0a41e655056281f02640f5",
      "outputSha256": "c5ace9156b9a3141378ca64b52da45563bb02e3938768b326825650abbe269e1",
      "deterministic": true,
      "externalRequests": 0
    }
  },
  "requiredHeaders": {
    "Content-Type": "application/json",
    "Idempotency-Key": "random 16–128 character operation identifier"
  },
  "fixedExample": "/reference/examples/sql-select-compile.json",
  "execution": {
    "deterministic": true,
    "externalRequests": 0,
    "maxExternalRequests": 0,
    "resultSnapshotPersisted": false,
    "fixedExampleIsIllustrativeSnapshot": false,
    "requiresPayment": true,
    "supportsMcpExecution": false
  },
  "releaseSnapshot": {
    "format": "static-release-reference-v1",
    "sourceVersion": "0.29.0",
    "sourceRegistrySha256": "a2b5ec09bf6c38b9d2879d746a4fded374f5928b445377b0270ef6aa8e6cac65",
    "generatedAt": "2026-10-06T15:38:00Z",
    "releaseAcceptance": "not-verified-by-generator",
    "runtimeReadiness": "not-evaluated",
    "livePaymentsVerified": false,
    "indexingVerified": false,
    "apiOrigin": null,
    "notice": "Build-time release reference. Runtime readiness, deployment, payment settlement and external indexing are not evaluated here. Prices are proposed; this file cannot authorize execution or payment."
  }
}
