Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions examples/dsh-turn-host-adapter-smoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from __future__ import annotations

from hashlib import sha256
import importlib.util
import json
import subprocess
import sys
Expand All @@ -21,6 +22,16 @@
if path not in sys.path:
sys.path.insert(0, path)

# The generic-cli e2e smoke owns the fake runner source every host smoke reuses,
# because a fake runner whose keyword signature lags the adapter turns into an
# unattributed ``host_failure`` instead of naming the seam that moved.
_BASE_PATH = REPO_ROOT / "examples" / "loopx-turn-dsh-e2e-smoke.py"
_SPEC = importlib.util.spec_from_file_location("loopx_turn_dsh_e2e_smoke", _BASE_PATH)
assert _SPEC is not None and _SPEC.loader is not None
_base = importlib.util.module_from_spec(_SPEC)
sys.modules[_SPEC.name] = _base
_SPEC.loader.exec_module(_base)

import dsh_turn_host_adapter as adapter # noqa: E402
from loopx.control_plane.turn_driver.executor import ( # noqa: E402
validate_loopx_turn_host_result,
Expand Down Expand Up @@ -284,11 +295,10 @@ def test_subprocess_adapter_roundtrip_with_fake_dsh_runner() -> None:
)
runner.write_text(
"import json, pathlib, sys\n"
"def run_dsh_turn(*, prompt, session_id, workspace, session_root,\n"
" provider, model, max_tokens, cordis, runtime_bin,\n"
" request_timeout_seconds):\n"
f" pathlib.Path({str(marker)!r}).write_text(prompt, encoding='utf-8')\n"
f" return {block!r}\n",
+ _base.FAKE_DSH_RUNNER_SIGNATURE
+ f" pathlib.Path({str(marker)!r}).write_text(prompt, "
+ "encoding='utf-8')\n"
+ f" return {block!r}\n",
encoding="utf-8",
)

Expand Down
24 changes: 18 additions & 6 deletions examples/loopx-turn-dsh-e2e-smoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,20 @@
MARKER_VALUE = "loopx-turn-dsh-e2e-step-1"
ADAPTER = REPO_ROOT / "scripts" / "dsh_turn_host_adapter.py"

# The fake runner stands in for the DeepSeek Harness host, so its keyword
# signature must track the keyword set the adapter supplies, which
# ``loopx.dsh_goal_mode.turn_host_adapter.load_dsh_runner`` documents. Three
# smokes load a fake runner, so the signature is emitted from this one place: a
# fixture that lags the adapter otherwise surfaces as an unattributed
# ``host_failure`` instead of a readable error at the seam that moved.
FAKE_DSH_RUNNER_SIGNATURE = (
"def run_dsh_turn(*, prompt, session_id, workspace, session_root,\n"
" provider, model, reasoning_effort, max_tokens, cordis,\n"
" runtime_bin, request_timeout_seconds):\n"
" assert provider and model and reasoning_effort, (\n"
" 'the adapter must hand over the resolved execution profile')\n"
)


def _write_fixture(root: Path) -> tuple[Path, Path, Path, Path]:
project = root / "project"
Expand Down Expand Up @@ -127,12 +141,10 @@ def _write_fake_dsh_runner(root: Path, workspace: Path) -> Path:
)
runner.write_text(
"import pathlib\n"
"def run_dsh_turn(*, prompt, session_id, workspace, session_root,\n"
" provider, model, max_tokens, cordis, runtime_bin,\n"
" request_timeout_seconds):\n"
f" pathlib.Path({str(workspace)!r}).joinpath({MARKER_NAME!r}).write_text("
f"{MARKER_VALUE!r}, encoding='utf-8')\n"
f" return {block!r}\n",
+ FAKE_DSH_RUNNER_SIGNATURE
+ f" pathlib.Path({str(workspace)!r}).joinpath({MARKER_NAME!r}).write_text("
+ f"{MARKER_VALUE!r}, encoding='utf-8')\n"
+ f" return {block!r}\n",
encoding="utf-8",
)
return runner
Expand Down
Loading