fix(p0): secure agent revocation and R6 worker queue

This commit is contained in:
Dom
2026-06-02 15:52:35 +02:00
parent 2dd306724c
commit 7a1a5cb6fd
11 changed files with 2869 additions and 109 deletions

View File

@@ -15,13 +15,20 @@ if str(ROOT) not in sys.path:
@pytest.fixture
def isolated_replay_state(monkeypatch):
def isolated_replay_state(monkeypatch, tmp_path):
monkeypatch.setenv("RPA_API_TOKEN", "test_replay_single_inflight_token")
from agent_v0.server_v1 import api_stream
from agent_v0.server_v1.agent_registry import AgentRegistry
monkeypatch.setattr(api_stream, "API_TOKEN", "test_replay_single_inflight_token")
# Isoler le registre pour que _agent_registry_has_entries() retourne False
# (mode dev, aucun agent enrolle) — sinon le garde fleet bloque les tests
original_registry = api_stream.agent_registry
empty_registry = AgentRegistry(db_path=str(tmp_path / "empty_agents.db"))
monkeypatch.setattr(api_stream, "agent_registry", empty_registry)
if api_stream._replay_lock.locked():
pytest.fail(
"_replay_lock is already held at fixture setup — a previous test "
@@ -53,6 +60,7 @@ def isolated_replay_state(monkeypatch):
api_stream._machine_replay_target.update(saved_targets)
api_stream._last_heartbeat.clear()
api_stream._last_heartbeat.update(saved_heartbeat)
monkeypatch.setattr(api_stream, "agent_registry", original_registry)
def _running_replay_state(