Expose Gjallar daemon affordances in local Verse

This commit is contained in:
Meta Vens 2026-06-05 00:20:54 +01:00
commit 9552f4d700
13 changed files with 407 additions and 22 deletions

View file

@ -1,9 +1,6 @@
use anyhow::Context;
use anyhow::Result;
use chrono::Utc;
use epiphany_core::query_epiphany_local_verse_context;
use epiphany_core::seed_epiphany_local_verse_context;
use epiphany_core::EpiphanyLocalVerseContext;
use epiphany_core::EPIPHANY_CULTMESH_CONTINUITY_CONTRACT_SCHEMA_VERSION;
use epiphany_core::EPIPHANY_CULTMESH_EYES_CONTRACT_SCHEMA_VERSION;
use epiphany_core::EPIPHANY_CULTMESH_GLOBAL_ROOM_POLICY_SCHEMA_VERSION;
@ -19,8 +16,12 @@ use epiphany_core::EPIPHANY_CULTMESH_OPERATOR_STATUS_SCHEMA_VERSION;
use epiphany_core::EPIPHANY_CULTMESH_SOUL_CONTRACT_SCHEMA_VERSION;
use epiphany_core::EPIPHANY_CULTMESH_SUBSTRATE_GATE_CONTRACT_SCHEMA_VERSION;
use epiphany_core::EPIPHANY_CULTMESH_VERSE_POLICY_SCHEMA_VERSION;
use serde_json::json;
use epiphany_core::EpiphanyLocalVerseContext;
use epiphany_core::GJALLAR_AFFORDANCE_SCHEMA_VERSION;
use epiphany_core::query_epiphany_local_verse_context;
use epiphany_core::seed_epiphany_local_verse_context;
use serde_json::Value;
use serde_json::json;
use std::env;
use std::fs;
use std::path::Path;
@ -196,6 +197,7 @@ fn surface_document(args: &Args, context: Option<&EpiphanyLocalVerseContext>) ->
"children": [
operator_status_panel(context),
local_verse_panel(context),
daemon_affordance_panel(context),
runtime_spine_panel(context),
memory_graph_panel(context),
persona_panel()
@ -262,6 +264,46 @@ fn local_verse_panel(context: Option<&EpiphanyLocalVerseContext>) -> Value {
})
}
fn daemon_affordance_panel(context: Option<&EpiphanyLocalVerseContext>) -> Value {
let rows: Vec<Value> = context
.map(|context| {
context
.daemon_affordances
.iter()
.take(12)
.map(|affordance| {
json!({
"label": affordance.affordance_id,
"value": format!(
"{}:{}; authority={}; status={}; source={}",
affordance.surface_kind,
affordance.action,
affordance.authority,
affordance.status,
affordance.source_record
)
})
})
.collect()
})
.unwrap_or_default();
json!({
"id": "epiphany.daemon.affordances",
"kind": "inspector.kv",
"props": {
"title": "Daemon Affordances",
"authority": "Gjallar affordance records derived from Odin-owned sight",
"freshness": context
.and_then(|context| context.daemon_affordances.first())
.map(|affordance| affordance.observed_at.as_str())
.unwrap_or("missing"),
"rows": rows,
"emptyState": "No Gjallar affordances loaded; import an Odin/Gjallar CultMesh store rather than probing sockets or calling MCP."
},
"children": []
})
}
fn runtime_spine_panel(context: Option<&EpiphanyLocalVerseContext>) -> Value {
let snapshot = context.and_then(|context| context.latest_operator_snapshot.as_ref());
let intent = context.and_then(|context| context.latest_operator_run_intent.as_ref());
@ -444,6 +486,14 @@ fn schema_catalog(context: Option<&EpiphanyLocalVerseContext>) -> Vec<Value> {
"cultmesh://huginn/persona/{personaId}",
true,
),
schema_entry(
GJALLAR_AFFORDANCE_SCHEMA_VERSION,
"gjallar",
"imported-affordance",
"cultcache-cc",
"cultmesh://odin/gjallar/affordances",
true,
),
];
if let Some(context) = context {
for contract in &context.contract_summaries {
@ -487,7 +537,8 @@ fn witnesses(args: &Args, context: Option<&EpiphanyLocalVerseContext>) -> Vec<Va
"schemas": [
EPIPHANY_CULTMESH_VERSE_POLICY_SCHEMA_VERSION,
EPIPHANY_CULTMESH_OPERATOR_STATUS_SCHEMA_VERSION,
EPIPHANY_CULTMESH_OPERATOR_SNAPSHOT_SCHEMA_VERSION
EPIPHANY_CULTMESH_OPERATOR_SNAPSHOT_SCHEMA_VERSION,
GJALLAR_AFFORDANCE_SCHEMA_VERSION
],
"redaction": "private worker transcripts and raw model payloads are not exposed",
"freshness": {

View file

@ -391,8 +391,8 @@ fn run_coordinator(args: &Args) -> Result<Value> {
break;
}
let can_accept = args.auto_review
&& result.pointer("/finding/statePatch").is_some()
&& revision.is_some();
&& revision.is_some()
&& role_result_auto_acceptable(role_id, &result);
if !can_accept {
final_action = json!({
"action": review_action_for_role(role_id),
@ -873,6 +873,27 @@ fn review_action_for_role(role_id: &str) -> &'static str {
}
}
fn role_result_auto_acceptable(role_id: &str, result: &Value) -> bool {
if result["status"].as_str() != Some("completed") {
return false;
}
let Some(finding) = result.get("finding").filter(|value| value.is_object()) else {
return false;
};
if finding
.get("itemError")
.and_then(Value::as_str)
.is_some_and(|error| !error.trim().is_empty())
{
return false;
}
match role_id {
"verification" => true,
"research" | "modeling" => finding.get("statePatch").is_some(),
_ => false,
}
}
fn launch_reorient(
client: &mut status_cli::AppServerClient,
thread_id: &str,
@ -1539,4 +1560,38 @@ mod tests {
"reviewImplementationResult"
);
}
#[test]
fn auto_review_accepts_patchless_verification_but_not_patchless_modeling() {
let verification = json!({
"status": "completed",
"finding": {
"verdict": "needs-evidence",
"summary": "Soul asks Hands for one bounded evidence-gathering turn.",
"nextSafeMove": "Continue implementation for evidence.",
"filesInspected": ["state/map.yaml"]
}
});
assert!(role_result_auto_acceptable("verification", &verification));
let modeling = json!({
"status": "completed",
"finding": {
"verdict": "checkpoint-ready",
"summary": "Looks plausible, but no statePatch was supplied."
}
});
assert!(!role_result_auto_acceptable("modeling", &modeling));
let errored_verification = json!({
"status": "completed",
"finding": {
"itemError": "verification result is malformed"
}
});
assert!(!role_result_auto_acceptable(
"verification",
&errored_verification
));
}
}

View file

@ -1,6 +1,7 @@
use anyhow::Context;
use anyhow::Result;
use chrono::Utc;
use epiphany_core::import_gjallar_daemon_affordances;
use epiphany_core::query_epiphany_local_verse_context;
use epiphany_core::seed_epiphany_local_verse_context;
use serde_json::json;
@ -16,10 +17,24 @@ fn main() -> Result<()> {
args.runtime_id.clone(),
Utc::now().to_rfc3339(),
)?;
if let Some(gjallar_store) = args.gjallar_affordance_store.as_ref() {
import_gjallar_daemon_affordances(
&args.store,
gjallar_store,
args.runtime_id.clone(),
)?;
}
let context = query_epiphany_local_verse_context(&args.store, args.runtime_id)?;
println!("{}", serde_json::to_string_pretty(&context)?);
}
"query" => {
if let Some(gjallar_store) = args.gjallar_affordance_store.as_ref() {
import_gjallar_daemon_affordances(
&args.store,
gjallar_store,
args.runtime_id.clone(),
)?;
}
let context = query_epiphany_local_verse_context(&args.store, args.runtime_id)?;
println!("{}", serde_json::to_string_pretty(&context)?);
}
@ -29,6 +44,13 @@ fn main() -> Result<()> {
args.runtime_id.clone(),
"2026-06-02T00:00:00Z",
)?;
if let Some(gjallar_store) = args.gjallar_affordance_store.as_ref() {
import_gjallar_daemon_affordances(
&args.store,
gjallar_store,
args.runtime_id.clone(),
)?;
}
let context = query_epiphany_local_verse_context(&args.store, args.runtime_id)?;
if context.verse_policies.len() != 3 {
anyhow::bail!("local Verse query smoke expected three Verse policies");
@ -41,6 +63,9 @@ fn main() -> Result<()> {
if context.contract_summaries.len() < 6 {
anyhow::bail!("local Verse query smoke expected organ contract summaries");
}
if args.gjallar_affordance_store.is_some() && context.daemon_affordances.is_empty() {
anyhow::bail!("local Verse query smoke expected imported daemon affordances");
}
println!(
"{}",
serde_json::to_string_pretty(&json!({
@ -50,6 +75,7 @@ fn main() -> Result<()> {
"verses": context.verse_policies.len(),
"globalRooms": context.global_room_policies.len(),
"contracts": context.contract_summaries.len(),
"daemonAffordances": context.daemon_affordances.len(),
}))?
);
}
@ -62,6 +88,7 @@ struct Args {
command: String,
store: PathBuf,
runtime_id: String,
gjallar_affordance_store: Option<PathBuf>,
}
impl Args {
@ -70,6 +97,7 @@ impl Args {
let command = values.next().unwrap_or_else(|| "query".to_string());
let mut store = PathBuf::from(".epiphany-run/cultmesh/epiphany-local.ccmp");
let mut runtime_id = "epiphany-local".to_string();
let mut gjallar_affordance_store = None;
while let Some(arg) = values.next() {
match arg.as_str() {
@ -79,6 +107,13 @@ impl Args {
"--runtime-id" => {
runtime_id = values.next().context("missing --runtime-id value")?;
}
"--gjallar-affordance-store" => {
gjallar_affordance_store = Some(PathBuf::from(
values
.next()
.context("missing --gjallar-affordance-store value")?,
));
}
_ => anyhow::bail!("unknown argument {arg:?}"),
}
}
@ -91,6 +126,7 @@ impl Args {
command,
store,
runtime_id,
gjallar_affordance_store,
})
}
}

View file

@ -64,6 +64,7 @@ pub const EPIPHANY_CULTMESH_CONTINUITY_CONTRACT_TYPE: &str =
"epiphany.cultmesh.continuity_contract";
pub const EPIPHANY_CULTMESH_CONTINUITY_CONTRACT_SCHEMA_VERSION: &str =
"epiphany.cultmesh.continuity_contract.v0";
pub const GJALLAR_AFFORDANCE_SCHEMA_VERSION: &str = "gjallar.affordance.v1";
pub const EPIPHANY_CULTMESH_INTERNAL_VERSE_ID: &str = "epiphany-internal";
pub const EPIPHANY_CULTMESH_LOCAL_AREA_VERSE_ID: &str = "gamecult-local";
pub const EPIPHANY_CULTMESH_GLOBAL_VERSE_ID: &str = "epiphany-global";
@ -467,6 +468,29 @@ pub struct EpiphanyCultMeshContinuityContractEntry {
pub notes: Vec<String>,
}
#[derive(Clone, Debug, PartialEq, Eq, DatabaseEntry)]
#[cultcache(type = "gjallar.affordance", schema = "gjallar.affordance.v1")]
pub struct GjallarAffordanceEntry {
#[cultcache(key = 0)]
pub affordance_id: String,
#[cultcache(key = 1)]
pub source_record: String,
#[cultcache(key = 2)]
pub verse_id: Option<String>,
#[cultcache(key = 3)]
pub surface_kind: String,
#[cultcache(key = 4)]
pub action: String,
#[cultcache(key = 5)]
pub authority: String,
#[cultcache(key = 6)]
pub status: String,
#[cultcache(key = 7)]
pub provenance: String,
#[cultcache(key = 8)]
pub observed_at: String,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct EpiphanyLocalVerseContext {
@ -484,6 +508,7 @@ pub struct EpiphanyLocalVerseContext {
pub latest_operator_run_intent: Option<EpiphanyCultMeshOperatorRunIntentEntry>,
pub latest_operator_run_receipt: Option<EpiphanyCultMeshOperatorRunReceiptEntry>,
pub contract_summaries: Vec<EpiphanyLocalVerseContractSummary>,
pub daemon_affordances: Vec<EpiphanyLocalDaemonAffordanceSummary>,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize)]
@ -497,6 +522,20 @@ pub struct EpiphanyLocalVerseContractSummary {
pub receipt_document_types: Vec<String>,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct EpiphanyLocalDaemonAffordanceSummary {
pub affordance_id: String,
pub source_record: String,
pub verse_id: Option<String>,
pub surface_kind: String,
pub action: String,
pub authority: String,
pub status: String,
pub provenance: String,
pub observed_at: String,
}
cultmesh_documents!(EpiphanyCultMeshDocuments {
EpiphanyCultMeshStatusEntry => EPIPHANY_CULTMESH_STATUS_SCHEMA_VERSION,
EpiphanyCultMeshOperatorStatusEntry => EPIPHANY_CULTMESH_OPERATOR_STATUS_SCHEMA_VERSION,
@ -511,6 +550,7 @@ cultmesh_documents!(EpiphanyCultMeshDocuments {
EpiphanyCultMeshHandsContractEntry => EPIPHANY_CULTMESH_HANDS_CONTRACT_SCHEMA_VERSION,
EpiphanyCultMeshSoulContractEntry => EPIPHANY_CULTMESH_SOUL_CONTRACT_SCHEMA_VERSION,
EpiphanyCultMeshContinuityContractEntry => EPIPHANY_CULTMESH_CONTINUITY_CONTRACT_SCHEMA_VERSION,
GjallarAffordanceEntry => GJALLAR_AFFORDANCE_SCHEMA_VERSION,
});
pub fn open_epiphany_cultmesh_node(
@ -832,9 +872,69 @@ pub fn query_epiphany_local_verse_context(
latest_operator_run_intent: node.get(EPIPHANY_CULTMESH_OPERATOR_RUN_INTENT_LATEST_KEY)?,
latest_operator_run_receipt: node.get(EPIPHANY_CULTMESH_OPERATOR_RUN_RECEIPT_LATEST_KEY)?,
contract_summaries,
daemon_affordances: query_gjallar_daemon_affordances_from_node(&node)?,
})
}
pub fn query_gjallar_daemon_affordances(
store_path: impl AsRef<Path>,
runtime_id: impl Into<String>,
) -> Result<Vec<EpiphanyLocalDaemonAffordanceSummary>> {
let node = open_epiphany_cultmesh_node(store_path, runtime_id)?;
query_gjallar_daemon_affordances_from_node(&node)
}
pub fn import_gjallar_daemon_affordances(
local_store_path: impl AsRef<Path>,
gjallar_store_path: impl AsRef<Path>,
runtime_id: impl Into<String>,
) -> Result<Vec<EpiphanyLocalDaemonAffordanceSummary>> {
let runtime_id = runtime_id.into();
let gjallar_node =
open_epiphany_cultmesh_node(gjallar_store_path, format!("{runtime_id}-gjallar-import"))?;
let affordances = gjallar_node.cache().get_all::<GjallarAffordanceEntry>()?;
let mut local_node = open_epiphany_cultmesh_node(local_store_path, runtime_id)?;
for affordance in &affordances {
local_node.put(affordance.affordance_id.clone(), affordance)?;
}
local_node.flush()?;
Ok(affordances
.into_iter()
.map(EpiphanyLocalDaemonAffordanceSummary::from)
.collect())
}
fn query_gjallar_daemon_affordances_from_node(
node: &CultMeshNode,
) -> Result<Vec<EpiphanyLocalDaemonAffordanceSummary>> {
let mut summaries: Vec<_> = node
.cache()
.get_all::<GjallarAffordanceEntry>()?
.into_iter()
.map(EpiphanyLocalDaemonAffordanceSummary::from)
.collect();
summaries.sort_by(|left, right| left.affordance_id.cmp(&right.affordance_id));
Ok(summaries)
}
impl From<GjallarAffordanceEntry> for EpiphanyLocalDaemonAffordanceSummary {
fn from(value: GjallarAffordanceEntry) -> Self {
Self {
affordance_id: value.affordance_id,
source_record: value.source_record,
verse_id: value.verse_id,
surface_kind: value.surface_kind,
action: value.action,
authority: value.authority,
status: value.status,
provenance: value.provenance,
observed_at: value.observed_at,
}
}
}
pub trait EpiphanyCultMeshContractSummarySource: DatabaseEntry {
fn contract_id(&self) -> &str;
fn verse_id(&self) -> &str;
@ -1530,6 +1630,43 @@ mod tests {
Ok(())
}
#[test]
fn local_verse_context_imports_gjallar_daemon_affordances() -> Result<()> {
let temp = tempfile::tempdir()?;
let local_store = temp.path().join("epiphany-local-verse.ccmp");
let gjallar_store = temp.path().join("gjallar-affordances.cc");
seed_epiphany_local_verse_context(&local_store, "epiphany-test", "2026-06-02T00:00:00Z")?;
let mut gjallar_node = open_epiphany_cultmesh_node(&gjallar_store, "gjallar-test")?;
let affordance = GjallarAffordanceEntry {
affordance_id: "gjallar:odin.service:bifrost:0".to_string(),
source_record: "odin.service:bifrost".to_string(),
verse_id: Some(EPIPHANY_CULTMESH_LOCAL_AREA_VERSE_ID.to_string()),
surface_kind: "service".to_string(),
action: "inspect-eve-tui".to_string(),
authority: "odin".to_string(),
status: "available".to_string(),
provenance: "cultmesh://odin/gjallar".to_string(),
observed_at: "2026-06-04T00:00:00Z".to_string(),
};
gjallar_node.put(affordance.affordance_id.clone(), &affordance)?;
gjallar_node.flush()?;
let imported =
import_gjallar_daemon_affordances(&local_store, &gjallar_store, "epiphany-test")?;
let context = query_epiphany_local_verse_context(&local_store, "epiphany-test")?;
assert_eq!(imported.len(), 1);
assert_eq!(context.daemon_affordances.len(), 1);
assert_eq!(
context.daemon_affordances[0].source_record,
"odin.service:bifrost"
);
assert_eq!(context.daemon_affordances[0].authority, "odin");
assert_eq!(context.daemon_affordances[0].action, "inspect-eve-tui");
Ok(())
}
#[test]
fn mind_contracts_use_verses_to_keep_state_guarded() -> Result<()> {
let temp = tempfile::tempdir()?;

View file

@ -158,8 +158,11 @@ pub use cultmesh_integration::EpiphanyCultMeshSoulContractEntry;
pub use cultmesh_integration::EpiphanyCultMeshStatusEntry;
pub use cultmesh_integration::EpiphanyCultMeshSubstrateGateContractEntry;
pub use cultmesh_integration::EpiphanyCultMeshVersePolicyEntry;
pub use cultmesh_integration::EpiphanyLocalDaemonAffordanceSummary;
pub use cultmesh_integration::EpiphanyLocalVerseContext;
pub use cultmesh_integration::EpiphanyLocalVerseContractSummary;
pub use cultmesh_integration::GJALLAR_AFFORDANCE_SCHEMA_VERSION;
pub use cultmesh_integration::GjallarAffordanceEntry;
pub use cultmesh_integration::default_epiphany_cultmesh_operator_status;
pub use cultmesh_integration::epiphany_cultmesh_continuity_contracts;
pub use cultmesh_integration::epiphany_cultmesh_eyes_contracts;
@ -170,6 +173,7 @@ pub use cultmesh_integration::epiphany_cultmesh_operator_snapshot_from_status_js
pub use cultmesh_integration::epiphany_cultmesh_soul_contracts;
pub use cultmesh_integration::epiphany_cultmesh_substrate_gate_contracts;
pub use cultmesh_integration::epiphany_cultmesh_verse_policies;
pub use cultmesh_integration::import_gjallar_daemon_affordances;
pub use cultmesh_integration::load_epiphany_cultmesh_operator_snapshot;
pub use cultmesh_integration::load_epiphany_cultmesh_operator_status;
pub use cultmesh_integration::load_epiphany_cultmesh_status;
@ -178,6 +182,7 @@ pub use cultmesh_integration::load_latest_epiphany_cultmesh_operator_run_receipt
pub use cultmesh_integration::load_latest_epiphany_cultmesh_operator_snapshot;
pub use cultmesh_integration::open_epiphany_cultmesh_node;
pub use cultmesh_integration::query_epiphany_local_verse_context;
pub use cultmesh_integration::query_gjallar_daemon_affordances;
pub use cultmesh_integration::seed_epiphany_local_verse_context;
pub use cultmesh_integration::write_epiphany_cultmesh_continuity_contracts;
pub use cultmesh_integration::write_epiphany_cultmesh_eyes_contracts;

View file

@ -71,6 +71,31 @@ pub fn render_epiphany_prompt_context(input: &EpiphanyPromptContextInput) -> Str
);
}
if !input.local_verse.daemon_affordances.is_empty() {
lines.push("## Odin/Gjallar Daemon Affordances".to_string());
lines.push(
"- Native path: ask Odin/Gjallar for daemon affordances, inspect Eve/CultUI TUI surfaces, and send provider-owned CultMesh command intents; MCP is not the Epiphany control path.".to_string(),
);
for affordance in input.local_verse.daemon_affordances.iter().take(8) {
lines.push(format!(
"- `{}` [{}:{}]: source={}, authority={}, status={}, provenance={}",
affordance.affordance_id,
affordance.surface_kind,
affordance.action,
compact_line(&affordance.source_record),
compact_line(&affordance.authority),
compact_line(&affordance.status),
compact_line(&affordance.provenance)
));
}
push_omitted_count(
&mut lines,
input.local_verse.daemon_affordances.len(),
8,
"daemon affordances",
);
}
lines.push("## Semantic Memory Context".to_string());
lines.push(format!(
"- Packet `{}` from query `{}`",