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,
})
}
}