Files
aios/tests/test_worker_availability_runtime_config.py
T

57 lines
2.2 KiB
Python

from __future__ import annotations
from pathlib import Path
ROOT=Path(__file__).resolve().parents[1]
def test_worker_source_has_idle_and_busy_liveness():
source=(ROOT/"active-runtime/app/aios_online_agent_worker.py").read_text()
assert "aios.online-agent.worker-liveness.v1" in source
assert 'write_worker_liveness("POLL_OK"' in source
assert '"POLL_FAILED"' in source
assert 'write_worker_liveness("STARTING")' in source
assert '"BUSY"' in source
assert "last_seen_epoch" in source
def test_guard_timer_is_persistent_and_frequent():
timer=(ROOT/"deploy/systemd/aios-worker-availability-guard.timer").read_text()
assert "OnBootSec=15s" in timer
assert "OnUnitActiveSec=30s" in timer
assert "Persistent=true" in timer
assert "WantedBy=timers.target" in timer
def test_guard_service_has_no_network_or_credentials():
unit=(ROOT/"deploy/systemd/aios-worker-availability-guard.service").read_text()
assert "User=root" in unit
assert "LoadCredential" not in unit
assert "RestrictAddressFamilies=AF_UNIX" in unit
assert "NoNewPrivileges=true" in unit
assert "ProtectSystem=strict" in unit
assert "ReadWritePaths=/run/aios-worker-availability" in unit
assert "AIOS_WORKER_AVAILABILITY_MAX_STALE_SECONDS=90" in unit
def test_guard_manages_all_three_workers_and_external_executor():
source=(ROOT/"active-runtime/app/aios_worker_availability_guard.py").read_text()
for unit in (
"aios-online-agent-worker-20260815.service",
"aios-hermes-online-agent-worker.service",
"aios-openclaw-online-agent-worker.service",
"aios-external-agent-executor.service",
):
assert unit in source
assert "maintenance.lock" in source
assert "RESTART_STALE" in source
def test_worker_defers_write_capable_source_capture_until_plan_exists():
source=(ROOT/"active-runtime/app/aios_online_agent_worker.py").read_text()
assert "ENGINEERING_WRITE_CAPABILITIES" in source
assert "source_capture_requires_deterministic_plan" in source
assert "TASK_SKIPPED_PENDING_DETERMINISTIC_PLAN" in source
assert '"governed.write.branch"' in source
assert '"governed.write.file"' in source