Skip to content

Commit e207130

Browse files
luisleo526claude
andcommitted
EN-132 lane F: declare contract revision 1.3 (complete value ownership)
Lane f, the last slice. Flips the one declared selected-window contract revision from the prerelease parity literal to the complete-ownership literal and updates its pinned tests and docs. Merges last, after lanes r, m and bx. - docker/selected_window_report.py: CONTRACT_REVISIONS = ("1.3",) - the single place the revision is written; the capability record reads it, so the --capabilities-json probe now advertises ["1.3"] for a supported runtime and [] otherwise. No feature switch, environment knob or second constant; the wire version (1), phase version (1) and fingerprint/schema version (2) are unchanged. - tests/test_run_json_selected_window.py: the pinned assertions inverted to the complete revision (never the parity literal), the "no revision literal in a request/report/phase/fingerprint" checks extended, and a guard test that rejects the old or any stray revision tuple by mutating the source. - README.md, docker/README.md, docs/pages/report-schema.md: state that the 1.6.0 image declares revision 1.3 - complete value ownership through strategy_value_invalid, engine_command_value_invalid, report_result_invalid and report_post_execution_failed. The receipt checks (check_capability_revisions with value_ownership.status complete, and check_stable_complete) confirm a release receipt pairs exactly ["1.3"] with a complete status; amendment 6 requires that pairing before the pin ships. Source-trace only here; the integration box runs the capability tests. Keep every existing file. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
1 parent 44b4d00 commit e207130

5 files changed

Lines changed: 90 additions & 32 deletions

File tree

‎README.md‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,15 @@ For the 1.5.0 pair, regenerate strategy C++ and relink against that pair's
4747
headers and archive. Published 1.3.0 download and installation examples below
4848
remain pinned to that earlier pair.
4949

50+
The engine/codegen **1.6.0** image advertises selected-window contract revision
51+
`1.3` through `docker/run_json.py --capabilities-json`: complete value ownership
52+
with `strategy_value_invalid`, `engine_command_value_invalid`,
53+
`report_result_invalid` and `report_post_execution_failed`.
54+
`capabilities.selected_window_contract_revisions` is `["1.3"]` when the runtime
55+
supports selected windows and `[]` otherwise; see the
56+
[capability table](docker/README.md#selected-window-contract-revision) and
57+
[report schema](docs/pages/report-schema.md).
58+
5059
---
5160

5261
## Get a backtest in 60 seconds

‎docker/README.md‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,20 @@ docker run --rm \
266266
or an index naming no symbol: the key is absent and the report is what it was
267267
before this variable existed, apart from `elapsed_seconds`.
268268

269+
### Selected-window contract revision
270+
271+
The engine/codegen **1.6.0** image's `run_json.py --so <strategy.so>
272+
--capabilities-json` probe declares revision `1.3`, meaning complete value
273+
ownership with `strategy_value_invalid`, `engine_command_value_invalid`,
274+
`report_result_invalid` and `report_post_execution_failed`.
275+
276+
| Capability member | Supported runtime | Unsupported runtime |
277+
| --- | --- | --- |
278+
| `selected_window_contract_revisions` | `["1.3"]` | `[]` |
279+
280+
This member belongs to the probe's `capabilities` object. The selected-window
281+
wire version remains 1, the phase version 1 and the fingerprint/schema version 2.
282+
269283
### Recorded outputs (the harness's `--outputs`)
270284

271285
This section describes support released in **1.5.0**. Released

‎docker/selected_window_report.py‎

Lines changed: 12 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 prerelease build's parity declaration, CONTRACT_REVISIONS);
13+
contract revision is this build's complete value-ownership 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,14 @@
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. It is a PRERELEASE PARITY capability:
57-
# the selected window without the value-ownership producers of the full contract, and NOT a
58-
# claim of full 1.3 coverage. A parity build lists ("1.3-parity",) and a full build lists
59-
# ("1.3",), never both: a future full build changes this one tuple and nothing else (no
60-
# feature switch, environment knob or second constant exists). It is a declaration only: no
61-
# request, report_window, phase record or fingerprint member carries it, and the wire version
62-
# (1), the phase version (1) and the fingerprint/schema version (2) are unchanged.
63-
CONTRACT_REVISIONS = ("1.3-parity",)
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",)
6464
REPORT_SHAPE = "full/v1"
6565
METERING_BASIS = "window-primary-input-bars/v1"
6666
MAX_PREROLL_BARS = 5000
@@ -692,8 +692,9 @@ def capabilities_record(supported: bool) -> Dict[str, Any]:
692692
members of features this build does not offer (compact shape, digest) are always absent.
693693
694694
selected_window_contract_revisions is CONTRACT_REVISIONS as a fresh list when supported:
695-
exactly ["1.3-parity"], the prerelease parity declaration (not full 1.3 coverage), and
696-
never "1.3", which only a full build carries. It is [] when the runtime is not 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+
It is [] when the runtime is not supported,
697698
so an unsupported runtime lists no revision at all. No other member of this document
698699
changes with the declaration."""
699700
return {

‎docs/pages/report-schema.md‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@ each field to its meaning and units.
77

88
@see #pf_report_t for the verbatim struct declaration.
99

10+
The engine/codegen **1.6.0** image declares selected-window contract revision
11+
`1.3`, meaning complete value ownership with `strategy_value_invalid`,
12+
`engine_command_value_invalid`, `report_result_invalid` and
13+
`report_post_execution_failed`.
14+
The `--capabilities-json` probe's
15+
`capabilities.selected_window_contract_revisions` is `["1.3"]` for a supported
16+
runtime and `[]` otherwise. The declaration lives in that capability record;
17+
the selected-window wire version remains 1, the phase version 1 and the
18+
fingerprint/schema version 2.
19+
1020
## Top-level layout
1121

1222
```c

‎tests/test_run_json_selected_window.py‎

Lines changed: 45 additions & 21 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 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

20942118
if __name__ == "__main__":
20952119
unittest.main()

0 commit comments

Comments
 (0)