Preflight Modeling runtime schemas

This commit is contained in:
Meta Vens 2026-07-12 12:09:36 +01:00
commit e76676642b
13 changed files with 284 additions and 12 deletions

View file

@ -225,6 +225,22 @@ fn service_launch(args: Args) -> Result<()> {
)?;
let context = query_epiphany_local_verse_context(&args.store, args.runtime_id.clone())?;
assert_swarm_brake_allows_service_lifecycle(&context)?;
if !args.required_document_types.is_empty()
&& (!args.schema_preflight_passed
|| args.executable_sha256.as_deref().is_none_or(str::is_empty)
|| args
.schema_catalog_sha256
.as_deref()
.is_none_or(str::is_empty)
|| args
.preflight_witness_id
.as_deref()
.is_none_or(str::is_empty))
{
anyhow::bail!(
"typed service launch requires passing schema preflight, executable and schema SHA-256 fingerprints, and preflight witness identity"
);
}
let started_at = Utc::now();
let command_path = service_command_path(&args)?;
let service_args = service_serve_args(&args);
@ -303,6 +319,11 @@ fn service_launch(args: Args) -> Result<()> {
"exitCode": written.exit_code,
"stdoutArtifact": args.stdout_artifact,
"stderrArtifact": args.stderr_artifact,
"executableSha256": written.executable_sha256,
"schemaCatalogSha256": written.schema_catalog_sha256,
"preflightWitnessId": written.preflight_witness_id,
"requiredDocumentTypes": written.required_document_types,
"schemaPreflightPassed": written.schema_preflight_passed,
"privateStateExposed": written.private_state_exposed,
}))?
);
@ -3036,6 +3057,11 @@ fn service_lifecycle_receipt(
"The service command may run the supervisor serve loop, but scheduler decisions remain typed local Verse receipts."
.to_string(),
],
executable_sha256: args.executable_sha256.clone().unwrap_or_default(),
schema_catalog_sha256: args.schema_catalog_sha256.clone().unwrap_or_default(),
preflight_witness_id: args.preflight_witness_id.clone().unwrap_or_default(),
required_document_types: args.required_document_types.clone(),
schema_preflight_passed: args.schema_preflight_passed,
}
}
@ -3191,6 +3217,11 @@ struct Args {
artifact_ref: Option<String>,
stdout_artifact: Option<PathBuf>,
stderr_artifact: Option<PathBuf>,
executable_sha256: Option<String>,
schema_catalog_sha256: Option<String>,
preflight_witness_id: Option<String>,
required_document_types: Vec<String>,
schema_preflight_passed: bool,
}
impl Args {
@ -3233,6 +3264,11 @@ impl Args {
let mut artifact_ref = None;
let mut stdout_artifact = None;
let mut stderr_artifact = None;
let mut executable_sha256 = None;
let mut schema_catalog_sha256 = None;
let mut preflight_witness_id = None;
let mut required_document_types = Vec::new();
let mut schema_preflight_passed = false;
while let Some(arg) = values.next() {
match arg.as_str() {
@ -3372,6 +3408,30 @@ impl Args {
values.next().context("missing --stderr-artifact value")?,
));
}
"--executable-sha256" => {
executable_sha256 =
Some(values.next().context("missing --executable-sha256 value")?);
}
"--schema-catalog-sha256" => {
schema_catalog_sha256 = Some(
values
.next()
.context("missing --schema-catalog-sha256 value")?,
);
}
"--preflight-witness-id" => {
preflight_witness_id = Some(
values
.next()
.context("missing --preflight-witness-id value")?,
);
}
"--required-document-type" => required_document_types.push(
values
.next()
.context("missing --required-document-type value")?,
),
"--schema-preflight-passed" => schema_preflight_passed = true,
other => anyhow::bail!("unknown argument {other:?}"),
}
}
@ -3499,6 +3559,11 @@ impl Args {
artifact_ref,
stdout_artifact,
stderr_artifact,
executable_sha256,
schema_catalog_sha256,
preflight_witness_id,
required_document_types,
schema_preflight_passed,
})
}
}

View file

@ -3372,6 +3372,11 @@ fn run_cli() -> Result<()> {
"Synthetic verse-query smoke receipt for service lifecycle action rows."
.to_string(),
],
executable_sha256: String::new(),
preflight_witness_id: String::new(),
required_document_types: Vec::new(),
schema_preflight_passed: false,
schema_catalog_sha256: String::new(),
},
)?;
}
@ -3402,6 +3407,11 @@ fn run_cli() -> Result<()> {
"Synthetic verse-query smoke receipt for single-service execution runbook action row."
.to_string(),
],
executable_sha256: String::new(),
preflight_witness_id: String::new(),
required_document_types: Vec::new(),
schema_preflight_passed: false,
schema_catalog_sha256: String::new(),
},
)?;
write_epiphany_cultmesh_daemon_service_lifecycle_receipt(
@ -3432,6 +3442,11 @@ fn run_cli() -> Result<()> {
"Synthetic verse-query smoke receipt for single-service lifecycle action rows."
.to_string(),
],
executable_sha256: String::new(),
preflight_witness_id: String::new(),
required_document_types: Vec::new(),
schema_preflight_passed: false,
schema_catalog_sha256: String::new(),
},
)?;
let service_overview = load_swarm_overview_report(&args)?;
@ -3848,6 +3863,11 @@ fn run_cli() -> Result<()> {
"Synthetic verse-query smoke receipt for lifecycle follow-up routing."
.to_string(),
],
executable_sha256: String::new(),
preflight_witness_id: String::new(),
required_document_types: Vec::new(),
schema_preflight_passed: false,
schema_catalog_sha256: String::new(),
};
let readiness_follow_up_row = receipt_directory_service_lifecycle_row(
"cluster-service-lifecycle",

View file

@ -14454,6 +14454,53 @@ fn launch_repo_work_modeling_worker(
)),
},
);
let runtime_bin = resolve_repo_work_model_runtime(epiphany_root)?;
let supervisor_bin = resolve_daemon_supervisor(epiphany_root)?;
let required_document_types = [
epiphany_core::REPO_WORK_MODELING_ROUTE_TYPE,
epiphany_core::REPO_WORK_MODELING_REQUEST_TYPE,
epiphany_core::REPO_WORK_MODELING_FINDING_TYPE,
epiphany_core::RUNTIME_WORKER_LAUNCH_REQUEST_TYPE,
];
let mut preflight_command = Command::new(&runtime_bin);
preflight_command
.arg("preflight")
.arg("--store")
.arg(runtime_store);
for document_type in required_document_types {
preflight_command
.arg("--require-document-type")
.arg(document_type);
}
let preflight_output = preflight_command.output().with_context(|| {
format!(
"failed to preflight Modeling runtime {}",
runtime_bin.display()
)
})?;
if !preflight_output.status.success() {
return Err(anyhow!(
"Modeling runtime preflight refused launch before opening a job: {}",
String::from_utf8_lossy(&preflight_output.stderr)
));
}
let preflight: Value = serde_json::from_slice(&preflight_output.stdout)
.context("Modeling runtime preflight did not emit JSON")?;
if preflight["schemaPreflightPassed"].as_bool() != Some(true) {
return Err(anyhow!("Modeling runtime schema preflight did not pass"));
}
let executable_sha256 = preflight["executableSha256"]
.as_str()
.filter(|value| !value.is_empty())
.ok_or_else(|| anyhow!("Modeling runtime preflight omitted executable SHA-256"))?;
let schema_catalog_sha256 = preflight["schemaCatalogSha256"]
.as_str()
.filter(|value| !value.is_empty())
.ok_or_else(|| anyhow!("Modeling runtime preflight omitted schema catalog SHA-256"))?;
let preflight_witness_id = preflight["preflightWitnessId"]
.as_str()
.filter(|value| !value.is_empty())
.ok_or_else(|| anyhow!("Modeling runtime preflight omitted witness identity"))?;
let created_at = Utc::now().to_rfc3339_opts(chrono::SecondsFormat::Secs, true);
open_runtime_spine_heartbeat_job(
runtime_store,
@ -14480,8 +14527,6 @@ fn launch_repo_work_modeling_worker(
created_at,
},
)?;
let runtime_bin = resolve_repo_work_model_runtime(epiphany_root)?;
let supervisor_bin = resolve_daemon_supervisor(epiphany_root)?;
let stdout_path = artifact_dir.join(format!("{job_id}.stdout.log"));
let stderr_path = artifact_dir.join(format!("{job_id}.stderr.log"));
let service_id = format!("idunn-{job_id}");
@ -14521,6 +14566,21 @@ fn launch_repo_work_modeling_worker(
.arg(&stdout_path)
.arg("--stderr-artifact")
.arg(&stderr_path)
.arg("--executable-sha256")
.arg(executable_sha256)
.arg("--schema-catalog-sha256")
.arg(schema_catalog_sha256)
.arg("--preflight-witness-id")
.arg(preflight_witness_id)
.arg("--required-document-type")
.arg(epiphany_core::REPO_WORK_MODELING_ROUTE_TYPE)
.arg("--required-document-type")
.arg(epiphany_core::REPO_WORK_MODELING_REQUEST_TYPE)
.arg("--required-document-type")
.arg(epiphany_core::REPO_WORK_MODELING_FINDING_TYPE)
.arg("--required-document-type")
.arg(epiphany_core::RUNTIME_WORKER_LAUNCH_REQUEST_TYPE)
.arg("--schema-preflight-passed")
.arg("--reason")
.arg(format!(
"Idunn launches typed repo-work Modeling job {job_id}."
@ -14548,6 +14608,11 @@ fn launch_repo_work_modeling_worker(
"lifecycleOwner": "Idunn",
"lifecycleReceiptId": lifecycle["receiptId"],
"serviceId": lifecycle["serviceId"],
"executableSha256": lifecycle["executableSha256"],
"schemaCatalogSha256": lifecycle["schemaCatalogSha256"],
"preflightWitnessId": lifecycle["preflightWitnessId"],
"requiredDocumentTypes": lifecycle["requiredDocumentTypes"],
"schemaPreflightPassed": lifecycle["schemaPreflightPassed"],
"stdoutArtifact": stdout_path,
"stderrArtifact": stderr_path,
"requestId": request.request_id,
@ -16867,6 +16932,11 @@ mod authority_tests {
assert!(!production.contains(".spawn()"));
assert!(production.contains("epiphany-daemon-supervisor"));
assert!(production.contains("\"lifecycleOwner\": \"Idunn\""));
assert!(
production.find("preflight_command.output()")
< production.find("open_runtime_spine_heartbeat_job(")
);
assert!(production.contains("schemaPreflightPassed"));
assert!(!source.contains(&["RepoWork", "MapStore"].concat()));
assert!(!source.contains(&["repo-work-map", ".msgpack"].concat()));
}

View file

@ -1459,6 +1459,16 @@ pub struct EpiphanyCultMeshDaemonServiceLifecycleReceiptEntry {
pub private_state_exposed: bool,
#[cultcache(key = 17)]
pub notes: Vec<String>,
#[cultcache(key = 18, default)]
pub executable_sha256: String,
#[cultcache(key = 19, default)]
pub preflight_witness_id: String,
#[cultcache(key = 20, default)]
pub required_document_types: Vec<String>,
#[cultcache(key = 21, default)]
pub schema_preflight_passed: bool,
#[cultcache(key = 22, default)]
pub schema_catalog_sha256: String,
}
#[derive(Clone, Debug, PartialEq, Eq, DatabaseEntry)]
@ -3988,6 +3998,16 @@ fn validate_daemon_service_lifecycle_receipt(
return Err(anyhow!("daemon service lifecycle receipt missing {label}"));
}
}
if !receipt.required_document_types.is_empty()
&& (!receipt.schema_preflight_passed
|| receipt.executable_sha256.trim().is_empty()
|| receipt.schema_catalog_sha256.trim().is_empty()
|| receipt.preflight_witness_id.trim().is_empty())
{
return Err(anyhow!(
"typed daemon service lifecycle receipt requires passing schema preflight, executable fingerprint, and preflight witness"
));
}
Ok(())
}
@ -7313,6 +7333,11 @@ mod tests {
operator_artifact_ref: "artifact://service-lifecycle/first".to_string(),
private_state_exposed: false,
notes: Vec::new(),
executable_sha256: String::new(),
preflight_witness_id: String::new(),
required_document_types: Vec::new(),
schema_preflight_passed: false,
schema_catalog_sha256: String::new(),
};
let mut second = first.clone();
second.receipt_id = "service-lifecycle-second".to_string();
@ -7378,6 +7403,11 @@ mod tests {
.to_string(),
private_state_exposed: false,
notes: Vec::new(),
executable_sha256: String::new(),
preflight_witness_id: String::new(),
required_document_types: Vec::new(),
schema_preflight_passed: false,
schema_catalog_sha256: String::new(),
},
]);
let runbook_check = report

View file

@ -818,6 +818,7 @@ pub use runtime_spine::runtime_job_snapshot;
pub use runtime_spine::runtime_latest_hands_receipt_chain_after;
pub use runtime_spine::runtime_mind_gateway_review;
pub use runtime_spine::runtime_mind_state_commit_receipt;
pub use runtime_spine::runtime_registered_document_types;
pub use runtime_spine::runtime_reorient_worker_result;
pub use runtime_spine::runtime_repo_work_map_entry;
pub use runtime_spine::runtime_repo_work_modeling_finding;

View file

@ -789,7 +789,7 @@ pub fn initialize_runtime_spine(
runtime_kind: "epiphany.native".to_string(),
created_at,
updated_at: options.created_at,
supported_document_types: supported_runtime_document_types(),
supported_document_types: runtime_registered_document_types(),
metadata: BTreeMap::from([("codexEvacuationBridge".to_string(), "temporary".to_string())]),
};
cache.put(RUNTIME_IDENTITY_KEY, &identity)?;
@ -1117,7 +1117,7 @@ pub fn prepare_runtime_spine_heartbeat_job(
.map(|value| value.created_at.clone())
.unwrap_or_else(|| options.created_at.clone()),
updated_at: options.created_at.clone(),
supported_document_types: supported_runtime_document_types(),
supported_document_types: runtime_registered_document_types(),
metadata: BTreeMap::from([("codexEvacuationBridge".to_string(), "temporary".to_string())]),
};
let session = match cache.get::<EpiphanyRuntimeSession>(&options.session_id)? {
@ -2544,7 +2544,7 @@ fn require_identity(cache: &CultCache) -> Result<EpiphanyRuntimeIdentity> {
.ok_or_else(|| anyhow!("runtime spine is missing identity; run init first"))
}
fn supported_runtime_document_types() -> Vec<String> {
pub fn runtime_registered_document_types() -> Vec<String> {
let mut document_types = Vec::new();
for contract in epiphany_mutation_contracts() {
if !document_types.contains(&contract.document_type) {