{
  "schema": "durable-workflow.v2.sdk-neutrality.contract",
  "version": 5,
  "authority_doc": "https://github.com/durable-workflow/workflow/blob/main/docs/architecture/sdk-neutrality.md",
  "authority_url": "https://durable-workflow.github.io/sdk-neutrality-contract.json",
  "surface_stability_authority": "durable-workflow.v2.surface-stability.contract",
  "protocol_specs_authority": "durable-workflow.v2.platform-protocol-specs.catalog",
  "conformance_suite_authority": "durable-workflow.v2.platform-conformance.suite",
  "scope": {
    "goal": "Preserve protocol and contract neutrality so the Go prototype and future TypeScript, Java, and .NET SDKs can use the published protocol without a redesign.",
    "non_goal": "Ship a broad official SDK portfolio. First-party SDK breadth is intentionally narrow and grows only when adoption demand justifies it.",
    "present_priority": "Python is the current highest-value non-PHP path for existing users and is treated as a priority surface for parity coverage.",
    "future_posture": "Go has an approved, owned prototype with conformance pending. TypeScript, Java, .NET, and other languages are demand-driven. Public contracts must support these SDKs without breaking the wire protocol."
  },
  "sdk_breadth_policy": {
    "description": "The first-party roster records SDKs with published conformance scenarios. Approved prototypes, demand-driven languages, and embedded engines have separate entries.",
    "first_party": {
      "php_sdk": {
        "package": "durable-workflow/sdk",
        "package_url": "https://packagist.org/packages/durable-workflow/sdk",
        "language": "php",
        "posture": "priority",
        "role": "Framework-neutral standalone client and remote-worker SDK. Used to validate PHP control-plane and worker-protocol behavior across real process boundaries.",
        "conformance": {
          "scenario_catalog_schema": "durable-workflow.v2.platform-conformance.runtime-scenarios",
          "scenario_catalog_url": "https://durable-workflow.github.io/platform-conformance/signal-query-runtime-scenarios.json",
          "category": "signal_query_runtime_contract",
          "actor_ids": [
            "sdk_php",
            "php_sdk_client",
            "php_worker"
          ],
          "scenario_ids": [
            "published_artifact_install_only",
            "php_worker_cli_and_sdk_baseline",
            "python_worker_php_facing_and_cli_clients",
            "php_worker_python_and_cli_clients",
            "rust_worker_rust_php_python_clients",
            "php_worker_rust_client",
            "rust_replayed_instance_state_query_after_cold_restart"
          ]
        }
      },
      "python_sdk": {
        "package": "durable_workflow",
        "package_url": "https://pypi.org/project/durable-workflow/",
        "language": "python",
        "posture": "priority",
        "role": "Highest-value non-PHP SDK. Used to validate that the worker protocol, control plane, and replay fixtures behave the same way outside PHP.",
        "conformance": {
          "scenario_catalog_schema": "durable-workflow.v2.platform-conformance.runtime-scenarios",
          "scenario_catalog_url": "https://durable-workflow.github.io/platform-conformance/replay-runtime-scenarios.json",
          "category": "history_replay_bundles",
          "actor_ids": [
            "python_sdk_runtime"
          ],
          "scenario_ids": [
            "published_artifact_install_only",
            "python_completed_history_activity_replay",
            "python_completed_history_signal_update_replay",
            "python_completed_history_wait_condition_replay",
            "python_completed_history_version_marker_replay",
            "python_completed_history_saga_compensation_replay",
            "python_worker_restart_completed_query",
            "python_worker_restart_activity_state",
            "python_worker_restart_signal_update_state",
            "python_worker_restart_wait_condition_state",
            "python_worker_restart_version_marker_state",
            "python_worker_restart_saga_compensation_state",
            "python_code_divergence_refusal",
            "server_history_mutation_refusal",
            "malformed_history_refusal",
            "python_in_flight_signal_restart_timing"
          ]
        }
      },
      "rust_sdk": {
        "package": "durable-workflow",
        "package_url": "https://crates.io/crates/durable-workflow",
        "language": "rust",
        "posture": "priority",
        "role": "First-party deterministic workflow, activity, worker-service, and control-plane SDK. Used to validate replay, lifecycle, and codec interoperability outside PHP and Python.",
        "conformance": {
          "scenario_catalog_schema": "durable-workflow.v2.platform-conformance.runtime-scenarios",
          "scenario_catalog_url": "https://durable-workflow.github.io/platform-conformance/signal-query-runtime-scenarios.json",
          "category": "signal_query_runtime_contract",
          "actor_ids": [
            "rust_sdk",
            "rust_worker",
            "rust_sdk_client"
          ],
          "scenario_ids": [
            "published_artifact_install_only",
            "rust_worker_rust_php_python_clients",
            "python_worker_rust_client",
            "php_worker_rust_client",
            "rust_query_error_and_immutability",
            "rust_replayed_instance_state_query_after_cold_restart"
          ]
        }
      }
    },
    "approved_prototypes": {
      "go_sdk": {
        "language": "go",
        "posture": "approved_prototype",
        "repository_url": "https://github.com/durable-workflow/sdk-go",
        "module_path": "go.durable-workflow.com/sdk",
        "owner": "sdk-go",
        "adoption_signal": "Laravel Go v0.1.0 shipped durable workflows on 2026-12-02. The operator approved sdk-go as a priority on 2026-12-02.",
        "maintenance_commitment": "The sdk-go maintainer owns qualification and keeping the SDK represented in the conformance harness, protocol-spec catalog, and release authority manifest.",
        "conformance": {
          "status": "pending",
          "qualification_plan_url": "https://github.com/durable-workflow/sdk-go/issues/1",
          "replay_preview": {
            "scenario_catalog_url": "https://durable-workflow.github.io/platform-conformance/go-replay-preview-scenarios.json",
            "actor_ids": ["go_sdk_runtime"],
            "scenario_ids": [
              "go_completed_history_version_marker_replay",
              "go_worker_restart_version_marker_state"
            ],
            "evidence_url": "https://github.com/durable-workflow/server/actions/runs/47576865574"
          }
        },
        "protocol_contract_additions": {
          "payload_mapping_and_map_key_order": "https://github.com/durable-workflow/workflow/issues/1380",
          "sdk_behaviour_flags": "https://github.com/durable-workflow/workflow/issues/1378",
          "staged_patch_activation": "https://github.com/durable-workflow/workflow/issues/1379",
          "compiled_definition_identity": "https://github.com/durable-workflow/workflow/issues/1381"
        }
      }
    },
    "embedded_engines": {
      "php_workflow_engine": {
        "package": "durable-workflow/workflow",
        "package_url": "https://packagist.org/packages/durable-workflow/workflow",
        "language": "php",
        "role": "Embedded Laravel workflow engine and replay owner. It provides authoring, durable state, queue execution, replay persistence, and frozen history semantics without owning standalone client or remote-worker APIs.",
        "conformance": {
          "scenario_catalog_schema": "durable-workflow.v2.platform-conformance.runtime-scenarios",
          "scenario_catalog_url": "https://durable-workflow.github.io/platform-conformance/replay-runtime-scenarios.json",
          "category": "history_replay_bundles",
          "actor_ids": [
            "workflow_php_runtime"
          ],
          "scenario_ids": [
            "published_artifact_install_only",
            "php_completed_history_activity_replay",
            "php_completed_history_signal_update_replay",
            "php_completed_history_wait_condition_replay",
            "php_completed_history_version_marker_replay",
            "php_completed_history_saga_compensation_replay",
            "php_worker_restart_completed_query",
            "php_worker_restart_activity_state",
            "php_worker_restart_signal_update_state",
            "php_worker_restart_wait_condition_state",
            "php_worker_restart_version_marker_state",
            "php_worker_restart_saga_compensation_state",
            "php_code_divergence_refusal",
            "server_history_mutation_refusal",
            "malformed_history_refusal",
            "php_in_flight_signal_restart_timing"
          ]
        }
      }
    },
    "demand_driven": {
      "typescript_sdk": {
        "language": "typescript",
        "posture": "demand_driven",
        "note": "No first-party SDK exists. Public contracts must remain implementable in TypeScript without protocol redesign."
      },
      "java_sdk": {
        "language": "java",
        "posture": "demand_driven",
        "note": "No first-party SDK exists. Public contracts must remain implementable in Java without protocol redesign."
      },
      "dotnet_sdk": {
        "language": "dotnet",
        "posture": "demand_driven",
        "note": "No first-party SDK exists. Public contracts must remain implementable in .NET without protocol redesign."
      }
    },
    "expansion_criteria": {
      "adoption_signal": "A new first-party SDK is considered only when there is documented user demand the existing SDKs cannot serve.",
      "maintenance_commitment": "A candidate language must have an owner team willing to keep it on the conformance harness, the platform protocol-spec catalog, and the release authority manifest.",
      "no_protocol_redesign": "Adding a new SDK must not require breaking changes to the worker protocol, control plane, history event wire formats, or replay-fixture shapes. If it would, the protocol is the bug, not the SDK."
    }
  },
  "neutrality_rules": {
    "protocol_neutrality": {
      "requirement": "Public RPC and event surfaces use HTTP+JSON or AsyncAPI shapes that any HTTP-capable runtime can produce and consume. No language-specific RPC framing, no PHP-only or Python-only headers, and no transport that requires an existing first-party SDK to be parseable.",
      "rationale": "A future TypeScript, Go, Java, or .NET SDK must be able to drive the worker protocol and control plane using only the language's standard HTTP and JSON tools.",
      "authority": [
        {
          "kind": "protocol_spec",
          "id": "durable-workflow.v2.control-plane-api",
          "url": "https://durable-workflow.github.io/platform-protocol-specs/control-plane-api.openapi.yaml"
        },
        {
          "kind": "protocol_spec",
          "id": "durable-workflow.v2.worker-protocol-api",
          "url": "https://durable-workflow.github.io/platform-protocol-specs/worker-protocol-api.openapi.yaml"
        },
        {
          "kind": "protocol_spec",
          "id": "durable-workflow.v2.worker-protocol-stream",
          "url": "https://durable-workflow.github.io/platform-protocol-specs/worker-protocol-stream.asyncapi.yaml"
        }
      ],
      "how_to_apply": "Every public route documented in the protocol-spec catalog must validate against the published OpenAPI document. Any field that requires a first-party serialization library is either internal or covered by an explicit codec entry under `codec_neutrality`."
    },
    "codec_neutrality": {
      "requirement": "Every durable payload that crosses a public boundary advertises codec `avro`; no other public or engine-specific v2 codec is offered.",
      "rationale": "The fixed typed Avro Value schema and single-object framing are language-neutral. JSON remains the HTTP document transport, while PHP-specific v1 readers stay behind the internal import/drain boundary.",
      "authority": [
        {
          "kind": "protocol_spec",
          "id": "durable-workflow.v2.worker-protocol-api",
          "url": "https://durable-workflow.github.io/platform-protocol-specs/worker-protocol-api.openapi.yaml"
        },
        {
          "kind": "protocol_spec",
          "id": "durable-workflow.v2.cluster-info-envelope",
          "url": "https://durable-workflow.github.io/platform-protocol-specs/cluster-info-envelope.schema.json"
        }
      ],
      "how_to_apply": "Worker and control-plane contracts advertise exactly [\"avro\"]. Reject json-tagged, unknown, or untagged durable payloads with unsupported_payload_codec; never transcode or guess."
    },
    "error_shape_neutrality": {
      "requirement": "Public failure objects use a structured envelope of (`code`, `message`, optional `details`) where `code` is a stable string identifier. Language-specific exception class names, stack traces, or framework-internal error types are diagnostic only and must not be required for consumers to branch on.",
      "rationale": "A non-PHP, non-Python SDK has no way to map a PHP `Throwable` FQCN or a Python exception class to a meaningful failure category. Stable string codes allow every SDK to translate the failure into the language's native error type.",
      "authority": [
        {
          "kind": "protocol_spec",
          "id": "durable-workflow.v2.worker-protocol-api",
          "url": "https://durable-workflow.github.io/platform-protocol-specs/worker-protocol-api.openapi.yaml"
        },
        {
          "kind": "protocol_spec",
          "id": "durable-workflow.v2.repair-actionability-objects",
          "url": "https://durable-workflow.github.io/platform-protocol-specs/repair-actionability-objects.schema.json"
        }
      ],
      "how_to_apply": "New public failure shapes must declare the `code` vocabulary and mark exception class names, file paths, and line numbers as diagnostic-only under the field-visibility rule."
    },
    "type_identity_neutrality": {
      "requirement": "Workflow types, activity types, child workflow types, and exception types are identified by stable string names in every public contract. PHP class fully-qualified names and Python module paths are accepted as inputs from their respective SDKs but are normalized to a string identity before crossing a public surface.",
      "rationale": "A TypeScript SDK has no PHP autoloader and no Python module path. Type identity must be portable across runtimes; class names are an SDK-specific convenience, not a contract.",
      "authority": [
        {
          "kind": "protocol_spec",
          "id": "durable-workflow.v2.history-event-payloads",
          "url": "https://durable-workflow.github.io/platform-protocol-specs/history-event-payloads.schema.json"
        },
        {
          "kind": "protocol_spec",
          "id": "durable-workflow.v2.worker-protocol-api",
          "url": "https://durable-workflow.github.io/platform-protocol-specs/worker-protocol-api.openapi.yaml"
        }
      ],
      "how_to_apply": "New surface areas that emit or accept a workflow/activity/exception identifier must use the registered type name. Any field that leaks a class FQCN must be marked diagnostic-only."
    },
    "replay_fixture_neutrality": {
      "requirement": "Replay fixtures and golden history bundles are stored as language-neutral JSON conforming to the `history_event_payloads` and `replay_bundle` JSON Schemas. No serialized PHP objects, no Python pickles, no language-specific binary state in fixtures that any conforming SDK must replay.",
      "rationale": "A future SDK proves conformance by replaying the fixture catalog. If a fixture only round-trips through PHP `unserialize` or Python `pickle`, no other language can claim conformance against it.",
      "authority": [
        {
          "kind": "protocol_spec",
          "id": "durable-workflow.v2.history-event-payloads",
          "url": "https://durable-workflow.github.io/platform-protocol-specs/history-event-payloads.schema.json"
        },
        {
          "kind": "protocol_spec",
          "id": "durable-workflow.v2.replay-bundle",
          "url": "https://durable-workflow.github.io/platform-protocol-specs/replay-bundle.schema.json"
        },
        {
          "kind": "scenario_catalog",
          "id": "durable-workflow.v2.platform-conformance.runtime-scenarios",
          "category": "history_replay_bundles",
          "url": "https://durable-workflow.github.io/platform-conformance/replay-runtime-scenarios.json"
        }
      ],
      "how_to_apply": "Every replay input exercised by the published `history_replay_bundles` scenario catalog must validate against the `durable-workflow.v2.history-event-payloads` and `durable-workflow.v2.replay-bundle` schemas. A fixture that depends on a language-specific serializer is a contract violation."
    },
    "discovery_neutrality": {
      "requirement": "Every public surface family is reachable from `GET /api/cluster/info` and the `platform_protocol_specs` catalog. SDK authors must not have to read PHP source, Python source, CLI help text, or this repository's tests to discover a public contract.",
      "rationale": "Discovery is the entry point for any SDK author. If a contract is only discoverable by reading PHP code, building it in Go is harder than it needs to be.",
      "authority": [
        {
          "kind": "catalog",
          "id": "durable-workflow.v2.platform-protocol-specs.catalog",
          "url": "https://durable-workflow.github.io/platform-protocol-specs.json"
        },
        {
          "kind": "protocol_spec",
          "id": "durable-workflow.v2.cluster-info-envelope",
          "url": "https://durable-workflow.github.io/platform-protocol-specs/cluster-info-envelope.schema.json"
        }
      ],
      "how_to_apply": "New public surfaces must add a catalog entry (status `published`, `in_progress`, or `planned`) and a discovery endpoint reference before the surface ships in a stable release."
    },
    "documentation_neutrality": {
      "requirement": "Public-contract documentation describes shapes in language-neutral terms. Code samples may use PHP and Python, but the normative description must read as schema, route, and field semantics, not as PHP class behavior or Python type behavior.",
      "rationale": "A documentation page that says \"the response is a `WorkflowRunDescription` object\" is unhelpful to a TypeScript developer. The same page that says \"the response is the JSON object documented at `cluster_info_envelope` with fields X, Y, Z\" is portable.",
      "authority": [
        {
          "kind": "catalog",
          "id": "durable-workflow.v2.platform-protocol-specs.catalog",
          "url": "https://durable-workflow.github.io/platform-protocol-specs.json"
        },
        {
          "kind": "catalog",
          "id": "durable-workflow.v2.platform-conformance.suite",
          "url": "https://durable-workflow.github.io/platform-conformance-contract.json"
        }
      ],
      "how_to_apply": "New public-contract docs link to the protocol-spec catalog entry, name the discovery endpoint, and describe field-level semantics. PHP class names and Python type names appear only as SDK-specific examples."
    }
  },
  "audit_checklist": {
    "description": "Every new server, workflow, CLI, Waterline, or MCP surface must clear this checklist before promotion to `stable`. The checklist is a standing review item on the release PR.",
    "steps": {
      "protocol_review": {
        "rule": "protocol_neutrality",
        "check": "The surface is described by an OpenAPI, AsyncAPI, or JSON Schema document in the platform-protocol-specs catalog. No required field depends on a PHP-only or Python-only serializer."
      },
      "codec_review": {
        "rule": "codec_neutrality",
        "check": "Every durable payload field uses codec avro. No other public or engine-specific v2 codec is offered or accepted."
      },
      "error_shape_review": {
        "rule": "error_shape_neutrality",
        "check": "Failures emit a stable string `code`. PHP `Throwable` FQCNs and Python exception class names are marked diagnostic-only."
      },
      "type_identity_review": {
        "rule": "type_identity_neutrality",
        "check": "Workflow, activity, child workflow, and exception identity uses registered string names. Class FQCNs do not appear in guaranteed fields."
      },
      "replay_fixture_review": {
        "rule": "replay_fixture_neutrality",
        "check": "Any history or replay fixture introduced with the surface is JSON-shaped and validates against the `history_event_payloads` and `replay_bundle` schemas."
      },
      "discovery_review": {
        "rule": "discovery_neutrality",
        "check": "The surface is reachable from `GET /api/cluster/info`. The protocol-spec catalog has an entry with the correct surface family and owner repo."
      },
      "documentation_review": {
        "rule": "documentation_neutrality",
        "check": "Public docs describe the surface in schema/route/field terms. Language-specific behavior appears in SDK examples, not in the normative section."
      },
      "future_sdk_thought_experiment": {
        "rule": "protocol_neutrality",
        "check": "Reviewer can describe, in two sentences, how a TypeScript or Go SDK would consume the new surface using only the published spec and a standard HTTP+JSON toolchain. If the answer requires a first-party SDK, the surface is not neutral."
      }
    }
  },
  "audit_scope_surface_families": [
    "server_api",
    "worker_protocol",
    "cli_json",
    "waterline_api",
    "mcp_discovery_results",
    "cluster_info_manifests"
  ],
  "release_gates": {
    "description": "A release that introduces a new public surface family or promotes an existing surface from `prerelease` or `experimental` to `stable` must record the audit checklist outcome on the release PR.",
    "gates": {
      "audit_recorded": "The release PR description (or a linked design note) states which audit steps were applied and links the protocol-spec catalog entry, the conformance fixture, and the discovery entry for the new surface.",
      "no_php_or_python_only_required_fields": "No guaranteed field on a `stable` surface requires the `workflow-serializer-y`, `workflow-serializer-base64`, PHP `serialize`, or Python `pickle` codec.",
      "universal_codec_advertised": "Worker protocol negotiation advertises exactly one universal codec, avro, as documented by `durable-workflow.v2.worker-protocol-api`.",
      "fixture_schema_validated": "New replay inputs validate against the published `durable-workflow.v2.history-event-payloads` and `durable-workflow.v2.replay-bundle` schemas.",
      "discovery_entry_present": "New public surfaces have a `platform_protocol_specs` catalog entry with a non-empty `surface_family`, `owner_repo`, and `format`."
    },
    "enforcement": {
      "machine_authority": "https://durable-workflow.github.io/sdk-neutrality-contract.json",
      "machine": "Release CI resolves every authority URL, protocol/schema ID, and conformance scenario ID in the public contract. It also cross-references the audit scope against the surface stability families and rejects replay inputs that do not validate against the published JSON Schemas.",
      "human": "Release reviewers tick the SDK-neutrality audit on every release PR that adds or promotes a public surface. The reviewer is responsible for the future-SDK thought experiment."
    }
  }
}
