from pathlib import Path ROOT = Path(__file__).resolve().parents[3] SCRIPT = ROOT / "scripts/reboot-recovery/agent99-stale-queue-quarantine.ps1" def test_stale_queue_quarantine_is_exact_recoverable_and_receipted() -> None: source = SCRIPT.read_text(encoding="utf-8") assert '[ValidateSet("Check", "Apply")]' in source assert "ExpectedQueueSha256" in source assert "ExpectedMaintenanceSha256" in source assert '"Global\\WoooAgent99StaleQueueMaintenanceV1"' in source assert '"Global\\WoooAgent99RecoveryTransportV1"' in source assert 'Get-ScheduledTask `' in source assert '"Wooo-Agent99-Control-Loop"' in source assert 'throw "control_loop_not_frozen"' in source assert 'throw "active_control_or_recover_process"' in source assert 'throw "recovery_lease_present"' in source assert 'throw "recovery_mutex_active"' in source assert '[string]$command.mode -ne "Recover"' in source assert '[string]$command.source -ne "agent99-recovery-observer"' in source assert "$command.controlledApply -isnot [bool]" in source assert '"atomic_move_exact_queue_item_to_failed"' in source assert "[IO.File]::Move($sourcePath, $destinationPath)" in source assert "[IO.File]::Move($destinationPath, $sourcePath)" in source assert '"verified_quarantined"' in source assert '"failed_rolled_back"' in source assert '"rollback_unverified"' in source def test_stale_queue_quarantine_does_not_execute_or_delete_command() -> None: source = SCRIPT.read_text(encoding="utf-8") assert "commandExecuted = $false" in source assert "deletePerformed = $false" in source assert "otherQueueMutationPerformed = $false" in source assert "rawInstructionStored = $false" in source assert "secretValueRead = $false" in source assert "Remove-Item -LiteralPath $sourcePath" not in source assert "Start-ScheduledTask" not in source assert "Invoke-Expression" not in source assert "& $command" not in source