{
  "id": "text-edit-align",
  "name": "Exact Scalar Text Edit Alignment",
  "description": "Generate a minimum unit-edit alignment of two supplied short texts with deterministic ties, scalar/UTF-16/UTF-8 spans, exact digests and a fully guarded text-edits-apply request. Preserves every supplied scalar and newline without normalization.",
  "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": [
    "Generate guarded text edits from two short exact text versions",
    "Align scalar changes with Unicode byte and code-unit offset evidence"
  ],
  "whenToUse": [
    "Produce a complete reproducible minimum unit-edit script and consumer-ready guarded edit request"
  ],
  "whenNotToUse": [
    "Line, token, grapheme or semantic alignment; fuzzy anchoring or transposition distance",
    "Long documents or more than 200 separated changed blocks",
    "Network requests, file changes, external execution, publishing or deployment"
  ],
  "capabilities": [
    "Suffix DP with optimal step precedence equal, substitute, delete, insert",
    "Coalesce adjacent equal steps only; every non-equal step stays scalar-granular",
    "Guarded edits group maximal contiguous non-equal blocks without crossing equal text",
    "Actual consumer input schema and complete generated-input semantic checks before challenge; consumer purchase/execution remains separate",
    "Exact UTF-8 SHA-256 provenance; no normalization, trimming or newline conversion",
    "Complete bounded result computed during semantic preflight before payment challenge; recomputed during execution",
    "Supplied-data-only artifact; externalRequests=0"
  ],
  "related": [
    "text-edits-apply",
    "text-offset-map",
    "lines-diff"
  ],
  "limits": {
    "inputBytes": 100000,
    "outputBytes": 300000,
    "jsonNodes": 12000,
    "depth": 20,
    "dpCells": 262144,
    "textScalars": 512,
    "atomicSteps": 1024,
    "editBlocks": 200,
    "editOffsetUnit": "utf16-code-units",
    "alignmentUnit": "unicode-scalars",
    "tieOrder": "equal,substitute,delete,insert"
  },
  "errorCodes": [
    "INVALID_INPUT",
    "INPUT_LIMIT",
    "OUTPUT_LIMIT",
    "COMPLEXITY_LIMIT",
    "INVALID_JSON",
    "INVALID_NUMBER",
    "INVALID_UNICODE",
    "UNSAFE_KEY",
    "WORK_LIMIT",
    "TEXT_LENGTH",
    "EDIT_BLOCK_LIMIT",
    "CONSUMER_INPUT"
  ],
  "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": "text-edit-align",
      "operation.category": "data-assurance",
      "limit.httpRequestBytes": 131072,
      "limit.requestBytes": 100000,
      "limit.responseBytes": 524288,
      "limit.resultBytes": 300000,
      "limit.jsonDepth": 20,
      "limit.jsonNodes": 12000,
      "textAlignment.profile": "scalar-unit-edit-alignment-v1",
      "textAlignment.unit": "unicode-scalars",
      "textAlignment.minimumUnitCost": true,
      "textAlignment.tieOrder": "equal,substitute,delete,insert",
      "textAlignment.offsetSystems": "scalar,utf16,utf8",
      "textAlignment.guardedApplyArtifact": true,
      "textAlignment.consumerValidatedBeforeChallenge": true,
      "textAlignment.maxTextScalars": 512,
      "textAlignment.maxDpCells": 262144,
      "textAlignment.maxEditBlocks": 200,
      "textAlignment.normalization": false,
      "textAlignment.newlineConversion": false,
      "textAlignment.graphemeAlignment": false,
      "textAlignment.semanticAlignment": false,
      "textAlignment.fuzzyAnchoring": false,
      "textAlignment.consumerExecuted": false,
      "textAlignment.transpositionSingleEdit": false,
      "input.before.maxLength": 1024,
      "input.after.maxLength": 1024
    },
    "unknownPolicy": "Undeclared requirements are unknown, never compatible. Matching declared facts does not establish semantic fit or input validity.",
    "preflight": "/preflight"
  },
  "documentation": "/reference/tools/text-edit-align.md",
  "serviceContract": "/reference/services/text-edit-align.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/text-edit-align",
    "mpp": "/v1/mpp/text-edit-align"
  },
  "inputSchema": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "before": {
        "type": "string",
        "maxLength": 1024
      },
      "after": {
        "type": "string",
        "maxLength": 1024
      }
    },
    "required": [
      "before",
      "after"
    ],
    "additionalProperties": false
  },
  "outputSchema": {
    "type": "object",
    "required": [
      "operation",
      "version",
      "result",
      "provenance"
    ],
    "properties": {
      "operation": {
        "const": "text-edit-align",
        "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": "scalar-unit-edit-alignment-v1"
          },
          "tieOrder": {
            "type": "array",
            "prefixItems": [
              {
                "type": "string",
                "const": "equal"
              },
              {
                "type": "string",
                "const": "substitute"
              },
              {
                "type": "string",
                "const": "delete"
              },
              {
                "type": "string",
                "const": "insert"
              }
            ],
            "items": false,
            "minItems": 4,
            "maxItems": 4
          },
          "distance": {
            "type": "integer",
            "minimum": 0,
            "maximum": 512
          },
          "counts": {
            "type": "object",
            "properties": {
              "insertions": {
                "type": "integer",
                "minimum": 0,
                "maximum": 512
              },
              "deletions": {
                "type": "integer",
                "minimum": 0,
                "maximum": 512
              },
              "substitutions": {
                "type": "integer",
                "minimum": 0,
                "maximum": 512
              }
            },
            "required": [
              "insertions",
              "deletions",
              "substitutions"
            ],
            "additionalProperties": false
          },
          "before": {
            "type": "object",
            "properties": {
              "scalar": {
                "type": "integer",
                "minimum": 0,
                "maximum": 512
              },
              "utf16": {
                "type": "integer",
                "minimum": 0,
                "maximum": 1024
              },
              "utf8": {
                "type": "integer",
                "minimum": 0,
                "maximum": 2048
              }
            },
            "required": [
              "scalar",
              "utf16",
              "utf8"
            ],
            "additionalProperties": false
          },
          "after": {
            "type": "object",
            "properties": {
              "scalar": {
                "type": "integer",
                "minimum": 0,
                "maximum": 512
              },
              "utf16": {
                "type": "integer",
                "minimum": 0,
                "maximum": 1024
              },
              "utf8": {
                "type": "integer",
                "minimum": 0,
                "maximum": 2048
              }
            },
            "required": [
              "scalar",
              "utf16",
              "utf8"
            ],
            "additionalProperties": false
          },
          "beforeSha256": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$"
          },
          "afterSha256": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$"
          },
          "digestEncoding": {
            "type": "string",
            "const": "exact-utf8"
          },
          "dpCellCount": {
            "type": "integer",
            "minimum": 0,
            "maximum": 262144
          },
          "operations": {
            "maxItems": 1024,
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "op": {
                  "type": "string",
                  "enum": [
                    "equal",
                    "substitute",
                    "delete",
                    "insert"
                  ]
                },
                "source": {
                  "type": "object",
                  "properties": {
                    "scalar": {
                      "type": "array",
                      "prefixItems": [
                        {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 9007199254740991
                        },
                        {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 9007199254740991
                        }
                      ],
                      "items": false,
                      "minItems": 2,
                      "maxItems": 2
                    },
                    "utf16": {
                      "type": "array",
                      "prefixItems": [
                        {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 9007199254740991
                        },
                        {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 9007199254740991
                        }
                      ],
                      "items": false,
                      "minItems": 2,
                      "maxItems": 2
                    },
                    "utf8": {
                      "type": "array",
                      "prefixItems": [
                        {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 9007199254740991
                        },
                        {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 9007199254740991
                        }
                      ],
                      "items": false,
                      "minItems": 2,
                      "maxItems": 2
                    }
                  },
                  "required": [
                    "scalar",
                    "utf16",
                    "utf8"
                  ],
                  "additionalProperties": false
                },
                "target": {
                  "type": "object",
                  "properties": {
                    "scalar": {
                      "type": "array",
                      "prefixItems": [
                        {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 9007199254740991
                        },
                        {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 9007199254740991
                        }
                      ],
                      "items": false,
                      "minItems": 2,
                      "maxItems": 2
                    },
                    "utf16": {
                      "type": "array",
                      "prefixItems": [
                        {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 9007199254740991
                        },
                        {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 9007199254740991
                        }
                      ],
                      "items": false,
                      "minItems": 2,
                      "maxItems": 2
                    },
                    "utf8": {
                      "type": "array",
                      "prefixItems": [
                        {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 9007199254740991
                        },
                        {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 9007199254740991
                        }
                      ],
                      "items": false,
                      "minItems": 2,
                      "maxItems": 2
                    }
                  },
                  "required": [
                    "scalar",
                    "utf16",
                    "utf8"
                  ],
                  "additionalProperties": false
                },
                "sourceText": {
                  "type": "string"
                },
                "targetText": {
                  "type": "string"
                }
              },
              "required": [
                "op",
                "source",
                "target",
                "sourceText",
                "targetText"
              ],
              "additionalProperties": false
            }
          },
          "applyRequest": {
            "type": "object",
            "properties": {
              "text": {
                "type": "string"
              },
              "expectedSha256": {
                "type": "string",
                "pattern": "^[0-9a-f]{64}$"
              },
              "edits": {
                "maxItems": 200,
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 80
                    },
                    "start": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 9007199254740991
                    },
                    "end": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 9007199254740991
                    },
                    "expected": {
                      "type": "string"
                    },
                    "replacement": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "id",
                    "start",
                    "end",
                    "expected",
                    "replacement"
                  ],
                  "additionalProperties": false
                }
              }
            },
            "required": [
              "text",
              "expectedSha256",
              "edits"
            ],
            "additionalProperties": false
          },
          "consumerValidated": {
            "type": "boolean",
            "const": true
          },
          "externalRequests": {
            "type": "number",
            "const": 0
          }
        },
        "required": [
          "profile",
          "tieOrder",
          "distance",
          "counts",
          "before",
          "after",
          "beforeSha256",
          "afterSha256",
          "digestEncoding",
          "dpCellCount",
          "operations",
          "applyRequest",
          "consumerValidated",
          "externalRequests"
        ],
        "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": {
    "before": "A😀cat\n",
    "after": "A😀cut!\n"
  },
  "exampleResponse": {
    "operation": "text-edit-align",
    "version": "0.29.0",
    "result": {
      "profile": "scalar-unit-edit-alignment-v1",
      "tieOrder": [
        "equal",
        "substitute",
        "delete",
        "insert"
      ],
      "distance": 2,
      "counts": {
        "insertions": 1,
        "deletions": 0,
        "substitutions": 1
      },
      "before": {
        "scalar": 6,
        "utf16": 7,
        "utf8": 9
      },
      "after": {
        "scalar": 7,
        "utf16": 8,
        "utf8": 10
      },
      "beforeSha256": "c413f26d179faf31f2918a1c080a2004c7ee7f9bee8f1a2138342a9d56e078b6",
      "afterSha256": "adcffe9889029b9ee89f1d701983df061893f2e639ff91db6ffcad296cff2911",
      "digestEncoding": "exact-utf8",
      "dpCellCount": 56,
      "operations": [
        {
          "op": "equal",
          "source": {
            "scalar": [
              0,
              3
            ],
            "utf16": [
              0,
              4
            ],
            "utf8": [
              0,
              6
            ]
          },
          "target": {
            "scalar": [
              0,
              3
            ],
            "utf16": [
              0,
              4
            ],
            "utf8": [
              0,
              6
            ]
          },
          "sourceText": "A😀c",
          "targetText": "A😀c"
        },
        {
          "op": "substitute",
          "source": {
            "scalar": [
              3,
              4
            ],
            "utf16": [
              4,
              5
            ],
            "utf8": [
              6,
              7
            ]
          },
          "target": {
            "scalar": [
              3,
              4
            ],
            "utf16": [
              4,
              5
            ],
            "utf8": [
              6,
              7
            ]
          },
          "sourceText": "a",
          "targetText": "u"
        },
        {
          "op": "equal",
          "source": {
            "scalar": [
              4,
              5
            ],
            "utf16": [
              5,
              6
            ],
            "utf8": [
              7,
              8
            ]
          },
          "target": {
            "scalar": [
              4,
              5
            ],
            "utf16": [
              5,
              6
            ],
            "utf8": [
              7,
              8
            ]
          },
          "sourceText": "t",
          "targetText": "t"
        },
        {
          "op": "insert",
          "source": {
            "scalar": [
              5,
              5
            ],
            "utf16": [
              6,
              6
            ],
            "utf8": [
              8,
              8
            ]
          },
          "target": {
            "scalar": [
              5,
              6
            ],
            "utf16": [
              6,
              7
            ],
            "utf8": [
              8,
              9
            ]
          },
          "sourceText": "",
          "targetText": "!"
        },
        {
          "op": "equal",
          "source": {
            "scalar": [
              5,
              6
            ],
            "utf16": [
              6,
              7
            ],
            "utf8": [
              8,
              9
            ]
          },
          "target": {
            "scalar": [
              6,
              7
            ],
            "utf16": [
              7,
              8
            ],
            "utf8": [
              9,
              10
            ]
          },
          "sourceText": "\n",
          "targetText": "\n"
        }
      ],
      "applyRequest": {
        "text": "A😀cat\n",
        "expectedSha256": "c413f26d179faf31f2918a1c080a2004c7ee7f9bee8f1a2138342a9d56e078b6",
        "edits": [
          {
            "id": "e000",
            "start": 4,
            "end": 5,
            "expected": "a",
            "replacement": "u"
          },
          {
            "id": "e001",
            "start": 6,
            "end": 6,
            "expected": "",
            "replacement": "!"
          }
        ]
      },
      "consumerValidated": true,
      "externalRequests": 0
    },
    "provenance": {
      "inputSha256": "f90c8be8123103b347d0ea86db5571ec73dfb0a46de190ba7f761b4787aa2cad",
      "outputSha256": "346e06c8ac2c43944f12e853e875b8d69f68f31225ee4b36876ffc2c2b278d7a",
      "deterministic": true,
      "externalRequests": 0
    }
  },
  "requiredHeaders": {
    "Content-Type": "application/json",
    "Idempotency-Key": "random 16–128 character operation identifier"
  },
  "fixedExample": "/reference/examples/text-edit-align.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."
  }
}
