Skip to content

Commit 433f945

Browse files
luisleo526claude
andcommitted
tests: expect contract revision 1.3 in the selected-window declaration (EN-115)
Red-first step for the EN-115 declaration flip: the selected-window tests now expect CONTRACT_REVISIONS == ("1.3",), the probe to print ["1.3"] and no "1.3-parity" literal, and the AST guard to pin one "1.3" string while refusing ("1.3-parity",), ("1.3", "1.3-parity") and ("1.3-parity", "1.3"). On this commit's code the module still declares ("1.3-parity",), so these expectations fail for the intended reason. Co-Authored-By: Claude Code <[email protected]>
1 parent 8c4cc4d commit 433f945

1 file changed

Lines changed: 31 additions & 32 deletions

File tree

‎tests/test_run_json_selected_window.py‎

Lines changed: 31 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -993,15 +993,15 @@ def test_capability_record_when_unsupported_claims_nothing(self):
993993
on["results_digest_platform"]), (1, "selected-window/v1", 2,
994994
["full/v1"], None, None, None))
995995

996-
def test_the_supported_record_declares_the_parity_revision_alone_never_the_full_one(self):
997-
# A build with value parity on tested cases and typed codes (without a completeness
998-
# proof, EN-115) emits selected_window_contract_revisions == ["1.3-parity"], never ["1.3"].
996+
def test_the_supported_record_declares_the_full_revision_alone_never_the_parity_one(self):
997+
# A build with the section-4 producers and manifest and the completeness proof
998+
# (EN-115) emits selected_window_contract_revisions == ["1.3"], never ["1.3-parity"].
999999
# The literals are written out here, not read from the module.
10001000
supported = {
10011001
"engine": "pineforge",
10021002
"capabilities": {
10031003
"selected_window_wire_version": 1,
1004-
"selected_window_contract_revisions": ["1.3-parity"],
1004+
"selected_window_contract_revisions": ["1.3"],
10051005
"report_policy": "selected-window/v1",
10061006
"fingerprint_version": 2,
10071007
"report_shapes": ["full/v1"],
@@ -1020,39 +1020,39 @@ def test_the_supported_record_declares_the_parity_revision_alone_never_the_full_
10201020
self.assertEqual(swr.capabilities_record(False), unsupported)
10211021
revisions = (
10221022
swr.capabilities_record(True)["capabilities"]["selected_window_contract_revisions"])
1023-
self.assertEqual(revisions, ["1.3-parity"])
1023+
self.assertEqual(revisions, ["1.3"])
10241024
self.assertEqual(len(revisions), 1) # a singleton ...
1025-
self.assertNotIn("1.3", revisions) # ... that is never the full revision
1025+
self.assertNotIn("1.3-parity", revisions) # ... that is never the parity revision
10261026
self.assertEqual(
10271027
swr.capabilities_record(False)["capabilities"]["selected_window_contract_revisions"],
10281028
[]) # unsupported lists nothing at all
1029-
self.assertEqual(swr.CONTRACT_REVISIONS, ("1.3-parity",)) # the one constant
1029+
self.assertEqual(swr.CONTRACT_REVISIONS, ("1.3",)) # the one constant
10301030

10311031
def test_the_declared_revisions_are_a_fresh_list_of_the_one_constant(self):
10321032
first = swr.capabilities_record(True)["capabilities"]["selected_window_contract_revisions"]
1033-
first.append("1.3") # a caller that edits its copy changes neither the constant ...
1034-
self.assertEqual(swr.CONTRACT_REVISIONS, ("1.3-parity",))
1033+
first.append("1.3-parity") # a caller that edits its copy changes neither the constant ...
1034+
self.assertEqual(swr.CONTRACT_REVISIONS, ("1.3",))
10351035
again = swr.capabilities_record(True)["capabilities"]["selected_window_contract_revisions"]
1036-
self.assertEqual(again, ["1.3-parity"]) # ... nor the next record
1036+
self.assertEqual(again, ["1.3"]) # ... nor the next record
10371037
self.assertIsNot(first, again)
10381038

1039-
def test_without_a_completeness_proof_the_probe_declares_1_3_parity_only(self):
1040-
# Under amendment 6, "1.3" pairs only with value_ownership "complete", and no
1039+
def test_with_a_completeness_proof_the_probe_declares_1_3_only(self):
1040+
# Under amendment 6, "1.3" pairs only with value_ownership "complete", and the
10411041
# completeness proof has run (EN-115). Both capabilities_record(True) and the
1042-
# --capabilities-json probe must declare ["1.3-parity"] alone, never ["1.3"].
1043-
self.assertEqual(swr.CONTRACT_REVISIONS, ("1.3-parity",))
1042+
# --capabilities-json probe must declare ["1.3"] alone, never ["1.3-parity"].
1043+
self.assertEqual(swr.CONTRACT_REVISIONS, ("1.3",))
10441044
record = swr.capabilities_record(True)["capabilities"]
1045-
self.assertEqual(record["selected_window_contract_revisions"], ["1.3-parity"])
1046-
self.assertNotIn("1.3", record["selected_window_contract_revisions"])
1045+
self.assertEqual(record["selected_window_contract_revisions"], ["1.3"])
1046+
self.assertNotIn("1.3-parity", record["selected_window_contract_revisions"])
10471047
lib = FakeLib(full_plan())
10481048
FakePlanner.reset(None)
10491049
with mock.patch.object(run_json, "load_strategy", lambda p: lib), \
10501050
mock.patch.object(swp, "SelectedPrimaryPlanner", FakePlanner):
10511051
status, out, _ = run_main(["--so", "x.so", "--capabilities-json"])
10521052
self.assertEqual(status, 0)
10531053
probed = json.loads(out)["capabilities"]["selected_window_contract_revisions"]
1054-
self.assertEqual(probed, ["1.3-parity"])
1055-
self.assertNotIn("1.3", probed)
1054+
self.assertEqual(probed, ["1.3"])
1055+
self.assertNotIn("1.3-parity", probed)
10561056

10571057

10581058
# --- admission: nothing is touched before it passes --------------------------
@@ -1808,11 +1808,11 @@ def test_capabilities_probe_reports_a_supported_runtime_without_an_ohlcv(self):
18081808
status, out, _ = run_main(["--so", "x.so", "--capabilities-json"])
18091809
self.assertEqual((status, json.loads(out)), (0, swr.capabilities_record(True)))
18101810
self.assertEqual(lib.calls, []) # nothing was constructed or run
1811-
# The probe's real stdout carries the parity contract revision alone, not the full revision.
1811+
# The probe's real stdout carries the full contract revision alone, not the parity revision.
18121812
printed = json.loads(out)["capabilities"]
1813-
self.assertEqual(printed["selected_window_contract_revisions"], ["1.3-parity"])
1814-
self.assertIn('"selected_window_contract_revisions":["1.3-parity"]', out)
1815-
self.assertNotIn('"1.3"', out)
1813+
self.assertEqual(printed["selected_window_contract_revisions"], ["1.3"])
1814+
self.assertIn('"selected_window_contract_revisions":["1.3"]', out)
1815+
self.assertNotIn('"1.3-parity"', out)
18161816
self.assertEqual((printed["selected_window_wire_version"], printed["fingerprint_version"]),
18171817
(1, 2))
18181818

@@ -2084,7 +2084,7 @@ def writes_the_member(node):
20842084
self.assertNotIn('"has_unbounded_state": False', source)
20852085

20862086
def test_the_contract_revision_is_one_constant_with_one_literal_read_in_one_place(self):
2087-
# The parity declaration ("1.3-parity") has one tuple, one string literal, one reader, and
2087+
# The full declaration ("1.3") has one tuple, one string literal, one reader, and
20882088
# no revision literal in run_json (so none in a request, report, phase or fingerprint).
20892089
import ast
20902090
report_tree = ast.parse((ROOT / "docker" / "selected_window_report.py").read_text())
@@ -2094,14 +2094,14 @@ def string_constants(tree):
20942094
if isinstance(node, ast.Constant) and isinstance(node.value, str)]
20952095

20962096
strings = string_constants(report_tree)
2097-
self.assertEqual(strings.count("1.3-parity"), 1) # written once ...
2098-
self.assertNotIn("1.3", strings) # ... and never the full revision
2097+
self.assertEqual(strings.count("1.3"), 1) # written once ...
2098+
self.assertNotIn("1.3-parity", strings) # ... and never the parity revision
20992099
assignments = [node for node in report_tree.body if isinstance(node, ast.Assign)
21002100
and any(isinstance(target, ast.Name) and target.id == "CONTRACT_REVISIONS"
21012101
for target in node.targets)]
21022102
self.assertEqual(len(assignments), 1)
21032103
self.assertIsInstance(assignments[0].value, ast.Tuple)
2104-
self.assertEqual(string_constants(assignments[0].value), ["1.3-parity"])
2104+
self.assertEqual(string_constants(assignments[0].value), ["1.3"])
21052105
readers = [function.name for function in ast.walk(report_tree)
21062106
if isinstance(function, ast.FunctionDef)
21072107
and any(isinstance(name, ast.Name) and name.id == "CONTRACT_REVISIONS"
@@ -2111,17 +2111,16 @@ def string_constants(tree):
21112111
ast.parse((ROOT / "docker" / "run_json.py").read_text())))
21122112
self.assertEqual(run_json_strings & {"1.3", "1.3-parity"}, set())
21132113

2114-
def test_the_contract_revision_guard_rejects_the_old_or_a_stray_revision(self):
2115-
# Exercise the real guard on source mutations. Keeping the parity literal once while
2116-
# adding a stray revision isolates the exact tuple pin from the literal-count check.
2114+
def test_the_contract_revision_guard_rejects_the_parity_or_a_paired_revision(self):
2115+
# Exercise the real guard on source mutations. Keeping the full literal once while
2116+
# adding the parity revision isolates the exact tuple pin from the literal-count check.
21172117
report_path = ROOT / "docker" / "selected_window_report.py"
21182118
run_json_path = ROOT / "docker" / "run_json.py"
21192119
report_source = report_path.read_text()
21202120
run_json_source = run_json_path.read_text()
2121-
declaration = 'CONTRACT_REVISIONS = ("1.3-parity",)'
2121+
declaration = 'CONTRACT_REVISIONS = ("1.3",)'
21222122
self.assertEqual(report_source.count(declaration), 1)
2123-
cases = (("1.3",), ("1.3-stray",), ("1.3-parity", "1.3"),
2124-
("1.3-parity", "1.3-stray"), ("1.3-parity", "1.3-parity"))
2123+
cases = (("1.3-parity",), ("1.3", "1.3-parity"), ("1.3-parity", "1.3"))
21252124
for revisions in cases:
21262125
mutant_source = report_source.replace(
21272126
declaration, f"CONTRACT_REVISIONS = {revisions!r}", 1)

0 commit comments

Comments
 (0)