fix(k1): allow explicit reset after terminal start fault
This commit is contained in:
@@ -1722,6 +1722,72 @@ def test_terminal_cleanup_pending_is_locally_sealed_by_mode_reset(
|
||||
assert reset["connection_scenario_reset"]["network_write_performed"] is False
|
||||
|
||||
|
||||
def test_terminal_ambiguous_start_failure_can_be_locally_reset_after_worker_exit(
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
tmp_path: Path,
|
||||
) -> None:
|
||||
service = _service(monkeypatch, tmp_path)
|
||||
_seed_resettable_physical_record(service)
|
||||
acquisition = AcquisitionRecord(
|
||||
acquisition_id="reset-preflight-acquisition-0001",
|
||||
device_id="device-reset-terminal-start-fault",
|
||||
device_session_id="device-session-reset-terminal-start-fault",
|
||||
compatibility_profile_id=("xgrids.lixelkity-k1.fw-3.0.2.local-network.v2"),
|
||||
control_mode="plugin-commanded",
|
||||
requested_streams=("points",),
|
||||
target_host="192.168.68.51",
|
||||
duration_seconds=None,
|
||||
evidence_policy="required",
|
||||
)
|
||||
acquisition.transition(
|
||||
"failed",
|
||||
message_code="acquisition.start.device_outcome_unknown",
|
||||
result={
|
||||
"receiver_stopped": False,
|
||||
"device_start": "outcome-unknown",
|
||||
},
|
||||
)
|
||||
control = service._application_control_session # noqa: SLF001
|
||||
with control._lock: # noqa: SLF001
|
||||
control._set_phase_locked("failed") # noqa: SLF001
|
||||
control._failure = { # noqa: SLF001
|
||||
"reason_code": "device_status_fault",
|
||||
"safe_to_retry": False,
|
||||
"modeling_command_attempted": True,
|
||||
"outcome_unknown": True,
|
||||
}
|
||||
control._thread = None # noqa: SLF001
|
||||
control._transport = None # noqa: SLF001
|
||||
with service._lock: # noqa: SLF001
|
||||
service._acquisition = acquisition # noqa: SLF001
|
||||
|
||||
before = control.snapshot()
|
||||
assert before["state"] == "failed"
|
||||
assert before["can_open"] is False
|
||||
|
||||
reset = service.select_connection_mode(
|
||||
_reset(
|
||||
mode="bridge",
|
||||
revision=0,
|
||||
reset_id="op-reset-terminal-ambiguous-start-01",
|
||||
)
|
||||
)
|
||||
|
||||
assert reset["desired_connection_mode_revision"] == 1
|
||||
assert reset["connection_scenario_reset"]["local_session_closed"] is True
|
||||
assert reset["connection_scenario_reset"]["physical_disposition"] == (
|
||||
"operator-retired-outcome-unknown"
|
||||
)
|
||||
assert reset["connection_scenario_reset"]["device_command_performed"] is False
|
||||
assert reset["connection_scenario_reset"]["network_write_performed"] is False
|
||||
assert reset["application_control_session"]["state"] == "idle"
|
||||
assert reset["acquisition"]["state"] == "failed"
|
||||
assert reset["acquisition"]["cleanup_pending"] is False
|
||||
physical = service._physical_command_ledger.snapshot().record # noqa: SLF001
|
||||
assert physical is not None
|
||||
assert physical.resolution == "operator-retired-outcome-unknown"
|
||||
|
||||
|
||||
def test_terminal_cleanup_failure_stays_visible_and_exact_reset_can_retry(
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
tmp_path: Path,
|
||||
|
||||
Reference in New Issue
Block a user