Skip to content

Commit 9b59876

Browse files
committed
refactor(control-plane): resolve turn result kind through effect turn
1 parent e9430cb commit 9b59876

2 files changed

Lines changed: 34 additions & 2 deletions

File tree

loopx/control_plane/turn_driver/executor.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
from ...authority import validate_public_safe_text
1515
from ...file_lock import exclusive_file_lock
16+
from ..effect_program import interpret_turn_result_packet
1617
from ..goals.goal_vision import normalize_goal_vision_packet
1718
from ..work_items.delivery_batch_scale import require_delivery_batch_scale
1819
from ..work_items.delivery_outcome import require_delivery_outcome
@@ -851,7 +852,8 @@ def _task_validation_stage(
851852
journal_path: Path,
852853
effects: dict[str, bool],
853854
) -> tuple[list[str], dict[str, Any] | None]:
854-
kind = LoopXTurnResultKind(str(result["result_kind"]))
855+
turn = interpret_turn_result_packet(result)
856+
kind = LoopXTurnResultKind(turn.observation.decision)
855857
if kind in STOP_HOST_RESULT_KINDS:
856858
completed_phases = list(TRANSACTION_PHASES[:3])
857859
journal.update(

tests/test_loopx_turn_executor.py

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@
1313
run_loopx_turn_once,
1414
validate_loopx_turn_host_result,
1515
)
16-
from loopx.control_plane.turn_driver.executor import BuiltInHostError
16+
from loopx.control_plane.turn_driver.executor import (
17+
BuiltInHostError,
18+
_task_validation_stage,
19+
)
20+
from loopx.control_plane.turn_driver.transaction import TRANSACTION_PHASES
1721

1822

1923
def _plan() -> dict[str, object]:
@@ -87,6 +91,32 @@ def _host_result(plan: dict[str, object], *, kind: str = "validated_progress") -
8791
return result
8892

8993

94+
def test_task_validation_stage_reads_result_kind_through_effect_turn(
95+
tmp_path: Path,
96+
) -> None:
97+
plan = _plan()
98+
result = _host_result(plan, kind="wait")
99+
journal = {
100+
"status": "in_progress",
101+
"completed_phases": list(TRANSACTION_PHASES[:2]),
102+
}
103+
104+
completed, payload = _task_validation_stage(
105+
plan,
106+
result,
107+
task_validator=None,
108+
completed_phases=list(TRANSACTION_PHASES[:2]),
109+
journal=journal,
110+
journal_path=tmp_path / "journal.json",
111+
effects={},
112+
)
113+
114+
assert completed == list(TRANSACTION_PHASES[:3])
115+
assert journal["status"] == "stopped"
116+
assert payload is not None
117+
assert payload["status"] == "stopped"
118+
119+
90120
def _host_argv(result_path: Path, count_path: Path) -> list[str]:
91121
script = """
92122
import json

0 commit comments

Comments
 (0)