fix(agent99): restore autonomous recovery transport
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[3]
|
||||
CONTROL = ROOT / "agent99-control-plane.ps1"
|
||||
DEPLOY = ROOT / "agent99-deploy.ps1"
|
||||
BOOTSTRAP = ROOT / "agent99-bootstrap.ps1"
|
||||
|
||||
|
||||
def test_agent99_uses_dedicated_identity_and_preferred_jump_route() -> None:
|
||||
source = CONTROL.read_text(encoding="utf-8")
|
||||
function = source[source.index("function Invoke-HostSshText") :]
|
||||
function = function[: function.index("function Convert-AgentDouble")]
|
||||
|
||||
assert '"sshIdentityFile"' in source
|
||||
assert '"IdentitiesOnly=yes"' in source
|
||||
assert 'PSObject.Properties["preferJumpHost"]' in function
|
||||
assert 'PSObject.Properties["directHosts"]' in function
|
||||
assert function.index("if ($preferJumpHost -and $canUseJump)") < function.index(
|
||||
"$direct = Invoke-SshText"
|
||||
)
|
||||
assert 'Write-AgentLog "ssh_jump_fallback' in function
|
||||
|
||||
|
||||
def test_agent99_auto_recovery_is_single_flight_and_slo_measured() -> None:
|
||||
source = CONTROL.read_text(encoding="utf-8")
|
||||
trigger = source[source.index("function Start-AgentRecoveryFromObservation") :]
|
||||
trigger = trigger[: trigger.index("function Get-AgentRecoverySloConfig")]
|
||||
|
||||
assert 'reason = "recovery_already_queued"' in trigger
|
||||
assert 'reason = "recovery_trigger_cooldown"' in trigger
|
||||
assert 'source = "agent99-recovery-observer"' in trigger
|
||||
assert 'mode = "Recover"' in trigger
|
||||
assert "Start-Process" not in trigger
|
||||
assert 'Record-AgentEvent "recovery_slo_result"' in source
|
||||
assert "withinSlo = $withinSlo" in source
|
||||
|
||||
|
||||
def test_agent99_99_config_has_bounded_transport_and_recovery_defaults() -> None:
|
||||
config = json.loads((ROOT / "agent99.config.99.example.json").read_text())
|
||||
|
||||
assert config["sshIdentityFile"].endswith(r"keys\agent99_ed25519")
|
||||
assert config["k3s"]["jumpHost"] == "192.168.0.110"
|
||||
assert config["k3s"]["preferJumpHost"] is True
|
||||
assert config["k3s"]["directHosts"] == ["192.168.0.110", "192.168.0.112"]
|
||||
assert config["autoRecovery"]["enabled"] is True
|
||||
assert config["autoRecovery"]["cooldownMinutes"] == 10
|
||||
assert config["recoverySlo"]["targetMinutes"] == 10
|
||||
|
||||
|
||||
def test_agent99_deployer_verifies_promoted_runtime_and_writes_revision() -> None:
|
||||
deploy = DEPLOY.read_text(encoding="utf-8")
|
||||
bootstrap = BOOTSTRAP.read_text(encoding="utf-8")
|
||||
|
||||
assert 'schemaVersion = "agent99_deploy_receipt_v2"' in deploy
|
||||
assert 'schemaVersion = "agent99_runtime_manifest_v1"' in deploy
|
||||
assert "sourceRevision = $SourceRevision" in deploy
|
||||
assert 'Join-Path $BinDir "agent99-contract-check.ps1"' in deploy
|
||||
assert 'Join-Path $BinDir "agent99-synthetic-tests.ps1"' in deploy
|
||||
assert "if (-not $runtimeMatched)" in deploy
|
||||
for name in (
|
||||
"agent99-contract-check.ps1",
|
||||
"agent99-deploy.ps1",
|
||||
"agent99-synthetic-tests.ps1",
|
||||
):
|
||||
assert f'"{name}"' in deploy
|
||||
assert f'"{name}"' in bootstrap
|
||||
Reference in New Issue
Block a user