diff --git a/epiphany-core/Cargo.toml b/epiphany-core/Cargo.toml index 3a6d655a..7af24250 100644 --- a/epiphany-core/Cargo.toml +++ b/epiphany-core/Cargo.toml @@ -31,6 +31,7 @@ epiphany-state-model = { path = "../epiphany-state-model" } ed25519-dalek = "2" ignore = "0.4.23" rand_core = { version = "0.6", features = ["getrandom"] } +zeroize = "1" postgres = "0.19" reqwest = { version = "0.12", features = ["blocking", "json"] } rmp-serde = "1" diff --git a/epiphany-core/src/bin/epiphany-daemon-supervisor.rs b/epiphany-core/src/bin/epiphany-daemon-supervisor.rs index 9980b519..244f85fd 100644 --- a/epiphany-core/src/bin/epiphany-daemon-supervisor.rs +++ b/epiphany-core/src/bin/epiphany-daemon-supervisor.rs @@ -3,6 +3,7 @@ use anyhow::Result; use chrono::DateTime; use chrono::Duration; use chrono::Utc; +use ed25519_dalek::SigningKey; use epiphany_core::EPIPHANY_CULTMESH_DAEMON_RESTART_POLICY_SCHEMA_VERSION; use epiphany_core::EPIPHANY_CULTMESH_DAEMON_SCHEDULER_RECEIPT_SCHEMA_VERSION; use epiphany_core::EPIPHANY_CULTMESH_DAEMON_SERVICE_LIFECYCLE_RECEIPT_SCHEMA_VERSION; @@ -46,6 +47,14 @@ use epiphany_core::write_epiphany_cultmesh_daemon_service_lifecycle_receipt; use epiphany_core::write_epiphany_cultmesh_managed_service_policy; use epiphany_core::write_epiphany_cultmesh_semantic_projector_service_policy; use epiphany_core::write_epiphany_cultmesh_workspace_coverage_projector_service_policy; +use epiphany_core::{ + WORKSPACE_COVERAGE_PROCESS_LAUNCH_SCHEMA_VERSION, WorkspaceCoverageManagedProcessLaunchEntry, + WorkspaceCoverageProcessBootstrap, capture_process_instance, native_boot_identity, + open_default_host_identity, sign_workspace_coverage_launch, + workspace_coverage_host_identity_record_digest, + write_workspace_coverage_managed_process_launch, write_workspace_coverage_process_bootstrap, +}; +use rand_core::{OsRng, RngCore}; use serde_json::Value; use serde_json::json; use sha2::Digest; @@ -56,6 +65,7 @@ use std::path::{Path, PathBuf}; use std::process::Command; use std::process::Stdio; use uuid::Uuid; +use zeroize::Zeroize; const SEMANTIC_PROJECTOR_SERVICE_ID: &str = "epiphany-memory-semantic-projector-service"; const SEMANTIC_PROJECTOR_EXECUTOR_ID: &str = "epiphany-memory-semantic-projector"; @@ -794,9 +804,9 @@ fn service_launch(args: Args) -> Result<()> { let started_at = Utc::now(); let command_path = service_command_path(&args)?; let service_args = service_serve_args(&args); + let coverage_reserved = args.service_id == WORKSPACE_COVERAGE_PROJECTOR_SERVICE_ID; let reserved_executor_id = match args.service_id.as_str() { SEMANTIC_PROJECTOR_SERVICE_ID => Some(SEMANTIC_PROJECTOR_EXECUTOR_ID), - WORKSPACE_COVERAGE_PROJECTOR_SERVICE_ID => Some(WORKSPACE_COVERAGE_PROJECTOR_EXECUTOR_ID), _ => None, }; let reserved_launch = if let Some(executor_id) = reserved_executor_id { @@ -828,11 +838,56 @@ fn service_launch(args: Args) -> Result<()> { } else { None }; + let coverage_launch = if coverage_reserved { + let (policy, digest) = load_epiphany_cultmesh_managed_service_policy_with_digest( + &args.store, + args.runtime_id.clone(), + &args.service_id, + )? + .context("reserved workspace coverage managed policy is absent")?; + if command_path != PathBuf::from(&policy.command) + || service_args != policy.args + || args.cwd.as_ref().map(|path| path.display().to_string()) != policy.cwd + { + anyhow::bail!("workspace coverage launch must use the exact current managed policy"); + } + if args.wait_child { + anyhow::bail!("workspace coverage launch is an infinite managed child"); + } + let host = open_default_host_identity() + .context("workspace coverage launch requires an enrolled host identity")?; + let boot = native_boot_identity() + .context("workspace coverage launch requires a proven native boot identity")?; + let mut seed = [0_u8; 32]; + OsRng.fill_bytes(&mut seed); + let provider_key = SigningKey::from_bytes(&seed); + Some(( + policy, + digest, + host, + boot, + Uuid::new_v4(), + Uuid::new_v4(), + seed, + provider_key, + )) + } else { + None + }; let mut command = Command::new(&command_path); command.args(&service_args); if let Some((_, _, receipt_id, _, _)) = &reserved_launch { command.env("EPIPHANY_STARTUP_LIFECYCLE_RECEIPT_ID", receipt_id); } + if let Some((_, _, _, _, launch_id, _, _, _)) = &coverage_launch { + command.env( + "EPIPHANY_WORKSPACE_COVERAGE_LAUNCH_ID", + launch_id.to_string(), + ); + command.stdin(Stdio::piped()); + } else { + command.stdin(Stdio::null()); + } if let Some(stdout_path) = &args.stdout_artifact { if let Some(parent) = stdout_path.parent() { fs::create_dir_all(parent)?; @@ -859,6 +914,108 @@ fn service_launch(args: Args) -> Result<()> { let mut child = command .spawn() .with_context(|| format!("failed to launch service {}", command_path.display()))?; + if let Some(( + policy, + policy_digest, + host, + boot, + launch_id, + incarnation_id, + mut seed, + provider_key, + )) = coverage_launch + { + let persist_result = (|| -> Result { + let process = capture_process_instance(child.id()) + .context("failed to capture exact workspace coverage process identity")?; + let canonical_executable = command_path + .canonicalize() + .context("failed to canonicalize workspace coverage executable")?; + if process.executable_path != canonical_executable { + anyhow::bail!( + "spawned workspace coverage process executable disagrees with policy command" + ); + } + let executable_sha256 = local_file_sha256(&canonical_executable.display().to_string()) + .map(|digest| format!("sha256-{digest}")) + .context("workspace coverage executable cannot be fingerprinted")?; + let mut bootstrap = WorkspaceCoverageProcessBootstrap { + launch_id, + provider_signing_seed: seed, + }; + let mut stdin = child + .stdin + .take() + .context("workspace coverage child stdin is unavailable")?; + write_workspace_coverage_process_bootstrap(&mut stdin, &bootstrap)?; + drop(stdin); + bootstrap.provider_signing_seed.zeroize(); + seed.zeroize(); + let launched_at = started_at.to_rfc3339(); + let mut launch = WorkspaceCoverageManagedProcessLaunchEntry { + schema_version: WORKSPACE_COVERAGE_PROCESS_LAUNCH_SCHEMA_VERSION.to_string(), + launch_id: launch_id.to_string(), + service_id: WORKSPACE_COVERAGE_PROJECTOR_SERVICE_ID.to_string(), + provider_daemon_id: WORKSPACE_COVERAGE_PROJECTOR_EXECUTOR_ID.to_string(), + runtime_id: args.runtime_id.clone(), + policy_id: policy.policy_id, + policy_envelope_digest: policy_digest, + command: policy.command, + args: policy.args, + cwd: policy.cwd, + launched_at_utc: launched_at, + host_identity_id: host.entry().identity_id.clone(), + host_public_key: host.entry().public_key.clone(), + host_assurance: host.entry().assurance.clone(), + host_identity_record_digest: workspace_coverage_host_identity_record_digest( + host.entry(), + )?, + boot_identity: boot, + process_id: process.process_id, + process_creation_token: process.creation_token, + process_created_at_rfc3339: process.created_at_rfc3339, + process_executable_path: process.executable_path.display().to_string(), + executable_sha256, + provider_incarnation_id: incarnation_id.to_string(), + provider_public_key: provider_key.verifying_key().to_bytes().to_vec(), + host_signature: Vec::new(), + supervisor_id: "epiphany-daemon-supervisor".to_string(), + identity_captured_at_utc: Utc::now().to_rfc3339(), + signature_algorithm: "ed25519".to_string(), + }; + sign_workspace_coverage_launch(&mut launch, &host)?; + write_workspace_coverage_managed_process_launch( + &args.store, + args.runtime_id.clone(), + launch, + host.entry(), + ) + })(); + seed.zeroize(); + match persist_result { + Ok(written) => { + println!( + "{}", + serde_json::to_string_pretty(&json!({ + "status": "launched", + "store": args.store, + "runtimeId": args.runtime_id, + "serviceId": written.service_id, + "launchId": written.launch_id, + "processId": written.process_id, + "privateStateExposed": false, + }))? + ); + return Ok(()); + } + Err(error) => { + let _ = child.kill(); + let _ = child.wait(); + return Err(error) + .context("failed to establish authenticated workspace coverage launch"); + } + } + } let process_id = Some(child.id()); let mut exit_code = None; let mut completed_at = reserved_launch.as_ref().map(|_| Utc::now()); @@ -2823,6 +2980,30 @@ mod semantic_projector_authority_tests { assert!(body.contains("let _ = child.wait()")); } + #[test] + fn workspace_coverage_launch_uses_only_specialized_process_authority() { + let source = include_str!("epiphany-daemon-supervisor.rs"); + let start = source.find("fn service_launch(args: Args)").unwrap(); + let tail = &source[start..]; + let end = tail.find("\nfn ").unwrap(); + let body = &tail[..end]; + let env = body.find("EPIPHANY_WORKSPACE_COVERAGE_LAUNCH_ID").unwrap(); + let spawn = body.find(".spawn()").unwrap(); + let capture = body.find("capture_process_instance(child.id())").unwrap(); + let bootstrap = body + .find("write_workspace_coverage_process_bootstrap") + .unwrap(); + let persist = body + .find("write_workspace_coverage_managed_process_launch") + .unwrap(); + assert!(env < spawn && spawn < capture && capture < bootstrap && bootstrap < persist); + assert!(body.contains("open_default_host_identity")); + assert!(body.contains("native_boot_identity")); + assert!(body.contains("seed.zeroize()")); + assert!(body.contains("let _ = child.kill()")); + assert!(body.contains("let _ = child.wait()")); + } + #[test] fn reserved_projector_policy_has_no_generic_or_command_override_path() { let source = include_str!("epiphany-daemon-supervisor.rs"); diff --git a/epiphany-core/src/bin/epiphany-host-identity.rs b/epiphany-core/src/bin/epiphany-host-identity.rs new file mode 100644 index 00000000..765321c4 --- /dev/null +++ b/epiphany-core/src/bin/epiphany-host-identity.rs @@ -0,0 +1,30 @@ +use anyhow::{Result, anyhow}; +use epiphany_core::{ + default_host_identity_store_path, enroll_default_host_identity, open_default_host_identity, +}; +use serde_json::json; + +fn main() -> Result<()> { + let command = std::env::args() + .nth(1) + .ok_or_else(|| anyhow!("usage: epiphany-host-identity "))?; + let signer = match command.as_str() { + "enroll" => enroll_default_host_identity()?, + "status" => open_default_host_identity()?, + _ => return Err(anyhow!("usage: epiphany-host-identity ")), + }; + let entry = signer.entry(); + println!( + "{}", + serde_json::to_string_pretty(&json!({ + "schemaVersion": entry.schema_version, + "identityId": entry.identity_id, + "assurance": entry.assurance, + "protectorKind": entry.protector_kind, + "createdAt": entry.created_at, + "store": default_host_identity_store_path()?, + "privateStateExposed": false + }))? + ); + Ok(()) +} diff --git a/epiphany-core/src/bin/epiphany-workspace-coverage-projector.rs b/epiphany-core/src/bin/epiphany-workspace-coverage-projector.rs index f0b984c0..0e893bf6 100644 --- a/epiphany-core/src/bin/epiphany-workspace-coverage-projector.rs +++ b/epiphany-core/src/bin/epiphany-workspace-coverage-projector.rs @@ -1,28 +1,37 @@ use anyhow::{Context, Result, anyhow}; +use ed25519_dalek::SigningKey; use epiphany_core::{ - EPIPHANY_CULTMESH_DAEMON_HEARTBEAT_EVENT_SCHEMA_VERSION, - EPIPHANY_WORKSPACE_COVERAGE_PROJECTOR_DAEMON_ID, EpiphanyCultMeshDaemonHeartbeatEventEntry, - EpiphanyCultMeshDaemonServiceLifecycleReceiptEntry, WorkspaceCoverageProjectorConfig, + WORKSPACE_COVERAGE_PROVIDER_HEARTBEAT_SCHEMA_VERSION, + WorkspaceCoverageManagedProcessLaunchEntry, WorkspaceCoverageProjectorConfig, WorkspaceCoverageProjectorPulseStatus, WorkspaceCoverageProjectorServiceBody, - authenticate_epiphany_cultmesh_workspace_coverage_projector_launch, - load_epiphany_cultmesh_daemon_service_lifecycle_receipt, - write_epiphany_cultmesh_daemon_heartbeat_event, + WorkspaceCoverageProviderHeartbeatEntry, + authenticate_workspace_coverage_managed_process_launch, capture_process_instance, + load_workspace_coverage_managed_process_launch, + load_workspace_coverage_managed_process_launch_with_digest, native_boot_identity, + open_default_host_identity, read_workspace_coverage_process_bootstrap, + sign_workspace_coverage_heartbeat, write_workspace_coverage_provider_heartbeat, }; use serde_json::json; -use sha2::{Digest, Sha256}; use std::env; -use std::fs; +use std::io; use std::path::PathBuf; use std::thread; use std::time::{Duration, Instant}; use uuid::Uuid; +use zeroize::Zeroize; fn main() -> Result<()> { let args = Args::parse()?; - let receipt = authenticate_managed_launch(&args)?; - authenticate_process_body(&receipt)?; + let mut bootstrap = read_workspace_coverage_process_bootstrap(io::stdin().lock())?; + if bootstrap.launch_id.to_string() != args.managed_process_launch_id { + return Err(anyhow!( + "bootstrap launch id disagrees with launch environment" + )); + } + let provider_key = SigningKey::from_bytes(&bootstrap.provider_signing_seed); + bootstrap.provider_signing_seed.zeroize(); + let (launch, launch_digest) = authenticate_managed_launch(&args, &provider_key)?; - let provider_incarnation = Uuid::new_v4().to_string(); let mut config = WorkspaceCoverageProjectorConfig::from_env(); config.qdrant_url = args.qdrant_url.clone(); config.ollama_base_url = args.ollama_base_url.clone(); @@ -31,8 +40,8 @@ fn main() -> Result<()> { &args.runtime_store, &args.runtime_id, config, - &provider_incarnation, - &args.startup_lifecycle_receipt_id, + &launch.provider_incarnation_id, + &launch.launch_id, )?; let mut sequence = 0_u64; @@ -45,21 +54,33 @@ fn main() -> Result<()> { // Publishing it as degraded would make a live successor unable to // establish the ready heartbeat required to fence an abandoned owner. let degraded = matches!(pulse.status, WorkspaceCoverageProjectorPulseStatus::Refused); - let heartbeat = write_epiphany_cultmesh_daemon_heartbeat_event( + let mut heartbeat = WorkspaceCoverageProviderHeartbeatEntry { + schema_version: WORKSPACE_COVERAGE_PROVIDER_HEARTBEAT_SCHEMA_VERSION.to_string(), + heartbeat_id: Uuid::new_v4().to_string(), + launch_id: launch.launch_id.clone(), + launch_envelope_digest: launch_digest.clone(), + service_id: launch.service_id.clone(), + provider_daemon_id: launch.provider_daemon_id.clone(), + runtime_id: launch.runtime_id.clone(), + host_identity_id: launch.host_identity_id.clone(), + host_identity_record_digest: launch.host_identity_record_digest.clone(), + boot_identity: launch.boot_identity.clone(), + process_id: launch.process_id, + process_creation_token: launch.process_creation_token, + process_executable_path: launch.process_executable_path.clone(), + provider_incarnation_id: launch.provider_incarnation_id.clone(), + provider_public_key: launch.provider_public_key.clone(), + sequence, + status: if degraded { "degraded" } else { "ready" }.to_string(), + observed_at_utc: chrono::Utc::now().to_rfc3339(), + provider_signature: Vec::new(), + signature_algorithm: "ed25519".to_string(), + }; + sign_workspace_coverage_heartbeat(&mut heartbeat, &provider_key)?; + let heartbeat = write_workspace_coverage_provider_heartbeat( &args.local_verse_store, args.runtime_id.clone(), - EpiphanyCultMeshDaemonHeartbeatEventEntry { - schema_version: EPIPHANY_CULTMESH_DAEMON_HEARTBEAT_EVENT_SCHEMA_VERSION.to_string(), - heartbeat_id: Uuid::new_v4().to_string(), - daemon_id: EPIPHANY_WORKSPACE_COVERAGE_PROJECTOR_DAEMON_ID.to_string(), - cluster_id: "local".to_string(), - provider_incarnation: projector.provider_incarnation().to_string(), - sequence, - status: if degraded { "degraded" } else { "ready" }.to_string(), - heartbeat_at: chrono::Utc::now().to_rfc3339(), - private_state_exposed: false, - startup_lifecycle_receipt_id: projector.startup_lifecycle_receipt_id().to_string(), - }, + heartbeat, )?; println!( "{}", @@ -85,57 +106,54 @@ fn main() -> Result<()> { fn authenticate_managed_launch( args: &Args, -) -> Result { + provider_key: &SigningKey, +) -> Result<(WorkspaceCoverageManagedProcessLaunchEntry, String)> { + let host = open_default_host_identity()?; let deadline = Instant::now() + Duration::from_secs(5); loop { - if load_epiphany_cultmesh_daemon_service_lifecycle_receipt( + if load_workspace_coverage_managed_process_launch( &args.local_verse_store, args.runtime_id.clone(), - &args.startup_lifecycle_receipt_id, + &args.managed_process_launch_id, )? .is_some() { - return authenticate_epiphany_cultmesh_workspace_coverage_projector_launch( + let launch = authenticate_workspace_coverage_managed_process_launch( &args.local_verse_store, args.runtime_id.clone(), - &args.startup_lifecycle_receipt_id, - ); + &args.managed_process_launch_id, + host.entry(), + )?; + let own = capture_process_instance(std::process::id())?; + let boot = native_boot_identity() + .ok_or_else(|| anyhow!("native boot identity is not provable"))?; + if launch.boot_identity != boot + || launch.process_id != own.process_id + || launch.process_creation_token != own.creation_token + || PathBuf::from(&launch.process_executable_path) != own.executable_path + || launch.provider_public_key != provider_key.verifying_key().to_bytes() + { + return Err(anyhow!( + "managed launch disagrees with this exact provider process" + )); + } + let (_, digest) = load_workspace_coverage_managed_process_launch_with_digest( + &args.local_verse_store, + args.runtime_id.clone(), + &args.managed_process_launch_id, + )? + .ok_or_else(|| anyhow!("managed launch disappeared"))?; + return Ok((launch, digest)); } if Instant::now() >= deadline { return Err(anyhow!( - "managed workspace coverage projector startup launch receipt was not persisted" + "managed workspace coverage projector launch was not persisted" )); } thread::sleep(Duration::from_millis(20)); } } -fn authenticate_process_body( - receipt: &EpiphanyCultMeshDaemonServiceLifecycleReceiptEntry, -) -> Result<()> { - if receipt.process_id != Some(std::process::id()) { - return Err(anyhow!( - "managed workspace coverage projector process disagrees with its launch receipt" - )); - } - let executable = env::current_exe().context("failed to resolve projector executable")?; - let executable_sha256 = format!( - "sha256-{:x}", - Sha256::digest(fs::read(&executable).with_context(|| { - format!( - "failed to fingerprint projector executable {}", - executable.display() - ) - })?) - ); - if receipt.executable_sha256 != executable_sha256 { - return Err(anyhow!( - "managed workspace coverage projector executable disagrees with its launch receipt" - )); - } - Ok(()) -} - fn pulse_status(status: WorkspaceCoverageProjectorPulseStatus) -> &'static str { match status { WorkspaceCoverageProjectorPulseStatus::Idle => "idle", @@ -150,7 +168,7 @@ struct Args { local_verse_store: PathBuf, runtime_id: String, interval_seconds: u64, - startup_lifecycle_receipt_id: String, + managed_process_launch_id: String, qdrant_url: String, ollama_base_url: String, ollama_model: String, @@ -191,11 +209,11 @@ impl Args { if interval_seconds == 0 { return Err(anyhow!("--interval-seconds must be positive")); } - let startup_lifecycle_receipt_id = - env::var("EPIPHANY_STARTUP_LIFECYCLE_RECEIPT_ID").unwrap_or_default(); - if startup_lifecycle_receipt_id.trim().is_empty() { + let managed_process_launch_id = + env::var("EPIPHANY_WORKSPACE_COVERAGE_LAUNCH_ID").unwrap_or_default(); + if managed_process_launch_id.trim().is_empty() { return Err(anyhow!( - "managed workspace coverage projector requires its startup launch receipt id" + "managed workspace coverage projector requires its managed process launch id" )); } Ok(Self { @@ -203,7 +221,7 @@ impl Args { local_verse_store: local_verse_store.context("missing --local-verse-store")?, runtime_id: runtime_id.context("missing --runtime-id")?, interval_seconds, - startup_lifecycle_receipt_id, + managed_process_launch_id, qdrant_url: required_nonempty(qdrant_url, "--qdrant-url")?, ollama_base_url: required_nonempty(ollama_base_url, "--ollama-base-url")?, ollama_model: required_nonempty(ollama_model, "--ollama-model")?, diff --git a/epiphany-core/src/cultmesh_integration.rs b/epiphany-core/src/cultmesh_integration.rs index 5af6dc41..b7248212 100644 --- a/epiphany-core/src/cultmesh_integration.rs +++ b/epiphany-core/src/cultmesh_integration.rs @@ -4158,16 +4158,8 @@ pub fn write_epiphany_cultmesh_daemon_service_lifecycle_receipt( let (receipt_envelope, written) = node.cache().prepare_entry(receipt_key, &receipt)?; let mut expected = Vec::new(); let mut replacements = vec![receipt_envelope]; - if matches!( - written.service_id.as_str(), - EPIPHANY_SEMANTIC_PROJECTOR_SERVICE_ID | EPIPHANY_WORKSPACE_COVERAGE_PROJECTOR_SERVICE_ID - ) && written.action == "launch" - { - let reserved_name = if written.service_id == EPIPHANY_SEMANTIC_PROJECTOR_SERVICE_ID { - "semantic projector" - } else { - "workspace coverage projector" - }; + if written.service_id == EPIPHANY_SEMANTIC_PROJECTOR_SERVICE_ID && written.action == "launch" { + let reserved_name = "semantic projector"; let policy_key = epiphany_cultmesh_managed_service_policy_key(&written.service_id); let policy_envelope = node .cache() @@ -4305,39 +4297,6 @@ pub fn authenticate_epiphany_cultmesh_semantic_projector_launch( Ok(receipt) } -pub fn authenticate_epiphany_cultmesh_workspace_coverage_projector_launch( - store_path: impl AsRef, - runtime_id: impl Into, - receipt_id: &str, -) -> Result { - let runtime_id = runtime_id.into(); - let receipt = load_epiphany_cultmesh_daemon_service_lifecycle_receipt( - store_path.as_ref(), - runtime_id.clone(), - receipt_id, - )? - .ok_or_else(|| anyhow!("workspace coverage projector startup launch receipt is absent"))?; - validate_workspace_coverage_projector_launch_receipt(&receipt)?; - let (policy, digest) = load_epiphany_cultmesh_managed_service_policy_with_digest( - store_path, - runtime_id, - EPIPHANY_WORKSPACE_COVERAGE_PROJECTOR_SERVICE_ID, - )? - .ok_or_else(|| anyhow!("workspace coverage projector managed policy is absent"))?; - validate_workspace_coverage_projector_managed_service_policy(&policy)?; - if receipt.managed_policy_id != policy.policy_id - || receipt.managed_policy_digest != digest - || receipt.command != policy.command - || receipt.args != policy.args - || receipt.cwd != policy.cwd - { - return Err(anyhow!( - "workspace coverage projector startup launch receipt disagrees with current managed policy" - )); - } - Ok(receipt) -} - pub fn load_latest_epiphany_cultmesh_daemon_service_lifecycle_receipt( store_path: impl AsRef, runtime_id: impl Into, @@ -4981,6 +4940,11 @@ fn daemon_scheduler_event_key( fn validate_daemon_service_lifecycle_receipt( receipt: &EpiphanyCultMeshDaemonServiceLifecycleReceiptEntry, ) -> Result<()> { + if receipt.service_id == EPIPHANY_WORKSPACE_COVERAGE_PROJECTOR_SERVICE_ID { + return Err(anyhow!( + "workspace coverage process authority belongs to its specialized managed process documents" + )); + } if receipt.private_state_exposed { return Err(anyhow!( "daemon service lifecycle receipts must not expose private state" @@ -5031,11 +4995,6 @@ fn validate_daemon_service_lifecycle_receipt( if receipt.service_id == EPIPHANY_SEMANTIC_PROJECTOR_SERVICE_ID && receipt.action == "launch" { validate_semantic_projector_launch_receipt(receipt)?; } - if receipt.service_id == EPIPHANY_WORKSPACE_COVERAGE_PROJECTOR_SERVICE_ID - && receipt.action == "launch" - { - validate_workspace_coverage_projector_launch_receipt(receipt)?; - } Ok(()) } @@ -5063,31 +5022,6 @@ fn validate_semantic_projector_launch_receipt( Ok(()) } -fn validate_workspace_coverage_projector_launch_receipt( - receipt: &EpiphanyCultMeshDaemonServiceLifecycleReceiptEntry, -) -> Result<()> { - if receipt.schema_version != EPIPHANY_CULTMESH_DAEMON_SERVICE_LIFECYCLE_RECEIPT_SCHEMA_VERSION - || receipt.service_id != EPIPHANY_WORKSPACE_COVERAGE_PROJECTOR_SERVICE_ID - || receipt.action != "launch" - || receipt.status != "launched" - || receipt.process_id.is_none() - || receipt.exit_code.is_some() - || receipt.completed_at_utc.is_none() - || !receipt.executable_sha256.starts_with("sha256-") - || receipt.managed_policy_id - != "managed-service-policy-epiphany-workspace-coverage-projector-service" - || !receipt.managed_policy_digest.starts_with("sha256-") - || receipt.provider_daemon_id != EPIPHANY_WORKSPACE_COVERAGE_PROJECTOR_DAEMON_ID - || receipt.startup_correlation_id != receipt.receipt_id - || Uuid::parse_str(&receipt.receipt_id).is_err() - { - return Err(anyhow!( - "reserved workspace coverage projector launch receipt must bind completed spawn to exact managed policy and provider identity" - )); - } - Ok(()) -} - fn daemon_service_lifecycle_event_key( receipt: &EpiphanyCultMeshDaemonServiceLifecycleReceiptEntry, ) -> (DateTime, &str) { @@ -7657,6 +7591,11 @@ fn validate_daemon_heartbeat_event( if event.schema_version != EPIPHANY_CULTMESH_DAEMON_HEARTBEAT_EVENT_SCHEMA_VERSION { return Err(anyhow!("unsupported daemon heartbeat schema")); } + if event.daemon_id == EPIPHANY_WORKSPACE_COVERAGE_PROJECTOR_DAEMON_ID { + return Err(anyhow!( + "workspace coverage provider authority belongs to its specialized signed heartbeat" + )); + } validate_heartbeat_identifier("heartbeat", &event.heartbeat_id)?; validate_heartbeat_identifier("daemon", &event.daemon_id)?; validate_heartbeat_identifier("cluster", &event.cluster_id)?; @@ -8405,12 +8344,6 @@ mod tests { "local", exact.clone(), )?; - let (_, digest) = load_epiphany_cultmesh_managed_service_policy_with_digest( - &store, - "local", - EPIPHANY_WORKSPACE_COVERAGE_PROJECTOR_SERVICE_ID, - )? - .context("workspace coverage policy missing")?; let receipt_id = "fd3b7be9-02b0-4ac7-a47e-2d25097ff1f5"; let receipt = EpiphanyCultMeshDaemonServiceLifecycleReceiptEntry { schema_version: EPIPHANY_CULTMESH_DAEMON_SERVICE_LIFECYCLE_RECEIPT_SCHEMA_VERSION @@ -8438,7 +8371,7 @@ mod tests { schema_preflight_passed: false, schema_catalog_sha256: String::new(), managed_policy_id: exact.policy_id.clone(), - managed_policy_digest: digest.clone(), + managed_policy_digest: "sha256-dead-authority".into(), provider_daemon_id: EPIPHANY_WORKSPACE_COVERAGE_PROJECTOR_DAEMON_ID.into(), startup_correlation_id: receipt_id.into(), }; @@ -8462,24 +8395,15 @@ mod tests { write_epiphany_cultmesh_daemon_service_lifecycle_receipt(&store, "local", stale) .is_err() ); - let written = write_epiphany_cultmesh_daemon_service_lifecycle_receipt( - &store, - "local", - receipt.clone(), - )?; - assert_eq!( - load_latest_epiphany_cultmesh_daemon_service_lifecycle_receipt_for_service( + assert!( + write_epiphany_cultmesh_daemon_service_lifecycle_receipt( &store, "local", - EPIPHANY_WORKSPACE_COVERAGE_PROJECTOR_SERVICE_ID, - )?, - Some(written.clone()) - ); - assert_eq!( - authenticate_epiphany_cultmesh_workspace_coverage_projector_launch( - &store, "local", receipt_id, - )?, - written + receipt.clone(), + ) + .unwrap_err() + .to_string() + .contains("specialized managed process documents") ); let mut advanced = exact; @@ -8488,12 +8412,26 @@ mod tests { &store, "local", advanced, )?; assert!( - authenticate_epiphany_cultmesh_workspace_coverage_projector_launch( - &store, "local", receipt_id, - ) - .unwrap_err() - .to_string() - .contains("disagrees with current managed policy") + load_epiphany_cultmesh_daemon_service_lifecycle_receipt(&store, "local", receipt_id,)? + .is_none() + ); + let generic_heartbeat = EpiphanyCultMeshDaemonHeartbeatEventEntry { + schema_version: EPIPHANY_CULTMESH_DAEMON_HEARTBEAT_EVENT_SCHEMA_VERSION.to_string(), + heartbeat_id: Uuid::new_v4().to_string(), + daemon_id: EPIPHANY_WORKSPACE_COVERAGE_PROJECTOR_DAEMON_ID.to_string(), + cluster_id: "local".to_string(), + provider_incarnation: Uuid::new_v4().to_string(), + sequence: 1, + status: "ready".to_string(), + heartbeat_at: "2026-07-15T12:00:03Z".to_string(), + private_state_exposed: false, + startup_lifecycle_receipt_id: receipt_id.to_string(), + }; + assert!( + write_epiphany_cultmesh_daemon_heartbeat_event(&store, "local", generic_heartbeat,) + .unwrap_err() + .to_string() + .contains("specialized signed heartbeat") ); Ok(()) } diff --git a/epiphany-core/src/lib.rs b/epiphany-core/src/lib.rs index b760ba97..d741990a 100644 --- a/epiphany-core/src/lib.rs +++ b/epiphany-core/src/lib.rs @@ -36,6 +36,7 @@ mod substrate_gate; mod surfaces; mod thread_state_store; mod weksa_interlingua; +mod workspace_coverage_process_bootstrap; mod workspace_coverage_process_documents; mod workspace_coverage_projector; mod workspace_coverage_projector_service; @@ -395,7 +396,6 @@ pub use cultmesh_integration::EpiphanyLocalVerseWorkLoopSummary; pub use cultmesh_integration::EpiphanyServiceExecutionAuditCheck; pub use cultmesh_integration::EpiphanyServiceExecutionAuditReport; pub use cultmesh_integration::authenticate_epiphany_cultmesh_semantic_projector_launch; -pub use cultmesh_integration::authenticate_epiphany_cultmesh_workspace_coverage_projector_launch; pub use cultmesh_integration::default_epiphany_cultmesh_swarm_brake; pub use cultmesh_integration::epiphany_cluster_service_execution_audit_report; pub use cultmesh_integration::epiphany_cultmesh_agent_state_soa_summary_from_entry; @@ -1154,6 +1154,10 @@ pub use weksa_interlingua::build_weksa_interlingua_packet; pub use weksa_interlingua::build_weksa_lowering_prompt; pub use weksa_interlingua::build_weksa_target_lowering_request; pub use weksa_interlingua::record_weksa_target_lowering_receipt; +pub use workspace_coverage_process_bootstrap::{ + WorkspaceCoverageProcessBootstrap, read_workspace_coverage_process_bootstrap, + write_workspace_coverage_process_bootstrap, +}; pub use workspace_coverage_process_documents::{ WORKSPACE_COVERAGE_PROCESS_LAUNCH_LATEST_KEY, WORKSPACE_COVERAGE_PROCESS_LAUNCH_SCHEMA_VERSION, WORKSPACE_COVERAGE_PROCESS_LAUNCH_TYPE, WORKSPACE_COVERAGE_PROVIDER_HEARTBEAT_LATEST_KEY, @@ -1164,11 +1168,13 @@ pub use workspace_coverage_process_documents::{ authenticate_workspace_coverage_provider_heartbeat, load_latest_workspace_coverage_managed_process_launch, load_latest_workspace_coverage_provider_heartbeat, - load_workspace_coverage_managed_process_launch, load_workspace_coverage_provider_heartbeat, - process_identity_from_workspace_coverage_launch, sign_workspace_coverage_heartbeat, - sign_workspace_coverage_launch, workspace_coverage_heartbeat_statement, - workspace_coverage_host_identity_record_digest, workspace_coverage_launch_statement, - write_workspace_coverage_managed_process_launch, write_workspace_coverage_provider_heartbeat, + load_workspace_coverage_managed_process_launch, + load_workspace_coverage_managed_process_launch_with_digest, + load_workspace_coverage_provider_heartbeat, process_identity_from_workspace_coverage_launch, + sign_workspace_coverage_heartbeat, sign_workspace_coverage_launch, + workspace_coverage_heartbeat_statement, workspace_coverage_host_identity_record_digest, + workspace_coverage_launch_statement, write_workspace_coverage_managed_process_launch, + write_workspace_coverage_provider_heartbeat, }; pub use workspace_coverage_projector_service::WorkspaceCoverageProjectorConfig; pub use workspace_coverage_projector_service::WorkspaceCoverageProjectorPulseStatus; diff --git a/epiphany-core/src/workspace_coverage_process_bootstrap.rs b/epiphany-core/src/workspace_coverage_process_bootstrap.rs new file mode 100644 index 00000000..b6bb15db --- /dev/null +++ b/epiphany-core/src/workspace_coverage_process_bootstrap.rs @@ -0,0 +1,91 @@ +use anyhow::{Context, Result, anyhow, bail}; +use std::io::{Read, Write}; +use uuid::Uuid; +use zeroize::Zeroize; + +const MAGIC: &[u8; 8] = b"EPHWCOV\0"; +const FRAME_LEN: usize = MAGIC.len() + 16 + 32; + +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct WorkspaceCoverageProcessBootstrap { + pub launch_id: Uuid, + pub provider_signing_seed: [u8; 32], +} + +impl Drop for WorkspaceCoverageProcessBootstrap { + fn drop(&mut self) { + self.provider_signing_seed.zeroize(); + } +} + +pub fn write_workspace_coverage_process_bootstrap( + mut writer: impl Write, + frame: &WorkspaceCoverageProcessBootstrap, +) -> Result<()> { + let mut bytes = [0_u8; FRAME_LEN]; + bytes[..MAGIC.len()].copy_from_slice(MAGIC); + bytes[MAGIC.len()..MAGIC.len() + 16].copy_from_slice(frame.launch_id.as_bytes()); + bytes[MAGIC.len() + 16..].copy_from_slice(&frame.provider_signing_seed); + writer + .write_all(&bytes) + .context("failed to write workspace coverage bootstrap frame")?; + writer + .flush() + .context("failed to flush workspace coverage bootstrap frame") +} + +pub fn read_workspace_coverage_process_bootstrap( + mut reader: impl Read, +) -> Result { + let mut bytes = [0_u8; FRAME_LEN]; + reader + .read_exact(&mut bytes) + .context("workspace coverage bootstrap frame is truncated")?; + let mut trailing = [0_u8; 1]; + if reader + .read(&mut trailing) + .context("failed to verify workspace coverage bootstrap EOF")? + != 0 + { + bail!("workspace coverage bootstrap contains trailing bytes"); + } + if &bytes[..MAGIC.len()] != MAGIC { + bail!("workspace coverage bootstrap magic is invalid"); + } + let launch_id = Uuid::from_slice(&bytes[MAGIC.len()..MAGIC.len() + 16]) + .map_err(|_| anyhow!("workspace coverage bootstrap launch id is invalid"))?; + let provider_signing_seed = bytes[MAGIC.len() + 16..] + .try_into() + .map_err(|_| anyhow!("workspace coverage bootstrap seed length is invalid"))?; + Ok(WorkspaceCoverageProcessBootstrap { + launch_id, + provider_signing_seed, + }) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn fixed_frame_round_trips_and_requires_eof() { + let frame = WorkspaceCoverageProcessBootstrap { + launch_id: Uuid::new_v4(), + provider_signing_seed: [7; 32], + }; + let mut encoded = Vec::new(); + write_workspace_coverage_process_bootstrap(&mut encoded, &frame).unwrap(); + assert_eq!(encoded.len(), FRAME_LEN); + assert_eq!( + read_workspace_coverage_process_bootstrap(encoded.as_slice()).unwrap(), + frame + ); + encoded.push(0); + assert!(read_workspace_coverage_process_bootstrap(encoded.as_slice()).is_err()); + } + + #[test] + fn truncated_frame_is_rejected() { + assert!(read_workspace_coverage_process_bootstrap(&[0_u8; FRAME_LEN - 1][..]).is_err()); + } +} diff --git a/epiphany-core/src/workspace_coverage_process_documents.rs b/epiphany-core/src/workspace_coverage_process_documents.rs index c329d8be..77fb818a 100644 --- a/epiphany-core/src/workspace_coverage_process_documents.rs +++ b/epiphany-core/src/workspace_coverage_process_documents.rs @@ -448,6 +448,23 @@ pub fn load_workspace_coverage_managed_process_launch( open_epiphany_cultmesh_node(store_path, runtime_id)?.get(&launch_key(launch_id)) } +pub fn load_workspace_coverage_managed_process_launch_with_digest( + store_path: impl AsRef, + runtime_id: impl Into, + launch_id: &str, +) -> Result> { + require_nonempty("launch id", launch_id)?; + let node = open_epiphany_cultmesh_node(store_path, runtime_id)?; + let Some(envelope) = node + .cache() + .get_envelope::(&launch_key(launch_id))? + else { + return Ok(None); + }; + let digest = envelope_digest(&envelope); + Ok(Some((rmp_serde::from_slice(&envelope.payload)?, digest))) +} + pub fn load_latest_workspace_coverage_managed_process_launch( store_path: impl AsRef, runtime_id: impl Into, diff --git a/epiphany-core/src/workspace_coverage_projector.rs b/epiphany-core/src/workspace_coverage_projector.rs index 7ffde44c..1268b8e5 100644 --- a/epiphany-core/src/workspace_coverage_projector.rs +++ b/epiphany-core/src/workspace_coverage_projector.rs @@ -25,8 +25,8 @@ use std::path::{Path, PathBuf}; const CLAIM_TYPE: &str = "gamecult.epiphany.workspace_coverage_projection_claim"; const ATTEMPT_TYPE: &str = "gamecult.epiphany.workspace_coverage_projection_attempt"; const CLAIM_KEY: &str = "workspace-coverage-projector-current"; -const CLAIM_SCHEMA: &str = "gamecult.epiphany.workspace_coverage_projection_claim.v0"; -const ATTEMPT_SCHEMA: &str = "gamecult.epiphany.workspace_coverage_projection_attempt.v0"; +const CLAIM_SCHEMA: &str = "gamecult.epiphany.workspace_coverage_projection_claim.v1"; +const ATTEMPT_SCHEMA: &str = "gamecult.epiphany.workspace_coverage_projection_attempt.v1"; const PROJECTION_SCHEMA: &str = "gamecult.epiphany.workspace_bytes_projection.v0"; const CHUNKER_ID: &str = "utf8_lines_96_overlap_8_v0"; const MAXIMUM_FILE_BYTES: u64 = 4 * 1024 * 1024; @@ -149,7 +149,7 @@ pub(crate) struct WorkspaceCoverageProjectionClaim { #[cultcache(key = 11)] executor_incarnation: String, #[cultcache(key = 12)] - startup_lifecycle_receipt_id: String, + managed_process_launch_id: String, } fn validate_projection_claim(claim: &WorkspaceCoverageProjectionClaim) -> Result<()> { @@ -163,7 +163,7 @@ fn validate_projection_claim(claim: &WorkspaceCoverageProjectionClaim) -> Result || claim.manifest_root_sha256.trim().is_empty() || claim.executor_id.trim().is_empty() || claim.executor_incarnation.trim().is_empty() - || claim.startup_lifecycle_receipt_id.trim().is_empty() + || claim.managed_process_launch_id.trim().is_empty() || !matches!(claim.status.as_str(), "running" | "failed" | "succeeded") { bail!("invalid workspace coverage projection claim"); @@ -180,7 +180,7 @@ fn validate_projection_attempt(attempt: &WorkspaceCoverageProjectionAttempt) -> || attempt.started_at.trim().is_empty() || attempt.executor_id.trim().is_empty() || attempt.executor_incarnation.trim().is_empty() - || attempt.startup_lifecycle_receipt_id.trim().is_empty() + || attempt.managed_process_launch_id.trim().is_empty() || !matches!(attempt.status.as_str(), "running" | "failed" | "succeeded") { bail!("invalid workspace coverage projection attempt"); @@ -220,7 +220,7 @@ fn validate_claim_attempt_link( || claim.status != attempt.status || claim.executor_id != attempt.executor_id || claim.executor_incarnation != attempt.executor_incarnation - || claim.startup_lifecycle_receipt_id != attempt.startup_lifecycle_receipt_id + || claim.managed_process_launch_id != attempt.managed_process_launch_id { bail!("workspace coverage claim/attempt authority is split"); } @@ -256,7 +256,7 @@ pub(crate) struct WorkspaceCoverageProjectionAttempt { #[cultcache(key = 10)] executor_incarnation: String, #[cultcache(key = 11)] - startup_lifecycle_receipt_id: String, + managed_process_launch_id: String, } #[derive(Clone, Debug)] @@ -563,11 +563,11 @@ pub(crate) fn acquire_workspace_coverage_projection( prepared: &PreparedWorkspaceCoverageProjection, executor_id: &str, executor_incarnation: &str, - startup_lifecycle_receipt_id: &str, + managed_process_launch_id: &str, ) -> Result { if executor_id.trim().is_empty() || executor_incarnation.trim().is_empty() - || startup_lifecycle_receipt_id.trim().is_empty() + || managed_process_launch_id.trim().is_empty() { bail!("workspace coverage acquisition requires exact executor lifecycle identity"); } @@ -615,7 +615,7 @@ pub(crate) fn acquire_workspace_coverage_projection( status: "running".into(), executor_id: executor_id.into(), executor_incarnation: executor_incarnation.into(), - startup_lifecycle_receipt_id: startup_lifecycle_receipt_id.into(), + managed_process_launch_id: managed_process_launch_id.into(), }; let attempt = WorkspaceCoverageProjectionAttempt { schema_version: ATTEMPT_SCHEMA.into(), @@ -629,7 +629,7 @@ pub(crate) fn acquire_workspace_coverage_projection( error: None, executor_id: executor_id.into(), executor_incarnation: executor_incarnation.into(), - startup_lifecycle_receipt_id: startup_lifecycle_receipt_id.into(), + managed_process_launch_id: managed_process_launch_id.into(), }; let mut expected = authority.clone(); if let Some(existing) = existing_claim { diff --git a/epiphany-core/src/workspace_coverage_projector_service.rs b/epiphany-core/src/workspace_coverage_projector_service.rs index 5964534d..16ba6ec4 100644 --- a/epiphany-core/src/workspace_coverage_projector_service.rs +++ b/epiphany-core/src/workspace_coverage_projector_service.rs @@ -169,7 +169,7 @@ pub struct WorkspaceCoverageProjectorServiceBody { _singleton: WorkspaceCoverageProjectorSingletonGuard, runtime_store: PathBuf, executor_incarnation: String, - startup_lifecycle_receipt_id: String, + managed_process_launch_id: String, embedder: OllamaEmbedder, qdrant: QdrantBackend, } @@ -180,16 +180,17 @@ impl WorkspaceCoverageProjectorServiceBody { runtime_id: impl Into, config: WorkspaceCoverageProjectorConfig, executor_incarnation: impl Into, - startup_lifecycle_receipt_id: impl Into, + managed_process_launch_id: impl Into, ) -> Result { config.validate()?; let executor_incarnation = executor_incarnation.into(); if executor_incarnation.trim().is_empty() { bail!("workspace coverage projector requires its executor incarnation"); } - let startup_lifecycle_receipt_id = startup_lifecycle_receipt_id.into(); - Uuid::parse_str(&startup_lifecycle_receipt_id) - .context("workspace coverage projector requires its authenticated launch receipt id")?; + let managed_process_launch_id = managed_process_launch_id.into(); + Uuid::parse_str(&managed_process_launch_id).context( + "workspace coverage projector requires its authenticated managed process launch id", + )?; let runtime_id = runtime_id.into(); if runtime_id.trim().is_empty() { bail!("workspace coverage projector requires its CultMesh runtime id"); @@ -226,7 +227,7 @@ impl WorkspaceCoverageProjectorServiceBody { _singleton: singleton, runtime_store, executor_incarnation, - startup_lifecycle_receipt_id, + managed_process_launch_id, embedder, qdrant, }) @@ -236,8 +237,8 @@ impl WorkspaceCoverageProjectorServiceBody { &self.executor_incarnation } - pub fn startup_lifecycle_receipt_id(&self) -> &str { - &self.startup_lifecycle_receipt_id + pub fn managed_process_launch_id(&self) -> &str { + &self.managed_process_launch_id } pub fn pulse(&mut self) -> WorkspaceCoverageProjectorServicePulse { @@ -298,7 +299,7 @@ impl WorkspaceCoverageProjectorServiceBody { &prepared, EPIPHANY_WORKSPACE_COVERAGE_PROJECTOR_DAEMON_ID, &self.executor_incarnation, - &self.startup_lifecycle_receipt_id, + &self.managed_process_launch_id, )? { WorkspaceCoverageAcquireResult::Contended => { Ok(WorkspaceCoverageProjectorServicePulse { diff --git a/notes/fresh-workspace-handoff.md b/notes/fresh-workspace-handoff.md index 4db24732..1c917627 100644 --- a/notes/fresh-workspace-handoff.md +++ b/notes/fresh-workspace-handoff.md @@ -1834,6 +1834,24 @@ child launch authentication, specialized heartbeat publication, then generic writer rejection for reserved coverage. Do not let the new and old documents remain co-owners after that cut. +The migration cut is now implemented and verified. Reserved-child stdin carries +one fixed binary launch-id/seed frame and requires EOF; all nonreserved service +stdin is null. Supervisor captures the spawned process incarnation, sends the +secret, host-signs/CAS-persists the specialized launch, and kills/waits on any +failure. The projector authenticates host, current policy, boot, exact process, +launch digest, and derived provider key before service construction, then emits +only specialized signed heartbeats. Generic lifecycle and daemon-heartbeat +writers reject the reserved coverage identities, and the old generic coverage +authenticator is deleted. Coverage claim/attempt v1 now binds +`managed_process_launch_id`, refusing semantic reinterpretation of v0 state. + +The new native `epiphany-host-identity enroll|status` actuator explicitly +enrolled this Windows installation at the default LocalAppData DPAPI store; +status reopened identity +`17f041421045aa66d4c8ab0488f462dbb5ea1a7d8507dbf75216f5ec368dbb7a`. +Next implement immutable Idunn termination observation before replacement spawn, +then the exact Body recovery CAS. Timeout recovery remains forbidden. + The deployment next action is unchanged and permission-bound. Do not reboot without exact live operator approval. With that approval, run the real reboot/logon recovery proof already specified above. diff --git a/state/ledgers.msgpack b/state/ledgers.msgpack index 40cfa528..19cd0dda 100644 Binary files a/state/ledgers.msgpack and b/state/ledgers.msgpack differ diff --git a/state/map.yaml b/state/map.yaml index 3db1e724..d9f1bcb0 100644 --- a/state/map.yaml +++ b/state/map.yaml @@ -727,4 +727,5 @@ current_status: - Static cluster topology owns declared faculty routing only, not attendance. Explicit bootstrap may persist seven declared faculty routes, desired private-Verse addresses, and daemon/Eve targets. Only persisted provider-authored daemon status creates an observed daemon row. The synthetic `unknown_daemon_status` path is deleted; fresh bootstrap therefore means seven declared targets and zero observed daemons. Topology, liveness, restart-policy, swarm overview/triage, compact swarm output, prompt context, and wrapper summaries distinguish `declared*` counts/routes from `observedDaemonCount`; a heartbeat does not become an agent count. Restart-policy rows may carry `daemonStatus=unobserved` solely for Idunn desired-state reconciliation. Configured ids, routes, topology row counts, and policy targets are forbidden from proving deployed daemons, active private Verses, agent presence, Eve availability, or readiness. - Native process and host incarnation foundations are now separate authorities. Process identity is PID plus native creation token plus canonical executable, with exact alive/exited/replaced/missing/inaccessible/indeterminate observations and optional proven boot incarnation; the PID-only compatibility projection cannot report death. Host identity is one immutable non-workspace CultCache enrollment with an Ed25519 identity/signing handle, purpose-bound signatures, fail-closed open, and no silent regeneration. Windows protects its seed with CurrentUser DPAPI and honestly labels assurance `os_user_installation_bound_best_effort`; Linux uses 0700/0600 state plus machine-id binding and labels the baseline cloneable. Neither claims physical-chassis identity. These foundations do not themselves authorize service recovery. - Specialized reserved coverage process documents now exist as typed CultMesh state. Idunn's mandatory host-signed launch binds the exact current specialized policy envelope, enrolled host record digest, proven boot, PID creation token, captured executable path and bytes digest, provider incarnation, and ephemeral provider public key. Provider heartbeats are signed by that ephemeral key, bind the exact launch envelope and repeated host/boot/process tuple, and advance exact per-launch sequence/time under CAS. Hostile tests reject forged signatures, sequence gaps, identity collisions, wrong supervisor/status/runtime, stale policy, and tuple drift. These documents are not operational owners until supervisor and projector migrate and generic writers reject reserved coverage identities. - next_action: Atomically migrate the workspace-coverage supervisor launch and projector heartbeat path to the specialized documents. Deliver the ephemeral provider seed in one fixed-size frame over reserved-child stdin, persist the exact host-signed launch after process identity capture, and require the child to authenticate seed/public key/launch/process before publishing. Then make generic lifecycle and heartbeat writers reject reserved coverage identities and rename the claim binding away from `startup_lifecycle_receipt_id`. After that, add immutable exact termination before replacement spawn and the one Body recovery CAS. The separate reboot/logon proof remains permission-bound. + - The live workspace-coverage process path now uses only specialized authority. Supervisor generates a per-launch provider key, spawns with reserved stdin piped and all other child stdin null, captures exact process identity, sends one fixed-size launch-id/seed frame, host-signs and CAS-persists the specialized launch, and kills/waits on any bootstrap or persistence failure. The child requires exact frame plus EOF, authenticates the enrolled host, current policy, boot, its PID creation token/path, launch digest, and provider public key before constructing the service or publishing its signed per-launch heartbeat. Generic lifecycle and generic daemon-heartbeat writers reject the reserved coverage identities; their old authenticator is deleted. Body claim/attempt v1 binds `managed_process_launch_id`; v0 lifecycle semantics cannot deserialize as the new owner. This Windows installation is explicitly enrolled at the default DPAPI CurrentUser host store and status re-open proved identity `17f041421045aa66d4c8ab0488f462dbb5ea1a7d8507dbf75216f5ec368dbb7a` without exposing private state. + next_action: Add Idunn-owned immutable process-termination observation bound to the exact prior specialized launch, its per-launch latest heartbeat, current policy envelope, enrolled host record, and native boot/process observation. Persist termination before replacement spawn; refuse ExactAlive, Inaccessible, Indeterminate, unknown boot, or host mismatch. Then require exact old termination plus replacement signed ready heartbeat for one Body CAS that terminalizes the old claim/attempt and acquires epoch+1. No timeout or staleness recovery. The separate reboot/logon proof remains permission-bound. diff --git a/state/scratch.md b/state/scratch.md index 653ee7f9..22e8e841 100644 --- a/state/scratch.md +++ b/state/scratch.md @@ -105,3 +105,20 @@ public key, then waits for and authenticates the launch document before acting. Write or persistence failure kills and waits the child; all nonreserved service stdin is explicitly null. This uses Rust's stable cross-platform child-stdin contract instead of bespoke inherited-handle plumbing. + +## Live reserved authority migration (2026-07-16) + +The supervisor/projector chain now consumes the specialized documents. Idunn +generates the ephemeral provider seed, spawns, captures exact process identity, +writes the fixed stdin frame, then host-signs and persists the launch; every +failure after spawn kills and waits. The child reads exact frame+EOF and checks +host, current policy, boot, PID generation/path, launch digest, and derived +public key before any service pulse. Heartbeats are specialized and signed. + +Generic lifecycle and generic heartbeat writers now refuse the reserved +coverage identities, and the old coverage lifecycle authenticator is gone. +Claim/attempt schema v1 binds `managed_process_launch_id`; v0 positional state +cannot impersonate the new semantic owner. A native `epiphany-host-identity` +enroll/status actuator was added, and this Windows installation was enrolled +once at the default DPAPI CurrentUser path. Next build immutable termination +evidence before replacement and only then the Body recovery CAS.