Unify resident cognitive brake identity

This commit is contained in:
Meta Vens 2026-08-10 10:59:50 +01:00
commit 9bf985fc4a
6 changed files with 196 additions and 16 deletions

View file

@ -14,6 +14,7 @@ use epiphany_core::{
load_resident_self_state, observe_process_instance, pending_resident_self_acks,
prepare_resident_self_launch, publish_resident_provider_readiness,
recover_receipt_free_dead_coordinator_session,
resident_cognitive_runtime_id,
resident_prepared_launch_thread_id, resident_self_child_claim,
resident_self_grant_has_typed_request, resident_self_local_provider_status,
resident_self_typed_attempt_exists,
@ -78,7 +79,7 @@ fn main() -> Result<()> {
enqueue_resident_self_pressure(&args.state_store, pressure)?;
}
let mut state = load_resident_self_state(&args.state_store)?;
let mut ports = NativePorts::new(&args.policy);
let mut ports = NativePorts::new(&args.policy)?;
match args.command {
CommandKind::Once => {
let outcome = cycle(&args, &mut state, &mut ports, false)?;
@ -693,15 +694,17 @@ impl Args {
struct NativePorts<'a> {
policy: &'a ResidentSelfPolicy,
cognitive_runtime_id: String,
children: BTreeMap<u32, Child>,
}
impl<'a> NativePorts<'a> {
fn new(policy: &'a ResidentSelfPolicy) -> Self {
Self {
fn new(policy: &'a ResidentSelfPolicy) -> Result<Self> {
Ok(Self {
policy,
cognitive_runtime_id: resident_cognitive_runtime_id(&policy.runtime_store)?,
children: BTreeMap::new(),
}
})
}
}
@ -709,7 +712,7 @@ impl ResidentSelfPorts for NativePorts<'_> {
fn brake_engaged(&mut self) -> Result<bool> {
resident_self_brake_engaged(
&self.policy.local_verse_store,
&self.policy.release_runtime_id,
&self.cognitive_runtime_id,
)
}
@ -806,7 +809,7 @@ mod brake_tests {
use super::*;
#[test]
fn resident_self_uses_exact_release_runtime_brake_namespace() -> Result<()> {
fn brake_lookup_uses_the_exact_requested_runtime_namespace() -> Result<()> {
let temp = tempfile::tempdir()?;
let store = temp.path().join("verse.cc");
let mut brake =
@ -820,6 +823,64 @@ mod brake_tests {
Ok(())
}
#[test]
fn native_resident_uses_mounted_cognitive_runtime_for_braking() -> Result<()> {
let temp = tempfile::tempdir()?;
let runtime_store = temp.path().join("runtime.cc");
let verse_store = temp.path().join("verse.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 mut cognitive_brake =
epiphany_core::default_epiphany_cultmesh_swarm_brake("2026-08-10T00:00:00Z");
cognitive_brake.status = "engaged".into();
cognitive_brake.reason = "cognitive brake".into();
epiphany_core::write_epiphany_cultmesh_swarm_brake(
&verse_store,
"cognitive-runtime",
cognitive_brake,
)?;
let shared = temp.path().to_path_buf();
let policy = ResidentSelfPolicy {
workspace: shared.clone(),
coordinator_bin: shared.join("coordinator"),
model_runtime_bin: shared.join("model"),
tool_adapter_bin: shared.join("tool"),
runtime_store,
local_verse_store: verse_store,
agent_memory_store: shared.join("mind.cc"),
artifact_root: shared.join("artifacts"),
codex_home: shared.join("codex-home"),
mcp_config: shared.join("mcp.toml"),
model_provider: "test".into(),
max_steps: 1,
turn_timeout_seconds: 1,
cooldown_seconds: 1,
idle_sleep_seconds: 1,
failure_backoff_seconds: 1,
release_commit: "release-commit".into(),
release_manifest_digest: "sha256:release".into(),
release_store: shared.join("release.cc"),
release_runtime_id: "deployment-runtime".into(),
release_id: "sha256:release".into(),
release_witness_sha256: "sha256:witness".into(),
};
let mut ports = NativePorts::new(&policy)?;
assert_eq!(ports.cognitive_runtime_id, "cognitive-runtime");
assert!(ports.brake_engaged()?);
assert!(!resident_self_brake_engaged(
&policy.local_verse_store,
&policy.release_runtime_id,
)?);
Ok(())
}
#[test]
fn engaged_brake_does_not_touch_the_bifrost_provider_store() -> Result<()> {
let touched = std::cell::Cell::new(false);

View file

@ -302,6 +302,7 @@ pub struct ResidentCognitionReadinessProjection {
pub schema_version: String,
pub status: String,
pub runtime_id: Option<String>,
pub release_runtime_id: Option<String>,
pub release_id: Option<String>,
pub release_witness_sha256: Option<String>,
pub source_commit: Option<String>,
@ -345,6 +346,16 @@ pub fn derive_resident_cognition_readiness(
if let Err(error) = release.as_ref() {
reasons.push(format!("packaged release authentication failed: {error:#}"));
}
let cognitive_runtime_id =
match crate::resident_cognitive_runtime_id(&request.policy.runtime_store) {
Ok(runtime_id) => Some(runtime_id),
Err(error) => {
reasons.push(format!(
"mounted cognitive runtime identity is invalid: {error:#}"
));
None
}
};
let physical_stores_separate =
validate_resident_self_store_separation(request.resident_store, request.policy).is_ok()
&& distinct_physical_paths(request.heartbeat_store, request.resident_store);
@ -397,10 +408,9 @@ pub fn derive_resident_cognition_readiness(
(false, "unreadable".into())
}
};
let brake_engaged = resident_brake_engaged(
&request.policy.local_verse_store,
&request.policy.release_runtime_id,
);
let brake_engaged = cognitive_runtime_id.as_deref().is_some_and(|runtime_id| {
resident_brake_engaged(&request.policy.local_verse_store, runtime_id)
});
let workspace_ready = directory_ready(&request.policy.workspace);
if !workspace_ready {
reasons.push("workspace is absent, inaccessible, or read-only".into());
@ -415,6 +425,7 @@ pub fn derive_resident_cognition_readiness(
&& heartbeat_provider_fresh
&& resident_provider_fresh
&& resident_state_coherent
&& cognitive_runtime_id.is_some()
&& workspace_ready
&& credential_ready;
ResidentCognitionReadinessProjection {
@ -427,7 +438,8 @@ pub fn derive_resident_cognition_readiness(
"degraded"
}
.into(),
runtime_id: release.as_ref().ok().map(|value| value.runtime_id.clone()),
runtime_id: cognitive_runtime_id,
release_runtime_id: release.as_ref().ok().map(|value| value.runtime_id.clone()),
release_id: release.as_ref().ok().map(|value| value.release_id.clone()),
release_witness_sha256: release
.as_ref()
@ -958,6 +970,7 @@ mod tests {
schema_version: "epiphany.resident_cognition.readiness.v0".into(),
status: "warming".into(),
runtime_id: Some("epiphany-yggdrasil".into()),
release_runtime_id: Some("epiphany-release-yggdrasil".into()),
release_id: Some("release-1".into()),
release_witness_sha256: Some("sha256:witness".into()),
source_commit: Some("commit-1".into()),
@ -980,6 +993,72 @@ mod tests {
assert!(!json.contains("secret"));
}
#[test]
fn readiness_uses_mounted_cognitive_identity_for_projection_and_brake() -> Result<()> {
let temp = tempfile::tempdir()?;
let shared = temp.path().canonicalize()?;
let runtime_store = shared.join("runtime.cc");
let local_verse_store = shared.join("verse.cc");
crate::initialize_runtime_spine(
&runtime_store,
crate::RuntimeSpineInitOptions {
runtime_id: "cognitive-runtime".into(),
display_name: "Cognitive Runtime".into(),
created_at: "2026-08-10T00:00:00Z".into(),
},
)?;
crate::engage_epiphany_cultmesh_swarm_brake(
&local_verse_store,
"cognitive-runtime",
"identity split proof",
"soul",
"2026-08-10T00:00:01Z",
false,
)?;
let policy = ResidentSelfPolicy {
workspace: shared.clone(),
coordinator_bin: shared.join("coordinator"),
model_runtime_bin: shared.join("model"),
tool_adapter_bin: shared.join("tool"),
runtime_store,
local_verse_store,
agent_memory_store: shared.join("mind.cc"),
artifact_root: shared.join("artifacts"),
codex_home: shared.join("codex-home"),
mcp_config: shared.join("mcp.toml"),
model_provider: "test".into(),
max_steps: 1,
turn_timeout_seconds: 1,
cooldown_seconds: 1,
idle_sleep_seconds: 1,
failure_backoff_seconds: 1,
release_commit: "release-commit".into(),
release_manifest_digest: "sha256:release".into(),
release_store: shared.join("release.cc"),
release_runtime_id: "deployment-runtime".into(),
release_id: "sha256:release".into(),
release_witness_sha256: "sha256:witness".into(),
};
let heartbeat_store = shared.join("heartbeat.cc");
let resident_store = shared.join("resident.cc");
let projection = derive_resident_cognition_readiness(ResidentReadinessRequest {
release_store: &policy.release_store,
heartbeat_store: &heartbeat_store,
resident_store: &resident_store,
policy: &policy,
release_runtime_id: &policy.release_runtime_id,
release_id: &policy.release_id,
release_witness_sha256: &policy.release_witness_sha256,
now_millis: 0,
freshness_millis: 1,
});
assert_eq!(projection.runtime_id.as_deref(), Some("cognitive-runtime"));
assert!(projection.brake_engaged);
assert_eq!(projection.release_runtime_id, None);
Ok(())
}
#[test]
fn incoherent_or_reused_active_lease_is_not_ready() {
let mut reasons = Vec::new();

View file

@ -1319,8 +1319,14 @@ The live identity matrix is explicit:
- packaged-release witness runtime authenticates the binary publication;
- mounted runtime-store identity owns coordinator execution, request identity,
runtime mutation, and the coordinator's `--runtime-id`;
- local-Verse brake identity is the namespace read by the process using that
Verse store and must contain the canonical brake entry;
- 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;
- 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
observe the same kill switch;
- Persona feedback target identity belongs to the feedback crossing contract
and is not silently rewritten when cognition mounts a narrower runtime.

View file

@ -1,5 +1,39 @@
# Fresh workspace handoff
## Cognitive brake identity cut — 2026-08-10
Exact crash-atomic source `0e8cd91af1dae0b48c59a6c0985075279ee58a6b`
packaged without warnings as 24-binary release
`sha256-ff906f3850e3ceaf743ce330116d545d57efb3340a69da186d834392fa8f1dcf`
with witness
`sha256-ea0997317b82fae9117d96ef2cfc7289d0aa552405275b89160c4e30cb4fef2b`.
Independent packaged inspection passed. Construction took seven minutes after
the CultCache source hash invalidated the release graph. The first bootstrap
attempt refused before compilation because its local submodule URLs still
named the bundle mount; the corrected canonical-URL attempt is the accepted
package. Receipts are under `.epiphany-run/linux-package-0e8cd91a/`.
Do not start c006 from that release. Recovery preflight found that prepared
coordinator argv already uses the mounted cognitive runtime identity, but
resident `NativePorts` still read the local-Verse brake under release/provider
identity. Current source resolves the immutable mounted runtime identity once
and uses it for every resident brake observation, so resident and child share
one kill-switch namespace. Readiness now projects mounted cognition as
`runtimeId`, authenticated binary provenance as `releaseRuntimeId`, and reads
the same cognitive brake. Release identity remains binary/provider provenance;
Persona feedback target remains a crossing contract. Thirteen focused readiness
tests and all nine swarm-binary tests pass, including deliberate
`deployment-runtime` versus `cognitive-runtime` cases. Commit/package this
narrow correction before c006.
Recovery state is staged but inert in named volume
`epiphany-resident-c006-state`. Its resident snapshot comes from
`coordinator-session-live-5a479522`: heartbeat, top runtime, Eyes runtime, and
Eyes local-Verse hashes prove that copied run descended from c005's surviving
state. The snapshot records sleeping revision 6, both original grants terminal,
and one typed admitted-model-direction pressure pending. Derived provider
readiness will be republished. The zero file was not imported.
## Starfire reboot exposed non-atomic CultCache publication — 2026-08-10
Live c005 and the copied e97 Continuity harness independently lost only

Binary file not shown.

View file

@ -36,9 +36,9 @@ invariants:
current_status:
summary: Epiphany is a supervised engineering alpha on Starfire, not deployment-ready. Exact b8138a6b active-child SIGTERM and restart, exact 9f369528 deterministic warm packaging, exact c930f505 cross-container ownership, exact ed15f83a resident lifecycle retention, exact 16c4b19f coordinator receipt and Heartbeat artifact retention, exact cce2b8ac narrow model-generation retention, exact eea15e82 model-turn JSON ingress, exact b1e8c89a semantic unattempted-generation retention, exact 6bc3ec3f semantic physical-epoch retirement, and exact 44230a05 Persona conversation retention are proven. Gamecult-ops 059821f owns Yggdrasil stream retention and exact 6ee08a4 owns stable Starfire Persona-permit firewall ingress. Exact 16c4b19f genuine idle and exact a987d2f7 active cognition completed 900-pulse bounded plateaus. Runtime-owned typed fulfillment is accepted live under exact 6dd9b132. Yggdrasil is the small public crossing body, never the release forge.
latest_phase: Exact e97ee1fa receipt-free coordinator death recovery is committed, pushed, packaged, and warm-reproduced, but its copied-live kill proof exposed a lower storage wound. During the 2026-08-10 Starfire reboot, live c005 and the copied harness independently replaced resident-self.cc with all-zero files 0.563 seconds apart; c005 exited 255 and every sibling store remained nonzero. The corrupt c005 bytes and host/container receipts are immutable under .epiphany-run/interventions/c005-zero-store-20260810T091926Z. CultCache e8a9f2d cuts the delete-before-rename gap, flushes staged bytes, atomically replaces the destination, and syncs the Unix parent directory. Forty ordinary tests pass; exact Linux overlayfs and Starfire bind probes pass; thirty randomized bind SIGKILL/reopen passes and ten named-volume passes always decoded one complete typed snapshot. Epiphany dependency advance, exact packaging, and a new resident incarnation remain open; c005 must not restart.
latest_phase: Exact 0e8cd91a packages crash-atomic CultCache e8a9f2d as warning-free 24-binary release sha256-ff906f38 with witness sha256-ea099731; independent inspection passed. Recovery preflight then refused deployment because release/provider and mounted cognitive runtime identities still selected different brake namespaces. Current source makes NativePorts resolve mounted cognition once for actuation; readiness projects mounted cognition as runtimeId, authenticated binary provenance separately as releaseRuntimeId, and reads the same cognitive brake. Thirteen readiness tests and all nine swarm-binary tests pass with explicit deployment-runtime versus cognitive-runtime proofs. Recovery state is staged but inert in named volume epiphany-resident-c006-state from the authenticated c005-descended sleeping revision-6 snapshot; it retains two terminal historical grants and one typed pending model-direction pressure, and excludes the zero file. Commit and exact packaging of the identity correction remain open.
operational_state:
local_worktree: cultcache_crash_atomic_dependency_pending_root_commit
local_worktree: cognitive_brake_identity_cut_source_verified_pending_commit
operator_wireguard: restored
starfire_persona_permit_firewall: persistent_exact_gamecult_ops_6ee08a4
yggdrasil: canonical_small_public_crossing_body
@ -70,7 +70,7 @@ current_status:
yggdrasil_epiphany_service_contract: repaired_in_gamecult_ops_812b427_not_installed
resident_physiology: c005_exited_255_and_sealed_as_corruption_evidence
unresolved_authority: Coordinator receipt, Heartbeat pulse-artifact, deployed supervisor/projector log retention, genuine-idle and active resource plateaus, exact-grant terminality, restart-persistent cooldown refusal, schedule/action issuance cardinality, runtime-owned typed fulfillment, narrow model-generation retention, published model-turn JSON ingress, semantic logical/physical retention, Persona conversation retention, stable Starfire firewall ownership, completed model-adapter session archival, and normal coordinator lifecycle opening/error closure/legacy repair/archival are accepted live. Receipt-free hard-death recovery is source- and package-accepted but its live kill matrix remains unproven because the first copied run exposed non-atomic storage publication. A typed worker launch without valid terminal fulfillment deliberately remains active awaiting an owner for exact orphan-worker death and supersession; it is not retryable yet. Historical migrated semantic attempts without recorded physical namespace remain durable and non-retirable. Repository Body observation still performs two authenticated full-tree Git index/manifest passes. Execute-mode workers require a persistent process body. Mutable Starfire bind storage is not accepted as resident authority until the packaged CultCache repair and recovery replay pass. One completed Discord consequence remains blocked by the absent Yggdrasil credential.
next_action: Advance Epiphany to CultCache e8a9f2d, commit and push the exact dependency, package once with the persistent Starfire cache, and recover a new resident incarnation from surviving typed runtime/heartbeat/Mind/Body authority without importing the zero file. Prove no pending or terminal authority resurrects, one exact lifecycle completes, SIGTERM/restart remains clean, and copied receipt-free pre-open/opened deaths preserve a parseable store. Then map orphan-worker death/supersession. Yggdrasil never builds.
next_action: Integrate bounded Modeling review of the cognitive brake identity cut, commit and push it, then package once from the persistent Starfire cache. Start c006 only from that exact release against staged named-volume authority. Require Heartbeat to consume the historical terminal acknowledgement without reissuing either old grant, issue one new grant for the sole pending typed pressure, complete it once, and pass SIGTERM/restart plus parseable-store checks. Then resume copied receipt-free death and orphan-worker Continuity. Yggdrasil never builds.
active_subgoals:
- Prove Persona, Self, Eyes, Modeling, Imagination, Hands, Soul, Mind, Continuity, and nervous-system behavior individually.