{
  "id": "records-crosstab-compose",
  "name": "Exact typed record crosstab",
  "description": "Compose first-occurrence typed row/column axes, dense counts, exact decimal-string sums and per-measure missing/null/valid coverage with aligned margins.",
  "category": "data-assurance",
  "priceUsd": "0.006",
  "pricingStatus": "proposed-unverified",
  "pricing": {
    "unit": "one successful operation call",
    "proposedNominalUsd": "0.006",
    "sixDecimalTokenBaseUnits": "6000",
    "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": [
    "build typed exact decimal crosstab matrix",
    "pivot records with missing null measure coverage",
    "compose chart ready counts and decimal totals"
  ],
  "whenToUse": [
    "Producing typed crossed categories with exact decimal sums from supplied records",
    "Preserving missing versus null and scalar-type distinctions",
    "Preparing aligned count grids and row/column/grand totals"
  ],
  "whenNotToUse": [
    "Accounting advice, statistical inference or verification of supplied observations",
    "Floating-point measurements, automatic numeric string coercion or implicit chart conversion",
    "Locale ordering, category normalization or inventing absent categories",
    "Fetching sources, changing external state or executing supplied data"
  ],
  "capabilities": [
    "RFC 6901 selection with first-occurrence typed tuples",
    "Exact BigInt scale-18 decimal aggregation with canonical string outputs",
    "Complete per-measure valid, null and missing coverage",
    "Dense-axis and metric-slot admission before matrix allocation",
    "Deterministic supplied-input-only inert artifact; no network, clock, randomness or external state change"
  ],
  "related": [
    "records-aggregate",
    "record-profile",
    "decimal-distribution-summarize"
  ],
  "limits": {
    "inputBytes": 100000,
    "outputBytes": 300000,
    "jsonNodes": 10000,
    "depth": 20,
    "profile": "typed-exact-decimal-crosstab-v1",
    "records": 1000,
    "rowPointers": 2,
    "columnPointers": 2,
    "measures": 4,
    "axisTuples": 128,
    "denseCells": 1024,
    "metricSlotsIncludingMargins": 4096,
    "pointerSteps": 64000,
    "decimalParses": 4000,
    "decimalIntegerDigits": 24,
    "decimalFractionDigits": 18,
    "pointerCharacters": 2048,
    "measureNameCharacters": 128
  },
  "errorCodes": [
    "INPUT_LIMIT",
    "OUTPUT_LIMIT",
    "COMPLEXITY_LIMIT",
    "INVALID_JSON",
    "INVALID_NUMBER",
    "INVALID_UNICODE",
    "UNSAFE_KEY",
    "INVALID_INPUT",
    "CROSSTAB_MEASURE_NAME",
    "CROSSTAB_DECIMAL",
    "CROSSTAB_AXIS",
    "CROSSTAB_AXIS_LIMIT",
    "CROSSTAB_CELL_LIMIT",
    "CROSSTAB_WORK_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": "records-crosstab-compose",
      "operation.category": "data-assurance",
      "limit.httpRequestBytes": 131072,
      "limit.requestBytes": 100000,
      "limit.responseBytes": 524288,
      "limit.resultBytes": 300000,
      "limit.jsonDepth": 20,
      "limit.jsonNodes": 10000,
      "crosstab.profile": "typed-exact-decimal-crosstab-v1",
      "crosstab.axisOrder": "first-occurrence-typed-tuples",
      "crosstab.missingDiffersFromNull": true,
      "crosstab.numericStringsDistinct": true,
      "crosstab.exactDecimalSums": true,
      "crosstab.measureInput": "bounded-decimal-strings-only",
      "crosstab.maxRecords": 1000,
      "crosstab.maxRowPointers": 2,
      "crosstab.maxColumnPointers": 2,
      "crosstab.maxMeasures": 4,
      "crosstab.maxAxisTuples": 128,
      "crosstab.maxDenseCells": 1024,
      "crosstab.maxMetricSlotsIncludingMargins": 4096,
      "crosstab.maxPointerSteps": 64000,
      "crosstab.maxDecimalParses": 4000,
      "crosstab.maxDecimalIntegerDigits": 24,
      "crosstab.maxDecimalFractionDigits": 18,
      "crosstab.populationInference": false,
      "crosstab.missingValuesImputed": false,
      "crosstab.sourceAuthenticity": false,
      "input.records.maxItems": 1000,
      "input.rowPointers.maxItems": 2,
      "input.rowPointers.minItems": 1,
      "input.columnPointers.maxItems": 2,
      "input.columnPointers.minItems": 1,
      "input.measures.maxItems": 4
    },
    "unknownPolicy": "Undeclared requirements are unknown, never compatible. Matching declared facts does not establish semantic fit or input validity.",
    "preflight": "/preflight"
  },
  "documentation": "/reference/tools/records-crosstab-compose.md",
  "serviceContract": "/reference/services/records-crosstab-compose.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/records-crosstab-compose",
    "mpp": "/v1/mpp/records-crosstab-compose"
  },
  "inputSchema": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "records": {
        "maxItems": 1000,
        "type": "array",
        "items": {
          "type": "object",
          "propertyNames": {
            "type": "string"
          },
          "additionalProperties": {}
        }
      },
      "rowPointers": {
        "minItems": 1,
        "maxItems": 2,
        "type": "array",
        "items": {
          "type": "string",
          "maxLength": 2048,
          "pattern": "^(?:\\/(?:[^~]|~[01])*)*$"
        }
      },
      "columnPointers": {
        "minItems": 1,
        "maxItems": 2,
        "type": "array",
        "items": {
          "type": "string",
          "maxLength": 2048,
          "pattern": "^(?:\\/(?:[^~]|~[01])*)*$"
        }
      },
      "measures": {
        "maxItems": 4,
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "name": {
              "type": "string",
              "minLength": 1,
              "maxLength": 128
            },
            "pointer": {
              "type": "string",
              "maxLength": 2048,
              "pattern": "^(?:\\/(?:[^~]|~[01])*)*$"
            }
          },
          "required": [
            "name",
            "pointer"
          ],
          "additionalProperties": false
        }
      }
    },
    "required": [
      "records",
      "rowPointers",
      "columnPointers",
      "measures"
    ],
    "additionalProperties": false
  },
  "outputSchema": {
    "type": "object",
    "required": [
      "operation",
      "version",
      "result",
      "provenance"
    ],
    "properties": {
      "operation": {
        "const": "records-crosstab-compose",
        "type": "string"
      },
      "version": {
        "const": "0.29.0",
        "type": "string"
      },
      "result": {
        "$schema": "https://json-schema.org/draft/2020-12/schema",
        "type": "object",
        "properties": {
          "profile": {
            "type": "string",
            "const": "typed-exact-decimal-crosstab-v1"
          },
          "axisOrder": {
            "type": "string",
            "const": "first-occurrence"
          },
          "rowAxes": {
            "maxItems": 128,
            "type": "array",
            "items": {
              "minItems": 1,
              "maxItems": 2,
              "type": "array",
              "items": {
                "oneOf": [
                  {
                    "type": "object",
                    "properties": {
                      "type": {
                        "type": "string",
                        "const": "missing"
                      }
                    },
                    "required": [
                      "type"
                    ],
                    "additionalProperties": false
                  },
                  {
                    "type": "object",
                    "properties": {
                      "type": {
                        "type": "string",
                        "const": "null"
                      }
                    },
                    "required": [
                      "type"
                    ],
                    "additionalProperties": false
                  },
                  {
                    "type": "object",
                    "properties": {
                      "type": {
                        "type": "string",
                        "const": "string"
                      },
                      "value": {
                        "type": "string",
                        "maxLength": 100000
                      }
                    },
                    "required": [
                      "type",
                      "value"
                    ],
                    "additionalProperties": false
                  },
                  {
                    "type": "object",
                    "properties": {
                      "type": {
                        "type": "string",
                        "const": "number"
                      },
                      "value": {
                        "type": "number"
                      }
                    },
                    "required": [
                      "type",
                      "value"
                    ],
                    "additionalProperties": false
                  },
                  {
                    "type": "object",
                    "properties": {
                      "type": {
                        "type": "string",
                        "const": "boolean"
                      },
                      "value": {
                        "type": "boolean"
                      }
                    },
                    "required": [
                      "type",
                      "value"
                    ],
                    "additionalProperties": false
                  }
                ]
              }
            }
          },
          "columnAxes": {
            "maxItems": 128,
            "type": "array",
            "items": {
              "minItems": 1,
              "maxItems": 2,
              "type": "array",
              "items": {
                "oneOf": [
                  {
                    "type": "object",
                    "properties": {
                      "type": {
                        "type": "string",
                        "const": "missing"
                      }
                    },
                    "required": [
                      "type"
                    ],
                    "additionalProperties": false
                  },
                  {
                    "type": "object",
                    "properties": {
                      "type": {
                        "type": "string",
                        "const": "null"
                      }
                    },
                    "required": [
                      "type"
                    ],
                    "additionalProperties": false
                  },
                  {
                    "type": "object",
                    "properties": {
                      "type": {
                        "type": "string",
                        "const": "string"
                      },
                      "value": {
                        "type": "string",
                        "maxLength": 100000
                      }
                    },
                    "required": [
                      "type",
                      "value"
                    ],
                    "additionalProperties": false
                  },
                  {
                    "type": "object",
                    "properties": {
                      "type": {
                        "type": "string",
                        "const": "number"
                      },
                      "value": {
                        "type": "number"
                      }
                    },
                    "required": [
                      "type",
                      "value"
                    ],
                    "additionalProperties": false
                  },
                  {
                    "type": "object",
                    "properties": {
                      "type": {
                        "type": "string",
                        "const": "boolean"
                      },
                      "value": {
                        "type": "boolean"
                      }
                    },
                    "required": [
                      "type",
                      "value"
                    ],
                    "additionalProperties": false
                  }
                ]
              }
            }
          },
          "counts": {
            "type": "object",
            "properties": {
              "cells": {
                "maxItems": 128,
                "type": "array",
                "items": {
                  "maxItems": 128,
                  "type": "array",
                  "items": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 1000
                  }
                }
              },
              "rowTotals": {
                "maxItems": 128,
                "type": "array",
                "items": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 1000
                }
              },
              "columnTotals": {
                "maxItems": 128,
                "type": "array",
                "items": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 1000
                }
              },
              "grandTotal": {
                "type": "integer",
                "minimum": 0,
                "maximum": 1000
              }
            },
            "required": [
              "cells",
              "rowTotals",
              "columnTotals",
              "grandTotal"
            ],
            "additionalProperties": false
          },
          "measures": {
            "maxItems": 4,
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 128
                },
                "pointer": {
                  "type": "string",
                  "maxLength": 2048,
                  "pattern": "^(?:\\/(?:[^~]|~[01])*)*$"
                },
                "sums": {
                  "type": "object",
                  "properties": {
                    "cells": {
                      "maxItems": 128,
                      "type": "array",
                      "items": {
                        "maxItems": 128,
                        "type": "array",
                        "items": {
                          "type": "string",
                          "maxLength": 47,
                          "pattern": "^(?:0|-?[1-9]\\d{0,26}|-?(?:0|[1-9]\\d{0,26})\\.\\d{0,17}[1-9])$"
                        }
                      }
                    },
                    "rowTotals": {
                      "maxItems": 128,
                      "type": "array",
                      "items": {
                        "type": "string",
                        "maxLength": 47,
                        "pattern": "^(?:0|-?[1-9]\\d{0,26}|-?(?:0|[1-9]\\d{0,26})\\.\\d{0,17}[1-9])$"
                      }
                    },
                    "columnTotals": {
                      "maxItems": 128,
                      "type": "array",
                      "items": {
                        "type": "string",
                        "maxLength": 47,
                        "pattern": "^(?:0|-?[1-9]\\d{0,26}|-?(?:0|[1-9]\\d{0,26})\\.\\d{0,17}[1-9])$"
                      }
                    },
                    "grandTotal": {
                      "type": "string",
                      "maxLength": 47,
                      "pattern": "^(?:0|-?[1-9]\\d{0,26}|-?(?:0|[1-9]\\d{0,26})\\.\\d{0,17}[1-9])$"
                    }
                  },
                  "required": [
                    "cells",
                    "rowTotals",
                    "columnTotals",
                    "grandTotal"
                  ],
                  "additionalProperties": false
                },
                "validCounts": {
                  "type": "object",
                  "properties": {
                    "cells": {
                      "maxItems": 128,
                      "type": "array",
                      "items": {
                        "maxItems": 128,
                        "type": "array",
                        "items": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 1000
                        }
                      }
                    },
                    "rowTotals": {
                      "maxItems": 128,
                      "type": "array",
                      "items": {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 1000
                      }
                    },
                    "columnTotals": {
                      "maxItems": 128,
                      "type": "array",
                      "items": {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 1000
                      }
                    },
                    "grandTotal": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 1000
                    }
                  },
                  "required": [
                    "cells",
                    "rowTotals",
                    "columnTotals",
                    "grandTotal"
                  ],
                  "additionalProperties": false
                },
                "nullCounts": {
                  "type": "object",
                  "properties": {
                    "cells": {
                      "maxItems": 128,
                      "type": "array",
                      "items": {
                        "maxItems": 128,
                        "type": "array",
                        "items": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 1000
                        }
                      }
                    },
                    "rowTotals": {
                      "maxItems": 128,
                      "type": "array",
                      "items": {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 1000
                      }
                    },
                    "columnTotals": {
                      "maxItems": 128,
                      "type": "array",
                      "items": {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 1000
                      }
                    },
                    "grandTotal": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 1000
                    }
                  },
                  "required": [
                    "cells",
                    "rowTotals",
                    "columnTotals",
                    "grandTotal"
                  ],
                  "additionalProperties": false
                },
                "missingCounts": {
                  "type": "object",
                  "properties": {
                    "cells": {
                      "maxItems": 128,
                      "type": "array",
                      "items": {
                        "maxItems": 128,
                        "type": "array",
                        "items": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 1000
                        }
                      }
                    },
                    "rowTotals": {
                      "maxItems": 128,
                      "type": "array",
                      "items": {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 1000
                      }
                    },
                    "columnTotals": {
                      "maxItems": 128,
                      "type": "array",
                      "items": {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 1000
                      }
                    },
                    "grandTotal": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 1000
                    }
                  },
                  "required": [
                    "cells",
                    "rowTotals",
                    "columnTotals",
                    "grandTotal"
                  ],
                  "additionalProperties": false
                }
              },
              "required": [
                "name",
                "pointer",
                "sums",
                "validCounts",
                "nullCounts",
                "missingCounts"
              ],
              "additionalProperties": false
            }
          }
        },
        "required": [
          "profile",
          "axisOrder",
          "rowAxes",
          "columnAxes",
          "counts",
          "measures"
        ],
        "additionalProperties": false
      },
      "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": {
    "records": [
      {
        "team": "A",
        "status": "open",
        "amount": "0.1"
      },
      {
        "team": "A",
        "status": "open",
        "amount": "0.2"
      },
      {
        "team": "A",
        "status": "closed",
        "amount": null
      },
      {
        "team": "B",
        "status": "open"
      },
      {
        "team": "B",
        "status": "closed",
        "amount": "-0.3"
      }
    ],
    "rowPointers": [
      "/team"
    ],
    "columnPointers": [
      "/status"
    ],
    "measures": [
      {
        "name": "amount",
        "pointer": "/amount"
      }
    ]
  },
  "exampleResponse": {
    "operation": "records-crosstab-compose",
    "version": "0.29.0",
    "result": {
      "profile": "typed-exact-decimal-crosstab-v1",
      "axisOrder": "first-occurrence",
      "rowAxes": [
        [
          {
            "type": "string",
            "value": "A"
          }
        ],
        [
          {
            "type": "string",
            "value": "B"
          }
        ]
      ],
      "columnAxes": [
        [
          {
            "type": "string",
            "value": "open"
          }
        ],
        [
          {
            "type": "string",
            "value": "closed"
          }
        ]
      ],
      "counts": {
        "cells": [
          [
            2,
            1
          ],
          [
            1,
            1
          ]
        ],
        "rowTotals": [
          3,
          2
        ],
        "columnTotals": [
          3,
          2
        ],
        "grandTotal": 5
      },
      "measures": [
        {
          "name": "amount",
          "pointer": "/amount",
          "sums": {
            "cells": [
              [
                "0.3",
                "0"
              ],
              [
                "0",
                "-0.3"
              ]
            ],
            "rowTotals": [
              "0.3",
              "-0.3"
            ],
            "columnTotals": [
              "0.3",
              "-0.3"
            ],
            "grandTotal": "0"
          },
          "validCounts": {
            "cells": [
              [
                2,
                0
              ],
              [
                0,
                1
              ]
            ],
            "rowTotals": [
              2,
              1
            ],
            "columnTotals": [
              2,
              1
            ],
            "grandTotal": 3
          },
          "nullCounts": {
            "cells": [
              [
                0,
                1
              ],
              [
                0,
                0
              ]
            ],
            "rowTotals": [
              1,
              0
            ],
            "columnTotals": [
              0,
              1
            ],
            "grandTotal": 1
          },
          "missingCounts": {
            "cells": [
              [
                0,
                0
              ],
              [
                1,
                0
              ]
            ],
            "rowTotals": [
              0,
              1
            ],
            "columnTotals": [
              1,
              0
            ],
            "grandTotal": 1
          }
        }
      ]
    },
    "provenance": {
      "inputSha256": "72b700a118cc9572364a507b93986dd707aadd075e3d697f3242807d7313db75",
      "outputSha256": "450697aed2f4eb568f1bb009e8db63f0e30a8691f3538227936e23d6345d8b68",
      "deterministic": true,
      "externalRequests": 0
    }
  },
  "requiredHeaders": {
    "Content-Type": "application/json",
    "Idempotency-Key": "random 16–128 character operation identifier"
  },
  "fixedExample": "/reference/examples/records-crosstab-compose.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."
  }
}
