From 8d92c8266b07a98b5c6b2e8d6bdbded5661e8cbb Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Mon, 10 Aug 2026 11:27:21 +0100 Subject: [PATCH] Bind Heartbeat braking to cognition --- .../src/bin/epiphany-heartbeat-store.rs | 62 ++++++++++++++---- notes/epiphany-current-algorithmic-map.md | 7 +- notes/fresh-workspace-handoff.md | 27 ++++++++ state/ledgers.msgpack | Bin 602360 -> 602816 bytes state/map.yaml | 6 +- 5 files changed, 84 insertions(+), 18 deletions(-) diff --git a/epiphany-core/src/bin/epiphany-heartbeat-store.rs b/epiphany-core/src/bin/epiphany-heartbeat-store.rs index 2e02a038..e19eae68 100644 --- a/epiphany-core/src/bin/epiphany-heartbeat-store.rs +++ b/epiphany-core/src/bin/epiphany-heartbeat-store.rs @@ -24,6 +24,7 @@ use epiphany_core::pulse_resident_self_heartbeat; use epiphany_core::pump_heartbeat_store; use epiphany_core::queue_heartbeat_pending_mention_store; use epiphany_core::recover_stale_heartbeat_store; +use epiphany_core::resident_cognitive_runtime_id; use epiphany_core::retain_heartbeat_pulse_artifacts; use epiphany_core::run_void_routine_store; use epiphany_core::tick_heartbeat_store; @@ -68,6 +69,7 @@ fn main() -> Result<()> { let mut limit = 8_usize; let mut agent_store: Option = None; let mut resident_self_store: Option = None; + let mut resident_runtime_store: Option = None; let mut apply_rumination = false; let mut profile = "epiphany".to_string(); let mut scene_id = "ghostlight.scene".to_string(); @@ -146,6 +148,9 @@ fn main() -> Result<()> { "--resident-self-store" => { resident_self_store = Some(next_path(&mut args, "--resident-self-store")?) } + "--resident-runtime-store" => { + resident_runtime_store = Some(next_path(&mut args, "--resident-runtime-store")?) + } "--apply-rumination" => apply_rumination = true, "--profile" => profile = next_value(&mut args, "--profile")?, "--scene-id" => scene_id = next_value(&mut args, "--scene-id")?, @@ -521,6 +526,11 @@ fn main() -> Result<()> { } else { None }; + let brake_runtime_id = heartbeat_brake_runtime_id( + &resident_self_store, + &resident_runtime_store, + release_runtime_id.as_deref(), + )?; if let Some(agent_store) = &agent_store { let errors = validate_agent_memory_store(agent_store)?; if !errors.is_empty() { @@ -572,13 +582,7 @@ fn main() -> Result<()> { )?; } let iteration_dir = artifact_dir.join(format!("pulse-{iteration:06}")); - let brake = active_swarm_brake( - &local_verse_store, - provider_release - .as_ref() - .map(|release| release.runtime_id.as_str()) - .or(release_runtime_id.as_deref()), - )?; + let brake = active_swarm_brake(&local_verse_store, brake_runtime_id.as_deref())?; if let Some(resident_store) = resident_self_store.as_deref() { let pulse = pulse_resident_self_heartbeat( &store_path, @@ -817,7 +821,7 @@ fn usage() -> Result<()> { " epiphany-heartbeat-store queue-mention --store [options]\n", " epiphany-heartbeat-store status --store [--artifact-dir ]\n", " epiphany-heartbeat-store routine --store --artifact-dir [options]\n", - " epiphany-heartbeat-store serve --store --artifact-dir [--local-verse-store ] [--agent-store ] [--source ] [--no-dream] [--interval-seconds ] [--max-iterations ]\n", + " epiphany-heartbeat-store serve --store --artifact-dir [--local-verse-store ] [--resident-self-store --resident-runtime-store ] [--agent-store ] [--source ] [--no-dream] [--interval-seconds ] [--max-iterations ]\n", " epiphany-heartbeat-store smoke [--agent-store ]" ))) } @@ -839,6 +843,20 @@ fn assert_swarm_brake_allows_heartbeat( Ok(()) } +fn heartbeat_brake_runtime_id( + resident_self_store: &Option, + resident_runtime_store: &Option, + release_runtime_id: Option<&str>, +) -> Result> { + if resident_self_store.is_some() { + let runtime_store = resident_runtime_store + .as_deref() + .ok_or_else(|| anyhow!("resident heartbeat serve requires --resident-runtime-store"))?; + return Ok(Some(resident_cognitive_runtime_id(runtime_store)?)); + } + Ok(release_runtime_id.map(str::to_string)) +} + fn active_swarm_brake( local_verse_store: &Option, runtime_id: Option<&str>, @@ -849,9 +867,8 @@ fn active_swarm_brake( if !local_verse_store.exists() { return Ok(None); } - let runtime_id = runtime_id.ok_or_else(|| { - anyhow!("heartbeat local Verse brake lookup requires --release-runtime-id") - })?; + let runtime_id = runtime_id + .ok_or_else(|| anyhow!("heartbeat local Verse brake lookup requires runtime identity"))?; Ok( load_epiphany_cultmesh_swarm_brake(local_verse_store, runtime_id)? .filter(|brake| brake.status == "engaged"), @@ -863,7 +880,7 @@ mod brake_tests { use super::*; #[test] - fn heartbeat_uses_exact_release_runtime_brake_namespace() -> Result<()> { + fn heartbeat_brake_lookup_uses_the_exact_requested_namespace() -> Result<()> { let temp = tempfile::tempdir()?; let store = temp.path().join("verse.cc"); let store_arg = Some(store.clone()); @@ -883,6 +900,27 @@ mod brake_tests { Ok(()) } + #[test] + fn resident_heartbeat_uses_mounted_cognitive_runtime_for_braking() -> Result<()> { + let temp = tempfile::tempdir()?; + let runtime_store = temp.path().join("runtime.cc"); + epiphany_core::initialize_runtime_spine( + &runtime_store, + epiphany_core::RuntimeSpineInitOptions { + runtime_id: "cognitive-runtime".into(), + display_name: "Cognitive runtime".into(), + created_at: "2026-08-10T00:00:00Z".into(), + }, + )?; + let selected = heartbeat_brake_runtime_id( + &Some(temp.path().join("resident.cc")), + &Some(runtime_store), + Some("deployment-runtime"), + )?; + assert_eq!(selected.as_deref(), Some("cognitive-runtime")); + Ok(()) + } + #[test] fn retention_receipt_projection_names_operator_fields() { let projection = retention_receipt_projection(&EpiphanyHeartbeatArtifactRetentionReceipt { diff --git a/notes/epiphany-current-algorithmic-map.md b/notes/epiphany-current-algorithmic-map.md index 1d37ca93..c74fbda7 100644 --- a/notes/epiphany-current-algorithmic-map.md +++ b/notes/epiphany-current-algorithmic-map.md @@ -1320,9 +1320,10 @@ The live identity matrix is explicit: - mounted runtime-store identity owns coordinator execution, request identity, runtime mutation, and the coordinator's `--runtime-id`; - mounted runtime-store identity also owns the local-Verse brake namespace for - resident Self and its coordinator child. `NativePorts` resolves that identity - once from the immutable runtime envelope; release/provider identity cannot - choose a second kill switch merely because it authenticated the binary; + Heartbeat scheduling, resident Self, and its coordinator child. Each resident + process resolves that identity from the immutable runtime envelope; + release/provider identity cannot choose a second kill switch merely because + it authenticated the binary; - cognition readiness projects mounted cognition as `runtimeId`, authenticated binary provenance separately as `releaseRuntimeId`, and reads the brake only under mounted cognition. Operator sight and resident actuation therefore diff --git a/notes/fresh-workspace-handoff.md b/notes/fresh-workspace-handoff.md index a2a54a95..6410ed16 100644 --- a/notes/fresh-workspace-handoff.md +++ b/notes/fresh-workspace-handoff.md @@ -1,5 +1,32 @@ # Fresh workspace handoff +## c006 recovery exposed Heartbeat identity and legacy-session residue — 2026-08-10 + +Exact `9bf985fc4ab5a7f75de26493ed6e122524c71775` packaged in 6m46s as +24-binary release `sha256-eedde4e6257dbf9ad700ad6a8793599504ae4b7bbf86147ced1275fa8596e9d3` +with witness `sha256-828949cd0a4ad865c5a43e68079f9b8db36d63b992a72d6f191b6c18bd241b73`. +Inspection passed and no warnings were emitted. + +c006 first refused before cognition because the copied runtime retained one +legacy active session ID reused across 24 unbound starts and 22 receipts. A +proposed latest-timestamp repair was rejected: timestamps cannot bind a receipt +to an incarnation. The exact pre-intervention runtime +`sha256-8aace759c246bd45b86c32cf0f15ce518eab12e2b2aa91f57a8dc764f5d08c84` +is preserved under +`.epiphany-run/interventions/c006-ambiguous-legacy-receipts/`. The stopped-volume +intervention removed the entire unbound session/start/receipt family under a +full-snapshot fence; exact packaged runtime parsing passed and no remaining +envelope references the legacy session. External typed receipt +`quarantine-receipt.json` records the cut. No guessed completion was created. + +c006 then started sleeping and stopped by SIGTERM with exit 0, but no Heartbeat +pulse was allowed: Heartbeat serve still selected the release runtime for its +brake. Current source requires `--resident-runtime-store`, resolves mounted +cognition for scheduling brake lookup, and retains release identity solely for +provider/binary authentication. Four Heartbeat binary tests pass, including a +deliberate deployment/cognitive identity split. Commit and package this final +identity cut before pulsing c006. + ## Cognitive brake identity cut — 2026-08-10 Exact crash-atomic source `0e8cd91af1dae0b48c59a6c0985075279ee58a6b` diff --git a/state/ledgers.msgpack b/state/ledgers.msgpack index e20e89fd60e6aef9c1b8589e379643acd7cff815..d29f6136d5812c59bddaa558dfd3469ccc578132 100644 GIT binary patch delta 490 zcmXv~yH3ME5X9k`h7LhNu@aOxu}xxLKY&C_MYq0eoCEvp+?@ldQXs(xK!k)u!5<(| zAUZ1kgMx}5pk&Vq#ptwqGqbb%`?dY?z5TN0t%kv2w0qcz&pzjx;nVAuH}t%l>uKY5 z+VB|eoo6gC78y&7WyZ?ew9yo;wfpxdh+;q3_ru`y-|OyqePi+{f*^*BQWRq_WQ;5n zNM%WnNLg2unvAP@KvyU%m;pxJ*xyGKwAVcVT`@1G9nf@6!ZNQ?rl?d8T-#X8Oa3ZR z>K#Dt4lC5i62(j#4+z{GO{_|4Rp`%Rw4;vCa&6mDWj22Jf#&Aq2uc(e zn6l9<1UEFR!LlvKt})rmgUtN+nC<`_NTfnN M2Fuqm9NC!GA7{p`5C8xG delta 72 zcmX@`ROQD*l?|edd