{
  "id": "records-map-transform",
  "name": "Nested record mapping with guarded patches",
  "description": "Construct nested destination records from explicit copy, literal and exact-string lookup rules. Return bounded provenance and optional root-test-guarded RFC 6902 patches. Object destinations only; no implicit coercion, expressions, array expansion, writes or source authenticity checks.",
  "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": [
    "Adapt records into a nested import schema with provenance",
    "Generate guarded reviewable record migration patches"
  ],
  "whenToUse": [
    "Map supplied records to nested object destinations using a bounded declarative mapping"
  ],
  "whenNotToUse": [
    "Flat field selection only; use records-project",
    "General expressions, recursive array mapping, joins, coercion or redaction",
    "Executing code, writing files, environment changes, network requests, publishing or deployment"
  ],
  "capabilities": [
    "Resolve all sources against the original row; no order-sensitive destination overwrite",
    "Numeric destination segments are object names; source arrays require canonical indexes",
    "Missing-null copy uses default disposition and sourcePresent=false; omitted mappings remain in lineage",
    "Patches include the original source row in a root test and do not authorize a write",
    "Patch modes also pass the released json-patch consumer, including every intermediate-state size/depth/container limit",
    "Aggregate mapped destinations and consumer node/character work have explicit pre-challenge budgets",
    "Complete bounded computation before payment challenge and execution; externalRequests=0"
  ],
  "limits": {
    "inputBytes": 100000,
    "outputBytes": 400000,
    "jsonNodes": 12000,
    "depth": 20,
    "records": 128,
    "rules": 32,
    "pointerDepth": 12,
    "pointerUnits": 1024,
    "lookupPairsPerRule": 64,
    "lookupPairsTotal": 512,
    "patchesPerRow": 100,
    "patchesTotal": 2000,
    "projectedDestinationBytes": 400000,
    "destinationJsonNodes": 12000,
    "patchConsumerNodeWork": 50000,
    "patchConsumerCharacterWork": 5000000,
    "patchConsumerContainerEntries": 1000,
    "patchConsumerJsonNodes": 20000,
    "patchConsumerJsonCharacters": 100000,
    "patchConsumerDepth": 32
  },
  "related": [
    "records-project",
    "json-structural-diff",
    "json-patch",
    "json-batch-encode"
  ],
  "errorCodes": [
    "INPUT_LIMIT",
    "OUTPUT_LIMIT",
    "COMPLEXITY_LIMIT",
    "INVALID_JSON",
    "INVALID_NUMBER",
    "INVALID_UNICODE",
    "UNSAFE_KEY",
    "INVALID_POINTER",
    "POINTER_LIMIT",
    "INVALID_ARRAY_INDEX",
    "DUPLICATE_ID",
    "DUPLICATE_LOOKUP_KEY",
    "LOOKUP_LIMIT",
    "DESTINATION_COLLISION",
    "MISSING_SOURCE",
    "LOOKUP_TYPE",
    "UNKNOWN_LOOKUP_KEY",
    "PATCH_LIMIT",
    "PATCH_COMPOSITION",
    "MAPPING_WORK_LIMIT",
    "PATCH_WORK_LIMIT",
    "ITEM_LIMIT",
    "SIZE_LIMIT",
    "DEPTH_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-map-transform",
      "operation.category": "structured",
      "limit.httpRequestBytes": 131072,
      "limit.requestBytes": 100000,
      "limit.responseBytes": 524288,
      "limit.resultBytes": 400000,
      "limit.jsonDepth": 20,
      "limit.jsonNodes": 12000,
      "recordMap.profile": "nested-record-map-v1",
      "recordMap.maxRecords": 128,
      "recordMap.maxRules": 32,
      "recordMap.maxPointerDepth": 12,
      "recordMap.maxLookupPairsPerRule": 64,
      "recordMap.maxLookupPairs": 512,
      "recordMap.maxPatchOperationsPerRow": 100,
      "recordMap.maxPatchOperations": 2000,
      "recordMap.maxDestinationJsonNodes": 12000,
      "recordMap.maxPatchConsumerNodeWork": 50000,
      "recordMap.maxPatchConsumerCharacterWork": 5000000,
      "recordMap.patchConsumerNodeWorkFormula": "sum(patch.length * (sourceNodes + destinationNodes))",
      "recordMap.patchConsumerCharacterWorkFormula": "sum(patch.length * (JSON.stringify(source).length + JSON.stringify(destination).length))",
      "recordMap.patchConsumerMaxContainerEntries": 1000,
      "recordMap.patchConsumerMaxJsonNodes": 20000,
      "recordMap.patchConsumerMaxJsonCharacters": 100000,
      "recordMap.patchConsumerMaxDepth": 32,
      "recordMap.patchConsumerChecksIntermediateStates": true,
      "recordMap.sourceSnapshot": "original-record",
      "recordMap.destinationContainers": "objects-only",
      "recordMap.guard": "root-test-original-record",
      "recordMap.guardedPatchEchoesOriginal": true,
      "recordMap.expressions": false,
      "recordMap.coercion": false,
      "recordMap.recursiveArrayMapping": false,
      "recordMap.redactionProduct": false,
      "recordMap.appliesRemoteChanges": false,
      "input.records.maxItems": 128,
      "input.rules.maxItems": 32,
      "input.rules.minItems": 1
    },
    "unknownPolicy": "Undeclared requirements are unknown, never compatible. Matching declared facts does not establish semantic fit or input validity.",
    "preflight": "/preflight"
  },
  "documentation": "/reference/tools/records-map-transform.md",
  "serviceContract": "/reference/services/records-map-transform.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-map-transform",
    "mpp": "/v1/mpp/records-map-transform"
  },
  "inputSchema": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "records": {
        "maxItems": 128,
        "type": "array",
        "items": {
          "type": "object",
          "propertyNames": {
            "type": "string"
          },
          "additionalProperties": {
            "$ref": "#/$defs/__schema0"
          }
        }
      },
      "rules": {
        "minItems": 1,
        "maxItems": 32,
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "id": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100
            },
            "destination": {
              "type": "string",
              "maxLength": 1024
            },
            "source": {
              "oneOf": [
                {
                  "type": "object",
                  "properties": {
                    "kind": {
                      "type": "string",
                      "const": "copy"
                    },
                    "pointer": {
                      "type": "string",
                      "maxLength": 1024
                    },
                    "onMissing": {
                      "type": "string",
                      "enum": [
                        "error",
                        "omit",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "kind",
                    "pointer",
                    "onMissing"
                  ],
                  "additionalProperties": false
                },
                {
                  "type": "object",
                  "properties": {
                    "kind": {
                      "type": "string",
                      "const": "literal"
                    },
                    "value": {
                      "$ref": "#/$defs/__schema0"
                    }
                  },
                  "required": [
                    "kind",
                    "value"
                  ],
                  "additionalProperties": false
                },
                {
                  "type": "object",
                  "properties": {
                    "kind": {
                      "type": "string",
                      "const": "lookup"
                    },
                    "pointer": {
                      "type": "string",
                      "maxLength": 1024
                    },
                    "pairs": {
                      "maxItems": 64,
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "key": {
                            "type": "string"
                          },
                          "value": {
                            "$ref": "#/$defs/__schema0"
                          }
                        },
                        "required": [
                          "key",
                          "value"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "onUnknown": {
                      "oneOf": [
                        {
                          "type": "object",
                          "properties": {
                            "kind": {
                              "type": "string",
                              "const": "error"
                            }
                          },
                          "required": [
                            "kind"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "kind": {
                              "type": "string",
                              "const": "default"
                            },
                            "value": {
                              "$ref": "#/$defs/__schema0"
                            }
                          },
                          "required": [
                            "kind",
                            "value"
                          ],
                          "additionalProperties": false
                        }
                      ]
                    }
                  },
                  "required": [
                    "kind",
                    "pointer",
                    "pairs",
                    "onUnknown"
                  ],
                  "additionalProperties": false
                }
              ]
            }
          },
          "required": [
            "id",
            "destination",
            "source"
          ],
          "additionalProperties": false
        }
      },
      "mode": {
        "type": "string",
        "enum": [
          "records",
          "guarded-patches",
          "both"
        ]
      }
    },
    "required": [
      "records",
      "rules",
      "mode"
    ],
    "additionalProperties": false,
    "$defs": {
      "__schema0": {
        "anyOf": [
          {
            "type": "string"
          },
          {
            "type": "number"
          },
          {
            "type": "boolean"
          },
          {
            "type": "null"
          },
          {
            "type": "array",
            "items": {
              "$ref": "#/$defs/__schema0"
            }
          },
          {
            "type": "object",
            "propertyNames": {
              "type": "string"
            },
            "additionalProperties": {
              "$ref": "#/$defs/__schema0"
            }
          }
        ]
      }
    }
  },
  "outputSchema": {
    "type": "object",
    "required": [
      "operation",
      "version",
      "result",
      "provenance"
    ],
    "properties": {
      "operation": {
        "const": "records-map-transform",
        "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": "nested-record-map-v1"
          },
          "mode": {
            "type": "string",
            "enum": [
              "records",
              "guarded-patches",
              "both"
            ]
          },
          "rows": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "sourceIndex": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 9007199254740991
                },
                "record": {
                  "anyOf": [
                    {
                      "type": "object",
                      "propertyNames": {
                        "type": "string"
                      },
                      "additionalProperties": {
                        "$ref": "#/properties/result/$defs/__schema0"
                      }
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "provenance": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "ruleId": {
                        "type": "string"
                      },
                      "sourcePointer": {
                        "type": [
                          "string",
                          "null"
                        ]
                      },
                      "destinationPointer": {
                        "type": "string"
                      },
                      "sourcePresent": {
                        "type": [
                          "boolean",
                          "null"
                        ]
                      },
                      "disposition": {
                        "type": "string",
                        "enum": [
                          "copied",
                          "literal",
                          "lookup",
                          "default",
                          "omitted"
                        ]
                      }
                    },
                    "required": [
                      "ruleId",
                      "sourcePointer",
                      "destinationPointer",
                      "sourcePresent",
                      "disposition"
                    ],
                    "additionalProperties": false
                  }
                },
                "patch": {
                  "anyOf": [
                    {
                      "type": "array",
                      "items": {
                        "oneOf": [
                          {
                            "type": "object",
                            "properties": {
                              "op": {
                                "type": "string",
                                "const": "test"
                              },
                              "path": {
                                "type": "string",
                                "const": ""
                              },
                              "value": {
                                "$ref": "#/properties/result/$defs/__schema0"
                              }
                            },
                            "required": [
                              "op",
                              "path",
                              "value"
                            ],
                            "additionalProperties": false
                          },
                          {
                            "type": "object",
                            "properties": {
                              "op": {
                                "type": "string",
                                "const": "add"
                              },
                              "path": {
                                "type": "string",
                                "maxLength": 1024
                              },
                              "value": {
                                "$ref": "#/properties/result/$defs/__schema0"
                              }
                            },
                            "required": [
                              "op",
                              "path",
                              "value"
                            ],
                            "additionalProperties": false
                          },
                          {
                            "type": "object",
                            "properties": {
                              "op": {
                                "type": "string",
                                "const": "replace"
                              },
                              "path": {
                                "type": "string",
                                "maxLength": 1024
                              },
                              "value": {
                                "$ref": "#/properties/result/$defs/__schema0"
                              }
                            },
                            "required": [
                              "op",
                              "path",
                              "value"
                            ],
                            "additionalProperties": false
                          },
                          {
                            "type": "object",
                            "properties": {
                              "op": {
                                "type": "string",
                                "const": "remove"
                              },
                              "path": {
                                "type": "string",
                                "maxLength": 1024
                              }
                            },
                            "required": [
                              "op",
                              "path"
                            ],
                            "additionalProperties": false
                          }
                        ]
                      }
                    },
                    {
                      "type": "null"
                    }
                  ]
                }
              },
              "required": [
                "sourceIndex",
                "record",
                "provenance",
                "patch"
              ],
              "additionalProperties": false
            }
          },
          "recordCount": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "operationCount": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "externalRequests": {
            "type": "number",
            "const": 0
          },
          "execution": {
            "type": "boolean",
            "const": false
          }
        },
        "required": [
          "profile",
          "mode",
          "rows",
          "recordCount",
          "operationCount",
          "externalRequests",
          "execution"
        ],
        "additionalProperties": false,
        "$defs": {
          "__schema0": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "number"
              },
              {
                "type": "boolean"
              },
              {
                "type": "null"
              },
              {
                "type": "array",
                "items": {
                  "$ref": "#/properties/result/$defs/__schema0"
                }
              },
              {
                "type": "object",
                "propertyNames": {
                  "type": "string"
                },
                "additionalProperties": {
                  "$ref": "#/properties/result/$defs/__schema0"
                }
              }
            ]
          }
        }
      },
      "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": [
      {
        "id": "c7",
        "display": "Ada",
        "tier": "pro"
      }
    ],
    "rules": [
      {
        "id": "id",
        "destination": "/customer/id",
        "source": {
          "kind": "copy",
          "pointer": "/id",
          "onMissing": "error"
        }
      },
      {
        "id": "name",
        "destination": "/customer/name",
        "source": {
          "kind": "copy",
          "pointer": "/display",
          "onMissing": "error"
        }
      },
      {
        "id": "plan",
        "destination": "/plan",
        "source": {
          "kind": "lookup",
          "pointer": "/tier",
          "pairs": [
            {
              "key": "pro",
              "value": "paid"
            }
          ],
          "onUnknown": {
            "kind": "error"
          }
        }
      },
      {
        "id": "version",
        "destination": "/apiVersion",
        "source": {
          "kind": "literal",
          "value": 1
        }
      }
    ],
    "mode": "both"
  },
  "exampleResponse": {
    "operation": "records-map-transform",
    "version": "0.29.0",
    "result": {
      "profile": "nested-record-map-v1",
      "mode": "both",
      "rows": [
        {
          "sourceIndex": 0,
          "record": {
            "apiVersion": 1,
            "customer": {
              "id": "c7",
              "name": "Ada"
            },
            "plan": "paid"
          },
          "provenance": [
            {
              "ruleId": "id",
              "sourcePointer": "/id",
              "destinationPointer": "/customer/id",
              "sourcePresent": true,
              "disposition": "copied"
            },
            {
              "ruleId": "name",
              "sourcePointer": "/display",
              "destinationPointer": "/customer/name",
              "sourcePresent": true,
              "disposition": "copied"
            },
            {
              "ruleId": "plan",
              "sourcePointer": "/tier",
              "destinationPointer": "/plan",
              "sourcePresent": true,
              "disposition": "lookup"
            },
            {
              "ruleId": "version",
              "sourcePointer": null,
              "destinationPointer": "/apiVersion",
              "sourcePresent": null,
              "disposition": "literal"
            }
          ],
          "patch": [
            {
              "op": "test",
              "path": "",
              "value": {
                "display": "Ada",
                "id": "c7",
                "tier": "pro"
              }
            },
            {
              "op": "add",
              "path": "/apiVersion",
              "value": 1
            },
            {
              "op": "add",
              "path": "/customer",
              "value": {
                "id": "c7",
                "name": "Ada"
              }
            },
            {
              "op": "remove",
              "path": "/display"
            },
            {
              "op": "remove",
              "path": "/id"
            },
            {
              "op": "add",
              "path": "/plan",
              "value": "paid"
            },
            {
              "op": "remove",
              "path": "/tier"
            }
          ]
        }
      ],
      "recordCount": 1,
      "operationCount": 7,
      "externalRequests": 0,
      "execution": false
    },
    "provenance": {
      "inputSha256": "8a4f0c25859630ea88a6e0300b7add71a1a2bf111d562cb9d5293cc61cd85cff",
      "outputSha256": "6344421da2c94f9751785c5e99bf3febd7bc3fce3d06070bd5777e2b0d7076ee",
      "deterministic": true,
      "externalRequests": 0
    }
  },
  "requiredHeaders": {
    "Content-Type": "application/json",
    "Idempotency-Key": "random 16–128 character operation identifier"
  },
  "fixedExample": "/reference/examples/records-map-transform.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."
  }
}
