From de7424d31030995f962a9430dc6ef5b61ab3bdd4 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Mon, 22 Jun 2026 17:15:52 +0100 Subject: [PATCH] Read Bifrost bridge readiness in status --- epiphany-core/src/bin/epiphany-mvp-status.rs | 137 +++++++++++++++++++ notes/fresh-workspace-handoff.md | 1 + state/ledgers.msgpack | Bin 395581 -> 396137 bytes state/map.yaml | 1 + tools/epiphany_local_run.ps1 | 6 +- 5 files changed, 144 insertions(+), 1 deletion(-) diff --git a/epiphany-core/src/bin/epiphany-mvp-status.rs b/epiphany-core/src/bin/epiphany-mvp-status.rs index 24a29a17..8b3a19ee 100644 --- a/epiphany-core/src/bin/epiphany-mvp-status.rs +++ b/epiphany-core/src/bin/epiphany-mvp-status.rs @@ -528,6 +528,7 @@ fn run_native_status(args: &Args) -> Result { "tools": tool_invocations, "heartbeat": native_aux.heartbeat, "persona": native_aux.persona, + "bifrostBridge": native_aux.bifrost_bridge, "voidMemory": native_aux.void_memory, }); Ok(sanitize_for_operator(status)) @@ -644,6 +645,7 @@ fn run_codex_status(args: &Args) -> Result { "tools": tool_invocations, "heartbeat": native_aux.heartbeat, "persona": native_aux.persona, + "bifrostBridge": native_aux.bifrost_bridge, "voidMemory": native_aux.void_memory, }); Ok(sanitize_for_operator(status)) @@ -652,6 +654,7 @@ fn run_codex_status(args: &Args) -> Result { struct NativeAuxiliaryStatus { heartbeat: Value, persona: Value, + bifrost_bridge: Value, void_memory: Value, } @@ -734,6 +737,7 @@ fn native_auxiliary_status(root: &Path) -> Result { "latestArtifacts": latest_artifacts, "availableActions": ["personaBubble", "characterTurn", "discordPersonaPost", "redditPersonaPost", "otherWorldPersonaRequest"], }); + let bifrost_bridge = bifrost_bridge_readiness(root); let void_memory = native_json( "epiphany-void-memory", &["status", "--config", "state/void-memory.toml"], @@ -743,10 +747,112 @@ fn native_auxiliary_status(root: &Path) -> Result { Ok(NativeAuxiliaryStatus { heartbeat, persona, + bifrost_bridge, void_memory, }) } +fn bifrost_bridge_readiness(root: &Path) -> Value { + let bifrost_root = root + .parent() + .map(|parent| parent.join("Bifrost")) + .unwrap_or_else(|| root.join("../Bifrost")); + let advertisement_tool = bifrost_root.join("tools").join("provider-advertisement.mjs"); + if !advertisement_tool.exists() { + return json!({ + "status": "unavailable", + "owner": "Bifrost", + "tool": advertisement_tool, + "note": "Bifrost provider advertisement tool was not found; Epiphany cannot infer outside-world bridge readiness locally.", + "privateStateExposed": false, + }); + } + + let output = Command::new("node") + .arg(&advertisement_tool) + .arg("print-surface") + .current_dir(&bifrost_root) + .output(); + let Ok(output) = output else { + return json!({ + "status": "unavailable", + "owner": "Bifrost", + "tool": advertisement_tool, + "note": "Failed to invoke Bifrost provider advertisement tool.", + "privateStateExposed": false, + }); + }; + if !output.status.success() { + return json!({ + "status": "unavailable", + "owner": "Bifrost", + "tool": advertisement_tool, + "note": format!("Bifrost provider advertisement failed: {}", String::from_utf8_lossy(&output.stderr)), + "privateStateExposed": false, + }); + } + + let parsed: Value = match serde_json::from_slice(&output.stdout) { + Ok(value) => value, + Err(error) => { + return json!({ + "status": "unavailable", + "owner": "Bifrost", + "tool": advertisement_tool, + "note": format!("Bifrost provider advertisement returned invalid JSON: {error}"), + "privateStateExposed": false, + }); + } + }; + let bridge = &parsed["stats"]["bridge"]; + let surfaces = bridge["surfaces"] + .as_array() + .cloned() + .unwrap_or_default() + .into_iter() + .map(|surface| { + let ready = surface["ready"].as_bool().unwrap_or(false); + let prepared = surface["prepared"].as_bool().unwrap_or(false); + json!({ + "id": surface["id"].clone(), + "label": surface["label"].clone(), + "status": if ready { "live" } else if prepared { "prepared" } else { "missing" }, + "ready": ready, + "prepared": prepared, + "authority": surface["authority"].clone(), + "credentialSource": surface["credentialSource"].clone(), + "note": surface["note"].clone(), + }) + }) + .collect::>(); + let ready_count = surfaces + .iter() + .filter(|surface| surface["ready"].as_bool().unwrap_or(false)) + .count(); + let prepared_count = surfaces + .iter() + .filter(|surface| { + surface["prepared"].as_bool().unwrap_or(false) + && !surface["ready"].as_bool().unwrap_or(false) + }) + .count(); + json!({ + "status": if bridge["ready"].as_bool().unwrap_or(false) { "live" } else if bridge["prepared"].as_bool().unwrap_or(false) { "prepared" } else { "unavailable" }, + "owner": "Bifrost", + "authority": "Bifrost owns outside-world crossing gates, bridge receipts, and readiness projection; Heimdall owns provider OAuth, account links, and capability truth; Epiphany consumes this as read-only bridge sight.", + "source": "Bifrost provider advertisement print-surface", + "tool": advertisement_tool, + "generatedAt": parsed["stats"]["generatedAt"].clone(), + "ready": bridge["ready"].clone(), + "prepared": bridge["prepared"].clone(), + "readySurfaceCount": ready_count, + "preparedSurfaceCount": prepared_count, + "surfaceCount": surfaces.len(), + "surfaces": surfaces, + "privateStateExposed": false, + }) +} + fn native_role_result( state: Option<&EpiphanyThreadState>, runtime_store: &Path, @@ -1413,6 +1519,7 @@ pub fn render_status(status: &Value) -> String { let coordinator = &status["coordinator"]; let heartbeat = &status["heartbeat"]; let persona = &status["persona"]; + let bifrost_bridge = &status["bifrostBridge"]; let planning_response = &status["planning"]; let planning_summary = &planning_response["summary"]; let checkpoint = &scene["investigationCheckpoint"]; @@ -1488,6 +1595,16 @@ pub fn render_status(status: &Value) -> String { "- latest content: {}", maybe(&latest_persona["content"], "none") ), + format!( + "- Bifrost bridge: {} ({}/{})", + maybe(&bifrost_bridge["status"], "unavailable"), + maybe(&bifrost_bridge["readySurfaceCount"], "0"), + maybe(&bifrost_bridge["surfaceCount"], "0") + ), + format!( + "- bridge surfaces: {}", + bifrost_bridge_surface_text(bifrost_bridge) + ), String::new(), "Planning".to_string(), format!( @@ -1794,3 +1911,23 @@ fn list_text(value: &Value, fallback: &str) -> String { } items.iter().map(text).collect::>().join(", ") } + +fn bifrost_bridge_surface_text(value: &Value) -> String { + let Some(items) = value["surfaces"].as_array() else { + return "none".to_string(); + }; + if items.is_empty() { + return "none".to_string(); + } + items + .iter() + .map(|surface| { + format!( + "{}={}", + maybe(&surface["id"], "unknown"), + maybe(&surface["status"], "unknown") + ) + }) + .collect::>() + .join(", ") +} diff --git a/notes/fresh-workspace-handoff.md b/notes/fresh-workspace-handoff.md index 7aad3ad2..cfe84048 100644 --- a/notes/fresh-workspace-handoff.md +++ b/notes/fresh-workspace-handoff.md @@ -41,6 +41,7 @@ remembers doctrine; the branch remembers the blade. - Bifrost's identity-provider, GitHub bridge/work-sync, Patreon support-intake, and bridge-ledger slice is now upstream truth on `GameCult/Bifrost` `main` at commit `72ffa0d` after the bridge chain through `f1f9171`: `POST /auth/bifrost/register` creates a Bifrost-owned identity without OAuth, signs in with the Bifrost cookie, leaves membership at `Authenticated`, and records `BifrostIdentity` / `NormalizedBifrostIdentity` on `UserAccount`. That native Bifrost identity is the default authenticating identity for GameCult services that accept Bifrost trust. GitHub is hooked in two ways: bridge mutations use `tools/bifrost-bridge.mjs github-draft-pr` / `github-pr-comment` with hosted Bifrost gate/receipts, and the hosted GitHub webhook path syncs issues, PRs, and reviews into Bifrost work/review state. GitHub and Heimdall sign-in paths now ensure new accounts also get a Bifrost identity; Heimdall still owns outside-provider OAuth, account association, token custody, grants, capability/account claims, and provider support normalization. Hosted Persona/agent Discord, Reddit, and temporary `Other` future-public-surface bridge actions now require the supplied Bifrost identity to normalize through Bifrost's native identity law, resolve to a registered `UserAccount.NormalizedBifrostIdentity`, have a linked `HeimdallAccountId` on that same account, and carry a Heimdall-shaped reference before Bifrost authorizes the outside-account crossing; named surfaces still require surface-shaped references. `tools/bifrost-bridge.mjs other-request` is now the generic receipt-only CLI mouth for future public worlds: it records `Other`/`Other` bridge actions through the hosted ledger, carries identity/Heimdall/Epiphany provenance, executes no provider transport, and fails closed without Bifrost bridge base URL/token unless an operator uses the explicit dry-run recovery hatch outside a dispatched turn. Patreon support is hooked through Heimdall-signed patronage intake, not Bifrost-owned Patreon OAuth: `/heimdall/patron-support/events` verifies Heimdall HMAC, resolves linked `HeimdallAccountId`, records `ExternalPatronProvider.Patreon` support, writes patron point transactions, and derives current patron tier snapshots. Verified after adding the Patreon endpoint proof with `DOTNET_ROLL_FORWARD=Major dotnet test tests\Bifrost.Web.Tests\Bifrost.Web.Tests.csproj --filter "FullyQualifiedName~PlatformEndpointsTests"`: 37 passed; previous bridge CLI/platform proof with `BridgeCliTests|PlatformEndpointsTests` passed 66. Follow-up Bifrost commit `718ae94` syncs the provider advertisement and Eve interface binding to the current bridge truth: `print` advertises bridge action ledger, GitHub webhooks, and patron support intake; `print-surface`/`print-binding` expose GitHub, Discord, Reddit, future-surface, and Heimdall patron-support capabilities; README quick-start now names `other-request`. Verified with provider advertisement print/surface/export plus `DOTNET_ROLL_FORWARD=Major dotnet test tests\Bifrost.Web.Tests\Bifrost.Web.Tests.csproj --filter "FullyQualifiedName~ProviderAdvertisementTests|FullyQualifiedName~BridgeCliTests"`: 32 passed. Post-push `git status --short --branch` in `E:\Projects\Bifrost` reported `main...origin/main` clean. - Bifrost commit `30e5945` strengthens the future-surface bridge law: hosted bridge actions now persist `TargetSurfaceName`, `other-request` sends it from `--surface-name`, and Bifrost rejects `Other` Persona/agent actions unless the request names the future surface and the Heimdall capability reference matches it, such as `heimdall:bluesky:*`. This makes Epiphany's generic Persona mouth a client-side purity seal over server-side law instead of a trust assumption. Verified with focused `PlatformEndpointsTests|BridgeCliTests|ProviderAdvertisementTests` passing 71 tests, provider print/surface/binding smokes, and a temporary CultCache advertisement export/readback path. - Bifrost commit `a474c28` exposes bridge surface readiness instead of a collapsed bridge yes/no. `tools/provider-advertisement.mjs print-surface` and `print-binding` now report per-surface rows: GitHub `live`, Patron `live` through Heimdall HMAC patron-support intake, Other `live` as receipt-only future-surface request, and Discord/Reddit `prepared` when local actuator credentials are not visible. The bridge metric warns when any prepared surface is not live, so Epiphany can treat Bifrost as the bridge oracle without guessing from its own environment. Verified with `DOTNET_ROLL_FORWARD=Major dotnet test tests\Bifrost.Web.Tests\Bifrost.Web.Tests.csproj --filter "FullyQualifiedName~ProviderAdvertisementTests"`: 2 passed, plus direct provider print/surface/binding smokes. +- Epiphany native status now reads that Bifrost bridge oracle directly. `epiphany-mvp-status` invokes Bifrost's provider advertisement `print-surface` read-only, exposes `bifrostBridge` in native/Codex status JSON, and the local wrapper `-Mode status` prints `bifrostBridge=`, ready counts, and compact per-surface rows. Verified with focused cargo build, direct native JSON status readback showing `status=prepared`, `ready=3/5`, `prepared=2`, `private=false`, and wrapper proof `local-20260622-171319-312-eb0f69bb` printing `github=live,discord=prepared,reddit=prepared,other=live,patron=live`. - Persona public mouth crossings now fail closed on missing or wrong-surface authority cargo before any Bifrost CLI invocation. `epiphany-persona-discord post` and `epiphany-persona-reddit post` require a Bifrost identity plus a Heimdall-backed `heimdall:discord:*` or `heimdall:reddit:*` capability/account reference, write blocked candidate artifacts with `missing-bifrost-identity`, `missing-heimdall-capability-ref`, or `wrong-heimdall-capability-surface`, and smokes prove the bridged path still carries identity, run/lane/agent, source, authority, and surface-shaped Heimdall provenance. Verified sequentially with `cargo run --manifest-path .\epiphany-core\Cargo.toml --bin epiphany-persona-discord -- smoke` and `cargo run --manifest-path .\epiphany-core\Cargo.toml --bin epiphany-persona-reddit -- smoke`. - Epiphany now has the matching generic Persona mouth for future Bifrost surfaces. `epiphany-persona-other` supports `draft`, `request`, `latest`, and `smoke`; records the same parent-side `epiphany.persona_speech_audit.v0` and CultMesh audit as the Discord/Reddit mouths; requires Bifrost identity plus a target-shaped Heimdall reference such as `heimdall:bluesky:*`; refuses missing bridge, missing identity, missing Heimdall reference, wrong-surface authority cargo, and repeated target saturation before transport; and invokes Bifrost `tools/bifrost-bridge.mjs other-request` with Epiphany run/lane/agent provenance when eligible. Native MVP status/coordinator Persona action lists expose `otherWorldPersonaRequest` beside Discord/Reddit, and the local wrapper build list includes the new binary. Verified with `epiphany-persona-other -- smoke`, Discord/Reddit Persona smokes, and focused `cargo check` for the touched binaries. `epiphany-mvp-status-smoke` could not run because the vendored `codex-app-server.exe` prerequisite was absent; rebuilding `codex-app-server` timed out twice without producing the binary. - The local operator wrapper now exposes the advertised Persona outside-world mouth actions directly: `-Mode persona-discord`, `-Mode persona-reddit`, and `-Mode persona-other`. These modes call the native mouth binaries, write shared `.epiphany-persona` artifacts plus CultMesh speech audits, skip the Codex app-server compatibility build, and leave Bifrost/Heimdall as the crossing authority. Native status/coordinator readback now merges Discord, Reddit, and Other latest Persona artifacts instead of advertising Reddit while only reading Discord/Other. Verified with focused `cargo build --manifest-path .\epiphany-core\Cargo.toml --bin epiphany-mvp-status --bin epiphany-mvp-coordinator --bin epiphany-persona-discord --bin epiphany-persona-reddit --bin epiphany-persona-other`, PowerShell parser proof for `tools/epiphany_local_run.ps1`, draft wrapper runs for all three modes, and `-Mode status` readback showing `personaBubble,characterTurn,discordPersonaPost,redditPersonaPost,otherWorldPersonaRequest` plus recent shared Persona artifacts. diff --git a/state/ledgers.msgpack b/state/ledgers.msgpack index 86657f3316fabc077aa1ddd7c5cdf0140a7253a6..ecdb3e95b65eb3ab70fbffe092c3f5ff771e4339 100644 GIT binary patch delta 489 zcmZ9Izb^zq6vyrDxd@3LAzURdk!b94yT=L1HG)Ed#Hn<%H}7sIVP?(D9x8=Gp~IO* zrJ@muLKG^A-k+h=E9^RV62&(&FZsUteCPXep8vSYKjf`GZ+5XTzw_3W>s@`Eu=XwM z?xdMHZDy=Q>1ij*ChC4_W^%W=fy-yV;FsJ&$@TqhuVk$2EF6EWL@WvkKLSoPYal31 zbgY1j1E>nF;yqNb#A;F~4S{5|jv$dx#!)HIp%igF>=+^`8jPZJ32mU%OyM4K4UuGA zyDFA7QpIVgv=D2R%?%&$FcKoc`Zf`rk*|(DDN9E$ooCEa)5eMZI;!vilLef8b0;Ej;%|eGLTi%FhDR_Ff z(0m$u)Qm6N{TEX=y^{`5Cb6p9U8X;57fO^$8xh?Ngc9 HR