fix(agent99): authorize observer recovery identity
All checks were successful
CD Pipeline / workflow-shape (push) Successful in 1s
CD Pipeline / cancel-stale-cd (push) Has been skipped
CD Pipeline / tests (push) Successful in 2m35s
CD Pipeline / build-and-deploy (push) Successful in 15m49s
AWOOOI Harbor 110 Local Repair / workflow-shape (push) Successful in 0s
AWOOOI Harbor 110 Local Repair / harbor-110-local-repair (push) Successful in 10s
CD Pipeline / post-deploy-checks (push) Successful in 2m18s
All checks were successful
CD Pipeline / workflow-shape (push) Successful in 1s
CD Pipeline / cancel-stale-cd (push) Has been skipped
CD Pipeline / tests (push) Successful in 2m35s
CD Pipeline / build-and-deploy (push) Successful in 15m49s
AWOOOI Harbor 110 Local Repair / workflow-shape (push) Successful in 0s
AWOOOI Harbor 110 Local Repair / harbor-110-local-repair (push) Successful in 10s
CD Pipeline / post-deploy-checks (push) Successful in 2m18s
This commit is contained in:
@@ -84,6 +84,7 @@ def test_agent99_runtime_has_local_correlation_dedupe_and_lock() -> None:
|
||||
assert "correlationKey = $correlationKey" in source
|
||||
assert "cold[-_ ]start|reboot[-_ ]auto[-_ ]recovery" in source
|
||||
for field in (
|
||||
"dispatchIdentitySchemaVersion",
|
||||
"automationRunId",
|
||||
"traceId",
|
||||
"workItemId",
|
||||
@@ -96,6 +97,8 @@ def test_agent99_runtime_has_local_correlation_dedupe_and_lock() -> None:
|
||||
|
||||
control_plane = CONTROL_PLANE.read_text(encoding="utf-8")
|
||||
assert "controlled_dispatch_identity_missing" in control_plane
|
||||
assert "controlled_dispatch_identity_invalid" in control_plane
|
||||
assert "Test-AgentControlledDispatchIdentity $dispatchIdentityEnvelope" in control_plane
|
||||
assert "-Name automationRunId" in control_plane
|
||||
assert "-Name traceId" in control_plane
|
||||
assert "-Name workItemId" in control_plane
|
||||
@@ -110,6 +113,17 @@ def test_agent99_runtime_has_local_correlation_dedupe_and_lock() -> None:
|
||||
assert evidence_ref in control_plane
|
||||
|
||||
|
||||
def test_agent99_queue_producers_project_canonical_identity_schema() -> None:
|
||||
inbox = SRE_INBOX.read_text(encoding="utf-8")
|
||||
relay = (ROOT / "agent99-sre-alert-relay.ps1").read_text(encoding="utf-8")
|
||||
submit = (ROOT / "agent99-submit-request.ps1").read_text(encoding="utf-8")
|
||||
|
||||
assert '$dispatchIdentitySchemaVersion = [string](Get-AgentField $dispatchIdentity "schema_version" "")' in inbox
|
||||
assert inbox.count("dispatchIdentitySchemaVersion = $dispatchIdentitySchemaVersion") >= 2
|
||||
assert 'dispatchIdentitySchemaVersion = [string](Get-AgentField $identity "schema_version" "")' in relay
|
||||
assert submit.count("dispatchIdentitySchemaVersion = $dispatchIdentity.schemaVersion") >= 2
|
||||
|
||||
|
||||
def test_agent99_mutating_inbox_requires_complete_typed_dispatch_envelope() -> None:
|
||||
source = SRE_INBOX.read_text(encoding="utf-8")
|
||||
guard = source[
|
||||
|
||||
@@ -7,6 +7,7 @@ ROOT = Path(__file__).resolve().parents[3]
|
||||
CONTROL = ROOT / "agent99-control-plane.ps1"
|
||||
DEPLOY = ROOT / "agent99-deploy.ps1"
|
||||
BOOTSTRAP = ROOT / "agent99-bootstrap.ps1"
|
||||
CONTRACT_CHECK = ROOT / "agent99-contract-check.ps1"
|
||||
SRE_INBOX = ROOT / "agent99-sre-alert-inbox.ps1"
|
||||
REMOTE_ATOMIC_RECEIVER = (
|
||||
ROOT / "scripts/reboot-recovery/agent99-remote-atomic-deploy-receiver.ps1"
|
||||
@@ -30,14 +31,94 @@ def test_agent99_uses_dedicated_identity_and_preferred_jump_route() -> None:
|
||||
|
||||
def test_agent99_auto_recovery_is_single_flight_and_slo_measured() -> None:
|
||||
source = CONTROL.read_text(encoding="utf-8")
|
||||
contract = CONTRACT_CHECK.read_text(encoding="utf-8")
|
||||
trigger = source[source.index("function Start-AgentRecoveryFromObservation") :]
|
||||
trigger = trigger[: trigger.index("function Get-AgentRecoverySloConfig")]
|
||||
identity = source[source.index("function New-AgentCanonicalControlledDispatchIdentity") :]
|
||||
identity = identity[: identity.index("function Get-AgentIncidentCardModel")]
|
||||
consumer = source[source.index("function Invoke-AgentQueuedCommands") :]
|
||||
consumer = consumer[: consumer.index("function Invoke-AgentControlTick")]
|
||||
|
||||
assert 'reason = "recovery_already_queued"' in trigger
|
||||
assert 'reason = "recovery_trigger_cooldown"' in trigger
|
||||
assert '"recovery-trigger-reservation.lock"' in trigger
|
||||
assert "Enter-AgentRecoveryTriggerReservation $reservationPath" in trigger
|
||||
assert 'reason = [string]$reservation.reason' in trigger
|
||||
assert 'source = "agent99-recovery-observer"' in trigger
|
||||
assert 'mode = "Recover"' in trigger
|
||||
assert "Start-Process" not in trigger
|
||||
assert "New-AgentObservedRecoveryDispatchIdentity" in trigger
|
||||
assert "-RequestId" not in trigger
|
||||
assert "-Observation $Observation" in trigger
|
||||
assert "-CooldownMinutes $autoRecovery.cooldownMinutes" in trigger
|
||||
for field in (
|
||||
"dispatchIdentitySchemaVersion",
|
||||
"automationRunId",
|
||||
"traceId",
|
||||
"workItemId",
|
||||
"idempotencyKey",
|
||||
"executionGeneration",
|
||||
"incidentId",
|
||||
"approvalId",
|
||||
"projectId",
|
||||
"sourceFingerprint",
|
||||
"dispatchRouteId",
|
||||
"singleFlightKey",
|
||||
"lockOwner",
|
||||
"canonicalDigest",
|
||||
):
|
||||
assert f"{field} = $dispatchIdentity." in trigger
|
||||
assert 'schema_version = "agent99_controlled_dispatch_identity_v1"' in identity
|
||||
assert '-RouteId "agent99_local_observer"' in identity
|
||||
assert 'idempotencyKey = "agent99-controlled:$digest"' in identity
|
||||
assert 'singleFlightKey = "agent99-controlled-flight:$singleFlightDigest"' in identity
|
||||
normalized = identity[identity.index("$normalized = [ordered]@{") : identity.index("$canonical =")]
|
||||
normalized_fields = (
|
||||
"approval_id",
|
||||
"execution_generation",
|
||||
"incident_id",
|
||||
"project_id",
|
||||
"route_id",
|
||||
"source_fingerprint",
|
||||
"work_item_id",
|
||||
)
|
||||
assert [normalized.index(f"{field} =") for field in normalized_fields] == sorted(
|
||||
normalized.index(f"{field} =") for field in normalized_fields
|
||||
)
|
||||
public = identity[identity.index("$public = [ordered]@{") : identity.index("[pscustomobject]@{")]
|
||||
public_fields = (
|
||||
"approval_id",
|
||||
"execution_generation",
|
||||
"idempotency_key",
|
||||
"incident_id",
|
||||
"lock_owner",
|
||||
"project_id",
|
||||
"route_id",
|
||||
"run_id",
|
||||
"schema_version",
|
||||
"single_flight_key",
|
||||
"source_fingerprint",
|
||||
"trace_id",
|
||||
"work_item_id",
|
||||
)
|
||||
assert [public.index(f"{field} =") for field in public_fields] == sorted(
|
||||
public.index(f"{field} =") for field in public_fields
|
||||
)
|
||||
assert "function Test-AgentControlledDispatchIdentity" in identity
|
||||
assert "function Enter-AgentRecoveryTriggerReservation" in identity
|
||||
assert "[System.IO.FileShare]::None" in identity
|
||||
assert "function Invoke-AgentControlledDispatchIdentitySelfTest" in identity
|
||||
assert "concurrentTriggerSuppressed" in identity
|
||||
assert "tamperedIdentityRejected" in identity
|
||||
assert "Test-AgentControlledDispatchIdentity $dispatchIdentityEnvelope" in consumer
|
||||
assert '"controlled_dispatch_identity_invalid"' in consumer
|
||||
assert consumer.index('"controlled_dispatch_identity_invalid"') < consumer.index(
|
||||
'$process = Start-Process -FilePath "powershell.exe"'
|
||||
)
|
||||
assert 'Add-Check "recovery:auto_trigger_controlled_identity"' in contract
|
||||
assert 'Add-Check "recovery:queue_identity_fail_closed"' in contract
|
||||
assert 'correlationKey = $dispatchIdentity.idempotencyKey' in contract
|
||||
assert 'canonicalDigest = $dispatchIdentity.canonicalDigest' in contract
|
||||
assert 'Record-AgentEvent "recovery_slo_result"' in source
|
||||
assert "withinSlo = $withinSlo" in source
|
||||
assert "function Invoke-AgentHost112GuestRecovery" in source
|
||||
|
||||
Reference in New Issue
Block a user