1515import sys
1616from collections .abc import Mapping , Sequence
1717from datetime import datetime , timezone
18+ from importlib import metadata
1819from pathlib import Path
1920from 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(
307324def _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 },
0 commit comments