Skip to content

Commit fd6a429

Browse files
authored
Verify bounded context reads from the original Turn (#10010)
Signed-off-by: lusendong.6789 <lusendong.6789@bytedance.com>
1 parent d59ab59 commit fd6a429

2 files changed

Lines changed: 19 additions & 6 deletions

File tree

‎tests/control_plane/test_context_delivery_cli.py‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -823,9 +823,17 @@ def unavailable_reference(path, _digest, **kwargs):
823823
assert printed[0]["captured_decision"]["sha256"] == sha256(saved.read_bytes()).hexdigest()
824824
elif native_failure == "reader_reference":
825825
assert reference_attempts == [tmp_path / "delivery.json"]
826-
assert len(printed) == 1 and "reference_file" not in printed[0]
827-
page = quota_context_reader.read_context_capture(_native_reader_args(printed[0]["command"]))
828-
assert page["ok"] and page["eof"]
826+
[fallback] = printed
827+
assert fallback["ok"] and "reference_file" not in fallback
828+
assert fallback["sha256"] == sha256((tmp_path / "delivery.json").read_bytes()).hexdigest()
829+
reader = (
830+
["pwsh", "-NoProfile", "-NonInteractive", "-Command", fallback["command"]]
831+
if os.name == "nt" else shlex.split(fallback["command"])
832+
)
833+
page = json.loads(subprocess.run(
834+
reader, capture_output=True, check=True, timeout=15,
835+
).stdout)
836+
assert page["ok"] and page["eof"] and page["sha256"] == fallback["sha256"]
829837
assert json.loads(page["content"]) == {"native_projection": original}
830838
else:
831839
assert len(printed) == 1 and "content" not in printed[0]

‎tests/control_plane/test_turn_todoless_settlement.py‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,12 +191,17 @@ def test_bound_todoless_planning_executes_and_settles_once(tmp_path, monkeypatch
191191
detail = request["detail_ref"]
192192
reader = assert_host_capture_readback(detail, journal["plan"]["detail_ref"])
193193
if reader is not None:
194-
pointer = "/interaction_contract/cli_channel/settlement_plan/identity"
195-
result_page = subprocess.run([*reader, "--select", pointer], capture_output=True, check=True, timeout=15)
194+
hash_pointer = "/contract_binding/content_hash"
195+
identity_pointer = "/interaction_contract/cli_channel/settlement_plan/identity"
196+
result_page = subprocess.run([*reader, "--select", hash_pointer, "--select", identity_pointer],
197+
capture_output=True, check=True, timeout=15)
196198
assert len(result_page.stdout) <= 12_000
197199
page = json.loads(result_page.stdout)
198200
assert page["eof"] and page["sha256"] == detail["captured_decision"]["sha256"]
199-
assert json.loads(page["content"])["selections"] == [{"pointer": pointer, "value": identity}]
201+
assert json.loads(page["content"])["selections"] == [
202+
{"pointer": hash_pointer, "value": request["source_decision_hash"]},
203+
{"pointer": identity_pointer, "value": identity},
204+
]
200205
# Recover the original signed source from the compatible full reader,
201206
# without re-entering quota or requiring the model to carry a second copy.
202207
full_reader = (

0 commit comments

Comments
 (0)