from __future__ import annotations from pathlib import Path ROOT = Path(__file__).resolve().parents[3] SCRIPT = ROOT / "scripts" / "ops" / "retire-host110-ollama-proxy.sh" def test_retirement_is_exact_bounded_and_rollback_capable() -> None: text = SCRIPT.read_text(encoding="utf-8") assert 'TRACE_ID="${TRACE_ID:?TRACE_ID is required}"' in text assert 'RUN_ID="${RUN_ID:?RUN_ID is required}"' in text assert 'WORK_ITEM_ID="${WORK_ITEM_ID:?WORK_ITEM_ID is required}"' in text assert 'CONFIG_PATH="/etc/nginx/sites-enabled/110-ollama-proxy.conf"' in text assert "flock -n 9" in text assert "source_sha=" in text assert "persistent_writes_performed=0" in text assert "rollback_receipt" in text assert "terminal=rollback_failed" in text assert "sudo -n nginx -t" in text assert "sudo -n systemctl reload nginx" in text assert "completed_already_converged_no_write" in text assert "state=already_retired" in text def test_retirement_proves_the_retired_identity_cannot_reappear() -> None: text = SCRIPT.read_text(encoding="utf-8") assert "listener_11435=0" in text assert "listener_11434=0" in text assert "ollama_containers=0" in text assert "stale_config_paths=0" in text assert "grep -RIl" in text assert "rm -rf" not in text assert "pkill" not in text assert "killall" not in text