2026-05-21 10:17:38 +01:00
param (
2026-06-22 17:38:55 +01:00
[ ValidateSet ( " status " , " plan " , " smoke " , " run " , " mvp " , " agent-state-soa " , " swarm-status " , " swarm-poke-down " , " swarm-triage " , " cluster-topology " , " eve-surfaces " , " eve-connect " , " collaboration-feedback " , " persona-discord " , " persona-reddit " , " persona-other " , " persona-bridge " , " daemon-survival-rehearsal " , " repo-swarm-mvp-gate " , " repo-livefire-closure " , " bifrost-publication " , " bifrost-public-proof " , " bifrost-artifact-acceptance " , " bifrost-metrics " , " bifrost-accounting-bundle " , " bifrost-ledger " , " receipt-directory " , " tool-directory " , " tool-invoke " , " swarm-overview " , " gjallar " , " repo-persona-intake " , " repo-swarm-run " , " repo-work-queue-run " , " repo-work-public-proof " , " repo-work-readiness " , " repo-work-readiness-review " , " repo-deployment-config-audit " , " repo-deployment-runbook " , " repo-deployment-aftercare-audit " , " repo-work-service-plan " , " repo-work-service-runbook " , " repo-work-service-launch " , " repo-work-service-audit " , " swarm-online-runbook " , " service-policy-directory " , " service-plan " , " service-launch " , " service-runbook " , " cluster-service-runbook " , " cluster-service-install-plan " , " cluster-service-install-execute " , " cluster-service-audit " , " cluster-service-start-plan " , " cluster-service-stop-plan " , " cluster-service-start-execute " , " cluster-service-stop-execute " , " cluster-service-execution-readiness " , " cluster-service-execution-runbook " , " cluster-service-execution-audit " , " service-execution-runbook " , " service-install-plan " , " service-install-execute " , " service-tick " , " service-status " , " service-reconcile " , " service-execution-readiness " , " service-execution-audit " , " service-start-plan " , " service-stop-plan " , " service-start-execute " , " service-stop-execute " ) ]
2026-05-21 10:17:38 +01:00
[ string ] $Mode = " smoke " ,
[ string ] $Root = ( Resolve-Path " . " ) . Path ,
2026-05-21 10:18:52 +01:00
[ string ] $Workspace = " " ,
2026-06-21 01:16:30 +01:00
[ Alias ( " LocalVerseStore " ) ]
[ string ] $LocalVerseStoreOverride = " " ,
[ string ] $LocalVerseRuntimeId = " epiphany-local " ,
2026-05-21 10:18:52 +01:00
[ string ] $ThreadId = " " ,
2026-05-21 10:17:38 +01:00
[ string ] $CodexHome = " " ,
[ string ] $TargetDir = " C:\Users\Meta\.cargo-target-codex " ,
[ int ] $MaxSteps = 4 ,
2026-05-28 14:44:08 +01:00
[ int ] $TimeoutSeconds = 600 ,
2026-05-28 15:42:52 +01:00
[ int ] $MaxRuntimeSeconds = 180 ,
2026-06-18 15:24:47 +01:00
[ string ] $DaemonId = " * " ,
[ string ] $ServiceId = " epiphany-daemon-supervisor-service " ,
[ string ] $ServiceName = " " ,
[ string ] $ServiceDisplayName = " " ,
[ ValidateSet ( " auto " , " demand " , " disabled " ) ]
[ string ] $ServiceStartType = " demand " ,
[ string ] $SchedulerId = " epiphany-daemon-supervisor " ,
[ int ] $LoopIntervalSeconds = 60 ,
[ int ] $ServiceMaxIterations = 0 ,
[ string ] $EveTargetClusterId = " epiphany.cluster.persona " ,
[ string ] $EveAdvertisementId = " " ,
[ string ] $CollaborationTopic = " local-swarm-collaboration " ,
[ string ] $CollaborationFeedbackSummary = " Persona recorded operator-safe local collaboration feedback for Imagination consensus discovery. " ,
[ string ] $PublicDiscussionRef = " eve://epiphany/persona#local-swarm-collaboration " ,
[ string ] $BifrostTargetRepository = " " ,
[ string ] $BifrostTargetBranch = " local-proof " ,
[ string ] $BifrostChangedPath = " tools/epiphany_local_run.ps1 " ,
[ string ] $BifrostChangeSummary = " Operator-safe local proof that body changes route through Bifrost before GitHub publication. " ,
[ string ] $BifrostJustification = " Body publication requires Bifrost ledger, review, credit, and GitHub receipt state before public substrate exposure. " ,
[ string ] $BifrostVerificationReceipt = " verification-receipt-local-proof " ,
[ string ] $BifrostReviewReceipt = " review-receipt-local-proof " ,
[ string ] $BifrostAuthorAgent = " epiphany.Hands " ,
[ string ] $BifrostCreditSubject = " epiphany.swarm " ,
[ string ] $BifrostLedgerEntryId = " bifrost-ledger-local-proof " ,
[ string ] $BifrostHandsPrReceiptId = " hands-pr-receipt-local-proof " ,
[ string ] $BifrostPublicationUrl = " https://github.com/local-proof/epiphany/pull/local-proof " ,
2026-06-20 13:30:43 +01:00
[ string ] $BifrostPublicProofId = " " ,
[ string ] $BifrostPublicProofPublicationReceiptId = " bifrost-public-proof-publication-local-proof " ,
[ string ] $BifrostPublicProofReviewReceipt = " public-proof-review-local-proof " ,
[ string ] $BifrostPublicProofCreditReceipt = " credit-public-proof-local-proof " ,
[ string ] $BifrostPublicProofRoomId = " epiphany-global/repo-work/public-proofs " ,
[ string ] $BifrostPublicProofPublicationUrl = " " ,
2026-06-21 14:01:55 +01:00
[ string ] $BifrostArtifactRef = " artifact://epiphany/local-proof " ,
[ string ] $BifrostArtifactAcceptanceReceiptId = " " ,
[ string ] $BifrostArtifactAcceptanceReviewReceipt = " artifact-acceptance-review-local-proof " ,
[ string ] $BifrostArtifactAcceptedBy = " Maintainer/Bifrost " ,
[ string ] $BifrostMetricsReceiptId = " " ,
[ string ] $BifrostModelSpendReceipt = " model-spend-local-proof " ,
[ string ] $BifrostReviewLoadReceipt = " review-load-local-proof " ,
[ string ] $BifrostCreditReadbackReceipt = " credit-readback-local-proof " ,
[ string ] $BifrostMetricsSummary = " model spend, review load, accepted artifact, and credit readback recorded " ,
2026-06-21 14:31:47 +01:00
[ string ] $BifrostArtifactSummaryPath = " " ,
[ string ] $BifrostMetricsSummaryPath = " " ,
2026-06-21 14:48:34 +01:00
[ string ] $RepoSwarmMvpFreshRepoSummaryPath = " " ,
[ string ] $RepoSwarmMvpReadinessSummaryPath = " " ,
[ string ] $RepoSwarmMvpBifrostAccountingSummaryPath = " " ,
2026-06-21 15:20:06 +01:00
[ string ] $RepoSwarmMvpDeploymentHandoffSummaryPath = " " ,
2026-06-21 15:01:37 +01:00
[ string ] $RepoSwarmMvpDaemonSurvivalSummaryPath = " " ,
2026-06-18 15:24:47 +01:00
[ string ] $ToolCapabilityId = " epiphany.cluster.hands.tool.repo-action " ,
[ string ] $ToolRequestingAgentId = " epiphany.Persona " ,
[ string ] $ToolRequestingClusterId = " epiphany.cluster.persona " ,
[ string ] $ToolInvocationReason = " " ,
[ string ] $ToolIntentId = " " ,
[ string ] $ToolReceiptId = " " ,
2026-06-20 01:51:45 +01:00
[ int ] $RepoWorkMaxItems = 1 ,
2026-06-20 02:49:29 +01:00
[ int ] $RepoSwarmMaxIterations = 8 ,
[ string ] $RepoSwarmUntil = " blocked-or-published " ,
2026-06-20 02:28:59 +01:00
[ string ] $RepoWorkItem = " persona-intake-local " ,
2026-06-21 19:03:35 +01:00
[ string ] $RepoLivefireExpectedPath = " README.md " ,
[ string ] $RepoLivefireExpectedFamily = " repo.status_section " ,
[ string ] $RepoLivefireExpectedGate = " awaiting-publication " ,
[ string ] $RepoLivefireExpectedBlocker = " bifrost-publication-missing " ,
2026-06-21 19:10:42 +01:00
[ string ] $RepoWorkPublicProofOutput = " " ,
2026-06-20 01:51:45 +01:00
[ string ] $RepoWorkRuntimeId = " repo-swarm-local " ,
2026-06-21 10:56:33 +01:00
[ string ] $RepoWorkPublicProof = " " ,
[ string ] $RepoWorkIdunnLifecycleReceipt = " " ,
[ string ] $RepoWorkToolDirectoryReceipt = " " ,
2026-06-21 11:16:24 +01:00
[ string ] $RepoWorkDeploymentAftercareReceipt = " " ,
[ string ] $RepoWorkDeploymentAftercareReceiptRef = " " ,
2026-06-21 12:20:28 +01:00
[ string ] $RepoWorkReadinessReceipt = " " ,
[ string ] $RepoWorkMaintainerReviewReceipt = " maintainer-review:local-proof " ,
[ string ] $RepoWorkSoulReviewReceipt = " soul-review:local-proof " ,
[ string ] $RepoWorkMindReviewReceipt = " mind-review:local-proof " ,
[ string ] $RepoWorkBifrostReviewReceipt = " bifrost-review:local-proof " ,
[ string ] $RepoWorkReadinessReviewSummary = " Operator-safe local readiness review approves a ready sight receipt without granting action authority. " ,
2026-06-21 11:05:46 +01:00
[ string ] $RepoDeploymentRemote = " origin " ,
[ string ] $RepoDeploymentRunbookReceipt = " " ,
[ string ] $RepoDeploymentIdunnReceipt = " " ,
[ string ] $RepoDeploymentIdunnReceiptRef = " " ,
[ string ] $RepoDeploymentAftercareReceipt = " " ,
[ string ] $RepoDeploymentAftercareReceiptRef = " " ,
2026-06-20 01:51:45 +01:00
[ switch ] $RepoWorkDryRun ,
2026-06-15 16:38:09 +01:00
[ string ] $PersonaInput = " " ,
2026-06-22 17:02:04 +01:00
[ ValidateSet ( " draft " , " bubble " , " post " , " request " , " latest " , " smoke " ) ]
[ string ] $PersonaMouthAction = " draft " ,
[ string ] $PersonaTitle = " Epiphany Persona bridge request " ,
[ string ] $PersonaTarget = " " ,
[ string ] $PersonaSurfaceName = " future-surface " ,
[ string ] $PersonaName = " " ,
[ string ] $PersonaChannelId = " " ,
[ string ] $PersonaSubreddit = " " ,
2026-05-21 10:17:38 +01:00
[ switch ] $SkipBuild ,
[ switch ] $AutoReview ,
2026-06-13 12:26:13 +01:00
[ switch ] $SupersedeFailedResults ,
2026-05-28 13:37:08 +01:00
[ switch ] $NoEphemeral ,
[ switch ] $SkipSleep
2026-05-21 10:17:38 +01:00
)
$ErrorActionPreference = " Stop "
2026-05-28 15:42:52 +01:00
function ConvertTo-NativeArgument {
param ( [ string ] $Argument )
if ( $Argument . Length -eq 0 ) {
return '""'
}
if ( $Argument -notmatch '[\s"]' ) {
return $Argument
}
$quoted = '"'
$backslashes = 0
foreach ( $character in $Argument . ToCharArray ( ) ) {
if ( $character -eq '\' ) {
$backslashes + = 1
continue
}
if ( $character -eq '"' ) {
$quoted + = ( '\' * ( ( $backslashes * 2 ) + 1 ) )
$quoted + = '"'
$backslashes = 0
continue
}
if ( $backslashes -gt 0 ) {
$quoted + = ( '\' * $backslashes )
$backslashes = 0
}
$quoted + = $character
}
if ( $backslashes -gt 0 ) {
$quoted + = ( '\' * ( $backslashes * 2 ) )
}
$quoted + = '"'
return $quoted
}
2026-05-21 10:17:38 +01:00
function Invoke-Checked {
param (
[ string ] $Label ,
[ string ] $FilePath ,
[ string[] ] $Arguments ,
[ string ] $WorkingDirectory ,
[ string ] $StdoutPath = " " ,
[ string ] $StderrPath = " "
)
Write-Host " ==> $Label "
2026-05-28 15:42:52 +01:00
$commandLine = ConvertTo-NativeArgument $FilePath
if ( $Arguments . Count -gt 0 ) {
$commandLine + = " "
$commandLine + = ( ( $Arguments | ForEach-Object { ConvertTo-NativeArgument $_ } ) -join " " )
}
if ( $StdoutPath -ne " " ) {
$commandLine + = " 1> "
$commandLine + = ConvertTo-NativeArgument $StdoutPath
}
if ( $StderrPath -ne " " ) {
$commandLine + = " 2> "
$commandLine + = ConvertTo-NativeArgument $StderrPath
2026-05-21 10:17:38 +01:00
}
2026-05-28 15:42:52 +01:00
$processInfo = [ System.Diagnostics.ProcessStartInfo ] :: new ( )
$processInfo . FileName = $env:ComSpec
$processInfo . Arguments = " /d /c " + $commandLine
$processInfo . WorkingDirectory = $WorkingDirectory
$processInfo . UseShellExecute = $false
$processInfo . CreateNoWindow = $true
$process = [ System.Diagnostics.Process ] :: Start ( $processInfo )
$process . WaitForExit ( )
$exitCode = $process . ExitCode
2026-05-21 10:17:38 +01:00
if ( $exitCode -ne 0 ) {
2026-06-19 02:26:54 +01:00
$stderrTail = " "
if ( $StderrPath -ne " " -and ( Test-Path -LiteralPath $StderrPath ) ) {
$stderrTail = ( ( Get-Content -LiteralPath $StderrPath -Tail 20 ) -join " `n " ) . Trim ( )
}
if ( $stderrTail -ne " " ) {
throw " $Label failed with exit code $exitCode `n $stderrTail "
}
2026-05-21 10:17:38 +01:00
throw " $Label failed with exit code $exitCode "
}
}
2026-06-18 17:12:52 +01:00
function Format-ServiceExecutionFailedChecks {
param ( [ object ] $Rows )
$rowList = @ ( $Rows )
if ( $null -eq $Rows -or $rowList . Count -eq 0 ) {
return " none "
}
return ( ( $rowList | ForEach-Object {
$observed = $_ . observedStatus
if ( $null -eq $observed -or $observed -eq " " ) {
$observed = " missing "
}
$artifact = $_ . operatorArtifactRef
if ( $null -eq $artifact -or $artifact -eq " " ) {
$artifact = " none "
}
$artifactSha256 = " none "
if ( $artifact -ne " none " -and ( Test-Path -LiteralPath $artifact -PathType Leaf ) ) {
$artifactSha256 = ( Get-FileHash -LiteralPath $artifact -Algorithm SHA256 ) . Hash . ToLowerInvariant ( )
}
2026-06-18 22:01:13 +01:00
$serviceId = $_ . serviceId
if ( $null -eq $serviceId -or $serviceId -eq " " ) {
$serviceId = " unknown-service "
}
2026-06-18 23:01:18 +01:00
$followUp = Get-ServiceExecutionCheckFollowUpCommand $_ . action
" ${serviceId} :: $( $_ . action ) = ${observed} :artifact= ${artifact} :sha256= ${artifactSha256} :followUp= ${followUp} "
2026-06-18 17:12:52 +01:00
} ) -join " ; " )
}
2026-06-18 23:01:18 +01:00
function Get-ServiceExecutionCheckFollowUpCommand {
param ( [ string ] $Action )
switch ( $Action ) {
" cluster-windows-service-execution-runbook " { return " tools/epiphany_local_run.ps1 -Mode cluster-service-execution-runbook " }
" cluster-windows-service-execution-readiness " { return " tools/epiphany_local_run.ps1 -Mode cluster-service-execution-readiness " }
" cluster-windows-service-install " { return " tools/epiphany_local_run.ps1 -Mode cluster-service-install-execute " }
" cluster-windows-service-start " { return " tools/epiphany_local_run.ps1 -Mode cluster-service-start-execute " }
" cluster-windows-service-execution-audit " { return " tools/epiphany_local_run.ps1 -Mode cluster-service-execution-audit " }
" cluster-windows-service-stop " { return " tools/epiphany_local_run.ps1 -Mode cluster-service-stop-execute " }
" windows-service-execution-runbook " { return " tools/epiphany_local_run.ps1 -Mode service-execution-runbook " }
" windows-service-execution-readiness " { return " tools/epiphany_local_run.ps1 -Mode service-execution-readiness " }
" windows-service-install " { return " tools/epiphany_local_run.ps1 -Mode service-install-execute " }
" windows-service-start " { return " tools/epiphany_local_run.ps1 -Mode service-start-execute " }
" windows-service-status " { return " tools/epiphany_local_run.ps1 -Mode service-status " }
" windows-service-reconcile " { return " tools/epiphany_local_run.ps1 -Mode service-reconcile " }
" windows-service-stop " { return " tools/epiphany_local_run.ps1 -Mode service-stop-execute " }
default { return " tools/epiphany_local_run.ps1 -Mode swarm-overview " }
}
}
2026-06-18 23:05:11 +01:00
function ConvertTo-PowerShellLiteral {
param ( [ string ] $Value )
return " ' " + $Value . Replace ( " ' " , " '' " ) + " ' "
}
2026-06-19 01:13:16 +01:00
function ConvertTo-PowerShellArrayLiteral {
param ( [ string[] ] $Values )
if ( $null -eq $Values -or $Values . Count -eq 0 ) {
return " @() "
}
return " @( " + ( ( $Values | ForEach-Object { ConvertTo-PowerShellLiteral $_ } ) -join " , " ) + " ) "
}
2026-06-18 23:05:11 +01:00
function Get-ElevatedRunbookCommand {
param ( [ string ] $RunbookPath )
$literalPath = ConvertTo-PowerShellLiteral $RunbookPath
return " Start-Process PowerShell -Verb RunAs -Wait -ArgumentList @('-NoProfile','-ExecutionPolicy','Bypass','-File', $literalPath ) "
}
2026-06-18 23:08:11 +01:00
function Get-LocalArtifactSha256 {
param ( [ string ] $ArtifactPath )
if ( $null -eq $ArtifactPath -or $ArtifactPath -eq " " -or -not ( Test-Path -LiteralPath $ArtifactPath -PathType Leaf ) ) {
return " none "
}
return ( Get-FileHash -LiteralPath $ArtifactPath -Algorithm SHA256 ) . Hash . ToLowerInvariant ( )
}
2026-06-18 21:08:02 +01:00
function Format-TuiRows {
param ( [ object ] $Rows )
$rowList = @ ( $Rows )
if ( $null -eq $Rows -or $rowList . Count -eq 0 ) {
return " none "
}
return ( $rowList -join " ; " )
}
2026-06-18 21:13:36 +01:00
function Format-ClusterServiceRows {
2026-06-18 21:18:04 +01:00
param (
[ object ] $Rows ,
[ string ] $DefaultStatus = " unknown "
)
2026-06-18 21:13:36 +01:00
$rowList = @ ( $Rows )
if ( $null -eq $Rows -or $rowList . Count -eq 0 ) {
return " none "
}
return ( ( $rowList | ForEach-Object {
$status = $_ . status
if ( $null -eq $status -or $status -eq " " ) {
$status = $_ . observedStatus
}
if ( $null -eq $status -or $status -eq " " ) {
2026-06-18 21:18:04 +01:00
$status = $DefaultStatus
2026-06-18 21:13:36 +01:00
}
$executed = $_ . executed
if ( $null -eq $executed -or $executed -eq " " ) {
$executed = " n/a "
}
$exitCode = $_ . exitCode
if ( $null -eq $exitCode -or $exitCode -eq " " ) {
$exitCode = " none "
}
$startType = $_ . startType
if ( $null -eq $startType -or $startType -eq " " ) {
$startType = " none "
}
" $( $_ . daemonId ) : ${status} :service= $( $_ . serviceName ) :cluster= $( $_ . clusterId ) :executed= ${executed} :exit= ${exitCode} :startType= ${startType} :private= $( $_ . privateStateExposed ) "
} ) -join " ; " )
}
2026-05-21 10:17:38 +01:00
Set-Location -LiteralPath $Root
$Root = ( Resolve-Path " . " ) . Path
$env:CARGO_TARGET_DIR = $TargetDir
2026-05-21 10:18:52 +01:00
if ( $Workspace -eq " " ) {
$Workspace = $Root
}
$Workspace = ( Resolve-Path $Workspace ) . Path
2026-05-21 10:17:38 +01:00
if ( $CodexHome -eq " " ) {
if ( $env:CODEX_HOME ) {
$CodexHome = $env:CODEX_HOME
} else {
$CodexHome = Join-Path $env:USERPROFILE " .codex "
}
}
2026-06-18 15:24:47 +01:00
$runId = " local- " + ( Get-Date -Format " yyyyMMdd-HHmmss-fff " ) + " - " + ( [ guid ] :: NewGuid ( ) . ToString ( " N " ) . Substring ( 0 , 8 ) )
2026-05-21 10:17:38 +01:00
$artifactRoot = Join-Path $Root " .epiphany-run\ $runId "
$dogfoodRoot = Join-Path $Root " .epiphany-dogfood\ $runId "
New-Item -ItemType Directory -Force -Path $artifactRoot | Out-Null
New-Item -ItemType Directory -Force -Path $dogfoodRoot | Out-Null
$codexAppServer = Join-Path $TargetDir " debug\codex-app-server.exe "
$statusExe = Join-Path $TargetDir " debug\epiphany-mvp-status.exe "
2026-05-27 21:08:55 +01:00
$operatorRunExe = Join-Path $TargetDir " debug\epiphany-operator-run.exe "
2026-05-27 20:58:31 +01:00
$operatorSnapshotExe = Join-Path $TargetDir " debug\epiphany-operator-snapshot.exe "
2026-06-02 14:24:55 +01:00
$verseQueryExe = Join-Path $TargetDir " debug\epiphany-verse-query.exe "
2026-06-21 15:01:37 +01:00
$daemonSurvivalRehearsalExe = Join-Path $TargetDir " debug\epiphany-daemon-survival-rehearsal-smoke.exe "
2026-06-21 14:48:34 +01:00
$repoSwarmMvpGateExe = Join-Path $TargetDir " debug\epiphany-repo-swarm-mvp-gate-smoke.exe "
2026-06-21 19:03:35 +01:00
$repoLivefireClosureSmokeExe = Join-Path $TargetDir " debug\epiphany-repo-livefire-closure-smoke.exe "
2026-06-21 14:31:47 +01:00
$bifrostAccountingBundleExe = Join-Path $TargetDir " debug\epiphany-repo-bifrost-accounting-bundle-smoke.exe "
2026-06-20 02:49:29 +01:00
$swarmExe = Join-Path $TargetDir " debug\epiphany-swarm.exe "
2026-06-20 01:51:45 +01:00
$repoWorkExe = Join-Path $TargetDir " debug\epiphany-work.exe "
2026-06-18 15:24:47 +01:00
$daemonSupervisorExe = Join-Path $TargetDir " debug\epiphany-daemon-supervisor.exe "
$clusterDaemonExe = Join-Path $TargetDir " debug\epiphany-cluster-daemon.exe "
2026-06-12 12:08:14 +01:00
$handsActionExe = Join-Path $TargetDir " debug\epiphany-hands-action.exe "
2026-05-21 10:17:38 +01:00
$coordinatorExe = Join-Path $TargetDir " debug\epiphany-mvp-coordinator.exe "
$coordinatorSmokeExe = Join-Path $TargetDir " debug\epiphany-mvp-coordinator-smoke.exe "
2026-05-27 22:18:52 +01:00
$modelRuntimeExe = Join-Path $TargetDir " debug\epiphany-model-runtime.exe "
2026-05-28 12:18:58 +01:00
$toolAdapterExe = Join-Path $TargetDir " debug\epiphany-tool-codex-mcp-spine.exe "
2026-05-28 13:37:08 +01:00
$heartbeatExe = Join-Path $TargetDir " debug\epiphany-heartbeat-store.exe "
2026-06-15 16:38:09 +01:00
$PersonaExe = Join-Path $TargetDir " debug\epiphany-persona-discord.exe "
2026-06-22 17:02:04 +01:00
$PersonaRedditExe = Join-Path $TargetDir " debug\epiphany-persona-reddit.exe "
2026-06-22 16:36:40 +01:00
$PersonaOtherExe = Join-Path $TargetDir " debug\epiphany-persona-other.exe "
2026-06-22 17:38:55 +01:00
$PersonaBridgeSmokeExe = Join-Path $TargetDir " debug\epiphany-persona-bridge-smoke.exe "
2026-05-28 13:37:08 +01:00
$characterLoopExe = Join-Path $TargetDir " debug\epiphany-character-loop.exe "
2026-06-18 15:24:47 +01:00
$agentMemoryExe = Join-Path $TargetDir " debug\epiphany-agent-memory-store.exe "
2026-05-27 22:18:52 +01:00
$modelProvider = " openai-codex "
2026-06-18 15:24:47 +01:00
$cargoExe = " cargo "
$userCargoExe = Join-Path $env:USERPROFILE " .cargo\bin\cargo.exe "
if ( Test-Path -LiteralPath $userCargoExe ) {
$cargoExe = $userCargoExe
}
2026-06-02 14:24:55 +01:00
$localVerseStore = Join-Path $Root " .epiphany-run\cultmesh\local-verse.ccmp "
2026-06-21 01:16:30 +01:00
$localVerseReadStore = $localVerseStore
if ( $LocalVerseStoreOverride -ne " " ) {
$localVerseParent = Split-Path -Parent $LocalVerseStoreOverride
if ( $localVerseParent -ne " " -and ( Test-Path -LiteralPath $localVerseParent ) ) {
$localVerseReadStore = Join-Path ( Resolve-Path $localVerseParent ) . Path ( Split-Path -Leaf $LocalVerseStoreOverride )
} elseif ( Test-Path -LiteralPath $LocalVerseStoreOverride ) {
$localVerseReadStore = ( Resolve-Path $LocalVerseStoreOverride ) . Path
} else {
$localVerseReadStore = $LocalVerseStoreOverride
}
}
2026-06-20 13:30:43 +01:00
$repoLocalVerseStore = Join-Path $Workspace " .epiphany\local-verse.ccmp "
2026-06-18 15:24:47 +01:00
$operatorRunStore = $localVerseStore
$operatorSnapshotStore = $localVerseStore
2026-05-27 21:08:55 +01:00
$operatorSnapshotId = " $runId -status "
2026-06-18 15:24:47 +01:00
if ( $BifrostTargetRepository -eq " " ) {
$BifrostTargetRepository = " repo: $Root "
}
2026-05-28 13:37:08 +01:00
$agentStore = Join-Path $Root " state\agents.msgpack "
$heartbeatStore = Join-Path $Root " state\agent-heartbeats.msgpack "
2026-05-28 14:44:08 +01:00
$runtimeStore = Join-Path $Workspace " state\runtime-spine.msgpack "
2026-05-28 13:37:08 +01:00
$liveRuntimeMode = @ ( " run " , " mvp " ) -contains $Mode
2026-05-21 10:17:38 +01:00
if ( -not $SkipBuild ) {
2026-06-22 17:38:55 +01:00
if ( $Mode -ne " status " -and $Mode -ne " agent-state-soa " -and $Mode -ne " swarm-status " -and $Mode -ne " swarm-poke-down " -and $Mode -ne " swarm-triage " -and $Mode -ne " cluster-topology " -and $Mode -ne " eve-surfaces " -and $Mode -ne " eve-connect " -and $Mode -ne " collaboration-feedback " -and $Mode -ne " persona-discord " -and $Mode -ne " persona-reddit " -and $Mode -ne " persona-other " -and $Mode -ne " persona-bridge " -and $Mode -ne " daemon-survival-rehearsal " -and $Mode -ne " repo-swarm-mvp-gate " -and $Mode -ne " repo-livefire-closure " -and $Mode -ne " repo-work-public-proof " -and $Mode -ne " bifrost-publication " -and $Mode -ne " bifrost-public-proof " -and $Mode -ne " bifrost-artifact-acceptance " -and $Mode -ne " bifrost-metrics " -and $Mode -ne " bifrost-accounting-bundle " -and $Mode -ne " bifrost-ledger " -and $Mode -ne " receipt-directory " -and $Mode -ne " tool-directory " -and $Mode -ne " tool-invoke " -and $Mode -ne " swarm-overview " -and $Mode -ne " gjallar " -and $Mode -ne " repo-persona-intake " -and $Mode -ne " repo-swarm-run " -and $Mode -ne " repo-work-queue-run " -and $Mode -ne " repo-work-readiness " -and $Mode -ne " repo-work-readiness-review " -and $Mode -ne " repo-deployment-config-audit " -and $Mode -ne " repo-deployment-runbook " -and $Mode -ne " repo-deployment-aftercare-audit " -and $Mode -ne " repo-work-service-plan " -and $Mode -ne " repo-work-service-runbook " -and $Mode -ne " repo-work-service-launch " -and $Mode -ne " repo-work-service-audit " -and $Mode -ne " swarm-online-runbook " -and $Mode -ne " service-policy-directory " -and $Mode -ne " service-plan " -and $Mode -ne " service-launch " -and $Mode -ne " service-runbook " -and $Mode -ne " cluster-service-runbook " -and $Mode -ne " cluster-service-install-plan " -and $Mode -ne " cluster-service-install-execute " -and $Mode -ne " cluster-service-audit " -and $Mode -ne " cluster-service-start-plan " -and $Mode -ne " cluster-service-stop-plan " -and $Mode -ne " cluster-service-start-execute " -and $Mode -ne " cluster-service-stop-execute " -and $Mode -ne " cluster-service-execution-readiness " -and $Mode -ne " cluster-service-execution-runbook " -and $Mode -ne " cluster-service-execution-audit " -and $Mode -ne " service-execution-runbook " -and $Mode -ne " service-install-plan " -and $Mode -ne " service-install-execute " -and $Mode -ne " service-tick " -and $Mode -ne " service-status " -and $Mode -ne " service-reconcile " -and $Mode -ne " service-execution-readiness " -and $Mode -ne " service-execution-audit " -and $Mode -ne " service-start-plan " -and $Mode -ne " service-stop-plan " -and $Mode -ne " service-start-execute " -and $Mode -ne " service-stop-execute " ) {
2026-05-27 21:32:29 +01:00
Invoke-Checked `
-Label " build Codex app-server compatibility organ " `
2026-06-18 15:24:47 +01:00
-FilePath $cargoExe `
2026-05-27 21:32:29 +01:00
-Arguments @ ( " build " , " -p " , " codex-app-server " , " --manifest-path " , " .\vendor\codex\codex-rs\Cargo.toml " ) `
-WorkingDirectory $Root `
-StdoutPath ( Join-Path $artifactRoot " build-codex-app-server.stdout.log " ) `
-StderrPath ( Join-Path $artifactRoot " build-codex-app-server.stderr.log " )
}
2026-05-21 10:17:38 +01:00
Invoke-Checked `
-Label " build Epiphany operator binaries " `
2026-06-18 15:24:47 +01:00
-FilePath $cargoExe `
2026-05-21 10:17:38 +01:00
-Arguments @ (
" build " ,
" --manifest-path " , " .\epiphany-core\Cargo.toml " ,
" --bin " , " epiphany-mvp-status " ,
2026-05-27 21:08:55 +01:00
" --bin " , " epiphany-operator-run " ,
2026-05-27 20:58:31 +01:00
" --bin " , " epiphany-operator-snapshot " ,
2026-06-02 14:24:55 +01:00
" --bin " , " epiphany-verse-query " ,
2026-06-21 15:01:37 +01:00
" --bin " , " epiphany-daemon-survival-rehearsal-smoke " ,
2026-06-21 14:48:34 +01:00
" --bin " , " epiphany-repo-swarm-mvp-gate-smoke " ,
2026-06-21 19:03:35 +01:00
" --bin " , " epiphany-repo-livefire-closure-smoke " ,
2026-06-21 14:31:47 +01:00
" --bin " , " epiphany-repo-bifrost-accounting-bundle-smoke " ,
2026-06-20 02:49:29 +01:00
" --bin " , " epiphany-swarm " ,
2026-06-20 01:51:45 +01:00
" --bin " , " epiphany-work " ,
2026-06-18 15:24:47 +01:00
" --bin " , " epiphany-daemon-supervisor " ,
" --bin " , " epiphany-cluster-daemon " ,
2026-06-12 12:08:14 +01:00
" --bin " , " epiphany-hands-action " ,
2026-05-21 10:17:38 +01:00
" --bin " , " epiphany-mvp-coordinator " ,
" --bin " , " epiphany-mvp-coordinator-smoke " ,
" --bin " , " epiphany-heartbeat-store " ,
2026-06-15 16:38:09 +01:00
" --bin " , " epiphany-persona-discord " ,
2026-06-22 17:02:04 +01:00
" --bin " , " epiphany-persona-reddit " ,
2026-06-22 16:36:40 +01:00
" --bin " , " epiphany-persona-other " ,
2026-06-22 17:38:55 +01:00
" --bin " , " epiphany-bifrost-bridge-status-smoke " ,
" --bin " , " epiphany-persona-bridge-smoke " ,
2026-05-28 13:37:08 +01:00
" --bin " , " epiphany-character-loop " ,
2026-06-18 15:24:47 +01:00
" --bin " , " epiphany-agent-memory-store " ,
2026-05-27 21:32:29 +01:00
" --bin " , " epiphany-agent-telemetry " ,
" --bin " , " epiphany-void-memory "
2026-05-21 10:17:38 +01:00
) `
-WorkingDirectory $Root `
-StdoutPath ( Join-Path $artifactRoot " build-epiphany-core.stdout.log " ) `
-StderrPath ( Join-Path $artifactRoot " build-epiphany-core.stderr.log " )
2026-05-28 13:37:08 +01:00
if ( $liveRuntimeMode ) {
2026-05-21 10:17:38 +01:00
Invoke-Checked `
2026-05-27 22:18:52 +01:00
-Label " build Epiphany model runtime " `
2026-06-18 15:24:47 +01:00
-FilePath $cargoExe `
2026-05-27 22:18:52 +01:00
-Arguments @ ( " build " , " --manifest-path " , " .\epiphany-openai-runtime\Cargo.toml " , " --bin " , " epiphany-model-runtime " ) `
2026-05-21 10:17:38 +01:00
-WorkingDirectory $Root `
2026-05-27 22:18:52 +01:00
-StdoutPath ( Join-Path $artifactRoot " build-model-runtime.stdout.log " ) `
-StderrPath ( Join-Path $artifactRoot " build-model-runtime.stderr.log " )
2026-05-28 12:18:58 +01:00
Invoke-Checked `
-Label " build quarantined Codex MCP tool adapter " `
2026-06-18 15:24:47 +01:00
-FilePath $cargoExe `
2026-05-28 12:18:58 +01:00
-Arguments @ ( " build " , " --manifest-path " , " .\epiphany-tool-codex-mcp-spine\Cargo.toml " ) `
-WorkingDirectory $Root `
-StdoutPath ( Join-Path $artifactRoot " build-tool-adapter.stdout.log " ) `
-StderrPath ( Join-Path $artifactRoot " build-tool-adapter.stderr.log " )
2026-05-21 10:17:38 +01:00
}
}
2026-06-20 02:49:29 +01:00
$requiredBinaries = @ ( $statusExe , $operatorRunExe , $operatorSnapshotExe , $verseQueryExe , $swarmExe , $repoWorkExe , $daemonSupervisorExe , $handsActionExe )
2026-06-21 15:01:37 +01:00
if ( $Mode -eq " daemon-survival-rehearsal " ) {
$requiredBinaries + = @ ( $daemonSurvivalRehearsalExe )
}
2026-06-21 14:48:34 +01:00
if ( $Mode -eq " repo-swarm-mvp-gate " ) {
$requiredBinaries + = @ ( $repoSwarmMvpGateExe )
}
2026-06-21 19:03:35 +01:00
if ( $Mode -eq " repo-livefire-closure " ) {
$requiredBinaries + = @ ( $repoLivefireClosureSmokeExe )
}
2026-06-21 14:31:47 +01:00
if ( $Mode -eq " bifrost-accounting-bundle " ) {
$requiredBinaries + = @ ( $bifrostAccountingBundleExe )
}
2026-06-22 17:38:55 +01:00
if ( $Mode -eq " persona-bridge " ) {
$requiredBinaries + = @ ( $PersonaBridgeSmokeExe )
}
if ( $Mode -ne " status " -and $Mode -ne " agent-state-soa " -and $Mode -ne " swarm-status " -and $Mode -ne " swarm-poke-down " -and $Mode -ne " swarm-triage " -and $Mode -ne " cluster-topology " -and $Mode -ne " eve-surfaces " -and $Mode -ne " eve-connect " -and $Mode -ne " collaboration-feedback " -and $Mode -ne " persona-discord " -and $Mode -ne " persona-reddit " -and $Mode -ne " persona-other " -and $Mode -ne " persona-bridge " -and $Mode -ne " daemon-survival-rehearsal " -and $Mode -ne " repo-swarm-mvp-gate " -and $Mode -ne " repo-livefire-closure " -and $Mode -ne " repo-work-public-proof " -and $Mode -ne " bifrost-publication " -and $Mode -ne " bifrost-public-proof " -and $Mode -ne " bifrost-artifact-acceptance " -and $Mode -ne " bifrost-metrics " -and $Mode -ne " bifrost-accounting-bundle " -and $Mode -ne " bifrost-ledger " -and $Mode -ne " receipt-directory " -and $Mode -ne " tool-directory " -and $Mode -ne " tool-invoke " -and $Mode -ne " swarm-overview " -and $Mode -ne " gjallar " -and $Mode -ne " repo-persona-intake " -and $Mode -ne " repo-swarm-run " -and $Mode -ne " repo-work-queue-run " -and $Mode -ne " repo-work-readiness " -and $Mode -ne " repo-work-readiness-review " -and $Mode -ne " repo-deployment-config-audit " -and $Mode -ne " repo-deployment-runbook " -and $Mode -ne " repo-deployment-aftercare-audit " -and $Mode -ne " repo-work-service-plan " -and $Mode -ne " repo-work-service-runbook " -and $Mode -ne " repo-work-service-launch " -and $Mode -ne " repo-work-service-audit " -and $Mode -ne " swarm-online-runbook " -and $Mode -ne " service-policy-directory " -and $Mode -ne " service-plan " -and $Mode -ne " service-launch " -and $Mode -ne " service-runbook " -and $Mode -ne " cluster-service-runbook " -and $Mode -ne " cluster-service-install-plan " -and $Mode -ne " cluster-service-install-execute " -and $Mode -ne " cluster-service-audit " -and $Mode -ne " cluster-service-start-plan " -and $Mode -ne " cluster-service-stop-plan " -and $Mode -ne " cluster-service-start-execute " -and $Mode -ne " cluster-service-stop-execute " -and $Mode -ne " cluster-service-execution-readiness " -and $Mode -ne " cluster-service-execution-runbook " -and $Mode -ne " cluster-service-execution-audit " -and $Mode -ne " service-execution-runbook " -and $Mode -ne " service-install-plan " -and $Mode -ne " service-install-execute " -and $Mode -ne " service-tick " -and $Mode -ne " service-status " -and $Mode -ne " service-reconcile " -and $Mode -ne " service-execution-readiness " -and $Mode -ne " service-execution-audit " -and $Mode -ne " service-start-plan " -and $Mode -ne " service-stop-plan " -and $Mode -ne " service-start-execute " -and $Mode -ne " service-stop-execute " ) {
2026-05-27 21:32:29 +01:00
$requiredBinaries + = @ ( $codexAppServer , $coordinatorExe )
}
2026-06-18 15:24:47 +01:00
function Assert-SwarmBrakeAllowsLiveRun {
$brakeContextPath = Join-Path $artifactRoot " swarm-brake-preflight.stdout.json "
if ( -not ( Test-Path -LiteralPath $localVerseStore ) ) {
Invoke-Checked `
-Label " seed local Verse before swarm brake preflight " `
-FilePath $verseQueryExe `
-Arguments @ (
" seed " ,
" --store " , $localVerseStore ,
2026-06-21 01:16:30 +01:00
" --runtime-id " , $LocalVerseRuntimeId
2026-06-18 15:24:47 +01:00
) `
-WorkingDirectory $Root `
-StdoutPath ( Join-Path $artifactRoot " swarm-brake-preflight-seed.stdout.json " ) `
-StderrPath ( Join-Path $artifactRoot " swarm-brake-preflight-seed.stderr.log " )
}
Invoke-Checked `
-Label " check local Verse swarm brake " `
-FilePath $verseQueryExe `
-Arguments @ (
" query " ,
" --store " , $localVerseStore ,
2026-06-21 01:16:30 +01:00
" --runtime-id " , $LocalVerseRuntimeId
2026-06-18 15:24:47 +01:00
) `
-WorkingDirectory $Root `
-StdoutPath $brakeContextPath `
-StderrPath ( Join-Path $artifactRoot " swarm-brake-preflight.stderr.log " )
$context = Get-Content -LiteralPath $brakeContextPath -Raw | ConvertFrom-Json
$brake = $context . swarmBrake
if ( $null -eq $brake ) {
$brake = $context . swarm_brake
}
$brakeStatus = $null
$brakeScope = " "
$brakeReason = " "
$protected = @ ( )
$affected = @ ( )
if ( $null -ne $brake ) {
if ( $brake -is [ array ] ) {
$brakeStatus = $brake [ 2 ]
$brakeScope = $brake [ 3 ]
$brakeReason = $brake [ 4 ]
if ( $null -ne $brake [ 6 ] ) {
$affected = @ ( $brake [ 6 ] )
}
if ( $null -ne $brake [ 7 ] ) {
$protected = @ ( $brake [ 7 ] )
}
} else {
$brakeStatus = $brake . status
$brakeScope = $brake . scope
$brakeReason = $brake . reason
if ( $null -ne $brake . protected_surfaces ) {
$protected = @ ( $brake . protected_surfaces )
} elseif ( $null -ne $brake . protectedSurfaces ) {
$protected = @ ( $brake . protectedSurfaces )
}
if ( $null -ne $brake . affected_clusters ) {
$affected = @ ( $brake . affected_clusters )
} elseif ( $null -ne $brake . affectedClusters ) {
$affected = @ ( $brake . affectedClusters )
}
}
}
if ( $brakeStatus -eq " engaged " ) {
throw " local Verse swarm brake engaged; refusing live mode ' $Mode '. scope= $brakeScope ; protected= $( $protected -join ',' ) ; affected= $( $affected -join ',' ) ; reason= $brakeReason "
}
}
2026-06-21 19:10:42 +01:00
if ( @ ( " plan " , " run " , " mvp " , " repo-persona-intake " , " repo-swarm-run " , " repo-work-queue-run " , " repo-livefire-closure " , " repo-work-public-proof " , " repo-work-readiness " , " repo-work-readiness-review " , " repo-deployment-config-audit " , " repo-deployment-runbook " , " repo-deployment-aftercare-audit " , " repo-work-service-plan " , " repo-work-service-runbook " , " repo-work-service-launch " , " repo-work-service-audit " , " service-plan " , " service-launch " , " service-runbook " , " cluster-service-runbook " , " cluster-service-install-plan " , " cluster-service-install-execute " , " cluster-service-audit " , " cluster-service-start-plan " , " cluster-service-stop-plan " , " cluster-service-start-execute " , " cluster-service-stop-execute " , " cluster-service-execution-readiness " , " cluster-service-execution-runbook " , " cluster-service-execution-audit " , " service-execution-runbook " , " service-install-plan " , " service-install-execute " , " service-tick " , " service-status " , " service-reconcile " , " service-execution-readiness " , " service-execution-audit " , " service-start-plan " , " service-stop-plan " , " service-start-execute " , " service-stop-execute " ) -contains $Mode ) {
2026-06-18 15:24:47 +01:00
if ( -not ( Test-Path -LiteralPath $verseQueryExe ) ) {
throw " required binary not found for swarm brake preflight: $verseQueryExe "
}
Assert-SwarmBrakeAllowsLiveRun
}
2026-05-28 13:37:08 +01:00
if ( $liveRuntimeMode ) {
$requiredBinaries + = @ ( $modelRuntimeExe , $toolAdapterExe )
}
2026-06-18 23:32:53 +01:00
if ( @ ( " service-policy-directory " , " service-plan " , " service-launch " , " service-tick " , " service-runbook " , " cluster-service-runbook " , " cluster-service-install-plan " , " cluster-service-install-execute " , " cluster-service-audit " , " cluster-service-start-plan " , " cluster-service-stop-plan " , " cluster-service-start-execute " , " cluster-service-stop-execute " , " cluster-service-execution-readiness " , " cluster-service-execution-runbook " , " cluster-service-execution-audit " , " service-execution-runbook " , " service-install-plan " , " service-install-execute " , " service-status " , " service-reconcile " , " service-execution-readiness " , " service-execution-audit " , " service-start-plan " , " service-stop-plan " , " service-start-execute " , " service-stop-execute " ) -contains $Mode ) {
2026-06-18 15:24:47 +01:00
$requiredBinaries + = @ ( $clusterDaemonExe )
}
2026-05-28 13:37:08 +01:00
if ( $Mode -eq " mvp " ) {
2026-06-15 16:38:09 +01:00
$requiredBinaries + = @ ( $heartbeatExe , $PersonaExe , $characterLoopExe )
2026-05-28 13:37:08 +01:00
}
2026-06-22 17:02:04 +01:00
if ( $Mode -eq " persona-discord " ) {
$requiredBinaries + = @ ( $PersonaExe )
}
if ( $Mode -eq " persona-reddit " ) {
$requiredBinaries + = @ ( $PersonaRedditExe )
}
if ( $Mode -eq " persona-other " ) {
$requiredBinaries + = @ ( $PersonaOtherExe )
}
2026-06-18 15:24:47 +01:00
$requiredBinaries + = @ ( $agentMemoryExe )
2026-05-27 21:32:29 +01:00
foreach ( $required in $requiredBinaries ) {
2026-05-21 10:17:38 +01:00
if ( -not ( Test-Path -LiteralPath $required ) ) {
throw " required binary not found: $required "
}
}
2026-06-18 15:24:47 +01:00
function Write-AgentStateSoaToLocalVerse {
param ( [ string ] $ArtifactSuffix = " " )
if ( -not ( Test-Path -LiteralPath $agentStore ) ) {
return
}
$suffix = $ArtifactSuffix
if ( $suffix -ne " " ) {
$suffix = " - $suffix "
}
Invoke-Checked `
-Label " refresh agent state SoA $suffix " `
-FilePath $agentMemoryExe `
-Arguments @ ( " refresh-soa " , " --store " , $agentStore ) `
-WorkingDirectory $Root `
-StdoutPath ( Join-Path $artifactRoot " agent-state-soa-refresh $suffix .stdout.json " ) `
-StderrPath ( Join-Path $artifactRoot " agent-state-soa-refresh $suffix .stderr.log " )
Invoke-Checked `
-Label " mirror agent state SoA into local Verse $suffix " `
-FilePath $verseQueryExe `
-Arguments @ (
" agent-state " ,
" --store " , $localVerseStore ,
2026-06-21 01:16:30 +01:00
" --runtime-id " , $LocalVerseRuntimeId ,
2026-06-18 15:24:47 +01:00
" --agent-store " , $agentStore
) `
-WorkingDirectory $Root `
-StdoutPath ( Join-Path $artifactRoot " local-verse-agent-state-soa $suffix .stdout.json " ) `
-StderrPath ( Join-Path $artifactRoot " local-verse-agent-state-soa $suffix .stderr.log " )
}
2026-05-21 10:31:10 +01:00
$resultPath = " "
2026-05-27 21:08:55 +01:00
$autoReviewValue = $AutoReview . IsPresent . ToString ( ) . ToLowerInvariant ( )
2026-05-28 15:42:52 +01:00
$effectiveNoEphemeral = $NoEphemeral . IsPresent -or ( $Mode -eq " mvp " )
$noEphemeralValue = $effectiveNoEphemeral . ToString ( ) . ToLowerInvariant ( )
2026-05-27 21:08:55 +01:00
$operatorRunIntentArgs = @ (
" intent " ,
" --store " , $operatorRunStore ,
2026-06-21 01:16:30 +01:00
" --runtime-id " , $LocalVerseRuntimeId ,
2026-05-27 21:08:55 +01:00
" --run-id " , $runId ,
" --mode " , $Mode ,
" --root " , $Root ,
" --workspace " , $Workspace ,
" --codex-home " , $CodexHome ,
" --target-dir " , $TargetDir ,
" --max-steps " , " $MaxSteps " ,
" --timeout-seconds " , " $TimeoutSeconds " ,
" --auto-review " , $autoReviewValue ,
" --no-ephemeral " , $noEphemeralValue ,
" --artifact-root " , $artifactRoot ,
" --dogfood-root " , $dogfoodRoot
)
if ( $ThreadId -ne " " ) {
$operatorRunIntentArgs + = @ ( " --thread-id " , $ThreadId )
}
Invoke-Checked `
-Label " write CultMesh operator run intent " `
-FilePath $operatorRunExe `
-Arguments $operatorRunIntentArgs `
-WorkingDirectory $Root `
-StdoutPath ( Join-Path $artifactRoot " operator-run-intent.stdout.json " ) `
-StderrPath ( Join-Path $artifactRoot " operator-run-intent.stderr.log " )
2026-05-21 10:31:10 +01:00
2026-06-21 19:17:14 +01:00
$compactOperatorContextModes = @ ( " agent-state-soa " , " swarm-status " , " swarm-poke-down " , " swarm-triage " , " cluster-topology " , " eve-surfaces " , " eve-connect " , " collaboration-feedback " , " daemon-survival-rehearsal " , " repo-swarm-mvp-gate " , " repo-livefire-closure " , " bifrost-publication " , " bifrost-public-proof " , " bifrost-artifact-acceptance " , " bifrost-metrics " , " bifrost-accounting-bundle " , " bifrost-ledger " , " receipt-directory " , " tool-directory " , " tool-invoke " , " swarm-overview " , " gjallar " , " swarm-online-runbook " , " service-policy-directory " )
$usesCompactOperatorContext = $compactOperatorContextModes -contains $Mode
$shouldReadLocalVerse = $Mode -ne " smoke " -and -not $usesCompactOperatorContext
2026-06-18 15:24:47 +01:00
if ( $shouldReadLocalVerse -and $Mode -ne " status " -and $Mode -ne " mvp " ) {
Invoke-Checked `
-Label " seed local Verse context " `
-FilePath $verseQueryExe `
-Arguments @ (
" seed-compact " ,
" --store " , $localVerseStore ,
2026-06-21 01:16:30 +01:00
" --runtime-id " , $LocalVerseRuntimeId
2026-06-18 15:24:47 +01:00
) `
-WorkingDirectory $Root `
-StdoutPath ( Join-Path $artifactRoot " local-verse-seed.stdout.json " ) `
-StderrPath ( Join-Path $artifactRoot " local-verse-context.stderr.log " )
Write-AgentStateSoaToLocalVerse -ArtifactSuffix " initial "
}
if ( $Mode -eq " status " -or $Mode -eq " mvp " ) {
2026-05-21 10:17:38 +01:00
$statusJson = Join-Path $artifactRoot " status.json "
2026-06-02 14:24:55 +01:00
$localVerseJson = Join-Path $artifactRoot " local-verse-context.json "
2026-06-18 15:24:47 +01:00
if ( $Mode -eq " status " ) {
$resultPath = $statusJson
$statusArgs = @ (
" --source " , " native " ,
" --cwd " , $Workspace ,
" --thread-state-store " , ( Join-Path $Root " state\thread-state.msgpack " ) ,
" --json " ,
" --result " , $statusJson
)
if ( $ThreadId -ne " " ) {
$statusArgs + = @ ( " --thread-id " , $ThreadId )
}
Invoke-Checked `
-Label " run operator status " `
-FilePath $statusExe `
-Arguments $statusArgs `
-WorkingDirectory $Root `
-StdoutPath ( Join-Path $artifactRoot " status.stdout.json " ) `
-StderrPath ( Join-Path $artifactRoot " status.stderr.log " )
}
Invoke-Checked `
-Label " seed local Verse context " `
-FilePath $verseQueryExe `
-Arguments @ (
" seed-compact " ,
" --store " , $localVerseStore ,
2026-06-21 01:16:30 +01:00
" --runtime-id " , $LocalVerseRuntimeId
2026-06-18 15:24:47 +01:00
) `
-WorkingDirectory $Root `
-StdoutPath ( Join-Path $artifactRoot " local-verse-seed.stdout.json " ) `
-StderrPath ( Join-Path $artifactRoot " local-verse-context.stderr.log " )
Write-AgentStateSoaToLocalVerse -ArtifactSuffix " initial "
if ( $Mode -eq " status " ) {
Invoke-Checked `
-Label " write CultMesh operator snapshot " `
-FilePath $operatorSnapshotExe `
-Arguments @ (
" from-status " ,
" --store " , $operatorSnapshotStore ,
2026-06-21 01:16:30 +01:00
" --runtime-id " , $LocalVerseRuntimeId ,
2026-06-18 15:24:47 +01:00
" --snapshot-id " , $operatorSnapshotId ,
" --source-mode " , " status " ,
" --input " , $statusJson
) `
-WorkingDirectory $Root `
-StdoutPath ( Join-Path $artifactRoot " operator-snapshot.stdout.json " ) `
-StderrPath ( Join-Path $artifactRoot " operator-snapshot.stderr.log " )
}
}
if ( $Mode -eq " agent-state-soa " ) {
Write-AgentStateSoaToLocalVerse -ArtifactSuffix " report "
$resultPath = Join-Path $artifactRoot " agent-state-soa-report.stdout.json "
Invoke-Checked `
-Label " read compact agent state SoA report " `
-FilePath $verseQueryExe `
-Arguments @ (
" agent-state-report " ,
" --store " , $localVerseStore ,
2026-06-21 01:16:30 +01:00
" --runtime-id " , $LocalVerseRuntimeId
2026-06-18 15:24:47 +01:00
) `
-WorkingDirectory $Root `
-StdoutPath $resultPath `
-StderrPath ( Join-Path $artifactRoot " agent-state-soa-report.stderr.log " )
}
if ( $Mode -eq " swarm-poke-down " ) {
$resultPath = Join-Path $artifactRoot " swarm-poke-down.stdout.json "
Invoke-Checked `
-Label " poke non-ready local Verse daemons " `
-FilePath $verseQueryExe `
-Arguments @ (
" poke-down-daemons " ,
" --store " , $localVerseStore ,
2026-06-21 01:16:30 +01:00
" --runtime-id " , $LocalVerseRuntimeId
2026-06-18 15:24:47 +01:00
) `
-WorkingDirectory $Root `
-StdoutPath $resultPath `
-StderrPath ( Join-Path $artifactRoot " swarm-poke-down.stderr.log " )
}
if ( $Mode -eq " swarm-triage " ) {
$resultPath = Join-Path $artifactRoot " swarm-triage.stdout.json "
Invoke-Checked `
-Label " triage and poke non-ready local Verse daemons " `
-FilePath $verseQueryExe `
-Arguments @ (
" swarm-triage " ,
2026-06-21 01:16:30 +01:00
" --store " , $localVerseReadStore ,
" --runtime-id " , $LocalVerseRuntimeId
2026-06-18 15:24:47 +01:00
) `
-WorkingDirectory $Root `
-StdoutPath $resultPath `
-StderrPath ( Join-Path $artifactRoot " swarm-triage.stderr.log " )
}
if ( $Mode -eq " swarm-status " ) {
$resultPath = Join-Path $artifactRoot " swarm-status.stdout.json "
Invoke-Checked `
-Label " read compact local Verse swarm status " `
-FilePath $verseQueryExe `
-Arguments @ (
" swarm-status " ,
" --store " , $localVerseStore ,
2026-06-21 01:16:30 +01:00
" --runtime-id " , $LocalVerseRuntimeId
2026-06-18 15:24:47 +01:00
) `
-WorkingDirectory $Root `
-StdoutPath $resultPath `
-StderrPath ( Join-Path $artifactRoot " swarm-status.stderr.log " )
}
if ( $Mode -eq " cluster-topology " ) {
$resultPath = Join-Path $artifactRoot " cluster-topology.stdout.json "
Invoke-Checked `
-Label " read compact cluster topology " `
-FilePath $verseQueryExe `
-Arguments @ (
" cluster-topology " ,
" --store " , $localVerseStore ,
2026-06-21 01:16:30 +01:00
" --runtime-id " , $LocalVerseRuntimeId
2026-06-18 15:24:47 +01:00
) `
-WorkingDirectory $Root `
-StdoutPath $resultPath `
-StderrPath ( Join-Path $artifactRoot " cluster-topology.stderr.log " )
}
if ( $Mode -eq " eve-surfaces " ) {
$resultPath = Join-Path $artifactRoot " eve-surfaces.stdout.json "
Invoke-Checked `
-Label " read compact Odin/Eve surface directory " `
-FilePath $verseQueryExe `
-Arguments @ (
" eve-surfaces " ,
" --store " , $localVerseStore ,
2026-06-21 01:16:30 +01:00
" --runtime-id " , $LocalVerseRuntimeId
2026-06-18 15:24:47 +01:00
) `
-WorkingDirectory $Root `
-StdoutPath $resultPath `
-StderrPath ( Join-Path $artifactRoot " eve-surfaces.stderr.log " )
}
if ( $Mode -eq " eve-connect " ) {
$resultPath = Join-Path $artifactRoot " eve-connect.stdout.json "
$connectArgs = @ (
" connect-eve " ,
" --store " , $localVerseStore ,
2026-06-21 01:16:30 +01:00
" --runtime-id " , $LocalVerseRuntimeId
2026-05-21 10:18:52 +01:00
)
2026-06-18 15:24:47 +01:00
if ( $EveAdvertisementId -ne " " ) {
$connectArgs + = @ ( " --advertisement-id " , $EveAdvertisementId )
} else {
$connectArgs + = @ ( " --target-cluster-id " , $EveTargetClusterId )
2026-05-21 10:18:52 +01:00
}
2026-05-21 10:17:38 +01:00
Invoke-Checked `
2026-06-18 15:24:47 +01:00
-Label " record compact Odin/Eve connection receipt " `
-FilePath $verseQueryExe `
-Arguments $connectArgs `
2026-05-21 10:17:38 +01:00
-WorkingDirectory $Root `
2026-06-18 15:24:47 +01:00
-StdoutPath $resultPath `
-StderrPath ( Join-Path $artifactRoot " eve-connect.stderr.log " )
}
if ( $Mode -eq " collaboration-feedback " ) {
2026-06-02 14:24:55 +01:00
Invoke-Checked `
2026-06-18 15:24:47 +01:00
-Label " record prerequisite Odin/Eve connection receipt " `
2026-06-02 14:24:55 +01:00
-FilePath $verseQueryExe `
-Arguments @ (
2026-06-18 15:24:47 +01:00
" connect-eve " ,
" --store " , $localVerseStore ,
2026-06-21 01:16:30 +01:00
" --runtime-id " , $LocalVerseRuntimeId ,
2026-06-18 15:24:47 +01:00
" --target-cluster-id " , $EveTargetClusterId
) `
-WorkingDirectory $Root `
-StdoutPath ( Join-Path $artifactRoot " collaboration-eve-connect.stdout.json " ) `
-StderrPath ( Join-Path $artifactRoot " collaboration-eve-connect.stderr.log " )
$resultPath = Join-Path $artifactRoot " collaboration-feedback.stdout.json "
Invoke-Checked `
-Label " record public collaboration feedback for Imagination consensus " `
-FilePath $verseQueryExe `
-Arguments @ (
" collaboration-feedback " ,
" --store " , $localVerseStore ,
2026-06-21 01:16:30 +01:00
" --runtime-id " , $LocalVerseRuntimeId ,
2026-06-18 15:24:47 +01:00
" --eve-connection-receipt-id " , " eve-connection-receipt " ,
" --collaboration-topic " , $CollaborationTopic ,
" --feedback-summary " , $CollaborationFeedbackSummary ,
" --public-discussion-ref " , $PublicDiscussionRef
) `
-WorkingDirectory $Root `
-StdoutPath $resultPath `
-StderrPath ( Join-Path $artifactRoot " collaboration-feedback.stderr.log " )
}
2026-06-22 17:02:04 +01:00
if ( @ ( " persona-discord " , " persona-reddit " , " persona-other " ) -contains $Mode ) {
$personaArtifactDir = Join-Path $Root " .epiphany-persona "
if ( $PersonaInput . Trim ( ) -eq " " ) {
$PersonaInput = " Epiphany Persona bridge mouth smoke: operator requested a Bifrost-owned outside-world crossing witness. "
}
if ( $Mode -eq " persona-discord " ) {
if ( @ ( " draft " , " bubble " , " post " , " latest " , " smoke " ) -notcontains $PersonaMouthAction ) {
throw " persona-discord supports PersonaMouthAction draft, bubble, post, latest, or smoke "
}
$resultPath = Join-Path $artifactRoot " persona-discord.stdout.json "
$personaArgs = @ (
$PersonaMouthAction ,
" --artifact-dir " , $personaArtifactDir ,
" --cultmesh-store " , $localVerseStore ,
" --runtime-id " , $LocalVerseRuntimeId
)
if ( @ ( " draft " , " bubble " , " post " ) -contains $PersonaMouthAction ) {
$personaArgs + = @ ( " --content " , $PersonaInput )
}
if ( $PersonaChannelId -ne " " ) {
$personaArgs + = @ ( " --channel-id " , $PersonaChannelId )
}
if ( $PersonaName -ne " " ) {
$personaArgs + = @ ( " --persona-name " , $PersonaName )
}
Invoke-Checked `
-Label " route Persona Discord mouth through Bifrost policy " `
-FilePath $PersonaExe `
-Arguments $personaArgs `
-WorkingDirectory $Root `
-StdoutPath $resultPath `
-StderrPath ( Join-Path $artifactRoot " persona-discord.stderr.log " )
} elseif ( $Mode -eq " persona-reddit " ) {
if ( @ ( " draft " , " post " , " latest " , " smoke " ) -notcontains $PersonaMouthAction ) {
throw " persona-reddit supports PersonaMouthAction draft, post, latest, or smoke "
}
$resultPath = Join-Path $artifactRoot " persona-reddit.stdout.json "
$personaArgs = @ (
$PersonaMouthAction ,
" --artifact-dir " , $personaArtifactDir ,
" --cultmesh-store " , $localVerseStore ,
" --runtime-id " , $LocalVerseRuntimeId
)
if ( @ ( " draft " , " post " ) -contains $PersonaMouthAction ) {
$personaArgs + = @ ( " --title " , $PersonaTitle , " --content " , $PersonaInput )
}
if ( $PersonaSubreddit -ne " " ) {
$personaArgs + = @ ( " --subreddit " , $PersonaSubreddit )
}
if ( $PersonaName -ne " " ) {
$personaArgs + = @ ( " --persona-name " , $PersonaName )
}
Invoke-Checked `
-Label " route Persona Reddit mouth through Bifrost policy " `
-FilePath $PersonaRedditExe `
-Arguments $personaArgs `
-WorkingDirectory $Root `
-StdoutPath $resultPath `
-StderrPath ( Join-Path $artifactRoot " persona-reddit.stderr.log " )
} else {
if ( @ ( " draft " , " request " , " latest " , " smoke " ) -notcontains $PersonaMouthAction ) {
throw " persona-other supports PersonaMouthAction draft, request, latest, or smoke "
}
$resultPath = Join-Path $artifactRoot " persona-other.stdout.json "
$personaArgs = @ (
$PersonaMouthAction ,
" --artifact-dir " , $personaArtifactDir ,
" --cultmesh-store " , $localVerseStore ,
" --runtime-id " , $LocalVerseRuntimeId
)
if ( @ ( " draft " , " request " ) -contains $PersonaMouthAction ) {
$personaArgs + = @ (
" --surface-name " , $PersonaSurfaceName ,
" --target-locator " , $PersonaTarget ,
" --title " , $PersonaTitle ,
" --content " , $PersonaInput
)
}
if ( $PersonaName -ne " " ) {
$personaArgs + = @ ( " --persona-name " , $PersonaName )
}
Invoke-Checked `
-Label " route Persona future-surface mouth through Bifrost policy " `
-FilePath $PersonaOtherExe `
-Arguments $personaArgs `
-WorkingDirectory $Root `
-StdoutPath $resultPath `
-StderrPath ( Join-Path $artifactRoot " persona-other.stderr.log " )
}
}
2026-06-22 17:38:55 +01:00
if ( $Mode -eq " persona-bridge " ) {
$resultPath = Join-Path $artifactRoot " persona-bridge.stdout.json "
Invoke-Checked `
-Label " prove Persona outside-world mouths route through Bifrost " `
-FilePath $PersonaBridgeSmokeExe `
-Arguments @ ( ) `
-WorkingDirectory $Root `
-StdoutPath $resultPath `
-StderrPath ( Join-Path $artifactRoot " persona-bridge.stderr.log " )
}
2026-06-18 15:24:47 +01:00
if ( $Mode -eq " bifrost-publication " ) {
$resultPath = Join-Path $artifactRoot " bifrost-publication.stdout.json "
Invoke-Checked `
-Label " record Bifrost body-change publication chain " `
-FilePath $verseQueryExe `
-Arguments @ (
" bifrost-publication " ,
" --store " , $localVerseStore ,
2026-06-21 01:16:30 +01:00
" --runtime-id " , $LocalVerseRuntimeId ,
2026-06-18 15:24:47 +01:00
" --target-repository " , $BifrostTargetRepository ,
" --target-branch " , $BifrostTargetBranch ,
" --change-summary " , $BifrostChangeSummary ,
" --justification " , $BifrostJustification ,
" --changed-path " , $BifrostChangedPath ,
" --verification-receipt " , $BifrostVerificationReceipt ,
" --review-receipt " , $BifrostReviewReceipt ,
" --author-agent " , $BifrostAuthorAgent ,
" --credit-subject " , $BifrostCreditSubject ,
" --ledger-entry-id " , $BifrostLedgerEntryId ,
" --hands-pr-receipt-id " , $BifrostHandsPrReceiptId ,
" --publication-url " , $BifrostPublicationUrl
) `
-WorkingDirectory $Root `
-StdoutPath $resultPath `
-StderrPath ( Join-Path $artifactRoot " bifrost-publication.stderr.log " )
}
2026-06-20 13:30:43 +01:00
if ( $Mode -eq " bifrost-public-proof " ) {
$resultPath = Join-Path $artifactRoot " bifrost-public-proof.stdout.json "
if ( -not ( Test-Path -LiteralPath $repoLocalVerseStore ) ) {
throw " repo-local Verse store not found for Bifrost public proof publication: $repoLocalVerseStore "
}
$publicProofId = $BifrostPublicProofId
if ( $publicProofId -eq " " ) {
$overviewPath = Join-Path $artifactRoot " bifrost-public-proof-overview.stdout.json "
Invoke-Checked `
-Label " read repo public proof rows before Bifrost publication " `
-FilePath $verseQueryExe `
-Arguments @ (
" swarm-overview " ,
" --store " , $repoLocalVerseStore ,
" --runtime-id " , $RepoWorkRuntimeId
) `
-WorkingDirectory $Root `
-StdoutPath $overviewPath `
-StderrPath ( Join-Path $artifactRoot " bifrost-public-proof-overview.stderr.log " )
$overview = Get-Content -LiteralPath $overviewPath -Raw | ConvertFrom-Json
$latestProof = $overview . latestRepoWorkPublicProof
if ( $null -eq $latestProof -or $latestProof -eq " " ) {
$proofRows = @ ( $overview . repoWorkPublicProofRows )
if ( $proofRows . Count -gt 0 ) {
$latestProof = $proofRows [ 0 ] . publicProofId
}
}
if ( $null -eq $latestProof -or $latestProof -eq " " ) {
throw " Bifrost public proof wrapper found no repoWorkPublicProofRows in $repoLocalVerseStore ; run epiphany-work export-proof --local-verse-store first or pass -BifrostPublicProofId "
}
$publicProofId = $latestProof
}
$publicationUrl = $BifrostPublicProofPublicationUrl
if ( $publicationUrl -eq " " ) {
$publicationUrl = " cultmesh:// $BifrostPublicProofRoomId / $publicProofId "
}
Invoke-Checked `
-Label " publish redacted repo proof through Bifrost " `
-FilePath $verseQueryExe `
-Arguments @ (
" bifrost-public-proof " ,
" --store " , $repoLocalVerseStore ,
" --runtime-id " , $RepoWorkRuntimeId ,
" --public-proof-id " , $publicProofId ,
" --receipt-id " , $BifrostPublicProofPublicationReceiptId ,
" --ledger-entry-id " , $BifrostLedgerEntryId ,
" --review-receipt " , $BifrostPublicProofReviewReceipt ,
" --credit-receipt " , $BifrostPublicProofCreditReceipt ,
" --public-room-id " , $BifrostPublicProofRoomId ,
" --publication-url " , $publicationUrl
) `
-WorkingDirectory $Root `
-StdoutPath $resultPath `
-StderrPath ( Join-Path $artifactRoot " bifrost-public-proof.stderr.log " )
}
2026-06-21 14:01:55 +01:00
if ( $Mode -eq " bifrost-artifact-acceptance " ) {
$resultPath = Join-Path $artifactRoot " bifrost-artifact-acceptance.stdout.json "
if ( -not ( Test-Path -LiteralPath $repoLocalVerseStore ) ) {
throw " repo-local Verse store not found for Bifrost artifact acceptance: $repoLocalVerseStore "
}
$receiptArgs = @ (
" bifrost-artifact-acceptance " ,
" --store " , $repoLocalVerseStore ,
" --runtime-id " , $RepoWorkRuntimeId ,
" --artifact-ref " , $BifrostArtifactRef ,
" --ledger-entry-id " , $BifrostLedgerEntryId ,
" --review-receipt " , $BifrostArtifactAcceptanceReviewReceipt ,
" --source-agent-id " , $BifrostArtifactAcceptedBy
)
if ( $BifrostArtifactAcceptanceReceiptId -ne " " ) {
$receiptArgs + = @ ( " --receipt-id " , $BifrostArtifactAcceptanceReceiptId )
}
if ( $BifrostPublicProofId -ne " " ) {
$receiptArgs + = @ ( " --public-proof-ref " , $BifrostPublicProofId )
} elseif ( $RepoWorkPublicProof -ne " " ) {
$receiptArgs + = @ ( " --public-proof-ref " , $RepoWorkPublicProof )
} else {
$receiptArgs + = @ ( " --public-proof-ref " , " repo-work-public-proof:latest " )
}
Invoke-Checked `
-Label " record Bifrost artifact acceptance receipt " `
-FilePath $verseQueryExe `
-Arguments $receiptArgs `
-WorkingDirectory $Root `
-StdoutPath $resultPath `
-StderrPath ( Join-Path $artifactRoot " bifrost-artifact-acceptance.stderr.log " )
}
if ( $Mode -eq " bifrost-metrics " ) {
$resultPath = Join-Path $artifactRoot " bifrost-metrics.stdout.json "
if ( -not ( Test-Path -LiteralPath $repoLocalVerseStore ) ) {
throw " repo-local Verse store not found for Bifrost metrics: $repoLocalVerseStore "
}
$receiptArgs = @ (
" bifrost-metrics " ,
" --store " , $repoLocalVerseStore ,
" --runtime-id " , $RepoWorkRuntimeId ,
" --model-spend-receipt " , $BifrostModelSpendReceipt ,
" --review-load-receipt " , $BifrostReviewLoadReceipt ,
" --credit-receipt " , $BifrostCreditReadbackReceipt ,
" --metrics-summary " , $BifrostMetricsSummary
)
if ( $BifrostMetricsReceiptId -ne " " ) {
$receiptArgs + = @ ( " --receipt-id " , $BifrostMetricsReceiptId )
}
if ( $BifrostArtifactAcceptanceReceiptId -ne " " ) {
$receiptArgs + = @ ( " --accepted-artifact-receipt-id " , $BifrostArtifactAcceptanceReceiptId )
}
if ( $BifrostPublicProofId -ne " " ) {
$receiptArgs + = @ ( " --public-proof-ref " , $BifrostPublicProofId )
} elseif ( $RepoWorkPublicProof -ne " " ) {
$receiptArgs + = @ ( " --public-proof-ref " , $RepoWorkPublicProof )
} else {
$receiptArgs + = @ ( " --public-proof-ref " , " repo-work-public-proof:latest " )
}
Invoke-Checked `
-Label " record Bifrost metrics receipt " `
-FilePath $verseQueryExe `
-Arguments $receiptArgs `
-WorkingDirectory $Root `
-StdoutPath $resultPath `
-StderrPath ( Join-Path $artifactRoot " bifrost-metrics.stderr.log " )
}
2026-06-21 15:01:37 +01:00
if ( $Mode -eq " daemon-survival-rehearsal " ) {
$resultPath = Join-Path $artifactRoot " daemon-survival-rehearsal.stdout.json "
Invoke-Checked `
-Label " verify Idunn daemon survival rehearsal " `
-FilePath $daemonSurvivalRehearsalExe `
-Arguments @ (
" --root " , $Root ,
" --smoke-root " , ( Join-Path $Root " .epiphany-smoke " )
) `
-WorkingDirectory $Root `
-StdoutPath $resultPath `
-StderrPath ( Join-Path $artifactRoot " daemon-survival-rehearsal.stderr.log " )
}
2026-06-21 14:48:34 +01:00
if ( $Mode -eq " repo-swarm-mvp-gate " ) {
$resultPath = Join-Path $artifactRoot " repo-swarm-mvp-gate.stdout.json "
$gateArgs = @ (
" --root " , $Root ,
" --smoke-root " , ( Join-Path $Root " .epiphany-smoke " )
)
if ( $RepoSwarmMvpFreshRepoSummaryPath -ne " " ) {
$gateArgs + = @ ( " --fresh-repo-summary " , $RepoSwarmMvpFreshRepoSummaryPath )
}
if ( $RepoSwarmMvpReadinessSummaryPath -ne " " ) {
$gateArgs + = @ ( " --readiness-summary " , $RepoSwarmMvpReadinessSummaryPath )
}
if ( $RepoSwarmMvpBifrostAccountingSummaryPath -ne " " ) {
$gateArgs + = @ ( " --bifrost-accounting-summary " , $RepoSwarmMvpBifrostAccountingSummaryPath )
}
2026-06-21 15:20:06 +01:00
if ( $RepoSwarmMvpDeploymentHandoffSummaryPath -ne " " ) {
$gateArgs + = @ ( " --deployment-handoff-summary " , $RepoSwarmMvpDeploymentHandoffSummaryPath )
}
2026-06-21 15:01:37 +01:00
if ( $RepoSwarmMvpDaemonSurvivalSummaryPath -ne " " ) {
$gateArgs + = @ ( " --daemon-survival-summary " , $RepoSwarmMvpDaemonSurvivalSummaryPath )
}
2026-06-21 14:48:34 +01:00
Invoke-Checked `
-Label " verify repo swarm MVP gate proof " `
-FilePath $repoSwarmMvpGateExe `
-Arguments $gateArgs `
-WorkingDirectory $Root `
-StdoutPath $resultPath `
-StderrPath ( Join-Path $artifactRoot " repo-swarm-mvp-gate.stderr.log " )
}
2026-06-21 19:03:35 +01:00
if ( $Mode -eq " repo-livefire-closure " ) {
$resultPath = Join-Path $artifactRoot " repo-livefire-closure.stdout.json "
Invoke-Checked `
-Label " verify repo live-fire closure proof " `
-FilePath $repoLivefireClosureSmokeExe `
-Arguments @ (
" --workspace " , $Workspace ,
" --item " , $RepoWorkItem ,
" --expected-path " , $RepoLivefireExpectedPath ,
" --expected-family " , $RepoLivefireExpectedFamily ,
" --expected-gate " , $RepoLivefireExpectedGate ,
" --expected-blocker " , $RepoLivefireExpectedBlocker
) `
-WorkingDirectory $Root `
-StdoutPath $resultPath `
-StderrPath ( Join-Path $artifactRoot " repo-livefire-closure.stderr.log " )
}
2026-06-21 14:31:47 +01:00
if ( $Mode -eq " bifrost-accounting-bundle " ) {
$resultPath = Join-Path $artifactRoot " bifrost-accounting-bundle.stdout.json "
$bundleArgs = @ (
" --root " , $Root ,
" --smoke-root " , ( Join-Path $Root " .epiphany-smoke " )
)
if ( $BifrostArtifactSummaryPath -ne " " ) {
$bundleArgs + = @ ( " --artifact-summary " , $BifrostArtifactSummaryPath )
}
if ( $BifrostMetricsSummaryPath -ne " " ) {
$bundleArgs + = @ ( " --metrics-summary " , $BifrostMetricsSummaryPath )
}
Invoke-Checked `
-Label " verify Bifrost accounting bundle proof " `
-FilePath $bifrostAccountingBundleExe `
-Arguments $bundleArgs `
-WorkingDirectory $Root `
-StdoutPath $resultPath `
-StderrPath ( Join-Path $artifactRoot " bifrost-accounting-bundle.stderr.log " )
}
2026-06-18 15:24:47 +01:00
if ( $Mode -eq " bifrost-ledger " ) {
$resultPath = Join-Path $artifactRoot " bifrost-ledger.stdout.json "
Invoke-Checked `
-Label " read compact Bifrost ledger report " `
-FilePath $verseQueryExe `
-Arguments @ (
" bifrost-ledger " ,
2026-06-21 13:13:26 +01:00
" --store " , $localVerseReadStore ,
2026-06-21 01:16:30 +01:00
" --runtime-id " , $LocalVerseRuntimeId
2026-06-02 14:24:55 +01:00
) `
-WorkingDirectory $Root `
2026-06-18 15:24:47 +01:00
-StdoutPath $resultPath `
-StderrPath ( Join-Path $artifactRoot " bifrost-ledger.stderr.log " )
}
if ( $Mode -eq " receipt-directory " ) {
$resultPath = Join-Path $artifactRoot " receipt-directory.stdout.json "
Invoke-Checked `
-Label " read compact receipt directory " `
-FilePath $verseQueryExe `
-Arguments @ (
" receipt-directory " ,
2026-06-21 13:02:00 +01:00
" --store " , $localVerseReadStore ,
2026-06-21 01:16:30 +01:00
" --runtime-id " , $LocalVerseRuntimeId
2026-06-18 15:24:47 +01:00
) `
-WorkingDirectory $Root `
-StdoutPath $resultPath `
-StderrPath ( Join-Path $artifactRoot " receipt-directory.stderr.log " )
}
if ( $Mode -eq " tool-directory " ) {
$resultPath = Join-Path $artifactRoot " tool-directory.stdout.json "
2026-05-27 20:58:31 +01:00
Invoke-Checked `
2026-06-18 15:24:47 +01:00
-Label " read compact daemon tool directory " `
-FilePath $verseQueryExe `
2026-05-27 20:58:31 +01:00
-Arguments @ (
2026-06-18 15:24:47 +01:00
" tool-directory " ,
" --store " , $localVerseStore ,
2026-06-21 01:16:30 +01:00
" --runtime-id " , $LocalVerseRuntimeId
2026-06-18 15:24:47 +01:00
) `
-WorkingDirectory $Root `
-StdoutPath $resultPath `
-StderrPath ( Join-Path $artifactRoot " tool-directory.stderr.log " )
}
if ( $Mode -eq " tool-invoke " ) {
$resultPath = Join-Path $artifactRoot " tool-invoke.stdout.json "
$toolInvokeArgs = @ (
" invoke-tool " ,
" --store " , $localVerseStore ,
2026-06-21 01:16:30 +01:00
" --runtime-id " , $LocalVerseRuntimeId ,
2026-06-18 15:24:47 +01:00
" --capability-id " , $ToolCapabilityId ,
" --requesting-agent-id " , $ToolRequestingAgentId ,
" --source-cluster-id " , $ToolRequestingClusterId
)
if ( $ToolInvocationReason -ne " " ) {
$toolInvokeArgs + = @ ( " --reason " , $ToolInvocationReason )
}
if ( $ToolIntentId -ne " " ) {
$toolInvokeArgs + = @ ( " --intent-id " , $ToolIntentId )
}
if ( $ToolReceiptId -ne " " ) {
$toolInvokeArgs + = @ ( " --receipt-id " , $ToolReceiptId )
}
Invoke-Checked `
-Label " record daemon tool invocation receipt " `
-FilePath $verseQueryExe `
-Arguments $toolInvokeArgs `
-WorkingDirectory $Root `
-StdoutPath $resultPath `
-StderrPath ( Join-Path $artifactRoot " tool-invoke.stderr.log " )
}
2026-06-19 00:28:48 +01:00
if ( $Mode -eq " swarm-overview " -or $Mode -eq " gjallar " ) {
$resultPath = Join-Path $artifactRoot " $Mode .stdout.json "
$overviewCommand = " swarm-overview "
if ( $Mode -eq " gjallar " ) {
$overviewCommand = " gjallar "
}
2026-06-18 15:24:47 +01:00
Invoke-Checked `
2026-06-19 00:28:48 +01:00
-Label " read compact whole-Verse herald overview " `
2026-06-18 15:24:47 +01:00
-FilePath $verseQueryExe `
-Arguments @ (
2026-06-19 00:28:48 +01:00
$overviewCommand ,
2026-06-21 01:16:30 +01:00
" --store " , $localVerseReadStore ,
" --runtime-id " , $LocalVerseRuntimeId
2026-06-18 15:24:47 +01:00
) `
-WorkingDirectory $Root `
-StdoutPath $resultPath `
2026-06-19 00:28:48 +01:00
-StderrPath ( Join-Path $artifactRoot " $Mode .stderr.log " )
2026-06-18 15:24:47 +01:00
}
2026-06-19 00:02:27 +01:00
if ( $Mode -eq " swarm-online-runbook " ) {
$overviewPath = Join-Path $artifactRoot " swarm-online-overview.stdout.json "
$runbookPath = Join-Path $artifactRoot " epiphany-swarm-online-runbook.ps1 "
$resultPath = Join-Path $artifactRoot " swarm-online-runbook.stdout.json "
2026-06-19 01:19:49 +01:00
$wrapperScriptPath = $PSCommandPath
if ( $wrapperScriptPath -eq " " ) {
$wrapperScriptPath = Join-Path $Root " tools\epiphany_local_run.ps1 "
}
$wrapperScriptPath = ( Resolve-Path $wrapperScriptPath ) . Path
2026-06-19 00:02:27 +01:00
Invoke-Checked `
-Label " read compact swarm overview for online runbook " `
-FilePath $verseQueryExe `
-Arguments @ (
" swarm-overview " ,
" --store " , $localVerseStore ,
2026-06-21 01:16:30 +01:00
" --runtime-id " , $LocalVerseRuntimeId
2026-06-19 00:02:27 +01:00
) `
-WorkingDirectory $Root `
-StdoutPath $overviewPath `
-StderrPath ( Join-Path $artifactRoot " swarm-online-overview.stderr.log " )
$overview = Get-Content -LiteralPath $overviewPath -Raw | ConvertFrom-Json
$authorityRows = @ ( $overview . swarmActionRows | Where-Object {
$_ . family -eq " service-execution-authority " -and
$_ . operatorArtifactStatus -eq " present " -and
$null -ne $_ . operatorArtifactExecutionCommand -and
$_ . operatorArtifactExecutionCommand -ne " " -and
$_ . operatorArtifactExecutionCommand -ne " none "
} | Sort-Object priority )
if ( $authorityRows . Count -eq 0 ) {
throw " swarm-online-runbook found no present elevated service execution artifacts in swarm overview "
}
2026-06-19 02:58:51 +01:00
$childArtifactPreflightRows = @ ( $authorityRows | ForEach-Object {
$artifactPresent = $false
$artifactActualSha256 = " none "
$artifactSha256Matches = $false
if ( $null -ne $_ . operatorArtifactRef -and $_ . operatorArtifactRef -ne " " -and $_ . operatorArtifactRef -ne " none " -and ( Test-Path -LiteralPath $_ . operatorArtifactRef -PathType Leaf ) ) {
$artifactPresent = $true
$artifactActualSha256 = ( Get-FileHash -LiteralPath $_ . operatorArtifactRef -Algorithm SHA256 ) . Hash . ToLowerInvariant ( )
$artifactSha256Matches = ( $_ . operatorArtifactSha256 -ne " none " -and $artifactActualSha256 -eq $_ . operatorArtifactSha256 )
}
[ pscustomobject ] @ {
serviceId = $_ . serviceId
serviceRoute = $_ . serviceRoute
artifactRef = $_ . operatorArtifactRef
expectedSha256 = $_ . operatorArtifactSha256
actualSha256 = $artifactActualSha256
artifactPresent = $artifactPresent
artifactSha256Matches = $artifactSha256Matches
privateStateExposed = $_ . privateStateExposed
}
} )
$childArtifactPresentCount = @ ( $childArtifactPreflightRows | Where-Object { $_ . artifactPresent } ) . Count
$childArtifactHashVerifiedCount = @ ( $childArtifactPreflightRows | Where-Object { $_ . artifactSha256Matches } ) . Count
$childArtifactMismatchCount = @ ( $childArtifactPreflightRows | Where-Object { $_ . artifactPresent -and -not $_ . artifactSha256Matches } ) . Count
$childArtifactMissingCount = @ ( $childArtifactPreflightRows | Where-Object { -not $_ . artifactPresent } ) . Count
$serviceExecutionFailedCheckCount = 0
$serviceExecutionMissingCheckCount = 0
$privateStateExposed = $false
foreach ( $row in $authorityRows ) {
$serviceExecutionFailedCheckCount + = [ int ] $row . serviceExecutionFailedCheckCount
$serviceExecutionMissingCheckCount + = [ int ] $row . serviceExecutionMissingCheckCount
if ( $row . privateStateExposed ) {
$privateStateExposed = $true
}
}
$preflightStatus = " ready-for-elevated-operator "
if ( $childArtifactMissingCount -gt 0 -or $childArtifactMismatchCount -gt 0 -or $privateStateExposed ) {
$preflightStatus = " blocked-regenerate-runbooks "
}
2026-06-19 00:02:27 +01:00
$aftercareCommands = @ ( $authorityRows | ForEach-Object { $_ . operatorAftercareCommand } | Where-Object { $null -ne $_ -and $_ -ne " " -and $_ -ne " none " } | Select-Object -Unique )
2026-06-19 01:19:49 +01:00
$aftercareRows = @ ( $authorityRows | Where-Object {
$null -ne $_ . operatorAftercareCommand -and
$_ . operatorAftercareCommand -ne " " -and
$_ . operatorAftercareCommand -ne " none " -and
$null -ne $_ . completionAuditWrapperMode -and
$_ . completionAuditWrapperMode -ne " " -and
$_ . completionAuditWrapperMode -ne " none "
} | Sort-Object operatorAftercareCommand , serviceId -Unique )
2026-06-19 00:07:51 +01:00
$quotedRoot = ConvertTo-PowerShellLiteral $Root
2026-06-19 00:02:27 +01:00
$runbookLines = @ (
" # Epiphany swarm online runbook. " ,
2026-06-19 00:33:02 +01:00
" # Lifecycle owner: Idunn. This artifact routes operator authority to Idunn-owned service lifecycle receipts. " ,
2026-06-19 00:02:27 +01:00
" # Generated from compact CultMesh swarm action rows. " ,
" # Run only with explicit operator authority. The individual sealed runbooks write lifecycle receipts. " ,
2026-06-19 00:07:51 +01:00
" # After execution, this runbook executes the advertised aftercare audit command(s). " ,
2026-06-19 00:02:27 +01:00
" Set-StrictMode -Version Latest " ,
'$ErrorActionPreference = "Stop"' ,
2026-06-19 00:07:51 +01:00
" Set-Location -LiteralPath $quotedRoot " ,
2026-06-19 00:33:02 +01:00
'$failureCount = 0' ,
2026-06-19 00:02:27 +01:00
" "
)
foreach ( $row in $authorityRows ) {
2026-06-19 00:33:02 +01:00
$serviceLiteral = ConvertTo-PowerShellLiteral $row . serviceId
$routeLiteral = ConvertTo-PowerShellLiteral $row . serviceRoute
$artifactLiteral = ConvertTo-PowerShellLiteral $row . operatorArtifactRef
$shaLiteral = ConvertTo-PowerShellLiteral $row . operatorArtifactSha256
$aftercareLiteral = ConvertTo-PowerShellLiteral $row . operatorAftercareCommand
2026-06-19 00:02:27 +01:00
$runbookLines + = " # Service: $( $row . serviceId ) "
$runbookLines + = " # Route: $( $row . serviceRoute ) "
$runbookLines + = " # Artifact: $( $row . operatorArtifactRef ) "
$runbookLines + = " # SHA-256: $( $row . operatorArtifactSha256 ) "
$runbookLines + = " # Aftercare: $( $row . operatorAftercareCommand ) "
2026-06-19 00:33:02 +01:00
$runbookLines + = " Write-Host `" Running Idunn service lifecycle runbook for Epiphany: service= $serviceLiteral route= $routeLiteral artifact= $artifactLiteral sha256= $shaLiteral aftercare= $aftercareLiteral `" "
$runbookLines + = " try { "
2026-06-19 01:07:21 +01:00
$runbookLines + = " if (-not (Test-Path -LiteralPath $artifactLiteral -PathType Leaf)) { throw `" missing child runbook artifact: $artifactLiteral `" } "
$runbookLines + = " if ( $shaLiteral -ne 'none') { "
$runbookLines + = " `$ actualSha256 = (Get-FileHash -LiteralPath $artifactLiteral -Algorithm SHA256).Hash.ToLowerInvariant() "
$runbookLines + = " if ( `$ actualSha256 -ne $shaLiteral ) { throw `" child runbook SHA-256 mismatch: expected= $shaLiteral actual= `$ actualSha256 artifact= $artifactLiteral `" } "
$runbookLines + = " } "
2026-06-19 00:33:02 +01:00
$runbookLines + = " `$ process = Start-Process PowerShell -Verb RunAs -Wait -PassThru -ArgumentList @('-NoProfile','-ExecutionPolicy','Bypass','-File', $artifactLiteral ) "
$runbookLines + = " `$ exitCode = `$ process.ExitCode "
$runbookLines + = " if ( `$ null -eq `$ exitCode) { `$ exitCode = -1 } "
$runbookLines + = " Write-Host `" Idunn service lifecycle runbook exit: service= $serviceLiteral route= $routeLiteral exitCode= `$ exitCode `" "
$runbookLines + = " if ( `$ exitCode -ne 0) { `$ failureCount += 1 } "
$runbookLines + = " } catch { "
$runbookLines + = " `$ failureCount += 1 "
$runbookLines + = " Write-Host `" Idunn service lifecycle runbook launch failed: service= $serviceLiteral route= $routeLiteral error= `$ ( `$ _.Exception.Message) `" "
$runbookLines + = " } "
2026-06-19 00:02:27 +01:00
$runbookLines + = " "
}
$runbookLines + = " # Aftercare audit command(s): "
2026-06-19 01:19:49 +01:00
foreach ( $aftercareRow in $aftercareRows ) {
$aftercareCommandLiteral = ConvertTo-PowerShellLiteral $aftercareRow . operatorAftercareCommand
$aftercareModeLiteral = ConvertTo-PowerShellLiteral $aftercareRow . completionAuditWrapperMode
$aftercareServiceLiteral = ConvertTo-PowerShellLiteral $aftercareRow . serviceId
$aftercareScriptLiteral = ConvertTo-PowerShellLiteral $wrapperScriptPath
$aftercareArgs = @ (
" -Mode " , $aftercareRow . completionAuditWrapperMode ,
" -SkipBuild " ,
" -Root " , $Root ,
" -Workspace " , $Workspace ,
" -CodexHome " , $CodexHome ,
" -TargetDir " , $TargetDir ,
" -DaemonId " , $DaemonId ,
" -ServiceId " , $aftercareRow . serviceId ,
" -ServiceStartType " , $ServiceStartType ,
" -SchedulerId " , $SchedulerId ,
" -LoopIntervalSeconds " , " $LoopIntervalSeconds " ,
" -ServiceMaxIterations " , " $ServiceMaxIterations "
)
$aftercareArgsLiteral = ConvertTo-PowerShellArrayLiteral $aftercareArgs
$runbookLines + = " Write-Host `" Running Idunn aftercare audit for Epiphany service lifecycle: command= $aftercareCommandLiteral mode= $aftercareModeLiteral service= $aftercareServiceLiteral `" "
2026-06-19 00:33:02 +01:00
$runbookLines + = " try { "
2026-06-19 01:19:49 +01:00
$runbookLines + = " `$ global:LASTEXITCODE = 0 "
$runbookLines + = " & $aftercareScriptLiteral $aftercareArgsLiteral "
$runbookLines + = " if ( `$ null -ne `$ global:LASTEXITCODE -and `$ global:LASTEXITCODE -ne 0) { throw `" Aftercare exited with code `$ global:LASTEXITCODE `" } "
2026-06-19 00:33:02 +01:00
$runbookLines + = " } catch { "
$runbookLines + = " `$ failureCount += 1 "
2026-06-19 01:19:49 +01:00
$runbookLines + = " Write-Host `" Idunn aftercare audit failed: command= $aftercareCommandLiteral mode= $aftercareModeLiteral service= $aftercareServiceLiteral error= `$ ( `$ _.Exception.Message) `" "
2026-06-19 00:33:02 +01:00
$runbookLines + = " } "
}
$runbookLines + = 'if ($failureCount -gt 0) {'
$runbookLines + = ' Write-Host "Idunn service lifecycle runbook for Epiphany failed: failures=$failureCount"'
$runbookLines + = ' exit 1'
$runbookLines + = '}'
$runbookLines + = 'Write-Host "Idunn service lifecycle runbook for Epiphany completed: failures=0"'
2026-06-19 00:02:27 +01:00
Set-Content -LiteralPath $runbookPath -Value ( $runbookLines -join [ Environment ] :: NewLine ) -Encoding UTF8
$runbookSha256 = Get-LocalArtifactSha256 $runbookPath
2026-06-19 01:03:49 +01:00
$elevatedCommand = Get-ElevatedRunbookCommand $runbookPath
2026-06-19 01:32:47 +01:00
$childRunbookRows = @ ( $authorityRows | ForEach-Object {
2026-06-19 02:58:51 +01:00
$authorityRow = $_
$preflightRow = @ ( $childArtifactPreflightRows | Where-Object { $_ . artifactRef -eq $authorityRow . operatorArtifactRef } | Select-Object -First 1 )
2026-06-19 01:32:47 +01:00
[ pscustomobject ] @ {
2026-06-19 02:58:51 +01:00
priority = $authorityRow . priority
family = $authorityRow . family
status = $authorityRow . status
lifecycleOwner = $authorityRow . lifecycleOwner
hostedBody = $authorityRow . hostedBody
serviceId = $authorityRow . serviceId
serviceRoute = $authorityRow . serviceRoute
wrapperMode = $authorityRow . wrapperMode
wrapperCommand = $authorityRow . wrapperCommand
authorityGate = $authorityRow . authorityGate
effectClass = $authorityRow . effectClass
mutatesState = $authorityRow . mutatesState
requiresElevatedAuthority = $authorityRow . requiresElevatedAuthority
artifactRef = $authorityRow . operatorArtifactRef
artifactStatus = $authorityRow . operatorArtifactStatus
artifactSha256 = $authorityRow . operatorArtifactSha256
artifactActualSha256 = $preflightRow . actualSha256
artifactSha256Verified = $preflightRow . artifactSha256Matches
artifactExecutionCommand = $authorityRow . operatorArtifactExecutionCommand
aftercareCommand = $authorityRow . operatorAftercareCommand
completionAuditWrapperMode = $authorityRow . completionAuditWrapperMode
completionAuditWrapperCommand = $authorityRow . completionAuditWrapperCommand
serviceExecutionFailedCheckCount = $authorityRow . serviceExecutionFailedCheckCount
serviceExecutionMissingCheckCount = $authorityRow . serviceExecutionMissingCheckCount
privateStateExposed = $authorityRow . privateStateExposed
2026-06-19 01:32:47 +01:00
}
} )
$aftercareRunbookRows = @ ( $aftercareRows | ForEach-Object {
[ pscustomobject ] @ {
serviceId = $_ . serviceId
serviceRoute = $_ . serviceRoute
command = $_ . operatorAftercareCommand
wrapperMode = $_ . completionAuditWrapperMode
wrapperCommand = $_ . completionAuditWrapperCommand
scriptPath = $wrapperScriptPath
privateStateExposed = $_ . privateStateExposed
}
} )
2026-06-19 00:02:27 +01:00
[ pscustomobject ] @ {
status = " ok "
2026-06-19 02:58:51 +01:00
preflightStatus = $preflightStatus
2026-06-19 00:02:27 +01:00
store = $localVerseStore
2026-06-21 01:16:30 +01:00
runtimeId = $LocalVerseRuntimeId
2026-06-19 00:02:27 +01:00
runbookPath = $runbookPath
artifactSha256 = $runbookSha256
2026-06-19 01:03:49 +01:00
elevatedCommand = $elevatedCommand
2026-06-19 00:02:27 +01:00
commandCount = $authorityRows . Count
2026-06-19 02:58:51 +01:00
childArtifactPresentCount = $childArtifactPresentCount
childArtifactHashVerifiedCount = $childArtifactHashVerifiedCount
childArtifactMismatchCount = $childArtifactMismatchCount
childArtifactMissingCount = $childArtifactMissingCount
serviceExecutionFailedCheckCount = $serviceExecutionFailedCheckCount
serviceExecutionMissingCheckCount = $serviceExecutionMissingCheckCount
2026-06-19 00:33:02 +01:00
lifecycleOwner = " Idunn "
hostedBody = " Epiphany "
2026-06-19 00:02:27 +01:00
commands = @ ( $authorityRows | ForEach-Object { $_ . operatorArtifactExecutionCommand } )
aftercareCommands = $aftercareCommands
2026-06-19 01:32:47 +01:00
childRunbookRows = $childRunbookRows
2026-06-19 02:58:51 +01:00
childArtifactPreflightRows = $childArtifactPreflightRows
2026-06-19 01:32:47 +01:00
aftercareRows = $aftercareRunbookRows
2026-06-19 00:33:02 +01:00
detectsChildExitCodes = $true
continuesAfterChildFailure = $true
2026-06-19 01:07:21 +01:00
verifiesChildArtifactSha256 = $true
2026-06-19 01:19:49 +01:00
usesExplicitAftercareArguments = $true
2026-06-19 00:33:02 +01:00
exitsNonzeroAfterChildOrAftercareFailure = $true
2026-06-19 00:02:27 +01:00
sourceOverviewPath = $overviewPath
2026-06-19 02:58:51 +01:00
privateStateExposed = $privateStateExposed
2026-06-19 00:02:27 +01:00
} | ConvertTo-Json -Depth 6 | Set-Content -LiteralPath $resultPath -Encoding UTF8
}
2026-06-18 15:24:47 +01:00
if ( $Mode -eq " service-policy-directory " ) {
$resultPath = Join-Path $artifactRoot " daemon-service-policy-directory.stdout.json "
Invoke-Checked `
-Label " read daemon restart policy coverage " `
-FilePath $verseQueryExe `
-Arguments @ (
" service-policy-directory " ,
" --store " , $localVerseStore ,
2026-06-21 01:16:30 +01:00
" --runtime-id " , $LocalVerseRuntimeId
2026-06-18 15:24:47 +01:00
) `
-WorkingDirectory $Root `
-StdoutPath $resultPath `
-StderrPath ( Join-Path $artifactRoot " daemon-service-policy-directory.stderr.log " )
}
2026-06-18 23:32:53 +01:00
if ( $Mode -eq " service-plan " ) {
$resultPath = Join-Path $artifactRoot " daemon-service-plan.stdout.json "
$planArgs = @ (
" service-plan " ,
" --store " , $localVerseStore ,
2026-06-21 01:16:30 +01:00
" --runtime-id " , $LocalVerseRuntimeId ,
2026-06-18 23:32:53 +01:00
" --daemon-id " , $DaemonId ,
" --scheduler-id " , $SchedulerId ,
" --service-id " , $ServiceId ,
" --loop-interval-seconds " , " $LoopIntervalSeconds "
)
if ( $ServiceMaxIterations -gt 0 ) {
$planArgs + = @ ( " --max-iterations " , " $ServiceMaxIterations " )
}
Invoke-Checked `
-Label " plan daemon supervisor service launch " `
-FilePath $daemonSupervisorExe `
-Arguments $planArgs `
-WorkingDirectory $Root `
-StdoutPath $resultPath `
-StderrPath ( Join-Path $artifactRoot " daemon-service-plan.stderr.log " )
}
if ( $Mode -eq " service-launch " ) {
$resultPath = Join-Path $artifactRoot " daemon-service-launch.stdout.json "
$launchArgs = @ (
" service-launch " ,
" --store " , $localVerseStore ,
2026-06-21 01:16:30 +01:00
" --runtime-id " , $LocalVerseRuntimeId ,
2026-06-18 23:32:53 +01:00
" --daemon-id " , $DaemonId ,
" --scheduler-id " , $SchedulerId ,
" --service-id " , $ServiceId ,
" --loop-interval-seconds " , " $LoopIntervalSeconds "
)
if ( $ServiceMaxIterations -gt 0 ) {
$launchArgs + = @ ( " --max-iterations " , " $ServiceMaxIterations " , " --wait-child " )
}
Invoke-Checked `
-Label " launch daemon supervisor service loop " `
-FilePath $daemonSupervisorExe `
-Arguments $launchArgs `
-WorkingDirectory $Root `
-StdoutPath $resultPath `
-StderrPath ( Join-Path $artifactRoot " daemon-service-launch.stderr.log " )
}
2026-06-18 15:24:47 +01:00
if ( $Mode -eq " service-runbook " ) {
$resultPath = Join-Path $artifactRoot " daemon-service-runbook.stdout.json "
$runbookPath = Join-Path $artifactRoot " epiphany-daemon-supervisor-service.ps1 "
$runbookArgs = @ (
" service-runbook " ,
" --store " , $localVerseStore ,
2026-06-21 01:16:30 +01:00
" --runtime-id " , $LocalVerseRuntimeId ,
2026-06-18 15:24:47 +01:00
" --daemon-id " , $DaemonId ,
" --scheduler-id " , $SchedulerId ,
" --service-id " , $ServiceId ,
" --loop-interval-seconds " , " $LoopIntervalSeconds " ,
" --runbook-path " , $runbookPath
)
if ( $ServiceMaxIterations -gt 0 ) {
$runbookArgs + = @ ( " --max-iterations " , " $ServiceMaxIterations " )
}
Invoke-Checked `
-Label " write daemon supervisor service runbook " `
-FilePath $daemonSupervisorExe `
-Arguments $runbookArgs `
-WorkingDirectory $Root `
-StdoutPath $resultPath `
-StderrPath ( Join-Path $artifactRoot " daemon-service-runbook.stderr.log " )
}
if ( $Mode -eq " cluster-service-runbook " ) {
$resultPath = Join-Path $artifactRoot " cluster-daemon-service-runbook.stdout.json "
$runbookPath = Join-Path $artifactRoot " epiphany-cluster-daemon-services.ps1 "
$clusterServiceId = $ServiceId
if ( $clusterServiceId -eq " epiphany-daemon-supervisor-service " ) {
$clusterServiceId = " epiphany-cluster-daemon-services "
}
$runbookArgs = @ (
" cluster-service-runbook " ,
" --store " , $localVerseStore ,
2026-06-21 01:16:30 +01:00
" --runtime-id " , $LocalVerseRuntimeId ,
2026-06-18 15:24:47 +01:00
" --daemon-id " , $DaemonId ,
" --scheduler-id " , $SchedulerId ,
" --service-id " , $clusterServiceId ,
" --service-command " , $clusterDaemonExe ,
" --loop-interval-seconds " , " $LoopIntervalSeconds " ,
" --runbook-path " , $runbookPath
)
if ( $ServiceMaxIterations -gt 0 ) {
$runbookArgs + = @ ( " --max-iterations " , " $ServiceMaxIterations " )
}
Invoke-Checked `
-Label " write cluster daemon service runbook " `
-FilePath $daemonSupervisorExe `
-Arguments $runbookArgs `
-WorkingDirectory $Root `
-StdoutPath $resultPath `
-StderrPath ( Join-Path $artifactRoot " cluster-daemon-service-runbook.stderr.log " )
}
if ( $Mode -eq " cluster-service-install-plan " -or $Mode -eq " cluster-service-install-execute " ) {
$clusterInstallModeName = if ( $Mode -eq " cluster-service-install-execute " ) { " execute " } else { " plan " }
$resultPath = Join-Path $artifactRoot " cluster-daemon-service-install- $clusterInstallModeName .stdout.json "
$installScriptPath = Join-Path $artifactRoot " epiphany-cluster-daemon-services-install.ps1 "
$clusterServiceId = $ServiceId
if ( $clusterServiceId -eq " epiphany-daemon-supervisor-service " ) {
$clusterServiceId = " epiphany-cluster-daemon-services "
}
$installArgs = @ (
" cluster-service-install-plan " ,
" --store " , $localVerseStore ,
2026-06-21 01:16:30 +01:00
" --runtime-id " , $LocalVerseRuntimeId ,
2026-06-18 15:24:47 +01:00
" --daemon-id " , $DaemonId ,
" --scheduler-id " , $SchedulerId ,
" --service-id " , $clusterServiceId ,
" --service-command " , $clusterDaemonExe ,
" --service-start-type " , $ServiceStartType ,
" --loop-interval-seconds " , " $LoopIntervalSeconds " ,
" --service-install-script-path " , $installScriptPath
)
if ( $ServiceName -ne " " ) {
$installArgs + = @ ( " --service-name " , $ServiceName )
}
if ( $ServiceDisplayName -ne " " ) {
$installArgs + = @ ( " --service-display-name " , $ServiceDisplayName )
}
if ( $ServiceMaxIterations -gt 0 ) {
$installArgs + = @ ( " --max-iterations " , " $ServiceMaxIterations " )
}
if ( $Mode -eq " cluster-service-install-execute " ) {
$installArgs + = @ ( " --execute-install " )
}
Invoke-Checked `
-Label " write cluster daemon Windows service install $clusterInstallModeName " `
-FilePath $daemonSupervisorExe `
-Arguments $installArgs `
-WorkingDirectory $Root `
-StdoutPath $resultPath `
-StderrPath ( Join-Path $artifactRoot " cluster-daemon-service-install- $clusterInstallModeName .stderr.log " )
}
if ( $Mode -eq " cluster-service-audit " ) {
$resultPath = Join-Path $artifactRoot " cluster-daemon-service-audit.stdout.json "
$clusterServiceId = $ServiceId
if ( $clusterServiceId -eq " epiphany-daemon-supervisor-service " ) {
$clusterServiceId = " epiphany-cluster-daemon-services "
}
$auditArgs = @ (
" cluster-service-audit " ,
" --store " , $localVerseStore ,
2026-06-21 01:16:30 +01:00
" --runtime-id " , $LocalVerseRuntimeId ,
2026-06-18 15:24:47 +01:00
" --daemon-id " , $DaemonId ,
" --scheduler-id " , $SchedulerId ,
" --service-id " , $clusterServiceId
)
if ( $ServiceName -ne " " ) {
$auditArgs + = @ ( " --service-name " , $ServiceName )
}
if ( $ServiceDisplayName -ne " " ) {
$auditArgs + = @ ( " --service-display-name " , $ServiceDisplayName )
}
Invoke-Checked `
-Label " audit cluster daemon Windows services " `
-FilePath $daemonSupervisorExe `
-Arguments $auditArgs `
-WorkingDirectory $Root `
-StdoutPath $resultPath `
-StderrPath ( Join-Path $artifactRoot " cluster-daemon-service-audit.stderr.log " )
}
if ( $Mode -eq " cluster-service-start-plan " -or $Mode -eq " cluster-service-stop-plan " -or $Mode -eq " cluster-service-start-execute " -or $Mode -eq " cluster-service-stop-execute " ) {
$control = if ( $Mode -eq " cluster-service-start-plan " -or $Mode -eq " cluster-service-start-execute " ) { " start " } else { " stop " }
$controlModeName = if ( $Mode -eq " cluster-service-start-execute " -or $Mode -eq " cluster-service-stop-execute " ) { " execute " } else { " plan " }
$resultPath = Join-Path $artifactRoot " cluster-daemon-service- $control - $controlModeName .stdout.json "
$clusterServiceId = $ServiceId
if ( $clusterServiceId -eq " epiphany-daemon-supervisor-service " ) {
$clusterServiceId = " epiphany-cluster-daemon-services "
}
$controlArgs = @ (
" cluster-service- $control " ,
" --store " , $localVerseStore ,
2026-06-21 01:16:30 +01:00
" --runtime-id " , $LocalVerseRuntimeId ,
2026-06-18 15:24:47 +01:00
" --daemon-id " , $DaemonId ,
" --scheduler-id " , $SchedulerId ,
" --service-id " , $clusterServiceId
)
if ( $ServiceName -ne " " ) {
$controlArgs + = @ ( " --service-name " , $ServiceName )
}
if ( $ServiceDisplayName -ne " " ) {
$controlArgs + = @ ( " --service-display-name " , $ServiceDisplayName )
}
if ( $controlModeName -eq " execute " ) {
$controlArgs + = @ ( " --execute-control " )
}
Invoke-Checked `
-Label " $controlModeName cluster daemon Windows service $control " `
-FilePath $daemonSupervisorExe `
-Arguments $controlArgs `
-WorkingDirectory $Root `
-StdoutPath $resultPath `
-StderrPath ( Join-Path $artifactRoot " cluster-daemon-service- $control - $controlModeName .stderr.log " )
}
if ( $Mode -eq " cluster-service-execution-runbook " ) {
$resultPath = Join-Path $artifactRoot " cluster-daemon-service-execution-runbook.stdout.json "
$executionRunbookPath = Join-Path $artifactRoot " epiphany-cluster-daemon-services-execution-runbook.ps1 "
$clusterServiceId = $ServiceId
if ( $clusterServiceId -eq " epiphany-daemon-supervisor-service " ) {
$clusterServiceId = " epiphany-cluster-daemon-services "
}
$wrapperScriptPath = $PSCommandPath
if ( $wrapperScriptPath -eq " " ) {
$wrapperScriptPath = Join-Path $Root " tools\epiphany_local_run.ps1 "
}
$wrapperScriptPath = ( Resolve-Path $wrapperScriptPath ) . Path
$baseWrapperArgs = @ (
" -SkipBuild " ,
" -Root " , $Root ,
" -Workspace " , $Workspace ,
" -CodexHome " , $CodexHome ,
" -TargetDir " , $TargetDir ,
" -DaemonId " , $DaemonId ,
" -ServiceId " , $clusterServiceId ,
" -ServiceStartType " , $ServiceStartType ,
" -SchedulerId " , $SchedulerId ,
" -LoopIntervalSeconds " , " $LoopIntervalSeconds " ,
" -ServiceMaxIterations " , " $ServiceMaxIterations "
)
if ( $ServiceName -ne " " ) {
$baseWrapperArgs + = @ ( " -ServiceName " , $ServiceName )
}
if ( $ServiceDisplayName -ne " " ) {
$baseWrapperArgs + = @ ( " -ServiceDisplayName " , $ServiceDisplayName )
}
$clusterExecutionRunbookTryModes = @ (
" cluster-service-execution-readiness " ,
" cluster-service-install-execute " ,
" cluster-service-start-execute " ,
" cluster-service-audit " ,
" cluster-service-stop-execute " ,
" cluster-service-audit "
)
$clusterExecutionRunbookFinalAuditMode = " cluster-service-execution-audit "
2026-06-19 01:13:16 +01:00
function New-ClusterRunbookArgs {
2026-06-18 15:24:47 +01:00
param ( [ string ] $RunbookMode )
2026-06-19 01:13:16 +01:00
return @ ( " -Mode " , $RunbookMode ) + $baseWrapperArgs
2026-06-18 15:24:47 +01:00
}
2026-06-18 16:10:22 +01:00
function New-RunbookStepLine {
param ( [ string ] $RunbookMode )
2026-06-19 01:13:16 +01:00
return " Invoke-EpiphanyRunbookStep -Name " + ( ConvertTo-PowerShellLiteral $RunbookMode ) + " -ScriptPath " + ( ConvertTo-PowerShellLiteral $wrapperScriptPath ) + " -Arguments " + ( ConvertTo-PowerShellArrayLiteral ( New-ClusterRunbookArgs $RunbookMode ) )
2026-06-18 16:10:22 +01:00
}
2026-06-18 15:24:47 +01:00
$runbookLines = @ (
" #Requires -RunAsAdministrator " ,
" Set-StrictMode -Version Latest " ,
'$ErrorActionPreference = "Stop"' ,
2026-06-18 16:10:22 +01:00
'$epiphanyRunbookFailures = New-Object System.Collections.Generic.List[string]' ,
2026-06-18 15:24:47 +01:00
" " ,
" # Elevated Epiphany cluster daemon service execution rite. " ,
" # Run only under explicit operator authority. Each command writes typed operator and lifecycle receipts into the local Verse store. " ,
2026-06-18 16:10:22 +01:00
" # Individual steps continue after failure so the local Verse gets the fullest possible receipt trail. " ,
2026-06-18 15:24:47 +01:00
" # ServiceId: $clusterServiceId " ,
" # ServiceName prefix: $ServiceName " ,
" " ,
2026-06-18 16:10:22 +01:00
" function Invoke-EpiphanyRunbookStep { " ,
" param( " ,
" [Parameter(Mandatory = `$ true)][string] `$ Name, " ,
2026-06-19 01:13:16 +01:00
" [Parameter(Mandatory = `$ true)][string] `$ ScriptPath, " ,
" [Parameter(Mandatory = `$ true)][string[]] `$ Arguments " ,
2026-06-18 16:10:22 +01:00
" ) " ,
" Write-Host `" ==> `$ Name `" " ,
" try { " ,
" `$ global:LASTEXITCODE = 0 " ,
2026-06-19 01:13:16 +01:00
" & `$ ScriptPath @Arguments " ,
2026-06-18 16:10:22 +01:00
" if ( `$ null -ne `$ global:LASTEXITCODE -and `$ global:LASTEXITCODE -ne 0) { " ,
" throw `" Command exited with code `$ global:LASTEXITCODE `" " ,
" } " ,
" } catch { " ,
" `$ epiphanyRunbookFailures.Add( `" `$ {Name}: `$ ( `$ _.Exception.Message) `" ) " ,
" Write-Warning `" Epiphany runbook step failed: `$ {Name}: `$ ( `$ _.Exception.Message) `" " ,
" } " ,
" } " ,
" " ,
2026-06-18 15:24:47 +01:00
" try { "
) + ( $clusterExecutionRunbookTryModes | ForEach-Object {
2026-06-18 16:10:22 +01:00
" " + ( New-RunbookStepLine $_ )
2026-06-18 15:24:47 +01:00
} ) + @ (
" } finally { " ,
2026-06-18 16:10:22 +01:00
" " + ( New-RunbookStepLine $clusterExecutionRunbookFinalAuditMode ) ,
" } " ,
'if ($epiphanyRunbookFailures.Count -gt 0) {' ,
' Write-Error ("Epiphany runbook completed with {0} failed step(s): {1}" -f $epiphanyRunbookFailures.Count, ($epiphanyRunbookFailures -join "; "))' ,
" exit 1 " ,
2026-06-18 15:24:47 +01:00
" } "
)
Set-Content -LiteralPath $executionRunbookPath -Value ( $runbookLines -join [ Environment ] :: NewLine ) -Encoding UTF8
$runbookReceiptArgs = @ (
" cluster-service-execution-runbook " ,
" --store " , $localVerseStore ,
2026-06-21 01:16:30 +01:00
" --runtime-id " , $LocalVerseRuntimeId ,
2026-06-18 15:24:47 +01:00
" --daemon-id " , $DaemonId ,
" --scheduler-id " , $SchedulerId ,
" --service-id " , $clusterServiceId ,
" --service-command " , $wrapperScriptPath ,
" --runbook-path " , $executionRunbookPath ,
" --artifact-ref " , $executionRunbookPath ,
" --reason " , " Generated elevated cluster service execution runbook with final audit in finally. "
)
Invoke-Checked `
-Label " record cluster daemon Windows service execution runbook receipt " `
-FilePath $daemonSupervisorExe `
-Arguments $runbookReceiptArgs `
-WorkingDirectory $Root `
-StdoutPath $resultPath `
-StderrPath ( Join-Path $artifactRoot " cluster-daemon-service-execution-runbook.stderr.log " )
}
if ( $Mode -eq " cluster-service-execution-readiness " ) {
$resultPath = Join-Path $artifactRoot " cluster-daemon-service-execution-readiness.stdout.json "
$clusterServiceId = $ServiceId
if ( $clusterServiceId -eq " epiphany-daemon-supervisor-service " ) {
$clusterServiceId = " epiphany-cluster-daemon-services "
}
$readinessArgs = @ (
" cluster-service-execution-readiness " ,
" --store " , $localVerseStore ,
2026-06-21 01:16:30 +01:00
" --runtime-id " , $LocalVerseRuntimeId ,
2026-06-18 15:24:47 +01:00
" --daemon-id " , $DaemonId ,
" --scheduler-id " , $SchedulerId ,
" --service-id " , $clusterServiceId
)
if ( $ServiceName -ne " " ) {
$readinessArgs + = @ ( " --service-name " , $ServiceName )
}
if ( $ServiceDisplayName -ne " " ) {
$readinessArgs + = @ ( " --service-display-name " , $ServiceDisplayName )
}
Invoke-Checked `
-Label " check cluster daemon Windows service execution readiness " `
-FilePath $daemonSupervisorExe `
-Arguments $readinessArgs `
-WorkingDirectory $Root `
-StdoutPath $resultPath `
-StderrPath ( Join-Path $artifactRoot " cluster-daemon-service-execution-readiness.stderr.log " )
}
if ( $Mode -eq " cluster-service-execution-audit " ) {
$resultPath = Join-Path $artifactRoot " cluster-daemon-service-execution-audit.stdout.json "
$clusterServiceId = $ServiceId
if ( $clusterServiceId -eq " epiphany-daemon-supervisor-service " ) {
$clusterServiceId = " epiphany-cluster-daemon-services "
}
$auditArgs = @ (
" cluster-service-execution-audit " ,
" --store " , $localVerseStore ,
2026-06-21 01:16:30 +01:00
" --runtime-id " , $LocalVerseRuntimeId ,
2026-06-18 15:24:47 +01:00
" --daemon-id " , $DaemonId ,
" --scheduler-id " , $SchedulerId ,
" --service-id " , $clusterServiceId
)
Invoke-Checked `
-Label " audit cluster daemon Windows service execution receipts " `
-FilePath $daemonSupervisorExe `
-Arguments $auditArgs `
-WorkingDirectory $Root `
-StdoutPath $resultPath `
-StderrPath ( Join-Path $artifactRoot " cluster-daemon-service-execution-audit.stderr.log " )
}
if ( $Mode -eq " service-execution-runbook " ) {
$resultPath = Join-Path $artifactRoot " daemon-service-execution-runbook.stdout.json "
$executionRunbookPath = Join-Path $artifactRoot " epiphany-daemon-supervisor-execution-runbook.ps1 "
$wrapperScriptPath = $PSCommandPath
if ( $wrapperScriptPath -eq " " ) {
$wrapperScriptPath = Join-Path $Root " tools\epiphany_local_run.ps1 "
}
$wrapperScriptPath = ( Resolve-Path $wrapperScriptPath ) . Path
$baseWrapperArgs = @ (
" -SkipBuild " ,
" -Root " , $Root ,
" -Workspace " , $Workspace ,
" -CodexHome " , $CodexHome ,
" -TargetDir " , $TargetDir ,
" -DaemonId " , $DaemonId ,
" -ServiceId " , $ServiceId ,
" -ServiceStartType " , $ServiceStartType ,
" -SchedulerId " , $SchedulerId ,
" -LoopIntervalSeconds " , " $LoopIntervalSeconds " ,
" -ServiceMaxIterations " , " $ServiceMaxIterations "
)
if ( $ServiceName -ne " " ) {
$baseWrapperArgs + = @ ( " -ServiceName " , $ServiceName )
}
if ( $ServiceDisplayName -ne " " ) {
$baseWrapperArgs + = @ ( " -ServiceDisplayName " , $ServiceDisplayName )
}
2026-06-19 01:13:16 +01:00
function New-ServiceRunbookArgs {
2026-06-18 15:24:47 +01:00
param ( [ string ] $RunbookMode )
2026-06-19 01:13:16 +01:00
return @ ( " -Mode " , $RunbookMode ) + $baseWrapperArgs
2026-06-18 15:24:47 +01:00
}
2026-06-18 16:10:22 +01:00
function New-ServiceRunbookStepLine {
param ( [ string ] $RunbookMode )
2026-06-19 01:13:16 +01:00
return " Invoke-EpiphanyRunbookStep -Name " + ( ConvertTo-PowerShellLiteral $RunbookMode ) + " -ScriptPath " + ( ConvertTo-PowerShellLiteral $wrapperScriptPath ) + " -Arguments " + ( ConvertTo-PowerShellArrayLiteral ( New-ServiceRunbookArgs $RunbookMode ) )
2026-06-18 16:10:22 +01:00
}
2026-06-18 15:24:47 +01:00
$runbookLines = @ (
" #Requires -RunAsAdministrator " ,
" Set-StrictMode -Version Latest " ,
'$ErrorActionPreference = "Stop"' ,
2026-06-18 16:10:22 +01:00
'$epiphanyRunbookFailures = New-Object System.Collections.Generic.List[string]' ,
2026-06-18 15:24:47 +01:00
" " ,
" # Elevated Epiphany daemon service execution rite. " ,
" # Run only under explicit operator authority. Each command writes typed operator and lifecycle receipts into the local Verse store. " ,
2026-06-18 16:10:22 +01:00
" # Individual steps continue after failure so the local Verse gets the fullest possible receipt trail. " ,
2026-06-18 15:24:47 +01:00
" # ServiceId: $ServiceId " ,
" # ServiceName: $ServiceName " ,
" " ,
2026-06-18 16:10:22 +01:00
" function Invoke-EpiphanyRunbookStep { " ,
" param( " ,
" [Parameter(Mandatory = `$ true)][string] `$ Name, " ,
2026-06-19 01:13:16 +01:00
" [Parameter(Mandatory = `$ true)][string] `$ ScriptPath, " ,
" [Parameter(Mandatory = `$ true)][string[]] `$ Arguments " ,
2026-06-18 16:10:22 +01:00
" ) " ,
" Write-Host `" ==> `$ Name `" " ,
" try { " ,
" `$ global:LASTEXITCODE = 0 " ,
2026-06-19 01:13:16 +01:00
" & `$ ScriptPath @Arguments " ,
2026-06-18 16:10:22 +01:00
" if ( `$ null -ne `$ global:LASTEXITCODE -and `$ global:LASTEXITCODE -ne 0) { " ,
" throw `" Command exited with code `$ global:LASTEXITCODE `" " ,
" } " ,
" } catch { " ,
" `$ epiphanyRunbookFailures.Add( `" `$ {Name}: `$ ( `$ _.Exception.Message) `" ) " ,
" Write-Warning `" Epiphany runbook step failed: `$ {Name}: `$ ( `$ _.Exception.Message) `" " ,
" } " ,
" } " ,
" " ,
" try { " ,
" " + ( New-ServiceRunbookStepLine " service-execution-readiness " ) ,
" " + ( New-ServiceRunbookStepLine " service-install-execute " ) ,
" " + ( New-ServiceRunbookStepLine " service-start-execute " ) ,
" " + ( New-ServiceRunbookStepLine " service-status " ) ,
" " + ( New-ServiceRunbookStepLine " service-reconcile " ) ,
" " + ( New-ServiceRunbookStepLine " service-stop-execute " ) ,
" " + ( New-ServiceRunbookStepLine " service-status " ) ,
" } finally { " ,
" " + ( New-ServiceRunbookStepLine " service-execution-audit " ) ,
" } " ,
'if ($epiphanyRunbookFailures.Count -gt 0) {' ,
' Write-Error ("Epiphany runbook completed with {0} failed step(s): {1}" -f $epiphanyRunbookFailures.Count, ($epiphanyRunbookFailures -join "; "))' ,
" exit 1 " ,
" } "
2026-06-18 15:24:47 +01:00
)
Set-Content -LiteralPath $executionRunbookPath -Value ( $runbookLines -join [ Environment ] :: NewLine ) -Encoding UTF8
$runbookReceiptArgs = @ (
" service-execution-runbook " ,
" --store " , $localVerseStore ,
2026-06-21 01:16:30 +01:00
" --runtime-id " , $LocalVerseRuntimeId ,
2026-06-18 15:24:47 +01:00
" --daemon-id " , $DaemonId ,
" --scheduler-id " , $SchedulerId ,
" --service-id " , $ServiceId ,
" --service-command " , $wrapperScriptPath ,
" --runbook-path " , $executionRunbookPath ,
" --artifact-ref " , $executionRunbookPath ,
" --reason " , " Generated elevated daemon service execution runbook. "
)
if ( $ServiceName -ne " " ) {
$runbookReceiptArgs + = @ ( " --service-name " , $ServiceName )
}
if ( $ServiceDisplayName -ne " " ) {
$runbookReceiptArgs + = @ ( " --service-display-name " , $ServiceDisplayName )
}
Invoke-Checked `
-Label " record daemon Windows service execution runbook receipt " `
-FilePath $daemonSupervisorExe `
-Arguments $runbookReceiptArgs `
-WorkingDirectory $Root `
-StdoutPath $resultPath `
-StderrPath ( Join-Path $artifactRoot " daemon-service-execution-runbook.stderr.log " )
}
if ( $Mode -eq " service-install-plan " -or $Mode -eq " service-install-execute " ) {
$installModeName = if ( $Mode -eq " service-install-execute " ) { " execute " } else { " plan " }
$resultPath = Join-Path $artifactRoot " daemon-service-install- $installModeName .stdout.json "
$installScriptPath = Join-Path $artifactRoot " epiphany-daemon-supervisor-install.ps1 "
$installArgs = @ (
" windows-service-install " ,
" --store " , $localVerseStore ,
2026-06-21 01:16:30 +01:00
" --runtime-id " , $LocalVerseRuntimeId ,
2026-06-18 15:24:47 +01:00
" --daemon-id " , $DaemonId ,
" --scheduler-id " , $SchedulerId ,
" --service-id " , $ServiceId ,
" --service-start-type " , $ServiceStartType ,
" --loop-interval-seconds " , " $LoopIntervalSeconds " ,
" --service-install-script-path " , $installScriptPath
)
if ( $ServiceName -ne " " ) {
$installArgs + = @ ( " --service-name " , $ServiceName )
}
if ( $ServiceDisplayName -ne " " ) {
$installArgs + = @ ( " --service-display-name " , $ServiceDisplayName )
}
if ( $ServiceMaxIterations -gt 0 ) {
$installArgs + = @ ( " --max-iterations " , " $ServiceMaxIterations " )
}
if ( $Mode -eq " service-install-execute " ) {
$installArgs + = @ ( " --execute-install " )
}
Invoke-Checked `
-Label " write daemon supervisor Windows service install $installModeName " `
-FilePath $daemonSupervisorExe `
-Arguments $installArgs `
-WorkingDirectory $Root `
-StdoutPath $resultPath `
-StderrPath ( Join-Path $artifactRoot " daemon-service-install- $installModeName .stderr.log " )
}
if ( $Mode -eq " service-status " ) {
$resultPath = Join-Path $artifactRoot " daemon-service-status.stdout.json "
$statusArgs = @ (
" windows-service-status " ,
" --store " , $localVerseStore ,
2026-06-21 01:16:30 +01:00
" --runtime-id " , $LocalVerseRuntimeId ,
2026-06-18 15:24:47 +01:00
" --daemon-id " , $DaemonId ,
" --scheduler-id " , $SchedulerId ,
" --service-id " , $ServiceId
)
if ( $ServiceName -ne " " ) {
$statusArgs + = @ ( " --service-name " , $ServiceName )
}
Invoke-Checked `
-Label " query daemon supervisor Windows service status " `
-FilePath $daemonSupervisorExe `
-Arguments $statusArgs `
-WorkingDirectory $Root `
-StdoutPath $resultPath `
-StderrPath ( Join-Path $artifactRoot " daemon-service-status.stderr.log " )
}
if ( $Mode -eq " service-tick " ) {
$resultPath = Join-Path $artifactRoot " daemon-service-tick.stdout.json "
Invoke-Checked `
-Label " run one daemon supervisor scheduler tick " `
-FilePath $daemonSupervisorExe `
-Arguments @ (
" tick " ,
" --store " , $localVerseStore ,
2026-06-21 01:16:30 +01:00
" --runtime-id " , $LocalVerseRuntimeId ,
2026-06-18 15:24:47 +01:00
" --daemon-id " , $DaemonId ,
" --scheduler-id " , $SchedulerId
2026-05-27 20:58:31 +01:00
) `
-WorkingDirectory $Root `
2026-06-18 15:24:47 +01:00
-StdoutPath $resultPath `
-StderrPath ( Join-Path $artifactRoot " daemon-service-tick.stderr.log " )
}
if ( $Mode -eq " service-reconcile " ) {
$resultPath = Join-Path $artifactRoot " daemon-service-reconcile.stdout.json "
$reconcileArgs = @ (
" windows-service-reconcile " ,
" --store " , $localVerseStore ,
2026-06-21 01:16:30 +01:00
" --runtime-id " , $LocalVerseRuntimeId ,
2026-06-18 15:24:47 +01:00
" --daemon-id " , $DaemonId ,
" --scheduler-id " , $SchedulerId ,
" --service-id " , $ServiceId ,
" --service-start-type " , $ServiceStartType
)
if ( $ServiceName -ne " " ) {
$reconcileArgs + = @ ( " --service-name " , $ServiceName )
}
Invoke-Checked `
-Label " reconcile daemon supervisor Windows service policy " `
-FilePath $daemonSupervisorExe `
-Arguments $reconcileArgs `
-WorkingDirectory $Root `
-StdoutPath $resultPath `
-StderrPath ( Join-Path $artifactRoot " daemon-service-reconcile.stderr.log " )
}
if ( $Mode -eq " service-execution-readiness " ) {
$resultPath = Join-Path $artifactRoot " daemon-service-execution-readiness.stdout.json "
$readinessArgs = @ (
" windows-service-execution-readiness " ,
" --store " , $localVerseStore ,
2026-06-21 01:16:30 +01:00
" --runtime-id " , $LocalVerseRuntimeId ,
2026-06-18 15:24:47 +01:00
" --daemon-id " , $DaemonId ,
" --scheduler-id " , $SchedulerId ,
" --service-id " , $ServiceId
)
if ( $ServiceName -ne " " ) {
$readinessArgs + = @ ( " --service-name " , $ServiceName )
}
Invoke-Checked `
-Label " check daemon supervisor Windows service execution readiness " `
-FilePath $daemonSupervisorExe `
-Arguments $readinessArgs `
-WorkingDirectory $Root `
-StdoutPath $resultPath `
-StderrPath ( Join-Path $artifactRoot " daemon-service-execution-readiness.stderr.log " )
}
if ( $Mode -eq " service-execution-audit " ) {
$resultPath = Join-Path $artifactRoot " daemon-service-execution-audit.stdout.json "
$auditArgs = @ (
" windows-service-execution-audit " ,
" --store " , $localVerseStore ,
2026-06-21 01:16:30 +01:00
" --runtime-id " , $LocalVerseRuntimeId ,
2026-06-18 15:24:47 +01:00
" --daemon-id " , $DaemonId ,
" --scheduler-id " , $SchedulerId ,
" --service-id " , $ServiceId
)
if ( $ServiceName -ne " " ) {
$auditArgs + = @ ( " --service-name " , $ServiceName )
}
Invoke-Checked `
-Label " audit daemon supervisor Windows service execution receipts " `
-FilePath $daemonSupervisorExe `
-Arguments $auditArgs `
-WorkingDirectory $Root `
-StdoutPath $resultPath `
-StderrPath ( Join-Path $artifactRoot " daemon-service-execution-audit.stderr.log " )
}
if ( $Mode -eq " service-start-plan " -or $Mode -eq " service-stop-plan " -or $Mode -eq " service-start-execute " -or $Mode -eq " service-stop-execute " ) {
$control = if ( $Mode -eq " service-start-plan " -or $Mode -eq " service-start-execute " ) { " start " } else { " stop " }
$controlModeName = if ( $Mode -eq " service-start-execute " -or $Mode -eq " service-stop-execute " ) { " execute " } else { " plan " }
$resultPath = Join-Path $artifactRoot " daemon-service- $control - $controlModeName .stdout.json "
$controlArgs = @ (
" windows-service- $control " ,
" --store " , $localVerseStore ,
2026-06-21 01:16:30 +01:00
" --runtime-id " , $LocalVerseRuntimeId ,
2026-06-18 15:24:47 +01:00
" --daemon-id " , $DaemonId ,
" --scheduler-id " , $SchedulerId ,
" --service-id " , $ServiceId
)
if ( $ServiceName -ne " " ) {
$controlArgs + = @ ( " --service-name " , $ServiceName )
}
if ( $controlModeName -eq " execute " ) {
$controlArgs + = @ ( " --execute-control " )
}
Invoke-Checked `
-Label " $controlModeName daemon supervisor Windows service $control " `
-FilePath $daemonSupervisorExe `
-Arguments $controlArgs `
-WorkingDirectory $Root `
-StdoutPath $resultPath `
-StderrPath ( Join-Path $artifactRoot " daemon-service- $control - $controlModeName .stderr.log " )
2026-05-21 10:17:38 +01:00
}
2026-06-20 02:28:59 +01:00
if ( $Mode -eq " repo-persona-intake " ) {
$resultPath = Join-Path $artifactRoot " repo-persona-intake.stdout.json "
$repoWorkVerseStore = Join-Path $Workspace " .epiphany\local-verse.ccmp "
$repoPersonaInput = $PersonaInput
if ( $repoPersonaInput -eq " " ) {
$repoPersonaInput = " Persona intake requests an Imagination plan for the next repo-swarm MVP cut. "
}
$repoWorkArgs = @ (
" persona-intake " ,
" --workspace " , $Workspace ,
" --epiphany-root " , $Root ,
" --item " , $RepoWorkItem ,
" --message " , $repoPersonaInput ,
" --local-verse-store " , $repoWorkVerseStore ,
" --runtime-id " , $RepoWorkRuntimeId
)
if ( $CollaborationTopic -ne " " ) {
$repoWorkArgs + = @ ( " --topic " , $CollaborationTopic )
}
Invoke-Checked `
-Label " record repo Persona intake surface " `
-FilePath $repoWorkExe `
-Arguments $repoWorkArgs `
-WorkingDirectory $Root `
-StdoutPath $resultPath `
-StderrPath ( Join-Path $artifactRoot " repo-persona-intake.stderr.log " )
}
2026-06-20 02:49:29 +01:00
if ( $Mode -eq " repo-swarm-run " ) {
$resultPath = Join-Path $artifactRoot " repo-swarm-run.stdout.json "
$repoWorkVerseStore = Join-Path $Workspace " .epiphany\local-verse.ccmp "
$repoSwarmArgs = @ (
" run " ,
" --workspace " , $Workspace ,
" --epiphany-root " , $Root ,
" --local-verse-store " , $repoWorkVerseStore ,
" --runtime-id " , $RepoWorkRuntimeId ,
" --until " , $RepoSwarmUntil ,
" --max-iterations " , " $RepoSwarmMaxIterations " ,
" --max-items " , " $RepoWorkMaxItems "
)
if ( $RepoWorkDryRun . IsPresent ) {
$repoSwarmArgs + = @ ( " --dry-run " )
}
Invoke-Checked `
-Label " run repo swarm queue mouth " `
-FilePath $swarmExe `
-Arguments $repoSwarmArgs `
-WorkingDirectory $Root `
-StdoutPath $resultPath `
-StderrPath ( Join-Path $artifactRoot " repo-swarm-run.stderr.log " )
}
2026-06-20 01:51:45 +01:00
if ( $Mode -eq " repo-work-queue-run " ) {
$resultPath = Join-Path $artifactRoot " repo-work-queue-run.stdout.json "
$repoWorkVerseStore = Join-Path $Workspace " .epiphany\local-verse.ccmp "
$repoWorkArgs = @ (
" queue-run " ,
" --workspace " , $Workspace ,
" --epiphany-root " , $Root ,
" --local-verse-store " , $repoWorkVerseStore ,
" --runtime-id " , $RepoWorkRuntimeId ,
" --max-items " , " $RepoWorkMaxItems "
)
if ( $RepoWorkDryRun . IsPresent ) {
$repoWorkArgs + = @ ( " --dry-run " )
}
Invoke-Checked `
-Label " run repo-work queue surface " `
-FilePath $repoWorkExe `
-Arguments $repoWorkArgs `
-WorkingDirectory $Root `
-StdoutPath $resultPath `
-StderrPath ( Join-Path $artifactRoot " repo-work-queue-run.stderr.log " )
}
2026-06-21 19:10:42 +01:00
if ( $Mode -eq " repo-work-public-proof " ) {
$resultPath = Join-Path $artifactRoot " repo-work-public-proof.stdout.json "
$repoWorkVerseStore = Join-Path $Workspace " .epiphany\local-verse.ccmp "
$repoWorkArgs = @ (
" export-proof " ,
" --workspace " , $Workspace ,
" --item " , $RepoWorkItem ,
" --local-verse-store " , $repoWorkVerseStore ,
" --runtime-id " , $RepoWorkRuntimeId
)
if ( $RepoWorkPublicProofOutput -ne " " ) {
$repoWorkArgs + = @ ( " --output " , $RepoWorkPublicProofOutput )
}
Invoke-Checked `
-Label " export redacted repo-work public proof " `
-FilePath $repoWorkExe `
-Arguments $repoWorkArgs `
-WorkingDirectory $Root `
-StdoutPath $resultPath `
-StderrPath ( Join-Path $artifactRoot " repo-work-public-proof.stderr.log " )
}
2026-06-21 10:56:33 +01:00
if ( $Mode -eq " repo-work-readiness " ) {
$resultPath = Join-Path $artifactRoot " repo-work-readiness.stdout.json "
$repoWorkArgs = @ (
" readiness " ,
" --workspace " , $Workspace ,
" --item " , $RepoWorkItem
)
if ( $RepoWorkPublicProof -ne " " ) {
$repoWorkArgs + = @ ( " --public-proof " , $RepoWorkPublicProof )
}
if ( $RepoWorkIdunnLifecycleReceipt -ne " " ) {
$repoWorkArgs + = @ ( " --idunn-lifecycle-receipt " , $RepoWorkIdunnLifecycleReceipt )
}
2026-06-21 11:16:24 +01:00
if ( $RepoWorkDeploymentAftercareReceipt -ne " " ) {
$repoWorkArgs + = @ ( " --deployment-aftercare-audit-receipt " , $RepoWorkDeploymentAftercareReceipt )
}
if ( $RepoWorkDeploymentAftercareReceiptRef -ne " " ) {
$repoWorkArgs + = @ ( " --deployment-aftercare-audit-receipt-ref " , $RepoWorkDeploymentAftercareReceiptRef )
}
2026-06-21 10:56:33 +01:00
if ( $RepoWorkToolDirectoryReceipt -ne " " ) {
$repoWorkArgs + = @ ( " --tool-directory-receipt " , $RepoWorkToolDirectoryReceipt )
}
Invoke-Checked `
-Label " read repo-work MVP readiness sight " `
-FilePath $repoWorkExe `
-Arguments $repoWorkArgs `
-WorkingDirectory $Root `
-StdoutPath $resultPath `
-StderrPath ( Join-Path $artifactRoot " repo-work-readiness.stderr.log " )
}
2026-06-21 12:20:28 +01:00
if ( $Mode -eq " repo-work-readiness-review " ) {
$resultPath = Join-Path $artifactRoot " repo-work-readiness-review.stdout.json "
$repoWorkArgs = @ (
" readiness-review " ,
" --workspace " , $Workspace ,
" --item " , $RepoWorkItem ,
" --maintainer-review-receipt " , $RepoWorkMaintainerReviewReceipt ,
" --soul-review-receipt " , $RepoWorkSoulReviewReceipt ,
" --mind-review-receipt " , $RepoWorkMindReviewReceipt ,
" --bifrost-review-receipt " , $RepoWorkBifrostReviewReceipt ,
" --review-summary " , $RepoWorkReadinessReviewSummary
)
if ( $RepoWorkReadinessReceipt -ne " " ) {
$repoWorkArgs + = @ ( " --readiness-receipt " , $RepoWorkReadinessReceipt )
}
Invoke-Checked `
-Label " review repo-work MVP readiness sight " `
-FilePath $repoWorkExe `
-Arguments $repoWorkArgs `
-WorkingDirectory $Root `
-StdoutPath $resultPath `
-StderrPath ( Join-Path $artifactRoot " repo-work-readiness-review.stderr.log " )
}
2026-06-21 11:05:46 +01:00
if ( $Mode -eq " repo-deployment-config-audit " ) {
$resultPath = Join-Path $artifactRoot " repo-deployment-config-audit.stdout.json "
Invoke-Checked `
-Label " audit repo Idunn deployment config " `
-FilePath $repoWorkExe `
-Arguments @ (
" deployment-config-audit " ,
" --workspace " , $Workspace
) `
-WorkingDirectory $Root `
-StdoutPath $resultPath `
-StderrPath ( Join-Path $artifactRoot " repo-deployment-config-audit.stderr.log " )
}
if ( $Mode -eq " repo-deployment-runbook " ) {
$resultPath = Join-Path $artifactRoot " repo-deployment-runbook.stdout.json "
Invoke-Checked `
-Label " write repo Idunn deployment runbook " `
-FilePath $repoWorkExe `
-Arguments @ (
" deployment-execution-runbook " ,
" --workspace " , $Workspace ,
" --remote " , $RepoDeploymentRemote
) `
-WorkingDirectory $Root `
-StdoutPath $resultPath `
-StderrPath ( Join-Path $artifactRoot " repo-deployment-runbook.stderr.log " )
}
if ( $Mode -eq " repo-deployment-aftercare-audit " ) {
$resultPath = Join-Path $artifactRoot " repo-deployment-aftercare-audit.stdout.json "
$repoWorkVerseStore = Join-Path $Workspace " .epiphany\local-verse.ccmp "
$aftercareArgs = @ (
" deployment-aftercare-audit " ,
" --workspace " , $Workspace ,
" --local-verse-store " , $repoWorkVerseStore ,
" --runtime-id " , $RepoWorkRuntimeId
)
if ( $RepoDeploymentRunbookReceipt -ne " " ) {
$aftercareArgs + = @ ( " --runbook-receipt " , $RepoDeploymentRunbookReceipt )
}
if ( $RepoDeploymentIdunnReceipt -ne " " ) {
$aftercareArgs + = @ ( " --idunn-deployment-receipt " , $RepoDeploymentIdunnReceipt )
}
if ( $RepoDeploymentIdunnReceiptRef -ne " " ) {
$aftercareArgs + = @ ( " --idunn-deployment-receipt-ref " , $RepoDeploymentIdunnReceiptRef )
}
if ( $RepoDeploymentAftercareReceipt -ne " " ) {
$aftercareArgs + = @ ( " --aftercare-audit-receipt " , $RepoDeploymentAftercareReceipt )
}
if ( $RepoDeploymentAftercareReceiptRef -ne " " ) {
$aftercareArgs + = @ ( " --aftercare-audit-receipt-ref " , $RepoDeploymentAftercareReceiptRef )
}
Invoke-Checked `
-Label " audit repo Idunn deployment aftercare " `
-FilePath $repoWorkExe `
-Arguments $aftercareArgs `
-WorkingDirectory $Root `
-StdoutPath $resultPath `
-StderrPath ( Join-Path $artifactRoot " repo-deployment-aftercare-audit.stderr.log " )
}
2026-06-21 01:49:47 +01:00
if ( $Mode -eq " repo-work-service-plan " -or $Mode -eq " repo-work-service-runbook " -or $Mode -eq " repo-work-service-launch " -or $Mode -eq " repo-work-service-audit " ) {
2026-06-20 02:17:09 +01:00
$repoWorkServiceId = $ServiceId
if ( $repoWorkServiceId -eq " epiphany-daemon-supervisor-service " ) {
$repoWorkServiceId = " epiphany-repo-work-queue-runner "
}
$repoWorkSchedulerId = $SchedulerId
if ( $repoWorkSchedulerId -eq " epiphany-daemon-supervisor " ) {
$repoWorkSchedulerId = " epiphany-repo-work-queue-runner "
}
$repoWorkVerseStore = Join-Path $Workspace " .epiphany\local-verse.ccmp "
$repoWorkServiceArgs = @ (
" queue-run " ,
" --workspace " , $Workspace ,
" --epiphany-root " , $Root ,
" --local-verse-store " , $repoWorkVerseStore ,
" --runtime-id " , $RepoWorkRuntimeId ,
" --max-items " , " $RepoWorkMaxItems "
)
if ( $RepoWorkDryRun . IsPresent ) {
$repoWorkServiceArgs + = @ ( " --dry-run " )
}
$serviceCommandArgs = @ (
" --store " , $localVerseStore ,
2026-06-21 01:16:30 +01:00
" --runtime-id " , $LocalVerseRuntimeId ,
2026-06-20 02:17:09 +01:00
" --daemon-id " , $DaemonId ,
" --scheduler-id " , $repoWorkSchedulerId ,
" --service-id " , $repoWorkServiceId ,
" --service-command " , $repoWorkExe ,
" --reason " , " Idunn-owned lifecycle artifact for Self-owned repo work queue-run pulse. " ,
" --cwd " , $Root
)
foreach ( $repoWorkServiceArg in $repoWorkServiceArgs ) {
$serviceCommandArgs + = @ ( " --service-arg " , $repoWorkServiceArg )
}
if ( $Mode -eq " repo-work-service-plan " ) {
$resultPath = Join-Path $artifactRoot " repo-work-service-plan.stdout.json "
Invoke-Checked `
-Label " plan Idunn repo-work queue-run lifecycle " `
-FilePath $daemonSupervisorExe `
-Arguments ( @ ( " service-plan " ) + $serviceCommandArgs ) `
-WorkingDirectory $Root `
-StdoutPath $resultPath `
-StderrPath ( Join-Path $artifactRoot " repo-work-service-plan.stderr.log " )
2026-06-21 01:31:05 +01:00
} elseif ( $Mode -eq " repo-work-service-runbook " ) {
2026-06-20 02:17:09 +01:00
$resultPath = Join-Path $artifactRoot " repo-work-service-runbook.stdout.json "
$runbookPath = Join-Path $artifactRoot " epiphany-repo-work-queue-runner.ps1 "
Invoke-Checked `
-Label " write Idunn repo-work queue-run runbook " `
-FilePath $daemonSupervisorExe `
-Arguments ( @ ( " service-runbook " ) + $serviceCommandArgs + @ ( " --runbook-path " , $runbookPath ) ) `
-WorkingDirectory $Root `
-StdoutPath $resultPath `
-StderrPath ( Join-Path $artifactRoot " repo-work-service-runbook.stderr.log " )
2026-06-21 01:49:47 +01:00
} elseif ( $Mode -eq " repo-work-service-launch " ) {
2026-06-21 01:31:05 +01:00
$resultPath = Join-Path $artifactRoot " repo-work-service-launch.stdout.json "
Invoke-Checked `
-Label " launch Idunn repo-work queue-run lifecycle proof " `
-FilePath $daemonSupervisorExe `
-Arguments ( @ ( " service-launch " ) + $serviceCommandArgs + @ ( " --wait-child " ) ) `
-WorkingDirectory $Root `
-StdoutPath $resultPath `
-StderrPath ( Join-Path $artifactRoot " repo-work-service-launch.stderr.log " )
2026-06-21 01:49:47 +01:00
} else {
$resultPath = Join-Path $artifactRoot " repo-work-service-audit.stdout.json "
Invoke-Checked `
-Label " audit Idunn repo-work queue-run lifecycle proof " `
-FilePath $daemonSupervisorExe `
-Arguments ( @ ( " repo-work-service-audit " ) + $serviceCommandArgs ) `
-WorkingDirectory $Root `
-StdoutPath $resultPath `
-StderrPath ( Join-Path $artifactRoot " repo-work-service-audit.stderr.log " )
2026-06-20 02:17:09 +01:00
}
}
2026-05-21 10:17:38 +01:00
if ( $Mode -eq " plan " ) {
2026-05-21 10:31:10 +01:00
$resultPath = Join-Path $artifactRoot " coordinator-plan.stdout.json "
2026-05-21 10:18:52 +01:00
$planArgs = @ (
" --app-server " , $codexAppServer ,
" --codex-home " , $CodexHome ,
" --cwd " , $Workspace ,
" --artifact-dir " , ( Join-Path $dogfoodRoot " coordinator " ) ,
2026-05-28 14:44:08 +01:00
" --runtime-store " , $runtimeStore ,
2026-05-21 10:18:52 +01:00
" --mode " , " plan " ,
" --max-steps " , " 1 " ,
" --timeout-seconds " , " $TimeoutSeconds "
)
if ( $ThreadId -ne " " ) {
$planArgs + = @ ( " --thread-id " , $ThreadId , " --no-ephemeral " )
}
2026-05-21 10:17:38 +01:00
Invoke-Checked `
-Label " run coordinator plan " `
-FilePath $coordinatorExe `
2026-05-21 10:18:52 +01:00
-Arguments $planArgs `
2026-05-21 10:17:38 +01:00
-WorkingDirectory $Root `
-StdoutPath ( Join-Path $artifactRoot " coordinator-plan.stdout.json " ) `
-StderrPath ( Join-Path $artifactRoot " coordinator-plan.stderr.log " )
}
if ( $Mode -eq " smoke " ) {
2026-05-21 10:31:10 +01:00
$resultPath = Join-Path $artifactRoot " coordinator-smoke.stdout.json "
2026-05-21 10:17:38 +01:00
if ( -not ( Test-Path -LiteralPath $coordinatorSmokeExe ) ) {
throw " required binary not found: $coordinatorSmokeExe "
}
Invoke-Checked `
-Label " run coordinator smoke " `
-FilePath $coordinatorSmokeExe `
-Arguments @ (
" --app-server " , $codexAppServer ,
" --artifact-root " , ( Join-Path $dogfoodRoot " coordinator-smoke " ) ,
" --coordinator-exe " , $coordinatorExe
) `
-WorkingDirectory $Root `
-StdoutPath ( Join-Path $artifactRoot " coordinator-smoke.stdout.json " ) `
-StderrPath ( Join-Path $artifactRoot " coordinator-smoke.stderr.log " )
}
2026-05-28 13:37:08 +01:00
if ( $Mode -eq " mvp " ) {
2026-06-15 16:38:09 +01:00
if ( $PersonaInput . Trim ( ) -eq " " ) {
$PersonaInput = " Operator requested the local Epiphany MVP cycle. Persona should surface the swarm state, then the coordinator may continue bounded work and sleep afterward. "
2026-05-28 12:18:58 +01:00
}
2026-06-15 16:38:09 +01:00
$PersonaArtifactDir = Join-Path $dogfoodRoot " Persona "
2026-05-28 13:37:08 +01:00
$characterArtifactDir = Join-Path $dogfoodRoot " character-loop "
2026-06-15 16:38:09 +01:00
$PersonaBubblePath = Join-Path $artifactRoot " Persona-bubble.stdout.json "
$characterTurnPath = Join-Path $artifactRoot " Persona-character-turn.stdout.json "
2026-05-28 13:37:08 +01:00
Invoke-Checked `
2026-06-15 16:38:09 +01:00
-Label " project Persona character turn " `
2026-05-28 13:37:08 +01:00
-FilePath $characterLoopExe `
-Arguments @ (
" turn " ,
2026-06-15 16:38:09 +01:00
" --role " , " Persona " ,
2026-05-28 13:37:08 +01:00
" --agent-store " , $agentStore ,
" --artifact-dir " , $characterArtifactDir ,
2026-06-15 16:38:09 +01:00
" --stimulus " , $PersonaInput ,
2026-05-28 13:37:08 +01:00
" --source " , " epiphany/local-mvp " ,
" --mode " , " local-mvp-front-door " ,
" --status " , " ready " ,
" --mood " , " attentive "
) `
-WorkingDirectory $Root `
-StdoutPath $characterTurnPath `
2026-06-15 16:38:09 +01:00
-StderrPath ( Join-Path $artifactRoot " Persona-character-turn.stderr.log " )
2026-05-28 13:37:08 +01:00
Invoke-Checked `
2026-06-15 16:38:09 +01:00
-Label " write Persona Aquarium bubble " `
-FilePath $PersonaExe `
2026-05-28 13:37:08 +01:00
-Arguments @ (
" bubble " ,
2026-06-15 16:38:09 +01:00
" --artifact-dir " , $PersonaArtifactDir ,
2026-06-18 15:24:47 +01:00
" --cultmesh-store " , $localVerseStore ,
2026-06-21 01:16:30 +01:00
" --runtime-id " , $LocalVerseRuntimeId ,
2026-06-15 16:38:09 +01:00
" --content " , $PersonaInput ,
2026-05-28 13:37:08 +01:00
" --source " , " epiphany/local-mvp " ,
" --status " , " ready " ,
" --mood " , " attentive "
) `
-WorkingDirectory $Root `
2026-06-15 16:38:09 +01:00
-StdoutPath $PersonaBubblePath `
-StderrPath ( Join-Path $artifactRoot " Persona-bubble.stderr.log " )
2026-05-28 13:37:08 +01:00
}
if ( $liveRuntimeMode ) {
$resultPath = Join-Path $artifactRoot " coordinator-run.stdout.json "
2026-05-21 10:17:38 +01:00
$runArgs = @ (
" --app-server " , $codexAppServer ,
2026-05-27 22:18:52 +01:00
" --model-runtime-bin " , $modelRuntimeExe ,
2026-05-28 12:18:58 +01:00
" --tool-adapter-bin " , $toolAdapterExe ,
2026-05-27 22:18:52 +01:00
" --model-provider " , $modelProvider ,
2026-05-21 10:17:38 +01:00
" --codex-home " , $CodexHome ,
2026-05-21 10:18:52 +01:00
" --cwd " , $Workspace ,
2026-05-21 10:17:38 +01:00
" --artifact-dir " , ( Join-Path $dogfoodRoot " coordinator " ) ,
2026-05-28 14:44:08 +01:00
" --runtime-store " , $runtimeStore ,
2026-05-21 10:17:38 +01:00
" --mode " , " run " ,
" --max-steps " , " $MaxSteps " ,
2026-05-28 15:42:52 +01:00
" --timeout-seconds " , " $TimeoutSeconds " ,
" --max-runtime-seconds " , " $MaxRuntimeSeconds "
2026-05-21 10:17:38 +01:00
)
if ( $AutoReview ) {
$runArgs + = " --auto-review "
}
2026-06-13 12:26:13 +01:00
if ( $SupersedeFailedResults ) {
$runArgs + = " --supersede-failed-results "
}
2026-05-28 14:44:08 +01:00
if ( $Mode -eq " mvp " -and $ThreadId -eq " " ) {
2026-06-15 16:38:09 +01:00
$runArgs + = @ ( " --bootstrap-local-state " , " --bootstrap-objective " , $PersonaInput )
2026-05-28 14:44:08 +01:00
}
2026-05-28 15:42:52 +01:00
if ( $Mode -eq " mvp " -or $NoEphemeral ) {
$runArgs + = " --no-ephemeral "
}
2026-05-21 10:18:52 +01:00
if ( $ThreadId -ne " " ) {
$runArgs + = @ ( " --thread-id " , $ThreadId , " --no-ephemeral " )
}
2026-05-21 10:17:38 +01:00
Invoke-Checked `
-Label " run coordinator loop " `
-FilePath $coordinatorExe `
-Arguments $runArgs `
-WorkingDirectory $Root `
-StdoutPath ( Join-Path $artifactRoot " coordinator-run.stdout.json " ) `
-StderrPath ( Join-Path $artifactRoot " coordinator-run.stderr.log " )
}
2026-06-18 15:24:47 +01:00
$coordinatorSummaryPath = Join-Path ( Join-Path $dogfoodRoot " coordinator " ) " coordinator-summary.json "
if ( ( $Mode -eq " plan " -or $liveRuntimeMode ) -and ( Test-Path -LiteralPath $coordinatorSummaryPath ) ) {
Invoke-Checked `
-Label " write CultMesh coordinator run receipt " `
-FilePath $operatorRunExe `
-Arguments @ (
" coordinator-receipt " ,
" --store " , $localVerseStore ,
2026-06-21 01:16:30 +01:00
" --runtime-id " , $LocalVerseRuntimeId ,
2026-06-18 15:24:47 +01:00
" --run-id " , $runId ,
" --artifact-root " , ( Join-Path $dogfoodRoot " coordinator " ) ,
" --coordinator-summary " , $coordinatorSummaryPath ,
" --coordinator-receipt-id " , " $runId -coordinator "
) `
-WorkingDirectory $Root `
-StdoutPath ( Join-Path $artifactRoot " coordinator-run-receipt.stdout.json " ) `
-StderrPath ( Join-Path $artifactRoot " coordinator-run-receipt.stderr.log " )
}
2026-05-28 13:37:08 +01:00
if ( $Mode -eq " mvp " -and -not $SkipSleep ) {
$sleepArtifactDir = Join-Path $dogfoodRoot " sleep "
if ( -not ( Test-Path -LiteralPath $heartbeatStore ) ) {
Invoke-Checked `
-Label " initialize heartbeat store " `
-FilePath $heartbeatExe `
-Arguments @ (
" init " ,
" --store " , $heartbeatStore
) `
-WorkingDirectory $Root `
-StdoutPath ( Join-Path $artifactRoot " heartbeat-init.stdout.json " ) `
-StderrPath ( Join-Path $artifactRoot " heartbeat-init.stderr.log " )
}
Invoke-Checked `
-Label " run sleep and dream routine " `
-FilePath $heartbeatExe `
-Arguments @ (
" routine " ,
" --store " , $heartbeatStore ,
" --artifact-dir " , $sleepArtifactDir ,
" --agent-store " , $agentStore ,
" --source " , " epiphany/local-mvp "
) `
-WorkingDirectory $Root `
-StdoutPath ( Join-Path $artifactRoot " sleep-routine.stdout.json " ) `
-StderrPath ( Join-Path $artifactRoot " sleep-routine.stderr.log " )
Invoke-Checked `
-Label " project heartbeat sleep status " `
-FilePath $heartbeatExe `
-Arguments @ (
" status " ,
" --store " , $heartbeatStore ,
" --artifact-dir " , $sleepArtifactDir
) `
-WorkingDirectory $Root `
-StdoutPath ( Join-Path $artifactRoot " sleep-status.stdout.json " ) `
-StderrPath ( Join-Path $artifactRoot " sleep-status.stderr.log " )
}
2026-05-21 10:17:38 +01:00
$summary = @"
# Epiphany Local Run
- mode : $Mode
- root : $Root
2026-05-21 10:18:52 +01:00
- workspace : $Workspace
- threadId : $ThreadId
2026-05-21 10:17:38 +01:00
- codexHome : $CodexHome
- targetDir : $TargetDir
- artifactRoot : $artifactRoot
- dogfoodRoot : $dogfoodRoot
- codexAppServer : $codexAppServer
- statusBinary : $statusExe
2026-05-27 21:08:55 +01:00
- operatorRunBinary : $operatorRunExe
- operatorRunStore : $operatorRunStore
2026-05-27 20:58:31 +01:00
- operatorSnapshotBinary : $operatorSnapshotExe
- operatorSnapshotStore : $operatorSnapshotStore
2026-06-02 14:24:55 +01:00
- localVerseBinary : $verseQueryExe
- localVerseStore : $localVerseStore
2026-06-21 01:16:30 +01:00
- localVerseReadStore : $localVerseReadStore
- localVerseRuntimeId : $LocalVerseRuntimeId
2026-05-21 10:17:38 +01:00
- coordinatorBinary : $coordinatorExe
2026-05-28 14:44:08 +01:00
- runtimeStore : $runtimeStore
2026-05-27 22:18:52 +01:00
- modelRuntimeBinary : $modelRuntimeExe
- modelProvider : $modelProvider
2026-06-15 16:38:09 +01:00
- PersonaBinary : $PersonaExe
2026-05-28 13:37:08 +01:00
- characterLoopBinary : $characterLoopExe
- heartbeatBinary : $heartbeatExe
2026-05-21 10:17:38 +01:00
2026-05-27 21:32:29 +01:00
This is an operator entrypoint over the current MVP shell . Status mode is
2026-06-02 14:24:55 +01:00
Epiphany-native and does not start Codex app-server ; it writes native status ,
operator snapshot , and a compact local Verse context read from CultMesh so
Aquarium / local-run can inspect the same policy / contract packet used for dynamic
prompt context . Coordinator plan / smoke / run modes still use the sealed Codex
compatibility bridge until their provider boundary is cut . MVP mode wraps that
2026-06-15 16:38:09 +01:00
bridge-equipped coordinator loop in the local product cycle : Persona front door ,
2026-06-02 14:24:55 +01:00
bounded swarm work , then heartbeat sleep / dream maintenance .
2026-05-21 10:17:38 +01:00
" @
Set-Content -LiteralPath ( Join-Path $artifactRoot " README.md " ) -Value $summary -Encoding UTF8
Write-Host " "
2026-05-21 10:31:10 +01:00
if ( $resultPath -ne " " -and ( Test-Path -LiteralPath $resultPath ) ) {
try {
$result = Get-Content -Raw -LiteralPath $resultPath | ConvertFrom-Json
if ( $Mode -eq " smoke " ) {
Write-Host " Smoke: cold= $( $result . coldAction ) , pressure= $( $result . pressureAction ) , privateBackendMutationRejected= $( $result . directBackendCompletionRejected ) "
} elseif ( $Mode -eq " status " ) {
2026-06-22 17:15:52 +01:00
$bridgeRows = " none "
if ( $null -ne $result . bifrostBridge -and $null -ne $result . bifrostBridge . surfaces -and $result . bifrostBridge . surfaces . Count -gt 0 ) {
$bridgeRows = ( @ ( $result . bifrostBridge . surfaces ) | ForEach-Object { " $( $_ . id ) = $( $_ . status ) " } ) -join " , "
}
Write-Host " Status: thread= $( $result . threadId ) , coordinator= $( $result . coordinator . action ) , crrc= $( $result . crrc . recommendation . action ) , bifrostBridge= $( $result . bifrostBridge . status ) , bridgeReady= $( $result . bifrostBridge . readySurfaceCount ) / $( $result . bifrostBridge . surfaceCount ) , bridgeRows= $bridgeRows "
2026-06-18 15:24:47 +01:00
} elseif ( $Mode -eq " agent-state-soa " ) {
2026-06-18 18:01:06 +01:00
$agentRows = " none "
if ( $null -ne $result . tuiRows -and $result . tuiRows . Count -gt 0 ) {
$agentRows = ( $result . tuiRows -join " ; " )
}
Write-Host " Agent state SoA: status= $( $result . status ) , agents= $( $result . agentCount ) , summaryRows= $( $result . summarySoaTableRows ) , agentRows= $agentRows , privateStateExposed= $( $result . privateStateExposed ) "
2026-06-18 15:24:47 +01:00
} elseif ( $Mode -eq " swarm-status " ) {
2026-06-18 17:55:40 +01:00
$daemonRows = " none "
2026-06-18 21:04:33 +01:00
$statusRows = " none "
if ( $null -ne $result . tuiRows -and $result . tuiRows . Count -gt 0 ) {
$statusRows = ( $result . tuiRows -join " ; " )
}
2026-06-18 17:55:40 +01:00
if ( $null -ne $result . rows -and $result . rows . Count -gt 0 ) {
$daemonRows = ( ( $result . rows | ForEach-Object {
" $( $_ . displayName ) : $( $_ . status ) : $( $_ . daemonId ) :privateVerse= $( $_ . privateVerseId ) :surface= $( $_ . eveSurfaceId ) -> $( $result . wrapperMode ) "
} ) -join " ; " )
}
2026-06-18 21:04:33 +01:00
Write-Host " Swarm status: status= $( $result . status ) , daemons= $( $result . daemonCount ) , nonReady= $( $result . nonReadyCount ) , daemonRows= $daemonRows , statusRows= $statusRows , privateStateExposed= $( $result . privateStateExposed ) "
2026-06-18 15:24:47 +01:00
} elseif ( $Mode -eq " cluster-topology " ) {
2026-06-18 18:22:37 +01:00
$topologyRows = " none "
if ( $null -ne $result . tuiRows -and $result . tuiRows . Count -gt 0 ) {
$topologyRows = ( $result . tuiRows -join " ; " )
}
Write-Host " Cluster topology: status= $( $result . status ) , clusters= $( $result . clusterCount ) , privateVerses= $( $result . privateVerseCount ) , daemons= $( $result . daemonCount ) , publicDiscussion= $( $result . publicDiscussionClusterCount ) , topologyRows= $topologyRows , privateStateExposed= $( $result . privateStateExposed ) "
2026-06-18 15:24:47 +01:00
} elseif ( $Mode -eq " eve-surfaces " ) {
2026-06-18 18:22:37 +01:00
$surfaceRows = " none "
if ( $null -ne $result . tuiRows -and $result . tuiRows . Count -gt 0 ) {
$surfaceRows = ( $result . tuiRows -join " ; " )
}
2026-06-18 17:35:38 +01:00
$publicSurfaces = " none "
if ( $null -ne $result . rows -and $result . rows . Count -gt 0 ) {
$publicSurfaceRows = @ ( $result . rows | Where-Object { $_ . publicPersonaDiscussionAllowed -eq $true } | ForEach-Object {
" $( $_ . displayName ) = $( $_ . eveSurfaceId ) @ $( $_ . privateVerseId ) "
} )
if ( $publicSurfaceRows . Count -gt 0 ) {
$publicSurfaces = ( $publicSurfaceRows -join " , " )
}
}
2026-06-20 01:38:31 +01:00
$repoWorkQueueRows = " none "
if ( $null -ne $result . repoWorkQueueTuiRows -and $result . repoWorkQueueTuiRows . Count -gt 0 ) {
$repoWorkQueueRows = ( $result . repoWorkQueueTuiRows -join " ; " )
}
Write-Host " Eve surfaces: status= $( $result . status ) , surfaces= $( $result . surfaceCount ) , publicDiscussion= $( $result . publicDiscussionSurfaceCount ) , repoWorkQueue= $( $result . repoWorkQueueCount ) , repoWorkRows= $repoWorkQueueRows , surfaceRows= $surfaceRows , publicSurfaces= $publicSurfaces , connectCommand= $( $result . connectionCommand ) , privateStateExposed= $( $result . privateStateExposed ) "
2026-06-18 15:24:47 +01:00
} elseif ( $Mode -eq " eve-connect " ) {
2026-06-20 01:38:31 +01:00
$repoWorkQueueRows = " none "
if ( $null -ne $result . repoWorkQueueTuiRows -and $result . repoWorkQueueTuiRows . Count -gt 0 ) {
$repoWorkQueueRows = ( $result . repoWorkQueueTuiRows -join " ; " )
}
Write-Host " Eve connect: status= $( $result . status ) , target= $( $result . targetClusterId ) , surface= $( $result . targetEveSurfaceId ) , receipt= $( $result . receiptId ) , repoWorkQueue= $( $result . repoWorkQueueCount ) , repoWorkRows= $repoWorkQueueRows , privateStateExposed= $( $result . privateStateExposed ) "
2026-06-18 15:24:47 +01:00
} elseif ( $Mode -eq " collaboration-feedback " ) {
2026-06-18 20:57:51 +01:00
$feedbackRows = " none "
if ( $null -ne $result . tuiRows -and $result . tuiRows . Count -gt 0 ) {
$feedbackRows = ( $result . tuiRows -join " ; " )
}
2026-06-18 17:29:13 +01:00
$publicRefs = " none "
if ( $null -ne $result . publicDiscussionRefs -and $result . publicDiscussionRefs . Count -gt 0 ) {
$publicRefs = ( $result . publicDiscussionRefs -join " , " )
}
$candidateRefs = " none "
if ( $null -ne $result . candidateActionRefs -and $result . candidateActionRefs . Count -gt 0 ) {
$candidateRefs = ( $result . candidateActionRefs -join " , " )
}
2026-06-18 20:57:51 +01:00
Write-Host " Collaboration feedback: status= $( $result . status ) , feedback= $( $result . feedbackId ) , consensus= $( $result . consensusReceiptId ) , publicRefs= $publicRefs , candidateActions= $candidateRefs , consensusPacket= $( $result . consensusPacketRef ) , adoptionGate= $( $result . adoptionGate ) , feedbackRows= $feedbackRows , privateStateExposed= $( $result . privateStateExposed ) "
2026-06-22 17:02:04 +01:00
} elseif ( @ ( " persona-discord " , " persona-reddit " , " persona-other " ) -contains $Mode ) {
$auditId = " none "
if ( $null -ne $result . speechAudit -and $null -ne $result . speechAudit . auditId ) {
$auditId = $result . speechAudit . auditId
} elseif ( $null -ne $result . auditId ) {
$auditId = $result . auditId
}
$decision = $result . decision
if ( $null -eq $decision -or $decision -eq " " ) {
$decision = $result . status
}
$target = $result . target
if ( $null -eq $target -or $target -eq " " ) {
$target = $result . requestedPublicTarget
}
if ( $null -eq $target -or $target -eq " " ) {
$target = " none "
}
$bridgeAction = $result . bridgeActionId
if ( $null -eq $bridgeAction -or $bridgeAction -eq " " ) {
$bridgeAction = " none "
}
Write-Host " Persona mouth: mode= $Mode , action= $PersonaMouthAction , decision= $decision , audit= $auditId , target= $target , bridgeAction= $bridgeAction , artifact= $resultPath "
2026-06-22 17:38:55 +01:00
} elseif ( $Mode -eq " persona-bridge " ) {
$surfaceRows = " none "
if ( $null -ne $result . surfaces -and $result . surfaces . Count -gt 0 ) {
$surfaceRows = ( ( $result . surfaces | ForEach-Object {
" $( $_ . surface ) :transport= $( $_ . transport ) ,identity= $( $_ . bifrostIdentity ) ,heimdall= $( $_ . heimdallCapabilityRef ) ,private= $( $_ . speechAuditPrivateStateExposed ) "
} ) -join " ; " )
}
$bridgeRows = " none "
if ( $null -ne $result . readiness -and $null -ne $result . readiness . surfaces -and $result . readiness . surfaces . Count -gt 0 ) {
$bridgeRows = ( ( $result . readiness . surfaces | ForEach-Object { " $( $_ . id ) = $( $_ . status ) " } ) -join " , " )
}
Write-Host " Persona bridge: status= $( $result . status ) , bridge= $( $result . readiness . status ) , ready= $( $result . readiness . readySurfaceCount ) / $( $result . readiness . surfaceCount ) , bridgeRows= $bridgeRows , mouthRows= $surfaceRows , privateStateExposed= $( $result . privateStateExposed ) , artifact= $resultPath "
2026-06-18 15:24:47 +01:00
} elseif ( $Mode -eq " bifrost-publication " ) {
Write-Host " Bifrost publication: status= $( $result . status ) , intent= $( $result . intentId ) , publication= $( $result . publicationReceiptId ) , github= $( $result . githubPublicationReceiptId ) , privateStateExposed= $( $result . privateStateExposed ) "
2026-06-20 13:30:43 +01:00
} elseif ( $Mode -eq " bifrost-public-proof " ) {
2026-06-21 19:17:14 +01:00
$creditReceipts = " none "
if ( $null -ne $result . creditReceiptIds -and $result . creditReceiptIds . Count -gt 0 ) {
$creditReceipts = ( $result . creditReceiptIds -join " , " )
}
$reviewReceipts = " none "
if ( $null -ne $result . reviewReceiptIds -and $result . reviewReceiptIds . Count -gt 0 ) {
$reviewReceipts = ( $result . reviewReceiptIds -join " , " )
}
Write-Host " Bifrost public proof: status= $( $result . status ) , item= $( $result . item ) , proof= $( $result . publicProofId ) , receipt= $( $result . receiptId ) , publicVerse= $( $result . targetPublicVerseId ) , room= $( $result . publicRoomId ) , sha256= $( $result . publicProofSha256 ) , ledger= $( $result . ledgerEntryId ) , credit= $creditReceipts , review= $reviewReceipts , public= $( $result . publicationUrl ) , privateStateExposed= $( $result . privateStateExposed ) "
2026-06-21 14:01:55 +01:00
} elseif ( $Mode -eq " bifrost-artifact-acceptance " ) {
$changedPaths = " none "
if ( $null -ne $result . changedPaths -and $result . changedPaths . Count -gt 0 ) {
$changedPaths = ( $result . changedPaths -join " , " )
}
2026-07-11 18:41:07 +01:00
$reviewReceipts = " none "
if ( $null -ne $result . reviewReceiptIds -and $result . reviewReceiptIds . Count -gt 0 ) {
$reviewReceipts = ( $result . reviewReceiptIds -join " , " )
}
Write-Host " Bifrost artifact acceptance: status= $( $result . status ) , item= $( $result . item ) , receipt= $( $result . receiptId ) , branch= $( $result . sourceBranch ) , commit= $( $result . commitSha ) , artifact= $( $result . artifactRef ) , publicProof= $( $result . publicProofRef ) , ledger= $( $result . ledgerEntryId ) , acceptedBy= $( $result . acceptedBy ) , review= $reviewReceipts , changedPaths= $changedPaths , privateStateExposed= $( $result . privateStateExposed ) "
2026-06-21 14:01:55 +01:00
} elseif ( $Mode -eq " bifrost-metrics " ) {
$modelSpend = " none "
if ( $null -ne $result . modelSpendReceiptIds -and $result . modelSpendReceiptIds . Count -gt 0 ) {
$modelSpend = ( $result . modelSpendReceiptIds -join " , " )
}
$reviewLoad = " none "
if ( $null -ne $result . reviewLoadReceiptIds -and $result . reviewLoadReceiptIds . Count -gt 0 ) {
$reviewLoad = ( $result . reviewLoadReceiptIds -join " , " )
}
$creditReadback = " none "
if ( $null -ne $result . creditReadbackReceiptIds -and $result . creditReadbackReceiptIds . Count -gt 0 ) {
$creditReadback = ( $result . creditReadbackReceiptIds -join " , " )
}
2026-07-11 18:41:07 +01:00
Write-Host " Bifrost metrics: status= $( $result . status ) , item= $( $result . item ) , receipt= $( $result . receiptId ) , branch= $( $result . sourceBranch ) , artifactAcceptance= $( $result . artifactAcceptanceReceiptId ) , publicProof= $( $result . publicProofRef ) , modelSpend= $modelSpend , reviewLoad= $reviewLoad , creditReadback= $creditReadback , summary= $( $result . metricsSummary ) , privateStateExposed= $( $result . privateStateExposed ) "
2026-06-21 15:01:37 +01:00
} elseif ( $Mode -eq " daemon-survival-rehearsal " ) {
Write-Host " Daemon survival rehearsal: status= $( $result . status ) , daemon= $( $result . daemonId ) , scheduler= $( $result . schedulerId ) , policy= $( $result . policyStatus ) , serve= $( $result . serveStatus ) , iterations= $( $result . serveIterations ) , schedulerReceipt= $( $result . schedulerReceiptId ) , serviceManagerMutated= $( $result . serviceManagerMutated ) , elevated= $( $result . requiresElevatedAuthority ) , privateStateExposed= $( $result . privateStateExposed ) , smokeDir= $( $result . smokeDir ) "
2026-06-21 14:48:34 +01:00
} elseif ( $Mode -eq " repo-swarm-mvp-gate " ) {
$remaining = " none "
if ( $null -ne $result . knownRemainingAuthorityGates -and $result . knownRemainingAuthorityGates . Count -gt 0 ) {
$remaining = ( $result . knownRemainingAuthorityGates -join " ; " )
}
Write-Host " Repo swarm MVP gate: status= $( $result . status ) , demoReady= $( $result . demoReady ) , mvpReady= $( $result . mvpReady ) , green= $( $result . greenGateCount ) , warnings= $( $result . warningGateCount ) , blockers= $( $result . blockerGateCount ) , remaining=' $remaining ', privateStateExposed= $( $result . privateStateExposed ) , smokeDir= $( $result . smokeDir ) "
2026-06-21 19:03:35 +01:00
} elseif ( $Mode -eq " repo-livefire-closure " ) {
$changedPaths = " none "
if ( $null -ne $result . changedPaths -and $result . changedPaths . Count -gt 0 ) {
$changedPaths = ( $result . changedPaths -join " , " )
}
Write-Host " Repo live-fire closure: status= $( $result . status ) , item= $( $result . item ) , branch= $( $result . branch ) , commit= $( $result . commitSha ) , family= $( $result . safeActionFamily ) , paths= $changedPaths , gate= $( $result . currentGate ) , blocker= $( $result . blocker ) , publicationGate= $( $result . publicationGate ) , soul= $( $result . soulVerdict ) , mindCommit= $( $result . mindStateCommitReceiptId ) , privateStateExposed= $( $result . privateStateExposed ) "
2026-06-21 14:31:47 +01:00
} elseif ( $Mode -eq " bifrost-accounting-bundle " ) {
Write-Host " Bifrost accounting bundle: status= $( $result . status ) , artifactFamily= $( $result . artifactAcceptanceFamily ) , metricsFamily= $( $result . metricsFamily ) , artifactReceipt= $( $result . artifactAcceptanceReceiptId ) , metricsReceipt= $( $result . metricsReceiptId ) , planningAuthorityOnly= $( $result . planningAuthorityOnly ) , operatorSafeProofBundle= $( $result . operatorSafeProofBundle ) , privateStateExposed= $( $result . privateStateExposed ) , smokeDir= $( $result . smokeDir ) "
2026-06-18 15:24:47 +01:00
} elseif ( $Mode -eq " bifrost-ledger " ) {
2026-06-18 20:57:51 +01:00
$ledgerRows = " none "
if ( $null -ne $result . tuiRows -and $result . tuiRows . Count -gt 0 ) {
$ledgerRows = ( $result . tuiRows -join " ; " )
}
2026-06-21 09:13:30 +01:00
$accountingRows = " none "
if ( $null -ne $result . accountingTuiRows -and $result . accountingTuiRows . Count -gt 0 ) {
$accountingRows = ( $result . accountingTuiRows -join " ; " )
}
2026-06-18 17:24:12 +01:00
$publicRefs = " none "
if ( $null -ne $result . rows -and $result . rows . Count -gt 0 ) {
$publicRefs = ( ( $result . rows | ForEach-Object {
$publicRef = $_ . publicRef
if ( $null -eq $publicRef -or $publicRef -eq " " ) {
$publicRef = " none "
}
" $( $_ . documentKind ) = ${publicRef} "
} ) -join " ; " )
}
2026-06-21 14:01:55 +01:00
Write-Host " Bifrost ledger: status= $( $result . status ) , rows= $( $result . rowCount ) , publicationChain= $( $result . publicationChainCount ) , publicProofPublications= $( $result . publicProofPublicationCount ) , artifactAcceptance= $( $result . artifactAcceptanceReceiptCount ) , metrics= $( $result . metricsReceiptCount ) , collaborationChain= $( $result . collaborationChainCount ) , accountingRows= $( $result . accountingRowCount ) , closedAccounting= $( $result . closedAccountingRowCount ) , attentionAccounting= $( $result . attentionAccountingRowCount ) , publicRefs= $publicRefs , accounting= $accountingRows , ledgerRows= $ledgerRows , privateStateExposed= $( $result . privateStateExposed ) "
2026-06-18 15:24:47 +01:00
} elseif ( $Mode -eq " receipt-directory " ) {
2026-06-18 16:54:43 +01:00
$artifactHashes = " none "
2026-06-18 17:40:52 +01:00
$attentionRoutes = " none "
2026-06-18 21:00:41 +01:00
$receiptRows = " none "
if ( $null -ne $result . tuiRows -and $result . tuiRows . Count -gt 0 ) {
$receiptRows = ( $result . tuiRows -join " ; " )
}
2026-06-18 16:54:43 +01:00
if ( $null -ne $result . rows -and $result . rows . Count -gt 0 ) {
$presentArtifactHashes = @ ( $result . rows | Where-Object { $_ . artifactStatus -eq " present " } | ForEach-Object {
$artifactSha256 = $_ . artifactSha256
if ( $null -eq $artifactSha256 -or $artifactSha256 -eq " " ) {
$artifactSha256 = " none "
}
" $( $_ . family ) : ${artifactSha256} "
} )
if ( $presentArtifactHashes . Count -gt 0 ) {
$artifactHashes = ( $presentArtifactHashes -join " ; " )
}
2026-06-18 21:24:01 +01:00
$attentionRouteRows = @ ( $result . attentionRouteRows )
2026-06-18 17:40:52 +01:00
if ( $attentionRouteRows . Count -gt 0 ) {
$attentionRoutes = ( $attentionRouteRows -join " ; " )
}
2026-06-18 16:54:43 +01:00
}
2026-06-18 21:00:41 +01:00
Write-Host " Receipt directory: status= $( $result . status ) , rows= $( $result . rowCount ) , present= $( $result . presentRowCount ) , absent= $( $result . absentRowCount ) , attention= $( $result . attentionRowCount ) , attentionRoutes= $attentionRoutes , receiptRows= $receiptRows , artifactNone= $( $result . artifactNoneCount ) , artifactExternalRef= $( $result . artifactExternalRefCount ) , artifactPresent= $( $result . artifactPresentCount ) , artifactMissing= $( $result . artifactMissingCount ) , artifactHashes= $artifactHashes , privateStateExposed= $( $result . privateStateExposed ) "
2026-06-18 15:24:47 +01:00
} elseif ( $Mode -eq " tool-directory " ) {
2026-06-18 18:19:14 +01:00
$toolRows = " none "
if ( $null -ne $result . tuiRows -and $result . tuiRows . Count -gt 0 ) {
$toolRows = ( $result . tuiRows -join " ; " )
}
Write-Host " Tool directory: status= $( $result . status ) , tools= $( $result . toolCount ) , hostReady= $( $result . hostReadyCount ) , hostAttention= $( $result . hostAttentionCount ) , availableToAllAgents= $( $result . invariants . availableToAllAgents ) , requiresReceipt= $( $result . invariants . requiresReceipt ) , toolRows= $toolRows , privateStateExposed= $( $result . invariants . privateStateExposed ) "
2026-06-18 15:24:47 +01:00
} elseif ( $Mode -eq " tool-invoke " ) {
2026-06-18 18:15:50 +01:00
$invocationRows = " none "
if ( $null -ne $result . invocationRows -and $result . invocationRows . Count -gt 0 ) {
$invocationRows = ( $result . invocationRows -join " ; " )
}
2026-06-19 01:40:02 +01:00
$serviceHealth = " none "
if ( $null -ne $result . serviceHealthReadback -and $null -ne $result . serviceHealthReadback . status ) {
2026-06-19 03:44:07 +01:00
$serviceHealth = " status= $( $result . serviceHealthReadback . status ) :owner= $( $result . serviceHealthReadback . lifecycleOwner ) :hostedBody= $( $result . serviceHealthReadback . hostedBody ) :preflight= $( $result . serviceHealthReadback . onlinePreflightStatus ) :childRunbooks= $( $result . serviceHealthReadback . onlinePreflightChildRunbookCount ) :present= $( $result . serviceHealthReadback . onlinePreflightPresentCount ) :hashVerified= $( $result . serviceHealthReadback . onlinePreflightHashVerifiedCount ) :missingArtifacts= $( $result . serviceHealthReadback . onlinePreflightMissingArtifactCount ) :attentionRows= $( @ ( $result . serviceHealthReadback . serviceLifecycleAttentionRows ) . Count ) :actionRows= $( @ ( $result . serviceHealthReadback . serviceActionRows ) . Count ) :failedChecks= $( $result . serviceHealthReadback . serviceExecutionFailedCheckCount ) :missingChecks= $( $result . serviceHealthReadback . serviceExecutionMissingCheckCount ) :private= $( $result . serviceHealthReadback . privateStateExposed ) "
2026-06-19 01:40:02 +01:00
}
2026-06-19 03:27:53 +01:00
$swarmOnlineRunbook = " none "
if ( $null -ne $result . swarmOnlineRunbookReadback -and $null -ne $result . swarmOnlineRunbookReadback . status ) {
2026-06-19 03:44:07 +01:00
$swarmOnlineRunbook = " status= $( $result . swarmOnlineRunbookReadback . status ) :owner= $( $result . swarmOnlineRunbookReadback . lifecycleOwner ) :hostedBody= $( $result . swarmOnlineRunbookReadback . hostedBody ) :childRunbooks= $( $result . swarmOnlineRunbookReadback . childRunbookCount ) :present= $( $result . swarmOnlineRunbookReadback . childArtifactPresentCount ) :hashVerified= $( $result . swarmOnlineRunbookReadback . childArtifactHashVerifiedCount ) :missingArtifacts= $( $result . swarmOnlineRunbookReadback . childArtifactMissingCount ) :failedChecks= $( $result . swarmOnlineRunbookReadback . serviceExecutionFailedCheckCount ) :missingChecks= $( $result . swarmOnlineRunbookReadback . serviceExecutionMissingCheckCount ) :operatorRequired= $( $result . swarmOnlineRunbookReadback . elevatedExecutionRequiresOperator ) :private= $( $result . swarmOnlineRunbookReadback . privateStateExposed ) "
2026-06-19 03:27:53 +01:00
}
2026-06-19 03:56:19 +01:00
$servicePolicyDirectory = " none "
if ( $null -ne $result . servicePolicyDirectoryReadback -and $null -ne $result . servicePolicyDirectoryReadback . status ) {
$servicePolicyDirectory = " status= $( $result . servicePolicyDirectoryReadback . status ) :owner= $( $result . servicePolicyDirectoryReadback . lifecycleOwner ) :hostedBody= $( $result . servicePolicyDirectoryReadback . hostedBody ) :daemons= $( $result . servicePolicyDirectoryReadback . daemonCount ) :covered= $( $result . servicePolicyDirectoryReadback . coveredCount ) :enabled= $( $result . servicePolicyDirectoryReadback . enabledCount ) :disabled= $( $result . servicePolicyDirectoryReadback . disabledCount ) :missing= $( $result . servicePolicyDirectoryReadback . missingCount ) :attention= $( $result . servicePolicyDirectoryReadback . attentionCount ) :tick= $( $result . servicePolicyDirectoryReadback . wrapperTick ) :private= $( $result . servicePolicyDirectoryReadback . privateStateExposed ) "
}
2026-06-19 01:59:53 +01:00
$daemonStatus = " none "
if ( $null -ne $result . daemonStatusReadback -and $null -ne $result . daemonStatusReadback . status ) {
$daemonStatus = " status= $( $result . daemonStatusReadback . status ) :cluster= $( $result . daemonStatusReadback . clusterId ) :daemon= $( $result . daemonStatusReadback . daemonId ) :surface= $( $result . daemonStatusReadback . eveSurfaceId ) :tools= $( $result . daemonStatusReadback . hostedToolCount ) :private= $( $result . daemonStatusReadback . privateStateExposed ) "
}
2026-06-19 02:07:43 +01:00
$eveConnection = " none "
if ( $null -ne $result . eveConnectionReadback -and $null -ne $result . eveConnectionReadback . targetClusterId ) {
2026-06-20 01:38:31 +01:00
$repoWorkQueueRows = " none "
if ( $null -ne $result . eveConnectionReadback . repoWorkQueueTuiRows -and $result . eveConnectionReadback . repoWorkQueueTuiRows . Count -gt 0 ) {
$repoWorkQueueRows = ( $result . eveConnectionReadback . repoWorkQueueTuiRows -join " ; " )
}
$eveConnection = " target= $( $result . eveConnectionReadback . targetClusterId ) :surface= $( $result . eveConnectionReadback . targetEveSurfaceId ) :publicDiscussion= $( $result . eveConnectionReadback . publicPersonaDiscussionAllowed ) :actions= $( @ ( $result . eveConnectionReadback . supportedActions ) . Count ) :repoWorkQueue= $( $result . eveConnectionReadback . repoWorkQueueCount ) :repoWorkRows= $repoWorkQueueRows :private= $( $result . eveConnectionReadback . privateStateExposed ) "
2026-06-19 02:07:43 +01:00
}
2026-06-19 02:18:38 +01:00
$authorityTool = " none "
if ( $null -ne $result . authorityToolReadback -and $null -ne $result . authorityToolReadback . authorityGate ) {
$authorityTool = " gate= $( $result . authorityToolReadback . authorityGate ) :input= $( $result . authorityToolReadback . inputContractType ) :receipt= $( $result . authorityToolReadback . receiptContractType ) :host= $( $result . authorityToolReadback . hostClusterId ) :private= $( $result . authorityToolReadback . privateStateExposed ) "
}
2026-06-19 03:56:19 +01:00
Write-Host " Tool invoke: status= $( $result . status ) , requester= $( $result . requestingDisplayName ) , host= $( $result . hostDisplayName ) , tool= $( $result . toolName ) , receipt= $( $result . receiptId ) , daemonStatus= $daemonStatus , eveConnection= $eveConnection , authorityTool= $authorityTool , serviceHealth= $serviceHealth , swarmOnlineRunbook= $swarmOnlineRunbook , servicePolicyDirectory= $servicePolicyDirectory , invocationRows= $invocationRows , privateStateExposed= $( $result . privateStateExposed ) "
2026-06-19 00:28:48 +01:00
} elseif ( $Mode -eq " swarm-overview " -or $Mode -eq " gjallar " ) {
2026-06-18 15:24:47 +01:00
$attention = " none "
if ( $null -ne $result . attentionDaemonIds -and $result . attentionDaemonIds . Count -gt 0 ) {
$attention = ( $result . attentionDaemonIds -join " , " )
}
$toolHostAttention = " none "
if ( $null -ne $result . toolHostAttentionRows -and $result . toolHostAttentionRows . Count -gt 0 ) {
$toolHostAttention = ( ( $result . toolHostAttentionRows | ForEach-Object {
" $( $_ . hostDaemonId ) : $( $_ . capabilityId ) : $( $_ . hostStatus ) "
} ) -join " ; " )
}
$serviceLifecycleAttention = " none "
if ( $null -ne $result . serviceLifecycleAttentionRows -and $result . serviceLifecycleAttentionRows . Count -gt 0 ) {
$serviceLifecycleAttention = ( ( $result . serviceLifecycleAttentionRows | ForEach-Object {
$artifactStatus = $_ . artifactStatus
if ( $null -eq $artifactStatus -or $artifactStatus -eq " " ) {
$artifactStatus = " unknown "
}
" $( $_ . family ) : $( $_ . route ) : $( $_ . status ) :artifactStatus= ${artifactStatus} "
} ) -join " ; " )
}
$actionQueue = " none "
if ( $null -ne $result . swarmActionRows -and $result . swarmActionRows . Count -gt 0 ) {
$actionQueue = ( ( $result . swarmActionRows | ForEach-Object {
$artifact = $_ . operatorArtifactRef
if ( $null -eq $artifact -or $artifact -eq " " ) {
$artifact = " none "
}
$artifactStatus = $_ . operatorArtifactStatus
if ( $null -eq $artifactStatus -or $artifactStatus -eq " " ) {
$artifactStatus = " unknown "
}
2026-06-18 16:41:03 +01:00
$artifactSha256 = $_ . operatorArtifactSha256
if ( $null -eq $artifactSha256 -or $artifactSha256 -eq " " ) {
$artifactSha256 = " none "
}
2026-06-18 15:24:47 +01:00
$audit = $_ . completionAuditWrapperMode
if ( $null -eq $audit -or $audit -eq " " ) {
$audit = " none "
}
2026-06-18 16:31:10 +01:00
$aftercare = $_ . operatorAftercareCommand
if ( $null -eq $aftercare -or $aftercare -eq " " ) {
$aftercare = " none "
}
2026-06-18 17:47:07 +01:00
$command = $_ . wrapperCommand
if ( $null -eq $command -or $command -eq " " ) {
$command = " none "
}
2026-06-18 23:57:18 +01:00
$executionCommand = $_ . operatorArtifactExecutionCommand
if ( $null -eq $executionCommand -or $executionCommand -eq " " ) {
$executionCommand = " none "
}
2026-06-18 22:07:14 +01:00
$failedChecks = $_ . serviceExecutionFailedCheckCount
if ( $null -eq $failedChecks ) {
$failedChecks = 0
}
$missingChecks = $_ . serviceExecutionMissingCheckCount
if ( $null -eq $missingChecks ) {
$missingChecks = 0
}
2026-06-18 22:20:58 +01:00
$serviceId = $_ . serviceId
if ( $null -eq $serviceId -or $serviceId -eq " " ) {
$serviceId = " none "
}
$serviceRoute = $_ . serviceRoute
if ( $null -eq $serviceRoute -or $serviceRoute -eq " " ) {
$serviceRoute = " none "
}
2026-06-19 00:47:48 +01:00
$owner = $_ . lifecycleOwner
if ( $null -eq $owner -or $owner -eq " " ) {
$owner = " none "
}
$hostedBody = $_ . hostedBody
if ( $null -eq $hostedBody -or $hostedBody -eq " " ) {
$hostedBody = " none "
}
" $( $_ . priority ) : $( $_ . family ) : $( $_ . wrapperMode ) : $( $_ . status ) :owner= ${owner} :hostedBody= ${hostedBody} :service= ${serviceId} :route= ${serviceRoute} :command= ${command} :mutates= $( $_ . mutatesState ) :elevated= $( $_ . requiresElevatedAuthority ) :failedChecks= ${failedChecks} :missingChecks= ${missingChecks} :artifactStatus= ${artifactStatus} :sha256= ${artifactSha256} :exec= ${executionCommand} :audit= ${audit} :aftercare= ${aftercare} :artifact= $artifact "
2026-06-18 15:24:47 +01:00
} ) -join " ; " )
}
2026-06-18 17:12:52 +01:00
$serviceExecutionFailedChecks = Format-ServiceExecutionFailedChecks $result . serviceExecutionFailedCheckRows
2026-06-18 21:08:02 +01:00
$actionRows = Format-TuiRows $result . swarmActionTuiRows
$toolAttentionRows = Format-TuiRows $result . toolHostAttentionTuiRows
$serviceAttentionRows = Format-TuiRows $result . serviceLifecycleAttentionTuiRows
$serviceFailedCheckRows = Format-TuiRows $result . serviceExecutionFailedCheckTuiRows
$daemonRows = Format-TuiRows $result . daemonTuiRows
$toolRows = Format-TuiRows $result . toolTuiRows
$policyRows = Format-TuiRows $result . policyTuiRows
2026-06-21 00:50:39 +01:00
$repoWorkMapRows = Format-TuiRows $result . repoWorkMapTuiRows
$repoWorkSemanticRows = Format-TuiRows $result . repoWorkMapSemanticTuiRows
$repoWorkFamilyLensRows = Format-TuiRows $result . repoWorkMapFamilyLensTuiRows
$repoWorkPathLensRows = Format-TuiRows $result . repoWorkMapPathLensTuiRows
$repoWorkBranchLensRows = Format-TuiRows $result . repoWorkMapBranchLensTuiRows
$repoWorkStageLensRows = Format-TuiRows $result . repoWorkMapStageLensTuiRows
$repoWorkGateLensRows = Format-TuiRows $result . repoWorkMapGateLensTuiRows
2026-06-21 09:01:48 +01:00
$repoWorkClosureRows = Format-TuiRows $result . repoWorkMapClosureTuiRows
2026-06-21 09:27:13 +01:00
$repoWorkAcceptanceRows = Format-TuiRows $result . repoWorkMapAcceptanceTuiRows
2026-06-21 00:50:39 +01:00
$repoWorkOverviewRows = Format-TuiRows $result . repoWorkOverviewTuiRows
$repoWorkPublicProofRows = Format-TuiRows $result . repoWorkPublicProofTuiRows
2026-06-21 10:56:33 +01:00
$repoWorkReadinessRows = Format-TuiRows $result . repoWorkReadinessTuiRows
2026-06-21 12:41:58 +01:00
$repoWorkReadinessReviewRows = Format-TuiRows $result . repoWorkReadinessReviewTuiRows
2026-06-19 03:35:44 +01:00
$swarmOnlineTool = " none "
if ( $null -ne $result . commands -and $null -ne $result . commands . wrapperInvokeSwarmOnlineRunbookTool ) {
$swarmOnlineTool = $result . commands . wrapperInvokeSwarmOnlineRunbookTool
}
2026-06-19 00:28:48 +01:00
$overviewLabel = " Swarm overview "
if ( $Mode -eq " gjallar " ) {
$overviewLabel = " Gjallar "
}
2026-06-21 12:41:58 +01:00
Write-Host " ${overviewLabel} : status= $( $result . status ) , liveness= $( $result . livenessStatus ) , recovery= $( $result . recoveryStatus ) , agents= $( $result . agentCount ) , clusters= $( $result . clusterCount ) , privateVerses= $( $result . privateVerseCount ) , surfaces= $( $result . surfaceCount ) , tools= $( $result . toolCount ) , nonReady= $( $result . nonReadyDaemonCount ) , policyMissing= $( $result . policyMissingCount ) , recommended= $( $result . recommendedWrapperMode ) , serviceRecommended= $( $result . serviceLifecycleRecommendedWrapperMode ) , swarmOnlineTool= $swarmOnlineTool , actionQueue= $actionQueue , actionRows= $actionRows , attention= $attention , daemonRows= $daemonRows , toolRows= $toolRows , policyRows= $policyRows , repoWorkMapRows= $repoWorkMapRows , repoWorkSemanticRows= $repoWorkSemanticRows , repoWorkFamilyLensRows= $repoWorkFamilyLensRows , repoWorkPathLensRows= $repoWorkPathLensRows , repoWorkBranchLensRows= $repoWorkBranchLensRows , repoWorkStageLensRows= $repoWorkStageLensRows , repoWorkGateLensRows= $repoWorkGateLensRows , repoWorkClosureRows= $repoWorkClosureRows , repoWorkAcceptanceRows= $repoWorkAcceptanceRows , repoWorkOverviewRows= $repoWorkOverviewRows , repoWorkPublicProofRows= $repoWorkPublicProofRows , repoWorkReadinessRows= $repoWorkReadinessRows , repoWorkReadinessReviewRows= $repoWorkReadinessReviewRows , toolHostAttention= $toolHostAttention , toolAttentionRows= $toolAttentionRows , serviceLifecycleAttention= $serviceLifecycleAttention , serviceAttentionRows= $serviceAttentionRows , serviceExecutionFailedChecks= $serviceExecutionFailedChecks , serviceFailedCheckRows= $serviceFailedCheckRows , privateStateExposed= $( $result . privateStateExposed ) "
2026-06-20 02:28:59 +01:00
} elseif ( $Mode -eq " repo-persona-intake " ) {
$feedbackId = " none "
$consensusReceiptId = " none "
$candidateActions = " none "
if ( $null -ne $result . feedback ) {
$feedbackId = $result . feedback . feedbackId
$consensusReceiptId = $result . feedback . consensusReceiptId
if ( $null -ne $result . feedback . candidateActionRefs -and @ ( $result . feedback . candidateActionRefs ) . Count -gt 0 ) {
$candidateActions = ( @ ( $result . feedback . candidateActionRefs ) -join " ; " )
}
}
Write-Host " Repo Persona intake: status= $( $result . status ) , item= $( $result . item ) , speechAudit= $( $result . speechAuditId ) , accept= $( $result . acceptReceiptPath ) , feedback= $feedbackId , consensus= $consensusReceiptId , candidateActions= $candidateActions , next= $( $result . nextSafeMove ) , privateStateExposed= $( $result . privateStateExposed ) "
2026-06-20 02:49:29 +01:00
} elseif ( $Mode -eq " repo-swarm-run " ) {
$pulseRows = " none "
if ( $null -ne $result . iterations -and @ ( $result . iterations ) . Count -gt 0 ) {
$pulseRows = ( ( @ ( $result . iterations ) | ForEach-Object {
$items = " none "
if ( $null -ne $_ . outputs -and @ ( $_ . outputs ) . Count -gt 0 ) {
$items = ( ( @ ( $_ . outputs ) | ForEach-Object {
" $( $_ . item ) :gateBefore= $( $_ . gateBefore ) :tick= $( $_ . tick . status ) / $( $_ . tick . action ) "
} ) -join " , " )
}
" $( $_ . pulse ) : $( $_ . queueRunStatus ) :actionable= $( $_ . actionableCount ) :items= $items "
} ) -join " ; " )
}
Write-Host " Repo swarm run: status= $( $result . status ) , stop= $( $result . stopReason ) , iterations= $( $result . iterationCount ) , until= $RepoSwarmUntil , maxIterations= $RepoSwarmMaxIterations , maxItems= $RepoWorkMaxItems , pulses= $pulseRows , next= $( $result . nextSafeMove ) , privateStateExposed= $( $result . privateStateExposed ) "
2026-06-20 01:51:45 +01:00
} elseif ( $Mode -eq " repo-work-queue-run " ) {
$selectedRows = Format-TuiRows $result . selectedRows
$tickRows = " none "
if ( $null -ne $result . outputs -and @ ( $result . outputs ) . Count -gt 0 ) {
$tickRows = ( ( @ ( $result . outputs ) | ForEach-Object {
" $( $_ . item ) :gateBefore= $( $_ . gateBefore ) :tick= $( $_ . tick . status ) / $( $_ . tick . action ) :next= $( $_ . tick . nextSafeMove ) "
} ) -join " ; " )
}
Write-Host " Repo work queue run: status= $( $result . status ) , queue= $( $result . queueCount ) , actionable= $( $result . actionableCount ) , maxItems= $( $result . maxItems ) , dryRun= $( $result . dryRun ) , selectedRows= $selectedRows , tickRows= $tickRows , privateStateExposed= $( $result . privateStateExposed ) "
2026-06-21 19:10:42 +01:00
} elseif ( $Mode -eq " repo-work-public-proof " ) {
$changedPaths = " none "
if ( $null -ne $result . publicProofBundle -and $null -ne $result . publicProofBundle . changedPaths -and @ ( $result . publicProofBundle . changedPaths ) . Count -gt 0 ) {
$changedPaths = ( @ ( $result . publicProofBundle . changedPaths ) -join " , " )
}
$artifactRows = 0
if ( $null -ne $result . publicProofBundle -and $null -ne $result . publicProofBundle . artifactRows ) {
$artifactRows = @ ( $result . publicProofBundle . artifactRows ) . Count
}
$publicationRows = 0
if ( $null -ne $result . publicProofBundle -and $null -ne $result . publicProofBundle . publicationRows ) {
$publicationRows = @ ( $result . publicProofBundle . publicationRows ) . Count
}
$publicProofId = " none "
if ( $null -ne $result . verseProjection -and $null -ne $result . verseProjection . publicProofId ) {
$publicProofId = $result . verseProjection . publicProofId
}
Write-Host " Repo work public proof: status= $( $result . status ) , item= $( $result . item ) , proof= $publicProofId , branch= $( $result . publicProofBundle . branch ) , commit= $( $result . publicProofBundle . commitSha ) , paths= $changedPaths , gate= $( $result . publicProofBundle . currentGate ) , blocker= $( $result . publicProofBundle . blocker ) , artifacts= $artifactRows , publicationRows= $publicationRows , sha256= $( $result . outputSha256 ) , path= $( $result . outputPath ) , privateStateExposed= $( $result . privateStateExposed ) "
2026-06-21 10:56:33 +01:00
} elseif ( $Mode -eq " repo-work-readiness " ) {
$readinessRows = " none "
if ( $null -ne $result . rows -and @ ( $result . rows ) . Count -gt 0 ) {
$readinessRows = ( ( @ ( $result . rows ) | ForEach-Object {
$kind = $_ . kind
if ( $null -eq $kind -or $kind -eq " " ) {
$kind = " unknown "
}
$owner = $_ . owner
if ( $null -eq $owner -or $owner -eq " " ) {
$owner = " unknown "
}
$status = $_ . status
if ( $null -eq $status -or $status -eq " " ) {
$status = " unknown "
}
$schema = $_ . requiredSchema
if ( $null -eq $schema -or $schema -eq " " ) {
$schema = " unknown "
}
" ${kind} : ${status} :owner= ${owner} :satisfied= $( $_ . satisfied ) :schema= ${schema} "
} ) -join " ; " )
}
$missingKinds = " none "
if ( $null -ne $result . rows -and @ ( $result . rows ) . Count -gt 0 ) {
$missingKinds = ( ( @ ( $result . rows ) | Where-Object { $_ . satisfied -ne $true } | ForEach-Object { $_ . kind } ) -join " , " )
if ( $missingKinds -eq " " ) {
$missingKinds = " none "
}
}
$verseProjection = " none "
if ( $null -ne $result . verseProjection -and $null -ne $result . verseProjection . readinessId ) {
$verseProjection = " $( $result . verseProjection . readinessId ) : $( $result . verseProjection . latestKey ) "
}
Write-Host " Repo work readiness: status= $( $result . status ) , item= $( $result . item ) , missing= $( $result . missingRequiredCount ) , missingKinds= $missingKinds , receipt= $( $result . receiptPath ) , verseProjection= $verseProjection , rows= $readinessRows , sightOnly= $( $result . authority . sightOnly ) , readinessApprovalAuthorized= $( $result . authority . readinessApprovalAuthorized ) , publicationAuthorized= $( $result . authority . publicationAuthorized ) , serviceLifecycleAuthority= $( $result . authority . serviceLifecycleAuthority ) , handsActionAuthorized= $( $result . authority . handsActionAuthorized ) , next= $( $result . nextSafeMove ) , privateStateExposed= $( $result . privateStateExposed ) "
2026-06-21 12:20:28 +01:00
} elseif ( $Mode -eq " repo-work-readiness-review " ) {
Write-Host " Repo work readiness review: status= $( $result . status ) , item= $( $result . item ) , review= $( $result . reviewId ) , missing= $( $result . missingRequiredCount ) , satisfied= $( $result . satisfiedRowCount ) , receipt= $( $result . receiptPath ) , readiness= $( $result . readinessReceiptPath ) , readinessApprovalAuthorized= $( $result . authority . readinessApprovalAuthorized ) , durableStateCommitAuthorized= $( $result . authority . durableStateCommitAuthorized ) , publicationAuthorized= $( $result . authority . publicationAuthorized ) , mergeAuthorized= $( $result . authority . mergeAuthorized ) , serviceLifecycleAuthority= $( $result . authority . serviceLifecycleAuthority ) , handsActionAuthorized= $( $result . authority . handsActionAuthorized ) , next= $( $result . nextSafeMove ) , privateStateExposed= $( $result . privateStateExposed ) "
2026-06-21 11:05:46 +01:00
} elseif ( $Mode -eq " repo-deployment-config-audit " ) {
$failed = " none "
if ( $null -ne $result . assertions -and @ ( $result . assertions ) . Count -gt 0 ) {
$failed = ( ( @ ( $result . assertions ) | Where-Object { $_ . passed -ne $true } | ForEach-Object { $_ . id } ) -join " , " )
if ( $failed -eq " " ) {
$failed = " none "
}
}
Write-Host " Repo deployment config audit: status= $( $result . status ) , readyForIdunnReview= $( $result . readyForIdunnReview ) , daemonOwnsExecution= $( $result . daemonOwnsExecution ) , failed= $failed , receipt= $( $result . receiptPath ) , executionAuthorized= $( $result . executionAuthorized ) , deploymentAuthority= $( $result . deploymentAuthority ) , gitPushAuthority= $( $result . gitPushAuthority ) , serviceLifecycleAuthority= $( $result . serviceLifecycleAuthority ) , nextGate= $( $result . nextGate ) , privateStateExposed= $( $result . privateStateExposed ) "
} elseif ( $Mode -eq " repo-deployment-runbook " ) {
$artifactSha256 = Get-LocalArtifactSha256 $result . runbookPath
if ( $artifactSha256 -eq " none " -and $null -ne $result . runbookSha256 -and $result . runbookSha256 -ne " " ) {
$artifactSha256 = $result . runbookSha256
}
Write-Host " Repo deployment runbook: status= $( $result . status ) , runbookWritten= $( $result . runbookWritten ) , remote= $( $result . remote ) , watchedRef= $( $result . watchedRef ) , gitPush=' $( $result . gitPushCommand ) ', operatorCommand= $( $result . operatorExecutionCommand ) , artifactSha256= $artifactSha256 , mutatesRemoteWhenRun= $( $result . mutatesRemoteWhenRun ) , requiresExplicitOperatorAuthority= $( $result . requiresExplicitOperatorAuthority ) , executionAuthorized= $( $result . executionAuthorized ) , deploymentAuthority= $( $result . deploymentAuthority ) , gitPushAuthority= $( $result . gitPushAuthority ) , serviceLifecycleAuthority= $( $result . serviceLifecycleAuthority ) , path= $( $result . runbookPath ) , privateStateExposed= $( $result . privateStateExposed ) "
} elseif ( $Mode -eq " repo-deployment-aftercare-audit " ) {
$failed = " none "
if ( $null -ne $result . assertions -and @ ( $result . assertions ) . Count -gt 0 ) {
$failed = ( ( @ ( $result . assertions ) | Where-Object { $_ . passed -ne $true } | ForEach-Object { $_ . id } ) -join " , " )
if ( $failed -eq " " ) {
$failed = " none "
}
}
$idunnDeployment = " none "
if ( $null -ne $result . idunnDeploymentReceipt -and $null -ne $result . idunnDeploymentReceipt . receiptId ) {
$idunnDeployment = " $( $result . idunnDeploymentReceipt . receiptId ) : $( $result . idunnDeploymentReceipt . status ) "
}
$idunnAftercare = " none "
if ( $null -ne $result . idunnAftercareAuditReceipt -and $null -ne $result . idunnAftercareAuditReceipt . receiptId ) {
$idunnAftercare = " $( $result . idunnAftercareAuditReceipt . receiptId ) : $( $result . idunnAftercareAuditReceipt . status ) "
}
Write-Host " Repo deployment aftercare audit: status= $( $result . status ) , deploymentComplete= $( $result . deploymentComplete ) , failed= $failed , idunnDeployment= $idunnDeployment , idunnAftercare= $idunnAftercare , localVerseStore= $( $result . localVerseStore ) , runtimeId= $( $result . runtimeId ) , receipt= $( $result . receiptPath ) , executionAuthorized= $( $result . executionAuthorized ) , deploymentAuthority= $( $result . deploymentAuthority ) , gitPushAuthority= $( $result . gitPushAuthority ) , serviceLifecycleAuthority= $( $result . serviceLifecycleAuthority ) , privateStateExposed= $( $result . privateStateExposed ) "
2026-06-20 02:17:09 +01:00
} elseif ( $Mode -eq " repo-work-service-plan " ) {
$plannedArgs = " none "
if ( $null -ne $result . args -and $result . args . Count -gt 0 ) {
$plannedArgs = ( $result . args -join " " )
}
Write-Host " Repo work service plan: service= $( $result . serviceId ) , status= $( $result . status ) , receipt= $( $result . receiptId ) , command= $( $result . command ) , args= $plannedArgs , owner=Idunn, hostedBody=repo-work, followUp=tools/epiphany_local_run.ps1 -Mode repo-work-service-runbook, aftercare=tools/epiphany_local_run.ps1 -Mode repo-work-queue-run -RepoWorkDryRun, privateStateExposed= $( $result . privateStateExposed ) "
} elseif ( $Mode -eq " repo-work-service-runbook " ) {
$artifactSha256 = Get-LocalArtifactSha256 $result . runbookPath
$plannedArgs = " none "
if ( $null -ne $result . args -and $result . args . Count -gt 0 ) {
$plannedArgs = ( $result . args -join " " )
}
Write-Host " Repo work service runbook: service= $( $result . serviceId ) , status= $( $result . status ) , receipt= $( $result . receiptId ) , command= $( $result . command ) , args= $plannedArgs , owner=Idunn, hostedBody=repo-work, artifactSha256= $artifactSha256 , elevatedRequired=false, aftercare=tools/epiphany_local_run.ps1 -Mode repo-work-queue-run -RepoWorkDryRun, path= $( $result . runbookPath ) , privateStateExposed= $( $result . privateStateExposed ) "
2026-06-21 01:31:05 +01:00
} elseif ( $Mode -eq " repo-work-service-launch " ) {
Write-Host " Repo work service launch: service= $( $result . serviceId ) , status= $( $result . status ) , processId= $( $result . processId ) , exitCode= $( $result . exitCode ) , receipt= $( $result . receiptId ) , owner=Idunn, hostedBody=repo-work, waitChild=true, serviceManagerMutation=false, aftercare=tools/epiphany_local_run.ps1 -Mode repo-work-queue-run -RepoWorkDryRun, privateStateExposed= $( $result . privateStateExposed ) "
2026-06-21 01:49:47 +01:00
} elseif ( $Mode -eq " repo-work-service-audit " ) {
$missing = " none "
if ( $null -ne $result . missingChecks -and @ ( $result . missingChecks ) . Count -gt 0 ) {
$missing = ( @ ( $result . missingChecks ) -join " , " )
}
$failed = " none "
if ( $null -ne $result . failedChecks -and @ ( $result . failedChecks ) . Count -gt 0 ) {
$failed = ( @ ( $result . failedChecks ) -join " , " )
}
Write-Host " Repo work service audit: service= $( $result . serviceId ) , status= $( $result . status ) , receipt= $( $result . receiptId ) , plan= $( $result . planStatus ) , runbook= $( $result . runbookStatus ) , runbookArtifact= $( $result . runbookArtifactStatus ) , launch= $( $result . launchStatus ) , exitCode= $( $result . launchExitCode ) , missing= $missing , failed= $failed , owner=Idunn, hostedBody=repo-work, serviceManagerMutation=false, nextSafeMove= $( $result . nextSafeMove ) , privateStateExposed= $( $result . privateStateExposed ) "
2026-06-19 00:02:27 +01:00
} elseif ( $Mode -eq " swarm-online-runbook " ) {
$aftercare = " none "
if ( $null -ne $result . aftercareCommands -and $result . aftercareCommands . Count -gt 0 ) {
$aftercare = ( $result . aftercareCommands -join " ; " )
}
2026-06-19 01:32:47 +01:00
$childRows = 0
if ( $null -ne $result . childRunbookRows ) {
$childRows = @ ( $result . childRunbookRows ) . Count
}
$aftercareRows = 0
if ( $null -ne $result . aftercareRows ) {
$aftercareRows = @ ( $result . aftercareRows ) . Count
}
2026-06-19 02:58:51 +01:00
Write-Host " Swarm online runbook: status= $( $result . status ) , preflight= $( $result . preflightStatus ) , owner= $( $result . lifecycleOwner ) , hostedBody= $( $result . hostedBody ) , commands= $( $result . commandCount ) , childRows= $childRows , present= $( $result . childArtifactPresentCount ) , hashVerified= $( $result . childArtifactHashVerifiedCount ) , hashMismatch= $( $result . childArtifactMismatchCount ) , missingArtifacts= $( $result . childArtifactMissingCount ) , failedChecks= $( $result . serviceExecutionFailedCheckCount ) , missingChecks= $( $result . serviceExecutionMissingCheckCount ) , aftercareRows= $aftercareRows , artifactSha256= $( $result . artifactSha256 ) , elevatedCommand= $( $result . elevatedCommand ) , verifiesChildArtifactSha256= $( $result . verifiesChildArtifactSha256 ) , usesExplicitAftercareArguments= $( $result . usesExplicitAftercareArguments ) , aftercare= $aftercare , path= $( $result . runbookPath ) , privateStateExposed= $( $result . privateStateExposed ) "
2026-06-18 15:24:47 +01:00
} elseif ( $Mode -eq " service-policy-directory " ) {
2026-06-18 17:51:39 +01:00
$policyRows = " none "
2026-06-18 21:33:10 +01:00
if ( $null -ne $result . tuiRows -and $result . tuiRows . Count -gt 0 ) {
$policyRows = Format-TuiRows $result . tuiRows
2026-06-18 17:51:39 +01:00
}
2026-06-19 00:39:21 +01:00
Write-Host " Service policy directory: status= $( $result . status ) , owner= $( $result . lifecycleOwner ) , hostedBody= $( $result . hostedBody ) , daemons= $( $result . daemonCount ) , covered= $( $result . coveredCount ) , enabled= $( $result . enabledCount ) , disabled= $( $result . disabledCount ) , missing= $( $result . missingCount ) , attention= $( $result . attentionCount ) , policyRows= $policyRows , privateStateExposed= $( $result . privateStateExposed ) "
2026-06-18 23:32:53 +01:00
} elseif ( $Mode -eq " service-plan " ) {
$plannedArgs = " none "
if ( $null -ne $result . args -and $result . args . Count -gt 0 ) {
$plannedArgs = ( $result . args -join " " )
}
Write-Host " Service plan: service= $( $result . serviceId ) , status= $( $result . status ) , receipt= $( $result . receiptId ) , command= $( $result . command ) , args= $plannedArgs , followUp=tools/epiphany_local_run.ps1 -Mode service-runbook, aftercare=tools/epiphany_local_run.ps1 -Mode service-status, privateStateExposed= $( $result . privateStateExposed ) "
} elseif ( $Mode -eq " service-launch " ) {
Write-Host " Service launch: service= $( $result . serviceId ) , status= $( $result . status ) , processId= $( $result . processId ) , exitCode= $( $result . exitCode ) , receipt= $( $result . receiptId ) , followUp=tools/epiphany_local_run.ps1 -Mode service-status, aftercare=tools/epiphany_local_run.ps1 -Mode service-tick, privateStateExposed= $( $result . privateStateExposed ) "
2026-06-18 15:24:47 +01:00
} elseif ( $Mode -eq " swarm-poke-down " ) {
2026-06-18 18:07:29 +01:00
$pokeRows = " none "
if ( $null -ne $result . pokeRows -and $result . pokeRows . Count -gt 0 ) {
$pokeRows = ( $result . pokeRows -join " ; " )
}
Write-Host " Swarm poke down: status= $( $result . status ) , observed= $( $result . observedDaemonCount ) , poked= $( $result . pokedDaemonCount ) , pokeRows= $pokeRows , privateStateExposed= $( $result . privateStateExposed ) "
2026-06-18 15:24:47 +01:00
} elseif ( $Mode -eq " swarm-triage " ) {
$attention = " none "
if ( $null -ne $result . attentionDaemonIds -and $result . attentionDaemonIds . Count -gt 0 ) {
$attention = ( $result . attentionDaemonIds -join " , " )
}
$toolHostAttention = " none "
if ( $null -ne $result . toolHostAttentionRows -and $result . toolHostAttentionRows . Count -gt 0 ) {
$toolHostAttention = ( ( $result . toolHostAttentionRows | ForEach-Object {
" $( $_ . hostDaemonId ) : $( $_ . capabilityId ) : $( $_ . hostStatus ) "
} ) -join " ; " )
}
$serviceLifecycleAttention = " none "
if ( $null -ne $result . serviceLifecycleAttentionRows -and $result . serviceLifecycleAttentionRows . Count -gt 0 ) {
$serviceLifecycleAttention = ( ( $result . serviceLifecycleAttentionRows | ForEach-Object {
$artifactStatus = $_ . artifactStatus
if ( $null -eq $artifactStatus -or $artifactStatus -eq " " ) {
$artifactStatus = " unknown "
}
" $( $_ . family ) : $( $_ . route ) : $( $_ . status ) :artifactStatus= ${artifactStatus} "
} ) -join " ; " )
}
$actionQueue = " none "
if ( $null -ne $result . swarmActionRows -and $result . swarmActionRows . Count -gt 0 ) {
$actionQueue = ( ( $result . swarmActionRows | ForEach-Object {
$artifact = $_ . operatorArtifactRef
if ( $null -eq $artifact -or $artifact -eq " " ) {
$artifact = " none "
}
$artifactStatus = $_ . operatorArtifactStatus
if ( $null -eq $artifactStatus -or $artifactStatus -eq " " ) {
$artifactStatus = " unknown "
}
2026-06-18 16:41:03 +01:00
$artifactSha256 = $_ . operatorArtifactSha256
if ( $null -eq $artifactSha256 -or $artifactSha256 -eq " " ) {
$artifactSha256 = " none "
}
2026-06-18 15:24:47 +01:00
$audit = $_ . completionAuditWrapperMode
if ( $null -eq $audit -or $audit -eq " " ) {
$audit = " none "
}
2026-06-18 16:31:10 +01:00
$aftercare = $_ . operatorAftercareCommand
if ( $null -eq $aftercare -or $aftercare -eq " " ) {
$aftercare = " none "
}
2026-06-18 17:47:07 +01:00
$command = $_ . wrapperCommand
if ( $null -eq $command -or $command -eq " " ) {
$command = " none "
}
2026-06-18 22:07:14 +01:00
$failedChecks = $_ . serviceExecutionFailedCheckCount
if ( $null -eq $failedChecks ) {
$failedChecks = 0
}
$missingChecks = $_ . serviceExecutionMissingCheckCount
if ( $null -eq $missingChecks ) {
$missingChecks = 0
}
2026-06-18 22:20:58 +01:00
$serviceId = $_ . serviceId
if ( $null -eq $serviceId -or $serviceId -eq " " ) {
$serviceId = " none "
}
$serviceRoute = $_ . serviceRoute
if ( $null -eq $serviceRoute -or $serviceRoute -eq " " ) {
$serviceRoute = " none "
}
2026-06-19 00:47:48 +01:00
$owner = $_ . lifecycleOwner
if ( $null -eq $owner -or $owner -eq " " ) {
$owner = " none "
}
$hostedBody = $_ . hostedBody
if ( $null -eq $hostedBody -or $hostedBody -eq " " ) {
$hostedBody = " none "
}
" $( $_ . priority ) : $( $_ . family ) : $( $_ . wrapperMode ) : $( $_ . status ) :owner= ${owner} :hostedBody= ${hostedBody} :service= ${serviceId} :route= ${serviceRoute} :command= ${command} :mutates= $( $_ . mutatesState ) :elevated= $( $_ . requiresElevatedAuthority ) :failedChecks= ${failedChecks} :missingChecks= ${missingChecks} :artifactStatus= ${artifactStatus} :sha256= ${artifactSha256} :audit= ${audit} :aftercare= ${aftercare} :artifact= $artifact "
2026-06-18 15:24:47 +01:00
} ) -join " ; " )
}
2026-06-18 17:12:52 +01:00
$serviceExecutionFailedChecks = Format-ServiceExecutionFailedChecks $result . serviceExecutionFailedCheckRows
2026-06-18 21:08:02 +01:00
$actionRows = Format-TuiRows $result . swarmActionTuiRows
$toolAttentionRows = Format-TuiRows $result . toolHostAttentionTuiRows
$serviceAttentionRows = Format-TuiRows $result . serviceLifecycleAttentionTuiRows
$serviceFailedCheckRows = Format-TuiRows $result . serviceExecutionFailedCheckTuiRows
$daemonRows = Format-TuiRows $result . daemonTuiRows
2026-06-21 00:50:39 +01:00
$repoWorkMapRows = Format-TuiRows $result . repoWorkMapTuiRows
$repoWorkSemanticRows = Format-TuiRows $result . repoWorkMapSemanticTuiRows
$repoWorkFamilyLensRows = Format-TuiRows $result . repoWorkMapFamilyLensTuiRows
$repoWorkPathLensRows = Format-TuiRows $result . repoWorkMapPathLensTuiRows
$repoWorkBranchLensRows = Format-TuiRows $result . repoWorkMapBranchLensTuiRows
$repoWorkStageLensRows = Format-TuiRows $result . repoWorkMapStageLensTuiRows
$repoWorkGateLensRows = Format-TuiRows $result . repoWorkMapGateLensTuiRows
2026-06-21 09:01:48 +01:00
$repoWorkClosureRows = Format-TuiRows $result . repoWorkMapClosureTuiRows
2026-06-21 09:27:13 +01:00
$repoWorkAcceptanceRows = Format-TuiRows $result . repoWorkMapAcceptanceTuiRows
2026-06-21 00:50:39 +01:00
$repoWorkOverviewRows = Format-TuiRows $result . repoWorkOverviewTuiRows
$repoWorkPublicProofRows = Format-TuiRows $result . repoWorkPublicProofTuiRows
2026-06-21 10:56:33 +01:00
$repoWorkReadinessRows = Format-TuiRows $result . repoWorkReadinessTuiRows
2026-06-21 12:41:58 +01:00
$repoWorkReadinessReviewRows = Format-TuiRows $result . repoWorkReadinessReviewTuiRows
Write-Host " Swarm triage: status= $( $result . status ) , overview= $( $result . overviewStatus ) , liveness= $( $result . livenessStatus ) , recovery= $( $result . recoveryStatus ) , clusters= $( $result . clusterCount ) , privateVerses= $( $result . privateVerseCount ) , recommended= $( $result . recommendedWrapperMode ) , serviceRecommended= $( $result . serviceLifecycleRecommendedWrapperMode ) , actionQueue= $actionQueue , actionRows= $actionRows , attention= $attention , daemonRows= $daemonRows , repoWorkMapRows= $repoWorkMapRows , repoWorkSemanticRows= $repoWorkSemanticRows , repoWorkFamilyLensRows= $repoWorkFamilyLensRows , repoWorkPathLensRows= $repoWorkPathLensRows , repoWorkBranchLensRows= $repoWorkBranchLensRows , repoWorkStageLensRows= $repoWorkStageLensRows , repoWorkGateLensRows= $repoWorkGateLensRows , repoWorkClosureRows= $repoWorkClosureRows , repoWorkAcceptanceRows= $repoWorkAcceptanceRows , repoWorkOverviewRows= $repoWorkOverviewRows , repoWorkPublicProofRows= $repoWorkPublicProofRows , repoWorkReadinessRows= $repoWorkReadinessRows , repoWorkReadinessReviewRows= $repoWorkReadinessReviewRows , toolHostAttention= $toolHostAttention , toolAttentionRows= $toolAttentionRows , serviceLifecycleAttention= $serviceLifecycleAttention , serviceAttentionRows= $serviceAttentionRows , serviceExecutionFailedChecks= $serviceExecutionFailedChecks , serviceFailedCheckRows= $serviceFailedCheckRows , poked= $( $result . pokedDaemonCount ) , privateStateExposed= $( $result . privateStateExposed ) "
2026-06-18 15:24:47 +01:00
} elseif ( $Mode -eq " service-runbook " ) {
2026-06-18 23:23:55 +01:00
$artifactSha256 = Get-LocalArtifactSha256 $result . runbookPath
Write-Host " Service runbook: service= $( $result . serviceId ) , receipt= $( $result . receiptId ) , artifactSha256= $artifactSha256 , followUp=tools/epiphany_local_run.ps1 -Mode service-launch, aftercare=tools/epiphany_local_run.ps1 -Mode service-status, path= $( $result . runbookPath ) "
2026-06-18 15:24:47 +01:00
} elseif ( $Mode -eq " cluster-service-runbook " ) {
2026-06-18 23:23:55 +01:00
$artifactSha256 = Get-LocalArtifactSha256 $result . runbookPath
Write-Host " Cluster daemon service runbook: service= $( $result . serviceId ) , daemons= $( $result . daemonCount ) , receipt= $( $result . receiptId ) , artifactSha256= $artifactSha256 , followUp=tools/epiphany_local_run.ps1 -Mode service-tick, aftercare=tools/epiphany_local_run.ps1 -Mode swarm-overview, path= $( $result . runbookPath ) "
2026-06-18 15:24:47 +01:00
} elseif ( $Mode -eq " cluster-service-install-plan " -or $Mode -eq " cluster-service-install-execute " ) {
2026-06-18 21:13:36 +01:00
$serviceRows = Format-ClusterServiceRows $result . services
2026-06-18 23:11:49 +01:00
$artifactSha256 = Get-LocalArtifactSha256 $result . installScriptPath
Write-Host " Cluster daemon service install: service= $( $result . serviceId ) , daemons= $( $result . daemonCount ) , status= $( $result . status ) , executed= $( $result . executed ) , receipt= $( $result . receiptId ) , artifactSha256= $artifactSha256 , followUp=tools/epiphany_local_run.ps1 -Mode cluster-service-install-execute, serviceRows= $serviceRows , path= $( $result . installScriptPath ) "
2026-06-18 15:24:47 +01:00
} elseif ( $Mode -eq " cluster-service-audit " ) {
2026-06-18 21:13:36 +01:00
$serviceRows = Format-ClusterServiceRows $result . services
2026-06-18 23:23:55 +01:00
Write-Host " Cluster daemon service audit: service= $( $result . serviceId ) , daemons= $( $result . daemonCount ) , status= $( $result . status ) , missing= $( $result . missingCount ) , running= $( $result . runningCount ) , present= $( $result . presentCount ) , queryFailed= $( $result . queryFailedCount ) , receipt= $( $result . receiptId ) , followUp=tools/epiphany_local_run.ps1 -Mode cluster-service-install-plan, aftercare=tools/epiphany_local_run.ps1 -Mode cluster-service-execution-audit, serviceRows= $serviceRows "
2026-06-18 15:24:47 +01:00
} elseif ( $Mode -eq " cluster-service-start-plan " -or $Mode -eq " cluster-service-stop-plan " -or $Mode -eq " cluster-service-start-execute " -or $Mode -eq " cluster-service-stop-execute " ) {
2026-06-18 21:13:36 +01:00
$serviceRows = Format-ClusterServiceRows $result . services
2026-06-18 23:15:58 +01:00
Write-Host " Cluster daemon service control: service= $( $result . serviceId ) , daemons= $( $result . daemonCount ) , status= $( $result . status ) , executeRequested= $( $result . executeRequested ) , executed= $( $result . executed ) , planned= $( $result . plannedCount ) , requested= $( $result . requestedCount ) , refused= $( $result . refusedCount ) , failed= $( $result . failedCount ) , receipt= $( $result . receiptId ) , followUp=tools/epiphany_local_run.ps1 -Mode cluster-service-audit, aftercare=tools/epiphany_local_run.ps1 -Mode cluster-service-execution-audit, serviceRows= $serviceRows "
2026-06-18 15:24:47 +01:00
} elseif ( $Mode -eq " cluster-service-execution-readiness " ) {
2026-06-18 21:18:04 +01:00
$serviceRows = Format-ClusterServiceRows $result . services $result . status
2026-06-18 23:20:00 +01:00
Write-Host " Cluster daemon service execution readiness: service= $( $result . serviceId ) , daemons= $( $result . daemonCount ) , services= $( $result . serviceCount ) , status= $( $result . status ) , elevated= $( $result . elevated ) , receipt= $( $result . receiptId ) , followUp=tools/epiphany_local_run.ps1 -Mode cluster-service-execution-runbook, aftercare=tools/epiphany_local_run.ps1 -Mode cluster-service-execution-audit, serviceRows= $serviceRows "
2026-06-18 15:24:47 +01:00
} elseif ( $Mode -eq " cluster-service-execution-runbook " ) {
2026-06-18 23:05:11 +01:00
$elevatedCommand = Get-ElevatedRunbookCommand $result . runbookPath
2026-06-18 23:08:11 +01:00
$artifactSha256 = Get-LocalArtifactSha256 $result . runbookPath
Write-Host " Cluster daemon service execution runbook: service= $( $result . serviceId ) , status= $( $result . status ) , finalAuditInFinally= $( $result . finalAuditRunsInFinally ) , continueAfterStepFailure= $( $result . continueAfterStepFailure ) , nonzeroExitFailsStep= $( $result . nonzeroExitFailsStep ) , exitsNonzeroAfterFinalAudit= $( $result . exitsNonzeroAfterFinalAudit ) , artifactSha256= $artifactSha256 , elevatedCommand= $elevatedCommand , aftercare=tools/epiphany_local_run.ps1 -Mode cluster-service-execution-audit, path= $( $result . runbookPath ) "
2026-06-18 15:24:47 +01:00
} elseif ( $Mode -eq " cluster-service-execution-audit " ) {
2026-06-19 02:45:17 +01:00
Write-Host " Cluster daemon service execution audit: service= $( $result . serviceId ) , status= $( $result . status ) , missing= $( $result . missingCount ) , failed= $( $result . failedCount ) , receipt= $( $result . receiptId ) , runbookSha256= $( $result . runbookSha256 ) , elevatedCommand= $( $result . elevatedCommand ) , aftercare= $( $result . aftercareCommand ) , requiresElevatedAuthority= $( $result . requiresElevatedAuthority ) "
2026-06-18 23:01:18 +01:00
$failedCheckRows = Format-ServiceExecutionFailedChecks @ ( $result . checks | Where-Object { -not $_ . ok } )
2026-06-18 17:08:27 +01:00
$runbookWitnessChecks = @ ( $result . checks | Where-Object { $_ . ok -and $null -ne $_ . operatorArtifactRef -and $_ . operatorArtifactRef -ne " " -and $_ . operatorArtifactRef -ne " none " } )
if ( $runbookWitnessChecks . Count -gt 0 ) {
$runbookWitnessSummary = ( $runbookWitnessChecks | ForEach-Object {
$artifact = $_ . operatorArtifactRef
$artifactSha256 = " none "
if ( Test-Path -LiteralPath $artifact -PathType Leaf ) {
$artifactSha256 = ( Get-FileHash -LiteralPath $artifact -Algorithm SHA256 ) . Hash . ToLowerInvariant ( )
}
2026-06-18 22:01:13 +01:00
$serviceId = $_ . serviceId
if ( $null -eq $serviceId -or $serviceId -eq " " ) {
$serviceId = " unknown-service "
}
" ${serviceId} :: $( $_ . action ) = ${artifact} :sha256= ${artifactSha256} "
2026-06-18 17:08:27 +01:00
} ) -join " ; "
Write-Host " Cluster daemon service execution runbook witnesses: $runbookWitnessSummary "
}
2026-06-18 15:24:47 +01:00
$failedChecks = @ ( $result . checks | Where-Object { -not $_ . ok } )
if ( $failedChecks . Count -gt 0 ) {
$failedSummary = ( $failedChecks | ForEach-Object {
$observed = $_ . observedStatus
if ( $null -eq $observed -or $observed -eq " " ) {
$observed = " missing "
}
2026-06-18 22:01:13 +01:00
$serviceId = $_ . serviceId
if ( $null -eq $serviceId -or $serviceId -eq " " ) {
$serviceId = " unknown-service "
}
" ${serviceId} :: $( $_ . action ) = $observed "
2026-06-18 15:24:47 +01:00
} ) -join " ; "
Write-Host " Cluster daemon service execution failed checks: $failedSummary "
}
2026-06-18 23:01:18 +01:00
Write-Host " Cluster daemon service execution failed check rows: $failedCheckRows "
2026-06-18 15:24:47 +01:00
} elseif ( $Mode -eq " service-execution-runbook " ) {
2026-06-18 23:05:11 +01:00
$elevatedCommand = Get-ElevatedRunbookCommand $result . runbookPath
2026-06-18 23:08:11 +01:00
$artifactSha256 = Get-LocalArtifactSha256 $result . runbookPath
Write-Host " Service execution runbook: service= $( $result . serviceId ) , name= $( $result . serviceName ) , status= $( $result . status ) , finalAuditInFinally= $( $result . finalAuditRunsInFinally ) , continueAfterStepFailure= $( $result . continueAfterStepFailure ) , nonzeroExitFailsStep= $( $result . nonzeroExitFailsStep ) , exitsNonzeroAfterFinalAudit= $( $result . exitsNonzeroAfterFinalAudit ) , artifactSha256= $artifactSha256 , elevatedCommand= $elevatedCommand , aftercare=tools/epiphany_local_run.ps1 -Mode service-execution-audit, path= $( $result . runbookPath ) "
2026-06-18 15:24:47 +01:00
} elseif ( $Mode -eq " service-install-plan " -or $Mode -eq " service-install-execute " ) {
2026-06-18 23:11:49 +01:00
$artifactSha256 = Get-LocalArtifactSha256 $result . installScriptPath
Write-Host " Service install: service= $( $result . serviceId ) , name= $( $result . serviceName ) , status= $( $result . status ) , executed= $( $result . executed ) , receipt= $( $result . receiptId ) , artifactSha256= $artifactSha256 , followUp=tools/epiphany_local_run.ps1 -Mode service-install-execute, path= $( $result . installScriptPath ) "
2026-06-18 15:24:47 +01:00
} elseif ( $Mode -eq " service-status " ) {
2026-06-18 23:20:00 +01:00
Write-Host " Service status: service= $( $result . serviceId ) , name= $( $result . serviceName ) , status= $( $result . status ) , receipt= $( $result . receiptId ) , followUp=tools/epiphany_local_run.ps1 -Mode service-reconcile, aftercare=tools/epiphany_local_run.ps1 -Mode service-execution-audit "
2026-06-18 15:24:47 +01:00
} elseif ( $Mode -eq " service-tick " ) {
Write-Host " Scheduler tick: scheduler= $( $result . schedulerId ) , daemonSelector= $( $result . daemonId ) , status= $( $result . status ) , outcomes= $( $result . outcomeCount ) , restarted= $( $result . restartedCount ) , refused= $( $result . refusedCount ) , skipped= $( $result . skippedCount ) , receipt= $( $result . schedulerReceiptId ) , privateStateExposed= $( $result . privateStateExposed ) "
} elseif ( $Mode -eq " service-reconcile " ) {
2026-06-18 23:20:00 +01:00
Write-Host " Service reconcile: service= $( $result . serviceId ) , name= $( $result . serviceName ) , status= $( $result . status ) , receipt= $( $result . receiptId ) , followUp=tools/epiphany_local_run.ps1 -Mode service-install-plan, aftercare=tools/epiphany_local_run.ps1 -Mode service-execution-audit "
2026-06-18 15:24:47 +01:00
} elseif ( $Mode -eq " service-execution-readiness " ) {
2026-06-18 23:20:00 +01:00
Write-Host " Service execution readiness: service= $( $result . serviceId ) , name= $( $result . serviceName ) , status= $( $result . status ) , elevated= $( $result . elevated ) , receipt= $( $result . receiptId ) , followUp=tools/epiphany_local_run.ps1 -Mode service-execution-runbook, aftercare=tools/epiphany_local_run.ps1 -Mode service-execution-audit "
2026-06-18 15:24:47 +01:00
} elseif ( $Mode -eq " service-execution-audit " ) {
2026-06-19 02:45:17 +01:00
Write-Host " Service execution audit: service= $( $result . serviceId ) , name= $( $result . serviceName ) , status= $( $result . status ) , missing= $( $result . missingCount ) , failed= $( $result . failedCount ) , receipt= $( $result . receiptId ) , runbookSha256= $( $result . runbookSha256 ) , elevatedCommand= $( $result . elevatedCommand ) , aftercare= $( $result . aftercareCommand ) , requiresElevatedAuthority= $( $result . requiresElevatedAuthority ) "
2026-06-18 23:01:18 +01:00
$failedCheckRows = Format-ServiceExecutionFailedChecks @ ( $result . checks | Where-Object { -not $_ . ok } )
2026-06-18 17:08:27 +01:00
$runbookWitnessChecks = @ ( $result . checks | Where-Object { $_ . ok -and $null -ne $_ . operatorArtifactRef -and $_ . operatorArtifactRef -ne " " -and $_ . operatorArtifactRef -ne " none " } )
if ( $runbookWitnessChecks . Count -gt 0 ) {
$runbookWitnessSummary = ( $runbookWitnessChecks | ForEach-Object {
$artifact = $_ . operatorArtifactRef
$artifactSha256 = " none "
if ( Test-Path -LiteralPath $artifact -PathType Leaf ) {
$artifactSha256 = ( Get-FileHash -LiteralPath $artifact -Algorithm SHA256 ) . Hash . ToLowerInvariant ( )
}
2026-06-18 22:01:13 +01:00
$serviceId = $_ . serviceId
if ( $null -eq $serviceId -or $serviceId -eq " " ) {
$serviceId = " unknown-service "
}
" ${serviceId} :: $( $_ . action ) = ${artifact} :sha256= ${artifactSha256} "
2026-06-18 17:08:27 +01:00
} ) -join " ; "
Write-Host " Service execution runbook witnesses: $runbookWitnessSummary "
}
2026-06-18 15:24:47 +01:00
$failedChecks = @ ( $result . checks | Where-Object { -not $_ . ok } )
if ( $failedChecks . Count -gt 0 ) {
$failedSummary = ( $failedChecks | ForEach-Object {
$observed = $_ . observedStatus
if ( $null -eq $observed -or $observed -eq " " ) {
$observed = " missing "
}
2026-06-18 22:01:13 +01:00
$serviceId = $_ . serviceId
if ( $null -eq $serviceId -or $serviceId -eq " " ) {
$serviceId = " unknown-service "
}
" ${serviceId} :: $( $_ . action ) = $observed "
2026-06-18 15:24:47 +01:00
} ) -join " ; "
Write-Host " Service execution failed checks: $failedSummary "
}
2026-06-18 23:01:18 +01:00
Write-Host " Service execution failed check rows: $failedCheckRows "
2026-06-18 15:24:47 +01:00
} elseif ( $Mode -eq " service-start-plan " -or $Mode -eq " service-stop-plan " -or $Mode -eq " service-start-execute " -or $Mode -eq " service-stop-execute " ) {
2026-06-18 23:15:58 +01:00
Write-Host " Service control: service= $( $result . serviceId ) , name= $( $result . serviceName ) , status= $( $result . status ) , executeRequested= $( $result . executeRequested ) , executed= $( $result . executed ) , receipt= $( $result . receiptId ) , followUp=tools/epiphany_local_run.ps1 -Mode service-status, aftercare=tools/epiphany_local_run.ps1 -Mode service-execution-audit "
2026-05-21 10:31:10 +01:00
} else {
Write-Host " Coordinator: thread= $( $result . threadId ) , finalAction= $( $result . finalAction . action ) , runtimePresent= $( $result . runtimeSpine . present ) "
}
} catch {
Write-Host " Summary parse failed; inspect $resultPath "
}
}
2026-05-27 21:08:55 +01:00
$operatorRunReceiptArgs = @ (
" receipt " ,
" --store " , $operatorRunStore ,
2026-06-21 01:16:30 +01:00
" --runtime-id " , $LocalVerseRuntimeId ,
2026-05-27 21:08:55 +01:00
" --run-id " , $runId ,
" --mode " , $Mode ,
" --status " , " completed " ,
" --result-path " , $resultPath ,
" --artifact-root " , $artifactRoot ,
" --dogfood-root " , $dogfoodRoot ,
" --operator-snapshot-store " , $operatorSnapshotStore
)
if ( $Mode -eq " status " ) {
$operatorRunReceiptArgs + = @ ( " --operator-snapshot-id " , $operatorSnapshotId )
}
Invoke-Checked `
-Label " write CultMesh operator run receipt " `
-FilePath $operatorRunExe `
-Arguments $operatorRunReceiptArgs `
-WorkingDirectory $Root `
2026-06-18 15:24:47 +01:00
-StdoutPath ( Join-Path $artifactRoot " operator-run-receipt.stdout.json " ) `
-StderrPath ( Join-Path $artifactRoot " operator-run-receipt.stderr.log " )
if ( $shouldReadLocalVerse ) {
Invoke-Checked `
-Label " read local Verse context " `
-FilePath $verseQueryExe `
-Arguments @ (
" query " ,
" --store " , $localVerseStore ,
2026-06-21 01:16:30 +01:00
" --runtime-id " , $LocalVerseRuntimeId
2026-06-18 15:24:47 +01:00
) `
-WorkingDirectory $Root `
-StdoutPath ( Join-Path $artifactRoot " local-verse-context.json " ) `
-StderrPath ( Join-Path $artifactRoot " local-verse-context.final.stderr.log " )
}
2026-05-21 10:17:38 +01:00
Write-Host " Epiphany local run complete. "
Write-Host " Launcher artifacts: $artifactRoot "
Write-Host " Coordinator artifacts: $dogfoodRoot "