Skip to content

Commit fd024fd

Browse files
HaoLiangWenHaoLiangWen
authored andcommitted
fix(selected_window): declare 1.3-parity without completeness proof (EN-115)
1 parent 1949e4f commit fd024fd

2 files changed

Lines changed: 38 additions & 34 deletions

File tree

‎docker/selected_window_report.py‎

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* the in-place trim view and the hash of the retained rows in the existing primary hash domain;
1111
* the exact report_window record R (its lookback member is the one triple of a build with no
1212
lookback producer), the full/v1 report_shape and the capability record (its
13-
contract revision is this build's complete value-ownership declaration, CONTRACT_REVISIONS);
13+
contract revision is this build's parity declaration, CONTRACT_REVISIONS);
1414
* the frozen selected_window ABI as a ctypes wrapper, and
1515
the exact comparison of the engine's native counts with the planned counts.
1616
@@ -53,14 +53,16 @@
5353
FINGERPRINT_VERSION = 2
5454
# The contract revision this build declares in its capability record (the member
5555
# selected_window_contract_revisions of --capabilities-json). This is the ONE place it is
56-
# written; capabilities_record is the code that reads it. Revision 1.3 declares complete
57-
# value ownership: strategy_value_invalid, engine_command_value_invalid,
58-
# report_result_invalid and report_post_execution_failed. The supported runtime lists
59-
# this singleton tuple, with no feature switch, environment knob or second constant.
60-
# It is a declaration only: no request, report_window, phase record or fingerprint member
61-
# carries it, and the wire version (1), the phase version (1) and the fingerprint/schema
62-
# version (2) are unchanged.
63-
CONTRACT_REVISIONS = ("1.3",)
56+
# written; capabilities_record is the code that reads it. Revision 1.3-parity declares value
57+
# parity with the 1.4.0 reference on the tested cases, with the typed value-ownership codes
58+
# strategy_value_invalid, engine_command_value_invalid, report_result_invalid and
59+
# report_post_execution_failed emitted and no completeness claim (value_ownership
60+
# parity_with_reference; a full build with a completeness proof lists ("1.3",), never both).
61+
# The supported runtime lists this singleton tuple, with no feature switch, environment knob
62+
# or second constant. It is a declaration only: no request, report_window, phase record or
63+
# fingerprint member carries it, and the wire version (1), the phase version (1) and the
64+
# fingerprint/schema version (2) are unchanged.
65+
CONTRACT_REVISIONS = ("1.3-parity",)
6466
REPORT_SHAPE = "full/v1"
6567
METERING_BASIS = "window-primary-input-bars/v1"
6668
MAX_PREROLL_BARS = 5000
@@ -692,8 +694,10 @@ def capabilities_record(supported: bool) -> Dict[str, Any]:
692694
members of features this build does not offer (compact shape, digest) are always absent.
693695
694696
selected_window_contract_revisions is CONTRACT_REVISIONS as a fresh list when supported:
695-
exactly ["1.3"], declaring complete value ownership through strategy_value_invalid,
696-
engine_command_value_invalid, report_result_invalid and report_post_execution_failed.
697+
exactly ["1.3-parity"], declaring value parity with the 1.4.0 reference on the tested
698+
cases, with the typed value-ownership codes (strategy_value_invalid,
699+
engine_command_value_invalid, report_result_invalid and report_post_execution_failed)
700+
emitted and no completeness claim, and never "1.3", which requires a completeness proof.
697701
It is [] when the runtime is not supported,
698702
so an unsupported runtime lists no revision at all. No other member of this document
699703
changes with the declaration."""

‎tests/test_run_json_selected_window.py‎

Lines changed: 23 additions & 23 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_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.
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"].
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"],
1004+
"selected_window_contract_revisions": ["1.3-parity"],
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_full_revision_alone_never_the_parity_
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"])
1023+
self.assertEqual(revisions, ["1.3-parity"])
10241024
self.assertEqual(len(revisions), 1) # a singleton ...
1025-
self.assertNotIn("1.3-parity", revisions) # ... that never advertises parity only
1025+
self.assertNotIn("1.3", revisions) # ... that is never the full 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",)) # the one constant
1029+
self.assertEqual(swr.CONTRACT_REVISIONS, ("1.3-parity",)) # 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-parity") # a caller's old revision changes neither the constant ...
1034-
self.assertEqual(swr.CONTRACT_REVISIONS, ("1.3",))
1033+
first.append("1.3") # a caller that edits its copy changes neither the constant ...
1034+
self.assertEqual(swr.CONTRACT_REVISIONS, ("1.3-parity",))
10351035
again = swr.capabilities_record(True)["capabilities"]["selected_window_contract_revisions"]
1036-
self.assertEqual(again, ["1.3"]) # ... nor the next record
1036+
self.assertEqual(again, ["1.3-parity"]) # ... nor the next record
10371037
self.assertIsNot(first, again)
10381038

10391039
def test_without_a_completeness_proof_the_probe_declares_1_3_parity_only(self):
@@ -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 complete contract revision alone.
1811+
# The probe's real stdout carries the parity contract revision alone, not the full revision.
18121812
printed = json.loads(out)["capabilities"]
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)
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)
18161816
self.assertEqual((printed["selected_window_wire_version"], printed["fingerprint_version"]),
18171817
(1, 2))
18181818

@@ -2084,8 +2084,8 @@ 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 complete declaration ("1.3") has one tuple, one string literal, one reader, and no
2088-
# revision literal in run_json (so none in a request, report, phase or fingerprint).
2087+
# The parity declaration ("1.3-parity") has one tuple, one string literal, one reader, and
2088+
# 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())
20912091

@@ -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"), 1) # written once ...
2098-
self.assertNotIn("1.3-parity", strings) # ... and never the old parity revision
2097+
self.assertEqual(strings.count("1.3-parity"), 1) # written once ...
2098+
self.assertNotIn("1.3", strings) # ... and never the full 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"])
2104+
self.assertEqual(string_constants(assignments[0].value), ["1.3-parity"])
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"
@@ -2112,16 +2112,16 @@ def string_constants(tree):
21122112
self.assertEqual(run_json_strings & {"1.3", "1.3-parity"}, set())
21132113

21142114
def test_the_contract_revision_guard_rejects_the_old_or_a_stray_revision(self):
2115-
# Exercise the real guard on source mutations. Keeping the full literal once while
2115+
# Exercise the real guard on source mutations. Keeping the parity literal once while
21162116
# adding a stray 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",)'
2121+
declaration = 'CONTRACT_REVISIONS = ("1.3-parity",)'
21222122
self.assertEqual(report_source.count(declaration), 1)
2123-
cases = (("1.3-parity",), ("1.3-stray",), ("1.3", "1.3-parity"),
2124-
("1.3", "1.3-stray"), ("1.3", "1.3"))
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"))
21252125
for revisions in cases:
21262126
mutant_source = report_source.replace(
21272127
declaration, f"CONTRACT_REVISIONS = {revisions!r}", 1)

0 commit comments

Comments
 (0)