feat(events): deliver state changes to the configurable operator event center

This commit is contained in:
DCCONSTRUCTIONS
2026-11-21 20:58:27 +03:00
parent d4ed96f3cd
commit 1b67d5f7df
35 changed files with 2058 additions and 8 deletions
+23
View File
@@ -364,6 +364,29 @@ def test_client_controls_round_trip_with_exact_sim_and_guards(action):
assert fleet.routers.heartbeat(fleet.row, {})["router_commands"] == [request]
def test_policy_notification_uses_confirmed_heartbeat_and_keeps_timeout_identity(tmp_path):
from k1link.fleet.router_notifications import publish_router_results
from k1link.notifications import NotificationHistory
fleet, state, request = ready_client_control()
fleet.row['name'] = 'Test rover'
history = NotificationHistory(tmp_path)
receipt = fleet.routers.control(fleet, 'vehicle', request)
entry = fleet.routers.pending[('vehicle', request['operation_id'])]
entry['deadline'] = time.time() - 1
fleet.routers.prune()
publish_router_results(history, fleet.row, fleet.routers.pending)
assert history.listing()['items'][0]['tone'] == 'warning'
assert entry['public']['action'] == 'policy'
state['results'] = [{**receipt, 'state': 'complete', 'at': int(time.time())}]
fleet.routers.heartbeat(fleet.row, {'routers': state})
publish_router_results(history, fleet.row, fleet.routers.pending)
assert history.listing()['items'][0]['tone'] == 'success'
fleet.routers.heartbeat(fleet.row, {'routers': state})
publish_router_results(history, fleet.row, fleet.routers.pending)
assert len(history.listing()['items']) == 2
@pytest.mark.parametrize(
"change",
[