From 05f11df79ac3198b61059a460b7683955be62b3f Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Wed, 15 Jul 2026 07:33:00 +0100 Subject: [PATCH] Publish semantic health as powerless sight --- .../src/bin/epiphany-memory-semantic.rs | 70 +- epiphany-core/src/bin/epiphany-verse-query.rs | 81 ++- epiphany-core/src/cultmesh_integration.rs | 631 ++++++++++++++++++ epiphany-core/src/lib.rs | 7 + .../src/memory_graph/semantic_projector.rs | 128 +++- notes/fresh-workspace-handoff.md | 21 +- ...graph-semantic-projection-authority-map.md | 34 + state/ledgers.msgpack | Bin 498165 -> 498768 bytes state/map.yaml | 2 +- 9 files changed, 962 insertions(+), 12 deletions(-) diff --git a/epiphany-core/src/bin/epiphany-memory-semantic.rs b/epiphany-core/src/bin/epiphany-memory-semantic.rs index 8ec746d7..9ea980d3 100644 --- a/epiphany-core/src/bin/epiphany-memory-semantic.rs +++ b/epiphany-core/src/bin/epiphany-memory-semantic.rs @@ -3,8 +3,9 @@ use epiphany_core::{ EpiphanyMemoryContextQuery, EpiphanyMemoryGraphSnapshot, MemorySemanticIndexConfig, MemorySemanticProjectionInput, SemanticPartition, agent_memory_semantic_projection_input, execute_memory_semantic_projection, load_memory_graph_snapshot, - load_memory_semantic_projection_readiness, runtime_modeling_semantic_projection_input, - semantic_memory_context, + load_memory_semantic_projection_readiness, + publish_epiphany_cultmesh_semantic_projection_health, + runtime_modeling_semantic_projection_input, semantic_memory_context, }; use std::env; use std::path::PathBuf; @@ -25,6 +26,21 @@ fn main() -> Result<()> { execute_memory_semantic_projection(source_store, &input, executor_id, &config)?; print_receipt(&receipt, source_store)?; } + "health" => { + let (input, source_store) = options.load_projection_input()?; + let verse_store = options + .local_verse_store + .as_ref() + .ok_or_else(|| usage_error("health requires --local-verse-store "))?; + let health = publish_epiphany_cultmesh_semantic_projection_health( + verse_store, + options.runtime_id.clone(), + source_store, + &input, + options.provider_incarnation()?, + )?; + print_semantic_health(&health)?; + } "context" => { let (snapshot, swarm_id) = options.load_source()?; let text = options @@ -67,6 +83,9 @@ struct Options { runtime_store: Option, agent_store: Option, executor_id: Option, + local_verse_store: Option, + runtime_id: String, + provider_incarnation: Option, swarm_id: Option, partition: SemanticPartition, text: Option, @@ -82,6 +101,9 @@ impl Options { runtime_store: None, agent_store: None, executor_id: None, + local_verse_store: None, + runtime_id: "epiphany-memory-semantic".to_string(), + provider_incarnation: None, swarm_id: None, partition: SemanticPartition::Modeling, text: None, @@ -100,6 +122,9 @@ impl Options { "--runtime-store" => options.runtime_store = Some(PathBuf::from(value()?)), "--agent-store" => options.agent_store = Some(PathBuf::from(value()?)), "--executor-id" => options.executor_id = Some(value()?), + "--local-verse-store" => options.local_verse_store = Some(PathBuf::from(value()?)), + "--runtime-id" => options.runtime_id = value()?, + "--provider-incarnation" => options.provider_incarnation = Some(value()?), "--swarm-id" => options.swarm_id = Some(value()?), "--partition" => options.partition = parse_partition(&value()?)?, "--text" => options.text = Some(value()?), @@ -184,6 +209,15 @@ impl Options { fn source_store(&self) -> Option<&PathBuf> { self.runtime_store.as_ref().or(self.agent_store.as_ref()) } + + fn provider_incarnation(&self) -> Result<&str> { + self.provider_incarnation + .as_deref() + .filter(|value| !value.trim().is_empty()) + .ok_or_else(|| { + usage_error("CultMesh health publication requires --provider-incarnation ") + }) + } } fn parse_partition(value: &str) -> Result { @@ -201,7 +235,7 @@ fn parse_profile(value: &str) -> Result { fn usage_error(message: &str) -> anyhow::Error { anyhow!( - "{message}\nusage: epiphany-memory-semantic (--runtime-store |--agent-store |--graph-store ) [--swarm-id ] --partition [--executor-id ] [--text ] [--query-id ] [--budget ] [--profile ]" + "{message}\nusage: epiphany-memory-semantic (--runtime-store |--agent-store |--graph-store ) [--swarm-id ] --partition [--executor-id ] [--local-verse-store --runtime-id --provider-incarnation ] [--text ] [--query-id ] [--budget ] [--profile ]" ) } @@ -234,3 +268,33 @@ fn print_receipt( "indexedAt": receipt.indexed_at, })) } + +fn print_semantic_health( + health: &epiphany_core::EpiphanyCultMeshSemanticProjectionHealthEntry, +) -> Result<()> { + print_json(&serde_json::json!({ + "schemaVersion": health.schema_version, + "verseId": health.verse_id, + "verseTier": health.verse_tier, + "swarmId": health.swarm_id, + "partition": health.partition, + "obligationId": health.obligation_id, + "sourceGeneration": health.source_generation, + "canonicalModelHash": health.canonical_model_hash, + "canonicalContentSetHash": health.canonical_content_set_hash, + "status": health.status, + "receiptId": health.receipt_id, + "indexedDocumentCount": health.indexed_document_count, + "vectorDimensions": health.vector_dimensions, + "observedAt": health.observed_at, + "observedSourceAt": health.observed_source_at, + "providerId": health.provider_id, + "providerIncarnation": health.provider_incarnation, + "authoritative": health.authoritative, + "nonAuthoritative": !health.authoritative, + "authority": "sight-only", + "queryAdmission": false, + "queryEligibleDisplayOnly": health.query_eligible_display_only, + "privateStateExposed": health.private_state_exposed, + })) +} diff --git a/epiphany-core/src/bin/epiphany-verse-query.rs b/epiphany-core/src/bin/epiphany-verse-query.rs index 92bdc985..a5cd0592 100644 --- a/epiphany-core/src/bin/epiphany-verse-query.rs +++ b/epiphany-core/src/bin/epiphany-verse-query.rs @@ -31,6 +31,7 @@ use epiphany_core::EpiphanyCultMeshRepoWorkMapEntry; use epiphany_core::EpiphanyCultMeshRepoWorkOverviewEntry; use epiphany_core::EpiphanyCultMeshRepoWorkPublicProofEntry; use epiphany_core::EpiphanyCultMeshRepoWorkReadinessEntry; +use epiphany_core::EpiphanyCultMeshSemanticProjectionHealthEntry; use epiphany_core::EpiphanyCultMeshSwarmBrakeEntry; use epiphany_core::EpiphanyCultMeshWorkLoopTelemetryEntry; use epiphany_core::EpiphanyLocalVerseContext; @@ -64,6 +65,7 @@ use epiphany_core::load_epiphany_cultmesh_repo_work_map_entries; use epiphany_core::load_epiphany_cultmesh_repo_work_overviews; use epiphany_core::load_epiphany_cultmesh_repo_work_public_proofs; use epiphany_core::load_epiphany_cultmesh_repo_work_readiness_reports; +use epiphany_core::load_epiphany_cultmesh_semantic_projection_health; use epiphany_core::load_epiphany_cultmesh_status; use epiphany_core::load_epiphany_cultmesh_swarm_brake; use epiphany_core::load_latest_epiphany_cultmesh_agent_state_soa_summary; @@ -292,6 +294,38 @@ fn run_cli() -> Result<()> { let context = query_epiphany_local_verse_context(&args.store, args.runtime_id.clone())?; println!("{}", serde_json::to_string_pretty(&context)?); } + "semantic-health" | "semantic-projection-health" => { + if !args.store.exists() { + anyhow::bail!("local Verse semantic health is absent"); + } + let rows = load_epiphany_cultmesh_semantic_projection_health( + &args.store, + args.runtime_id.clone(), + )?; + let tui_rows = rows + .iter() + .map(semantic_projection_health_tui_row) + .collect::>(); + let report_rows = rows + .iter() + .map(semantic_projection_health_report_row) + .collect::>(); + println!( + "{}", + serde_json::to_string_pretty(&json!({ + "schemaVersion": "epiphany.cultmesh.semantic_projection_health_report.v0", + "status": if rows.is_empty() { "unknown" } else if rows.iter().all(|row| row.status == "ready") { "observed-ready" } else { "observed-attention" }, + "rowCount": rows.len(), + "readyCount": rows.iter().filter(|row| row.status == "ready").count(), + "privateStateExposed": false, + "authoritative": false, + "authority": "sight-only", + "queryAdmission": false, + "rows": report_rows, + "tuiRows": tui_rows, + }))? + ); + } "receipt-directory" | "receipts" | "evidence-directory" => { let context = query_epiphany_local_verse_context(&args.store, args.runtime_id.clone())?; let lifecycle_receipts = load_epiphany_cultmesh_daemon_service_lifecycle_receipts( @@ -2840,7 +2874,7 @@ fn run_cli() -> Result<()> { ); } other => anyhow::bail!( - "unknown command {other:?}; use seed, query, tools, tool-directory, invoke-tool, restart-policy-directory, swarm-brake, swarm-status, swarm-overview, swarm-triage, managed-services, cluster-topology, eve-surfaces, agent-state, agent-state-report, poke-daemon, poke-down-daemons, bifrost-publication, bifrost-public-proof, bifrost-artifact-acceptance, bifrost-metrics, bifrost-ledger, collaboration-feedback, connect-eve, or smoke" + "unknown command {other:?}; use seed, query, semantic-health, tools, tool-directory, invoke-tool, restart-policy-directory, swarm-brake, swarm-status, swarm-overview, swarm-triage, managed-services, cluster-topology, eve-surfaces, agent-state, agent-state-report, poke-daemon, poke-down-daemons, bifrost-publication, bifrost-public-proof, bifrost-artifact-acceptance, bifrost-metrics, bifrost-ledger, collaboration-feedback, connect-eve, or smoke" ), } Ok(()) @@ -2852,6 +2886,51 @@ struct DaemonLivenessReport { non_ready_count: usize, } +fn semantic_projection_health_tui_row( + row: &EpiphanyCultMeshSemanticProjectionHealthEntry, +) -> String { + format!( + "SEMANTIC-HEALTH swarm={} partition={} generation={} status=observed-{} documents={} dimensions={} provider={} incarnation={} authority=sight-only query-admission=false private=false", + row.swarm_id, + row.partition, + row.source_generation, + row.status, + row.indexed_document_count + .map_or_else(|| "-".to_string(), |value| value.to_string()), + row.vector_dimensions + .map_or_else(|| "-".to_string(), |value| value.to_string()), + row.provider_id, + row.provider_incarnation, + ) +} + +fn semantic_projection_health_report_row( + row: &EpiphanyCultMeshSemanticProjectionHealthEntry, +) -> serde_json::Value { + json!({ + "swarmId": row.swarm_id, + "partition": row.partition, + "obligationId": row.obligation_id, + "sourceGeneration": row.source_generation, + "canonicalModelHash": row.canonical_model_hash, + "canonicalContentSetHash": row.canonical_content_set_hash, + "status": row.status, + "receiptId": row.receipt_id, + "indexedDocumentCount": row.indexed_document_count, + "vectorDimensions": row.vector_dimensions, + "observedAt": row.observed_at, + "observedSourceAt": row.observed_source_at, + "providerId": row.provider_id, + "providerIncarnation": row.provider_incarnation, + "authoritative": row.authoritative, + "nonAuthoritative": !row.authoritative, + "authority": "sight-only", + "queryAdmission": false, + "queryEligibleDisplayOnly": row.query_eligible_display_only, + "privateStateExposed": row.private_state_exposed, + }) +} + fn agent_state_soa_tui_rows(summary: &EpiphanyCultMeshAgentStateSoaSummaryEntry) -> Vec { summary .role_ids diff --git a/epiphany-core/src/cultmesh_integration.rs b/epiphany-core/src/cultmesh_integration.rs index 19043ed8..d57c7791 100644 --- a/epiphany-core/src/cultmesh_integration.rs +++ b/epiphany-core/src/cultmesh_integration.rs @@ -11,6 +11,7 @@ use anyhow::anyhow; use chrono::DateTime; use chrono::FixedOffset; use chrono::Utc; +use cultcache_rs::CacheBackingStore; use cultcache_rs::CultSoaColumnValues; use cultcache_rs::DatabaseEntry; use cultcache_rs::SingleFileMessagePackBackingStore; @@ -269,6 +270,58 @@ pub const EPIPHANY_CULTMESH_GLOBAL_VERSE_ID: &str = "epiphany-global"; pub const EPIPHANY_CULTMESH_INTERNAL_TIER: &str = "internal"; pub const EPIPHANY_CULTMESH_LOCAL_AREA_TIER: &str = "local-area"; pub const EPIPHANY_CULTMESH_GLOBAL_TIER: &str = "global"; +pub const EPIPHANY_CULTMESH_SEMANTIC_PROJECTION_HEALTH_TYPE: &str = + "epiphany.cultmesh.semantic_projection_health"; +pub const EPIPHANY_CULTMESH_SEMANTIC_PROJECTION_HEALTH_SCHEMA_VERSION: &str = + "epiphany.cultmesh.semantic_projection_health.v0"; + +#[derive(Clone, Debug, PartialEq, Eq, DatabaseEntry)] +#[cultcache( + type = "epiphany.cultmesh.semantic_projection_health", + schema = "EpiphanyCultMeshSemanticProjectionHealthEntry" +)] +pub struct EpiphanyCultMeshSemanticProjectionHealthEntry { + #[cultcache(key = 0)] + pub schema_version: String, + #[cultcache(key = 1)] + pub verse_id: String, + #[cultcache(key = 2)] + pub verse_tier: String, + #[cultcache(key = 3)] + pub swarm_id: String, + #[cultcache(key = 4)] + pub partition: String, + #[cultcache(key = 5)] + pub obligation_id: String, + #[cultcache(key = 6)] + pub source_generation: u64, + #[cultcache(key = 7)] + pub canonical_model_hash: String, + #[cultcache(key = 8)] + pub canonical_content_set_hash: String, + #[cultcache(key = 9)] + pub status: String, + #[cultcache(key = 10)] + pub receipt_id: Option, + #[cultcache(key = 11)] + pub indexed_document_count: Option, + #[cultcache(key = 12)] + pub vector_dimensions: Option, + #[cultcache(key = 13)] + pub observed_at: String, + #[cultcache(key = 14)] + pub private_state_exposed: bool, + #[cultcache(key = 15)] + pub provider_id: String, + #[cultcache(key = 16)] + pub provider_incarnation: String, + #[cultcache(key = 17)] + pub observed_source_at: String, + #[cultcache(key = 18)] + pub authoritative: bool, + #[cultcache(key = 19)] + pub query_eligible_display_only: bool, +} #[derive(Clone, Debug, PartialEq, Eq, DatabaseEntry)] #[cultcache( @@ -2560,6 +2613,7 @@ cultmesh_documents!(EpiphanyCultMeshDocuments { EpiphanyCultMeshBifrostMetricsReceiptEntry => EPIPHANY_CULTMESH_BIFROST_METRICS_RECEIPT_SCHEMA_VERSION, EpiphanyCultMeshBifrostCollaborationFeedbackEntry => EPIPHANY_CULTMESH_BIFROST_COLLABORATION_FEEDBACK_SCHEMA_VERSION, EpiphanyCultMeshImaginationConsensusReceiptEntry => EPIPHANY_CULTMESH_IMAGINATION_CONSENSUS_RECEIPT_SCHEMA_VERSION, + EpiphanyCultMeshSemanticProjectionHealthEntry => EPIPHANY_CULTMESH_SEMANTIC_PROJECTION_HEALTH_SCHEMA_VERSION, }); pub fn open_epiphany_cultmesh_node( @@ -2576,6 +2630,189 @@ pub fn open_epiphany_cultmesh_node( ) } +fn semantic_projection_health_scope_key(swarm_id: &str, partition: &str) -> String { + use sha2::{Digest, Sha256}; + format!( + "gamecult-local/semantic-projection-health/{:x}", + Sha256::digest(format!("{swarm_id}|{partition}").as_bytes()) + ) +} + +/// Publishes operator sight derived from authenticated canonical projection state. +/// +/// This mirror is deliberately powerless: it neither creates work nor participates +/// in semantic-query admission. Callers must retain the canonical source store and +/// sealed input for either operation. +pub fn publish_epiphany_cultmesh_semantic_projection_health( + verse_store: impl AsRef, + runtime_id: impl Into, + canonical_store: impl AsRef, + input: &crate::MemorySemanticProjectionInput, + provider_incarnation: &str, +) -> Result { + let runtime_id = runtime_id.into(); + if !bounded_opaque_health_id(&runtime_id) || !bounded_opaque_health_id(provider_incarnation) { + return Err(anyhow!( + "semantic projection health provider identity is required" + )); + } + let observation = crate::observe_memory_semantic_projection(canonical_store, input)?; + let entry = EpiphanyCultMeshSemanticProjectionHealthEntry { + schema_version: EPIPHANY_CULTMESH_SEMANTIC_PROJECTION_HEALTH_SCHEMA_VERSION.to_string(), + verse_id: EPIPHANY_CULTMESH_LOCAL_AREA_VERSE_ID.to_string(), + verse_tier: EPIPHANY_CULTMESH_LOCAL_AREA_TIER.to_string(), + swarm_id: observation.swarm_id, + partition: observation.partition, + obligation_id: observation.obligation_id, + source_generation: observation.source_generation, + canonical_model_hash: observation.canonical_model_hash, + canonical_content_set_hash: observation.canonical_content_set_hash, + status: observation.status, + receipt_id: observation.receipt_id, + indexed_document_count: observation.indexed_document_count, + vector_dimensions: observation.vector_dimensions, + observed_at: Utc::now().to_rfc3339(), + private_state_exposed: false, + provider_id: runtime_id.clone(), + provider_incarnation: provider_incarnation.to_string(), + observed_source_at: observation.observed_source_at, + authoritative: false, + query_eligible_display_only: observation.query_eligible_display_only, + }; + validate_semantic_projection_health(&entry)?; + + let scope_key = semantic_projection_health_scope_key(&entry.swarm_id, &entry.partition); + let latest_key = format!("{scope_key}/latest"); + use sha2::{Digest, Sha256}; + let event_key = format!( + "{scope_key}/event-{:x}", + Sha256::digest( + format!( + "{}|{}|{}|{}", + entry.obligation_id, + entry.status, + entry.receipt_id.as_deref().unwrap_or("none"), + entry.observed_at + ) + .as_bytes() + ) + ); + let node = open_epiphany_cultmesh_node(&verse_store, runtime_id)?; + let backing = SingleFileMessagePackBackingStore::new(verse_store.as_ref()); + for _ in 0..8 { + let opening = backing.pull_all()?; + let latest_envelope = opening.iter().find(|row| { + row.r#type == EPIPHANY_CULTMESH_SEMANTIC_PROJECTION_HEALTH_TYPE && row.key == latest_key + }); + let latest = latest_envelope + .map(|row| { + rmp_serde::from_slice::(&row.payload) + }) + .transpose()?; + if let Some(latest) = &latest { + validate_semantic_projection_health(latest)?; + let latest_time = DateTime::parse_from_rfc3339(&latest.observed_source_at)?; + let entry_time = DateTime::parse_from_rfc3339(&entry.observed_source_at)?; + if latest.source_generation == entry.source_generation + && latest.obligation_id != entry.obligation_id + { + return Err(anyhow!( + "semantic projection health generation has conflicting canonical obligations" + )); + } + if latest.source_generation > entry.source_generation + || (latest.source_generation == entry.source_generation && latest_time > entry_time) + { + return Ok(latest.clone()); + } + } + let event = node.cache().prepare_entry(&event_key, &entry)?.0; + let latest_replacement = node.cache().prepare_entry(&latest_key, &entry)?.0; + let expected = latest_envelope.cloned().into_iter().collect::>(); + if backing.compare_and_swap_batch(&expected, vec![event, latest_replacement])? { + return Ok(entry); + } + } + Err(anyhow!( + "semantic projection health latest advanced during publication" + )) +} + +pub fn load_epiphany_cultmesh_semantic_projection_health( + verse_store: impl AsRef, + runtime_id: impl Into, +) -> Result> { + let node = open_epiphany_cultmesh_node(verse_store, runtime_id)?; + let mut rows = node + .get_all_with_keys::()? + .into_iter() + .filter(|(key, _)| key.ends_with("/latest")) + .map(|(key, row)| { + let expected_key = format!( + "{}/latest", + semantic_projection_health_scope_key(&row.swarm_id, &row.partition) + ); + if key != expected_key { + return Err(anyhow!( + "semantic projection health latest key does not match its declared scope" + )); + } + Ok(row) + }) + .collect::>>()?; + for row in &rows { + validate_semantic_projection_health(row)?; + } + rows.sort_by(|left, right| { + left.swarm_id + .cmp(&right.swarm_id) + .then(left.partition.cmp(&right.partition)) + }); + Ok(rows) +} + +fn validate_semantic_projection_health( + row: &EpiphanyCultMeshSemanticProjectionHealthEntry, +) -> Result<()> { + if row.schema_version != EPIPHANY_CULTMESH_SEMANTIC_PROJECTION_HEALTH_SCHEMA_VERSION + || row.verse_id != EPIPHANY_CULTMESH_LOCAL_AREA_VERSE_ID + || row.verse_tier != EPIPHANY_CULTMESH_LOCAL_AREA_TIER + || row.swarm_id.trim().is_empty() + || !matches!(row.partition.as_str(), "mind" | "modeling") + || row.obligation_id.trim().is_empty() + || row.canonical_model_hash.trim().is_empty() + || row.canonical_content_set_hash.trim().is_empty() + || !matches!(row.status.as_str(), "pending" | "failed" | "ready") + || DateTime::parse_from_rfc3339(&row.observed_at).is_err() + || DateTime::parse_from_rfc3339(&row.observed_source_at).is_err() + || row.private_state_exposed + || !bounded_opaque_health_id(&row.provider_id) + || !bounded_opaque_health_id(&row.provider_incarnation) + || row.authoritative + { + return Err(anyhow!("semantic projection health mirror is invalid")); + } + let has_receipt = row.receipt_id.is_some() + && row.indexed_document_count.is_some() + && row.vector_dimensions.is_some(); + if row.query_eligible_display_only != (row.status == "ready") + || has_receipt != (row.status == "ready") + { + return Err(anyhow!( + "semantic projection health evidence shape is invalid" + )); + } + Ok(()) +} + +fn bounded_opaque_health_id(value: &str) -> bool { + !value.is_empty() + && value.len() <= 128 + && value + .bytes() + .all(|byte| byte.is_ascii_alphanumeric() || matches!(byte, b'.' | b'_' | b'-' | b':')) +} + pub fn write_epiphany_cultmesh_status( store_path: impl AsRef, status: EpiphanyCultMeshStatusEntry, @@ -7226,8 +7463,402 @@ pub fn write_epiphany_cultmesh_bifrost_contracts( #[cfg(test)] mod tests { use super::*; + use cultcache_rs::CacheBackingStore; use pretty_assertions::assert_eq; + fn semantic_health_input( + store: &Path, + swarm_id: &str, + partition: &str, + generation: u64, + ) -> Result { + let graph_id = format!("{partition}-graph"); + let obligation = crate::MemorySemanticProjectionObligation { + schema_version: crate::MEMORY_SEMANTIC_PROJECTION_OBLIGATION_SCHEMA_VERSION.to_string(), + obligation_id: format!("obligation-{partition}-{generation}"), + swarm_id: swarm_id.to_string(), + partition: partition.to_string(), + canonical_source_id: format!("canonical/{partition}"), + source_commit_id: format!("commit-{generation}"), + graph_id: graph_id.clone(), + source_generation: generation, + source_model_hash: format!("model-{generation}"), + canonical_content_set_hash: format!("content-{generation}"), + projection_schema_version: crate::SEMANTIC_PROJECTION_SCHEMA_VERSION.to_string(), + created_at: "2026-07-15T12:00:00Z".to_string(), + }; + let head = crate::MemorySemanticProjectionSourceHead { + swarm_id: swarm_id.to_string(), + partition: partition.to_string(), + canonical_source_id: format!("canonical/{partition}"), + source_commit_id: format!("commit-{generation}"), + graph_id: graph_id.clone(), + source_generation: generation, + source_model_hash: format!("model-{generation}"), + canonical_content_set_hash: format!("content-{generation}"), + }; + let mut cache = crate::memory_graph::semantic_projector::semantic_projector_cache(store)?; + cache.put(&obligation.obligation_id, &obligation)?; + let envelopes = SingleFileMessagePackBackingStore::new(store).pull_all()?; + let authority = envelopes + .into_iter() + .find(|row| { + row.r#type == "gamecult.epiphany.memory_semantic_projection_obligation" + && row.key == obligation.obligation_id + }) + .expect("persisted obligation envelope"); + Ok(crate::MemorySemanticProjectionInput { + snapshot: crate::EpiphanyMemoryGraphSnapshot { + schema_version: Some("v0".to_string()), + graph_id, + model_revision: generation, + ..Default::default() + }, + obligation, + authority: + crate::memory_graph::semantic_projector::MemorySemanticProjectionAuthoritySnapshot { + head, + envelopes: vec![authority], + }, + }) + } + + #[test] + fn semantic_health_publication_is_monotonic_partitioned_sight_only() -> Result<()> { + let temp = tempfile::tempdir()?; + let canonical = temp.path().join("canonical.msgpack"); + let verse = temp.path().join("verse.ccmp"); + let modeling_1 = semantic_health_input(&canonical, "swarm-a", "modeling", 1)?; + let modeling_2 = semantic_health_input(&canonical, "swarm-a", "modeling", 2)?; + let mind_1 = semantic_health_input(&canonical, "swarm-a", "mind", 1)?; + let before = SingleFileMessagePackBackingStore::new(&canonical).pull_all()?; + + publish_epiphany_cultmesh_semantic_projection_health( + &verse, + "runtime", + &canonical, + &modeling_1, + "incarnation-a", + )?; + publish_epiphany_cultmesh_semantic_projection_health( + &verse, + "runtime", + &canonical, + &modeling_2, + "incarnation-a", + )?; + let delayed = publish_epiphany_cultmesh_semantic_projection_health( + &verse, + "runtime", + &canonical, + &modeling_1, + "incarnation-a", + )?; + publish_epiphany_cultmesh_semantic_projection_health( + &verse, + "runtime", + &canonical, + &mind_1, + "incarnation-a", + )?; + + assert_eq!(delayed.source_generation, 2); + let rows = load_epiphany_cultmesh_semantic_projection_health(&verse, "runtime")?; + assert_eq!(rows.len(), 2); + assert_eq!(rows[0].partition, "mind"); + assert_eq!(rows[1].partition, "modeling"); + assert_eq!(rows[1].source_generation, 2); + assert!(rows.iter().all(|row| !row.private_state_exposed)); + assert_eq!( + SingleFileMessagePackBackingStore::new(&canonical).pull_all()?, + before, + "publishing sight must not create canonical projection work" + ); + Ok(()) + } + + #[test] + fn semantic_health_rejects_older_conflicting_obligation_for_same_generation() -> Result<()> { + let temp = tempfile::tempdir()?; + let canonical = temp.path().join("canonical.msgpack"); + let verse = temp.path().join("verse.ccmp"); + let mut latest = semantic_health_input(&canonical, "swarm-a", "modeling", 2)?; + latest.obligation.created_at = "2026-07-15T12:02:00Z".to_string(); + let mut cache = + crate::memory_graph::semantic_projector::semantic_projector_cache(&canonical)?; + cache.put(&latest.obligation.obligation_id, &latest.obligation)?; + latest.authority.envelopes = SingleFileMessagePackBackingStore::new(&canonical) + .pull_all()? + .into_iter() + .filter(|row| { + row.r#type == "gamecult.epiphany.memory_semantic_projection_obligation" + && row.key == latest.obligation.obligation_id + }) + .collect(); + publish_epiphany_cultmesh_semantic_projection_health( + &verse, + "runtime", + &canonical, + &latest, + "incarnation-a", + )?; + + let mut older_conflict = latest.clone(); + older_conflict.obligation.obligation_id = "conflicting-obligation-modeling-2".to_string(); + older_conflict.obligation.created_at = "2026-07-15T12:01:00Z".to_string(); + cache.put( + &older_conflict.obligation.obligation_id, + &older_conflict.obligation, + )?; + older_conflict.authority.envelopes = SingleFileMessagePackBackingStore::new(&canonical) + .pull_all()? + .into_iter() + .filter(|row| { + row.r#type == "gamecult.epiphany.memory_semantic_projection_obligation" + && row.key == older_conflict.obligation.obligation_id + }) + .collect(); + + let error = publish_epiphany_cultmesh_semantic_projection_health( + &verse, + "runtime", + &canonical, + &older_conflict, + "incarnation-a", + ) + .expect_err("chronology must not hide a same-generation obligation conflict"); + assert!( + error + .to_string() + .contains("conflicting canonical obligations") + ); + Ok(()) + } + + #[test] + fn semantic_health_loader_rejects_latest_outside_declared_scope() -> Result<()> { + let temp = tempfile::tempdir()?; + let canonical = temp.path().join("canonical.msgpack"); + let verse = temp.path().join("verse.ccmp"); + let input = semantic_health_input(&canonical, "swarm-a", "mind", 1)?; + let row = publish_epiphany_cultmesh_semantic_projection_health( + &verse, + "runtime", + &canonical, + &input, + "incarnation-a", + )?; + let hostile_key = format!( + "{}/latest", + semantic_projection_health_scope_key("other-swarm", "mind") + ); + let mut node = open_epiphany_cultmesh_node(&verse, "hostile")?; + node.put(hostile_key, &row)?; + node.flush()?; + + let error = load_epiphany_cultmesh_semantic_projection_health(&verse, "runtime") + .expect_err("a latest row must authenticate its key scope"); + assert!( + error + .to_string() + .contains("does not match its declared scope") + ); + Ok(()) + } + + #[test] + fn forged_ready_health_cannot_mint_canonical_readiness() -> Result<()> { + let temp = tempfile::tempdir()?; + let canonical = temp.path().join("canonical.msgpack"); + let verse = temp.path().join("verse.ccmp"); + let input = semantic_health_input(&canonical, "swarm-a", "mind", 1)?; + let mut empty_authority = input.clone(); + empty_authority.authority.envelopes.clear(); + assert!( + publish_epiphany_cultmesh_semantic_projection_health( + &verse, + "runtime", + &canonical, + &empty_authority, + "incarnation-a" + ) + .is_err() + ); + let other_store = temp.path().join("other.msgpack"); + assert!( + publish_epiphany_cultmesh_semantic_projection_health( + &verse, + "runtime", + &other_store, + &input, + "incarnation-a" + ) + .is_err() + ); + let mut forged = publish_epiphany_cultmesh_semantic_projection_health( + &verse, + "runtime", + &canonical, + &input, + "incarnation-a", + )?; + forged.status = "ready".to_string(); + forged.receipt_id = Some("forged-receipt".to_string()); + forged.indexed_document_count = Some(999); + forged.vector_dimensions = Some(999); + let mut node = open_epiphany_cultmesh_node(&verse, "hostile")?; + node.put("gamecult-local/hostile/forged-ready", &forged)?; + node.flush()?; + + assert!( + crate::load_memory_semantic_projection_readiness(&canonical, &input)?.is_none(), + "CultMesh mirrors are not an import edge into canonical readiness" + ); + let mut config = crate::MemorySemanticIndexConfig::from_env(); + config.qdrant_url = "http://127.0.0.1:1".to_string(); + let packet = crate::semantic_memory_context( + input.snapshot(), + "swarm-a", + crate::SemanticPartition::Mind, + &crate::EpiphanyMemoryContextQuery { + id: "hostile-query".to_string(), + text: Some("test".to_string()), + ..Default::default() + }, + None, + &config, + ); + assert!( + packet + .warnings + .iter() + .any(|warning| warning.contains("canonical BM25")) + ); + Ok(()) + } + + #[test] + fn semantic_health_preserves_projection_states_and_later_repair_failure() -> Result<()> { + let temp = tempfile::tempdir()?; + let canonical = temp.path().join("canonical.msgpack"); + let verse = temp.path().join("verse.ccmp"); + let input = semantic_health_input(&canonical, "swarm-four", "modeling", 7)?; + let pending = publish_epiphany_cultmesh_semantic_projection_health( + &verse, + "provider", + &canonical, + &input, + "incarnation-a", + )?; + assert_eq!(pending.status, "pending"); + + let claim = crate::memory_graph::semantic_projector::claim_memory_semantic_projection( + &canonical, + input.obligation(), + "executor-a", + "2026-07-15T12:01:00Z", + )?; + let raw_receipt = crate::MemorySemanticIndexReceipt { + schema_version: crate::MEMORY_SEMANTIC_INDEX_RECEIPT_SCHEMA_VERSION.to_string(), + receipt_id: "receipt-four-state".to_string(), + swarm_id: input.obligation().swarm_id.clone(), + partition: input.obligation().partition.clone(), + collection_name: "projection".to_string(), + graph_id: input.obligation().graph_id.clone(), + model_revision: input.obligation().source_generation, + model_hash: input.obligation().source_model_hash.clone(), + embedding_provider_id: "embedder".to_string(), + embedding_model: "model".to_string(), + vector_dimensions: 3, + indexed_document_count: 2, + deleted_document_count: 0, + canonical_content_set_hash: input.obligation().canonical_content_set_hash.clone(), + indexed_at: "2026-07-15T12:02:00Z".to_string(), + status: "ready".to_string(), + obligation_id: claim.obligation_id.clone(), + canonical_source_id: String::new(), + source_commit_id: String::new(), + source_generation: input.obligation().source_generation, + projection_schema_version: crate::SEMANTIC_PROJECTION_SCHEMA_VERSION.to_string(), + claim_id: claim.claim_id.clone(), + claim_epoch: claim.epoch, + }; + crate::memory_graph::semantic_projector::succeed_memory_semantic_projection_claim( + &canonical, + &claim.claim_id, + &input.authority, + raw_receipt, + "2026-07-15T12:02:01Z", + )?; + let ready = publish_epiphany_cultmesh_semantic_projection_health( + &verse, + "provider", + &canonical, + &input, + "incarnation-a", + )?; + assert_eq!(ready.status, "ready"); + assert!(ready.query_eligible_display_only); + + let terminal_claim = crate::MemorySemanticProjectionClaim { + status: "succeeded".to_string(), + completed_at: Some("2026-07-15T12:02:01Z".to_string()), + ..claim.clone() + }; + let repair = crate::memory_graph::semantic_projector::reopen_succeeded_projection_claim( + &canonical, + &terminal_claim, + input.obligation(), + "executor-b", + "2026-07-15T12:03:00Z", + )?; + crate::memory_graph::semantic_projector::fail_memory_semantic_projection_claim( + &canonical, + &repair.claim_id, + "2026-07-15T12:04:00Z", + "private backend failure /secret/path", + )?; + let failed = publish_epiphany_cultmesh_semantic_projection_health( + &verse, + "provider", + &canonical, + &input, + "incarnation-a", + )?; + assert_eq!(failed.status, "failed"); + assert!(!failed.query_eligible_display_only); + assert!(failed.receipt_id.is_none()); + let encoded = format!("{failed:?}"); + assert!(!encoded.contains("private backend failure")); + assert!(!encoded.contains("/secret/path")); + + let mut stale_input = input.clone(); + stale_input.authority.head.source_generation += 1; + assert!(crate::observe_memory_semantic_projection(&canonical, &stale_input).is_err()); + assert!( + publish_epiphany_cultmesh_semantic_projection_health( + &verse, + "provider", + &canonical, + &stale_input, + "incarnation-a" + ) + .is_err() + ); + assert!( + publish_epiphany_cultmesh_semantic_projection_health( + &verse, + "provider", + &canonical, + &input, + "C:\\secret\\token" + ) + .is_err() + ); + + Ok(()) + } + fn publish_all_test_provider_state(store: &Path) -> Result<()> { for cluster in epiphany_cultmesh_cluster_topology() { publish_epiphany_cultmesh_provider_state(store, "epiphany-test", &cluster.daemon_id)?; diff --git a/epiphany-core/src/lib.rs b/epiphany-core/src/lib.rs index a8458703..954731ae 100644 --- a/epiphany-core/src/lib.rs +++ b/epiphany-core/src/lib.rs @@ -305,6 +305,8 @@ pub use cultmesh_integration::EPIPHANY_CULTMESH_REPO_WORK_READINESS_TYPE; pub use cultmesh_integration::EPIPHANY_CULTMESH_ROLE_REVIEW_EVENT_LATEST_KEY; pub use cultmesh_integration::EPIPHANY_CULTMESH_ROLE_REVIEW_EVENT_SCHEMA_VERSION; pub use cultmesh_integration::EPIPHANY_CULTMESH_ROLE_REVIEW_EVENT_TYPE; +pub use cultmesh_integration::EPIPHANY_CULTMESH_SEMANTIC_PROJECTION_HEALTH_SCHEMA_VERSION; +pub use cultmesh_integration::EPIPHANY_CULTMESH_SEMANTIC_PROJECTION_HEALTH_TYPE; pub use cultmesh_integration::EPIPHANY_CULTMESH_SOUL_CONTRACT_SCHEMA_VERSION; pub use cultmesh_integration::EPIPHANY_CULTMESH_SOUL_CONTRACT_TYPE; pub use cultmesh_integration::EPIPHANY_CULTMESH_STATUS_KEY; @@ -367,6 +369,7 @@ pub use cultmesh_integration::EpiphanyCultMeshRepoWorkOverviewEntry; pub use cultmesh_integration::EpiphanyCultMeshRepoWorkPublicProofEntry; pub use cultmesh_integration::EpiphanyCultMeshRepoWorkReadinessEntry; pub use cultmesh_integration::EpiphanyCultMeshRoleReviewEventEntry; +pub use cultmesh_integration::EpiphanyCultMeshSemanticProjectionHealthEntry; pub use cultmesh_integration::EpiphanyCultMeshSoulContractEntry; pub use cultmesh_integration::EpiphanyCultMeshStatusEntry; pub use cultmesh_integration::EpiphanyCultMeshSubstrateGateContractEntry; @@ -448,6 +451,7 @@ pub use cultmesh_integration::load_epiphany_cultmesh_repo_work_map_entries; pub use cultmesh_integration::load_epiphany_cultmesh_repo_work_overviews; pub use cultmesh_integration::load_epiphany_cultmesh_repo_work_public_proofs; pub use cultmesh_integration::load_epiphany_cultmesh_repo_work_readiness_reports; +pub use cultmesh_integration::load_epiphany_cultmesh_semantic_projection_health; pub use cultmesh_integration::load_epiphany_cultmesh_status; pub use cultmesh_integration::load_epiphany_cultmesh_swarm_brake; pub use cultmesh_integration::load_latest_epiphany_cultmesh_agent_state_soa_summary; @@ -477,6 +481,7 @@ pub use cultmesh_integration::load_latest_epiphany_cultmesh_weksa_lowering_recei pub use cultmesh_integration::load_latest_epiphany_cultmesh_work_loop_telemetry; pub use cultmesh_integration::open_epiphany_cultmesh_node; pub use cultmesh_integration::publish_epiphany_cultmesh_provider_state; +pub use cultmesh_integration::publish_epiphany_cultmesh_semantic_projection_health; pub use cultmesh_integration::query_epiphany_local_verse_context; pub use cultmesh_integration::seed_epiphany_local_verse_context; pub use cultmesh_integration::write_epiphany_cultmesh_agent_state_soa_summary; @@ -642,6 +647,7 @@ pub use memory_graph::MemorySemanticProjectionHealth; pub use memory_graph::MemorySemanticProjectionHealthStatus; pub use memory_graph::MemorySemanticProjectionInput; pub use memory_graph::MemorySemanticProjectionObligation; +pub use memory_graph::MemorySemanticProjectionObservation; pub use memory_graph::MemorySemanticProjectionReadiness; pub use memory_graph::MemorySemanticProjectionSourceHead; pub use memory_graph::RepoFrontierAdoptedPlan; @@ -683,6 +689,7 @@ pub use memory_graph::memory_graph_from_heartbeat_cognition; pub use memory_graph::memory_graph_model_hash; pub use memory_graph::memory_graph_node_id; pub use memory_graph::memory_semantic_projection_query_eligible; +pub use memory_graph::observe_memory_semantic_projection; pub use memory_graph::plan_memory_graph_context_cut; pub use memory_graph::plan_memory_graph_context_cut_with_ranked_ids; pub use memory_graph::refresh_or_validate_repo_memory_graph; diff --git a/epiphany-core/src/memory_graph/semantic_projector.rs b/epiphany-core/src/memory_graph/semantic_projector.rs index 2b3517c6..bc11be5e 100644 --- a/epiphany-core/src/memory_graph/semantic_projector.rs +++ b/epiphany-core/src/memory_graph/semantic_projector.rs @@ -58,6 +58,22 @@ pub struct MemorySemanticProjectionInput { pub(crate) authority: MemorySemanticProjectionAuthoritySnapshot, } +#[derive(Clone, Debug)] +pub struct MemorySemanticProjectionObservation { + pub(crate) swarm_id: String, + pub(crate) partition: String, + pub(crate) obligation_id: String, + pub(crate) source_generation: u64, + pub(crate) canonical_model_hash: String, + pub(crate) canonical_content_set_hash: String, + pub(crate) status: String, + pub(crate) receipt_id: Option, + pub(crate) indexed_document_count: Option, + pub(crate) vector_dimensions: Option, + pub(crate) observed_source_at: String, + pub(crate) query_eligible_display_only: bool, +} + impl MemorySemanticProjectionInput { pub fn snapshot(&self) -> &super::EpiphanyMemoryGraphSnapshot { &self.snapshot @@ -72,6 +88,114 @@ impl MemorySemanticProjectionInput { } } +pub fn observe_memory_semantic_projection( + store_path: impl AsRef, + input: &MemorySemanticProjectionInput, +) -> Result { + if input.authority.envelopes.is_empty() { + return Err(anyhow!( + "semantic projection observation requires canonical authority" + )); + } + validate_memory_semantic_projection_obligation(&input.obligation)?; + let envelopes = SingleFileMessagePackBackingStore::new(store_path.as_ref()).pull_all()?; + let persisted_obligation = decode_one::( + &envelopes, + &input.obligation.obligation_id, + )? + .ok_or_else(|| anyhow!("semantic projection observation obligation disappeared"))?; + if persisted_obligation != input.obligation { + return Err(anyhow!( + "semantic projection observation obligation identity collision" + )); + } + for expected in &input.authority.envelopes { + let current = envelopes + .iter() + .find(|row| row.r#type == expected.r#type && row.key == expected.key) + .ok_or_else(|| anyhow!("semantic projection observation authority disappeared"))?; + if current != expected { + return Err(anyhow!( + "semantic projection observation authority advanced" + )); + } + } + let attempts = decode_all::(&envelopes)?; + let receipts = decode_all::(&envelopes)?; + let health = super::derive_memory_semantic_projection_health( + &input.obligation, + &input.authority.head, + &attempts, + &receipts, + )?; + let receipt = health + .receipt_id + .as_ref() + .and_then(|id| receipts.iter().find(|receipt| &receipt.receipt_id == id)); + if health.status == super::MemorySemanticProjectionHealthStatus::Ready { + let authenticated = load_memory_semantic_projection_success( + store_path.as_ref(), + &input.obligation, + &input.authority.head, + )? + .ok_or_else(|| { + anyhow!("semantic projection ready observation lacks authenticated success") + })?; + if receipt.is_none_or(|receipt| receipt != &authenticated) { + return Err(anyhow!( + "semantic projection ready observation receipt is not authentic" + )); + } + } + let observed_source_at = attempts + .iter() + .filter(|attempt| attempt.obligation_id == input.obligation.obligation_id) + .flat_map(|attempt| { + [ + attempt.started_at.as_str(), + attempt.completed_at.as_deref().unwrap_or(""), + ] + }) + .chain( + receipt + .into_iter() + .map(|receipt| receipt.indexed_at.as_str()), + ) + .filter(|value| !value.is_empty()) + .max_by_key(|value| chrono::DateTime::parse_from_rfc3339(value).ok()) + .unwrap_or(input.obligation.created_at.as_str()) + .to_string(); + let status = match health.status { + super::MemorySemanticProjectionHealthStatus::Pending => "pending", + super::MemorySemanticProjectionHealthStatus::Failed => "failed", + super::MemorySemanticProjectionHealthStatus::Stale => { + return Err(anyhow!( + "semantic projection observation input is not the current canonical head" + )); + } + super::MemorySemanticProjectionHealthStatus::Ready => "ready", + }; + let display_receipt = if health.status == super::MemorySemanticProjectionHealthStatus::Ready { + receipt + } else { + None + }; + Ok(MemorySemanticProjectionObservation { + swarm_id: input.obligation.swarm_id.clone(), + partition: input.obligation.partition.clone(), + obligation_id: input.obligation.obligation_id.clone(), + source_generation: input.obligation.source_generation, + canonical_model_hash: input.obligation.source_model_hash.clone(), + canonical_content_set_hash: input.obligation.canonical_content_set_hash.clone(), + status: status.to_string(), + receipt_id: display_receipt.map(|row| row.receipt_id.clone()), + indexed_document_count: display_receipt.map(|row| row.indexed_document_count), + vector_dimensions: display_receipt.map(|row| row.vector_dimensions), + observed_source_at, + query_eligible_display_only: health.query_eligible, + }) +} + pub(crate) fn projection_scope_id(swarm_id: &str, partition: &str) -> Result { if swarm_id.trim().is_empty() || !matches!(partition, "mind" | "modeling") { return Err(anyhow!("semantic projection scope identity is invalid")); @@ -225,7 +349,7 @@ pub fn execute_memory_semantic_projection( } } -fn reopen_succeeded_projection_claim( +pub(crate) fn reopen_succeeded_projection_claim( store_path: &Path, current: &MemorySemanticProjectionClaim, obligation: &MemorySemanticProjectionObligation, @@ -577,7 +701,7 @@ pub(crate) fn validate_memory_semantic_projection_claim( } } -fn semantic_projector_cache(store_path: &Path) -> Result { +pub(crate) fn semantic_projector_cache(store_path: &Path) -> Result { let mut cache = CultCache::new(); cache.register_entry_type::()?; cache.register_entry_type::()?; diff --git a/notes/fresh-workspace-handoff.md b/notes/fresh-workspace-handoff.md index d3ed59d1..354af05f 100644 --- a/notes/fresh-workspace-handoff.md +++ b/notes/fresh-workspace-handoff.md @@ -1189,8 +1189,19 @@ successful restart commands leave the provider envelope unchanged and produce distinct awaiting receipts, then a real provider heartbeat resolves the lifecycle observation and clears restart pressure. -Next: publish renderer-neutral semantic projection health derived from -canonical Mind/Modeling evidence through CultMesh; then give Idunn typed -executor grants, single-use fenced recovery authority, open-obligation -discovery, and one packaged projector owner. CultMesh, Idunn, Eve, and Gjallar -remain unable to mint semantic readiness. +Renderer-neutral semantic projection health now leaves the provider through +CultMesh as non-authoritative local-area sight. Publication reauthenticates the +sealed Mind or Modeling input, persisted obligation, canonical authority +envelopes, and—when ready—the complete succeeded claim/attempt/receipt chain. +The mirror carries only pending/failed/ready, canonical fingerprints, +bounded counts, provider/incarnation identity, and timestamps; it carries no +error text, path, command, payload prose, or readiness capability. Immutable +events plus a per-swarm/partition chronological CAS prevent a delayed writer +from rewinding latest sight. `epiphany-memory-semantic health` repairs the +mirror independently, and `epiphany-verse-query semantic-health` reads a named, +compact report without touching canonical state. A stale sealed input is +refused rather than published as if it described the current canonical head. + +Next: give Idunn typed executor grants, single-use fenced recovery authority, +open-obligation discovery, and one packaged projector owner. CultMesh, Idunn, +Eve, and Gjallar remain unable to mint semantic readiness. diff --git a/notes/memory-graph-semantic-projection-authority-map.md b/notes/memory-graph-semantic-projection-authority-map.md index 87052c22..44853807 100644 --- a/notes/memory-graph-semantic-projection-authority-map.md +++ b/notes/memory-graph-semantic-projection-authority-map.md @@ -503,6 +503,40 @@ cannot rewind the latest lifecycle observation. ### Shared Paths And Verification Layer +CultMesh health sight is landed. + +- Owner: canonical Mind or Modeling CultCache state owns projection truth and + query admission. The semantic-health publisher owns only creation of the + non-authoritative CultMesh observation. +- Inputs: the canonical store, a sealed projection input whose obligation and + authority envelopes exactly match that store, and bounded opaque provider + runtime/incarnation identities. Ready observation additionally reloads and + authenticates the complete succeeded scope-claim, attempt, and receipt chain. +- Outputs: immutable local-area observation events plus one chronological + per-swarm/partition latest mirror carrying `pending|failed|ready`, canonical + fingerprints, bounded ready-only counts, provider identity, and timestamps. +- Derived state: mirror status, `queryEligibleDisplayOnly`, aggregate + `observed-ready|observed-attention|unknown`, and TUI rows are sight only. +- Forbidden writers: CultMesh rows, Verse/Eve/Gjallar consumers, Idunn, and + operator repair commands cannot create obligations, claims, attempts, + receipts, readiness, or semantic-query admission. +- Shared paths: `epiphany-memory-semantic health` is the sole explicit + publication pulse, and `epiphany-verse-query semantic-health` only lowers the + latest mirrors. Index execution emits its canonical receipt without calling + the sight publisher, so a mirror failure cannot redefine execution success. +- Cut line: there is no mirror-to-canonical import, mirror-to-Qdrant query, or + mirror-to-readiness edge. A stale sealed input is refused instead of being + published as current sight. +- Verification layer: tests exercise pending, authenticated ready, later failed + repair, stale-input refusal, bounded provider identities, mirror poisoning, + chronological latest behavior, private-text exclusion, and absence of + backend contact or query admission from forged sight. + +The published document is explicitly non-authoritative, +provider/incarnation-stamped, private-state sealed, and contains no graph path, +error, command, or payload prose. Event and latest writes advance atomically +through a chronological compare-and-swap. + - Initial execution, retry, crash replay, scheduled rediscovery, and operator request share the same projector execution primitive. A stuck running claim branches only through typed Idunn recovery, then re-enters that path. diff --git a/state/ledgers.msgpack b/state/ledgers.msgpack index a7e4490ddd5556c9c26a4ed93c97c8509c6632e8..70188aea70a17d3705c306f19f94037a1aa2e3c9 100644 GIT binary patch delta 640 zcmY*Wv5pfl5M^^fD!LO?oJOL}9?2#-P)-yGi7pMIqQbFfcMV?8p2r(5RSF7zfG7n& zancpQ4^UI{AM}hjIt0aN*Pi#D-@N&Kee(0$$<_Vr-q~VWEM~=>uxZ7yFdQ?y%-l~`S?jbnZF(%H1^r6;e(@JgM1IW;qmrG z=i(B%h8mTNHCP5uK383=DcGo@T_doq>bL;BY@O9M-eB8qC1-(`NbP3tgX5-=OkwX%LBhq7Z);iw#f^=%hNuo58#m*gY7 z#|=XyFsPjhXn-}fn3(TSM`5Z4^9ntN!(;!vtI3z*TR85rB3XW0a& p3|b0NqGk+hH2ERg4_4Ou-(H`U>Y-!ob$e6KO=CHUNJko{e*mRH;~xM3 delta 63 zcmcbxL+%vi|CxW0KRQ~OjVMj!^!%s|Wn#H>Kf LwtXrSd%|=8v1k-? diff --git a/state/map.yaml b/state/map.yaml index eacd3251..0e78deb4 100644 --- a/state/map.yaml +++ b/state/map.yaml @@ -714,4 +714,4 @@ current_status: - 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. last_completed_repo_swarm_cut: Huginn live-fire has crossed the first real repo Body from Persona pressure to branch-local Hands commit and Soul/Mind closure, and now has repeatable closure and redacted-public-proof mouths. On `E:\Projects\Huginn` branch `epiphany/huginn/first-awakening`, `tools/epiphany_local_run.ps1 -Mode repo-persona-intake` accepted item `huginn-inspection-readback-livefire`, Weksa/Persona intake remained sealed, and `epiphany-work derive-plan` lowered it to model-authored safe family `repo.status_section` for `README.md` only. `tools/epiphany_local_run.ps1 -Mode repo-swarm-run` advanced four bounded pulses: run-from-plan, adopt-from-plan, execute-from-plan, and close-from-execute. Huginn commit `e9b07c38fceabbdc89ea35c2156326c80c0393a2` updated only `README.md`; closure receipt `.epiphany\work\work-close-huginn-inspection-readback-livefire.json` records status `closed`, Soul verdict `passed`, Mind state commit `repo-work-close-huginn-inspection-readback-livefire-mind-commit`, safe family `repo.status_section`, path scope `README.md`, Bifrost publication gate, and `privateStateExposed=false`. Verification also ran Huginn's TypeScript compiler through concrete Node path: `C:\Program Files\nodejs\node.exe E:\Projects\Huginn\node_modules\typescript\bin\tsc -p tsconfig.json` passed. Native verifier `epiphany-repo-livefire-closure-smoke --workspace E:\Projects\Huginn --item huginn-inspection-readback-livefire --expected-path README.md --expected-family repo.status_section --expected-gate awaiting-publication --expected-blocker bifrost-publication-missing` checks closure receipt, Mind map entry, overview gate/blocker, authority seals, and `git show` changed paths, returning `status=ok`, `soulVerdict=passed`, `publicationGate=Bifrost`, and `privateStateExposed=false`. Wrapper `tools/epiphany_local_run.ps1 -Mode repo-livefire-closure -Workspace E:\Projects\Huginn -RepoWorkItem huginn-inspection-readback-livefire -SkipBuild` exposes the same read-only proof through the local operator mouth; artifact `local-20260621-190156-803-2f85ba15` printed commit, path, gate, blocker, Soul verdict, Mind commit receipt, and `privateStateExposed=False` without push, merge, publication, or target mutation. New wrapper `tools/epiphany_local_run.ps1 -Mode repo-work-public-proof -Workspace E:\Projects\Huginn -RepoWorkItem huginn-inspection-readback-livefire -SkipBuild` exports the redacted proof bundle and repo-local Verse index without publishing; artifact `local-20260621-190645-345-4555b1dc` wrote `.epiphany\public\proof-bundles\repo-work-public-proof-huginn-inspection-readback-livefire.json`, proof id `repo-work-public-proof-huginn-inspection-readback-livefire`, SHA-256 `857545b199f3e37eb06c2e757e5cfc201958e46667bb1f8403fd333a22620f63`, nine artifact rows, zero publication rows, and `privateStateExposed=False`. swarm overview readback `local-20260621-190701-140-b9519ec6` sees the `REPO-WORK-PUBLIC-PROOF` row and action row from Huginn's repo-local Verse with the same SHA-256 while Bifrost publication remains missing. Launcher compact modes are now named compact operator-context modes instead of read-only modes, and `bifrost-public-proof` summaries print item, target public Verse, room, proof SHA-256, review receipts, and credit receipts so publication receipts are auditable without claiming upstream sync. - next_action: Complete semantic projection physiology on the landed atomic admission, physically epoch-isolated projector, exact query gate, and provider-status ownership cut. Mind and Modeling emit canonical obligations; live `gamecult.epiphany.main` projections are isolated in Qdrant by obligation, claim, and epoch; readiness authenticates the complete succeeded claim/attempt/receipt chain. Idunn now records stale observation, restart attempts, policy, and backoff without writing provider heartbeat/status; command success remains `awaiting-provider-heartbeat` until a causally newer provider heartbeat proves recovery. Next publish renderer-neutral derived pending/failed/stale/ready health through CultMesh, add typed Idunn executor grants and single-use recovery authorization, and add open-obligation discovery without letting a timer create demand. Package exactly one projector owner after resolving local-versus-Yggdrasil canonical-store placement; Yggdrasil currently has GPU Ollama/Odin/Idunn but no Qdrant or Epiphany target, while local Qdrant is healthy but overexposed on all interfaces. Timers, collection metadata, point counts, runtime ids, paths, CLI labels, Idunn liveness, CultMesh mirrors, Eve/Gjallar, and payload prose own no readiness. + next_action: Complete semantic projection physiology on the landed atomic admission, physically epoch-isolated projector, exact query gate, provider-status ownership cut, and non-authoritative CultMesh health sight. Mind and Modeling emit canonical obligations; live `gamecult.epiphany.main` projections are isolated in Qdrant by obligation, claim, and epoch; readiness authenticates the complete succeeded claim/attempt/receipt chain. CultMesh health publication reauthenticates the sealed canonical input and success chain, publishes bounded pending/failed/ready sight with provider incarnation through chronological CAS, refuses stale sealed inputs, and carries no readiness capability, private error, path, command, or payload prose. Idunn records stale observation, restart attempts, policy, and backoff without writing provider heartbeat/status; command success remains `awaiting-provider-heartbeat` until a causally newer provider heartbeat proves recovery. Next add typed Idunn executor grants and single-use recovery authorization, and add open-obligation discovery without letting a timer create demand. Package exactly one projector owner after resolving local-versus-Yggdrasil canonical-store placement; Yggdrasil currently has GPU Ollama/Odin/Idunn but no Qdrant or Epiphany target, while local Qdrant is healthy but overexposed on all interfaces. Timers, collection metadata, point counts, runtime ids, paths, CLI labels, Idunn liveness, CultMesh mirrors, Eve/Gjallar, and payload prose own no readiness.