Browse operation contracts · Static machine index · OpenAPI release reference · Build manifest

SPDX Expression Analyze

Parse bounded SPDX-style license expression syntax into a flat indexed AST, unique identifiers/exceptions and fully parenthesized normalization. Supports AND/OR/WITH, +, LicenseRef and DocumentRef; enforces precedence and simple-left WITH. Does not validate current license/exception lists or give compliance advice; NONE/NOASSERTION document markers are rejected.

supply-chain · Operation ID: spdx-expression-analyze

Choose this operation when

Outside this profile

Exact release references

Static JSON contract · Markdown reference · Fixed example response

Complete input schema

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "expression": {
      "type": "string",
      "minLength": 1,
      "maxLength": 4096
    }
  },
  "required": [
    "expression"
  ],
  "additionalProperties": false
}

Complete output-envelope schema

{
  "type": "object",
  "required": [
    "operation",
    "version",
    "result",
    "provenance"
  ],
  "properties": {
    "operation": {
      "const": "spdx-expression-analyze",
      "type": "string"
    },
    "version": {
      "const": "0.29.0",
      "type": "string"
    },
    "result": {
      "$schema": "https://json-schema.org/draft/2020-12/schema",
      "type": "object",
      "properties": {
        "syntaxValid": {
          "type": "boolean",
          "const": true
        },
        "normalized": {
          "type": "string",
          "maxLength": 8192
        },
        "root": {
          "type": "integer",
          "minimum": 0,
          "maximum": 254
        },
        "nodes": {
          "minItems": 1,
          "maxItems": 255,
          "type": "array",
          "items": {
            "oneOf": [
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "type": "string",
                    "const": "license"
                  },
                  "identifier": {
                    "type": "string",
                    "maxLength": 256
                  },
                  "orLater": {
                    "type": "boolean"
                  },
                  "customReference": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "kind",
                  "identifier",
                  "orLater",
                  "customReference"
                ],
                "additionalProperties": false
              },
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "type": "string",
                    "const": "with"
                  },
                  "license": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 254
                  },
                  "exception": {
                    "type": "string",
                    "maxLength": 128
                  }
                },
                "required": [
                  "kind",
                  "license",
                  "exception"
                ],
                "additionalProperties": false
              },
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "type": "string",
                    "enum": [
                      "and",
                      "or"
                    ]
                  },
                  "left": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 254
                  },
                  "right": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 254
                  }
                },
                "required": [
                  "kind",
                  "left",
                  "right"
                ],
                "additionalProperties": false
              }
            ]
          }
        },
        "licenseIdentifiers": {
          "maxItems": 128,
          "type": "array",
          "items": {
            "type": "string",
            "maxLength": 256
          }
        },
        "exceptions": {
          "maxItems": 128,
          "type": "array",
          "items": {
            "type": "string",
            "maxLength": 128
          }
        },
        "scope": {
          "type": "string",
          "const": "SPDX 2.3 expression grammar subset with ASCII spaces/tabs, case-sensitive operators, LicenseRef and optional DocumentRef. Identifiers are not checked against a current SPDX list; no legal or compatibility conclusions."
        }
      },
      "required": [
        "syntaxValid",
        "normalized",
        "root",
        "nodes",
        "licenseIdentifiers",
        "exceptions",
        "scope"
      ],
      "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
}

Fixed example

One accepted fixed example, not a custom-input trial. No operation runs when this static page is requested.

Example input

{
  "expression": "MIT OR Apache-2.0 AND GPL-2.0-only WITH Classpath-exception-2.0"
}

Example response

{
  "operation": "spdx-expression-analyze",
  "version": "0.29.0",
  "result": {
    "syntaxValid": true,
    "normalized": "(MIT OR (Apache-2.0 AND GPL-2.0-only WITH Classpath-exception-2.0))",
    "root": 5,
    "nodes": [
      {
        "kind": "license",
        "identifier": "MIT",
        "orLater": false,
        "customReference": false
      },
      {
        "kind": "license",
        "identifier": "Apache-2.0",
        "orLater": false,
        "customReference": false
      },
      {
        "kind": "license",
        "identifier": "GPL-2.0-only",
        "orLater": false,
        "customReference": false
      },
      {
        "kind": "with",
        "license": 2,
        "exception": "Classpath-exception-2.0"
      },
      {
        "kind": "and",
        "left": 1,
        "right": 3
      },
      {
        "kind": "or",
        "left": 0,
        "right": 4
      }
    ],
    "licenseIdentifiers": [
      "Apache-2.0",
      "GPL-2.0-only",
      "MIT"
    ],
    "exceptions": [
      "Classpath-exception-2.0"
    ],
    "scope": "SPDX 2.3 expression grammar subset with ASCII spaces/tabs, case-sensitive operators, LicenseRef and optional DocumentRef. Identifiers are not checked against a current SPDX list; no legal or compatibility conclusions."
  },
  "provenance": {
    "inputSha256": "2d769c525513182591de214bb176bf06aed5e0544a40aa706ec0920311cca573",
    "outputSha256": "32c66e480aa54016a4e908e59960671718f6afa5c0f95e16ae75ac708b083cd2",
    "deterministic": true,
    "externalRequests": 0
  }
}

Bounds and precision

JavaScript IEEE-754 numbers; use strings for large integer IDs/exact decimals where the schema accepts strings. No lossless numeric parsing.

{
  "global": {
    "requestBytes": 131072,
    "responseBytes": 524288,
    "jsonDepth": 32,
    "jsonNodes": 20000,
    "requestsPerMinute": 60,
    "paidAttemptsPerMinute": 20,
    "idempotencyHours": 24
  },
  "operation": {
    "inputBytes": 100000,
    "jsonNodes": 12000,
    "jsonDepth": 24,
    "outputBytes": 300000,
    "expressionCharacters": 4096,
    "tokens": 255,
    "astNodes": 255,
    "parenthesisLevels": 16
  }
}

Complete schemas, descriptions and cross-field validation may impose additional limits.

Proposed price and protocol definitions

{
  "unit": "one successful operation call",
  "proposedNominalUsd": "0.003",
  "sixDecimalTokenBaseUnits": "3000",
  "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."
}

Protocol definitions: x402, mpp. MPP uses Tempo charge. Paid MCP execution is unsupported. All runtime readiness is not evaluated in this build.

API path templates, not endpoints on this documentation host

{
  "x402": "/v1/x402/spdx-expression-analyze",
  "mpp": "/v1/mpp/spdx-expression-analyze"
}

Required headers

{
  "Content-Type": "application/json",
  "Idempotency-Key": "random 16–128 character operation identifier"
}

Actual SDK challenge amount, asset, network, recipient and wallet costs must pass independent authorization. Preserve identical key, body, protocol and credential on retries; on PAYMENT_UNCERTAIN stop and reconcile.

Execution profile and provider conditions

{
  "deterministic": true,
  "externalRequests": 0,
  "maxExternalRequests": 0,
  "resultSnapshotPersisted": false,
  "fixedExampleIsIllustrativeSnapshot": false,
  "requiresPayment": true,
  "supportsMcpExecution": false
}

Deterministic supplied-input operation with no external requests or stored request/result bodies. Payment infrastructure retains payment metadata and hashes.

Failure handling

Declared requirements

Before any paid call, refresh the live operation contract and POST the complete bounded budgeted plan to the separate API's /preflight. Unknown requirements block selection; compatible preflight is not permission to spend.

Related contracts