From c49399d4dacb2014dce09368888c1d1354659cde Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Fri, 12 Jun 2026 17:36:48 +0100 Subject: [PATCH] Route work-loop telemetry through CultMesh --- epiphany-codex-bridge/src/launch_context.rs | 293 ++++++++++++++++-- epiphany-codex-bridge/src/mutation_service.rs | 11 +- epiphany-core/src/cultmesh_integration.rs | 140 +++++++++ epiphany-core/src/lib.rs | 6 + notes/fresh-workspace-handoff.md | 4 +- state/ledgers.msgpack | Bin 178069 -> 178509 bytes state/map.yaml | 2 +- 7 files changed, 428 insertions(+), 28 deletions(-) diff --git a/epiphany-codex-bridge/src/launch_context.rs b/epiphany-codex-bridge/src/launch_context.rs index 6ba79614..0074fd12 100644 --- a/epiphany-codex-bridge/src/launch_context.rs +++ b/epiphany-codex-bridge/src/launch_context.rs @@ -1,10 +1,15 @@ use chrono::SecondsFormat; use chrono::Utc; +use epiphany_core::EPIPHANY_CULTMESH_INTERNAL_VERSE_ID; +use epiphany_core::EPIPHANY_CULTMESH_WORK_LOOP_TELEMETRY_SCHEMA_VERSION; +use epiphany_core::EpiphanyCultMeshWorkLoopTelemetryEntry; use epiphany_core::EpiphanyMemoryContextPacket; use epiphany_core::EpiphanyMemoryContextQuery; use epiphany_core::EpiphanyMemoryProfile; use epiphany_core::EpiphanyPromptContextInput; use epiphany_core::EpiphanyThreadState; +use epiphany_core::RuntimeHandsReceiptChainSummary; +use epiphany_core::load_latest_epiphany_cultmesh_work_loop_telemetry; use epiphany_core::load_memory_graph_snapshot; use epiphany_core::memory_graph_from_epiphany_graphs; use epiphany_core::plan_memory_graph_context_cut; @@ -12,10 +17,13 @@ use epiphany_core::query_epiphany_local_verse_context; use epiphany_core::render_epiphany_prompt_context; use epiphany_core::runtime_latest_hands_receipt_chain_after; use epiphany_core::seed_epiphany_local_verse_context; +use epiphany_core::write_epiphany_cultmesh_work_loop_telemetry; use epiphany_core::write_memory_graph_snapshot; +use epiphany_state_model::EpiphanyAcceptanceReceipt; use std::fs; use std::path::Path; use std::path::PathBuf; +use uuid::Uuid; pub const EPIPHANY_LOCAL_VERSE_RUNTIME_ID: &str = "epiphany-local"; @@ -99,32 +107,29 @@ pub fn append_verification_hands_receipt_context( mut context: String, runtime_store_path: &Path, state: &EpiphanyThreadState, -) -> String { +) -> Result { let Some(accepted_at) = latest_accepted_verification_timestamp(state) else { - return context; + return Ok(context); }; let Ok(Some(chain)) = runtime_latest_hands_receipt_chain_after(runtime_store_path, accepted_at) else { - return context; + return Ok(context); }; - context.push_str("\n\n\n"); + let telemetry = work_loop_telemetry_from_hands_chain(&chain, state, accepted_at, Vec::new()); + let telemetry_store = local_verse_store_path(runtime_store_path); + write_epiphany_cultmesh_work_loop_telemetry(&telemetry_store, telemetry.clone()).map_err( + |error| { + format!( + "failed to write work-loop telemetry to internal CultMesh store {}: {error}", + telemetry_store.display() + ) + }, + )?; + context.push_str("\n\n\n"); context.push_str( - "Soul is reviewing concrete Hands consequence evidence produced after the latest accepted Verification finding.\n", + "Soul is reviewing typed internal CultMesh telemetry for concrete Hands consequence evidence produced after the latest accepted Verification finding.\n", ); - context.push_str(&format!( - "- lowerBoundAcceptedVerificationAt: {accepted_at}\n" - )); - context.push_str(&format!("- intentId: {}\n", chain.intent_id)); - context.push_str(&format!("- reviewId: {}\n", chain.review_id)); - context.push_str(&format!("- runtimeJobId: {}\n", chain.runtime_job_id)); - context.push_str(&format!( - "- substrateGateGrantReceiptId: {}\n", - chain.substrate_gate_grant_receipt_id - )); - context.push_str(&format!( - "- receiptIds: patch={}, command={}, commit={}\n", - chain.patch_receipt_id, chain.command_receipt_id, chain.commit_receipt_id - )); + context.push_str(&render_work_loop_telemetry(&telemetry)); context.push_str("- resolvedReceiptPayloads:\n"); context.push_str(&format!( " - patch: schemaVersion={} changedPaths={}\n", @@ -182,10 +187,75 @@ pub fn append_verification_hands_receipt_context( " - coordinator treats a complete post-verification Hands chain as implementation evidence that requires a fresh Soul pass.\n", ); context.push_str( - "Use these receipts, artifacts, and source references as the concrete Hands evidence under review. Do not ask for generic receipt-path evidence without first judging this packet.\n", + "Use these typed internal Verse receipts, artifacts, and source references as the concrete Hands evidence under review. Do not ask for generic receipt-path evidence without first judging this packet.\n", ); - context.push_str(""); - context + context.push_str(""); + Ok(context) +} + +pub fn append_modeling_work_loop_telemetry_context( + mut context: String, + runtime_store_path: &Path, + state: &EpiphanyThreadState, +) -> Result { + let store = local_verse_store_path(runtime_store_path); + let Some(mut telemetry) = + load_latest_epiphany_cultmesh_work_loop_telemetry(&store, EPIPHANY_LOCAL_VERSE_RUNTIME_ID) + .map_err(|error| { + format!( + "failed to load work-loop telemetry from internal CultMesh store {}: {error}", + store.display() + ) + })? + else { + return Ok(context); + }; + let soul_receipts = latest_accepted_soul_receipts(state); + if !soul_receipts.is_empty() { + telemetry.telemetry_id = format!("{}-soul-{}", telemetry.telemetry_id, state.revision); + telemetry.produced_at_utc = Utc::now().to_rfc3339_opts(SecondsFormat::Secs, true); + telemetry.source_stage = "hands+soul".to_string(); + telemetry.target_stages = vec!["proprioception".to_string()]; + telemetry.soul_receipt_ids = soul_receipts + .iter() + .map(|receipt| receipt.id.clone()) + .collect(); + telemetry.summary = format!( + "{} Soul acceptance telemetry attached for Proprioception model update.", + telemetry.summary + ); + write_epiphany_cultmesh_work_loop_telemetry(&store, telemetry.clone()).map_err( + |error| { + format!( + "failed to enrich work-loop telemetry in internal CultMesh store {}: {error}", + store.display() + ) + }, + )?; + } + context.push_str("\n\n\n"); + context.push_str( + "Proprioception is modeling the machine after Soul has reviewed the latest Hands consequence telemetry. This packet is loaded from the internal CultMesh Verse, not reconstructed from chat memory.\n", + ); + context.push_str(&render_work_loop_telemetry(&telemetry)); + if !soul_receipts.is_empty() { + context.push_str("- soulAcceptedReceipts:\n"); + for receipt in soul_receipts { + context.push_str(&format!( + " - id={} resultId={} jobId={} acceptedAt={} summary={}\n", + receipt.id, + receipt.result_id, + receipt.job_id, + receipt.accepted_at, + receipt.summary.unwrap_or_default() + )); + } + } + context.push_str( + "Update the machine model from this verified consequence before another Hands turn. Do not request a new Eyes step merely to rediscover this already-typed telemetry.\n", + ); + context.push_str(""); + Ok(context) } fn latest_accepted_verification_timestamp(state: &EpiphanyThreadState) -> Option<&str> { @@ -201,6 +271,142 @@ fn latest_accepted_verification_timestamp(state: &EpiphanyThreadState) -> Option .max() } +fn latest_accepted_soul_receipts(state: &EpiphanyThreadState) -> Vec { + let Some(latest_at) = latest_accepted_verification_timestamp(state) else { + return Vec::new(); + }; + state + .acceptance_receipts + .iter() + .filter(|receipt| { + receipt.role_id == "verification" + && receipt.surface == "roleAccept" + && receipt.status == "accepted" + && receipt.accepted_at == latest_at + }) + .cloned() + .collect() +} + +fn work_loop_telemetry_from_hands_chain( + chain: &RuntimeHandsReceiptChainSummary, + state: &EpiphanyThreadState, + lower_bound_receipt_at: &str, + soul_receipt_ids: Vec, +) -> EpiphanyCultMeshWorkLoopTelemetryEntry { + EpiphanyCultMeshWorkLoopTelemetryEntry { + schema_version: EPIPHANY_CULTMESH_WORK_LOOP_TELEMETRY_SCHEMA_VERSION.to_string(), + runtime_id: EPIPHANY_LOCAL_VERSE_RUNTIME_ID.to_string(), + verse_id: EPIPHANY_CULTMESH_INTERNAL_VERSE_ID.to_string(), + telemetry_id: format!( + "work-loop-telemetry-{}-{}", + state.revision, + Uuid::new_v4() + ), + thread_id: state.last_updated_turn_id.clone().unwrap_or_default(), + produced_at_utc: Utc::now().to_rfc3339_opts(SecondsFormat::Secs, true), + source_stage: "hands".to_string(), + target_stages: vec!["soul".to_string(), "proprioception".to_string()], + lower_bound_receipt_at: lower_bound_receipt_at.to_string(), + hands_intent_id: chain.intent_id.clone(), + hands_review_id: chain.review_id.clone(), + hands_runtime_job_id: chain.runtime_job_id.clone(), + substrate_gate_grant_receipt_id: chain.substrate_gate_grant_receipt_id.clone(), + hands_patch_receipt_id: chain.patch_receipt_id.clone(), + hands_command_receipt_id: chain.command_receipt_id.clone(), + hands_commit_receipt_id: chain.commit_receipt_id.clone(), + command: chain.command.clone(), + exit_code: chain.exit_code.clone(), + stdout_artifact: chain.stdout_artifact.clone(), + stderr_artifact: chain.stderr_artifact.clone(), + commit_sha: chain.commit_sha.clone(), + branch: chain.branch.clone(), + changed_paths: chain.changed_paths.clone(), + artifact_previews: vec![ + format!("stdout: {}", artifact_preview(&chain.stdout_artifact)), + format!("stderr: {}", artifact_preview(&chain.stderr_artifact)), + ], + source_refs: vec![ + "epiphany-core/src/bin/epiphany-hands-action.rs".to_string(), + "epiphany-core/src/hands_gateway.rs".to_string(), + "epiphany-core/src/runtime_spine.rs".to_string(), + "epiphany-core/src/bin/epiphany-mvp-coordinator.rs".to_string(), + "epiphany-codex-bridge/src/coordinator.rs".to_string(), + ], + source_path_proof: vec![ + "epiphany-hands-action `record-pass` records patch, command, and commit receipts through runtime-spine put functions.".to_string(), + "runtime_spine registers Hands receipt document types, persists/rereads them through the shared CultCache runtime-spine store, and exposes latest-chain readback.".to_string(), + "bridge launch context writes this typed packet to the internal CultMesh Verse before Soul receives the rendered projection.".to_string(), + "coordinator treats a complete post-verification Hands chain as implementation evidence that requires a fresh Soul pass.".to_string(), + ], + soul_receipt_ids, + summary: chain.summary.clone(), + } +} + +fn render_work_loop_telemetry(telemetry: &EpiphanyCultMeshWorkLoopTelemetryEntry) -> String { + let mut rendered = String::new(); + rendered.push_str(&format!("- schemaVersion: {}\n", telemetry.schema_version)); + rendered.push_str(&format!("- verseId: {}\n", telemetry.verse_id)); + rendered.push_str(&format!("- telemetryId: {}\n", telemetry.telemetry_id)); + rendered.push_str(&format!("- sourceStage: {}\n", telemetry.source_stage)); + rendered.push_str(&format!( + "- targetStages: {}\n", + telemetry.target_stages.join(", ") + )); + rendered.push_str(&format!( + "- lowerBoundAcceptedVerificationAt: {}\n", + telemetry.lower_bound_receipt_at + )); + rendered.push_str(&format!("- intentId: {}\n", telemetry.hands_intent_id)); + rendered.push_str(&format!("- reviewId: {}\n", telemetry.hands_review_id)); + rendered.push_str(&format!( + "- runtimeJobId: {}\n", + telemetry.hands_runtime_job_id + )); + rendered.push_str(&format!( + "- substrateGateGrantReceiptId: {}\n", + telemetry.substrate_gate_grant_receipt_id + )); + rendered.push_str(&format!( + "- receiptIds: patch={}, command={}, commit={}\n", + telemetry.hands_patch_receipt_id, + telemetry.hands_command_receipt_id, + telemetry.hands_commit_receipt_id + )); + if !telemetry.soul_receipt_ids.is_empty() { + rendered.push_str(&format!( + "- soulReceiptIds: {}\n", + telemetry.soul_receipt_ids.join(", ") + )); + } + rendered.push_str(&format!( + "- command: `{}` exitCode={} stdoutArtifact={} stderrArtifact={}\n", + telemetry.command, + telemetry.exit_code, + telemetry.stdout_artifact, + telemetry.stderr_artifact + )); + rendered.push_str(&format!( + "- commit: sha={} branch={}\n", + telemetry.commit_sha, telemetry.branch + )); + if !telemetry.changed_paths.is_empty() { + rendered.push_str("- changedPaths:\n"); + for path in &telemetry.changed_paths { + rendered.push_str(&format!(" - {path}\n")); + } + } + if !telemetry.artifact_previews.is_empty() { + rendered.push_str("- artifactPreviews:\n"); + for preview in &telemetry.artifact_previews { + rendered.push_str(&format!(" - {preview}\n")); + } + } + rendered.push_str(&format!("- summary: {}\n", telemetry.summary)); + rendered +} + fn artifact_preview(path: &str) -> String { let path = Path::new(path); let text = fs::read_to_string(path) @@ -474,15 +680,54 @@ mod tests { "".to_string(), &runtime_store, &state, - ); + ) + .map_err(anyhow::Error::msg)?; - assert!(context.contains("")); + assert!(context.contains("")); assert!(context.contains("hands-patch-context")); assert!(context.contains("hands-command-context")); assert!(context.contains("hands-commit-context")); assert!(context.contains("resolvedReceiptPayloads")); assert!(context.contains("test result: ok")); assert!(context.contains("sourcePathProof")); + let telemetry = load_latest_epiphany_cultmesh_work_loop_telemetry( + local_verse_store_path(&runtime_store), + EPIPHANY_LOCAL_VERSE_RUNTIME_ID, + )? + .expect("Verification launch should write internal CultMesh telemetry"); + assert_eq!( + telemetry.verse_id, + EPIPHANY_CULTMESH_INTERNAL_VERSE_ID.to_string() + ); + assert_eq!(telemetry.hands_patch_receipt_id, "hands-patch-context"); + assert_eq!(telemetry.hands_command_receipt_id, "hands-command-context"); + assert_eq!(telemetry.hands_commit_receipt_id, "hands-commit-context"); + assert_eq!( + telemetry.target_stages, + vec!["soul".to_string(), "proprioception".to_string()] + ); + + let modeling_context = append_modeling_work_loop_telemetry_context( + "".to_string(), + &runtime_store, + &state, + ) + .map_err(anyhow::Error::msg)?; + assert!(modeling_context.contains("")); + assert!(modeling_context.contains("hands-patch-context")); + assert!(modeling_context.contains("accept-verification-context")); + assert!(modeling_context.contains("Soul acceptance telemetry")); + let telemetry = load_latest_epiphany_cultmesh_work_loop_telemetry( + local_verse_store_path(&runtime_store), + EPIPHANY_LOCAL_VERSE_RUNTIME_ID, + )? + .expect("Modeling launch should preserve enriched CultMesh telemetry"); + assert_eq!(telemetry.source_stage, "hands+soul"); + assert_eq!(telemetry.target_stages, vec!["proprioception".to_string()]); + assert_eq!( + telemetry.soul_receipt_ids, + vec!["accept-verification-context".to_string()] + ); fs::remove_dir_all(&temp)?; Ok(()) diff --git a/epiphany-codex-bridge/src/mutation_service.rs b/epiphany-codex-bridge/src/mutation_service.rs index e64ff4ee..b7de9d89 100644 --- a/epiphany-codex-bridge/src/mutation_service.rs +++ b/epiphany-codex-bridge/src/mutation_service.rs @@ -73,6 +73,7 @@ use crate::jobs::derive_epiphany_jobs; use crate::jobs::epiphany_blocked_state_job; use crate::jobs::map_interrupted_epiphany_job; use crate::jobs::map_launched_epiphany_job; +use crate::launch_context::append_modeling_work_loop_telemetry_context; use crate::launch_context::append_verification_hands_receipt_context; use crate::launch_context::render_launch_dynamic_prompt_context; use crate::launch_context::reorient_launch_context_focus; @@ -716,7 +717,15 @@ pub async fn launch_thread_epiphany_role( dynamic_prompt_context, runtime_store_path.as_path(), &state, - ); + ) + .map_err(EpiphanyBridgeError::Fatal)?; + } else if role_id == EpiphanyRoleResultRoleId::Modeling { + dynamic_prompt_context = append_modeling_work_loop_telemetry_context( + dynamic_prompt_context, + runtime_store_path.as_path(), + &state, + ) + .map_err(EpiphanyBridgeError::Fatal)?; } let launch_request = build_epiphany_role_launch_request_with_dynamic_context( thread_id, diff --git a/epiphany-core/src/cultmesh_integration.rs b/epiphany-core/src/cultmesh_integration.rs index a8af8715..4b208a7d 100644 --- a/epiphany-core/src/cultmesh_integration.rs +++ b/epiphany-core/src/cultmesh_integration.rs @@ -39,6 +39,12 @@ pub const EPIPHANY_CULTMESH_OPERATOR_RUN_RECEIPT_SCHEMA_VERSION: &str = "epiphany.cultmesh.operator_run_receipt.v0"; pub const EPIPHANY_CULTMESH_OPERATOR_RUN_RECEIPT_LATEST_KEY: &str = "epiphany-local/operator-run-receipt/latest"; +pub const EPIPHANY_CULTMESH_WORK_LOOP_TELEMETRY_TYPE: &str = + "epiphany.cultmesh.work_loop_telemetry"; +pub const EPIPHANY_CULTMESH_WORK_LOOP_TELEMETRY_SCHEMA_VERSION: &str = + "epiphany.cultmesh.work_loop_telemetry.v0"; +pub const EPIPHANY_CULTMESH_WORK_LOOP_TELEMETRY_LATEST_KEY: &str = + "epiphany-internal/work-loop-telemetry/latest"; pub const EPIPHANY_CULTMESH_VERSE_POLICY_TYPE: &str = "epiphany.cultmesh.verse_policy"; pub const EPIPHANY_CULTMESH_VERSE_POLICY_SCHEMA_VERSION: &str = "epiphany.cultmesh.verse_policy.v0"; pub const EPIPHANY_CULTMESH_GLOBAL_ROOM_POLICY_TYPE: &str = "epiphany.cultmesh.global_room_policy"; @@ -245,6 +251,70 @@ pub struct EpiphanyCultMeshOperatorRunReceiptEntry { pub notes: Vec, } +#[derive(Clone, Debug, PartialEq, Eq, DatabaseEntry)] +#[cultcache( + type = "epiphany.cultmesh.work_loop_telemetry", + schema = "EpiphanyCultMeshWorkLoopTelemetryEntry" +)] +pub struct EpiphanyCultMeshWorkLoopTelemetryEntry { + #[cultcache(key = 0)] + pub schema_version: String, + #[cultcache(key = 1)] + pub runtime_id: String, + #[cultcache(key = 2)] + pub verse_id: String, + #[cultcache(key = 3)] + pub telemetry_id: String, + #[cultcache(key = 4)] + pub thread_id: String, + #[cultcache(key = 5)] + pub produced_at_utc: String, + #[cultcache(key = 6)] + pub source_stage: String, + #[cultcache(key = 7)] + pub target_stages: Vec, + #[cultcache(key = 8)] + pub lower_bound_receipt_at: String, + #[cultcache(key = 9)] + pub hands_intent_id: String, + #[cultcache(key = 10)] + pub hands_review_id: String, + #[cultcache(key = 11)] + pub hands_runtime_job_id: String, + #[cultcache(key = 12)] + pub substrate_gate_grant_receipt_id: String, + #[cultcache(key = 13)] + pub hands_patch_receipt_id: String, + #[cultcache(key = 14)] + pub hands_command_receipt_id: String, + #[cultcache(key = 15)] + pub hands_commit_receipt_id: String, + #[cultcache(key = 16)] + pub command: String, + #[cultcache(key = 17)] + pub exit_code: String, + #[cultcache(key = 18)] + pub stdout_artifact: String, + #[cultcache(key = 19)] + pub stderr_artifact: String, + #[cultcache(key = 20)] + pub commit_sha: String, + #[cultcache(key = 21)] + pub branch: String, + #[cultcache(key = 22)] + pub changed_paths: Vec, + #[cultcache(key = 23)] + pub artifact_previews: Vec, + #[cultcache(key = 24)] + pub source_refs: Vec, + #[cultcache(key = 25)] + pub source_path_proof: Vec, + #[cultcache(key = 26)] + pub soul_receipt_ids: Vec, + #[cultcache(key = 27)] + pub summary: String, +} + #[derive(Clone, Debug, PartialEq, Eq, DatabaseEntry)] #[cultcache( type = "epiphany.cultmesh.verse_policy", @@ -501,6 +571,7 @@ cultmesh_documents!(EpiphanyCultMeshDocuments { EpiphanyCultMeshOperatorSnapshotEntry => EPIPHANY_CULTMESH_OPERATOR_SNAPSHOT_SCHEMA_VERSION, EpiphanyCultMeshOperatorRunIntentEntry => EPIPHANY_CULTMESH_OPERATOR_RUN_INTENT_SCHEMA_VERSION, EpiphanyCultMeshOperatorRunReceiptEntry => EPIPHANY_CULTMESH_OPERATOR_RUN_RECEIPT_SCHEMA_VERSION, + EpiphanyCultMeshWorkLoopTelemetryEntry => EPIPHANY_CULTMESH_WORK_LOOP_TELEMETRY_SCHEMA_VERSION, EpiphanyCultMeshVersePolicyEntry => EPIPHANY_CULTMESH_VERSE_POLICY_SCHEMA_VERSION, EpiphanyCultMeshGlobalRoomPolicyEntry => EPIPHANY_CULTMESH_GLOBAL_ROOM_POLICY_SCHEMA_VERSION, EpiphanyCultMeshMindContractEntry => EPIPHANY_CULTMESH_MIND_CONTRACT_SCHEMA_VERSION, @@ -714,6 +785,25 @@ pub fn load_latest_epiphany_cultmesh_operator_run_receipt( node.get(EPIPHANY_CULTMESH_OPERATOR_RUN_RECEIPT_LATEST_KEY) } +pub fn write_epiphany_cultmesh_work_loop_telemetry( + store_path: impl AsRef, + telemetry: EpiphanyCultMeshWorkLoopTelemetryEntry, +) -> Result { + let mut node = open_epiphany_cultmesh_node(&store_path, telemetry.runtime_id.clone())?; + let written = node.put(telemetry.telemetry_id.clone(), &telemetry)?; + node.put(EPIPHANY_CULTMESH_WORK_LOOP_TELEMETRY_LATEST_KEY, &written)?; + node.flush()?; + Ok(written) +} + +pub fn load_latest_epiphany_cultmesh_work_loop_telemetry( + store_path: impl AsRef, + runtime_id: impl Into, +) -> Result> { + let node = open_epiphany_cultmesh_node(store_path, runtime_id)?; + node.get(EPIPHANY_CULTMESH_WORK_LOOP_TELEMETRY_LATEST_KEY) +} + pub fn seed_epiphany_local_verse_context( store_path: impl AsRef, runtime_id: impl Into, @@ -1402,6 +1492,56 @@ mod tests { Ok(()) } + #[test] + fn work_loop_telemetry_round_trips_as_internal_cultmesh_document() -> Result<()> { + let temp = tempfile::tempdir()?; + let store = temp.path().join("epiphany-local-verse.ccmp"); + let telemetry = EpiphanyCultMeshWorkLoopTelemetryEntry { + schema_version: EPIPHANY_CULTMESH_WORK_LOOP_TELEMETRY_SCHEMA_VERSION.to_string(), + runtime_id: "epiphany-test".to_string(), + verse_id: EPIPHANY_CULTMESH_INTERNAL_VERSE_ID.to_string(), + telemetry_id: "work-loop-telemetry-test".to_string(), + thread_id: "thread-test".to_string(), + produced_at_utc: "2026-06-12T00:00:00Z".to_string(), + source_stage: "hands".to_string(), + target_stages: vec!["soul".to_string(), "proprioception".to_string()], + lower_bound_receipt_at: "2026-06-12T00:00:01Z".to_string(), + hands_intent_id: "hands-intent-test".to_string(), + hands_review_id: "hands-review-test".to_string(), + hands_runtime_job_id: "hands-job-test".to_string(), + substrate_gate_grant_receipt_id: "substrate-grant-test".to_string(), + hands_patch_receipt_id: "hands-patch-test".to_string(), + hands_command_receipt_id: "hands-command-test".to_string(), + hands_commit_receipt_id: "hands-commit-test".to_string(), + command: "cargo test".to_string(), + exit_code: "0".to_string(), + stdout_artifact: "stdout.log".to_string(), + stderr_artifact: "stderr.log".to_string(), + commit_sha: "abc123".to_string(), + branch: "codex/test".to_string(), + changed_paths: vec!["epiphany-core/src/runtime_spine.rs".to_string()], + artifact_previews: vec!["stdout: ok".to_string()], + source_refs: vec!["epiphany-core/src/runtime_spine.rs".to_string()], + source_path_proof: vec!["runtime-spine persisted Hands receipts".to_string()], + soul_receipt_ids: vec!["accept-verification-test".to_string()], + summary: "Hands consequence telemetry for the work loop.".to_string(), + }; + + write_epiphany_cultmesh_work_loop_telemetry(&store, telemetry.clone())?; + + assert_eq!( + load_latest_epiphany_cultmesh_work_loop_telemetry(&store, "epiphany-test")?, + Some(telemetry) + ); + let node = open_epiphany_cultmesh_node(&store, "epiphany-test")?; + assert!( + node.documents() + .binding(EPIPHANY_CULTMESH_WORK_LOOP_TELEMETRY_TYPE) + .is_some() + ); + Ok(()) + } + #[test] fn builtin_verse_policies_keep_public_and_private_boundaries_apart() -> Result<()> { let temp = tempfile::tempdir()?; diff --git a/epiphany-core/src/lib.rs b/epiphany-core/src/lib.rs index e4a9f977..249661d5 100644 --- a/epiphany-core/src/lib.rs +++ b/epiphany-core/src/lib.rs @@ -142,6 +142,9 @@ pub use cultmesh_integration::EPIPHANY_CULTMESH_SUBSTRATE_GATE_CONTRACT_SCHEMA_V pub use cultmesh_integration::EPIPHANY_CULTMESH_SUBSTRATE_GATE_CONTRACT_TYPE; pub use cultmesh_integration::EPIPHANY_CULTMESH_VERSE_POLICY_SCHEMA_VERSION; pub use cultmesh_integration::EPIPHANY_CULTMESH_VERSE_POLICY_TYPE; +pub use cultmesh_integration::EPIPHANY_CULTMESH_WORK_LOOP_TELEMETRY_LATEST_KEY; +pub use cultmesh_integration::EPIPHANY_CULTMESH_WORK_LOOP_TELEMETRY_SCHEMA_VERSION; +pub use cultmesh_integration::EPIPHANY_CULTMESH_WORK_LOOP_TELEMETRY_TYPE; pub use cultmesh_integration::EpiphanyCultMeshContinuityContractEntry; pub use cultmesh_integration::EpiphanyCultMeshDocuments; pub use cultmesh_integration::EpiphanyCultMeshEyesContractEntry; @@ -156,6 +159,7 @@ pub use cultmesh_integration::EpiphanyCultMeshSoulContractEntry; pub use cultmesh_integration::EpiphanyCultMeshStatusEntry; pub use cultmesh_integration::EpiphanyCultMeshSubstrateGateContractEntry; pub use cultmesh_integration::EpiphanyCultMeshVersePolicyEntry; +pub use cultmesh_integration::EpiphanyCultMeshWorkLoopTelemetryEntry; pub use cultmesh_integration::EpiphanyLocalVerseContext; pub use cultmesh_integration::EpiphanyLocalVerseContractSummary; pub use cultmesh_integration::default_epiphany_cultmesh_operator_status; @@ -174,6 +178,7 @@ pub use cultmesh_integration::load_epiphany_cultmesh_status; pub use cultmesh_integration::load_latest_epiphany_cultmesh_operator_run_intent; 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::load_latest_epiphany_cultmesh_work_loop_telemetry; pub use cultmesh_integration::open_epiphany_cultmesh_node; pub use cultmesh_integration::query_epiphany_local_verse_context; pub use cultmesh_integration::seed_epiphany_local_verse_context; @@ -190,6 +195,7 @@ pub use cultmesh_integration::write_epiphany_cultmesh_soul_contracts; pub use cultmesh_integration::write_epiphany_cultmesh_status; pub use cultmesh_integration::write_epiphany_cultmesh_substrate_gate_contracts; pub use cultmesh_integration::write_epiphany_cultmesh_verse_policies; +pub use cultmesh_integration::write_epiphany_cultmesh_work_loop_telemetry; pub use distillation::EpiphanyDistillInput; pub use distillation::EpiphanyDistillProposal; pub use distillation::distill_observation; diff --git a/notes/fresh-workspace-handoff.md b/notes/fresh-workspace-handoff.md index 07ce47e4..10a0b027 100644 --- a/notes/fresh-workspace-handoff.md +++ b/notes/fresh-workspace-handoff.md @@ -35,7 +35,7 @@ remembers doctrine; the branch remembers the blade. - Do not copy exact branch or HEAD from this note. Run `git status --short --branch` and `git log --oneline -5`. - Canonical anatomy now lives in `notes/epiphany-anatomy.md`. Embodied sub-agents are Self, Face, Imagination, Eyes, Proprioception, Hands, and Soul. Body, Mind, Continuity, and Substrate Gate are substrate/state/protocol surfaces, not sub-agent identities. State is split by layer: `work_organ` for resident Epiphany sub-agents, `persona` for portable public/person-shaped state shared by Epiphany Face, VoidBot repo Faces, and Ghostlight characters, and heartbeat/swarm state for scheduling and coordination physiology. Persona state now carries provenance, required public presentation, `date-time` timestamps, typed `candidateActions`, strict anchored thoughts with non-authoritative extensions, custom enum companion labels, and typed affect records for bonds/status reads/doctrine stances. - The repo now has a one-command local operator path: `.\tools\epiphany_local_run.ps1`. Default mode is `smoke`; it builds the retained Codex app-server compatibility edge, builds native Epiphany operator binaries, runs the coordinator smoke, and writes launcher artifacts under `.epiphany-run/` plus coordinator artifacts under `.epiphany-dogfood/`. `-Mode status` is now Epiphany-native: it builds only Epiphany operator binaries, reads `state/thread-state.msgpack` when present, derives status through `epiphany-core`, and does not start or require `codex-app-server`. Use `-Mode plan` or `-Mode run -MaxSteps 4` for the raw bridge-equipped coordinator entrypoints; use `-Mode mvp -FaceInput "" -MaxSteps 4` for the local product cycle that projects Face's character turn, writes a Face/Aquarium bubble, bootstraps a minimal local checkpoint for fresh threads, runs the coordinator with auto-tools, then runs heartbeat sleep/dream maintenance. Live plan/run/mvp modes use the workspace `state/runtime-spine.msgpack`, because CodexThread launch writes worker requests there; the run bundle remains artifact evidence, not runtime lifecycle authority. Add `-ThreadId ` and `-Workspace ` to inspect or continue an existing thread. `status`, `plan`, and `smoke` do not spend model calls; `run` and `mvp` build and use `epiphany-openai-runtime`. Coordinator workers now launch detached and are polled through runtime-spine instead of blocking the coordinator. MVP runs are non-ephemeral by default so `-ThreadId ` can resume and poll later. `-MaxRuntimeSeconds ` is passed into worker runtime; timeout writes a failed worker receipt and exits. Failed modeling now blocks downstream verification until the failed result is reviewed. -- Current Mom-ready status: the normal MVP pass reaches Face -> coordinator -> detached runtime -> heartbeat sleep, and modeling workers now complete through the ChatGPT subscription transport. The first failure was a stack of violated observability/runtime invariants: worker prompts prepended the whole shared persistent-memory rite, Responses frame liveness was invisible until completion, and the runtime tried to persist hundreds of text deltas before completing the worker job. Role/reorient workers now get a compact Epiphany worker boundary instead of full persistent memory; runtime-spine records sampled raw Responses frame kinds with small previews; contiguous reasoning/text deltas compact before durable storage; and live proofs completed `2fe38dcd-d99e-4c73-9a58-afcc81f851c7`, `241e3851-e3ea-4877-a63b-0d2bbd96a7e2`, and `85149a26-6975-403f-ac93-092b717c5825` instead of timing out. The second failure was stale lifecycle authority: completed runtime jobs remained as unresolved `runtime_links`, replacement launches treated historical active links as current, and one bad validation path opened an orphan job before rejecting the state patch. Latest-link-wins is now the runtime-link invariant, terminal links project completed jobs, stale active history cannot veto replacement, launch validation happens before opening runtime jobs, and completed-but-unreviewable modeling findings stop for review instead of relaunching the same lane. The Eyes/source-gather fork is now landed: Research is a fixed Eyes lane with launch/result/accept/status/coordinator/protocol support, and `regather-needed` modeling findings route to `LaunchResearch` instead of relaunching blind Proprioception. Research statePatch admission is Eyes-shaped only: observations, evidence, scratch, and optional investigationCheckpoint; no graph, planning, objective, or checkpoint authority. Mind admission now leaves typed runtime-spine proof: role/reorient acceptance persists `epiphany.mind.gateway_review` before state admission and `epiphany.mind.state_commit_receipt` after admission with the resulting durable revision. Launch contracts now split the broad receipt catalogue from effect-specific proof profiles for state admission, evidence promotion, repo action, verification, and continuity recovery. Research evidence promotion enforces Substrate Gate read/snapshot grant, Eyes evidence packet, and Mind review before state admission; Verification acceptance enforces Soul verdict and Mind review; Reorient acceptance enforces Continuity recovery receipt and Mind review. `epiphany-mvp-coordinator` now records a typed Substrate Gate grant plus Hands intent/review gate when the coordinator selects `continueImplementation`, including a structured `recordPassCommand` template; `epiphany-hands-action` records patch/command/commit receipts against that gate and refuses mismatched, unapproved, or out-of-scope consequences. `epiphany-mvp-coordinator-smoke` now proves the deterministic path: forced `continueImplementation`, gate emission, and `record-pass` receipts in the smoke runtime-spine store. Live run `local-20260612-133920` proved a receipt-only Verification `needs-evidence` finding can be accepted through `roleAccept` and advance to a Hands gate without granting Soul statePatch authority. Runtime-spine now detects and summarizes a complete post-verification Hands patch/command/commit receipt chain so the coordinator can route Soul after Hands, and Verification launches append that chain as bounded dynamic context with receipt ids, resolved receipt payload fields, command artifact previews, commit sha, changed paths, source-path proof notes, and source refs. The bridge launch-context test seeds a real runtime-spine Hands chain and asserts the Verification context contains the receipt ids, payload section, artifact preview, and source-path proof. The corrected work loop is Hands -> Soul -> Proprioception -> Hands: Soul verifies concrete consequence receipts and changed source, then Proprioception updates the machine model from verified consequence before another implementation turn. +- Current Mom-ready status: the normal MVP pass reaches Face -> coordinator -> detached runtime -> heartbeat sleep, and modeling workers now complete through the ChatGPT subscription transport. The first failure was a stack of violated observability/runtime invariants: worker prompts prepended the whole shared persistent-memory rite, Responses frame liveness was invisible until completion, and the runtime tried to persist hundreds of text deltas before completing the worker job. Role/reorient workers now get a compact Epiphany worker boundary instead of full persistent memory; runtime-spine records sampled raw Responses frame kinds with small previews; contiguous reasoning/text deltas compact before durable storage; and live proofs completed `2fe38dcd-d99e-4c73-9a58-afcc81f851c7`, `241e3851-e3ea-4877-a63b-0d2bbd96a7e2`, and `85149a26-6975-403f-ac93-092b717c5825` instead of timing out. The second failure was stale lifecycle authority: completed runtime jobs remained as unresolved `runtime_links`, replacement launches treated historical active links as current, and one bad validation path opened an orphan job before rejecting the state patch. Latest-link-wins is now the runtime-link invariant, terminal links project completed jobs, stale active history cannot veto replacement, launch validation happens before opening runtime jobs, and completed-but-unreviewable modeling findings stop for review instead of relaunching the same lane. The Eyes/source-gather fork is now landed: Research is a fixed Eyes lane with launch/result/accept/status/coordinator/protocol support, and `regather-needed` modeling findings route to `LaunchResearch` instead of relaunching blind Proprioception. Research statePatch admission is Eyes-shaped only: observations, evidence, scratch, and optional investigationCheckpoint; no graph, planning, objective, or checkpoint authority. Mind admission now leaves typed runtime-spine proof: role/reorient acceptance persists `epiphany.mind.gateway_review` before state admission and `epiphany.mind.state_commit_receipt` after admission with the resulting durable revision. Launch contracts now split the broad receipt catalogue from effect-specific proof profiles for state admission, evidence promotion, repo action, verification, and continuity recovery. Research evidence promotion enforces Substrate Gate read/snapshot grant, Eyes evidence packet, and Mind review before state admission; Verification acceptance enforces Soul verdict and Mind review; Reorient acceptance enforces Continuity recovery receipt and Mind review. `epiphany-mvp-coordinator` now records a typed Substrate Gate grant plus Hands intent/review gate when the coordinator selects `continueImplementation`, including a structured `recordPassCommand` template; `epiphany-hands-action` records patch/command/commit receipts against that gate and refuses mismatched, unapproved, or out-of-scope consequences. `epiphany-mvp-coordinator-smoke` now proves the deterministic path: forced `continueImplementation`, gate emission, and `record-pass` receipts in the smoke runtime-spine store. Live run `local-20260612-133920` proved a receipt-only Verification `needs-evidence` finding can be accepted through `roleAccept` and advance to a Hands gate without granting Soul statePatch authority. Runtime-spine now detects and summarizes a complete post-verification Hands patch/command/commit receipt chain so the coordinator can route Soul after Hands. Verification launches now write that chain into the internal CultMesh Verse as `epiphany.cultmesh.work_loop_telemetry.v0` and render a Soul packet from it; Modeling launches read the latest packet, attach accepted Soul receipt ids, and render the Proprioception packet from the same typed state. The corrected work loop is Hands -> Soul -> Proprioception -> Hands: Soul verifies concrete consequence receipts and changed source, then Proprioception updates the machine model from verified consequence before another implementation turn. - The investment dossier readiness target is now explicit: `E:\Projects\gamecult-site\docs\gamecult_integrated_dossier.tex` expects Epiphany to be part of a Bifrost-first labor loop, not only a local Mom demo. The external proof bar is: Bifrost owns topics/work items/dispatch packets/receipts/credit/reward pressure; Epiphany executes bounded work; maintainers review artifacts; public/operator evidence records scope, consent, roles, model spend, review load, artifacts, accepted/rejected outcome, memory lessons, and case-study permission; and private worker/operator/agent context stays sealed. Diligence also asks for a live fresh-repo Epiphany demo, Bifrost work item/topic/agent transport/receipt/ledger demo, CultMesh status, VoidBot/Discord swarm demo, compute/output metrics, and security model for secrets/write permissions/public-private exports. - This Codex operator's own roadmap/todo posture has been retuned for this scale target, with the Epiphany Imagination specialist as an optional sub-agent rail rather than the whole point. `notes/epiphany-investor-readiness-roadmap.md` now says: make the local Mom MVP a repeatable proof bundle; build the Bifrost-first external-work bridge; add compute/review/accepted-artifact accounting; prove fresh-repo operation without supervisor contamination; keep public/operator-safe exports sealed; and treat angel capital as fuel for capacity, not command authority. The Imagination specialist prompt was also updated so investor-scale Objective Drafts must name Bifrost provenance, bounded Epiphany proof, maintainer review, receipts/ledger evidence, compute/output metrics, public/private export safety, consent, and legal/security gates. - Local operator runs now write typed CultMesh intent/receipt documents to `.epiphany-run/cultmesh/operator-runs.ccmp` through `epiphany-operator-run`. The wrapper writes intent before acting and a completion receipt after success; this is the local consent/trace rail, not a hidden scheduler queue. @@ -51,7 +51,7 @@ remembers doctrine; the branch remembers the blade. - CultMesh is now the preferred Rust abstraction for that local store work. The compile-time Rust substrate is repo-contained: `vendor/cultcache-rs`, `vendor/cultnet-rs`, and `vendor/cultmesh-rs`. The old `E:\Projects\CultLib\crates\*` dependency body is dead in this checkout and must not be revived by accident. Vendored CultCache reads/writes `cultcache.store.v1`, so `state/ledgers.msgpack` and `epiphany-state status` are aligned again. The first integrations are deliberately small: status, Verse policy, global room policy, organ contract policy, native operator status, native operator snapshots, and local operator run intent/receipt round-trip through CultMesh. `notes/epiphany-verse-architecture.md` now names the local Verse/Odin/Yggdrasil architecture: Odin sees advertised Verse metadata without bypassing boundaries, Yggdrasil hosts important trusted GameCult Verses such as Bifrost, and prompt assembly should query compact local Verse plus semantic memory packets instead of carrying the whole archive. Role/reorient launch documents now have optional `dynamicPromptContext`; runtime prompt assembly consumes that field into worker instructions, `epiphany-prompt-context-smoke` proves a rendered Verse/memory packet is preserved on a role launch document, live bridge role/reorient launches now feed local Verse plus memory graph context from sibling `local-verse.ccmp` and `memory-graph.msgpack` stores beside runtime-spine, and the bridge launch-context test proves the packet survives into a persisted runtime-spine worker launch request. The memory graph refreshes from current typed thread-state repo graphs when absent, so thin state remains visibly thin. Local-run status now has an operator read proof too: `tools/epiphany_local_run.ps1 -Mode status` builds/calls `epiphany-verse-query` and writes `local-verse-context.json` from `.epiphany-run\cultmesh\local-verse.ccmp` beside `status.json` and the operator snapshot. Use `cargo run --manifest-path .\epiphany-core\Cargo.toml --bin epiphany-cultmesh-smoke`, `cargo run --manifest-path .\epiphany-core\Cargo.toml --bin epiphany-cultmesh-status -- smoke --store .\.epiphany-smoke\cultmesh\operator-status.ccmp --runtime-id epiphany-cultmesh-status-smoke`, `cargo run --manifest-path .\epiphany-core\Cargo.toml --bin epiphany-operator-snapshot -- smoke --store .\.epiphany-smoke\cultmesh\operator-snapshots.ccmp --runtime-id epiphany-operator-snapshot-smoke --snapshot-id smoke-status`, `cargo run --manifest-path .\epiphany-core\Cargo.toml --bin epiphany-operator-run -- smoke --store .\.epiphany-smoke\cultmesh\operator-runs.ccmp --runtime-id epiphany-operator-run-smoke --run-id smoke-run`, `cargo run --manifest-path .\epiphany-core\Cargo.toml --bin epiphany-verse-query -- smoke`, `cargo run --manifest-path .\epiphany-core\Cargo.toml --bin epiphany-prompt-context-smoke`, and `.\tools\epiphany_local_run.ps1 -Mode status` for the focused proofs. Future local dream/status/Verse work should start from CultMesh, not raw CultNet, unless the task is polishing the CultMesh internals themselves. Preserve the three Verse tiers: `epiphany-internal` for private sub-agent typed state, `gamecult-local` for trusted LAN/Yggdrasil-tunnel GameCult sharing, and `epiphany-global` for untrusted public dreams plus topic-specific threaded public rooms for Face posts. - `notes/codex-auth-spine-inventory.md` is the source-grounded keeper list for that reliquary. Corrected compliance invariant: Codex-compatible auth identity stays anchored in vendored Codex-derived auth machinery. `epiphany-openai-auth-spine` is now a thin Epiphany-named boundary over `codex-login`, not a clean-room clone of credential storage or token refresh. Codex apps, skills, marketplace, plugin UX, broad app-server workflow, and JSON-RPC sprawl remain cuttable because they are not subscription-auth legitimacy. - Edge JSON is allowed for schema description, hostile ingress before immediate typed parsing, sealed forensic artifacts, or named quarantine experiments. When both subsystems are ours, runtime data must remain typed CultCache documents and move over CultNet typed contracts. Generic `serde_json::Value` in worker launch/result/selfPatch/runtime flow is contamination until classified and replaced. -- Hands now has a first executable action receipt spine. `epiphany-core::hands_gateway` owns `HandsActionIntent`, `HandsActionReview`, `HandsPatchReceipt`, `HandsCommandReceipt`, and `HandsCommitReceipt`; runtime-spine can persist/reread them; `runtime_spine_persists_mind_gateway_review_receipts` includes the Hands chain beside Mind/Eyes/Substrate/Soul/Continuity proofs and proves the post-timestamp Hands receipt-chain detector; `epiphany-hands-action-smoke` emits intent/review/patch/command/commit receipt ids from `.epiphany-smoke\runtime-spine\hands-action-smoke.msgpack`; and the repo-action launch proof profile now requires action intent, action review, and patch receipt together. `epiphany-mvp-coordinator` now turns `continueImplementation` into a persisted Substrate Gate grant plus Hands intent/review gate and includes the receipt ids in the operator step. `epiphany-hands-action` is the native consequence recorder for that gate: `record-patch`, `record-command`, `record-commit`, and turn-level `record-pass` load the stored intent/review or `finalAction.handsActionGate` from `coordinator-summary.json`, require an approved matching review, enforce allowed operations, and keep patch/commit changed paths inside the requested scope. `epiphany-mvp-coordinator-smoke` includes the deterministic Hands pass proof. The coordinator now treats a complete Hands receipt chain after an accepted Soul result as new implementation evidence, launches Soul again, and routes a passing accepted Soul result to Proprioception/modeling before another Hands turn. Verification role launches append the latest complete post-verification Hands receipt chain into `dynamicPromptContext`, including resolved receipt payload fields and small stdout/stderr artifact previews, so Soul can judge actual patch/command/commit receipts and artifacts rather than infer from stale graph prose. +- Hands now has a first executable action receipt spine. `epiphany-core::hands_gateway` owns `HandsActionIntent`, `HandsActionReview`, `HandsPatchReceipt`, `HandsCommandReceipt`, and `HandsCommitReceipt`; runtime-spine can persist/reread them; `runtime_spine_persists_mind_gateway_review_receipts` includes the Hands chain beside Mind/Eyes/Substrate/Soul/Continuity proofs and proves the post-timestamp Hands receipt-chain detector; `epiphany-hands-action-smoke` emits intent/review/patch/command/commit receipt ids from `.epiphany-smoke\runtime-spine\hands-action-smoke.msgpack`; and the repo-action launch proof profile now requires action intent, action review, and patch receipt together. `epiphany-mvp-coordinator` now turns `continueImplementation` into a persisted Substrate Gate grant plus Hands intent/review gate and includes the receipt ids in the operator step. `epiphany-hands-action` is the native consequence recorder for that gate: `record-patch`, `record-command`, `record-commit`, and turn-level `record-pass` load the stored intent/review or `finalAction.handsActionGate` from `coordinator-summary.json`, require an approved matching review, enforce allowed operations, and keep patch/commit changed paths inside the requested scope. `epiphany-mvp-coordinator-smoke` includes the deterministic Hands pass proof. The coordinator now treats a complete Hands receipt chain after an accepted Soul result as new implementation evidence, launches Soul again, and routes a passing accepted Soul result to Proprioception/modeling before another Hands turn. Work-loop telemetry is now typed internal CultMesh state: Verification role launches write `epiphany.cultmesh.work_loop_telemetry.v0` beside runtime-spine, render that packet for Soul with resolved payload fields and stdout/stderr previews, and Modeling launches read/enrich the latest packet with Soul acceptance receipt ids before Proprioception updates the map. - `notes/epiphany-swarm-readiness-plan.md` is the current live-fire direction gate. The local runner proves startup/status/coordinator wiring; it does not authorize unattended swarm operation. Carry VoidBot's lessons forward: one CTB-style initiative scheduler, typed pause/brake, active-turn freeze, cooldown after completion, stale active-turn recovery receipts, parent-side speech eligibility, memory lifecycle phases, and typed operation proposals instead of prompt-owned governance. - `epiphany-openai-runtime` worker result ingress now parses assistant output directly into typed role/reorient ingress structs selected from the durable launch document, stores nested `statePatch` and `selfPatch` as typed MessagePack in `EpiphanyRuntimeRoleWorkerResult`, and no longer passes worker result data through generic `serde_json::Value`. JSON survives there only as the OpenAI text-output edge before typed deserialization. - Agent self-memory review/application now has typed `AgentSelfPatch` core APIs. JSON-value selfPatch functions are compatibility wrappers for CLI/artifact ingress; native callers should parse once at the edge and then call `review_agent_self_patch_document` / `apply_agent_self_patch_document`. Role-result self-persistence no longer exports a JSON-value reviewer; the live API is `review_role_self_patch_document`. diff --git a/state/ledgers.msgpack b/state/ledgers.msgpack index 04a9f98672cd8b2655bf7a7a1d6fcfa574649dae..5dc0a881affd37356a49f5df761fbfb34667857e 100644 GIT binary patch delta 378 zcmYL_u}T9`5Ji3483-tnG=hxSNfMF`MA%BON)Z$k1x3Tl?j-y0<-K)wk~Ou3et^q< zf}o8cg8qP=_z(VoU}fn>)YNz8o_lZlQF#3<+?PeM<+&SPvw8S3=RB=Htcf!r<}Xs` zGIhjF>Nt;!*UxUMi2IpRA2d$l{KK{$oL_~kdR``#IduqoaBh^6w&=h)W&t_ zlO1Mnw@&GZ&_@+