From e8d2906978c0d586ed025c0bd75e6af458d15c8c Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Fri, 19 Jun 2026 02:58:51 +0100 Subject: [PATCH] Expose swarm online preflight --- notes/fresh-workspace-handoff.md | 1 + state/ledgers.msgpack | Bin 294815 -> 295437 bytes state/map.yaml | 1 + tools/epiphany_local_run.ps1 | 101 +++++++++++++++++++++++-------- 4 files changed, 78 insertions(+), 25 deletions(-) diff --git a/notes/fresh-workspace-handoff.md b/notes/fresh-workspace-handoff.md index 761d7485..48814cc6 100644 --- a/notes/fresh-workspace-handoff.md +++ b/notes/fresh-workspace-handoff.md @@ -121,6 +121,7 @@ remembers doctrine; the branch remembers the blade. - Idunn, not Codex/Self/Gjallar, owns daemon survival and service lifecycle physiology. `tools/epiphany_local_run.ps1 -Mode swarm-online-runbook` now generates an Idunn-owned service lifecycle runbook for the Epiphany hosted body: the artifact verifies each sealed child runbook artifact exists and matches its advertised SHA-256 before launching it with `Start-Process ... -PassThru`, records child exit codes, continues after child failure, runs aftercare audits through `tools\epiphany_local_run.ps1` with explicit arguments instead of string evaluation, and exits nonzero if any child or aftercare step fails. Its wrapper JSON and one-line summary print the exact swarm-level `elevatedCommand=Start-Process PowerShell -Verb RunAs -Wait ...`, parent artifact SHA-256, `verifiesChildArtifactSha256=True`, `usesExplicitAftercareArguments=True`, child/aftercare row counts, aftercare commands, owner, hosted body, and private-state seal; JSON now includes structured `childRunbookRows` and `aftercareRows` with service ids, routes, SHA-256s, audit modes, authority gates, failed-check counts, and private-state seals. Proof `local-20260619-013021-159-c93088be` generated and inspected that guard without mutating services. It still requires explicit elevated operator authority before service mutation. - Service execution audits now expose the exact Idunn runbook route at the audit mouth: `cluster-service-execution-audit` and `service-execution-audit` JSON and wrapper summaries include the sealed runbook path, SHA-256, elevated `Start-Process PowerShell -Verb RunAs -Wait ...` command, aftercare command, and `requiresElevatedAuthority=True`. Daemon-supervisor `*smoke` commands default to `.epiphany-smoke/daemon-supervisor-/local-verse.ccmp` unless `--store` is explicit, keeping synthetic smoke receipts out of the shared live local Verse. - Gjallar/swarm-overview now demotes `smoke://` service runbook witnesses to non-elevated runbook regeneration rows, not operator authority rows. The live local Verse cluster runbook witness has been repaired through `cluster-service-execution-runbook` plus `cluster-service-execution-audit`; latest Gjallar shows real cluster and single-service runbook paths, SHA-256s, elevated commands, and aftercare. +- `swarm-online-runbook` now prints and stores Idunn preflight fields: ready/blocked status, child artifact present/hash-verified/mismatch/missing counts, aggregate failed/missing service-execution checks, and child expected/actual SHA-256 rows. Latest proof `local-20260619-025627-410-9724e2f6` is ready for explicit operator elevation with two child runbooks present and hash-verified, zero missing artifacts, eleven failed sealed checks still awaiting elevated execution, and no private-state exposure. - `swarm-triage` is the compact responsibility rite after sight: it no-ops when liveness is ready, carries blocked tool-host/service lifecycle attention plus an ordered action queue as sealed sight, and emits topology-aware typed daemon poke receipts only for current daemon liveness attention rows. - `epiphany-openai-runtime` worker result ingress now parses assistant output directly into typed role/reorient ingress structs selected from the durable launch document, stores nested `statePatch` and `selfPatch` as typed MessagePack in `EpiphanyRuntimeRoleWorkerResult`, and no longer passes worker result data through generic `serde_json::Value`. JSON survives there only as the OpenAI text-output edge before typed deserialization. - Agent self-memory review/application now has typed `AgentSelfPatch` core APIs. JSON-value selfPatch functions are compatibility wrappers for CLI/artifact ingress; native callers should parse once at the edge and then call `review_agent_self_patch_document` / `apply_agent_self_patch_document`. Role-result self-persistence no longer exports a JSON-value reviewer; the live API is `review_role_self_patch_document`. diff --git a/state/ledgers.msgpack b/state/ledgers.msgpack index 5e317f7901a67019bb191eb4e51a1d13b832a8d3..daca47e1aaa99e334f5d393879baadb40d05078a 100644 GIT binary patch delta 585 zcmZ9JL5mYH6vv&mc-WiDvU>6@UYp(N&~0g9K`)}KGPLrBsc2+?uD0uQ_ znWJAp@F0Ex@q>8sBKrw6u~Qa3goNb1_y7NY`S||)ed+}tjyE3)` zTIk^6p{R|4r6XDCQU#EjD&av|2X;vggLTZKB%q4UFlcK)p%GTf`DNEhz)<@kaHT5& z=z^BWLwfgQ!l6R1*cmw;hl|67_6G|LT&0uOrUY(l6Jk4-rK1u9fka(xN>f3*|Gj@> z#1-+=RAodbMCVK5A=X8)8Y?(?aE}#76L7Zi2k@xf-y7_$W-O0)#gvUlIh#$3F%@zG zC7BeC1O!E}L>GNt8gFz^|ED{4gyIE@VAuu)3AQCPgwWW|l&j4%YfpWbeig??!wCUw z5e(raISXC` for each failed/missing check. Live proofs `local-20260618-225923-468-d818951a` and `local-20260618-225923-529-7cfa2bb3` showed cluster readiness/install/start/audit/stop failures and supervisor-service readiness/install/start/status/reconcile/stop missing checks with actionable follow-up wrappers and `privateStateExposed=false`. - Service execution audits now carry their own elevated runbook readback instead of relying on Gjallar or wrapper memory. `epiphany-daemon-supervisor windows-service-execution-audit` and `cluster-windows-service-execution-audit` return `runbookPath`, `runbookSha256`, `elevatedCommand`, `requiresElevatedAuthority`, `aftercareMode`, and `aftercareCommand` from the sealed runbook witness; the wrapper summaries print those fields directly for `service-execution-audit` and `cluster-service-execution-audit`. Live proofs `local-20260619-024011-505-a18982fa` and `local-20260619-024010-980-842fc3a6` showed incomplete audits with repaired runbook hashes, exact `Start-Process PowerShell -Verb RunAs -Wait ... -File ` commands, explicit aftercare, and no private-state exposure. `epiphany-daemon-supervisor` smoke commands now default to `.epiphany-smoke/daemon-supervisor-/local-verse.ccmp` unless `--store` is explicit, so synthetic smoke receipts cannot become the latest live local Verse service proof by accident. - Gjallar/swarm-overview service-execution authority rows now treat synthetic `smoke://` runbook witnesses as missing artifacts, not external executable refs. Such rows demote to `runbook-artifact-missing`, `service-lifecycle-runbook-regeneration`, no elevated authority, no mutation, no execution command, and no aftercare until a real local runbook artifact is regenerated. Source smoke guards this demotion, while live local Verse was repaired by regenerating the cluster execution runbook and re-auditing it: Gjallar proof `local-20260619-025100-231-0d70bace` showed both cluster and single-service authority rows with `artifactStatus=present`, real SHA-256s, exact elevated commands, aftercare audits, Idunn/Epiphany ownership, and no `smoke://` artifact refs. + - `tools/epiphany_local_run.ps1 -Mode swarm-online-runbook` now emits an explicit Idunn preflight summary before the operator elevation boundary. Its JSON and one-line summary report `preflightStatus`, child artifact present/hash-verified/mismatch/missing counts, aggregate service execution failed/missing check counts, child preflight rows with expected/actual SHA-256s, and private-state exposure. Live proof `local-20260619-025627-410-9724e2f6` generated the non-mutating parent artifact with `preflightStatus=ready-for-elevated-operator`, two child runbooks present, two hashes verified, zero mismatches, zero missing artifacts, eleven failed sealed service checks, zero missing checks, explicit aftercare audits, and `privateStateExposed=false`. The remaining scar is still explicit elevated operator execution followed by complete Idunn audits, not missing parent/child artifact readiness. - Service lifecycle receipt history is now event-only: `load_epiphany_cultmesh_daemon_service_lifecycle_receipts` filters out the `epiphany-local/daemon-service-lifecycle-receipt/latest` mirror, while `load_latest_epiphany_cultmesh_daemon_service_lifecycle_receipt` remains the latest-state reader. Focused unit test `service_lifecycle_receipt_history_excludes_latest_mirror` proves two per-receipt writes return exactly two history records and latest points at the second. Fresh smoke `verse-query-lifecycle-history-filter-smoke` and live overview/triage `local-20260618-145632-497-efac6f0d` / `local-20260618-145632-321-867947af` prove compact swarm sights still expose service lifecycle attention plus the present elevated runbook artifact without daemon pokes or service mutation. Do not use a broad unscoped cargo test filter for this check on Windows; it fans out across bin harnesses and hit a broken pipe during this pass. - `epiphany-verse-query seed-compact` is the compact seed receipt for wrappers and read-only rites. The older `seed` command still prints the full local Verse context for explicit debugging, but compact wrapper modes now avoid full `seed`/final `query` readback after the combined overview proof exposed Windows debug stack overflow from full-context serialization pressure. next_action: Continue the swarm-readiness cuts toward elevated operator install/start execution and completed audit/readiness for the seven installed services. Run generated service execution/install/control runbooks only when the operator grants that authority. The current local Verse proves liveness readiness, scheduler-policy coverage, daemon-body invocation, per-organ launch artifact generation, per-organ install-plan generation, non-elevated install/start/stop execution refusal, read-only installed-service audit, cluster-wide service control planning, service-lifecycle attention surfacing, and cluster execution audit acceptance criteria: `swarm-overview` now reports `status=attention`, `livenessStatus=ready`, `recoveryStatus=attention`, `recommendedWrapperMode=swarm-online-runbook`, and `recommendedWrapperCommand=tools/epiphany_local_run.ps1 -Mode swarm-online-runbook`; `service-tick` can refresh all seven daemon heartbeats through sealed scheduler receipts; `cluster-service-runbook` writes seven explicit `epiphany-cluster-daemon serve` commands with `privateStateExposed=false`; `cluster-service-install-plan` writes seven distinct Windows service install commands with `privateStateExposed=false`; `cluster-service-install-execute`, `cluster-service-start-execute`, and `cluster-service-stop-execute` refuse as `execution-refused-not-elevated` with `executed=false` when the shell lacks service authority; `cluster-service-start-plan` and `cluster-service-stop-plan` emit seven non-mutating planned rows; `cluster-service-audit` currently reports `incomplete` with seven missing services in this non-installed environment; `service-execution-runbook` and `cluster-service-execution-runbook` write elevated wrapper sequences that continue after per-step failure, run final audits in `finally`, exit nonzero after audit when any step failed, and seal typed runbook receipts with aftercare args (`stepFailurePolicy`, `continueAfterStepFailure`, `nonzeroExitFailsStep`, `exitsNonzeroAfterFinalAudit`); and `service-execution-audit` plus `cluster-service-execution-audit` now require those runbook witnesses before considering elevated-ready/install/start/audit/status/reconcile/stop effect receipts. Preserve the existing typed local Verse surfaces: `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-execution-audit`, `service-tick`, `service-policy-directory`, `agent-state-soa`, `swarm-status`, `swarm-poke-down`, `swarm-triage`, `cluster-topology`, `eve-surfaces`, `eve-connect`, `collaboration-feedback`, `bifrost-publication`, `bifrost-ledger`, `receipt-directory`, `tool-directory`, `tool-invoke`, `swarm-overview`, `swarm-online-runbook`, `seed-compact`, service manager status/reconcile/readiness/control wrappers, compact daemon scheduler/policy receipt rows, daemon liveness-gated tool routing, Bifrost/Imagination chains, coordinator-run receipts, Hands gates, role review mirrors, and sealed agent-state SoA summary. Keep the seven-standing-faculty SoA, stale-turn repair, memory lifecycle, shared local Verse witnesses, and typed CultMesh Persona speech gate intact. diff --git a/tools/epiphany_local_run.ps1 b/tools/epiphany_local_run.ps1 index c6e3a7e7..e03c6262 100644 --- a/tools/epiphany_local_run.ps1 +++ b/tools/epiphany_local_run.ps1 @@ -904,6 +904,45 @@ if ($Mode -eq "swarm-online-runbook") { throw "swarm-online-runbook found no present elevated service execution artifacts in swarm overview" } + $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" + } + $aftercareCommands = @($authorityRows | ForEach-Object { $_.operatorAftercareCommand } | Where-Object { $null -ne $_ -and $_ -ne "" -and $_ -ne "none" } | Select-Object -Unique) $aftercareRows = @($authorityRows | Where-Object { $null -ne $_.operatorAftercareCommand -and @@ -995,30 +1034,34 @@ if ($Mode -eq "swarm-online-runbook") { $runbookSha256 = Get-LocalArtifactSha256 $runbookPath $elevatedCommand = Get-ElevatedRunbookCommand $runbookPath $childRunbookRows = @($authorityRows | ForEach-Object { + $authorityRow = $_ + $preflightRow = @($childArtifactPreflightRows | Where-Object { $_.artifactRef -eq $authorityRow.operatorArtifactRef } | Select-Object -First 1) [pscustomobject]@{ - priority = $_.priority - family = $_.family - status = $_.status - lifecycleOwner = $_.lifecycleOwner - hostedBody = $_.hostedBody - serviceId = $_.serviceId - serviceRoute = $_.serviceRoute - wrapperMode = $_.wrapperMode - wrapperCommand = $_.wrapperCommand - authorityGate = $_.authorityGate - effectClass = $_.effectClass - mutatesState = $_.mutatesState - requiresElevatedAuthority = $_.requiresElevatedAuthority - artifactRef = $_.operatorArtifactRef - artifactStatus = $_.operatorArtifactStatus - artifactSha256 = $_.operatorArtifactSha256 - artifactExecutionCommand = $_.operatorArtifactExecutionCommand - aftercareCommand = $_.operatorAftercareCommand - completionAuditWrapperMode = $_.completionAuditWrapperMode - completionAuditWrapperCommand = $_.completionAuditWrapperCommand - serviceExecutionFailedCheckCount = $_.serviceExecutionFailedCheckCount - serviceExecutionMissingCheckCount = $_.serviceExecutionMissingCheckCount - privateStateExposed = $_.privateStateExposed + 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 } }) $aftercareRunbookRows = @($aftercareRows | ForEach-Object { @@ -1034,17 +1077,25 @@ if ($Mode -eq "swarm-online-runbook") { }) [pscustomobject]@{ status = "ok" + preflightStatus = $preflightStatus store = $localVerseStore runtimeId = "epiphany-local" runbookPath = $runbookPath artifactSha256 = $runbookSha256 elevatedCommand = $elevatedCommand commandCount = $authorityRows.Count + childArtifactPresentCount = $childArtifactPresentCount + childArtifactHashVerifiedCount = $childArtifactHashVerifiedCount + childArtifactMismatchCount = $childArtifactMismatchCount + childArtifactMissingCount = $childArtifactMissingCount + serviceExecutionFailedCheckCount = $serviceExecutionFailedCheckCount + serviceExecutionMissingCheckCount = $serviceExecutionMissingCheckCount lifecycleOwner = "Idunn" hostedBody = "Epiphany" commands = @($authorityRows | ForEach-Object { $_.operatorArtifactExecutionCommand }) aftercareCommands = $aftercareCommands childRunbookRows = $childRunbookRows + childArtifactPreflightRows = $childArtifactPreflightRows aftercareRows = $aftercareRunbookRows detectsChildExitCodes = $true continuesAfterChildFailure = $true @@ -1052,7 +1103,7 @@ if ($Mode -eq "swarm-online-runbook") { usesExplicitAftercareArguments = $true exitsNonzeroAfterChildOrAftercareFailure = $true sourceOverviewPath = $overviewPath - privateStateExposed = $false + privateStateExposed = $privateStateExposed } | ConvertTo-Json -Depth 6 | Set-Content -LiteralPath $resultPath -Encoding UTF8 } @@ -2195,7 +2246,7 @@ if ($resultPath -ne "" -and (Test-Path -LiteralPath $resultPath)) { if ($null -ne $result.aftercareRows) { $aftercareRows = @($result.aftercareRows).Count } - Write-Host "Swarm online runbook: status=$($result.status), owner=$($result.lifecycleOwner), hostedBody=$($result.hostedBody), commands=$($result.commandCount), childRows=$childRows, aftercareRows=$aftercareRows, artifactSha256=$($result.artifactSha256), elevatedCommand=$($result.elevatedCommand), verifiesChildArtifactSha256=$($result.verifiesChildArtifactSha256), usesExplicitAftercareArguments=$($result.usesExplicitAftercareArguments), aftercare=$aftercare, path=$($result.runbookPath), privateStateExposed=$($result.privateStateExposed)" + 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)" } elseif ($Mode -eq "service-policy-directory") { $policyRows = "none" if ($null -ne $result.tuiRows -and $result.tuiRows.Count -gt 0) {