Files
Assistant/tests/creator_web/verify-remote.ps1
T
m 6a5550b7b0
CI / test (push) Failing after 15m2s
feat: show Creator continuity in Domovoy
2026-08-16 15:51:18 +03:00

62 lines
3.9 KiB
PowerShell

param(
[string]$DockerContext = "docker-prod",
[string]$BaseURL = "http://docker.cin.su:18080"
)
$ErrorActionPreference = "Stop"
$coreContainer = "assistant-core-runtime-1"
$continuityContainer = "assistant-continuity-runtime-1"
function Post-ContinuityJson([string]$url, [object]$body) {
$json = $body | ConvertTo-Json -Depth 8 -Compress
$local = New-TemporaryFile
$remote = "/tmp/domovoy-$([guid]::NewGuid().ToString('N')).json"
try {
[IO.File]::WriteAllText($local, $json, [Text.UTF8Encoding]::new($false))
docker --context $DockerContext cp $local "${continuityContainer}:$remote" | Out-Null
docker --context $DockerContext exec $continuityContainer wget -qO- --header "Content-Type: application/json" --post-file $remote $url
if ($LASTEXITCODE -ne 0) { throw "Continuity fixture creation failed" }
} finally {
docker --context $DockerContext exec --user root $continuityContainer rm -f $remote 2>$null
Remove-Item -LiteralPath $local -Force
}
}
$health = Invoke-RestMethod -Uri "$BaseURL/healthz" -Method Get
if ($health.status -ne "ok" -or $health.runtime -ne "creator-web") { throw "Creator web health response is invalid" }
$page = Invoke-WebRequest -Uri "$BaseURL/" -Method Get
if ($page.StatusCode -ne 200 -or $page.Content -notmatch "Домовой") { throw "Creator console is not available" }
if (-not $page.Headers["Content-Security-Policy"]) { throw "Creator console security headers are missing" }
$denied = Invoke-WebRequest -Uri "$BaseURL/api/focus-task-commits" -Method Post -SkipHttpErrorCheck
if ($denied.StatusCode -ne 404) { throw "Internal mutation route was exposed" }
$continuityMutation = Invoke-WebRequest -Uri "$BaseURL/api/prospective-items/blocked" -Method Post -SkipHttpErrorCheck
if ($continuityMutation.StatusCode -ne 404) { throw "Continuity mutation route was exposed" }
$invalid = Invoke-WebRequest -Uri "$BaseURL/api/session/current" -Headers @{Authorization="Bearer invalid"} -SkipHttpErrorCheck
if ($invalid.StatusCode -ne 401) { throw "Invalid Creator session was not denied" }
$environment = docker --context $DockerContext inspect --format '{{range .Config.Env}}{{println .}}{{end}}' $coreContainer
$bootstrapEntry = $environment | Where-Object { $_ -like "CREATOR_BOOTSTRAP_TOKEN=*" } | Select-Object -First 1
if (-not $bootstrapEntry) { throw "Creator bootstrap token is not configured" }
$bootstrapToken = $bootstrapEntry.Substring("CREATOR_BOOTSTRAP_TOKEN=".Length)
$issued = Invoke-RestMethod -Uri "$BaseURL/api/session" -Method Post -Headers @{Authorization="Bearer $bootstrapToken"}
if (-not $issued.Token) { throw "Creator session was not issued through the gateway" }
$current = Invoke-RestMethod -Uri "$BaseURL/api/session/current" -Method Get -Headers @{Authorization="Bearer $($issued.Token)"}
if ($current.ActorID -ne "domovoy-creator-actor") { throw "Creator identity was not preserved through the gateway" }
$capability = Invoke-RestMethod -Uri "$BaseURL/api/capabilities/cognitive-proposal/health" -Method Get -Headers @{Authorization="Bearer $($issued.Token)"}
if ($capability.CapabilityID -ne "cognitive-proposal") { throw "Capability health was not returned through the gateway" }
$suffix = [guid]::NewGuid().ToString("N")
$prospectiveID = "web-prospective-$suffix"
Post-ContinuityJson "http://localhost:8081/v1/prospective-items" @{
ID=$prospectiveID;CommitmentID="web-commitment-$suffix";OwnerPrincipalID="domovoy-creator-principal"
ScopeID="domovoy-global-scope";GoalID="web-goal-$suffix";TriggerAtUnixMillis=1800000000000
State="ARMED";Revision=1
}
$prospective = Invoke-RestMethod -Uri "$BaseURL/api/prospective-items/$prospectiveID" -Method Get -Headers @{Authorization="Bearer $($issued.Token)"}
if ($prospective.ID -ne $prospectiveID -or $prospective.State -ne "ARMED") { throw "ProspectiveItem was not returned through the gateway" }
Write-Output "DEV-000027 remote Creator Continuity console: PASS"