Expose authenticated provider health in Status
This commit is contained in:
parent
ac546ed1e8
commit
b2db6ca5b8
8 changed files with 543 additions and 13 deletions
|
|
@ -1,8 +1,8 @@
|
|||
use anyhow::{Context, Result, anyhow, bail};
|
||||
use epiphany_core::{
|
||||
OperatorCapability, OperatorCommandPolicy, OperatorCommandServiceConfig,
|
||||
OperatorCommandServiceReadiness, open_host_identity_at, read_operator_command_trust_anchor,
|
||||
serve_operator_command_rudp,
|
||||
OperatorCommandServiceReadiness, OperatorStatusProviderHealthConfig, open_host_identity_at,
|
||||
read_operator_command_trust_anchor, serve_operator_command_rudp,
|
||||
};
|
||||
use std::collections::BTreeMap;
|
||||
use std::net::{SocketAddr, UdpSocket};
|
||||
|
|
@ -24,6 +24,17 @@ fn main() -> Result<()> {
|
|||
max_ttl_seconds: args.max_ttl_seconds,
|
||||
},
|
||||
trusted_bifrost_identity: read_operator_command_trust_anchor(&args.bifrost_trust_anchor)?,
|
||||
provider_health: OperatorStatusProviderHealthConfig {
|
||||
query_endpoint: args.idunn_provider_query,
|
||||
idunn_runtime_id: args.idunn_runtime_id.clone(),
|
||||
trust_anchor_store: args.idunn_projection_anchor.clone(),
|
||||
admission_store: args.provider_admission_store.clone(),
|
||||
max_local_age_millis: args.provider_ttl_millis,
|
||||
deployment_id: args.deployment_id.clone(),
|
||||
release_id: args.release_id.clone(),
|
||||
release_witness_sha256: args.release_witness_sha256.clone(),
|
||||
source_commit: args.source_commit.clone(),
|
||||
},
|
||||
};
|
||||
if args.status_only {
|
||||
print_readiness(&args, &signer, "configured")?;
|
||||
|
|
@ -82,6 +93,12 @@ struct Args {
|
|||
release_id: String,
|
||||
release_witness_sha256: String,
|
||||
source_commit: String,
|
||||
deployment_id: String,
|
||||
idunn_provider_query: SocketAddr,
|
||||
idunn_runtime_id: String,
|
||||
idunn_projection_anchor: PathBuf,
|
||||
provider_admission_store: PathBuf,
|
||||
provider_ttl_millis: u64,
|
||||
status_only: bool,
|
||||
}
|
||||
|
||||
|
|
@ -126,6 +143,12 @@ impl Args {
|
|||
| "--release-id"
|
||||
| "--release-witness-sha256"
|
||||
| "--source-commit"
|
||||
| "--deployment-id"
|
||||
| "--idunn-provider-query"
|
||||
| "--idunn-runtime-id"
|
||||
| "--idunn-projection-anchor"
|
||||
| "--provider-admission-store"
|
||||
| "--provider-ttl-millis"
|
||||
| "--max-ttl-seconds" => {
|
||||
let value = values
|
||||
.next()
|
||||
|
|
@ -154,6 +177,10 @@ impl Args {
|
|||
if !(1..=60).contains(&max_ttl_seconds) {
|
||||
bail!("operator service max TTL must be 1..=60 seconds");
|
||||
}
|
||||
let provider_ttl_millis = required("--provider-ttl-millis")?.parse()?;
|
||||
if provider_ttl_millis == 0 {
|
||||
bail!("provider health TTL must be nonzero");
|
||||
}
|
||||
Ok(Self {
|
||||
bind: required("--bind")?.parse()?,
|
||||
runtime_id: required("--runtime-id")?,
|
||||
|
|
@ -171,6 +198,12 @@ impl Args {
|
|||
release_id: required("--release-id")?,
|
||||
release_witness_sha256: required("--release-witness-sha256")?,
|
||||
source_commit: required("--source-commit")?,
|
||||
deployment_id: required("--deployment-id")?,
|
||||
idunn_provider_query: required("--idunn-provider-query")?.parse()?,
|
||||
idunn_runtime_id: required("--idunn-runtime-id")?,
|
||||
idunn_projection_anchor: required("--idunn-projection-anchor")?.into(),
|
||||
provider_admission_store: required("--provider-admission-store")?.into(),
|
||||
provider_ttl_millis,
|
||||
status_only,
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -107,6 +107,22 @@ pub struct IdunnProviderHealthAdmission {
|
|||
pub trust_anchor_bound_at_unix_millis: u64,
|
||||
}
|
||||
|
||||
pub fn read_idunn_provider_health_trust_anchor(
|
||||
path: &Path,
|
||||
) -> Result<GameCultServiceTrustAnchorRecord> {
|
||||
let rows = SingleFileMessagePackBackingStore::new(path).pull_all_read_only_snapshot()?;
|
||||
if rows.len() != 1 {
|
||||
bail!("Idunn provider-health trust anchor store must contain exactly one row");
|
||||
}
|
||||
let row = &rows[0];
|
||||
if row.r#type != GameCultServiceTrustAnchorRecord::TYPE {
|
||||
bail!("Idunn provider-health trust anchor store contains foreign authority");
|
||||
}
|
||||
let anchor: GameCultServiceTrustAnchorRecord = rmp_serde::from_slice(&row.payload)?;
|
||||
anchor.validate()?;
|
||||
Ok(anchor)
|
||||
}
|
||||
|
||||
pub fn provider_health_record_key(daemon_id: &str, health_contract: &str) -> String {
|
||||
format!(
|
||||
"provider-health:{:x}",
|
||||
|
|
@ -230,6 +246,31 @@ pub fn admit_required_idunn_provider_health(
|
|||
bail!("Idunn provider-health admission lost repeated cross-process contention")
|
||||
}
|
||||
|
||||
/// Verify one expected provider projection without granting durable complete-set
|
||||
/// admission authority. Status may use this to report partial current sight.
|
||||
pub fn verify_idunn_provider_health_candidate(
|
||||
requirement: &RequiredProviderHealth,
|
||||
record: &CultNetRawDocumentRecord,
|
||||
trust_anchor: &GameCultServiceTrustAnchorRecord,
|
||||
expected_idunn_runtime_id: &str,
|
||||
now_unix_millis: u64,
|
||||
max_local_age_millis: u64,
|
||||
) -> Result<IdunnProviderHealthAdmission> {
|
||||
validate_required_set(std::slice::from_ref(requirement))?;
|
||||
validate_anchor(trust_anchor, expected_idunn_runtime_id, now_unix_millis)?;
|
||||
if max_local_age_millis == 0 {
|
||||
bail!("local provider-health TTL is zero");
|
||||
}
|
||||
verify_projection(
|
||||
record,
|
||||
requirement,
|
||||
trust_anchor,
|
||||
expected_idunn_runtime_id,
|
||||
now_unix_millis,
|
||||
max_local_age_millis,
|
||||
)
|
||||
}
|
||||
|
||||
fn verify_projection(
|
||||
record: &CultNetRawDocumentRecord,
|
||||
requirement: &RequiredProviderHealth,
|
||||
|
|
@ -645,6 +686,40 @@ mod tests {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn one_current_candidate_remains_reportable_without_partial_admission() -> Result<()> {
|
||||
let temp = tempfile::tempdir()?;
|
||||
let signer =
|
||||
enroll_service_identity_at::<IdunnServiceIdentity>(&temp.path().join("id.cc"))?;
|
||||
let epiphany = required("epiphany");
|
||||
let bifrost = required("bifrost");
|
||||
let epiphany_record = record(&projection(&signer, &epiphany, 1, 1));
|
||||
let candidate = verify_idunn_provider_health_candidate(
|
||||
&epiphany,
|
||||
&epiphany_record,
|
||||
&anchor(&signer),
|
||||
RUNTIME,
|
||||
NOW,
|
||||
30_000,
|
||||
)?;
|
||||
assert_eq!(candidate.daemon_id, "epiphany");
|
||||
let store = temp.path().join("partial.cc");
|
||||
assert!(
|
||||
admit_required_idunn_provider_health(
|
||||
&store,
|
||||
&[epiphany, bifrost],
|
||||
&[epiphany_record],
|
||||
&anchor(&signer),
|
||||
RUNTIME,
|
||||
NOW,
|
||||
30_000,
|
||||
)
|
||||
.is_err()
|
||||
);
|
||||
assert!(!store.exists());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hostile_projection_substitutions_cannot_erase_prior_admission() -> Result<()> {
|
||||
let temp = tempfile::tempdir()?;
|
||||
|
|
|
|||
|
|
@ -682,7 +682,8 @@ pub use idunn_provider_health::{
|
|||
EPIPHANY_IDUNN_PROVIDER_HEALTH_ADMISSION_SCHEMA, EPIPHANY_IDUNN_PROVIDER_HEALTH_ADMISSION_TYPE,
|
||||
IdunnProviderHealthAdmission, ProviderReleaseBinding, RequiredProviderHealth,
|
||||
admit_required_idunn_provider_health, provider_health_record_key,
|
||||
required_idunn_provider_health_query,
|
||||
read_idunn_provider_health_trust_anchor, required_idunn_provider_health_query,
|
||||
verify_idunn_provider_health_candidate,
|
||||
};
|
||||
pub use idunn_runtime_health::{
|
||||
CULTNET_RUDP_PROTOCOL_ID, EPIPHANY_IDUNN_RUNTIME_HEALTH_CONTRACT,
|
||||
|
|
@ -838,9 +839,10 @@ pub use operator_command_service::{
|
|||
EPIPHANY_OPERATOR_COMMAND_RESULT_RECEIPT_SCHEMA_VERSION,
|
||||
EPIPHANY_OPERATOR_COMMAND_RESULT_RECEIPT_TYPE, EPIPHANY_OPERATOR_COMMAND_RUDP_CONNECTION_ID,
|
||||
EpiphanyOperatorCommandResultReceipt, EpiphanyOperatorCommandServiceHealth,
|
||||
EpiphanyOperatorCommandWireResult, OperatorCommandInteropFixtureManifest,
|
||||
OperatorCommandServiceConfig, OperatorCommandServiceHealthConfig,
|
||||
OperatorCommandServiceReadiness, authenticate_operator_command_service_health,
|
||||
EpiphanyOperatorCommandWireResult, EpiphanyOperatorStatusProviderV2, EpiphanyOperatorStatusV2,
|
||||
OperatorCommandInteropFixtureManifest, OperatorCommandServiceConfig,
|
||||
OperatorCommandServiceHealthConfig, OperatorCommandServiceReadiness,
|
||||
OperatorStatusProviderHealthConfig, authenticate_operator_command_service_health,
|
||||
execute_operator_command_admission, operator_command_result_receipt_signing_payload,
|
||||
operator_command_result_receipt_signing_purpose, read_operator_command_trust_anchor,
|
||||
serve_operator_command_rudp, write_operator_command_interop_fixture,
|
||||
|
|
|
|||
|
|
@ -6,19 +6,24 @@ use cultcache_rs::{
|
|||
use cultnet_rs::{
|
||||
CultNetMessage, CultNetRawDocumentRecord, CultNetRawPayloadEncoding,
|
||||
CultNetRudpSocketTransportConnection, CultNetRudpSocketTransportOptions, CultNetWireContract,
|
||||
decode_cultnet_message_from_slice, encode_cultnet_message_to_vec,
|
||||
GameCultServiceTrustAnchorRecord, decode_cultnet_message_from_slice,
|
||||
encode_cultnet_message_to_vec, query_read_only_raw_snapshot,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use sha2::{Digest, Sha256};
|
||||
use std::net::UdpSocket;
|
||||
use std::net::{SocketAddr, UdpSocket};
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::time::Duration;
|
||||
use std::time::{Instant, SystemTime, UNIX_EPOCH};
|
||||
|
||||
use crate::{
|
||||
BIFROST_OPERATOR_COMMAND_DELIVERY_TYPE, BifrostOperatorCommandAdmission, HostIdentitySigner,
|
||||
HostIdentityTrustAnchorEntry, OperatorCommandPolicy, OperatorCommandResult,
|
||||
admit_and_execute_bifrost_operator_command,
|
||||
HostIdentityTrustAnchorEntry, IdunnProviderHealthAdmission, OperatorCommand,
|
||||
OperatorCommandPolicy, OperatorCommandResult, ProviderReleaseBinding, RequiredProviderHealth,
|
||||
admit_and_execute_bifrost_operator_command, admit_required_idunn_provider_health,
|
||||
load_resident_self_state, pending_repo_frontier_plan_reviews,
|
||||
read_idunn_provider_health_trust_anchor, required_idunn_provider_health_query,
|
||||
resident_self_pressures, verify_idunn_provider_health_candidate,
|
||||
};
|
||||
|
||||
pub const EPIPHANY_OPERATOR_COMMAND_RESULT_RECEIPT_TYPE: &str =
|
||||
|
|
@ -31,6 +36,7 @@ pub const EPIPHANY_OPERATOR_COMMAND_SERVICE_HEALTH_SCHEMA_VERSION: &str =
|
|||
"epiphany.operator_command.service_health.v0";
|
||||
const SERVICE_HEALTH_KEY: &str = "operator-command-service";
|
||||
const SERVICE_HEALTH_SIGNING_PURPOSE: &str = "epiphany.operator-command.service-health.v0";
|
||||
const IDUNN_PUBLIC_HEALTH_QUERY_CONNECTION_ID: u32 = 0x1d0d_0002;
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct OperatorCommandServiceConfig {
|
||||
|
|
@ -40,6 +46,20 @@ pub struct OperatorCommandServiceConfig {
|
|||
pub runtime_store: PathBuf,
|
||||
pub policy: OperatorCommandPolicy,
|
||||
pub trusted_bifrost_identity: HostIdentityTrustAnchorEntry,
|
||||
pub provider_health: OperatorStatusProviderHealthConfig,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct OperatorStatusProviderHealthConfig {
|
||||
pub query_endpoint: SocketAddr,
|
||||
pub idunn_runtime_id: String,
|
||||
pub trust_anchor_store: PathBuf,
|
||||
pub admission_store: PathBuf,
|
||||
pub max_local_age_millis: u64,
|
||||
pub deployment_id: String,
|
||||
pub release_id: String,
|
||||
pub release_witness_sha256: String,
|
||||
pub source_commit: String,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
|
|
@ -127,6 +147,47 @@ pub struct EpiphanyOperatorCommandWireResult {
|
|||
pub reviews: Vec<crate::RepoFrontierPlanReviewSummary>,
|
||||
pub review_candidate_id: String,
|
||||
pub review_decision: String,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub status_v2: Option<EpiphanyOperatorStatusV2>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||
pub struct EpiphanyOperatorStatusProviderV2 {
|
||||
pub daemon_id: String,
|
||||
pub health_contract: String,
|
||||
pub availability: String,
|
||||
pub unavailable_reason: String,
|
||||
pub state: Option<String>,
|
||||
pub reason_code: Option<String>,
|
||||
pub provider_observed_at_unix_millis: Option<u64>,
|
||||
pub evaluated_at_unix_millis: Option<u64>,
|
||||
pub expires_at_unix_millis: Option<u64>,
|
||||
pub release_id: Option<String>,
|
||||
pub release_witness_sha256: Option<String>,
|
||||
pub source_commit: Option<String>,
|
||||
pub deployment_id: Option<String>,
|
||||
pub projection_sha256: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||
pub struct EpiphanyOperatorStatusV2 {
|
||||
pub schema_version: String,
|
||||
pub release_id: String,
|
||||
pub release_witness_sha256: String,
|
||||
pub source_commit: String,
|
||||
pub deployment_id: String,
|
||||
pub coordinator_snapshot: String,
|
||||
pub coordinator_state: String,
|
||||
pub coordinator_action: String,
|
||||
pub brake_status: String,
|
||||
pub resident_status: String,
|
||||
pub pressure_count: usize,
|
||||
pub pending_review_count: usize,
|
||||
pub provider_set_status: String,
|
||||
pub providers: Vec<EpiphanyOperatorStatusProviderV2>,
|
||||
pub private_state_exposed: bool,
|
||||
}
|
||||
|
||||
impl From<&OperatorCommandResult> for EpiphanyOperatorCommandWireResult {
|
||||
|
|
@ -150,6 +211,7 @@ impl From<&OperatorCommandResult> for EpiphanyOperatorCommandWireResult {
|
|||
reviews: value.reviews.clone(),
|
||||
review_candidate_id: value.review_candidate_id.clone(),
|
||||
review_decision: value.review_decision.clone(),
|
||||
status_v2: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -223,7 +285,11 @@ pub fn execute_operator_command_admission(
|
|||
&config.policy,
|
||||
now,
|
||||
)?;
|
||||
let wire_result = EpiphanyOperatorCommandWireResult::from(&result);
|
||||
let mut wire_result = EpiphanyOperatorCommandWireResult::from(&result);
|
||||
if matches!(admission.packet.command, OperatorCommand::Status) {
|
||||
wire_result.schema_version = "epiphany.operator_command.status_result.v2".into();
|
||||
wire_result.status_v2 = Some(build_operator_status_v2(config, &result)?);
|
||||
}
|
||||
let result_payload = rmp_serde::to_vec_named(&wire_result)?;
|
||||
let mut receipt = EpiphanyOperatorCommandResultReceipt {
|
||||
schema_version: EPIPHANY_OPERATOR_COMMAND_RESULT_RECEIPT_SCHEMA_VERSION.into(),
|
||||
|
|
@ -246,6 +312,263 @@ pub fn execute_operator_command_admission(
|
|||
Ok(receipt)
|
||||
}
|
||||
|
||||
fn required_status_providers(
|
||||
config: &OperatorStatusProviderHealthConfig,
|
||||
) -> Vec<RequiredProviderHealth> {
|
||||
vec![
|
||||
RequiredProviderHealth {
|
||||
daemon_id: "yggdrasil-epiphany".into(),
|
||||
health_contract: crate::EPIPHANY_IDUNN_RUNTIME_HEALTH_CONTRACT.into(),
|
||||
release_binding: ProviderReleaseBinding::Exact {
|
||||
release_id: config.release_id.clone(),
|
||||
release_witness_sha256: config.release_witness_sha256.clone(),
|
||||
source_commit: config.source_commit.clone(),
|
||||
deployment_id: config.deployment_id.clone(),
|
||||
},
|
||||
},
|
||||
RequiredProviderHealth {
|
||||
daemon_id: "yggdrasil-bifrost-persona-feedback".into(),
|
||||
health_contract: "bifrost.cultnet-rudp-persona-feedback-health".into(),
|
||||
release_binding: ProviderReleaseBinding::Forbidden,
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
fn build_operator_status_v2(
|
||||
config: &OperatorCommandServiceConfig,
|
||||
result: &OperatorCommandResult,
|
||||
) -> Result<EpiphanyOperatorStatusV2> {
|
||||
let now = SystemTime::now()
|
||||
.duration_since(UNIX_EPOCH)?
|
||||
.as_millis()
|
||||
.try_into()?;
|
||||
let required = required_status_providers(&config.provider_health);
|
||||
let (providers, complete) = match query_and_admit_status_providers(config, &required, now) {
|
||||
Ok(value) => value,
|
||||
Err(_) => (
|
||||
required
|
||||
.iter()
|
||||
.map(|item| {
|
||||
unavailable_provider(item, "authenticated-provider-snapshot-unavailable")
|
||||
})
|
||||
.collect(),
|
||||
false,
|
||||
),
|
||||
};
|
||||
let resident = load_resident_self_state(&config.resident_self_store)?;
|
||||
Ok(EpiphanyOperatorStatusV2 {
|
||||
schema_version: "epiphany.operator.status.v2".into(),
|
||||
release_id: config.provider_health.release_id.clone(),
|
||||
release_witness_sha256: config.provider_health.release_witness_sha256.clone(),
|
||||
source_commit: config.provider_health.source_commit.clone(),
|
||||
deployment_id: config.provider_health.deployment_id.clone(),
|
||||
coordinator_snapshot: result.operator_status.clone(),
|
||||
coordinator_state: result.state_status.clone(),
|
||||
coordinator_action: result.coordinator_action.clone(),
|
||||
brake_status: result.brake_status.clone(),
|
||||
resident_status: if resident.active_turn.is_some() {
|
||||
"resident-self/running"
|
||||
} else {
|
||||
"resident-self/idle"
|
||||
}
|
||||
.into(),
|
||||
pressure_count: resident_self_pressures(&config.resident_self_store)?.len(),
|
||||
pending_review_count: pending_repo_frontier_plan_reviews(&config.runtime_store, 25)?.len(),
|
||||
provider_set_status: if complete {
|
||||
"complete-authenticated"
|
||||
} else {
|
||||
"incomplete"
|
||||
}
|
||||
.into(),
|
||||
providers,
|
||||
private_state_exposed: false,
|
||||
})
|
||||
}
|
||||
|
||||
fn query_and_admit_status_providers(
|
||||
config: &OperatorCommandServiceConfig,
|
||||
required: &[RequiredProviderHealth],
|
||||
now: u64,
|
||||
) -> Result<(Vec<EpiphanyOperatorStatusProviderV2>, bool)> {
|
||||
let anchor: GameCultServiceTrustAnchorRecord =
|
||||
read_idunn_provider_health_trust_anchor(&config.provider_health.trust_anchor_store)?;
|
||||
let query = required_idunn_provider_health_query(
|
||||
format!("operator-status-{now}"),
|
||||
required,
|
||||
&config.provider_health.idunn_runtime_id,
|
||||
)?;
|
||||
let records = query_read_only_raw_snapshot(&query, |request| {
|
||||
exchange_idunn_public_snapshot(
|
||||
config.provider_health.query_endpoint,
|
||||
&config.policy.runtime_id,
|
||||
request,
|
||||
)
|
||||
})?;
|
||||
let mut projected = Vec::with_capacity(required.len());
|
||||
let mut verified_records = Vec::with_capacity(required.len());
|
||||
for requirement in required {
|
||||
let Some(record) = records
|
||||
.iter()
|
||||
.find(|record| record.record_key == requirement.record_key())
|
||||
else {
|
||||
projected.push(unavailable_provider(
|
||||
requirement,
|
||||
"required-provider-record-missing",
|
||||
));
|
||||
continue;
|
||||
};
|
||||
match verify_idunn_provider_health_candidate(
|
||||
requirement,
|
||||
record,
|
||||
&anchor,
|
||||
&config.provider_health.idunn_runtime_id,
|
||||
now,
|
||||
config.provider_health.max_local_age_millis,
|
||||
) {
|
||||
Ok(value) => {
|
||||
projected.push(available_provider(&value));
|
||||
verified_records.push(record.clone());
|
||||
}
|
||||
Err(_) => projected.push(unavailable_provider(
|
||||
requirement,
|
||||
"required-provider-record-invalid",
|
||||
)),
|
||||
}
|
||||
}
|
||||
let complete = verified_records.len() == required.len();
|
||||
if complete {
|
||||
admit_required_idunn_provider_health(
|
||||
&config.provider_health.admission_store,
|
||||
required,
|
||||
&verified_records,
|
||||
&anchor,
|
||||
&config.provider_health.idunn_runtime_id,
|
||||
now,
|
||||
config.provider_health.max_local_age_millis,
|
||||
)?;
|
||||
}
|
||||
Ok((projected, complete))
|
||||
}
|
||||
|
||||
fn exchange_idunn_public_snapshot(
|
||||
endpoint: SocketAddr,
|
||||
runtime_id: &str,
|
||||
request: CultNetMessage,
|
||||
) -> Result<CultNetMessage> {
|
||||
let socket = UdpSocket::bind("0.0.0.0:0")?;
|
||||
socket.set_read_timeout(Some(Duration::from_millis(100)))?;
|
||||
let mut transport =
|
||||
CultNetRudpSocketTransportConnection::new(CultNetRudpSocketTransportOptions::client(
|
||||
runtime_id,
|
||||
socket,
|
||||
endpoint,
|
||||
IDUNN_PUBLIC_HEALTH_QUERY_CONNECTION_ID,
|
||||
))?;
|
||||
transport.connect(Vec::new())?;
|
||||
let deadline = Instant::now() + Duration::from_secs(2);
|
||||
while !transport.connected() {
|
||||
let _ = transport.receive_once()?;
|
||||
transport.poll_resends()?;
|
||||
if Instant::now() >= deadline {
|
||||
bail!("Idunn public provider-health handshake unavailable");
|
||||
}
|
||||
}
|
||||
transport.send(
|
||||
"schema",
|
||||
encode_cultnet_message_to_vec(&request, CultNetWireContract::CultNetSchemaV0)?,
|
||||
)?;
|
||||
loop {
|
||||
if let Some(frame) = transport.receive_once()? {
|
||||
if frame.channel_id != "schema" {
|
||||
bail!("Idunn public provider-health response channel is invalid");
|
||||
}
|
||||
return decode_cultnet_message_from_slice(
|
||||
&frame.payload,
|
||||
CultNetWireContract::CultNetSchemaV0,
|
||||
);
|
||||
}
|
||||
transport.poll_resends()?;
|
||||
if Instant::now() >= deadline {
|
||||
bail!("Idunn public provider-health response unavailable");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn available_provider(value: &IdunnProviderHealthAdmission) -> EpiphanyOperatorStatusProviderV2 {
|
||||
EpiphanyOperatorStatusProviderV2 {
|
||||
daemon_id: value.daemon_id.clone(),
|
||||
health_contract: value.health_contract.clone(),
|
||||
availability: "authenticated-current".into(),
|
||||
unavailable_reason: String::new(),
|
||||
state: Some(value.provider_state.clone()),
|
||||
reason_code: Some(value.reason_code.clone()),
|
||||
provider_observed_at_unix_millis: Some(value.provider_observed_at_unix_millis),
|
||||
evaluated_at_unix_millis: Some(value.evaluated_at_unix_millis),
|
||||
expires_at_unix_millis: Some(value.expires_at_unix_millis),
|
||||
release_id: value.release_id.clone(),
|
||||
release_witness_sha256: value.release_witness_sha256.clone(),
|
||||
source_commit: value.source_commit.clone(),
|
||||
deployment_id: value.deployment_id.clone(),
|
||||
projection_sha256: Some(value.projection_sha256.clone()),
|
||||
}
|
||||
}
|
||||
|
||||
fn unavailable_provider(
|
||||
value: &RequiredProviderHealth,
|
||||
reason: &str,
|
||||
) -> EpiphanyOperatorStatusProviderV2 {
|
||||
EpiphanyOperatorStatusProviderV2 {
|
||||
daemon_id: value.daemon_id.clone(),
|
||||
health_contract: value.health_contract.clone(),
|
||||
availability: "unavailable".into(),
|
||||
unavailable_reason: reason.into(),
|
||||
state: None,
|
||||
reason_code: None,
|
||||
provider_observed_at_unix_millis: None,
|
||||
evaluated_at_unix_millis: None,
|
||||
expires_at_unix_millis: None,
|
||||
release_id: None,
|
||||
release_witness_sha256: None,
|
||||
source_commit: None,
|
||||
deployment_id: None,
|
||||
projection_sha256: None,
|
||||
}
|
||||
}
|
||||
|
||||
fn operator_status_v2_migration_fixture() -> EpiphanyOperatorStatusV2 {
|
||||
let requirements = required_status_providers(&OperatorStatusProviderHealthConfig {
|
||||
query_endpoint: "127.0.0.1:1".parse().expect("fixed fixture endpoint"),
|
||||
idunn_runtime_id: "idunn-yggdrasil".into(),
|
||||
trust_anchor_store: PathBuf::new(),
|
||||
admission_store: PathBuf::new(),
|
||||
max_local_age_millis: 30_000,
|
||||
deployment_id: "deployment-fixture".into(),
|
||||
release_id: "release-fixture".into(),
|
||||
release_witness_sha256: format!("sha256-{}", "a".repeat(64)),
|
||||
source_commit: "b".repeat(40),
|
||||
});
|
||||
EpiphanyOperatorStatusV2 {
|
||||
schema_version: "epiphany.operator.status.v2".into(),
|
||||
release_id: "release-fixture".into(),
|
||||
release_witness_sha256: format!("sha256-{}", "a".repeat(64)),
|
||||
source_commit: "b".repeat(40),
|
||||
deployment_id: "deployment-fixture".into(),
|
||||
coordinator_snapshot: "coordinator-snapshot/sleeping".into(),
|
||||
coordinator_state: "coordinator-state/ready".into(),
|
||||
coordinator_action: "coordinator-action/none".into(),
|
||||
brake_status: "engaged".into(),
|
||||
resident_status: "resident-self/idle".into(),
|
||||
pressure_count: 0,
|
||||
pending_review_count: 0,
|
||||
provider_set_status: "incomplete".into(),
|
||||
providers: requirements
|
||||
.iter()
|
||||
.map(|value| unavailable_provider(value, "required-provider-record-missing"))
|
||||
.collect(),
|
||||
private_state_exposed: false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn serve_operator_command_rudp(
|
||||
socket: UdpSocket,
|
||||
config: &OperatorCommandServiceConfig,
|
||||
|
|
@ -329,6 +652,17 @@ fn service_config_sha256(
|
|||
&config.policy.actor_capabilities,
|
||||
config.policy.max_ttl_seconds,
|
||||
config.trusted_bifrost_identity.identity_id.as_str(),
|
||||
(
|
||||
config.provider_health.query_endpoint,
|
||||
config.provider_health.idunn_runtime_id.as_str(),
|
||||
&config.provider_health.trust_anchor_store,
|
||||
&config.provider_health.admission_store,
|
||||
config.provider_health.max_local_age_millis,
|
||||
config.provider_health.deployment_id.as_str(),
|
||||
config.provider_health.release_id.as_str(),
|
||||
config.provider_health.release_witness_sha256.as_str(),
|
||||
config.provider_health.source_commit.as_str(),
|
||||
),
|
||||
health.bind.as_str(),
|
||||
health.release_id.as_str(),
|
||||
health.release_witness_sha256.as_str(),
|
||||
|
|
@ -560,6 +894,17 @@ pub fn write_operator_command_interop_fixture(
|
|||
max_ttl_seconds: 60,
|
||||
},
|
||||
trusted_bifrost_identity: bifrost_anchor.clone(),
|
||||
provider_health: OperatorStatusProviderHealthConfig {
|
||||
query_endpoint: "127.0.0.1:1".parse()?,
|
||||
idunn_runtime_id: "idunn-interop-fixture".into(),
|
||||
trust_anchor_store: private.join("idunn-anchor.cc"),
|
||||
admission_store: private.join("provider-admission.cc"),
|
||||
max_local_age_millis: 30_000,
|
||||
deployment_id: "deployment-fixture".into(),
|
||||
release_id: "release-fixture".into(),
|
||||
release_witness_sha256: format!("sha256-{}", "a".repeat(64)),
|
||||
source_commit: "b".repeat(40),
|
||||
},
|
||||
};
|
||||
let packet = crate::OperatorCommandPacket {
|
||||
command_id: "fixture-command-1".into(),
|
||||
|
|
@ -668,7 +1013,11 @@ pub fn write_operator_command_interop_fixture(
|
|||
}],
|
||||
review_candidate_id: String::new(),
|
||||
review_decision: String::new(),
|
||||
status_v2: None,
|
||||
})?,
|
||||
"operatorStatusV2MigrationFixture": serde_json::to_value(
|
||||
operator_status_v2_migration_fixture()
|
||||
)?,
|
||||
});
|
||||
let protocol_bytes = serde_json::to_vec_pretty(&protocol)?;
|
||||
std::fs::write(output.join("protocol.json"), &protocol_bytes)?;
|
||||
|
|
@ -710,6 +1059,32 @@ mod tests {
|
|||
use std::thread;
|
||||
use std::time::Instant;
|
||||
|
||||
#[test]
|
||||
fn status_v2_golden_is_bounded_and_names_exact_provider_policies() {
|
||||
let value = operator_status_v2_migration_fixture();
|
||||
assert_eq!(value.schema_version, "epiphany.operator.status.v2");
|
||||
assert_eq!(value.provider_set_status, "incomplete");
|
||||
assert_eq!(value.providers.len(), 2);
|
||||
assert_eq!(value.providers[0].daemon_id, "yggdrasil-epiphany");
|
||||
assert_eq!(
|
||||
value.providers[1].daemon_id,
|
||||
"yggdrasil-bifrost-persona-feedback"
|
||||
);
|
||||
assert!(value.providers.iter().all(|provider| {
|
||||
provider.availability == "unavailable"
|
||||
&& provider.state.is_none()
|
||||
&& provider.projection_sha256.is_none()
|
||||
}));
|
||||
let json = serde_json::to_string(&value).unwrap();
|
||||
for forbidden in ["signature", "privateKey", "detail", "\\\\", ":\\"] {
|
||||
assert!(
|
||||
!json.contains(forbidden),
|
||||
"leaked forbidden field {forbidden}"
|
||||
);
|
||||
}
|
||||
assert!(!value.private_state_exposed);
|
||||
}
|
||||
|
||||
fn fixture(
|
||||
root: &Path,
|
||||
) -> Result<(
|
||||
|
|
@ -737,6 +1112,17 @@ mod tests {
|
|||
max_ttl_seconds: 60,
|
||||
},
|
||||
trusted_bifrost_identity: anchor,
|
||||
provider_health: OperatorStatusProviderHealthConfig {
|
||||
query_endpoint: "127.0.0.1:1".parse()?,
|
||||
idunn_runtime_id: "idunn-yggdrasil".into(),
|
||||
trust_anchor_store: root.join("idunn-anchor.cc"),
|
||||
admission_store: root.join("provider-admission.cc"),
|
||||
max_local_age_millis: 30_000,
|
||||
deployment_id: "deployment-test".into(),
|
||||
release_id: "release-test".into(),
|
||||
release_witness_sha256: format!("sha256-{}", "a".repeat(64)),
|
||||
source_commit: "b".repeat(40),
|
||||
},
|
||||
},
|
||||
executor,
|
||||
bifrost,
|
||||
|
|
|
|||
|
|
@ -208,6 +208,19 @@ before return. The ignored persistent smoke output lives at
|
|||
`.epiphany-smoke/operator-command-interop-rust`; regenerate it rather than
|
||||
committing generated signatures or private material.
|
||||
|
||||
Status now has an explicit Epiphany-owned v2 wire projection. The persisted
|
||||
command result remains v1; only a Status receipt carries
|
||||
`epiphany.operator_command.status_result.v2` plus typed `statusV2`. Every call
|
||||
queries Idunn's public CultNet/RUDP snapshot for exactly Epiphany and Bifrost,
|
||||
verifies each returned record independently against the root-pinned Idunn
|
||||
projection anchor, and commits the local admission store only when the complete
|
||||
set verifies. A valid record remains visible when its peer is absent, while the
|
||||
set stays `incomplete`; stale admission is never reused as current sight.
|
||||
Provider output contains bounded state, reason, clocks, lineage, and digest—no
|
||||
signature, detail, path, key, or private state. `protocol.json` now contains the
|
||||
typed `operatorStatusV2MigrationFixture` golden value for Bifrost and VoidBot
|
||||
migration; neither consumer is changed by this pass.
|
||||
|
||||
Bifrost's JavaScript smoke consumes those Rust bytes, verifies admission and
|
||||
receipt signatures plus payload digests, compares the real compact enum/byte
|
||||
shapes, and rejects mutation. That proof exposed two corrected boundary faults:
|
||||
|
|
|
|||
|
|
@ -1,5 +1,26 @@
|
|||
# Fresh Workspace Handoff
|
||||
|
||||
## Authenticated provider health is wired into Epiphany Status v2 (2026-07-19)
|
||||
|
||||
The Epiphany operator service now requires Idunn public-query endpoint, pinned
|
||||
projection anchor, provider admission store, Idunn runtime, local TTL, and exact
|
||||
deployment lineage configuration. Each Status invocation queries exactly
|
||||
`yggdrasil-epiphany` and `yggdrasil-bifrost-persona-feedback` through CultNet
|
||||
RUDP, verifies returned records independently, and atomically advances durable
|
||||
admission only for a complete valid set. One valid record remains reportable
|
||||
when its peer is missing, but the set is explicitly `incomplete`; stale durable
|
||||
admission is never presented as current sight.
|
||||
|
||||
Only Status uses `epiphany.operator_command.status_result.v2` and typed
|
||||
`statusV2`; stored command results and every non-Status wire result remain v1.
|
||||
The bounded projection carries release lineage, coordinator/brake/resident
|
||||
namespaces, pressure and pending-review counts, and two provider projections
|
||||
containing state/reason/clocks/bounded lineage/digest. It carries no provider
|
||||
signature, detail, path, key, or private state. The Rust interop protocol fixture
|
||||
now includes `operatorStatusV2MigrationFixture` for later Bifrost/VoidBot work;
|
||||
those consumers are deliberately unchanged. Focused provider/service/CLI tests
|
||||
pass 6/6, 7/7, and 1/1; full core library passes 605/0/1.
|
||||
|
||||
## Epiphany canonical signed-health publisher landed (2026-07-19)
|
||||
|
||||
The Epiphany supervisor now publishes the generic canonical
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -18,7 +18,7 @@ experiment:
|
|||
sleep_brake_semantics: "An engaged swarm brake is sleep mode, not daemon death. Resident services may remain supervised, publish liveness/health, refresh leases, and expose read-only operator sight. The brake blocks cognition launches, scheduling that creates cognitive work, Hands consequences, publication, and deployment action."
|
||||
swarm_brake_authority: "The only physical brake truth is the runtime-scoped CultMesh key epiphany-local/swarm-brake. Observation uses swarm-brake-status and is byte-pure; mutation uses swarm-brake-set and requires explicit engaged/released status, canonical document id epiphany/swarm-brake, actor, and reason. Legacy swarm-brake/brake commands refuse. The stable owner is epiphany.swarm-brake; command actors are provenance, not owners. Release refuses absent or foreign/legacy identity. Idunn alone may adopt an already-engaged legacy head into the canonical identity during deployment, without any released interval. Discord Sleep preserves foreign brakes; Wake releases only the exact canonical owner. Resident readiness reads the same key, and deployment admission requires brakeEngaged=true before service restart."
|
||||
discord_mind_review_owner: "The typed Discord operator core routes Reviews/Review into the canonical frontier-plan Mind owner, not a parallel queue. Reviews exposes only bounded request/candidate/model/frontier identities. Exact Adopt/Refuse/Hold revalidates immutable Imagination and current RepoModel bindings; Hold/Refuse are terminal inert receipts; Adopt alone uses the existing RepoModel CAS and creates no Hands authority, Substrate grant, Persona speech, Bifrost release, or Idunn deployment. Decision provenance is typed as Mind worker or authenticated operator command/admission/packet/actor; downstream RepoModel provenance is typed as worker result or frontier-plan decision, with Option absence instead of empty sentinels. Replay time derives from immutable issuance, machine faults are not terminal refusals, CultCache v0 decision tuples decode explicitly, and signed v0 deliveries may drain only the original four commands. The v1 Epiphany/Bifrost/VoidBot chain is deployed on Yggdrasil behind an engaged canonical brake; the remaining proof is operator-safe Discord interaction, not schema or deployment work."
|
||||
discord_status_truth: "The deployed Status command reads a narrow coordinator snapshot and the independently owned swarm brake. It namespaces the coordinator fields as coordinator-snapshot/<status>, coordinator-state/<status>, and coordinator-action/<action>; VoidBot labels them Coordinator snapshot and Coordinator action. It explicitly refuses to call them deployment/provider readiness and does not authenticate or compose packaged-release, resident-readiness, Idunn, or Bifrost health. Audit found no usable Idunn/Bifrost ingress: generic idunn.daemon_health.v1 is typed but unsigned, trusts self-declared publication source/transport, and has no authenticated Idunn outward projection. Odin branch codex/ygg-organizational-idunn commit be8836f now verifies generic signed health against an exact root trust binding, atomically admits statement+judgment+health under monotonic CAS, rejoins current trust on managed reads, and quarantines unsigned packets under a diagnostic-only type/key that cannot reset continuity or suppress recovery. The outward contract is deliberately narrower than Idunn's complete managed judgment: `idunn.authenticated_provider_health_projection.v1` asserts only a current authenticated provider statement joined to its admission, root binding, and optional deployment lineage. Missing publication, release drift, and dependency failure are absence of that assertion; they may not be conceptually substituted into provider health. Idunn signs the bounded assertion with a separately stored typed service identity and writes only a dedicated public CultCache store. A generic CultNet snapshot server carries exact bytes from that public store. Epiphany pins the Idunn public trust anchor and locally verifies signature, freshness, replay monotonicity, requested daemon/contract, and release/deployment lineage before lowering bounded status to Discord. Odin transports bytes but never recreates health truth. Private Idunn state, provider detail, unsigned diagnostics, PID sight, generic ready strings, caller booleans, and provider signatures cannot substitute. The source is intentionally not deployable until Epiphany and Bifrost publishers, root bindings, Idunn projection, public query, and consumer verification migrate together."
|
||||
discord_status_truth: "Epiphany's operator service now emits an explicit typed Status v2 while preserving stored command results and every non-Status wire result as v1. Each invocation queries Idunn's public CultNet/RUDP snapshot for exact Epiphany and Bifrost policies, verifies each returned projection independently against the root-pinned Idunn anchor and current clock/release policy, and atomically admits only a complete valid set. A valid record remains visible when its peer is absent, while providerSetStatus remains incomplete; stale admission never becomes current sight. The bounded payload carries deployment lineage, coordinator/brake/resident namespaces, pressure and pending-review counts, and two provider state/reason/time/lineage/digest projections. Missing, invalid, or transport-unavailable providers are explicitly unavailable, never manufactured failed. Signatures, private details, paths, keys, and provider detail are excluded. Bifrost and VoidBot are not yet migrated; the generated interop protocol includes a typed Status v2 golden fixture for that later boundary cut."
|
||||
idunn_provider_health_consumer: "Epiphany now owns a pure read/admission organ for Idunn's public `idunn.authenticated_provider_health_projection.v1` records. It builds an exact CultNet raw-snapshot query for the required daemon/contract pairs, rejects duplicates, extras, and missing records, requires canonical MessagePack and exact transport/runtime/schema/key identity, validates the closed provider state/reason contract, verifies the Idunn signature with the root-pinned typed service trust anchor and fixed purpose, enforces anchor and local TTL lifetimes plus Forbidden-or-Exact release lineage, and atomically CAS-admits the complete required set into a dedicated CultCache store. Durable admissions preserve projection/provider sequence and incarnation, exact signed digests, Idunn signer/runtime, anchor digest/bound time, and release lineage. Same-anchor replay is refused; a root anchor rotation resets continuity only when its bound time strictly follows the prior admitted/evaluated sight and the new signed projection follows that binding. An old anchor or packet-supplied self key cannot rotate trust. Invalid, absent, stale, substituted, or replayed input performs no write and cannot erase the last admission. CultNet owner commit `a1001dc` now also owns the canonical `idunn.signed_daemon_health.v1` record beside the shared identity/contracts/query/RUDP organs consumed here. This module grants no Status, Mind, Hands, Bifrost, Idunn, Wake, release, or deployment authority."
|
||||
epiphany_signed_provider_health_publisher: "The daemon supervisor now publishes only the canonical generic 17-field positional `idunn.signed_daemon_health.v1` record, signed over the empty-signature tuple with CultNet's dedicated `GameCultProviderHealthIdentity` and `IdunnSignedDaemonHealthPurpose`. The record binds exact supervisor runtime id, release id/witness, source commit, deployment request, one process UUID incarnation, and checked monotonic sequence; detail is a bounded generic reason and private state is false. Runtime opens an immutable typed provider identity store and never enrolls implicitly. Explicit enroll/export commands live in the existing supervisor binary and export a distinct public-only anchor, so package witness roles do not change. Host identity and the Epiphany-only v0 health contract are no longer publisher authorities. Focused publisher tests pass 6/6, supervisor tests 25/25, full library 603/0/1, and isolated live enroll/export smoke passed."
|
||||
status: active
|
||||
|
|
@ -814,4 +814,4 @@ current_status:
|
|||
- Candidate `b8517d9d7905eb62314db675cc2f0688510aa5bd` proved stale launch terminalization and current-policy replacement launch: supervisor PID `1147968` launched replacement workspace projector PID `1148157`, whose authenticated ready heartbeat advanced while the engaged brake held. Recovery still stalled because the old Body claim could be read only through current-claim authentication, which correctly rejected its historical policy before the mismatch recovery branch. The candidate was rolled back and revoked; no deployment witness exists. Claim sight now has two explicit authorities: current authentication is required for provider projection work and rejects stale launches; recovery authentication proves the old signed claim/body/route lineage only. Supervisor recovery and directive writing use the recovery reader, while old launch authentication inside the atomic lease-transfer transaction is historical and the replacement launch/heartbeat remain current-policy evidence. The full causal test performs an actual policy rotation and proves current refusal, historical recovery, directive fencing, lease transfer, successor current sight, and replay/tamper boundaries. Full core passes 573/573 with one ignored; all binaries compile.
|
||||
- Candidate `351355d3baee2d475f84168136380d2f50197ef8` authenticated the historical claim and started all three owners under the brake, but recovery refused because the claim named an older launch than the current replacement's direct parent. Repeated failed candidate deployments had formed a valid signed replacement chain, while recovery still assumed one direct old-to-new edge. The exact Idunn process group was terminated, all services stopped, active pointer and witness removed, and Bifrost authority revoked. No deployment witness exists. Recovery now authenticates the complete immutable chain from the claim's historical launch to the live current-policy descendant: every intermediate launch is host-signed, every parent termination id and envelope digest is exact, chronology is ordered, cycles and broken edges refuse, and the selected endpoint must be current. Directive writing, receipt verification, atomic lease transfer, and supervisor resume share this proof. Typed refusal now exposes the exact lineage fault instead of swallowing it. The causal recovery test contains a real intermediate generation and still proves the full fenced transaction. Full library passes 573/573 with one ignored; supervisor authority tests pass 24/24.
|
||||
- Candidate `a70fe275195740ecefc2984b32ebd8ae93658c18` proved the full signed multi-generation chain and emitted recovery directive `06165fb6-97bd-4c27-97e3-38af03dec72d` from historical claim `c6df4335-7080-4d5f-80fc-4fa18a9d16ce` to current launch `9414c32f-f53c-450c-bc19-a69f5ba04a29`. The replacement projector nevertheless kept refusing stale-policy claim sight because its pulse authenticated the not-yet-created current successor claim before looking for the recovery directive. Supervisor replayed the same directive without mutating Body, exposing a circular ordering fault. The exact Idunn process group was terminated, services stopped, pointer and witness removed, and Bifrost authority revoked; no deployment witness exists. Projector recovery directive consumption now precedes all ordinary projection work and invokes the already idempotent atomic transfer directly. Current claim sight is an output of recovery, never a prerequisite for it. Full library now passes 574/574 with one ignored; supervisor authority tests pass 24/24.
|
||||
next_action: "Advance Odin to CultNet `a1001dc` and remove/re-export its duplicate Rust `IdunnSignedDaemonHealthRecord`, then complete root-owned Idunn trust bindings and Idunn's dedicated public CultCache snapshot serving. Epiphany and Bifrost canonical dedicated-identity publishers are landed. Wire Status only after the authenticated projection chain is complete; missing provider assertion remains explicit absence. Deploy through Bifrost/Idunn under the engaged brake. Do not test Wake or reboot the host."
|
||||
next_action: "Migrate Bifrost and VoidBot to consume the explicit Epiphany Status v2 sealed result using the generated golden fixture, then provision the operator service's Idunn query/anchor/admission/lineage arguments on Yggdrasil and deploy through Bifrost/Idunn under the engaged brake. Run operator-safe Discord Status proof with complete and one-missing provider cases. Missing provider assertion remains explicit absence. Do not test Wake or reboot the host."
|
||||
|
|
|
|||
Reference in a new issue