fix(k1): restore low-latency live recovery path
This commit is contained in:
@@ -193,6 +193,7 @@ class FakePhysicalCommandCoordinator:
|
||||
self.resolutions: list[tuple[str, str | None]] = []
|
||||
self.phase_probe: Callable[[], str] | None = None
|
||||
self.snapshot_override: dict[str, object] | None = None
|
||||
self.snapshot_calls = 0
|
||||
|
||||
def bind_control_session(self, binding: PhysicalCommandRuntimeBinding) -> None:
|
||||
self.bindings.append(binding)
|
||||
@@ -217,6 +218,7 @@ class FakePhysicalCommandCoordinator:
|
||||
self.resolutions.append((f"{action}-not-dispatched", phase))
|
||||
|
||||
def snapshot(self) -> dict[str, object]:
|
||||
self.snapshot_calls += 1
|
||||
if self.snapshot_override is not None:
|
||||
return self.snapshot_override
|
||||
return {
|
||||
@@ -433,6 +435,36 @@ def _successful_start_checkpoint_observer(
|
||||
return None
|
||||
|
||||
|
||||
def test_control_only_snapshot_reuses_preverified_physical_command() -> None:
|
||||
coordinator = FakePhysicalCommandCoordinator()
|
||||
session = InteractiveApplicationControlSession(
|
||||
FakeAuthorityLoader(),
|
||||
transport_factory=FakeTransport, # type: ignore[arg-type]
|
||||
physical_command_coordinator=coordinator, # type: ignore[arg-type]
|
||||
)
|
||||
|
||||
control_only = session.snapshot_control_only()
|
||||
assert control_only["state"] == "idle"
|
||||
assert control_only["physical_command"] is None
|
||||
assert coordinator.snapshot_calls == 0
|
||||
|
||||
verified_physical = {
|
||||
"status": "resolved",
|
||||
"requires_reconciliation": False,
|
||||
}
|
||||
joined = session.snapshot_with_physical_command(verified_physical)
|
||||
assert joined["physical_command"] == verified_physical
|
||||
assert coordinator.snapshot_calls == 0
|
||||
|
||||
regular = session.snapshot()
|
||||
assert regular["physical_command"] == {
|
||||
"status": "test",
|
||||
"requires_reconciliation": False,
|
||||
"automatic_replay_allowed": False,
|
||||
}
|
||||
assert coordinator.snapshot_calls == 1
|
||||
|
||||
|
||||
def test_canonical_stages_require_operator_events_but_device_standby_does_not(
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
|
||||
Reference in New Issue
Block a user