diff --git a/notes/fresh-workspace-handoff.md b/notes/fresh-workspace-handoff.md index 6b9a0251..8e4213ea 100644 --- a/notes/fresh-workspace-handoff.md +++ b/notes/fresh-workspace-handoff.md @@ -361,9 +361,14 @@ bounded browser-fallback controls. A live bridge probe also proved `prepareCheckpoint` creates a resumable thread and a later process can `readModelingResult` from it. -The next real move is bridge construction, not another Aetheria implementation -dogfood run. The first Unity bridge is landed, and it correctly blocks Aetheria -runtime execution until Unity `6000.1.10f1` is installed. The detailed +The next real move is still bridge construction, not another Aetheria +implementation dogfood run. The pinned Unity bridge is landed, the clean +Aetheria branch `codex/epiphany-unity-editor-bridge` now contains the resident +`Assets/Editor/Epiphany/EpiphanyEditorBridge.cs` package, and +`tools/epiphany_unity_bridge.py` can detect that package and plan named +editor-resident probes/tests through +`GameCult.Epiphany.Unity.EpiphanyEditorBridge.RunProbe`. Runtime execution +still correctly blocks until Unity `6000.1.10f1` is installed. The detailed next-environment plan now lives in `notes/epiphany-rider-unity-integration-plan.md`: Rider is the IDE/source-context organ, Unity is the editor/runtime fact organ, and Epiphany @@ -372,9 +377,8 @@ three-pronged: Rider is the human code view for repo state, source tree, diffs, diagnostics, and code refs; Epiphany GUI is the agent dashboard for objectives, specialist lane state, logs/artifacts, persisted state, and graph/control-flow views; Unity is the pinned runtime environment for tests, probes, scene -configuration, assets, shaders, and play/edit-mode evidence. Build that plan in -slices before the next run: Aetheria-side resident Unity editor package, named -Unity bridge operations over that package, GUI Environment panel, +configuration, assets, shaders, and play/edit-mode evidence. Build the +remaining slices before the next run: GUI Environment panel, EpiphanyGraph-backed GUI graph dashboard, Rider context bridge, and Rider plugin MVP. The Unity package is not optional decoration: scene files, prefabs, materials, shaders, ScriptableObjects, asset GUIDs, and prefab overrides must be diff --git a/state/evidence.jsonl b/state/evidence.jsonl index 161c30df..e797ab97 100644 --- a/state/evidence.jsonl +++ b/state/evidence.jsonl @@ -54,3 +54,4 @@ {"ts": "2026-04-30T13:05:00+01:00", "type": "design", "status": "ok", "note": "Next-action priority amended: do not run another Aetheria implementation dogfood pass until the Rider and Unity bridges are in place. The next implementation slice is bridge construction first: named Unity operations, Aetheria-side Unity editor probes, GUI Environment panel, Rider context bridge, and Rider plugin MVP, so Epiphany can test hypotheses through IDE/source and editor/runtime evidence instead of repeating bridge-less supervision scars."} {"ts": "2026-04-30T13:28:00+01:00", "type": "design", "status": "ok", "note": "Documented the three-pronged development workflow: Rider is the human code view for repo state/source tree/diffs/diagnostics, Epiphany GUI is the agent dashboard for objectives, specialist lanes, logs/artifacts, persisted state, and graph/control-flow visualization, and Unity is the pinned runtime environment for tests, probes, scene configuration, assets, shaders, and play/edit-mode evidence. The adjacent EpiphanyGraph React viewer is now called out as the preferred seed for GUI graph diagramming because it consumes typed `graphs.architecture`, `graphs.dataflow`, and `graphs.links` directly."} {"ts": "2026-04-30T13:48:00+01:00", "type": "design", "status": "ok", "note": "Unity integration priority corrected: the CLI bridge is only the pinned transport; the first real Unity organ must be an Aetheria-side resident Editor package that inspects scenes, prefabs, serialized component fields, prefab overrides, materials, shaders, ScriptableObjects, asset GUIDs, and scene configuration through Unity APIs, then writes typed artifacts. Direct text parsing of `.unity` and `.prefab` files is not enough for meaningful hypothesis testing or safe refactoring; future mutation support must be narrow, previewed when feasible, explicitly reviewed, and artifact-backed."} +{"ts": "2026-04-30T14:01:37+00:00", "type": "implementation", "status": "ok", "note": "Resident Unity editor bridge slice landed: Aetheria branch codex/epiphany-unity-editor-bridge contains Assets/Editor/Epiphany/EpiphanyEditorBridge.cs for editor-resident project, compilation, scene, prefab, serialized-object, reference-search probes; Epiphany Unity bridge now detects that package and plans named probe/test commands with auditable artifact receipts while still blocking runtime execution until the exact Unity 6000.1.10f1 editor is installed."} diff --git a/state/map.yaml b/state/map.yaml index b9e1f789..753380bc 100644 --- a/state/map.yaml +++ b/state/map.yaml @@ -65,7 +65,7 @@ active_subgoals: - Keep the supervisor out of Epiphany worker thought streams: dogfood artifacts should be operator-safe by default, with direct transcripts and raw result payloads sealed. - Use `tools/epiphany_agent_telemetry.py` and generated `agent-function-telemetry.json` files to inspect behavior shape without opening sealed transcripts. - Treat repeated no-diff implementation turns as an MVP blocker, not success. A bounded implementation pass must leave a reviewable workspace diff or an explicit reviewable failure artifact before dogfood can be called healthy. - - Build the Rider and Unity bridges before the next Aetheria implementation dogfood run: Aetheria-side resident Unity editor package, named Unity bridge operations over that package, GUI Environment panel, Rider context bridge, and Rider plugin MVP. + - Build the Rider and Unity bridges before the next Aetheria implementation dogfood run: the Aetheria-side resident Unity editor package and named Unity bridge operation planner are now landed; next build the GUI Environment panel, EpiphanyGraph-backed GUI graph dashboard, Rider context bridge, and Rider plugin MVP. - Treat the target workflow as three integrated surfaces: Rider is the human code/diff view, Epiphany GUI is the agent dashboard and persisted-state graph view, and Unity is the pinned runtime/test/scene environment. - Use `notes/epiphany-rider-unity-integration-plan.md` as the source-grounded plan for Rider-as-IDE and Unity-as-editor/runtime integration seams. @@ -129,6 +129,7 @@ accepted_design: - Rider and Unity are environment organs, not sources of truth: Rider should expose IDE/source context, diagnostics, navigation, and changed ranges; Unity should expose pinned-editor runtime facts, compilation, tests, probes, assets, scenes, and logs; Epiphany remains the durable Self that coordinates, records, and reviews. - The product architecture is three-pronged: Rider is the code view for human inspection of repo state, source tree, diffs, diagnostics, and code refs; Epiphany GUI is the agent dashboard for objectives, specialist lane state, logs/artifacts, persisted typed state, and graph/control-flow views; Unity is the runtime environment for pinned tests, probes, scene configuration, assets, shaders, and play/edit-mode evidence. - Unity integration must be editor-resident, not text-archeology-only: scene files, prefabs, materials, shaders, ScriptableObjects, asset GUIDs, prefab overrides, and serialized component fields should be inspected through a Unity Editor package using Unity APIs, with narrow mutation preview/apply commands and artifact receipts. + - The first resident Unity editor package now lives in the Aetheria branch `codex/epiphany-unity-editor-bridge`: `Assets/Editor/Epiphany/EpiphanyEditorBridge.cs` exposes editor-resident inspect, compilation, scene, prefab, serialized-object, and reference-search probes with JSON/Markdown artifacts. Epiphany's Unity bridge detects that package and plans named probe/test commands through `GameCult.Epiphany.Unity.EpiphanyEditorBridge.RunProbe`, while runtime execution remains blocked until the exact project-pinned Unity editor is present. - The adjacent EpiphanyGraph React viewer is the preferred seed for GUI graph/control-flow diagramming because it consumes `graphs.architecture`, `graphs.dataflow`, and `graphs.links` directly and exposes node/edge/code-ref inspection with machine-readable graph data behind the visual layout. - If the agent's persistent instructions, memory, workflow, or state shape are making it less coherent, slower to rehydrate, less honest, or more likely to build Jenga, the agent should ask the user to change it. - Epiphany should make compaction less like death and more like sleep: bank the fire before the dark, so the next waking thing finds coals instead of ash and can meaningfully resume the pattern instead of merely continuing the task. @@ -193,4 +194,4 @@ rejected_paths: current_status: summary: Phase 1 durable state through Phase 6 GUI/coordinator/specialist/CRRC MVP surfaces are landed. The Aetheria supervised run found and fixed real harness wounds in coordinator policy, no-diff audits, stale job/result projection, and reorient acceptance. The Unity incident proved the next blocker is environment access, so `notes/epiphany-rider-unity-integration-plan.md` now governs a three-pronged bridge-building pass: Rider code view, Epiphany GUI agent dashboard, and Unity runtime environment, with Unity integration treated as a resident editor package rather than text-only file inspection. - next_action: Implement the three-pronged Rider/Epiphany GUI/Unity workflow before further Aetheria implementation dogfood: Aetheria-side resident Unity editor package, named Unity bridge operations over that package, GUI Environment panel, EpiphanyGraph-backed GUI graph dashboard, Rider context bridge, then Rider plugin MVP. The next dogfood run should happen only after Epiphany can gather Rider/source context and Unity/editor runtime evidence through auditable bridges. Do not let implementation workers invoke Unity directly or refactor Unity-owned serialized scene/prefab state as raw text when an editor API path exists; use bridge artifacts as evidence of either a pinned-editor run, runtime/editor facts, or a missing-runtime blocker. Do not inspect raw worker transcripts or `rawResult` payloads unless the user explicitly requests forensic debugging. + next_action: Continue the three-pronged Rider/Epiphany GUI/Unity workflow before further Aetheria implementation dogfood: the Aetheria resident Unity editor package and named Unity bridge operation planner are landed; next build the GUI Environment panel, EpiphanyGraph-backed GUI graph dashboard, Rider context bridge, then Rider plugin MVP. The next dogfood run should happen only after Epiphany can gather Rider/source context and Unity/editor runtime evidence through auditable bridges. Do not let implementation workers invoke Unity directly or refactor Unity-owned serialized scene/prefab state as raw text when an editor API path exists; use bridge artifacts as evidence of either a pinned-editor run, runtime/editor facts, or a missing-runtime blocker. Do not inspect raw worker transcripts or `rawResult` payloads unless the user explicitly requests forensic debugging. diff --git a/tools/epiphany_unity_bridge.py b/tools/epiphany_unity_bridge.py index a00a5432..008e7c78 100644 --- a/tools/epiphany_unity_bridge.py +++ b/tools/epiphany_unity_bridge.py @@ -15,7 +15,39 @@ ROOT = Path(__file__).resolve().parents[1] DEFAULT_ARTIFACT_ROOT = ROOT / ".epiphany-gui" / "runtime" PROJECT_VERSION_RELATIVE = Path("ProjectSettings") / "ProjectVersion.txt" UNITY_EDITOR_RELATIVE = Path("Editor") / "Unity.exe" -FORBIDDEN_EXTRA_ARGS = {"-batchmode", "-quit", "-projectpath"} +FORBIDDEN_EXTRA_ARGS = {"-batchmode", "-quit", "-projectpath", "-logfile"} +EDITOR_BRIDGE_RELATIVE = Path("Assets") / "Editor" / "Epiphany" / "EpiphanyEditorBridge.cs" +EDITOR_BRIDGE_EXECUTE_METHOD = "GameCult.Epiphany.Unity.EpiphanyEditorBridge.RunProbe" +NAMED_PROBE_OPERATIONS = { + "inspect-project": { + "description": "Capture Unity project/editor/build/render-pipeline facts.", + "expectedArtifacts": ["project-facts.json", "unity-probe-result.json", "unity-probe-result.md"], + }, + "check-compilation": { + "description": "Check whether the editor bridge can run after Unity script compilation.", + "expectedArtifacts": ["compilation.json", "unity-probe-result.json", "unity-probe-result.md"], + }, + "scene-facts": { + "description": "Capture scene hierarchy, components, prefab links, and serialized fields.", + "expectedArtifacts": ["scene-facts.json", "unity-probe-result.json", "unity-probe-result.md"], + }, + "prefab-facts": { + "description": "Capture prefab hierarchy, nested instances, overrides, and serialized fields.", + "expectedArtifacts": ["prefab-facts.json", "unity-probe-result.json", "unity-probe-result.md"], + }, + "serialized-object": { + "description": "Capture SerializedObject properties for one asset.", + "expectedArtifacts": [ + "serialized-object-facts.json", + "unity-probe-result.json", + "unity-probe-result.md", + ], + }, + "reference-search": { + "description": "Search Unity asset dependencies for references to a GUID or asset.", + "expectedArtifacts": ["reference-search.json", "unity-probe-result.json", "unity-probe-result.md"], + }, +} def now_iso() -> str: @@ -140,6 +172,7 @@ def resolve_unity_editor(project_path: Path) -> dict[str, Any]: "status": "missingProjectVersion", "note": "ProjectSettings/ProjectVersion.txt was not found or did not pin a Unity editor.", } + result["editorBridge"] = detect_editor_bridge(project_path) project_version = version.get("editorVersion") if not isinstance(project_version, str) or not project_version: return result @@ -165,6 +198,17 @@ def resolve_unity_editor(project_path: Path) -> dict[str, Any]: return result +def detect_editor_bridge(project_path: Path) -> dict[str, Any]: + package_path = project_path.resolve() / EDITOR_BRIDGE_RELATIVE + return { + "kind": "epiphanyUnityEditorBridge", + "path": str(package_path), + "relativePath": str(EDITOR_BRIDGE_RELATIVE).replace("\\", "/"), + "exists": package_path.exists(), + "executeMethod": EDITOR_BRIDGE_EXECUTE_METHOD, + } + + def render_inspection(summary: dict[str, Any]) -> str: installed = summary.get("installedEditors") if not isinstance(installed, list) or not installed: @@ -221,12 +265,17 @@ def validate_unity_args(values: list[str]) -> None: forbidden = sorted(lowered & FORBIDDEN_EXTRA_ARGS) if forbidden: raise ValueError( - "Unity bridge owns batchmode, quit, and projectPath; remove extra args: " + "Unity bridge owns batchmode, quit, projectPath, and logFile; remove extra args: " + ", ".join(forbidden) ) -def build_unity_command(summary: dict[str, Any], extra_args: list[str]) -> list[str]: +def build_unity_command( + summary: dict[str, Any], + extra_args: list[str], + *, + log_path: Path | None = None, +) -> list[str]: editor_path = summary.get("editorPath") if not isinstance(editor_path, str) or not editor_path: raise ValueError("Unity editor path is unavailable.") @@ -234,14 +283,66 @@ def build_unity_command(summary: dict[str, Any], extra_args: list[str]) -> list[ if not isinstance(project_path, str) or not project_path: raise ValueError("Unity project path is unavailable.") validate_unity_args(extra_args) - return [ + command = [ editor_path, "-batchmode", "-quit", "-projectPath", project_path, - *extra_args, ] + if log_path is not None: + command.extend(["-logFile", str(log_path)]) + command.extend(extra_args) + return command + + +def editor_bridge_ready(summary: dict[str, Any]) -> bool: + bridge = summary.get("editorBridge") + return isinstance(bridge, dict) and bridge.get("exists") is True + + +def named_probe_extra_args(args: argparse.Namespace, operation: str, directory: Path) -> list[str]: + extra_args = [ + "-executeMethod", + EDITOR_BRIDGE_EXECUTE_METHOD, + "-epiphanyArtifactDir", + str(directory), + "-epiphanyOperation", + operation, + ] + optional_values = [ + ("scene", "-epiphanyScene"), + ("asset", "-epiphanyAsset"), + ("guid", "-epiphanyGuid"), + ("max_objects", "-epiphanyMaxObjects"), + ("max_properties", "-epiphanyMaxProperties"), + ("max_dependencies", "-epiphanyMaxDependencies"), + ] + for attribute, flag in optional_values: + value = getattr(args, attribute, None) + if value is None: + continue + extra_args.extend([flag, str(value)]) + return extra_args + + +def write_command_artifact( + directory: Path, + *, + command: list[str], + dry_run: bool, + operation: str, + expected_artifacts: list[str] | None = None, +) -> None: + write_json( + directory / "unity-command.json", + { + "command": command, + "dryRun": dry_run, + "operation": operation, + "expectedArtifacts": expected_artifacts or [], + }, + ) def run_unity(args: argparse.Namespace) -> dict[str, Any]: @@ -263,13 +364,15 @@ def run_unity(args: argparse.Namespace) -> dict[str, Any]: write_inspection_artifacts(directory, summary) return summary - command = build_unity_command(summary, extra_args) + log_path = directory / "unity.log" + command = build_unity_command(summary, extra_args, log_path=log_path) summary["command"] = command + summary["logPath"] = str(log_path) if args.dry_run: summary["runStatus"] = "planned" summary["returncode"] = None write_inspection_artifacts(directory, summary) - write_json(directory / "unity-command.json", {"command": command, "dryRun": True}) + write_command_artifact(directory, command=command, dry_run=True, operation="run") return summary stdout_path = directory / "unity-stdout.log" @@ -315,7 +418,221 @@ def run_unity(args: argparse.Namespace) -> dict[str, Any]: ) write_inspection_artifacts(directory, summary) - write_json(directory / "unity-command.json", {"command": command, "dryRun": False}) + write_command_artifact(directory, command=command, dry_run=False, operation="run") + return summary + + +def run_named_probe(args: argparse.Namespace, operation: str) -> dict[str, Any]: + directory = ( + args.artifact_dir.resolve() + if args.artifact_dir + else artifact_dir(args.artifact_root, operation.replace("-", "_")) + ) + project_path = args.project_path.resolve() + summary = resolve_unity_editor(project_path) + summary["artifactPath"] = str(directory) + summary["operation"] = operation + summary["probe"] = NAMED_PROBE_OPERATIONS[operation] + + if summary.get("status") != "ready": + summary["runStatus"] = "blocked" + summary["note"] = ( + f"{summary.get('note')} Runtime/editor probe refused; install the exact pinned editor " + "or use inspect artifacts as evidence of the missing runtime." + ) + write_inspection_artifacts(directory, summary) + return summary + + if not editor_bridge_ready(summary): + bridge = summary.get("editorBridge") + bridge_path = bridge.get("path") if isinstance(bridge, dict) else str(project_path / EDITOR_BRIDGE_RELATIVE) + summary["status"] = "missingEditorBridgePackage" + summary["runStatus"] = "blocked" + summary["note"] = ( + "The Epiphany Unity editor package is missing. Add " + f"{bridge_path} before running editor-resident probes." + ) + write_inspection_artifacts(directory, summary) + return summary + + extra_args = named_probe_extra_args(args, operation, directory) + log_path = directory / "unity.log" + command = build_unity_command(summary, extra_args, log_path=log_path) + summary["command"] = command + summary["logPath"] = str(log_path) + expected_artifacts = NAMED_PROBE_OPERATIONS[operation]["expectedArtifacts"] + + if args.dry_run: + summary["runStatus"] = "planned" + summary["returncode"] = None + write_inspection_artifacts(directory, summary) + write_command_artifact( + directory, + command=command, + dry_run=True, + operation=operation, + expected_artifacts=expected_artifacts, + ) + return summary + + stdout_path = directory / "unity-stdout.log" + stderr_path = directory / "unity-stderr.log" + started = time.time() + try: + completed = subprocess.run( + command, + cwd=project_path, + capture_output=True, + check=False, + timeout=args.timeout_seconds, + ) + duration_seconds = time.time() - started + stdout_path.parent.mkdir(parents=True, exist_ok=True) + stdout_path.write_bytes(completed.stdout) + stderr_path.write_bytes(completed.stderr) + summary.update( + { + "runStatus": "passed" if completed.returncode == 0 else "failed", + "returncode": completed.returncode, + "durationSeconds": round(duration_seconds, 3), + "stdoutPath": str(stdout_path), + "stderrPath": str(stderr_path), + } + ) + except subprocess.TimeoutExpired as error: + duration_seconds = time.time() - started + stdout_path.parent.mkdir(parents=True, exist_ok=True) + if error.stdout: + stdout_path.write_bytes(error.stdout) + summary["stdoutPath"] = str(stdout_path) + if error.stderr: + stderr_path.write_bytes(error.stderr) + summary["stderrPath"] = str(stderr_path) + summary.update( + { + "runStatus": "timedOut", + "returncode": None, + "durationSeconds": round(duration_seconds, 3), + "note": f"Unity command timed out after {args.timeout_seconds} seconds.", + } + ) + + write_inspection_artifacts(directory, summary) + write_command_artifact( + directory, + command=command, + dry_run=False, + operation=operation, + expected_artifacts=expected_artifacts, + ) + return summary + + +def check_compilation(args: argparse.Namespace) -> dict[str, Any]: + return run_named_probe(args, "check-compilation") + + +def probe_unity(args: argparse.Namespace) -> dict[str, Any]: + return run_named_probe(args, args.operation) + + +def test_unity(args: argparse.Namespace) -> dict[str, Any]: + directory = args.artifact_dir.resolve() if args.artifact_dir else artifact_dir(args.artifact_root, "run_tests") + project_path = args.project_path.resolve() + summary = resolve_unity_editor(project_path) + summary["artifactPath"] = str(directory) + summary["operation"] = "run-tests" + summary["testPlatform"] = args.platform + summary["testFilter"] = args.filter + + if summary.get("status") != "ready": + summary["runStatus"] = "blocked" + summary["note"] = ( + f"{summary.get('note')} Unity tests refused; install the exact pinned editor " + "or use inspect artifacts as evidence of the missing runtime." + ) + write_inspection_artifacts(directory, summary) + return summary + + log_path = directory / "unity.log" + test_results = directory / "test-results.xml" + extra_args = [ + "-runTests", + "-testPlatform", + args.platform, + "-testResults", + str(test_results), + ] + if args.filter: + extra_args.extend(["-testFilter", args.filter]) + command = build_unity_command(summary, extra_args, log_path=log_path) + summary["command"] = command + summary["logPath"] = str(log_path) + summary["testResultsPath"] = str(test_results) + + if args.dry_run: + summary["runStatus"] = "planned" + summary["returncode"] = None + write_inspection_artifacts(directory, summary) + write_command_artifact( + directory, + command=command, + dry_run=True, + operation="run-tests", + expected_artifacts=["test-results.xml", "unity.log"], + ) + return summary + + stdout_path = directory / "unity-stdout.log" + stderr_path = directory / "unity-stderr.log" + started = time.time() + try: + completed = subprocess.run( + command, + cwd=project_path, + capture_output=True, + check=False, + timeout=args.timeout_seconds, + ) + duration_seconds = time.time() - started + stdout_path.parent.mkdir(parents=True, exist_ok=True) + stdout_path.write_bytes(completed.stdout) + stderr_path.write_bytes(completed.stderr) + summary.update( + { + "runStatus": "passed" if completed.returncode == 0 else "failed", + "returncode": completed.returncode, + "durationSeconds": round(duration_seconds, 3), + "stdoutPath": str(stdout_path), + "stderrPath": str(stderr_path), + } + ) + except subprocess.TimeoutExpired as error: + duration_seconds = time.time() - started + stdout_path.parent.mkdir(parents=True, exist_ok=True) + if error.stdout: + stdout_path.write_bytes(error.stdout) + summary["stdoutPath"] = str(stdout_path) + if error.stderr: + stderr_path.write_bytes(error.stderr) + summary["stderrPath"] = str(stderr_path) + summary.update( + { + "runStatus": "timedOut", + "returncode": None, + "durationSeconds": round(duration_seconds, 3), + "note": f"Unity test command timed out after {args.timeout_seconds} seconds.", + } + ) + + write_inspection_artifacts(directory, summary) + write_command_artifact( + directory, + command=command, + dry_run=False, + operation="run-tests", + expected_artifacts=["test-results.xml", "unity.log"], + ) return summary @@ -338,12 +655,24 @@ def bridge_guidance(project_path: Path, repo_root: Path | None = None) -> str: f"`python {script_path} inspect --project-path {project_path}`" ) if summary.get("status") == "ready": + if editor_bridge_ready(summary): + return ( + f"- Unity bridge: project pins {summary.get('projectVersion')} and the exact editor " + f"resolved to `{summary.get('editorPath')}`. If Unity execution is needed, use named " + f"bridge operations such as `python {script_path} probe --project-path {project_path} " + "--operation scene-facts --scene ` or " + f"`python {script_path} check-compilation --project-path {project_path}`. The bridge " + "owns -batchmode, -quit, -projectPath, -logFile, -executeMethod, and artifacts. Do not " + "invoke `Unity`, `Unity.exe`, default installs, or PATH-resolved editors directly, and " + "do not refactor Unity-owned scene/prefab state as raw text when the editor bridge can " + "inspect it." + ) return ( f"- Unity bridge: project pins {summary.get('projectVersion')} and the exact editor " - f"resolved to `{summary.get('editorPath')}`. If Unity execution is needed, use " - f"`python {script_path} run --project-path {project_path} -- -executeMethod `; " - "the bridge owns -batchmode, -quit, -projectPath, logs, and artifacts. Do not invoke " - "`Unity`, `Unity.exe`, default installs, or PATH-resolved editors directly." + f"resolved to `{summary.get('editorPath')}`, but the resident editor package is missing. " + f"Add `{EDITOR_BRIDGE_RELATIVE.as_posix()}` before claiming scene, prefab, or runtime " + "facts. Do not invoke `Unity`, `Unity.exe`, default installs, or PATH-resolved editors " + "directly." ) return ( f"- Unity bridge: {summary.get('note')} Run {inspect_command} to write an auditable " @@ -371,12 +700,59 @@ def main() -> int: run_parser.add_argument("--dry-run", action="store_true") run_parser.add_argument("unity_args", nargs=argparse.REMAINDER) + check_parser = subparsers.add_parser( + "check-compilation", + help="Run the resident editor bridge compilation probe.", + ) + check_parser.add_argument("--project-path", type=Path, default=Path.cwd()) + check_parser.add_argument("--artifact-root", type=Path, default=DEFAULT_ARTIFACT_ROOT) + check_parser.add_argument("--artifact-dir", type=Path) + check_parser.add_argument("--timeout-seconds", type=int, default=600) + check_parser.add_argument("--dry-run", action="store_true") + + probe_parser = subparsers.add_parser( + "probe", + help="Run a named resident-editor probe through the pinned editor.", + ) + probe_parser.add_argument("--project-path", type=Path, default=Path.cwd()) + probe_parser.add_argument("--artifact-root", type=Path, default=DEFAULT_ARTIFACT_ROOT) + probe_parser.add_argument("--artifact-dir", type=Path) + probe_parser.add_argument("--timeout-seconds", type=int, default=600) + probe_parser.add_argument("--dry-run", action="store_true") + probe_parser.add_argument("--operation", choices=sorted(NAMED_PROBE_OPERATIONS), required=True) + probe_parser.add_argument("--scene") + probe_parser.add_argument("--asset") + probe_parser.add_argument("--guid") + probe_parser.add_argument("--max-objects", type=int) + probe_parser.add_argument("--max-properties", type=int) + probe_parser.add_argument("--max-dependencies", type=int) + + test_parser = subparsers.add_parser( + "run-tests", + help="Run Unity editmode/playmode tests through the pinned editor.", + ) + test_parser.add_argument("--project-path", type=Path, default=Path.cwd()) + test_parser.add_argument("--artifact-root", type=Path, default=DEFAULT_ARTIFACT_ROOT) + test_parser.add_argument("--artifact-dir", type=Path) + test_parser.add_argument("--timeout-seconds", type=int, default=900) + test_parser.add_argument("--dry-run", action="store_true") + test_parser.add_argument("--platform", choices=["editmode", "playmode"], default="editmode") + test_parser.add_argument("--filter") + args = parser.parse_args() try: if args.command == "inspect": result = inspect_unity(args) - else: + elif args.command == "run": result = run_unity(args) + elif args.command == "check-compilation": + result = check_compilation(args) + elif args.command == "probe": + result = probe_unity(args) + elif args.command == "run-tests": + result = test_unity(args) + else: + raise ValueError(f"Unsupported command: {args.command}") except Exception as error: print(json.dumps({"status": "error", "error": str(error)}, indent=2), flush=True) return 1 diff --git a/tools/epiphany_unity_bridge_smoke.py b/tools/epiphany_unity_bridge_smoke.py index bd234044..3de79dd8 100644 --- a/tools/epiphany_unity_bridge_smoke.py +++ b/tools/epiphany_unity_bridge_smoke.py @@ -25,7 +25,7 @@ def reset_path(path: Path) -> None: path.mkdir(parents=True, exist_ok=True) -def prepare_project(workspace: Path) -> None: +def prepare_project(workspace: Path, *, include_bridge: bool = False) -> None: reset_path(workspace) settings = workspace / "ProjectSettings" settings.mkdir(parents=True, exist_ok=True) @@ -39,6 +39,10 @@ def prepare_project(workspace: Path) -> None: ), encoding="utf-8", ) + if include_bridge: + bridge = workspace / "Assets" / "Editor" / "Epiphany" / "EpiphanyEditorBridge.cs" + bridge.parent.mkdir(parents=True, exist_ok=True) + bridge.write_text("// smoke marker for resident Epiphany editor bridge\n", encoding="utf-8") def create_fake_editor(root: Path, version: str) -> Path: @@ -94,6 +98,17 @@ def require_artifact(summary: dict[str, Any], name: str) -> None: require((artifact_path / name).exists(), f"missing bridge artifact: {name}") +def read_command_artifact(summary: dict[str, Any]) -> dict[str, Any]: + artifact_path = Path(str(summary["artifactPath"])) + command_path = artifact_path / "unity-command.json" + require(command_path.exists(), "missing unity-command.json") + return json.loads(command_path.read_text(encoding="utf-8")) + + +def require_command_contains(command: list[str], value: str) -> None: + require(value in command, f"command should contain {value!r}: {command}") + + def main() -> int: workspace = DEFAULT_WORKSPACE.resolve() artifact_root = DEFAULT_ARTIFACT_ROOT.resolve() @@ -127,6 +142,7 @@ def main() -> int: ) require(ready["status"] == "ready", "exact editor should satisfy pin") require(ready["editorPath"] == str(exact_editor), "inspection should resolve exact editor") + require(ready["editorBridge"]["exists"] is False, "fresh smoke project should not have bridge package yet") planned = run_bridge( workspace, @@ -138,13 +154,107 @@ def main() -> int: require(planned["runStatus"] == "planned", "dry run should plan instead of executing") command = planned["command"] require(command[0] == str(exact_editor), "command should use exact editor path") - require("-batchmode" in command, "bridge should own -batchmode") - require("-quit" in command, "bridge should own -quit") - require("-projectPath" in command, "bridge should own -projectPath") - require(str(workspace) in command, "command should target the requested project") + require_command_contains(command, "-batchmode") + require_command_contains(command, "-quit") + require_command_contains(command, "-projectPath") + require_command_contains(command, "-logFile") + require_command_contains(command, str(workspace)) require(str(wrong_editor) not in command, "command must not use wrong editor") require_artifact(planned, "unity-command.json") + missing_package = run_bridge( + workspace, + artifact_root, + roots=fake_roots, + args=[ + "probe", + "--dry-run", + "--operation", + "scene-facts", + "--scene", + "Assets/Scenes/Main.unity", + ], + expect_success=False, + ) + require( + missing_package["status"] == "missingEditorBridgePackage", + "named probes should require the resident editor package", + ) + require(missing_package["runStatus"] == "blocked", "missing package probe should be blocked") + + prepare_project(workspace, include_bridge=True) + bridged = run_bridge( + workspace, + artifact_root, + roots=fake_roots, + args=["inspect"], + ) + require(bridged["status"] == "ready", "bridge project should still resolve exact editor") + require(bridged["editorBridge"]["exists"] is True, "resident editor bridge should be detected") + + scene_probe = run_bridge( + workspace, + artifact_root, + roots=fake_roots, + args=[ + "probe", + "--dry-run", + "--operation", + "scene-facts", + "--scene", + "Assets/Scenes/Main.unity", + "--max-objects", + "25", + "--max-properties", + "12", + ], + ) + require(scene_probe["runStatus"] == "planned", "scene probe should plan under dry run") + scene_command = scene_probe["command"] + require(scene_command[0] == str(exact_editor), "scene probe should use exact editor path") + require_command_contains(scene_command, "-executeMethod") + require_command_contains(scene_command, "GameCult.Epiphany.Unity.EpiphanyEditorBridge.RunProbe") + require_command_contains(scene_command, "-epiphanyArtifactDir") + require_command_contains(scene_command, str(Path(str(scene_probe["artifactPath"])))) + require_command_contains(scene_command, "-epiphanyOperation") + require_command_contains(scene_command, "scene-facts") + require_command_contains(scene_command, "-epiphanyScene") + require_command_contains(scene_command, "Assets/Scenes/Main.unity") + require_command_contains(scene_command, "-epiphanyMaxObjects") + require_command_contains(scene_command, "25") + scene_artifact = read_command_artifact(scene_probe) + require(scene_artifact["operation"] == "scene-facts", "scene command artifact should name operation") + require("scene-facts.json" in scene_artifact["expectedArtifacts"], "scene facts artifact should be expected") + + compilation = run_bridge( + workspace, + artifact_root, + roots=fake_roots, + args=["check-compilation", "--dry-run"], + ) + require(compilation["runStatus"] == "planned", "compilation probe should plan under dry run") + compilation_artifact = read_command_artifact(compilation) + require( + "compilation.json" in compilation_artifact["expectedArtifacts"], + "compilation artifact should be expected", + ) + + tests = run_bridge( + workspace, + artifact_root, + roots=fake_roots, + args=["run-tests", "--dry-run", "--platform", "editmode", "--filter", "SmokeSuite"], + ) + require(tests["runStatus"] == "planned", "Unity test run should plan under dry run") + test_command = tests["command"] + require_command_contains(test_command, "-runTests") + require_command_contains(test_command, "-testPlatform") + require_command_contains(test_command, "editmode") + require_command_contains(test_command, "-testFilter") + require_command_contains(test_command, "SmokeSuite") + tests_artifact = read_command_artifact(tests) + require("test-results.xml" in tests_artifact["expectedArtifacts"], "test results should be expected") + blocked = run_bridge( workspace, artifact_root, @@ -160,6 +270,9 @@ def main() -> int: "missingStatus": missing["status"], "readyStatus": ready["status"], "plannedStatus": planned["runStatus"], + "missingPackageStatus": missing_package["status"], + "sceneProbeStatus": scene_probe["runStatus"], + "testStatus": tests["runStatus"], "blockedStatus": blocked["runStatus"], "resolvedEditor": ready["editorPath"], }