2026-05-21 10:17:38 +01:00
param (
2026-05-28 13:37:08 +01:00
[ ValidateSet ( " status " , " plan " , " smoke " , " run " , " mvp " ) ]
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 = " " ,
[ 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-07 05:21:20 +01:00
[ string ] $PersonaInput = " " ,
2026-05-21 10:17:38 +01:00
[ switch ] $SkipBuild ,
[ switch ] $AutoReview ,
2026-05-28 13:37:08 +01:00
[ switch ] $NoEphemeral ,
2026-06-05 00:20:54 +01:00
[ switch ] $SkipSleep ,
[ string ] $GjallarAffordanceStore = " "
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 ) {
throw " $Label failed with exit code $exitCode "
}
}
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 "
}
}
$runId = " local- " + ( Get-Date -Format " yyyyMMdd-HHmmss " )
$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-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-07 05:21:20 +01:00
$faceExe = Join-Path $TargetDir " debug\epiphany-persona-discord.exe "
2026-05-28 13:37:08 +01:00
$characterLoopExe = Join-Path $TargetDir " debug\epiphany-character-loop.exe "
2026-05-27 22:18:52 +01:00
$modelProvider = " openai-codex "
2026-06-09 02:45:09 +01:00
$operatorRunStore = Join-Path $Root " .epiphany-run\cultmesh\operator-runs.cc "
$operatorSnapshotStore = Join-Path $Root " .epiphany-run\cultmesh\operator-snapshots.cc "
$localVerseStore = Join-Path $Root " .epiphany-run\cultmesh\local-verse.cc "
2026-05-27 21:08:55 +01:00
$operatorSnapshotId = " $runId -status "
2026-06-09 02:45:09 +01:00
$agentStore = Join-Path $Root " state\agents.cc "
$heartbeatStore = Join-Path $Root " state\agent-heartbeats.cc "
$runtimeStore = Join-Path $Workspace " state\runtime-spine.cc "
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-05-27 21:32:29 +01:00
if ( $Mode -ne " status " ) {
Invoke-Checked `
-Label " build Codex app-server compatibility organ " `
-FilePath " cargo " `
-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 " `
-FilePath " cargo " `
-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-05-21 10:17:38 +01:00
" --bin " , " epiphany-mvp-coordinator " ,
" --bin " , " epiphany-mvp-coordinator-smoke " ,
" --bin " , " epiphany-heartbeat-store " ,
2026-06-07 05:21:20 +01:00
" --bin " , " epiphany-persona-discord " ,
2026-05-28 13:37:08 +01:00
" --bin " , " epiphany-character-loop " ,
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-05-21 10:17:38 +01:00
-FilePath " cargo " `
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 " `
-FilePath " cargo " `
-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-05 00:20:54 +01:00
if ( $GjallarAffordanceStore -eq " " ) {
if ( $env:EPIPHANY_GJALLAR_AFFORDANCE_STORE ) {
$GjallarAffordanceStore = $env:EPIPHANY_GJALLAR_AFFORDANCE_STORE
} else {
$candidateOdinStore = Join-Path ( Split-Path -Parent $Root ) " Odin\scratch\gjallar\gjallar.affordances.cc "
if ( Test-Path -LiteralPath $candidateOdinStore ) {
$GjallarAffordanceStore = $candidateOdinStore
}
}
}
if ( $GjallarAffordanceStore -ne " " ) {
$GjallarAffordanceStore = ( Resolve-Path -LiteralPath $GjallarAffordanceStore ) . Path
$env:EPIPHANY_GJALLAR_AFFORDANCE_STORE = $GjallarAffordanceStore
}
2026-06-02 14:24:55 +01:00
$requiredBinaries = @ ( $statusExe , $operatorRunExe , $operatorSnapshotExe , $verseQueryExe )
2026-05-27 21:32:29 +01:00
if ( $Mode -ne " status " ) {
$requiredBinaries + = @ ( $codexAppServer , $coordinatorExe )
}
2026-05-28 13:37:08 +01:00
if ( $liveRuntimeMode ) {
$requiredBinaries + = @ ( $modelRuntimeExe , $toolAdapterExe )
}
if ( $Mode -eq " mvp " ) {
$requiredBinaries + = @ ( $heartbeatExe , $faceExe , $characterLoopExe )
}
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-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 ,
" --runtime-id " , " epiphany-local " ,
" --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-05-21 10:17:38 +01:00
if ( $Mode -eq " status " ) {
$statusJson = Join-Path $artifactRoot " status.json "
2026-06-02 14:24:55 +01:00
$localVerseJson = Join-Path $artifactRoot " local-verse-context.json "
2026-05-21 10:31:10 +01:00
$resultPath = $statusJson
2026-05-21 10:18:52 +01:00
$statusArgs = @ (
2026-05-27 21:32:29 +01:00
" --source " , " native " ,
2026-05-21 10:18:52 +01:00
" --cwd " , $Workspace ,
2026-06-09 02:45:09 +01:00
" --thread-state-store " , ( Join-Path $Root " state\thread-state.cc " ) ,
2026-05-21 10:18:52 +01:00
" --json " ,
2026-05-27 21:32:29 +01:00
" --result " , $statusJson
2026-05-21 10:18:52 +01:00
)
if ( $ThreadId -ne " " ) {
2026-05-27 21:32:29 +01:00
$statusArgs + = @ ( " --thread-id " , $ThreadId )
2026-05-21 10:18:52 +01:00
}
2026-05-21 10:17:38 +01:00
Invoke-Checked `
-Label " run operator status " `
-FilePath $statusExe `
2026-05-21 10:18:52 +01:00
-Arguments $statusArgs `
2026-05-21 10:17:38 +01:00
-WorkingDirectory $Root `
-StdoutPath ( Join-Path $artifactRoot " status.stdout.json " ) `
-StderrPath ( Join-Path $artifactRoot " status.stderr.log " )
2026-06-05 00:20:54 +01:00
$localVerseArgs = @ (
" seed " ,
" --store " , $localVerseStore ,
" --runtime-id " , " epiphany-local "
)
if ( $GjallarAffordanceStore -ne " " ) {
$localVerseArgs + = @ ( " --gjallar-affordance-store " , $GjallarAffordanceStore )
}
2026-06-02 14:24:55 +01:00
Invoke-Checked `
-Label " read local Verse context " `
-FilePath $verseQueryExe `
2026-06-05 00:20:54 +01:00
-Arguments $localVerseArgs `
2026-06-02 14:24:55 +01:00
-WorkingDirectory $Root `
-StdoutPath $localVerseJson `
-StderrPath ( Join-Path $artifactRoot " local-verse-context.stderr.log " )
2026-05-27 20:58:31 +01:00
Invoke-Checked `
-Label " write CultMesh operator snapshot " `
-FilePath $operatorSnapshotExe `
-Arguments @ (
" from-status " ,
" --store " , $operatorSnapshotStore ,
" --runtime-id " , " epiphany-local " ,
2026-05-27 21:08:55 +01:00
" --snapshot-id " , $operatorSnapshotId ,
2026-05-27 20:58:31 +01:00
" --source-mode " , " status " ,
" --input " , $statusJson
) `
-WorkingDirectory $Root `
-StdoutPath ( Join-Path $artifactRoot " operator-snapshot.stdout.json " ) `
-StderrPath ( Join-Path $artifactRoot " operator-snapshot.stderr.log " )
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-07 05:21:20 +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-07 05:21:20 +01:00
$faceArtifactDir = Join-Path $dogfoodRoot " persona "
2026-05-28 13:37:08 +01:00
$characterArtifactDir = Join-Path $dogfoodRoot " character-loop "
2026-06-07 05:21:20 +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-07 05:21:20 +01:00
-Label " project Persona character turn " `
2026-05-28 13:37:08 +01:00
-FilePath $characterLoopExe `
-Arguments @ (
" turn " ,
2026-06-07 05:21:20 +01:00
" --role " , " persona " ,
2026-05-28 13:37:08 +01:00
" --agent-store " , $agentStore ,
" --artifact-dir " , $characterArtifactDir ,
2026-06-07 05:21:20 +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-07 05:21:20 +01:00
-StderrPath ( Join-Path $artifactRoot " persona-character-turn.stderr.log " )
2026-05-28 13:37:08 +01:00
Invoke-Checked `
2026-06-07 05:21:20 +01:00
-Label " write Persona Aquarium bubble " `
2026-05-28 13:37:08 +01:00
-FilePath $faceExe `
-Arguments @ (
" bubble " ,
" --artifact-dir " , $faceArtifactDir ,
2026-06-07 05:21:20 +01:00
" --content " , $PersonaInput ,
2026-05-28 13:37:08 +01:00
" --source " , " epiphany/local-mvp " ,
" --status " , " ready " ,
" --mood " , " attentive "
) `
-WorkingDirectory $Root `
2026-06-07 05:21:20 +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-05-28 14:44:08 +01:00
if ( $Mode -eq " mvp " -and $ThreadId -eq " " ) {
2026-06-07 05:21:20 +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-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-05 00:20:54 +01:00
- gjallarAffordanceStore : $GjallarAffordanceStore
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-05-28 13:37:08 +01:00
- faceBinary : $faceExe
- 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-07 05:21:20 +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 " ) {
Write-Host " Status: thread= $( $result . threadId ) , coordinator= $( $result . coordinator . action ) , crrc= $( $result . crrc . recommendation . action ) "
} 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 ,
" --runtime-id " , " epiphany-local " ,
" --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 `
-StdoutPath ( Join-Path $artifactRoot " operator-run-receipt.stdout.json " ) `
-StderrPath ( Join-Path $artifactRoot " operator-run-receipt.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 "