From a0173e220ce30ec17282372d6e78350de5df6f46 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sat, 20 Jun 2026 23:18:42 +0100 Subject: [PATCH] Ingest Idunn deployment receipts from CultMesh --- ...any-repo-deployment-config-family-smoke.rs | 108 ++++++-- epiphany-core/src/bin/epiphany-work.rs | 146 ++++++++++- epiphany-core/src/cultmesh_integration.rs | 235 ++++++++++++++++++ epiphany-core/src/lib.rs | 8 + notes/epiphany-repo-swarm-mvp-contract.md | 18 +- notes/fresh-workspace-handoff.md | 2 +- state/ledgers.msgpack | Bin 355682 -> 356266 bytes state/map.yaml | 6 +- 8 files changed, 483 insertions(+), 40 deletions(-) diff --git a/epiphany-core/src/bin/epiphany-repo-deployment-config-family-smoke.rs b/epiphany-core/src/bin/epiphany-repo-deployment-config-family-smoke.rs index 1a8244e2..fa871c24 100644 --- a/epiphany-core/src/bin/epiphany-repo-deployment-config-family-smoke.rs +++ b/epiphany-core/src/bin/epiphany-repo-deployment-config-family-smoke.rs @@ -2,6 +2,10 @@ use anyhow::Context; use anyhow::Result; use anyhow::anyhow; use chrono::Utc; +use epiphany_core::EpiphanyCultMeshIdunnAftercareAuditReceiptEntry; +use epiphany_core::EpiphanyCultMeshIdunnDeploymentReceiptEntry; +use epiphany_core::write_epiphany_cultmesh_idunn_aftercare_audit_receipt; +use epiphany_core::write_epiphany_cultmesh_idunn_deployment_receipt; use serde_json::Value; use serde_json::json; use std::env; @@ -221,29 +225,53 @@ fn run_smoke(args: Args) -> Result { ], &root, )?; - let idunn_receipt_dir = repo.join(".epiphany").join("work").join("idunn-deployment"); - fs::create_dir_all(&idunn_receipt_dir) - .with_context(|| format!("failed to create {}", idunn_receipt_dir.display()))?; - let idunn_deployment_receipt_path = idunn_receipt_dir.join("fixture-idunn-deployment.json"); - let idunn_aftercare_receipt_path = idunn_receipt_dir.join("fixture-idunn-aftercare.json"); - write_json( - &idunn_deployment_receipt_path, - &json!({ - "schemaVersion": "gamecult.idunn.deployment_receipt.v0", - "status": "deployed", - "trigger": "git-push-observed-by-idunn", - "watchedRef": "refs/heads/main", - "privateStateExposed": false - }), + let current_commit = git_output(["rev-parse", "HEAD"], &repo)?; + let idunn_deployment_receipt_id = "fixture-idunn-deployment"; + let idunn_aftercare_receipt_id = "fixture-idunn-aftercare"; + write_epiphany_cultmesh_idunn_deployment_receipt( + &local_verse, + "repo-deployment-config-family-smoke", + EpiphanyCultMeshIdunnDeploymentReceiptEntry { + schema_version: "gamecult.idunn.deployment_receipt.v0".to_string(), + receipt_id: idunn_deployment_receipt_id.to_string(), + runtime_id: "repo-deployment-config-family-smoke".to_string(), + verse_id: "gamecult-local".to_string(), + status: "deployed".to_string(), + trigger: "git-push-observed-by-idunn".to_string(), + watched_ref: "refs/heads/main".to_string(), + source_commit: current_commit, + result_ref: "idunn://deployment/fixture-idunn-deployment".to_string(), + result_summary: + "Fixture Idunn deployment receipt proves the repo audit can ingest sealed CultMesh receipt refs." + .to_string(), + private_state_exposed: false, + notes: vec![ + "Idunn owns deployment execution; this local Verse row is an operator-safe receipt projection." + .to_string(), + ], + }, )?; - write_json( - &idunn_aftercare_receipt_path, - &json!({ - "schemaVersion": "gamecult.idunn.deployment_aftercare_audit.v0", - "status": "complete", - "checkedRef": "refs/heads/main", - "privateStateExposed": false - }), + write_epiphany_cultmesh_idunn_aftercare_audit_receipt( + &local_verse, + "repo-deployment-config-family-smoke", + EpiphanyCultMeshIdunnAftercareAuditReceiptEntry { + schema_version: "gamecult.idunn.deployment_aftercare_audit.v0".to_string(), + receipt_id: idunn_aftercare_receipt_id.to_string(), + runtime_id: "repo-deployment-config-family-smoke".to_string(), + verse_id: "gamecult-local".to_string(), + status: "complete".to_string(), + checked_ref: "refs/heads/main".to_string(), + deployment_receipt_id: idunn_deployment_receipt_id.to_string(), + audit_ref: "idunn://deployment-aftercare/fixture-idunn-aftercare".to_string(), + result_summary: + "Fixture Idunn aftercare audit receipt proves the repo audit can close from sealed CultMesh receipt refs." + .to_string(), + private_state_exposed: false, + notes: vec![ + "Idunn owns aftercare; this local Verse row exposes status without private deployment state." + .to_string(), + ], + }, )?; let aftercare = cargo_json( &manifest, @@ -252,10 +280,14 @@ fn run_smoke(args: Args) -> Result { "deployment-aftercare-audit", "--workspace", path_str(&repo)?, - "--idunn-deployment-receipt", - path_str(&idunn_deployment_receipt_path)?, - "--aftercare-audit-receipt", - path_str(&idunn_aftercare_receipt_path)?, + "--local-verse-store", + path_str(&local_verse)?, + "--runtime-id", + "repo-deployment-config-family-smoke", + "--idunn-deployment-receipt-ref", + "latest", + "--aftercare-audit-receipt-ref", + "latest", ], &root, )?; @@ -399,6 +431,26 @@ fn run_smoke(args: Args) -> Result { require_bool(&aftercare, &["mergeAuthorized"], false)?; require_bool(&aftercare, &["daemonOwnsExecution"], true)?; require_bool(&aftercare, &["privateStateExposed"], false)?; + require_eq( + &aftercare, + &["idunnDeploymentReceipt", "source"], + "cultmesh", + )?; + require_eq( + &aftercare, + &["idunnDeploymentReceipt", "receiptId"], + idunn_deployment_receipt_id, + )?; + require_eq( + &aftercare, + &["idunnAftercareAuditReceipt", "source"], + "cultmesh", + )?; + require_eq( + &aftercare, + &["idunnAftercareAuditReceipt", "receiptId"], + idunn_aftercare_receipt_id, + )?; require_eq( &aftercare, &["idunnDeploymentReceipt", "schemaVersion"], @@ -434,6 +486,10 @@ fn run_smoke(args: Args) -> Result { "mutatesRemoteWhenRun": runbook["mutatesRemoteWhenRun"], "deploymentAftercareAuditStatus": aftercare["status"], "deploymentComplete": aftercare["deploymentComplete"], + "idunnDeploymentReceiptSource": aftercare["idunnDeploymentReceipt"]["source"], + "idunnAftercareAuditReceiptSource": aftercare["idunnAftercareAuditReceipt"]["source"], + "idunnDeploymentReceiptId": aftercare["idunnDeploymentReceipt"]["receiptId"], + "idunnAftercareAuditReceiptId": aftercare["idunnAftercareAuditReceipt"]["receiptId"], "deploymentTrigger": "git-push-observed-by-idunn", "deploymentOwner": "Idunn", "daemonOwnsExecution": true, diff --git a/epiphany-core/src/bin/epiphany-work.rs b/epiphany-core/src/bin/epiphany-work.rs index cc84aba0..9fec7b45 100644 --- a/epiphany-core/src/bin/epiphany-work.rs +++ b/epiphany-core/src/bin/epiphany-work.rs @@ -31,8 +31,12 @@ use epiphany_core::hands_commit_receipt_for_review; use epiphany_core::hands_patch_receipt_for_review; use epiphany_core::hands_pr_receipt_for_review; use epiphany_core::initialize_runtime_spine; +use epiphany_core::load_epiphany_cultmesh_idunn_aftercare_audit_receipt; +use epiphany_core::load_epiphany_cultmesh_idunn_deployment_receipt; use epiphany_core::load_epiphany_cultmesh_repo_work_overviews; use epiphany_core::load_epiphany_cultmesh_swarm_brake; +use epiphany_core::load_latest_epiphany_cultmesh_idunn_aftercare_audit_receipt; +use epiphany_core::load_latest_epiphany_cultmesh_idunn_deployment_receipt; use epiphany_core::load_latest_epiphany_cultmesh_repo_work_overview; use epiphany_core::mind_state_commit_receipt; use epiphany_core::put_hands_action_intent; @@ -348,9 +352,13 @@ struct DeploymentExecutionRunbookArgs { struct DeploymentAftercareAuditArgs { workspace: PathBuf, artifact_dir: Option, + local_verse_store: Option, + runtime_id: String, runbook_receipt: Option, idunn_deployment_receipt: Option, + idunn_deployment_receipt_ref: Option, aftercare_audit_receipt: Option, + aftercare_audit_receipt_ref: Option, write_receipt: bool, } @@ -1184,9 +1192,13 @@ fn parse_deployment_aftercare_audit_args( ) -> Result { let mut workspace = None; let mut artifact_dir = None; + let mut local_verse_store = None; + let mut runtime_id = "repo-swarm-local".to_string(); let mut runbook_receipt = None; let mut idunn_deployment_receipt = None; + let mut idunn_deployment_receipt_ref = None; let mut aftercare_audit_receipt = None; + let mut aftercare_audit_receipt_ref = None; let mut write_receipt = true; let mut args = args.peekable(); @@ -1194,15 +1206,27 @@ fn parse_deployment_aftercare_audit_args( match arg.as_str() { "--workspace" => workspace = Some(take_path(&mut args, "--workspace")?), "--artifact-dir" => artifact_dir = Some(take_path(&mut args, "--artifact-dir")?), + "--local-verse-store" | "--store" => { + local_verse_store = Some(take_path(&mut args, "--local-verse-store")?); + } + "--runtime-id" => runtime_id = take_string(&mut args, "--runtime-id")?, "--runbook-receipt" => { runbook_receipt = Some(take_path(&mut args, "--runbook-receipt")?) } "--idunn-deployment-receipt" | "--deployment-receipt" => { idunn_deployment_receipt = Some(take_path(&mut args, "--idunn-deployment-receipt")?) } + "--idunn-deployment-receipt-ref" | "--deployment-receipt-ref" => { + idunn_deployment_receipt_ref = + Some(take_string(&mut args, "--idunn-deployment-receipt-ref")?) + } "--aftercare-audit-receipt" | "--aftercare-receipt" => { aftercare_audit_receipt = Some(take_path(&mut args, "--aftercare-audit-receipt")?) } + "--aftercare-audit-receipt-ref" | "--aftercare-receipt-ref" => { + aftercare_audit_receipt_ref = + Some(take_string(&mut args, "--aftercare-audit-receipt-ref")?) + } "--no-write" | "--read-only" => write_receipt = false, other => { return Err(anyhow!( @@ -1214,9 +1238,13 @@ fn parse_deployment_aftercare_audit_args( Ok(DeploymentAftercareAuditArgs { workspace: workspace.context("missing --workspace")?, artifact_dir, + local_verse_store, + runtime_id, runbook_receipt, idunn_deployment_receipt, + idunn_deployment_receipt_ref, aftercare_audit_receipt, + aftercare_audit_receipt_ref, write_receipt, }) } @@ -10639,8 +10667,15 @@ fn run_deployment_aftercare_audit(args: DeploymentAftercareAuditArgs) -> Result< let runbook_receipt_path = args .runbook_receipt .unwrap_or_else(|| artifact_dir.join("deployment-execution-runbook.json")); + let local_verse_store = args + .local_verse_store + .unwrap_or_else(|| workspace.join(".epiphany").join("local-verse.ccmp")); let idunn_deployment_receipt_path = args.idunn_deployment_receipt; + let idunn_deployment_receipt_ref = args.idunn_deployment_receipt_ref; let aftercare_audit_receipt_path = args.aftercare_audit_receipt; + let aftercare_audit_receipt_ref = args.aftercare_audit_receipt_ref; + let runtime_id = args.runtime_id; + let local_verse_store_display = local_verse_store.display().to_string(); let generated_at = Utc::now().to_rfc3339_opts(chrono::SecondsFormat::Secs, true); let mut assertions = Vec::new(); @@ -10662,7 +10697,59 @@ fn run_deployment_aftercare_audit(args: DeploymentAftercareAuditArgs) -> Result< .to_string(), ); - let idunn_deployment_summary = if let Some(path) = idunn_deployment_receipt_path.as_ref() { + let idunn_deployment_summary = if let Some(receipt_ref) = idunn_deployment_receipt_ref.as_ref() + { + let receipt = if receipt_ref.trim().is_empty() || receipt_ref.trim() == "latest" { + load_latest_epiphany_cultmesh_idunn_deployment_receipt( + &local_verse_store, + runtime_id.clone(), + )? + } else { + load_epiphany_cultmesh_idunn_deployment_receipt( + &local_verse_store, + runtime_id.clone(), + receipt_ref, + )? + }; + if let Some(receipt) = receipt { + let schema_ok = receipt.schema_version == "gamecult.idunn.deployment_receipt.v0"; + let status_ok = matches!( + receipt.status.as_str(), + "ok" | "complete" | "deployed" | "passed" + ); + let private_ok = !receipt.private_state_exposed; + push_assertion( + &mut assertions, + "idunn-deployment-receipt-valid", + schema_ok && status_ok && private_ok, + "Idunn deployment receipt carries the expected CultMesh contract, successful status, and private-state seal." + .to_string(), + ); + json!({ + "source": "cultmesh", + "store": local_verse_store_display.clone(), + "runtimeId": runtime_id.clone(), + "receiptRef": receipt_ref, + "receiptId": receipt.receipt_id, + "schemaVersion": receipt.schema_version, + "status": receipt.status, + "trigger": receipt.trigger, + "watchedRef": receipt.watched_ref, + "resultRef": receipt.result_ref, + "privateStateExposed": receipt.private_state_exposed + }) + } else { + push_assertion( + &mut assertions, + "idunn-deployment-receipt-present", + false, + format!( + "Idunn deployment receipt ref {receipt_ref:?} was not found in the local Verse store." + ), + ); + Value::Null + } + } else if let Some(path) = idunn_deployment_receipt_path.as_ref() { let receipt = read_json(path)?; let schema_ok = string_from_json(&receipt, &["schemaVersion"]).as_deref() == Some("gamecult.idunn.deployment_receipt.v0"); @@ -10679,6 +10766,7 @@ fn run_deployment_aftercare_audit(args: DeploymentAftercareAuditArgs) -> Result< .to_string(), ); json!({ + "source": "file", "path": path, "schemaVersion": string_from_json(&receipt, &["schemaVersion"]).unwrap_or_else(|| "missing".to_string()), "status": status, @@ -10694,7 +10782,56 @@ fn run_deployment_aftercare_audit(args: DeploymentAftercareAuditArgs) -> Result< Value::Null }; - let aftercare_summary = if let Some(path) = aftercare_audit_receipt_path.as_ref() { + let aftercare_summary = if let Some(receipt_ref) = aftercare_audit_receipt_ref.as_ref() { + let receipt = if receipt_ref.trim().is_empty() || receipt_ref.trim() == "latest" { + load_latest_epiphany_cultmesh_idunn_aftercare_audit_receipt( + &local_verse_store, + runtime_id.clone(), + )? + } else { + load_epiphany_cultmesh_idunn_aftercare_audit_receipt( + &local_verse_store, + runtime_id.clone(), + receipt_ref, + )? + }; + if let Some(receipt) = receipt { + let schema_ok = + receipt.schema_version == "gamecult.idunn.deployment_aftercare_audit.v0"; + let status_ok = matches!(receipt.status.as_str(), "ok" | "complete" | "passed"); + let private_ok = !receipt.private_state_exposed; + push_assertion( + &mut assertions, + "idunn-aftercare-audit-receipt-valid", + schema_ok && status_ok && private_ok, + "Idunn aftercare audit receipt carries the expected CultMesh contract, successful status, and private-state seal." + .to_string(), + ); + json!({ + "source": "cultmesh", + "store": local_verse_store_display.clone(), + "runtimeId": runtime_id.clone(), + "receiptRef": receipt_ref, + "receiptId": receipt.receipt_id, + "schemaVersion": receipt.schema_version, + "status": receipt.status, + "checkedRef": receipt.checked_ref, + "deploymentReceiptId": receipt.deployment_receipt_id, + "auditRef": receipt.audit_ref, + "privateStateExposed": receipt.private_state_exposed + }) + } else { + push_assertion( + &mut assertions, + "idunn-aftercare-audit-receipt-present", + false, + format!( + "Idunn aftercare audit receipt ref {receipt_ref:?} was not found in the local Verse store." + ), + ); + Value::Null + } + } else if let Some(path) = aftercare_audit_receipt_path.as_ref() { let receipt = read_json(path)?; let schema_ok = string_from_json(&receipt, &["schemaVersion"]).as_deref() == Some("gamecult.idunn.deployment_aftercare_audit.v0"); @@ -10711,6 +10848,7 @@ fn run_deployment_aftercare_audit(args: DeploymentAftercareAuditArgs) -> Result< .to_string(), ); json!({ + "source": "file", "path": path, "schemaVersion": string_from_json(&receipt, &["schemaVersion"]).unwrap_or_else(|| "missing".to_string()), "status": status, @@ -10744,6 +10882,8 @@ fn run_deployment_aftercare_audit(args: DeploymentAftercareAuditArgs) -> Result< "workspace": workspace, "receiptPath": receipt_path, "runbookReceiptPath": runbook_receipt_path, + "localVerseStore": local_verse_store_display, + "runtimeId": runtime_id, "idunnDeploymentReceipt": idunn_deployment_summary, "idunnAftercareAuditReceipt": aftercare_summary, "deploymentComplete": status == "complete", @@ -12938,7 +13078,7 @@ fn print_usage() { overview --workspace [--item ] [--accept-receipt ] [--no-write]\n\ deployment-config-audit --workspace [--artifact-dir ] [--no-write]\n\ deployment-execution-runbook --workspace [--artifact-dir ] [--remote origin] [--no-write]\n\ - deployment-aftercare-audit --workspace [--artifact-dir ] [--runbook-receipt ] [--idunn-deployment-receipt ] [--aftercare-audit-receipt ] [--no-write]\n\ + deployment-aftercare-audit --workspace [--artifact-dir ] [--local-verse-store ] [--runtime-id ] [--runbook-receipt ] [--idunn-deployment-receipt-ref |--idunn-deployment-receipt ] [--aftercare-audit-receipt-ref |--aftercare-audit-receipt ] [--no-write]\n\ export-proof --workspace [--item ] [--accept-receipt ] [--output ] [--local-verse-store ] [--runtime-id repo-swarm-local]\n\ tick --workspace [--item ] [--local-verse-store ] [--runtime-store ] [--dry-run]\n\ queue-run --workspace [--local-verse-store ] [--runtime-id repo-swarm-local] [--max-items 1] [--dry-run]" diff --git a/epiphany-core/src/cultmesh_integration.rs b/epiphany-core/src/cultmesh_integration.rs index 9e5388c2..196b3248 100644 --- a/epiphany-core/src/cultmesh_integration.rs +++ b/epiphany-core/src/cultmesh_integration.rs @@ -144,6 +144,14 @@ pub const EPIPHANY_CULTMESH_DAEMON_SERVICE_LIFECYCLE_RECEIPT_SCHEMA_VERSION: &st "epiphany.cultmesh.daemon_service_lifecycle_receipt.v0"; pub const EPIPHANY_CULTMESH_DAEMON_SERVICE_LIFECYCLE_RECEIPT_LATEST_KEY: &str = "epiphany-local/daemon-service-lifecycle-receipt/latest"; +pub const EPIPHANY_CULTMESH_IDUNN_DEPLOYMENT_RECEIPT_SCHEMA_VERSION: &str = + "gamecult.idunn.deployment_receipt.v0"; +pub const EPIPHANY_CULTMESH_IDUNN_DEPLOYMENT_RECEIPT_LATEST_KEY: &str = + "gamecult-local/idunn/deployment-receipt/latest"; +pub const EPIPHANY_CULTMESH_IDUNN_AFTERCARE_AUDIT_RECEIPT_SCHEMA_VERSION: &str = + "gamecult.idunn.deployment_aftercare_audit.v0"; +pub const EPIPHANY_CULTMESH_IDUNN_AFTERCARE_AUDIT_RECEIPT_LATEST_KEY: &str = + "gamecult-local/idunn/deployment-aftercare-audit/latest"; pub const EPIPHANY_CULTMESH_SWARM_BRAKE_TYPE: &str = "epiphany.cultmesh.swarm_brake"; pub const EPIPHANY_CULTMESH_SWARM_BRAKE_SCHEMA_VERSION: &str = "epiphany.cultmesh.swarm_brake.v0"; pub const EPIPHANY_CULTMESH_SWARM_BRAKE_KEY: &str = "epiphany-local/swarm-brake"; @@ -1294,6 +1302,68 @@ pub struct EpiphanyCultMeshDaemonServiceLifecycleReceiptEntry { pub notes: Vec, } +#[derive(Clone, Debug, PartialEq, Eq, DatabaseEntry)] +#[cultcache( + type = "gamecult.idunn.deployment_receipt", + schema = "EpiphanyCultMeshIdunnDeploymentReceiptEntry" +)] +pub struct EpiphanyCultMeshIdunnDeploymentReceiptEntry { + #[cultcache(key = 0)] + pub schema_version: String, + #[cultcache(key = 1)] + pub receipt_id: String, + #[cultcache(key = 2)] + pub runtime_id: String, + #[cultcache(key = 3)] + pub verse_id: String, + #[cultcache(key = 4)] + pub status: String, + #[cultcache(key = 5)] + pub trigger: String, + #[cultcache(key = 6)] + pub watched_ref: String, + #[cultcache(key = 7)] + pub source_commit: String, + #[cultcache(key = 8)] + pub result_ref: String, + #[cultcache(key = 9)] + pub result_summary: String, + #[cultcache(key = 10)] + pub private_state_exposed: bool, + #[cultcache(key = 11)] + pub notes: Vec, +} + +#[derive(Clone, Debug, PartialEq, Eq, DatabaseEntry)] +#[cultcache( + type = "gamecult.idunn.deployment_aftercare_audit", + schema = "EpiphanyCultMeshIdunnAftercareAuditReceiptEntry" +)] +pub struct EpiphanyCultMeshIdunnAftercareAuditReceiptEntry { + #[cultcache(key = 0)] + pub schema_version: String, + #[cultcache(key = 1)] + pub receipt_id: String, + #[cultcache(key = 2)] + pub runtime_id: String, + #[cultcache(key = 3)] + pub verse_id: String, + #[cultcache(key = 4)] + pub status: String, + #[cultcache(key = 5)] + pub checked_ref: String, + #[cultcache(key = 6)] + pub deployment_receipt_id: String, + #[cultcache(key = 7)] + pub audit_ref: String, + #[cultcache(key = 8)] + pub result_summary: String, + #[cultcache(key = 9)] + pub private_state_exposed: bool, + #[cultcache(key = 10)] + pub notes: Vec, +} + #[derive(Clone, Debug, PartialEq, Eq, Serialize)] #[serde(rename_all = "camelCase")] pub struct EpiphanyServiceExecutionAuditCheck { @@ -2216,6 +2286,8 @@ cultmesh_documents!(EpiphanyCultMeshDocuments { EpiphanyCultMeshDaemonRestartPolicyEntry => EPIPHANY_CULTMESH_DAEMON_RESTART_POLICY_SCHEMA_VERSION, EpiphanyCultMeshDaemonSchedulerReceiptEntry => EPIPHANY_CULTMESH_DAEMON_SCHEDULER_RECEIPT_SCHEMA_VERSION, EpiphanyCultMeshDaemonServiceLifecycleReceiptEntry => EPIPHANY_CULTMESH_DAEMON_SERVICE_LIFECYCLE_RECEIPT_SCHEMA_VERSION, + EpiphanyCultMeshIdunnDeploymentReceiptEntry => EPIPHANY_CULTMESH_IDUNN_DEPLOYMENT_RECEIPT_SCHEMA_VERSION, + EpiphanyCultMeshIdunnAftercareAuditReceiptEntry => EPIPHANY_CULTMESH_IDUNN_AFTERCARE_AUDIT_RECEIPT_SCHEMA_VERSION, EpiphanyCultMeshSwarmBrakeEntry => EPIPHANY_CULTMESH_SWARM_BRAKE_SCHEMA_VERSION, EpiphanyCultMeshPersonaSpeechAuditEntry => EPIPHANY_CULTMESH_PERSONA_SPEECH_AUDIT_SCHEMA_VERSION, EpiphanyCultMeshDaemonToolCapabilityEntry => EPIPHANY_CULTMESH_DAEMON_TOOL_CAPABILITY_SCHEMA_VERSION, @@ -3225,6 +3297,76 @@ pub fn load_epiphany_cultmesh_daemon_service_lifecycle_receipts( .collect()) } +pub fn write_epiphany_cultmesh_idunn_deployment_receipt( + store_path: impl AsRef, + runtime_id: impl Into, + receipt: EpiphanyCultMeshIdunnDeploymentReceiptEntry, +) -> Result { + validate_idunn_deployment_receipt(&receipt)?; + let mut node = open_epiphany_cultmesh_node(store_path, runtime_id)?; + let receipt_key = epiphany_cultmesh_idunn_deployment_receipt_key(&receipt.receipt_id); + let written = node.put(receipt_key.as_str(), &receipt)?; + node.put( + EPIPHANY_CULTMESH_IDUNN_DEPLOYMENT_RECEIPT_LATEST_KEY, + &written, + )?; + node.flush()?; + Ok(written) +} + +pub fn load_epiphany_cultmesh_idunn_deployment_receipt( + store_path: impl AsRef, + runtime_id: impl Into, + receipt_ref: impl AsRef, +) -> Result> { + let node = open_epiphany_cultmesh_node(store_path, runtime_id)?; + let key = epiphany_cultmesh_idunn_deployment_receipt_ref_key(receipt_ref.as_ref()); + node.get(key.as_str()) +} + +pub fn load_latest_epiphany_cultmesh_idunn_deployment_receipt( + store_path: impl AsRef, + runtime_id: impl Into, +) -> Result> { + let node = open_epiphany_cultmesh_node(store_path, runtime_id)?; + node.get(EPIPHANY_CULTMESH_IDUNN_DEPLOYMENT_RECEIPT_LATEST_KEY) +} + +pub fn write_epiphany_cultmesh_idunn_aftercare_audit_receipt( + store_path: impl AsRef, + runtime_id: impl Into, + receipt: EpiphanyCultMeshIdunnAftercareAuditReceiptEntry, +) -> Result { + validate_idunn_aftercare_audit_receipt(&receipt)?; + let mut node = open_epiphany_cultmesh_node(store_path, runtime_id)?; + let receipt_key = epiphany_cultmesh_idunn_aftercare_audit_receipt_key(&receipt.receipt_id); + let written = node.put(receipt_key.as_str(), &receipt)?; + node.put( + EPIPHANY_CULTMESH_IDUNN_AFTERCARE_AUDIT_RECEIPT_LATEST_KEY, + &written, + )?; + node.flush()?; + Ok(written) +} + +pub fn load_epiphany_cultmesh_idunn_aftercare_audit_receipt( + store_path: impl AsRef, + runtime_id: impl Into, + receipt_ref: impl AsRef, +) -> Result> { + let node = open_epiphany_cultmesh_node(store_path, runtime_id)?; + let key = epiphany_cultmesh_idunn_aftercare_audit_receipt_ref_key(receipt_ref.as_ref()); + node.get(key.as_str()) +} + +pub fn load_latest_epiphany_cultmesh_idunn_aftercare_audit_receipt( + store_path: impl AsRef, + runtime_id: impl Into, +) -> Result> { + let node = open_epiphany_cultmesh_node(store_path, runtime_id)?; + node.get(EPIPHANY_CULTMESH_IDUNN_AFTERCARE_AUDIT_RECEIPT_LATEST_KEY) +} + pub fn default_epiphany_cultmesh_swarm_brake( generated_at_utc: impl Into, ) -> EpiphanyCultMeshSwarmBrakeEntry { @@ -3497,6 +3639,69 @@ fn validate_daemon_service_lifecycle_receipt( Ok(()) } +fn validate_idunn_deployment_receipt( + receipt: &EpiphanyCultMeshIdunnDeploymentReceiptEntry, +) -> Result<()> { + if receipt.private_state_exposed { + return Err(anyhow!( + "Idunn deployment receipts must not expose private state" + )); + } + if receipt.schema_version != EPIPHANY_CULTMESH_IDUNN_DEPLOYMENT_RECEIPT_SCHEMA_VERSION { + return Err(anyhow!( + "Idunn deployment receipt schema_version must be {:?}", + EPIPHANY_CULTMESH_IDUNN_DEPLOYMENT_RECEIPT_SCHEMA_VERSION + )); + } + for (label, value) in [ + ("receipt id", receipt.receipt_id.as_str()), + ("runtime id", receipt.runtime_id.as_str()), + ("verse id", receipt.verse_id.as_str()), + ("status", receipt.status.as_str()), + ("trigger", receipt.trigger.as_str()), + ("watched ref", receipt.watched_ref.as_str()), + ("result ref", receipt.result_ref.as_str()), + ] { + if value.trim().is_empty() { + return Err(anyhow!("Idunn deployment receipt missing {label}")); + } + } + Ok(()) +} + +fn validate_idunn_aftercare_audit_receipt( + receipt: &EpiphanyCultMeshIdunnAftercareAuditReceiptEntry, +) -> Result<()> { + if receipt.private_state_exposed { + return Err(anyhow!( + "Idunn aftercare audit receipts must not expose private state" + )); + } + if receipt.schema_version != EPIPHANY_CULTMESH_IDUNN_AFTERCARE_AUDIT_RECEIPT_SCHEMA_VERSION { + return Err(anyhow!( + "Idunn aftercare audit receipt schema_version must be {:?}", + EPIPHANY_CULTMESH_IDUNN_AFTERCARE_AUDIT_RECEIPT_SCHEMA_VERSION + )); + } + for (label, value) in [ + ("receipt id", receipt.receipt_id.as_str()), + ("runtime id", receipt.runtime_id.as_str()), + ("verse id", receipt.verse_id.as_str()), + ("status", receipt.status.as_str()), + ("checked ref", receipt.checked_ref.as_str()), + ( + "deployment receipt id", + receipt.deployment_receipt_id.as_str(), + ), + ("audit ref", receipt.audit_ref.as_str()), + ] { + if value.trim().is_empty() { + return Err(anyhow!("Idunn aftercare audit receipt missing {label}")); + } + } + Ok(()) +} + pub fn epiphany_cultmesh_daemon_tool_invocation_intent_from_capability( intent_id: impl Into, requesting_agent_id: impl Into, @@ -5214,6 +5419,36 @@ fn epiphany_cultmesh_daemon_service_lifecycle_receipt_key(receipt_id: &str) -> S format!("epiphany-local/daemon-service-lifecycle-receipt/{receipt_id}") } +fn epiphany_cultmesh_idunn_deployment_receipt_key(receipt_id: &str) -> String { + format!("gamecult-local/idunn/deployment-receipt/{receipt_id}") +} + +fn epiphany_cultmesh_idunn_deployment_receipt_ref_key(receipt_ref: &str) -> String { + let trimmed = receipt_ref.trim(); + if trimmed.is_empty() || trimmed == "latest" { + EPIPHANY_CULTMESH_IDUNN_DEPLOYMENT_RECEIPT_LATEST_KEY.to_string() + } else if trimmed.starts_with("gamecult-local/") { + trimmed.to_string() + } else { + epiphany_cultmesh_idunn_deployment_receipt_key(trimmed) + } +} + +fn epiphany_cultmesh_idunn_aftercare_audit_receipt_key(receipt_id: &str) -> String { + format!("gamecult-local/idunn/deployment-aftercare-audit/{receipt_id}") +} + +fn epiphany_cultmesh_idunn_aftercare_audit_receipt_ref_key(receipt_ref: &str) -> String { + let trimmed = receipt_ref.trim(); + if trimmed.is_empty() || trimmed == "latest" { + EPIPHANY_CULTMESH_IDUNN_AFTERCARE_AUDIT_RECEIPT_LATEST_KEY.to_string() + } else if trimmed.starts_with("gamecult-local/") { + trimmed.to_string() + } else { + epiphany_cultmesh_idunn_aftercare_audit_receipt_key(trimmed) + } +} + fn epiphany_cultmesh_daemon_tool_invocation_receipt_key(receipt_id: &str) -> String { format!("epiphany-local/daemon-tool-invocation-receipt/{receipt_id}") } diff --git a/epiphany-core/src/lib.rs b/epiphany-core/src/lib.rs index 5d756e43..7d5dfd7a 100644 --- a/epiphany-core/src/lib.rs +++ b/epiphany-core/src/lib.rs @@ -257,6 +257,8 @@ pub use cultmesh_integration::EpiphanyCultMeshEyesContractEntry; pub use cultmesh_integration::EpiphanyCultMeshGlobalRoomPolicyEntry; pub use cultmesh_integration::EpiphanyCultMeshHandsActionGateEntry; pub use cultmesh_integration::EpiphanyCultMeshHandsContractEntry; +pub use cultmesh_integration::EpiphanyCultMeshIdunnAftercareAuditReceiptEntry; +pub use cultmesh_integration::EpiphanyCultMeshIdunnDeploymentReceiptEntry; pub use cultmesh_integration::EpiphanyCultMeshImaginationConsensusReceiptEntry; pub use cultmesh_integration::EpiphanyCultMeshMindContractEntry; pub use cultmesh_integration::EpiphanyCultMeshOdinAdvertisementEntry; @@ -322,6 +324,8 @@ pub use cultmesh_integration::load_epiphany_cultmesh_daemon_restart_policy_direc pub use cultmesh_integration::load_epiphany_cultmesh_daemon_service_lifecycle_receipts; pub use cultmesh_integration::load_epiphany_cultmesh_daemon_tool_directory; pub use cultmesh_integration::load_epiphany_cultmesh_eve_surface_directory; +pub use cultmesh_integration::load_epiphany_cultmesh_idunn_aftercare_audit_receipt; +pub use cultmesh_integration::load_epiphany_cultmesh_idunn_deployment_receipt; 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_repo_work_map_entries; @@ -345,6 +349,8 @@ pub use cultmesh_integration::load_latest_epiphany_cultmesh_daemon_tool_invocati pub use cultmesh_integration::load_latest_epiphany_cultmesh_eve_connection_intent; pub use cultmesh_integration::load_latest_epiphany_cultmesh_eve_connection_receipt; pub use cultmesh_integration::load_latest_epiphany_cultmesh_hands_action_gate; +pub use cultmesh_integration::load_latest_epiphany_cultmesh_idunn_aftercare_audit_receipt; +pub use cultmesh_integration::load_latest_epiphany_cultmesh_idunn_deployment_receipt; pub use cultmesh_integration::load_latest_epiphany_cultmesh_imagination_consensus_receipt; pub use cultmesh_integration::load_latest_epiphany_cultmesh_operator_run_intent; pub use cultmesh_integration::load_latest_epiphany_cultmesh_operator_run_receipt; @@ -384,6 +390,8 @@ pub use cultmesh_integration::write_epiphany_cultmesh_eyes_contracts; pub use cultmesh_integration::write_epiphany_cultmesh_global_room_policies; pub use cultmesh_integration::write_epiphany_cultmesh_hands_action_gate; pub use cultmesh_integration::write_epiphany_cultmesh_hands_contracts; +pub use cultmesh_integration::write_epiphany_cultmesh_idunn_aftercare_audit_receipt; +pub use cultmesh_integration::write_epiphany_cultmesh_idunn_deployment_receipt; pub use cultmesh_integration::write_epiphany_cultmesh_imagination_consensus_receipt; pub use cultmesh_integration::write_epiphany_cultmesh_mind_contracts; pub use cultmesh_integration::write_epiphany_cultmesh_operator_run_intent; diff --git a/notes/epiphany-repo-swarm-mvp-contract.md b/notes/epiphany-repo-swarm-mvp-contract.md index 6ff47f52..e1815a12 100644 --- a/notes/epiphany-repo-swarm-mvp-contract.md +++ b/notes/epiphany-repo-swarm-mvp-contract.md @@ -806,17 +806,21 @@ runbook beside config close and audit. The post-push receipt mouth is now explicit as well. `epiphany-work deployment-aftercare-audit --workspace ---idunn-deployment-receipt --aftercare-audit-receipt ` reads the -operator runbook receipt plus supplied Idunn deployment and aftercare receipts, -checks `gamecult.idunn.deployment_receipt.v0` and +--local-verse-store --idunn-deployment-receipt-ref +--aftercare-audit-receipt-ref ` reads the operator runbook receipt plus +sealed Idunn deployment and aftercare receipt projections from the repo-local +CultMesh store, checks `gamecult.idunn.deployment_receipt.v0` and `gamecult.idunn.deployment_aftercare_audit.v0`, and emits `epiphany.repo_deployment_aftercare_audit.v0`. It reports `complete` only when the runbook is ready and both Idunn receipts carry successful statuses and private-state seals; otherwise it reports the missing gate without mutating -remote refs or granting deployment authority. Smoke -`.epiphany-smoke\repo-deployment-config-family-20260620-215037` proved the -complete ingestion path from explicit fixture receipts with -`deploymentComplete=true` and `privateStateExposed=false`. +remote refs or granting deployment authority. The older explicit receipt-file +flags remain as compatibility reliquaries. Smoke +`.epiphany-smoke\repo-deployment-config-family-20260620-221205` proved the +CultMesh receipt-ref ingestion path with +`idunnDeploymentReceiptSource=cultmesh`, +`idunnAftercareAuditReceiptSource=cultmesh`, `deploymentComplete=true`, and +`privateStateExposed=false`. ### Landed Work Run Gate diff --git a/notes/fresh-workspace-handoff.md b/notes/fresh-workspace-handoff.md index 6623169a..a9e4647c 100644 --- a/notes/fresh-workspace-handoff.md +++ b/notes/fresh-workspace-handoff.md @@ -128,7 +128,7 @@ remembers doctrine; the branch remembers the blade. - 2026-06-20: Gjallar now has a branch lens over Mind-admitted repo-work maps. `repoWorkMapBranchLensRows` / `REPO-WORK-MAP-BRANCH` group accepted map consequences by branch with item count, changed-path count, safe-family list, latest item/commit/Mind commit, Bifrost gate, and `privateStateExposed=false`. Smoke `.epiphany-smoke\repo-close-mind-adoption-guard-20260620-210747` reran the counterfeit-adoption guard and proved `gjallarRepoWorkMapBranchLensCount=1` alongside the family/path lenses. This is branch-workbench sight only: Gjallar still does not schedule, publish, merge, deploy, keep daemons alive, or admit Mind state. - 2026-06-20: `epiphany-work deployment-config-audit` is live as the non-mutating Idunn handoff readback for repo deployment config. It reads `.epiphany/deployment.toml`, writes `epiphany.repo_deployment_config_audit.v0`, reports `ready-for-idunn-review` only when the disabled git-push Idunn trigger, CultMesh intent/receipt/aftercare contracts, required receipts, and authority seals are present, and always keeps execution/deployment/SSH/git-push/service/Hands/publication/merge/cross-body authority false. Smoke `.epiphany-smoke\repo-deployment-config-family-20260620-213042` proved the audit beside the `repo.deployment_config` close path with `daemonOwnsExecution=true`, `readyForIdunnReview=true`, and `privateStateExposed=false`. - 2026-06-20: `epiphany-work deployment-execution-runbook` is live as the explicit operator-owned git-push handoff for Idunn deployment. It requires the deployment config audit to pass, writes `.epiphany/work/idunn-deployment/idunn-git-push-runbook.ps1`, emits `epiphany.repo_deployment_execution_runbook.v0`, reports `ready-for-operator-git-push`, includes the exact `git push origin HEAD:refs/heads/main` route, runbook SHA-256, and required Idunn deployment/aftercare receipt contracts, and marks `requiresExplicitOperatorAuthority=true` plus `mutatesRemoteWhenRun=true` while keeping execution/deployment/SSH/git-push/service/Hands/publication/merge/cross-body authority false for the repo agent. Smoke `.epiphany-smoke\repo-deployment-config-family-20260620-214109` proved the runbook with `deploymentExecutionRunbookStatus=ready-for-operator-git-push`, SHA-256 `57560eda912b6e5c15f97acf53500534bb3bcf739098f329add3d88e5a9cd1d3`, and `privateStateExposed=false`. -- 2026-06-20: `epiphany-work deployment-aftercare-audit` is live as the post-operator Idunn receipt ingestion mouth. It reads the deployment runbook receipt plus explicit `gamecult.idunn.deployment_receipt.v0` and `gamecult.idunn.deployment_aftercare_audit.v0` files, emits `epiphany.repo_deployment_aftercare_audit.v0`, reports `complete` only when both Idunn receipts have successful statuses and private-state seals, and remains non-mutating with deployment/SSH/git-push/service/Hands/publication/merge authority false. Smoke `.epiphany-smoke\repo-deployment-config-family-20260620-215037` proved the complete path with fixture Idunn receipts, `deploymentAftercareAuditStatus=complete`, `deploymentComplete=true`, and `privateStateExposed=false`. +- 2026-06-20: `epiphany-work deployment-aftercare-audit` is live as the post-operator Idunn receipt ingestion mouth, and now reads sealed Idunn receipt projections from repo-local CultMesh refs. It reads the deployment runbook receipt plus `gamecult.idunn.deployment_receipt.v0` and `gamecult.idunn.deployment_aftercare_audit.v0` via `--local-verse-store`, `--idunn-deployment-receipt-ref`, and `--aftercare-audit-receipt-ref`, emits `epiphany.repo_deployment_aftercare_audit.v0`, reports `complete` only when both Idunn receipts have successful statuses and private-state seals, and remains non-mutating with deployment/SSH/git-push/service/Hands/publication/merge authority false. The older explicit receipt-file flags remain compatibility reliquaries. Smoke `.epiphany-smoke\repo-deployment-config-family-20260620-221205` proved the CultMesh ref path with `idunnDeploymentReceiptSource=cultmesh`, `idunnAftercareAuditReceiptSource=cultmesh`, `deploymentAftercareAuditStatus=complete`, `deploymentComplete=true`, and `privateStateExposed=false`. - 2026-06-20: Deeper model-authored closure review is now live. `epiphany-work close` accepts `--closure-model-verdict passed|failed|needs-work|blocked`, `--closure-model-finding`, and `--require-closure-model-verdict`; the close review embeds `epiphany.repo_work_model_closure_review.v0` under `modelingReview.closureReview`, records reviewed inputs and gate enforcement, and Soul refuses closure when a supplied or required model verdict does not pass. Focused smoke `.epiphany-smoke\closure-model-gate-20260620-135103` created a disposable repo, ran two `repo.status_section` items through public front doors, closed one with required model verdict `passed`, and blocked one with `needs-work` while `familyAssertions.status=passed`, `pathScopeMatched=true`, and `privateStateExposed=false`. Current remaining repo-swarm MVP organs are deeper interpreter/adoption semantics, more useful repo-owned configuration/action families, and Idunn-owned queue-run service lifecycle under explicit operator authority. - 2026-06-20: Mind adoption/interpreter depth now has a concrete interpretation packet. `epiphany-work adopt` writes `epiphany.repo_work_mind_adoption_decision.v0` before the main adoption receipt, embeds `epiphany.repo_work_mind_interpretation.v0` with input summary, safe-family recognition, requested-path classification, allowed branch-local Hands transition, and forbidden durable-state/publication/service/private transitions, then records Self presentation, Mind evidence review, safe-family requirement, branch-local scope, Bifrost publication gate, Soul closure requirement, and no Hands/durable-state/publication/merge/service/cross-body/private authority inside the Mind decision; the main adoption receipt cites that decision before granting branch-local Hands authority. Focused smoke `.epiphany-smoke\repo-planning-facets-20260620-175503` proves model-authored planning facets survive into Imagination, plan derivation, Mind interpretation, Mind decision, and adoption, while close still passes Soul/family/path checks with `privateStateExposed=false`. Current remaining repo-swarm MVP organs are deeper interpreter semantics beyond the first Mind interpretation packet, more useful repo-owned configuration/action families, and Idunn-owned queue-run service lifecycle under explicit operator authority. - 2026-06-20: `repo-manifest` is now the next non-planning safe family. `epiphany-work derive-plan --action-family repo-manifest` lowers accepted pressure into a structured `epiphany.toml` Body manifest with safe family `repo.body_manifest`, body domain, private/local/public Verse ids, Eve surface id, receipt-required capability hints, arbitrary shell sealed false, and private-state seals. Soul closure assertions now inspect the committed manifest for schema, safe family, summary, body domain, Verse ids, Eve surface, receipt requirement, no arbitrary shell, and private-state seals. Focused smoke `.epiphany-smoke\repo-manifest-family-20260620-141552` ran a disposable repo through init -> online -> accept -> repo-manifest derive-plan -> tick run/adopt/execute/close; Hands committed only `epiphany.toml`, Soul passed with `pathScopeMatched=true`, `familyAssertions.status=passed`, and `privateStateExposed=false`. Current remaining repo-swarm MVP organs are deeper interpreter/adoption semantics, additional useful repo-owned config/action families, and Idunn-owned queue-run service lifecycle under explicit operator authority. diff --git a/state/ledgers.msgpack b/state/ledgers.msgpack index af02ae6fa64cc5cd35b5a69e4e6a7bc2629e81e5..49141bd40410e61eba9fcba67d1b9001504e0ac3 100644 GIT binary patch delta 336 zcmYLDu}T9$5cMwE&XiFI79%Naj3x(yL?nfkg>@j^x;JM=_I5YBd&cVo3u}w8ZE7pQ z!auOHu@ph@OWcTP@tAot?>*kvd;8(D{kV~|vfL#-!8Q(6_yG5Er ztY#yk`MgNk>t$HJHCrrOdBXiD?dY_VqmjBUQTZM(JX*mm_IQ<(2c_pg>H?j2aGF<2 z!M_-|%Hhud76p=ty29!*GNXG^3ohZLlKu?cG~Nm~49Paz3QJ<$^=y#!55QP`g?YG< zY|MOZ;;KfC%^e4G@>6iSvI37q%qU~VE;!G9