Bind operator service into signed runtime health

This commit is contained in:
Meta Vens 2026-07-19 15:33:42 +01:00
commit 75b3813874
5 changed files with 445 additions and 17 deletions

View file

@ -19,6 +19,7 @@ use epiphany_core::EpiphanyProcessObservation as ProcessObservation;
use epiphany_core::MemorySemanticProjectionInput;
use epiphany_core::agent_memory_semantic_projection_input;
use epiphany_core::authenticate_epiphany_cultmesh_semantic_projector_launch;
use epiphany_core::authenticate_operator_command_service_health;
use epiphany_core::authenticate_resident_provider_pair;
use epiphany_core::epiphany_cultmesh_daemon_poke_intent_from_status;
use epiphany_core::epiphany_cultmesh_daemon_poke_receipt_for_intent;
@ -37,6 +38,7 @@ use epiphany_core::load_latest_epiphany_cultmesh_daemon_service_lifecycle_receip
use epiphany_core::migrate_memory_semantic_projection_attempts_v0;
use epiphany_core::observe_native_process as observe_process;
use epiphany_core::query_epiphany_local_verse_context;
use epiphany_core::read_operator_command_trust_anchor;
use epiphany_core::retire_epiphany_cultmesh_operator_status_documents;
use epiphany_core::retire_memory_semantic_projection_claims_v0;
use epiphany_core::retire_orphaned_memory_semantic_projection_attempts_v0;
@ -950,6 +952,61 @@ fn publish_managed_service_iteration_health(
contradictions
.push("resident health requires both heartbeat and Self provider stores".into());
}
match (
args.operator_service_readiness_store.as_deref(),
args.operator_executor_trust_anchor.as_deref(),
args.operator_service_bind.as_deref(),
) {
(Some(store), Some(anchor_path), Some(bind)) => {
expected += 1;
let result = read_operator_command_trust_anchor(anchor_path).and_then(|anchor| {
authenticate_operator_command_service_health(
store,
&args.runtime_id,
&release.release_id,
authenticated_release_witness_sha256,
&release.source_commit_sha,
bind,
&anchor,
Utc::now().timestamp_millis().max(0) as u64,
15_000,
)
});
match result {
Ok(health) => {
let expected_executable =
epiphany_packaged_release_binary_path(release, "operator-command")
.and_then(|path| fs::canonicalize(path).map_err(Into::into));
let observed = capture_process_instance(health.process_id);
match (expected_executable, observed) {
(Ok(expected_executable), Ok(process))
if process.creation_token == health.process_creation_token
&& process.executable_path == expected_executable
&& process.executable_path.display().to_string()
== health.process_executable_path =>
{
terminal_current += 1
}
(Ok(_), Ok(_)) => contradictions.push(
"operator service process identity is not the signed packaged sibling"
.into(),
),
(Err(error), _) | (_, Err(error)) => contradictions.push(format!(
"operator service process cannot be authenticated: {error:#}"
)),
}
}
Err(error) => contradictions.push(format!(
"operator service signed readiness is invalid: {error:#}"
)),
}
}
(None, None, None) => {}
_ => {
expected += 1;
contradictions.push("operator service health requires readiness store, executor trust anchor, and exact bind".into());
}
}
for service_id in required {
let Some(policy) = policies
.iter()
@ -5118,6 +5175,9 @@ struct Args {
resident_heartbeat_store: Option<PathBuf>,
resident_self_store: Option<PathBuf>,
resident_provider_stale_seconds: u64,
operator_service_readiness_store: Option<PathBuf>,
operator_executor_trust_anchor: Option<PathBuf>,
operator_service_bind: Option<String>,
}
impl Args {
@ -5175,6 +5235,9 @@ impl Args {
let mut resident_heartbeat_store = None;
let mut resident_self_store = None;
let mut resident_provider_stale_seconds = 180_u64;
let mut operator_service_readiness_store = None;
let mut operator_executor_trust_anchor = None;
let mut operator_service_bind = None;
while let Some(arg) = values.next() {
match arg.as_str() {
@ -5401,6 +5464,26 @@ impl Args {
anyhow::bail!("--resident-provider-stale-seconds must be positive");
}
}
"--operator-service-readiness-store" => {
operator_service_readiness_store =
Some(PathBuf::from(values.next().context(
"missing --operator-service-readiness-store value",
)?))
}
"--operator-executor-trust-anchor" => {
operator_executor_trust_anchor = Some(PathBuf::from(
values
.next()
.context("missing --operator-executor-trust-anchor value")?,
))
}
"--operator-service-bind" => {
operator_service_bind = Some(
values
.next()
.context("missing --operator-service-bind value")?,
)
}
other => anyhow::bail!("unknown argument {other:?}"),
}
}
@ -5511,6 +5594,18 @@ impl Args {
idunn_health_contract.as_deref(),
idunn_deployment_request_id.as_deref(),
)?;
let operator_health_fields = [
operator_service_readiness_store.is_some(),
operator_executor_trust_anchor.is_some(),
operator_service_bind.is_some(),
];
if operator_health_fields.into_iter().any(|value| value)
&& !operator_health_fields.into_iter().all(|value| value)
{
anyhow::bail!(
"operator service health store, executor trust anchor, and bind are all-or-none"
);
}
Ok(Self {
command,
@ -5564,6 +5659,9 @@ impl Args {
resident_heartbeat_store,
resident_self_store,
resident_provider_stale_seconds,
operator_service_readiness_store,
operator_executor_trust_anchor,
operator_service_bind,
})
}
}

View file

@ -1,7 +1,7 @@
use anyhow::{Result, anyhow};
use epiphany_core::{
default_host_identity_store_path, enroll_default_host_identity,
export_host_identity_trust_anchor, open_default_host_identity,
default_host_identity_store_path, enroll_default_host_identity, enroll_host_identity_at,
export_host_identity_trust_anchor, open_default_host_identity, open_host_identity_at,
};
use serde_json::json;
@ -9,19 +9,36 @@ fn main() -> Result<()> {
let command = std::env::args().nth(1).ok_or_else(|| {
anyhow!("usage: epiphany-host-identity <enroll|status|enroll-trust-anchor|export-trust-anchor> [output]")
})?;
let values = std::env::args().skip(2).collect::<Vec<_>>();
let store_index = values.iter().position(|value| value == "--store");
let explicit_store = match store_index {
Some(index) if index + 2 == values.len() => {
Some(std::path::PathBuf::from(&values[index + 1]))
}
Some(_) => return Err(anyhow!("--store must be the final option with one path")),
None => None,
};
let positional = &values[..store_index.unwrap_or(values.len())];
if matches!(
command.as_str(),
"enroll-trust-anchor" | "export-trust-anchor"
) {
let output = std::env::args()
.nth(2)
.ok_or_else(|| anyhow!("{command} requires an output path"))?;
let output = positional
.first()
.filter(|_| positional.len() == 1)
.ok_or_else(|| anyhow!("{command} requires one output path"))?;
let signer = if command == "enroll-trust-anchor" {
enroll_default_host_identity()?
match explicit_store.as_deref() {
Some(store) => enroll_host_identity_at(store)?,
None => enroll_default_host_identity()?,
}
} else {
open_default_host_identity()?
match explicit_store.as_deref() {
Some(store) => open_host_identity_at(store)?,
None => open_default_host_identity()?,
}
};
let anchor = export_host_identity_trust_anchor(&signer, std::path::Path::new(&output))?;
let anchor = export_host_identity_trust_anchor(&signer, std::path::Path::new(output))?;
println!(
"{}",
serde_json::to_string_pretty(&json!({
@ -33,9 +50,18 @@ fn main() -> Result<()> {
);
return Ok(());
}
if !positional.is_empty() {
return Err(anyhow!("unexpected host identity positional argument"));
}
let signer = match command.as_str() {
"enroll" => enroll_default_host_identity()?,
"status" => open_default_host_identity()?,
"enroll" => match explicit_store.as_deref() {
Some(store) => enroll_host_identity_at(store)?,
None => enroll_default_host_identity()?,
},
"status" => match explicit_store.as_deref() {
Some(store) => open_host_identity_at(store)?,
None => open_default_host_identity()?,
},
_ => {
return Err(anyhow!(
"usage: epiphany-host-identity <enroll|status|enroll-trust-anchor|export-trust-anchor> [output]"
@ -51,7 +77,7 @@ fn main() -> Result<()> {
"assurance": entry.assurance,
"protectorKind": entry.protector_kind,
"createdAt": entry.created_at,
"store": default_host_identity_store_path()?,
"store": explicit_store.unwrap_or(default_host_identity_store_path()?),
"privateStateExposed": false
}))?
);

View file

@ -36,7 +36,14 @@ fn main() -> Result<()> {
)
})?;
print_readiness(&args, &signer, "serving")?;
serve_operator_command_rudp(socket, &config, &signer)
let health = epiphany_core::OperatorCommandServiceHealthConfig {
store: args.readiness_store.clone(),
bind: args.bind.to_string(),
release_id: args.release_id.clone(),
release_witness_sha256: args.release_witness_sha256.clone(),
source_commit: args.source_commit.clone(),
};
serve_operator_command_rudp(socket, &config, &signer, &health)
}
fn print_readiness(
@ -71,6 +78,10 @@ struct Args {
channel_ids: Vec<String>,
actor_capabilities: BTreeMap<String, Vec<OperatorCapability>>,
max_ttl_seconds: i64,
readiness_store: PathBuf,
release_id: String,
release_witness_sha256: String,
source_commit: String,
status_only: bool,
}
@ -111,6 +122,10 @@ impl Args {
| "--resident-self-store"
| "--runtime-store"
| "--guild-id"
| "--readiness-store"
| "--release-id"
| "--release-witness-sha256"
| "--source-commit"
| "--max-ttl-seconds" => {
let value = values
.next()
@ -152,6 +167,10 @@ impl Args {
channel_ids: channels,
actor_capabilities: actors,
max_ttl_seconds,
readiness_store: required("--readiness-store")?.into(),
release_id: required("--release-id")?,
release_witness_sha256: required("--release-witness-sha256")?,
source_commit: required("--source-commit")?,
status_only,
})
}