@@ -378,6 +378,32 @@ def test_malformed_golden_wire_must_be_canonical_base64(self) -> None:
378378 VALIDATOR ._avro_golden_fixture (fixture , "golden.json" )
379379
380380
381+ class PythonSemanticNeutralityTest (unittest .TestCase ):
382+ def test_module_class_and_function_docstrings_are_source_trivia (self ) -> None :
383+ base = '''\
384+ """Base module documentation."""
385+
386+ class Replayer:
387+ """Base class documentation."""
388+
389+ async def replay(self, history):
390+ """Base function documentation."""
391+ return tuple(history)
392+ '''
393+ current = '''\
394+ """Current module documentation."""
395+
396+ class Replayer:
397+ """Current class documentation."""
398+
399+ async def replay(self, history):
400+ """Current function documentation."""
401+ return tuple(history)
402+ '''
403+
404+ self .assertTrue (VALIDATOR ._python_change_is_semantically_neutral (base , current ))
405+
406+
381407class WorkerCodecGuardTest (unittest .TestCase ):
382408 def setUp (self ) -> None :
383409 self .temporary = tempfile .TemporaryDirectory (prefix = "regression-corpus-worker-guard-" )
@@ -396,6 +422,12 @@ def _command_payload_codec(codec):
396422 return codec or "avro"
397423
398424
425+ def replay_history(history):
426+ '''Replay durable history into a stable sequence.'''
427+ mode = "replay-history"
428+ return mode, tuple(history)
429+
430+
399431class Worker:
400432 async def validate_update(self, history, codec, approved):
401433 codec = _validate_payload_codec(codec)
@@ -499,11 +531,49 @@ def test_ignored_update_symbol_does_not_count_as_replay_change(self) -> None:
499531
500532 self .assertFalse (self ._replay_guard_matches ())
501533
502- def test_nonignored_history_symbol_still_counts_as_replay_change (self ) -> None :
534+ def test_docstring_only_edit_inside_replay_symbol_is_neutral (self ) -> None :
535+ source = self .root / "src/durable_workflow/worker.py"
536+ source .write_text (
537+ source .read_text (encoding = "utf-8" ).replace (
538+ "Replay durable history into a stable sequence." ,
539+ "Reconstruct durable history for a query." ,
540+ ),
541+ encoding = "utf-8" ,
542+ )
543+
544+ self .assertFalse (self ._replay_guard_matches ())
545+
546+ def test_logic_edit_inside_replay_symbol_remains_related (self ) -> None :
547+ source = self .root / "src/durable_workflow/worker.py"
548+ source .write_text (
549+ source .read_text (encoding = "utf-8" ).replace (
550+ "return mode, tuple(history)" ,
551+ "return mode, list(history)" ,
552+ ),
553+ encoding = "utf-8" ,
554+ )
555+
556+ self .assertTrue (self ._replay_guard_matches ())
557+
558+ def test_non_docstring_literal_edit_inside_replay_symbol_remains_related (self ) -> None :
503559 source = self .root / "src/durable_workflow/worker.py"
504560 source .write_text (
505- source .read_text (encoding = "utf-8" )
506- + "\n \n def replay_history(history):\n return tuple(history)\n " ,
561+ source .read_text (encoding = "utf-8" ).replace (
562+ 'mode = "replay-history"' ,
563+ 'mode = "strict-replay-history"' ,
564+ ),
565+ encoding = "utf-8" ,
566+ )
567+
568+ self .assertTrue (self ._replay_guard_matches ())
569+
570+ def test_unparseable_python_change_remains_related (self ) -> None :
571+ source = self .root / "src/durable_workflow/worker.py"
572+ source .write_text (
573+ source .read_text (encoding = "utf-8" ).replace (
574+ 'mode = "replay-history"' ,
575+ 'mode = "replay-history' ,
576+ ),
507577 encoding = "utf-8" ,
508578 )
509579
0 commit comments