@@ -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 parity build (a prerelease build, not full 1.3 coverage) emits
998- # selected_window_contract_revisions == ["1.3-parity"]; a full build carries ["1.3"];
999- # never both. The literals are written out here, not read from the module.
996+ def test_the_supported_record_declares_the_full_revision_alone_never_the_parity_one (self ):
997+ # A build with complete value ownership emits
998+ # selected_window_contract_revisions == ["1.3"], never the old parity revision.
999+ # 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,20 +1020,20 @@ 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 never advertises parity only
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's old revision 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
10391039
@@ -1252,6 +1252,8 @@ def test_a_selected_run_end_to_end(self):
12521252 # the report or the hashed fingerprint bytes (the phase records are checked below)
12531253 self .assertNotIn ("1.3-parity" , out )
12541254 self .assertNotIn ("1.3-parity" , token )
1255+ self .assertNotIn ('"1.3"' , out )
1256+ self .assertNotIn ('"1.3"' , token )
12551257 self .assertEqual (report ["report_window" ]["wire_version" ], 1 )
12561258 self .assertEqual (report ["report_shape" ], swr .report_shape_full (7 , 0 ))
12571259 timing = report ["diagnostics" ]["phase_timing" ]
@@ -1286,6 +1288,7 @@ def test_a_selected_run_end_to_end(self):
12861288 self .assertEqual ([r ["sequence" ] for r in records ], [1 , 2 , 3 , 4 , 5 ])
12871289 self .assertEqual ({r ["version" ] for r in records }, {1 }) # phase version 1, unchanged
12881290 self .assertNotIn ("1.3-parity" , json .dumps (records )) # no revision literal in a phase
1291+ self .assertNotIn ('"1.3"' , json .dumps (records ))
12891292 self .assertEqual (lib .observer_rc , 0 )
12901293 self .assertEqual (lib .receipt [2 ], 1 )
12911294 self .assertEqual (lib .receipt [0 ], lib .receipt [1 ])
@@ -1787,11 +1790,11 @@ def test_capabilities_probe_reports_a_supported_runtime_without_an_ohlcv(self):
17871790 status , out , _ = run_main (["--so" , "x.so" , "--capabilities-json" ])
17881791 self .assertEqual ((status , json .loads (out )), (0 , swr .capabilities_record (True )))
17891792 self .assertEqual (lib .calls , []) # nothing was constructed or run
1790- # The probe's real stdout carries the parity declaration alone, not the full revision.
1793+ # The probe's real stdout carries the complete contract revision alone .
17911794 printed = json .loads (out )["capabilities" ]
1792- self .assertEqual (printed ["selected_window_contract_revisions" ], ["1.3-parity " ])
1793- self .assertIn ('"selected_window_contract_revisions":["1.3-parity "]' , out )
1794- self .assertNotIn ('"1.3"' , out )
1795+ self .assertEqual (printed ["selected_window_contract_revisions" ], ["1.3" ])
1796+ self .assertIn ('"selected_window_contract_revisions":["1.3"]' , out )
1797+ self .assertNotIn ('"1.3-parity "' , out )
17951798 self .assertEqual ((printed ["selected_window_wire_version" ], printed ["fingerprint_version" ]),
17961799 (1 , 2 ))
17971800
@@ -1801,10 +1804,11 @@ def test_capabilities_probe_reports_zero_when_any_piece_is_missing(self):
18011804 mock .patch .object (swp , "SelectedPrimaryPlanner" , FakePlanner ):
18021805 status , out , _ = run_main (["--so" , "x.so" , "--capabilities-json" ])
18031806 self .assertEqual ((status , json .loads (out )), (0 , swr .capabilities_record (False )))
1804- # Not supported: no revision is listed at all, so neither "1.3-parity" nor "1.3" .
1807+ # An unsupported runtime lists no contract revision .
18051808 self .assertEqual (
18061809 json .loads (out )["capabilities" ]["selected_window_contract_revisions" ], [])
18071810 self .assertNotIn ("1.3" , out )
1811+ self .assertNotIn ("1.3-parity" , out )
18081812
18091813 def test_the_trusted_planner_path_is_absolute_under_the_installation_prefix (self ):
18101814 path = Path (run_json .trusted_planner_path ())
@@ -2062,8 +2066,7 @@ def writes_the_member(node):
20622066 self .assertNotIn ('"has_unbounded_state": False' , source )
20632067
20642068 def test_the_contract_revision_is_one_constant_with_one_literal_read_in_one_place (self ):
2065- # The parity declaration ("1.3-parity") is the single switchable place
2066- # for a future full build ("1.3"): one tuple, one string literal, one reader, and no
2069+ # The complete declaration ("1.3") has one tuple, one string literal, one reader, and no
20672070 # revision literal in run_json (so none in a request, report, phase or fingerprint).
20682071 import ast
20692072 report_tree = ast .parse ((ROOT / "docker" / "selected_window_report.py" ).read_text ())
@@ -2073,14 +2076,14 @@ def string_constants(tree):
20732076 if isinstance (node , ast .Constant ) and isinstance (node .value , str )]
20742077
20752078 strings = string_constants (report_tree )
2076- self .assertEqual (strings .count ("1.3-parity " ), 1 ) # written once ...
2077- self .assertNotIn ("1.3" , strings ) # ... and never the full revision
2079+ self .assertEqual (strings .count ("1.3" ), 1 ) # written once ...
2080+ self .assertNotIn ("1.3-parity " , strings ) # ... and never the old parity revision
20782081 assignments = [node for node in report_tree .body if isinstance (node , ast .Assign )
20792082 and any (isinstance (target , ast .Name ) and target .id == "CONTRACT_REVISIONS"
20802083 for target in node .targets )]
20812084 self .assertEqual (len (assignments ), 1 )
20822085 self .assertIsInstance (assignments [0 ].value , ast .Tuple )
2083- self .assertEqual (string_constants (assignments [0 ].value ), ["1.3-parity " ])
2086+ self .assertEqual (string_constants (assignments [0 ].value ), ["1.3" ])
20842087 readers = [function .name for function in ast .walk (report_tree )
20852088 if isinstance (function , ast .FunctionDef )
20862089 and any (isinstance (name , ast .Name ) and name .id == "CONTRACT_REVISIONS"
@@ -2090,6 +2093,27 @@ def string_constants(tree):
20902093 ast .parse ((ROOT / "docker" / "run_json.py" ).read_text ())))
20912094 self .assertEqual (run_json_strings & {"1.3" , "1.3-parity" }, set ())
20922095
2096+ def test_the_contract_revision_guard_rejects_the_old_or_a_stray_revision (self ):
2097+ # Exercise the real guard on source mutations. Keeping the full literal once while
2098+ # adding a stray revision isolates the exact tuple pin from the literal-count check.
2099+ report_path = ROOT / "docker" / "selected_window_report.py"
2100+ run_json_path = ROOT / "docker" / "run_json.py"
2101+ report_source = report_path .read_text ()
2102+ run_json_source = run_json_path .read_text ()
2103+ declaration = 'CONTRACT_REVISIONS = ("1.3",)'
2104+ self .assertEqual (report_source .count (declaration ), 1 )
2105+ cases = (("1.3-parity" ,), ("1.3-stray" ,), ("1.3" , "1.3-parity" ),
2106+ ("1.3" , "1.3-stray" ), ("1.3" , "1.3" ))
2107+ for revisions in cases :
2108+ mutant_source = report_source .replace (
2109+ declaration , f"CONTRACT_REVISIONS = { revisions !r} " , 1 )
2110+ self .assertNotEqual (mutant_source , report_source )
2111+ sources = {report_path : mutant_source , run_json_path : run_json_source }
2112+ with self .subTest (revisions = revisions ), mock .patch .object (
2113+ Path , "read_text" , autospec = True , side_effect = lambda path : sources [path ]):
2114+ with self .assertRaises (AssertionError ):
2115+ self .test_the_contract_revision_is_one_constant_with_one_literal_read_in_one_place ()
2116+
20932117
20942118if __name__ == "__main__" :
20952119 unittest .main ()
0 commit comments