From 559a6b97fd3e2a5ae742567dafa62faf41fd61a5 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Thu, 30 Apr 2026 12:43:56 +0100 Subject: [PATCH] Add pinned Unity runtime bridge --- apps/epiphany-gui/README.md | 4 + apps/epiphany-gui/src-tauri/src/lib.rs | 72 ++++ apps/epiphany-gui/src/App.tsx | 39 ++- apps/epiphany-gui/src/types.ts | 7 + notes/epiphany-fork-implementation-plan.md | 38 +- notes/fresh-workspace-handoff.md | 35 +- state/evidence.jsonl | 1 + state/map.yaml | 10 +- tools/epiphany_gui_action.py | 58 +-- tools/epiphany_unity_bridge.py | 388 +++++++++++++++++++++ tools/epiphany_unity_bridge_smoke.py | 173 +++++++++ 11 files changed, 731 insertions(+), 94 deletions(-) create mode 100644 tools/epiphany_unity_bridge.py create mode 100644 tools/epiphany_unity_bridge_smoke.py diff --git a/apps/epiphany-gui/README.md b/apps/epiphany-gui/README.md index d60af839..e1eaadf5 100644 --- a/apps/epiphany-gui/README.md +++ b/apps/epiphany-gui/README.md @@ -14,6 +14,8 @@ Current slice: lanes, role findings, jobs, and artifact bundles - writes explicit status-snapshot and coordinator-plan artifact bundles through bounded operator buttons +- resolves project-pinned Unity editors through the runtime bridge and writes + audit artifacts instead of letting workers launch PATH/default editors - prepares durable Epiphany checkpoint state, then launches and reads the fixed modeling, verification, and reorient lanes from GUI buttons, with reorient acceptance kept explicit and review-gated @@ -52,6 +54,8 @@ The bounded buttons are intentionally narrow: `.epiphany-gui/status-snapshots`. - **Coordinator Plan** runs `tools/epiphany_mvp_coordinator.py --mode plan` and writes an auditable bundle under `.epiphany-dogfood`. +- **Inspect Unity** runs `tools/epiphany_unity_bridge.py inspect` and writes a + pinned-editor inspection bundle under `.epiphany-gui/runtime`. - **Prepare Checkpoint** seeds durable Epiphany state for a GUI operator thread and returns the persisted thread id that unlocks lane actions. - **Launch/Read Modeling** and **Launch/Read Verification** call the fixed role diff --git a/apps/epiphany-gui/src-tauri/src/lib.rs b/apps/epiphany-gui/src-tauri/src/lib.rs index 27da1cf2..b4097d88 100644 --- a/apps/epiphany-gui/src-tauri/src/lib.rs +++ b/apps/epiphany-gui/src-tauri/src/lib.rs @@ -33,6 +33,7 @@ struct ArtifactBundle { final_status_path: Option, comparison_path: Option, implementation_audit: Option, + runtime_audit: Option, modified_millis: Option, } @@ -45,6 +46,15 @@ struct ImplementationAudit { changed_files: Vec, } +#[derive(Debug, Serialize)] +#[serde(rename_all = "camelCase")] +struct RuntimeAudit { + result_path: String, + status: String, + project_version: Option, + editor_path: Option, +} + #[derive(Debug, Serialize)] #[serde(rename_all = "camelCase")] struct OperatorSnapshot { @@ -77,6 +87,7 @@ fn run_operator_action( match action.as_str() { "statusSnapshot" => run_status_snapshot(&repo_root, request), "coordinatorPlan" => run_coordinator_plan(&repo_root, request), + "inspectUnity" => run_unity_inspection(&repo_root, request), "launchModeling" | "readModelingResult" | "acceptModeling" @@ -92,6 +103,39 @@ fn run_operator_action( } } +fn run_unity_inspection( + repo_root: &Path, + request: StatusRequest, +) -> Result { + let python = find_python()?; + let artifact_root = repo_root.join(".epiphany-gui").join("runtime"); + let workspace = request + .cwd + .map(PathBuf::from) + .unwrap_or_else(|| repo_root.to_path_buf()); + + let mut command = Command::new(python); + command + .current_dir(repo_root) + .arg(repo_root.join("tools").join("epiphany_unity_bridge.py")) + .arg("inspect") + .arg("--project-path") + .arg(workspace) + .arg("--artifact-root") + .arg(artifact_root); + let value = run_json_command(command, "unity inspection")?; + let status = value + .get("status") + .and_then(Value::as_str) + .unwrap_or("unknown"); + Ok(OperatorActionResult { + action: "inspectUnity".to_string(), + artifact_path: json_string(&value, "artifactPath")?, + summary: format!("Unity bridge inspection: {status}."), + thread_id: None, + }) +} + fn load_status(repo_root: &Path, request: StatusRequest) -> Result { let python = find_python()?; let status_script = repo_root.join("tools").join("epiphany_mvp_status.py"); @@ -338,6 +382,11 @@ fn list_artifacts(repo_root: &Path) -> Result, String> { &repo_root.join(".epiphany-gui").join("status-snapshots"), "status/", )?; + collect_artifact_root( + &mut bundles, + &repo_root.join(".epiphany-gui").join("runtime"), + "runtime/", + )?; bundles.sort_by(|a, b| b.modified_millis.cmp(&a.modified_millis)); Ok(bundles) @@ -379,11 +428,13 @@ fn collect_artifact_root( path: path.display().to_string(), summary_path: existing_path(&path, "epiphany-dogfood-summary.json") .or_else(|| existing_path(&path, "gui-action-summary.json")) + .or_else(|| existing_path(&path, "unity-bridge-summary.json")) .or_else(|| existing_path(&path, "status.json")), final_status_path: existing_path(&path, "epiphany-final-status.json") .or_else(|| existing_path(&path, "after-status.json")), comparison_path: existing_path(&path, "comparison.md"), implementation_audit: read_implementation_audit(&path), + runtime_audit: read_runtime_audit(&path), files, modified_millis, }); @@ -392,6 +443,27 @@ fn collect_artifact_root( Ok(()) } +fn read_runtime_audit(root: &Path) -> Option { + let result_path = root.join("unity-bridge-summary.json"); + let text = fs::read_to_string(&result_path).ok()?; + let value: Value = serde_json::from_str(&text).ok()?; + let status = value.get("status").and_then(Value::as_str)?.to_string(); + let project_version = value + .get("projectVersion") + .and_then(Value::as_str) + .map(ToString::to_string); + let editor_path = value + .get("editorPath") + .and_then(Value::as_str) + .map(ToString::to_string); + Some(RuntimeAudit { + result_path: result_path.display().to_string(), + status, + project_version, + editor_path, + }) +} + fn existing_path(root: &Path, name: &str) -> Option { let path = root.join(name); path.exists().then(|| path.display().to_string()) diff --git a/apps/epiphany-gui/src/App.tsx b/apps/epiphany-gui/src/App.tsx index 964e70dc..928b71b5 100644 --- a/apps/epiphany-gui/src/App.tsx +++ b/apps/epiphany-gui/src/App.tsx @@ -26,7 +26,7 @@ const actionButtons: Array<{ requiresVerificationResult?: boolean; requiresReorientResult?: boolean; requiresContinueImplementation?: boolean; - icon: "file" | "check" | "play" | "eye" | "accept"; + icon: "file" | "check" | "play" | "eye" | "accept" | "runtime"; }> = [ { action: "statusSnapshot", @@ -42,6 +42,13 @@ const actionButtons: Array<{ title: "Run a review-gated coordinator plan", icon: "check", }, + { + action: "inspectUnity", + label: "Inspect Unity", + runningLabel: "Inspecting", + title: "Resolve the project-pinned Unity editor and write runtime artifacts", + icon: "runtime", + }, { action: "prepareCheckpoint", label: "Prepare Checkpoint", @@ -247,6 +254,11 @@ export function App() { [snapshot?.artifacts], ); const latestImplementationAudit = latestImplementationArtifact?.implementationAudit; + const latestRuntimeArtifact = useMemo( + () => (snapshot?.artifacts ?? []).find((artifact) => artifact.runtimeAudit), + [snapshot?.artifacts], + ); + const latestRuntimeAudit = latestRuntimeArtifact?.runtimeAudit; const implementationNoDiffPending = Boolean(latestArtifact?.implementationAudit) && latestArtifact?.implementationAudit?.workspaceChanged === false; const readyState = scene.stateStatus === "ready"; @@ -367,6 +379,20 @@ export function App() { )} + {latestRuntimeAudit && ( +
+ {latestRuntimeAudit.status === "ready" ? ( +
+ )} +
}>
@@ -477,11 +503,12 @@ function SectionHeader({ title, icon }: { title: string; icon: React.ReactNode } ); } -function ActionIcon({ icon }: { icon: "file" | "check" | "play" | "eye" | "accept" }) { +function ActionIcon({ icon }: { icon: "file" | "check" | "play" | "eye" | "accept" | "runtime" }) { if (icon === "file") return