Skip to content

Commit 170a4ab

Browse files
authored
Fix stable replay report identity (#141)
* Verify installed SDK identity in replay conformance * Prepare stable 2.5.11 replay identity correction * Retain installed replay identity command regression --------- Co-authored-by: Durable Workflow <support@durable-workflow.com>
1 parent caf006b commit 170a4ab

7 files changed

Lines changed: 171 additions & 22 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
## [2.5.11] - 2026-10-13
10+
11+
### Fixed
12+
- Verify the installed Python distribution identity in offline replay conformance
13+
reports. Mismatched SDK pins or missing metadata fail explicitly; a declared
14+
platform tuple no longer claims verified artifact installation.
15+
916
## [2.5.10] - 2026-10-13
1017

1118
### Fixed

‎README.md‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,14 @@ for immutable context, operation policies, shielded cleanup and recovery.
135135

136136
## Development
137137

138+
The installed `durable-workflow-replay-conformance` command runs an offline
139+
Python replay shard. Its `sdk-python` artifact pin must match the installed
140+
distribution version reported by `importlib.metadata.version("durable-workflow")`.
141+
The report records that installed identity separately from the declared platform
142+
tuple and fails if metadata is missing or the SDK pin differs. Replay success
143+
does not prove installation or execution of the other declared artifacts; the
144+
aggregate runner supplies its own verified installation receipts.
145+
138146
```bash
139147
pip install -e '.[dev]'
140148
ruff check src/ tests/

‎pyproject.toml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "durable-workflow"
7-
version = "2.5.10"
7+
version = "2.5.11"
88
description = "Python client and worker SDK for Durable Workflow Cloud and self-hosted Server"
99
readme = "README.md"
1010
requires-python = ">=3.10"
@@ -71,8 +71,8 @@ durable-workflow-replay-conformance = "durable_workflow.replay_conformance:main"
7171
durable-workflow-workflow-updates-conformance = "durable_workflow.workflow_updates_conformance:main"
7272

7373
[tool.durable-workflow]
74-
product-train = "2.5.10"
75-
registry-version = "2.5.10"
74+
product-train = "2.5.11"
75+
registry-version = "2.5.11"
7676
supported-server-versions = "2.5.16"
7777
worker-protocol-version = "1.20"
7878
control-plane-version = "2"

‎src/durable_workflow/replay_conformance.py‎

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import sys
1616
from collections.abc import Mapping, Sequence
1717
from datetime import datetime, timezone
18+
from importlib import metadata
1819
from pathlib import Path
1920
from typing import Any
2021

@@ -204,6 +205,17 @@ def compose_report(
204205
started_at = _timestamp()
205206
versions = _canonical_artifact_metadata(dict(artifact_versions or {}))
206207
sources = _canonical_artifact_metadata(dict(artifact_sources or {}))
208+
try:
209+
installed_version = metadata.version("durable-workflow")
210+
except metadata.PackageNotFoundError:
211+
installed_version = None
212+
identity = {
213+
"runtime": "sdk-python",
214+
"package": "durable-workflow",
215+
"version": installed_version,
216+
"version_source": "installed_distribution_metadata" if installed_version else "unavailable",
217+
"declared_version": _artifact_metadata(versions, "sdk-python"),
218+
}
207219
scenario_results: dict[str, dict[str, Any]] = {}
208220
findings: list[dict[str, Any]] = []
209221
finding_links: dict[str, list[dict[str, Any]]] = {}
@@ -212,7 +224,7 @@ def compose_report(
212224
scenario_results,
213225
findings,
214226
finding_links,
215-
_published_artifact_scenario(versions, sources),
227+
_published_artifact_scenario(versions, sources, installed_version),
216228
)
217229

218230
for family, scenario_id in COMPLETED_SCENARIOS.items():
@@ -242,6 +254,9 @@ def compose_report(
242254
has_failures = any(
243255
scenario.get("status") != "pass" for scenario in scenario_results.values()
244256
)
257+
for scenario in scenario_results.values():
258+
scenario["implementation_identity"] = dict(identity)
259+
scenario["artifact_tuple_evidence"] = "declared"
245260

246261
return {
247262
"schema": RESULT_SCHEMA,
@@ -252,6 +267,8 @@ def compose_report(
252267
"finished_at": _timestamp(),
253268
"artifact_versions": versions,
254269
"artifact_sources": sources,
270+
"artifact_tuple_evidence": "declared",
271+
"implementation_identity": identity,
255272
"runtime_matrix": {
256273
"runtimes": ["sdk-python"],
257274
},
@@ -307,6 +324,7 @@ def _append_scenario(
307324
def _published_artifact_scenario(
308325
artifact_versions: Mapping[str, str],
309326
artifact_sources: Mapping[str, str],
327+
installed_version: str | None,
310328
) -> dict[str, Any]:
311329
missing_versions: list[str] = []
312330
missing_sources: list[str] = []
@@ -338,14 +356,14 @@ def _published_artifact_scenario(
338356
untrusted_sources[artifact] = source
339357

340358
missing = sorted(set(missing_versions + missing_sources))
341-
status = (
342-
"pass"
343-
if not missing
344-
and not rejected_versions
345-
and not forbidden_sources
346-
and not untrusted_sources
347-
else "fail"
348-
)
359+
declarations_valid = not missing and not rejected_versions and not forbidden_sources and not untrusted_sources
360+
declared_version = _artifact_metadata(artifact_versions, "sdk-python")
361+
identity_error = None
362+
if not installed_version:
363+
identity_error = "installed_sdk_metadata_missing"
364+
elif declared_version != installed_version:
365+
identity_error = "installed_sdk_version_mismatch"
366+
status = "pass" if declarations_valid and identity_error is None else "fail"
349367

350368
return _scenario(
351369
"published_artifact_install_only",
@@ -361,8 +379,14 @@ def _published_artifact_scenario(
361379
"rejected_versions": rejected_versions,
362380
"forbidden_sources": forbidden_sources,
363381
"untrusted_sources": untrusted_sources,
364-
"published_artifacts_only": status == "pass",
365-
"published_install_tuple_proven": status == "pass",
382+
"declared_artifacts_published_only": bool(declarations_valid),
383+
"declared_sdk_version": declared_version,
384+
"installed_sdk_version": installed_version,
385+
"sdk_identity_error": identity_error,
386+
"sdk_version_matches": bool(installed_version and declared_version == installed_version),
387+
"artifact_tuple_evidence": "declared",
388+
"published_artifacts_only": False,
389+
"published_install_tuple_proven": False,
366390
},
367391
)
368392

@@ -589,11 +613,6 @@ def _scenario(
589613
"scenario_id": scenario_id,
590614
"status": status,
591615
"published_artifact_versions": dict(artifact_versions),
592-
"implementation_identity": {
593-
"runtime": "sdk-python",
594-
"package": "durable-workflow",
595-
"version": _artifact_metadata(artifact_versions, "sdk-python"),
596-
},
597616
"runtime_matrix": {
598617
"runtimes": ["sdk-python"],
599618
},
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"$schema": "https://durable-workflow.github.io/schemas/replay-regression-v1.json",
3+
"fixture_schema": "durable-workflow.replay-regression/v1",
4+
"id": "installed-replay-sdk-identity-mismatch",
5+
"protocol_version": "1.20",
6+
"bindings": ["python"],
7+
"workflow": {
8+
"type": "sdk.replay-conformance-report",
9+
"input": [{
10+
"artifact_versions": {
11+
"server": "2.6.1",
12+
"cli": "2.2.3",
13+
"workflow-php": "2.5.12",
14+
"sdk-python": "2.5.9",
15+
"waterline": "2.10.0"
16+
},
17+
"artifact_sources": {
18+
"server": "published_docker_image",
19+
"cli": "github_release_asset",
20+
"workflow-php": "packagist_package",
21+
"sdk-python": "pypi_package",
22+
"waterline": "packagist_package"
23+
}
24+
}]
25+
},
26+
"command_sequence": [{
27+
"type": "replay_conformance_report",
28+
"outcome": "fail",
29+
"sdk_identity_error": "installed_sdk_version_mismatch",
30+
"declared_sdk_version": "2.5.9",
31+
"published_install_tuple_proven": false
32+
}],
33+
"expected": {
34+
"command_sequence": [{
35+
"type": "replay_conformance_report",
36+
"outcome": "fail",
37+
"sdk_identity_error": "installed_sdk_version_mismatch",
38+
"declared_sdk_version": "2.5.9",
39+
"published_install_tuple_proven": false
40+
}]
41+
},
42+
"provenance": {
43+
"issue": "https://github.com/durable-workflow/sdk-python/issues/139",
44+
"observed_installed_sdk": "2.5.10",
45+
"observed_old_outcome": "pass",
46+
"scope": "offline replay conformance report; other artifacts are declarations"
47+
}
48+
}

‎tests/test_replay_conformance.py‎

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
from __future__ import annotations
22

33
import json
4+
from importlib import metadata
45
from pathlib import Path
56
from typing import Any
67

8+
import pytest
9+
710
from durable_workflow.replay_conformance import (
811
COVERAGE_SCOPE,
912
RESULT_SCHEMA,
@@ -25,6 +28,11 @@ def artifact_versions() -> dict[str, str]:
2528
}
2629

2730

31+
@pytest.fixture(autouse=True)
32+
def installed_sdk_metadata(monkeypatch: pytest.MonkeyPatch) -> None:
33+
monkeypatch.setattr(metadata, "version", lambda package: "0.4.73")
34+
35+
2836
def artifact_sources() -> dict[str, str]:
2937
return {
3038
"server": "docker_image",
@@ -81,7 +89,7 @@ def test_compose_report_emits_python_replay_conformance_shard() -> None:
8189
assert indexed[scenario_id]["status"] == "pass"
8290

8391

84-
def test_report_proves_published_artifact_install_policy() -> None:
92+
def test_report_validates_declared_tuple_without_claiming_installation_proof() -> None:
8593
report = compose_report(
8694
artifact_versions=artifact_versions(),
8795
artifact_sources=artifact_sources(),
@@ -90,13 +98,46 @@ def test_report_proves_published_artifact_install_policy() -> None:
9098
observed = published["observed_outputs"]
9199

92100
assert published["status"] == "pass"
93-
assert observed["published_artifacts_only"] is True
94-
assert observed["published_install_tuple_proven"] is True
101+
assert observed["published_artifacts_only"] is False
102+
assert observed["published_install_tuple_proven"] is False
103+
assert observed["declared_artifacts_published_only"] is True
104+
assert observed["artifact_tuple_evidence"] == "declared"
105+
assert observed["installed_sdk_version"] == "0.4.73"
106+
assert observed["sdk_version_matches"] is True
107+
assert observed["sdk_identity_error"] is None
108+
assert report["implementation_identity"]["version"] == "0.4.73"
95109
assert observed["missing_artifacts"] == []
96110
assert observed["artifact_sources"]["server"] == "docker_image"
97111
assert observed["artifact_sources"]["sdk-python"] == "pypi_package"
98112

99113

114+
def test_report_rejects_declared_sdk_version_mismatch(monkeypatch: pytest.MonkeyPatch) -> None:
115+
monkeypatch.setattr(metadata, "version", lambda package: "2.5.10")
116+
report = compose_report(artifact_versions=artifact_versions(), artifact_sources=artifact_sources())
117+
install = scenarios(report)["published_artifact_install_only"]
118+
assert report["outcome"] == "fail"
119+
assert install["status"] == "fail"
120+
assert install["observed_outputs"]["installed_sdk_version"] == "2.5.10"
121+
assert install["observed_outputs"]["declared_sdk_version"] == "0.4.73"
122+
assert install["observed_outputs"]["sdk_identity_error"] == "installed_sdk_version_mismatch"
123+
assert install["observed_outputs"]["published_install_tuple_proven"] is False
124+
assert all(scenario["implementation_identity"]["version"] == "2.5.10" for scenario in report["scenario_results"])
125+
assert report["finding_links"]["published_artifact_install_only"]
126+
127+
128+
def test_report_rejects_missing_installed_sdk_metadata(monkeypatch: pytest.MonkeyPatch) -> None:
129+
def missing_metadata(package: str) -> str:
130+
raise metadata.PackageNotFoundError(package)
131+
132+
monkeypatch.setattr(metadata, "version", missing_metadata)
133+
report = compose_report(artifact_versions=artifact_versions(), artifact_sources=artifact_sources())
134+
install = scenarios(report)["published_artifact_install_only"]
135+
assert report["outcome"] == "fail"
136+
assert install["observed_outputs"]["sdk_identity_error"] == "installed_sdk_metadata_missing"
137+
assert install["implementation_identity"]["version"] is None
138+
assert install["observed_outputs"]["published_install_tuple_proven"] is False
139+
140+
100141
def test_report_rejects_missing_versions_and_sources() -> None:
101142
report = compose_report(
102143
artifact_versions={"sdk-python": "0.4.73"},

‎tests/test_replay_regression_corpus.py‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import json
44
from collections.abc import Mapping, Sequence
5+
from importlib import metadata
56
from pathlib import Path
67
from typing import Any
78
from unittest.mock import AsyncMock
@@ -11,6 +12,7 @@
1112
from durable_workflow import Replayer, Worker, serializer, workflow
1213
from durable_workflow.client import PROTOCOL_VERSION, Client, WorkflowExecution, WorkflowStreamAppendItem
1314
from durable_workflow.errors import NonDeterministicReplayError, WorkflowCancelled, WorkflowPayloadDecodeError
15+
from durable_workflow.replay_conformance import compose_report
1416
from durable_workflow.workflow import (
1517
LocalActivityExecutionAborted,
1618
WorkflowContext,
@@ -371,6 +373,27 @@ def _execute_fixture(fixture: dict[str, Any]) -> list[dict[str, Any]]:
371373
assert isinstance(workflow, dict)
372374
workflow_type = workflow.get("type")
373375
assert isinstance(workflow_type, str) and workflow_type
376+
if workflow_type == "sdk.replay-conformance-report":
377+
# This public command executes the SDK's offline replay scenarios. Its
378+
# regression input is artifact declarations, not an invented history.
379+
assert "history" not in fixture
380+
inputs = workflow.get("input")
381+
assert isinstance(inputs, list) and len(inputs) == 1 and isinstance(inputs[0], dict)
382+
report = compose_report(**inputs[0])
383+
install = next(scenario for scenario in report["scenario_results"]
384+
if scenario["scenario_id"] == "published_artifact_install_only")
385+
observed = install["observed_outputs"]
386+
commands = [{
387+
"type": "replay_conformance_report",
388+
"outcome": report["outcome"],
389+
"sdk_identity_error": observed.get("sdk_identity_error"),
390+
"declared_sdk_version": observed.get("declared_sdk_version"),
391+
"published_install_tuple_proven": observed["published_install_tuple_proven"],
392+
}]
393+
_assert_matches(fixture["command_sequence"], commands, f"{fixture['id']}.command_sequence")
394+
_assert_matches(fixture["expected"], {"command_sequence": commands}, f"{fixture['id']}.expected")
395+
assert report["implementation_identity"]["version"] == metadata.version("durable-workflow")
396+
return commands
374397
assert workflow_type in WORKFLOW_TYPES, (
375398
f"replay fixture workflow {workflow_type!r} has no Python implementation; "
376399
"register its reproducer workflow in WORKFLOWS"
@@ -462,6 +485,9 @@ def test_checked_in_replay_regression_corpus_uses_official_replayer(
462485
assert isinstance(workflow, dict)
463486
expected = fixture.get("expected")
464487
assert isinstance(expected, dict) and expected
488+
if workflow.get("type") == "sdk.replay-conformance-report":
489+
_execute_fixture(fixture)
490+
return
465491
expected_error = expected.get("error")
466492
expected_replay_error = fixture.get("expected_replay_error")
467493
if isinstance(expected_replay_error, dict):

0 commit comments

Comments
 (0)