deploy: add production notification delivery
This commit was merged in pull request #11.
This commit is contained in:
@@ -4,6 +4,7 @@ $ErrorActionPreference = "Stop"
|
||||
$coreContainer = "assistant-core-runtime-1"
|
||||
$commitContainer = "assistant-commit-runtime-1"
|
||||
$continuityContainer = "assistant-continuity-runtime-1"
|
||||
$receiverContainer = "assistant-notification-receiver-1"
|
||||
|
||||
function Post-Json([string]$container, [string]$url, [object]$body) {
|
||||
$json = $body | ConvertTo-Json -Depth 10 -Compress
|
||||
@@ -101,4 +102,30 @@ if ($updated.State -ne "SATISFIED" -or $updated.Revision -ne 2) { throw "Creator
|
||||
Expect-CreatorStatus http://localhost:8082/v1/creator/continuity/satisfy-delivered $command $creatorSession 409
|
||||
Expect-CreatorStatus "http://localhost:8082/v1/creator/authorized-actions/$($action.AuthorizedActionID)/reconcile" @{} $creatorSession 409
|
||||
|
||||
$notificationProspective = "prospective-notification-$suffix"
|
||||
Post-Json $continuityContainer http://localhost:8081/v1/prospective-items @{
|
||||
ID=$notificationProspective;CommitmentID="commitment-notification-$suffix";OwnerPrincipalID="domovoy-creator-principal"
|
||||
ScopeID=$scope;GoalID=$goal;TriggerAtUnixMillis=1800000000000;State="DELIVERED";Revision=1
|
||||
} | Out-Null
|
||||
$notificationCommand = @{
|
||||
Target=@{TaskID=$task;GoalID=$goal;ScopeID=$scope;Revision=1}
|
||||
ProspectiveItemID=$notificationProspective;ExpectedRevision=1;Confirm=$true
|
||||
}
|
||||
Expect-CreatorStatus http://localhost:8082/v1/creator/continuity/notify-delivered $notificationCommand "invalid" 401
|
||||
$hostileNotification = $notificationCommand.Clone()
|
||||
$hostileNotification.URL = 'https://example.invalid'
|
||||
$hostileNotification.Body = 'arbitrary'
|
||||
Expect-CreatorStatus http://localhost:8082/v1/creator/continuity/notify-delivered $hostileNotification $creatorSession 400
|
||||
$notificationAction = Creator-Post http://localhost:8082/v1/creator/continuity/notify-delivered $notificationCommand $creatorSession | ConvertFrom-Json
|
||||
if ($notificationAction.State -ne 'SUCCEEDED' -or -not $notificationAction.ActionIntentID) { throw 'Creator notification did not produce a successful receipt' }
|
||||
$notificationItem = docker --context $DockerContext exec $continuityContainer wget -qO- "http://localhost:8081/v1/prospective-items/$notificationProspective" | ConvertFrom-Json
|
||||
if ($notificationItem.State -ne 'DELIVERED' -or $notificationItem.Revision -ne 1) { throw 'Notification changed Continuity canonical state' }
|
||||
$receiptRaw = docker --context $DockerContext exec $receiverContainer sh -c 'token=$(cat /run/notification-reader/token); wget -qO- --header="Authorization: Bearer $token" "$1"' sh "http://localhost:8085/delivery/v1/receipts/$($notificationAction.ActionIntentID)"
|
||||
if ($LASTEXITCODE -ne 0) { throw 'Notification receipt lookup failed' }
|
||||
$receipt = ($receiptRaw -join "`n") | ConvertFrom-Json
|
||||
if ($receipt.action_intent_id -ne $notificationAction.ActionIntentID -or $receipt.request_digest -notmatch '^[0-9a-f]{64}$') { throw 'Notification receipt evidence mismatch' }
|
||||
$notificationHistory = Creator-Get 'http://localhost:8082/v1/creator/authorized-actions?limit=50' $creatorSession | ConvertFrom-Json
|
||||
$notificationHistoryItem = @($notificationHistory.Items | Where-Object { $_.AuthorizedActionID -eq $notificationAction.AuthorizedActionID })
|
||||
if ($notificationHistoryItem.Count -ne 1 -or $notificationHistoryItem[0].Operation -ne 'deliver-prospective-notification-v1' -or $notificationHistoryItem[0].State -ne 'SUCCEEDED') { throw 'Notification action history is incomplete' }
|
||||
|
||||
Write-Output "Creator Commit command verification: PASS"
|
||||
|
||||
Reference in New Issue
Block a user