Skip to content

Commit 347048c

Browse files
committed
Run newly admitted codec evidence through the official Python binding
1 parent 58a730a commit 347048c

2 files changed

Lines changed: 69 additions & 12 deletions

File tree

‎scripts/ci/test-validate-regression-corpus.py‎

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,13 @@ def setUp(self) -> None:
570570
"tests/fixtures/codec_archive/preexisting.json",
571571
_codec_fixture("preexisting"),
572572
)
573+
candidate_failure = _codec_fixture("candidate-failure")
574+
candidate_failure["value"] = {"type": "long", "value": 2}
575+
candidate_failure["framing"]["wire_base64"] = "BA=="
576+
self._write_json(
577+
"tests/fixtures/codec_archive/candidate-failure.json",
578+
candidate_failure,
579+
)
573580
self._write_text(
574581
"src/durable_workflow/serializer.py",
575582
"def encode(value):\n return value\n",
@@ -590,7 +597,7 @@ def setUp(self) -> None:
590597
source = (args.source_root / "src/durable_workflow/serializer.py").read_text()
591598
if identity == "candidate-failure":
592599
raise SystemExit(1)
593-
if identity == "unrelated":
600+
if identity in {"preexisting", "unrelated"}:
594601
raise SystemExit(0)
595602
raise SystemExit(0 if "return str(value)" in source else 1)
596603
""",
@@ -800,6 +807,50 @@ def test_selector_expansion_does_not_turn_existing_file_into_growth(self) -> Non
800807
):
801808
self._validate()
802809

810+
def test_policy_only_selector_expansion_runs_candidate_binding(self) -> None:
811+
self.policy["categories"]["codec"]["fixtures"].append(
812+
{
813+
"glob": "tests/fixtures/codec_archive/preexisting.json",
814+
"format": "codec-regression-v1",
815+
}
816+
)
817+
self._write_json("regression-corpus-policy.json", self.policy)
818+
819+
result = self._validate()
820+
821+
self.assertEqual(result["counts"]["codec"]["added"], 0)
822+
self.assertFalse(result["counts"]["codec"]["related_change"])
823+
self.assertEqual(result["counts"]["codec"]["revision_verified"], 1)
824+
825+
def test_policy_only_selector_expansion_rejects_candidate_failure(self) -> None:
826+
self.policy["categories"]["codec"]["fixtures"].append(
827+
{
828+
"glob": "tests/fixtures/codec_archive/candidate-failure.json",
829+
"format": "codec-regression-v1",
830+
}
831+
)
832+
self._write_json("regression-corpus-policy.json", self.policy)
833+
834+
with self.assertRaisesRegex(
835+
VALIDATOR.CorpusError,
836+
"does not pass on the candidate through the official Python binding",
837+
):
838+
self._validate()
839+
840+
def test_rename_into_selected_path_rejects_candidate_failure(self) -> None:
841+
source = "tests/fixtures/codec_archive/candidate-failure.json"
842+
destination = "tests/fixtures/codec_regressions/candidate-failure.json"
843+
self._git("mv", source, destination)
844+
845+
changed, added = VALIDATOR._changed_paths(self.root, "HEAD")
846+
self.assertEqual(changed, {source, destination})
847+
self.assertEqual(added, set())
848+
with self.assertRaisesRegex(
849+
VALIDATOR.CorpusError,
850+
"does not pass on the candidate through the official Python binding",
851+
):
852+
self._validate()
853+
803854
def test_guarded_change_accepts_counterfactual_evidence(self) -> None:
804855
self._write_text(
805856
"src/durable_workflow/serializer.py",

‎scripts/ci/validate-regression-corpus.py‎

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,7 @@ def _verify_new_codec_evidence(
841841
)
842842
if candidate.returncode != 0:
843843
raise CorpusError(
844-
f"new codec fixture {path} does not pass on the candidate "
844+
f"newly admitted codec fixture {path} does not pass on the candidate "
845845
"through the official Python binding: "
846846
f"{_process_detail(candidate)}"
847847
)
@@ -872,7 +872,7 @@ def _verify_new_codec_evidence(
872872
)
873873
if defective.returncode == 0:
874874
raise CorpusError(
875-
f"new codec fixture {path} also passes on the defective base; "
875+
f"newly admitted codec fixture {path} also passes on the defective base; "
876876
"it does not reproduce the guarded codec change"
877877
)
878878

@@ -1260,19 +1260,25 @@ def validate(
12601260
fixture = _object(raw_fixture, "categories.codec.fixtures[]")
12611261
if _string(fixture["format"], "fixture.format") == "codec-regression-v1":
12621262
codec_fixture_patterns.append(_string(fixture["glob"], "fixture.glob"))
1263-
new_codec_fixture_paths = sorted(
1264-
{
1265-
item.path
1266-
for item in current_evidence
1267-
if item.category == "codec"
1268-
and item.path in added_paths
1269-
and any(_matches(item.path, pattern) for pattern in codec_fixture_patterns)
1270-
}
1263+
current_codec_fixture_paths = {
1264+
item.path
1265+
for item in current_evidence
1266+
if item.category == "codec" and any(_matches(item.path, pattern) for pattern in codec_fixture_patterns)
1267+
}
1268+
base_codec_fixture_paths = {
1269+
item.path
1270+
for item in base_evidence
1271+
if item.category == "codec" and any(_matches(item.path, pattern) for pattern in codec_fixture_patterns)
1272+
}
1273+
newly_admitted_codec_fixture_paths = (
1274+
sorted(current_codec_fixture_paths - base_codec_fixture_paths)
1275+
if base_ref and not ZERO_COMMIT.fullmatch(base_ref)
1276+
else []
12711277
)
12721278
revision_verified = _verify_new_codec_evidence(
12731279
root=root,
12741280
base_files=base_files,
1275-
fixture_paths=new_codec_fixture_paths,
1281+
fixture_paths=newly_admitted_codec_fixture_paths,
12761282
require_defective_base=related,
12771283
python_executable=python_executable,
12781284
codec_runner=codec_runner,

0 commit comments

Comments
 (0)