From 63d2991e6381114a195d9d500f1eeda97cc3e63b Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Mon, 24 Aug 2026 03:15:12 +0200 Subject: [PATCH] Minimize coordinator terminal receipts --- .../src/bin/epiphany-mvp-coordinator.rs | 49 ++----------------- epiphany-core/src/runtime_spine.rs | 42 ++++++---------- ...iphany.coordinator-run-receipt.schema.json | 30 +++++------- schemas/cultnet/index.json | 4 +- 4 files changed, 33 insertions(+), 92 deletions(-) diff --git a/epiphany-core/src/bin/epiphany-mvp-coordinator.rs b/epiphany-core/src/bin/epiphany-mvp-coordinator.rs index 4264ecf1..a7eb507a 100644 --- a/epiphany-core/src/bin/epiphany-mvp-coordinator.rs +++ b/epiphany-core/src/bin/epiphany-mvp-coordinator.rs @@ -246,6 +246,9 @@ impl Args { "coordinator requires exact --runtime-id for local Verse authority" )); } + if !matches!(parsed.mode.as_str(), "plan" | "execute") { + return Err(anyhow!("--mode must be plan or execute")); + } if parsed.required_action.is_some() && (parsed.mode != "execute" || parsed.max_steps != 1) { return Err(anyhow!( "--required-action requires execute mode with exactly one step" @@ -1324,7 +1327,6 @@ fn run_coordinator(args: &Args) -> Result { "coordinator-final-action.txt".to_string(), "agent-function-telemetry.json".to_string(), ]; - let sealed_artifact_manifest = Vec::new(); let receipt_created_at = now(); let coordinator_run_receipt = EpiphanyCoordinatorRunReceipt { schema_version: COORDINATOR_RUN_RECEIPT_SCHEMA_VERSION.to_string(), @@ -1339,30 +1341,7 @@ fn run_coordinator(args: &Args) -> Result { status: coordinator_receipt_status(&args.mode, &final_action), final_action: final_action_name(&final_action), final_reason: final_action_reason(&final_action), - step_count: operator_steps - .as_array() - .map_or(0, |items| items.len() as u64), created_at: receipt_created_at, - model_provider: Some(args.model_provider.clone()), - runtime_store: runtime_store.display().to_string(), - artifact_refs: artifact_manifest.clone(), - sealed_artifact_refs: sealed_artifact_manifest.clone(), - metadata: BTreeMap::from([ - ( - "artifactDir".to_string(), - artifact_dir.display().to_string(), - ), - ( - "modelRuntimeBin".to_string(), - model_runtime_bin.display().to_string(), - ), - ( - "toolAdapterBin".to_string(), - tool_adapter_bin.display().to_string(), - ), - ("mcpConfig".to_string(), mcp_config.display().to_string()), - ("autoTools".to_string(), args.auto_tools.to_string()), - ]), resident_grant_id: args.resident_binding.get("grant-id").cloned(), resident_launch_digest: args.resident_binding.get("launch-digest").cloned(), resident_policy_digest: args.resident_binding.get("policy-digest").cloned(), @@ -1374,7 +1353,6 @@ fn run_coordinator(args: &Args) -> Result { .get("release-manifest-digest") .cloned(), resident_executable_digest: args.resident_binding.get("executable-digest").cloned(), - final_runtime_job_id: final_action["runtimeJobId"].as_str().map(str::to_string), }; finalize_coordinator_run(&runtime_store, &coordinator_run_receipt)?; let summary = json!({ @@ -1401,7 +1379,6 @@ fn run_coordinator(args: &Args) -> Result { "store": runtime_store, }, "artifactManifest": artifact_manifest, - "sealedArtifactManifest": [] }); write_json(&artifact_dir.join("coordinator-summary.json"), &summary)?; write_json( @@ -1433,13 +1410,8 @@ fn run_coordinator(args: &Args) -> Result { match run_result { Ok(summary) => Ok(summary), Err(run_error) => { - let failure_receipt = failed_coordinator_run_receipt( - args, - &runtime_session_id, - &thread_id, - &runtime_store, - &run_error, - ); + let failure_receipt = + failed_coordinator_run_receipt(args, &runtime_session_id, &thread_id, &run_error); match finalize_coordinator_run(&runtime_store, &failure_receipt) { Ok(_) => Err(anyhow!( "coordinator run failed after opening and was terminalized by receipt {:?}: {run_error:#}", @@ -1457,7 +1429,6 @@ fn failed_coordinator_run_receipt( args: &Args, session_id: &str, thread_id: &str, - runtime_store: &Path, error: &anyhow::Error, ) -> EpiphanyCoordinatorRunReceipt { let created_at = now(); @@ -1474,16 +1445,7 @@ fn failed_coordinator_run_receipt( status: "failed".to_string(), final_action: "failed".to_string(), final_reason: Some(format!("{error:#}")), - step_count: 0, created_at, - model_provider: Some(args.model_provider.clone()), - runtime_store: runtime_store.display().to_string(), - artifact_refs: Vec::new(), - sealed_artifact_refs: Vec::new(), - metadata: BTreeMap::from([( - "terminalizationOwner".to_string(), - "epiphany-mvp-coordinator-error-boundary".to_string(), - )]), resident_grant_id: args.resident_binding.get("grant-id").cloned(), resident_launch_digest: args.resident_binding.get("launch-digest").cloned(), resident_policy_digest: args.resident_binding.get("policy-digest").cloned(), @@ -1495,7 +1457,6 @@ fn failed_coordinator_run_receipt( .get("release-manifest-digest") .cloned(), resident_executable_digest: args.resident_binding.get("executable-digest").cloned(), - final_runtime_job_id: None, } } diff --git a/epiphany-core/src/runtime_spine.rs b/epiphany-core/src/runtime_spine.rs index af2245c3..20949330 100644 --- a/epiphany-core/src/runtime_spine.rs +++ b/epiphany-core/src/runtime_spine.rs @@ -84,11 +84,11 @@ pub const ARCHIVED_RUNTIME_WORKER_ATTEMPT_TYPE: &str = pub const RUNTIME_ROLE_WORKER_RESULT_TYPE: &str = "epiphany.runtime.role_worker_result"; pub const RUNTIME_REORIENT_WORKER_RESULT_TYPE: &str = "epiphany.runtime.reorient_worker_result"; pub const RUNTIME_JOB_RESULT_TYPE: &str = "epiphany.runtime.job_result"; -pub const COORDINATOR_RUN_RECEIPT_TYPE: &str = "epiphany.coordinator_run_receipt.v0"; +pub const COORDINATOR_RUN_RECEIPT_TYPE: &str = "epiphany.coordinator_run_receipt.v1"; pub const RUNTIME_IDENTITY_KEY: &str = "self"; pub const RUNTIME_SWARM_BINDING_KEY: &str = "runtime-swarm-binding"; pub const RUNTIME_SWARM_BINDING_SCHEMA_VERSION: &str = "epiphany.runtime.swarm_binding.v1"; -pub const RUNTIME_SPINE_SCHEMA_VERSION: &str = "epiphany.runtime_spine.v19"; +pub const RUNTIME_SPINE_SCHEMA_VERSION: &str = "epiphany.runtime_spine.v20"; pub const EPIPHANY_RUNTIME_ROOT_SESSION_ID: &str = "epiphany-main"; pub const RUNTIME_MODEL_EXECUTION_BINDING_SCHEMA_VERSION: &str = "epiphany.runtime.model_execution_binding.v0"; @@ -105,7 +105,7 @@ pub const RUNTIME_ROLE_WORKER_RESULT_SCHEMA_VERSION: &str = "epiphany.runtime.role_worker_result.v4"; pub const RUNTIME_REORIENT_WORKER_RESULT_SCHEMA_VERSION: &str = "epiphany.runtime.reorient_worker_result.v0"; -pub const COORDINATOR_RUN_RECEIPT_SCHEMA_VERSION: &str = "epiphany.coordinator_run_receipt.v0"; +pub const COORDINATOR_RUN_RECEIPT_SCHEMA_VERSION: &str = "epiphany.coordinator_run_receipt.v1"; #[derive(Clone, Debug, PartialEq, DatabaseEntry)] #[cultcache(type = "epiphany.runtime.identity", schema = "EpiphanyRuntimeIdentity")] pub struct EpiphanyRuntimeIdentity { @@ -661,7 +661,7 @@ pub struct EpiphanyRuntimeJobResult { #[derive(Clone, Debug, PartialEq, DatabaseEntry)] #[cultcache( - type = "epiphany.coordinator_run_receipt.v0", + type = "epiphany.coordinator_run_receipt.v1", schema = "EpiphanyCoordinatorRunReceipt" )] pub struct EpiphanyCoordinatorRunReceipt { @@ -682,37 +682,23 @@ pub struct EpiphanyCoordinatorRunReceipt { #[cultcache(key = 7, default)] pub final_reason: Option, #[cultcache(key = 8)] - pub step_count: u64, - #[cultcache(key = 9)] pub created_at: String, - #[cultcache(key = 10, default)] - pub model_provider: Option, - #[cultcache(key = 11, default)] - pub runtime_store: String, - #[cultcache(key = 12, default)] - pub artifact_refs: Vec, - #[cultcache(key = 13, default)] - pub sealed_artifact_refs: Vec, - #[cultcache(key = 14, default)] - pub metadata: BTreeMap, - #[cultcache(key = 15, default)] + #[cultcache(key = 9, default)] pub resident_grant_id: Option, - #[cultcache(key = 16, default)] + #[cultcache(key = 10, default)] pub resident_launch_digest: Option, - #[cultcache(key = 17, default)] + #[cultcache(key = 11, default)] pub resident_policy_digest: Option, - #[cultcache(key = 18, default)] + #[cultcache(key = 12, default)] pub resident_argv_digest: Option, - #[cultcache(key = 19, default)] + #[cultcache(key = 13, default)] pub resident_objective_digest: Option, - #[cultcache(key = 20, default)] + #[cultcache(key = 14, default)] pub resident_release_commit: Option, - #[cultcache(key = 21, default)] + #[cultcache(key = 15, default)] pub resident_release_manifest_digest: Option, - #[cultcache(key = 22, default)] + #[cultcache(key = 16, default)] pub resident_executable_digest: Option, - #[cultcache(key = 23, default)] - pub final_runtime_job_id: Option, } #[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)] @@ -8511,7 +8497,9 @@ fn validate_coordinator_run_receipt(receipt: &EpiphanyCoordinatorRunReceipt) -> validate_non_empty(&receipt.receipt_id, "coordinator run receipt id")?; validate_non_empty(&receipt.session_id, "coordinator run receipt session id")?; validate_non_empty(&receipt.thread_id, "coordinator run receipt thread id")?; - validate_non_empty(&receipt.mode, "coordinator run receipt mode")?; + if !matches!(receipt.mode.as_str(), "plan" | "execute") { + return Err(anyhow!("coordinator run receipt mode is invalid")); + } validate_non_empty(&receipt.status, "coordinator run receipt status")?; validate_non_empty( &receipt.final_action, diff --git a/schemas/cultnet/epiphany.coordinator-run-receipt.schema.json b/schemas/cultnet/epiphany.coordinator-run-receipt.schema.json index 96a6155a..00f061b5 100644 --- a/schemas/cultnet/epiphany.coordinator-run-receipt.schema.json +++ b/schemas/cultnet/epiphany.coordinator-run-receipt.schema.json @@ -2,7 +2,7 @@ "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://gamecult.dev/epiphany/cultnet/epiphany.coordinator-run-receipt.schema.json", "title": "Epiphany Coordinator Run Receipt", - "description": "Typed receipt emitted by the local coordinator after a plan/run/smoke pass. Artifact JSON may display the same facts, but this document is the durable coordinator decision receipt.", + "description": "Typed terminal decision and exact resident-launch provenance emitted by the local coordinator. Operator artifacts remain non-authoritative projections.", "type": "object", "required": [ "schema_version", @@ -12,34 +12,26 @@ "mode", "status", "final_action", - "step_count", "created_at" ], "properties": { - "schema_version": { "const": "epiphany.coordinator_run_receipt.v0" }, + "schema_version": { "const": "epiphany.coordinator_run_receipt.v1" }, "receipt_id": { "type": "string" }, "session_id": { "type": "string" }, "thread_id": { "type": "string" }, - "mode": { "enum": ["plan", "run", "smoke", "status"] }, + "mode": { "enum": ["plan", "execute"] }, "status": { "type": "string" }, "final_action": { "type": "string" }, "final_reason": { "type": ["string", "null"] }, - "step_count": { "type": "integer", "minimum": 0 }, "created_at": { "type": "string" }, - "model_provider": { "type": ["string", "null"] }, - "runtime_store": { "type": "string" }, - "artifact_refs": { - "type": "array", - "items": { "type": "string" } - }, - "sealed_artifact_refs": { - "type": "array", - "items": { "type": "string" } - }, - "metadata": { - "type": "object", - "additionalProperties": { "type": "string" } - } + "resident_grant_id": { "type": ["string", "null"] }, + "resident_launch_digest": { "type": ["string", "null"] }, + "resident_policy_digest": { "type": ["string", "null"] }, + "resident_argv_digest": { "type": ["string", "null"] }, + "resident_objective_digest": { "type": ["string", "null"] }, + "resident_release_commit": { "type": ["string", "null"] }, + "resident_release_manifest_digest": { "type": ["string", "null"] }, + "resident_executable_digest": { "type": ["string", "null"] } }, "additionalProperties": false } diff --git a/schemas/cultnet/index.json b/schemas/cultnet/index.json index 1402d915..8c970c99 100644 --- a/schemas/cultnet/index.json +++ b/schemas/cultnet/index.json @@ -95,8 +95,8 @@ "wireContracts": [ "cultnet.schema.v0" ], - "schemaVersion": "epiphany.coordinator_run_receipt.v0", - "documentType": "epiphany.coordinator_run_receipt.v0", + "schemaVersion": "epiphany.coordinator_run_receipt.v1", + "documentType": "epiphany.coordinator_run_receipt.v1", "title": "Epiphany Coordinator Run Receipt", "path": "epiphany.coordinator-run-receipt.schema.json" },