diff --git a/docs/architecture/rfcs/monorepo-distribution-split-v0.md b/docs/architecture/rfcs/monorepo-distribution-split-v0.md index 09c83044e0..3520404c27 100644 --- a/docs/architecture/rfcs/monorepo-distribution-split-v0.md +++ b/docs/architecture/rfcs/monorepo-distribution-split-v0.md @@ -4473,3 +4473,35 @@ view shows its independently checked result in the same conversation. Pinned-source/artifact checks, actual-model adoption, complete D2/D5 costs, R1/M3 and the original ten requirements remain separate. Preserve earlier failures and run full original-goal regression before completion. + +### 2026-11-15 — Reuse the final staged Host source check + +- **Gap:** the temporary request built after capture staging repeated + `host_context` immediately before `host_dispatch_context`. Its complete + assembly still matters: frozen captures retain mutable nested plan aliases. +- **Delta:** the public request builder and staged dispatch share the original + inspection, turn-key and route guards, source assembly, optional context, + subagent and native-child metadata. Only a staged complete-v1 plan producing + a Host-v1 request with `work_contract` and no `turn_envelope` omits the nested + `host_context`; the existing carrier conversion and final dispatch check stay + before admission and publication. Other shapes retain the original finish. + No checked result is retained across admission, publication or later effects. +- **Evidence:** matched File/SQLite source checks cover 42 guard, alias, carrier, + numeric/text, interval-wait and bridge-failure cases on the baseline and + candidate. Exact startup, transport-permission and offloaded-snapshot-size + diagnostics preserve the original carrier and zero publication/ledger effects. + A deliberately dropped goal reference fails the independent value oracle. + The staged operation trace removes one `host_context` and retains one + `host_dispatch_context`. Separate true Core wheels pass 15 identity, + execution/checkpoint, replay, journal inspection, process-loss/stale-lease and + invalid-artifact checks each on the candidate and the clean `main@37a79decfe99` + plus C1 #8266 at `638b7e3c23f0` composition. The C1 source comparison uses its + direct-complete-source planner API on both arms; the earlier incompatible + keyword setup failure is preserved. These checks use Python 3.13.5 and Node + 26.0.0; wheel, RECORD, source and runtime origins are independently bound. +- **Boundary:** this avoids one redundant bridge projection, without changing + the typed source owner, default activation, capture publication, recovery or + settlement boundaries. It does not establish total latency, complete-cost or + actual-model improvements, full D2/D5 closure, R1/M3 or C1 default cutover. + Preserve prior failures and the original ten requirements; full original-goal + regression still precedes completion and EdgeBench preparation. diff --git a/docs/architecture/rfcs/monorepo-distribution-split-v0.zh-CN.md b/docs/architecture/rfcs/monorepo-distribution-split-v0.zh-CN.md index 61c064be2c..9d0aa7b756 100644 --- a/docs/architecture/rfcs/monorepo-distribution-split-v0.zh-CN.md +++ b/docs/architecture/rfcs/monorepo-distribution-split-v0.zh-CN.md @@ -3462,3 +3462,29 @@ workspace 批准和脚本模型工作。桌面视图在采用检查后显示原 - **边界:**本次保护资格证据来源,不改变生产准入,也不认证 wheel 字节或模型 执行。固定源码/产物检查、真实模型采纳、完整 D2/D5 成本、R1/M3 和原十项要求 仍需分别验证;保留历史失败,完成前仍需完整原目标回归。 + +### 2026-11-15 — 复用 staged Host 的最终来源检查 + +- **缺口:**capture staging 后构造临时请求,在 `host_dispatch_context` 前紧接着 + 重复 `host_context`。完整组装仍有实际作用:frozen capture 的嵌套 plan 仍有 + 可变别名。 +- **增量:**公开请求 builder 与 staged dispatch 共享原 inspection、turn-key、 + route guards、来源组装、可选 context、subagent 和 native-child metadata。 + 仅 staged complete-v1 plan 生成含 `work_contract`、不含 `turn_envelope` 的 + Host-v1 请求时省去嵌套 `host_context`;原 carrier 转换和最终 dispatch 检查仍在 + 准入与发布之前。其它形状保留原 finish,不跨准入、发布或后续效果保留 checked + result。 +- **证据:**File/SQLite 基线与候选对照覆盖 42 个 guard、别名、carrier、数字/ + 文本、interval-wait 和 bridge 失败场景。精确 startup、transport permission、 + offloaded snapshot 大小诊断保留原 carrier,发布与 ledger 效果为零。刻意丢弃 + goal reference 能使独立值 oracle 失败。staged operation trace 少一次 + `host_context`,仍保留一次 `host_dispatch_context`。候选及 `main@37a79decfe99` + 与 C1 #8266 `638b7e3c23f0` 的干净组合分别构建真实 Core wheel,各通过 15 个 + identity、执行/checkpoint、回放、journal 查看、进程丢失/stale lease 和无效 + 产物检查。C1 来源两 arm 使用同一 direct-complete-source planner API;先前 + 不兼容 keyword 的 setup 失败保留。上述检查使用 Python 3.13.5、Node 26.0.0, + wheel、RECORD、source 与 runtime 来源分别绑定。 +- **边界:**本次省去一次重复 bridge projection,不改变 typed source owner、默认 + 激活、capture 发布、恢复或结算边界。它不证明总延迟、完整成本或真实模型改善, + 也不完成 D2/D5 闭包、R1/M3 或 C1 默认切换。保留历史失败和原十项要求;完成前 + 仍需完整原目标回归,随后才准备 EdgeBench。 diff --git a/loopx/control_plane/turn_driver/executor.py b/loopx/control_plane/turn_driver/executor.py index a5e68b24ff..27ba70f20b 100644 --- a/loopx/control_plane/turn_driver/executor.py +++ b/loopx/control_plane/turn_driver/executor.py @@ -38,7 +38,11 @@ normalize_reward_memory_reflection_validation, reward_memory_reflection_digest, ) -from ..quota.turn_envelope import turn_plan_host_source +from ..quota.turn_envelope import ( + COMPLETE_TURN_HOST_REQUEST_SCHEMA, + captured_turn_host_input, + turn_plan_host_source, +) from .driver import ( COMPLETE_TURN_PLAN_SCHEMA_VERSION, selected_turn_todo, turn_host_lineage, @@ -156,6 +160,10 @@ def build_loopx_turn_host_request(plan: Mapping[str, Any]) -> dict[str, Any]: """Deliver the plan's original source; decode saved v0 plans as recorded.""" + return _complete_loopx_turn_host_request(_assemble_loopx_turn_host_request(plan)) + + +def _assemble_loopx_turn_host_request(plan: Mapping[str, Any]) -> dict[str, Any]: boundary = plan.get("boundary") if isinstance(boundary, Mapping) and boundary.get("inspection_only") is True: raise ValueError("LoopX Turn CLI inspection requires the explicit run-once execution surface") @@ -197,6 +205,10 @@ def build_loopx_turn_host_request(plan: Mapping[str, Any]) -> dict[str, Any]: if configured_native_child_limit(request) is not None: request["turn_instance_id"] = transaction.get("turn_instance_id") or turn_key + return request + + +def _complete_loopx_turn_host_request(request: dict[str, Any]) -> dict[str, Any]: if "work_contract" in request: from .host_candidate import complete_host_input @@ -204,6 +216,20 @@ def build_loopx_turn_host_request(plan: Mapping[str, Any]) -> dict[str, Any]: return request +def _build_staged_dispatch_request(plan: Mapping[str, Any]) -> dict[str, Any]: + """Assemble staged input for the immediate mandatory dispatch check.""" + request = _assemble_loopx_turn_host_request(plan) + if (plan.get("schema_version") == COMPLETE_TURN_PLAN_SCHEMA_VERSION + and request.get("schema_version") == COMPLETE_TURN_HOST_REQUEST_SCHEMA + and "work_contract" in request and "turn_envelope" not in request): + # All assembly guards and projections still run on the staged aliases. + # This carrier's existing conversion only copies the top-level mapping; + # host_context returns no facts used by it. The caller checks this exact + # source with host_dispatch_context before admission or publication. + return captured_turn_host_input(request) + return _complete_loopx_turn_host_request(request) + + def _bounded_public_text( result: Mapping[str, Any], field: str, @@ -1706,7 +1732,7 @@ def persist_source_journal(source_admission: Mapping[str, Any]) -> None: # must not put otherwise eligible work into an interval wait. # Saved typed results retain their original finalization path. complete_turn_host_source( - build_loopx_turn_host_request(capture.plan) if capture is not None else request, + _build_staged_dispatch_request(capture.plan) if capture is not None else request, operation="host_dispatch_context", ) admission = None diff --git a/tests/control_plane/test_turn_host_decision_capture.py b/tests/control_plane/test_turn_host_decision_capture.py index e965463074..648f63cdcd 100644 --- a/tests/control_plane/test_turn_host_decision_capture.py +++ b/tests/control_plane/test_turn_host_decision_capture.py @@ -221,6 +221,340 @@ def execute(): assert state["eligibility"]["state"] == "waiting" +@pytest.mark.parametrize("mutation,expected", [ + ("inspection_key_route", "LoopX Turn CLI inspection requires the explicit run-once execution surface"), + ("key_route", "LoopX Turn plan has no valid transaction turn_key"), + ("route_false", "staged route refused"), + ("route_integer", "staged route refused"), + ("route_string", "staged route refused"), + ("route_none", "staged route refused"), + ("route_mapping", "staged route refused"), + ("route_fallback", "LoopX Turn route is not host executable"), +]) +def test_staged_capture_rechecks_aliased_plan_guards_before_effects( + complete_host_request, tmp_path, monkeypatch, mutation, expected, +): + from loopx.control_plane.turn_driver import executor + from loopx.control_plane.turn_driver.driver import build_loopx_turn_plan + + request, original = complete_host_request + plan = build_loopx_turn_plan(request["turn_envelope"], work_contract=original, + host="generic-cli", execution_mode="isolated-headless", + turn_instance_id="staged-alias-guards") + runtime = tmp_path / "staged-alias-runtime" + captures = [] + effects = [] + original_stage = executor.stage_turn_decision_capture + + def stage_then_mutate(*args, **kwargs): + capture = original_stage(*args, **kwargs) + captures.append(capture) + # A frozen capture still shares nested mutable plan fields. Mutate + # only after the real source binding, so the incoming checks pass. + if mutation == "inspection_key_route": + capture.plan["boundary"]["inspection_only"] = True + if mutation in {"inspection_key_route", "key_route"}: + capture.plan["transaction"]["turn_key"] = "invalid turn key" + route_flag = { + "route_integer": 1, "route_string": "true", "route_none": None, + "route_mapping": {"enabled": True}, + }.get(mutation, False) + capture.plan["route"]["would_invoke_host"] = route_flag + capture.plan["error"] = "" if mutation == "route_fallback" else "staged route refused" + return capture + + def unexpected_effect(*args, **kwargs): + effects.append((args, kwargs)) + raise AssertionError("a staged guard refusal must precede execution effects") + + monkeypatch.setattr(executor, "stage_turn_decision_capture", stage_then_mutate) + with pytest.raises(ValueError) as refused: + executor.run_loopx_turn_once(plan, host_runner=unexpected_effect, + project=tmp_path / "project", runtime_root=runtime, goal_id=original["goal_id"], + timeout_seconds=5, execute=True, writeback=unexpected_effect, + spend=unexpected_effect, scheduler=unexpected_effect, admit_start=unexpected_effect, + confirm_start=unexpected_effect, decision_capture_payload=original, + require_decision_capture=True) + assert str(refused.value) == expected + assert len(captures) == 1 and effects == [] + assert not captures[0].path.exists() + journal = turn_journal_path(runtime, goal_id=original["goal_id"], + turn_key=request["turn_key"]) + assert not journal.exists() + + +@pytest.mark.parametrize("mutation,expected", [ + ("contract", "complete Turn decision content integrity mismatch"), + ("source_hash", "complete Host request differs from captured source"), + ("capture_key", "complete Host request capture binding differs"), + ("adapter", "complete Turn plan requires one source without an executor adapter"), +]) +def test_staged_capture_rechecks_source_and_header_before_effects( + complete_host_request, tmp_path, monkeypatch, mutation, expected, +): + from copy import deepcopy + from loopx.control_plane.turn_driver import executor + from loopx.control_plane.turn_driver.driver import build_loopx_turn_plan + + request, original = complete_host_request + original = deepcopy(original) + plan = build_loopx_turn_plan(request["turn_envelope"], work_contract=original, + host="generic-cli", execution_mode="isolated-headless", + turn_instance_id="staged-source-guards") + captures = [] + original_stage = executor.stage_turn_decision_capture + + def stage_then_mutate(*args, **kwargs): + capture = original_stage(*args, **kwargs) + captures.append(capture) + if mutation == "contract": + capture.plan["work_contract"]["agent_identity"]["agent_id"] = "changed-agent" + elif mutation == "source_hash": + capture.plan["source_decision_hash"] = "sha256:" + "0" * 64 + elif mutation == "capture_key": + capture.plan["detail_ref"]["captured_decision"]["turn_key"] = "sha256:" + "0" * 64 + else: + capture.plan["turn_envelope"] = request["turn_envelope"] + return capture + + def unexpected_effect(*_args, **_kwargs): + raise AssertionError("a staged source refusal must precede execution effects") + + runtime = tmp_path / "staged-source-runtime" + monkeypatch.setattr(executor, "stage_turn_decision_capture", stage_then_mutate) + with pytest.raises((ValueError, RuntimeError)) as refused: + executor.run_loopx_turn_once(plan, host_runner=unexpected_effect, + project=tmp_path / "project", runtime_root=runtime, goal_id=original["goal_id"], + timeout_seconds=5, execute=True, writeback=unexpected_effect, + spend=unexpected_effect, scheduler=unexpected_effect, admit_start=unexpected_effect, + decision_capture_payload=original, require_decision_capture=True) + assert str(refused.value) == expected + assert len(captures) == 1 and not captures[0].path.exists() + assert not turn_journal_path(runtime, goal_id=original["goal_id"], + turn_key=request["turn_key"]).exists() + + +@pytest.mark.parametrize("optional_context", [False, True]) +def test_staged_capture_preserves_optional_bridge_startup_diagnostic( + complete_host_request, tmp_path, monkeypatch, optional_context, +): + from loopx.control_plane import effect_runtime + from loopx.control_plane.runtime.node_probe import NodeProbe, NodeProbeOutcome + from loopx.control_plane.turn_driver import executor + from loopx.control_plane.turn_driver.driver import build_loopx_turn_plan + + request, original = complete_host_request + plan = build_loopx_turn_plan(request["turn_envelope"], work_contract=original, + host="generic-cli", execution_mode="isolated-headless", + turn_instance_id="staged-bridge-failure") + original_carrier = json.dumps(plan, ensure_ascii=False) + original_stage = executor.stage_turn_decision_capture + original_request = effect_runtime.effect_runtime_request + captures, operations, probes = [], [], [] + + def observe_request(method, params, **kwargs): + operations.append((method, params.get("operation"))) + return original_request(method, params, **kwargs) + + def missing_node(**_kwargs): + probes.append("missing") + return NodeProbe(NodeProbeOutcome.MISSING) + + def stage_then_lose_bridge(*args, **kwargs): + capture = original_stage(*args, **kwargs) + captures.append(capture) + if optional_context: + capture.plan["turn_context_contributions"] = [{ + "hook_id": "synthetic-context", "readback_slots": [], + }] + # A new disposable locator selects the real startup failure path; + # no serving runtime or active developer process is retired. + monkeypatch.setattr(effect_runtime, "_runtime_dir", lambda: tmp_path / "missing-node-runtime") + monkeypatch.setattr(effect_runtime, "_probe_node", missing_node) + monkeypatch.setattr(effect_runtime, "effect_runtime_request", observe_request) + return capture + + def unexpected_effect(*_args, **_kwargs): + raise AssertionError("bridge startup refusal must precede execution effects") + + runtime = tmp_path / "staged-bridge-runtime" + monkeypatch.setattr(executor, "stage_turn_decision_capture", stage_then_lose_bridge) + with pytest.raises(effect_runtime.EffectRuntimeNodeProbeError) as refused: + executor.run_loopx_turn_once(plan, host_runner=unexpected_effect, + project=tmp_path / "project", runtime_root=runtime, goal_id=original["goal_id"], + timeout_seconds=5, execute=True, writeback=unexpected_effect, + spend=unexpected_effect, scheduler=unexpected_effect, admit_start=unexpected_effect, + decision_capture_payload=original, require_decision_capture=True) + assert refused.value.diagnostic_code == "node_unavailable" + assert str(refused.value) == "LoopX Effect runtime requires Node.js 22.22.3 or newer on PATH" + assert len(probes) == (2 if optional_context else 1) + assert len(operations) == len(probes) + if optional_context: + assert operations[0] == ("quota.turn_envelope.evaluate", "host_context_binding") + assert operations[-1][0] == "quota.turn_envelope.evaluate" + assert operations[-1][1] in {"host_context", "host_dispatch_context"} + assert len(captures) == 1 and not captures[0].path.exists() + assert not turn_journal_path(runtime, goal_id=original["goal_id"], + turn_key=request["turn_key"]).exists() + assert json.dumps(plan, ensure_ascii=False) == original_carrier + assert json.dumps(captures[0].observation, ensure_ascii=False) == json.dumps(original, ensure_ascii=False) + assert not list(runtime.rglob("*.jsonl")) + + +@pytest.mark.parametrize("current,child_limit", [(True, 2), (True, True), (False, 2)]) +def test_staged_dispatch_preserves_complete_request_values( + complete_host_request, tmp_path, monkeypatch, current, child_limit, +): + from copy import deepcopy + from loopx.control_plane.quota import turn_envelope + from loopx.control_plane.turn_driver import executor + from loopx.control_plane.turn_driver.driver import build_loopx_turn_plan + + _, original = complete_host_request + source = deepcopy({key: value for key, value in original.items() + if key not in {"schema_version", "contract_binding"}}) + source["future_task_data"] = {"numbers": [2**60 + 1, 1.0, -0.0], + "text": "Preserve all original requirements. \n保留原要求。"} + source["interaction_contract"]["agent_context"] = {"contributions": [ + {"capability_id": "multi_subagent", "facts": {"max_children": child_limit}}, + ]} + contract = turn_envelope.compose_turn_decision(source) + envelope = turn_envelope.build_turn_envelope(contract) + plan = build_loopx_turn_plan(envelope, host="generic-cli", execution_mode="isolated-headless", + turn_instance_id="staged-request-values", **({"work_contract": contract} if current else {})) + if not current: + # Retain the published transitional adapter decoder as a control. + plan["work_contract"] = contract + plan["goal_ref"] = {"goal_id": original["goal_id"], "instance_id": "synthetic-instance"} + plan["delegation_context"] = {"allowed": False, "detail": "preserve delegation"} + plan["child_operations"] = [{"operation": "synthetic-child-observation"}] + plan["subagent_execution_topology"] = {"state": "synthetic-topology"} + captured, dispatched, admissions = [], [], [] + original_stage = executor.stage_turn_decision_capture + original_check = turn_envelope.complete_turn_host_source + + def observe_stage(*args, **kwargs): + capture = original_stage(*args, **kwargs) + captured.append(capture) + return capture + + def observe_dispatch(request, **kwargs): + if kwargs.get("operation") == "host_dispatch_context": + dispatched.append(request) + return original_check(request, **kwargs) + + def deny_start(admission): + admissions.append(admission) + return {"admitted": False, "reason": "synthetic interval wait"} + + def unexpected_effect(*_args, **_kwargs): + raise AssertionError("interval wait must not publish or execute") + + runtime = tmp_path / "staged-values-runtime" + monkeypatch.setattr(executor, "stage_turn_decision_capture", observe_stage) + monkeypatch.setattr(turn_envelope, "complete_turn_host_source", observe_dispatch) + result = executor.run_loopx_turn_once(plan, host_runner=unexpected_effect, + project=tmp_path / "project", runtime_root=runtime, goal_id=original["goal_id"], + timeout_seconds=5, execute=True, writeback=unexpected_effect, + spend=unexpected_effect, scheduler=unexpected_effect, admit_start=deny_start, + decision_capture_payload=contract, require_decision_capture=True) + assert result["status"] == "interval_wait" + assert len(captured) == len(dispatched) == len(admissions) == 1 + request = dispatched[0] + assert request["schema_version"] == "loopx_turn_host_request_v1" + assert "turn_envelope" not in request + assert request["turn_key"] == plan["transaction"]["turn_key"] + assert request["route"] == plan["route"]["kind"] + assert request["session"] == plan["session"] + assert request["result_contract"] == {"schema_version": "loopx_turn_result_v0", + "completed_phases": ["host_execute", "typed_result"], "stdout": "one public-safe JSON object"} + assert request["goal_ref"] == plan["goal_ref"] and request["goal_ref"] is not plan["goal_ref"] + for field in ("delegation_context", "child_operations", "subagent_execution_topology"): + assert request[field] == plan[field] + assert request.get("turn_instance_id") == (None if child_limit is True else "staged-request-values") + assert json.dumps(request["work_contract"], ensure_ascii=False) == json.dumps(contract, ensure_ascii=False) + assert request["source_decision_hash"] == contract["contract_binding"]["content_hash"] + capture_ref = request["detail_ref"]["captured_decision"] + assert capture_ref["path"] == str(captured[0].path) + assert capture_ref["turn_key"] == request["turn_key"] + assert capture_ref["source_hash_ref"] == "$.source_decision_hash" + assert not captured[0].path.exists() + assert not turn_journal_path(runtime, goal_id=original["goal_id"], turn_key=request["turn_key"]).exists() + + +@pytest.mark.parametrize("optional_context", [False, True]) +@pytest.mark.parametrize("failure", ["snapshot_oversized", "transport_permission"]) +def test_staged_capture_preserves_bridge_transport_failure( + complete_host_request, tmp_path, monkeypatch, optional_context, failure, +): + from loopx.control_plane import effect_runtime + from loopx.control_plane.turn_driver import executor + from loopx.control_plane.turn_driver.driver import build_loopx_turn_plan + + request, original = complete_host_request + plan = build_loopx_turn_plan(request["turn_envelope"], work_contract=original, + host="generic-cli", execution_mode="isolated-headless", + turn_instance_id="staged-transport-failure") + original_carrier = json.dumps(plan, ensure_ascii=False) + original_stage = executor.stage_turn_decision_capture + original_request = effect_runtime.effect_runtime_request + captures, operations = [], [] + + def observe_request(method, params, **kwargs): + operations.append((method, params.get("operation"), kwargs.get("large_local_snapshot", False))) + return original_request(method, params, **kwargs) + + def denied_connection(*_args, **_kwargs): + raise PermissionError("synthetic transport denial") + + def stage_then_fail_transport(*args, **kwargs): + capture = original_stage(*args, **kwargs) + captures.append(capture) + if optional_context: + capture.plan["turn_context_contributions"] = [{ + "hook_id": "synthetic-context", "readback_slots": [], + }] + monkeypatch.setattr(effect_runtime, "effect_runtime_request", observe_request) + if failure == "snapshot_oversized": + # Exercise the existing encoder and offloaded-snapshot fallback + # with bounded local limits, without allocating a huge fixture. + monkeypatch.setattr(effect_runtime, "MAX_REQUEST_BYTES", 1024) + monkeypatch.setattr(effect_runtime, "MAX_LOCAL_SNAPSHOT_BYTES", 512) + else: + monkeypatch.setattr(effect_runtime.socket, "create_connection", denied_connection) + return capture + + def unexpected_effect(*_args, **_kwargs): + raise AssertionError("transport refusal must precede execution effects") + + runtime = tmp_path / "staged-transport-runtime" + monkeypatch.setattr(executor, "stage_turn_decision_capture", stage_then_fail_transport) + with pytest.raises((effect_runtime.EffectRuntimeRejected, effect_runtime.EffectRuntimeHostPermissionError)) as refused: + executor.run_loopx_turn_once(plan, host_runner=unexpected_effect, + project=tmp_path / "project", runtime_root=runtime, goal_id=original["goal_id"], + timeout_seconds=5, execute=True, writeback=unexpected_effect, + spend=unexpected_effect, scheduler=unexpected_effect, admit_start=unexpected_effect, + decision_capture_payload=original, require_decision_capture=True) + if failure == "snapshot_oversized": + assert refused.value.diagnostic_code == "request_too_large" + assert str(refused.value) == "TypeScript Effect runtime local snapshot is oversized" + assert [item[2] for item in operations] == ([False, True] * (2 if optional_context else 1)) + else: + assert refused.value.diagnostic_code == "runtime_host_permission_denied" + assert str(refused.value) == ("Host permission denied access to the local TypeScript Effect runtime " + "before request dispatch; no capability operation was executed") + assert [item[2] for item in operations] == ([False] * (2 if optional_context else 1)) + if optional_context: + assert operations[0][:2] == ("quota.turn_envelope.evaluate", "host_context_binding") + assert operations[-1][0] == "quota.turn_envelope.evaluate" + assert operations[-1][1] in {"host_context", "host_dispatch_context"} + assert len(captures) == 1 and not captures[0].path.exists() + assert not turn_journal_path(runtime, goal_id=original["goal_id"], turn_key=request["turn_key"]).exists() + assert json.dumps(plan, ensure_ascii=False) == original_carrier + assert json.dumps(captures[0].observation, ensure_ascii=False) == json.dumps(original, ensure_ascii=False) + assert not list(runtime.rglob("*.jsonl")) + + def test_typed_result_recovery_does_not_start_a_pending_goal_host( complete_host_request, tmp_path, ):