Separate daemon build from launch

This commit is contained in:
Meta Vens 2026-07-21 23:53:37 +01:00
commit 2d5180534b
3 changed files with 72 additions and 37 deletions

View file

@ -1357,14 +1357,19 @@ static void RequireClientTransportPlaneOwnership(string root)
"Aetheria editor reimport does not reset every daemon-private Ymir state path: " +
string.Join(", ", missingEditorResetSymbols));
if (editorLauncher.Contains("Start-Process", StringComparison.Ordinal) ||
!editorController.Contains("Process.Start(new ProcessStartInfo(DaemonExePath, arguments)", StringComparison.Ordinal) ||
!editorController.Contains("public static void Start()", StringComparison.Ordinal) ||
!editorController.Contains("public static void Build(bool forceImport = false)", StringComparison.Ordinal) ||
!editorController.Contains("Process.Start(startInfo)", StringComparison.Ordinal) ||
!editorController.Contains("new ProcessStartInfo(DotNetExePath, arguments)", StringComparison.Ordinal) ||
!editorController.Contains("DOTNET_ROOT", StringComparison.Ordinal) ||
!editorController.Contains("_status = \"Debug daemon prepared\"", StringComparison.Ordinal) ||
!editorController.Contains("SessionState.SetInt(ProcessIdSessionKey, daemon.Id)", StringComparison.Ordinal) ||
editorController.Contains("playModeStateChanged", StringComparison.Ordinal) ||
editorController.Contains("_enterPlayWhenReady", StringComparison.Ordinal) ||
editorController.Contains("Start & Play", StringComparison.Ordinal) ||
editorController.Contains("Start before Play", StringComparison.Ordinal))
throw new InvalidOperationException(
"The daemon window must directly own its process without coupling build, launch, or shutdown to Unity Play lifecycle.");
"The daemon window must independently build and launch through the system .NET host without coupling either operation to Unity Play lifecycle.");
Console.WriteLine("Client transport ownership: Ymir restores before transport listen; the daemon window owns an independent prepared Debug daemon and matching private state");
}

View file

@ -90,7 +90,8 @@ namespace Aetheria.Editor
using (new EditorGUILayout.HorizontalScope())
{
GUI.enabled = !AetheriaDaemonDevelopmentController.IsStarting &&
!AetheriaDaemonDevelopmentController.IsRunning;
!AetheriaDaemonDevelopmentController.IsRunning &&
AetheriaDaemonDevelopmentController.IsPrepared;
if (GUILayout.Button("Start daemon"))
AetheriaDaemonDevelopmentController.Start();
GUI.enabled = AetheriaDaemonDevelopmentController.IsRunning ||
@ -102,13 +103,16 @@ namespace Aetheria.Editor
using (new EditorGUILayout.HorizontalScope())
{
GUI.enabled = AetheriaDaemonDevelopmentController.IsRunning;
GUI.enabled = AetheriaDaemonDevelopmentController.IsRunning &&
!AetheriaDaemonDevelopmentController.IsStarting;
if (GUILayout.Button("Restart"))
AetheriaDaemonDevelopmentController.Restart();
GUI.enabled = !AetheriaDaemonDevelopmentController.IsRunning &&
!AetheriaDaemonDevelopmentController.IsStarting;
if (GUILayout.Button("Reimport state & start"))
AetheriaDaemonDevelopmentController.Start(forceImport: true);
if (GUILayout.Button("Build daemon"))
AetheriaDaemonDevelopmentController.Build();
if (GUILayout.Button("Reimport state & build"))
AetheriaDaemonDevelopmentController.Build(forceImport: true);
GUI.enabled = true;
}
@ -184,6 +188,7 @@ namespace Aetheria.Editor
public static bool IsRunning => TryRefreshDaemon();
public static bool IsStarting => _launcher != null && !_launcher.HasExited;
public static bool IsPrepared => File.Exists(DaemonDllPath) && File.Exists(DotNetExePath);
public static string Status => _status;
public static string LastError => _lastError;
public static string Endpoint => $"cultnet+tcp://127.0.0.1:{Port}";
@ -200,10 +205,12 @@ namespace Aetheria.Editor
private static string ErrorLogPath => Path.Combine(ArtifactsRoot, "daemon.error.log");
private static string LauncherLogPath => Path.Combine(ArtifactsRoot, "launcher.log");
private static string LauncherErrorPath => Path.Combine(ArtifactsRoot, "launcher.error.log");
private static string DaemonExePath => Path.Combine(
ProjectRoot, "Aetheria.State.Daemon", "bin", "Debug", "net10.0", "Aetheria.State.Daemon.exe");
private static string DaemonDllPath => Path.Combine(
ProjectRoot, "Aetheria.State.Daemon", "bin", "Debug", "net10.0", "Aetheria.State.Daemon.dll");
private static string DotNetExePath => Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "dotnet", "dotnet.exe");
public static void Start(bool forceImport = false)
public static void Start()
{
if (TryRefreshDaemon())
{
@ -213,8 +220,27 @@ namespace Aetheria.Editor
if (IsStarting)
return;
try
{
LaunchDaemon();
}
catch (Exception exception)
{
_lastError = exception.ToString();
_status = "Daemon launch failed";
Changed?.Invoke();
}
}
public static void Build(bool forceImport = false)
{
if (TryRefreshDaemon() || IsStarting)
return;
Directory.CreateDirectory(ArtifactsRoot);
File.Delete(PidPath);
File.WriteAllText(LauncherLogPath, "");
File.WriteAllText(LauncherErrorPath, "");
_lastError = "";
ApplyClientEnvironment();
@ -322,17 +348,8 @@ namespace Aetheria.Editor
}
if (exitCode == 0 && !TryRefreshDaemon())
{
try
{
LaunchDaemon();
}
catch (Exception exception)
{
_lastError = exception.ToString();
_status = "Daemon launch failed";
Changed?.Invoke();
return;
}
_status = "Debug daemon prepared";
Changed?.Invoke();
}
}
@ -519,26 +536,32 @@ namespace Aetheria.Editor
private static void LaunchDaemon()
{
if (!File.Exists(DaemonExePath))
throw new FileNotFoundException("Prepared Aetheria Debug daemon is missing.", DaemonExePath);
if (!File.Exists(DaemonDllPath))
throw new FileNotFoundException("Prepared Aetheria Debug daemon is missing. Use Build daemon first.", DaemonDllPath);
if (!File.Exists(DotNetExePath))
throw new FileNotFoundException("The system .NET host required by the Aetheria daemon is missing.", DotNetExePath);
File.WriteAllText(LogPath, "");
File.WriteAllText(ErrorLogPath, "");
var arguments =
$"--root {Quote(ProjectRoot)} " +
$"{Quote(DaemonDllPath)} --root {Quote(ProjectRoot)} " +
$"--state {Quote(StatePath)} " +
"--client-cultmesh-host 127.0.0.1 " +
"--client-cultmesh-advertise-host 127.0.0.1 " +
$"--client-cultmesh-port {Port} " +
"--tick-interval-ms 20 --fixed-delta-ms 20 --no-odin-announcements";
var daemon = Process.Start(new ProcessStartInfo(DaemonExePath, arguments)
var startInfo = new ProcessStartInfo(DotNetExePath, arguments)
{
WorkingDirectory = ProjectRoot,
UseShellExecute = false,
CreateNoWindow = true,
RedirectStandardOutput = true,
RedirectStandardError = true
}) ?? throw new InvalidOperationException("Aetheria Debug daemon process did not start.");
};
startInfo.EnvironmentVariables["DOTNET_ROOT"] = Path.GetDirectoryName(DotNetExePath);
startInfo.EnvironmentVariables.Remove("DOTNET_HOST_PATH");
var daemon = Process.Start(startInfo) ??
throw new InvalidOperationException("Aetheria Debug daemon process did not start.");
daemon.EnableRaisingEvents = true;
daemon.Exited += (_, __) =>
{

View file

@ -4,12 +4,17 @@ Open `Aetheria.Unity` in Unity and choose **Aetheria > Daemon Development**.
This is the interactive development path. The released-package witness remains
the automated integration proof and is not required for ordinary iteration.
The window synchronously builds `Aetheria.State.Daemon` in
`bin/Debug/net10.0` and imports an isolated development state under
`Aetheria.Unity/Build` when necessary. After preparation succeeds, the Unity
editor directly launches and owns the daemon process, its PID, and its output
streams. The generic EveUnity client connects directly to the daemon's local
CultMesh endpoint. Odin is not part of this path.
**Build daemon** explicitly builds `Aetheria.State.Daemon` in
`bin/Debug/net10.0`. **Reimport state & build** also replaces the isolated
development state under `Aetheria.Unity/Build`. **Start daemon** launches the
already-prepared DLL immediately; it never performs a build. The editor owns
the daemon process, its PID, and its output streams. The generic EveUnity
client connects directly to the daemon's local CultMesh endpoint. Odin is not
part of this path.
The daemon is launched by the installed system .NET host rather than Unity's
embedded runtime environment. This keeps .NET 10 host resolution deterministic
and preserves managed startup and error output in the daemon logs.
The daemon lifecycle is independent of Unity Play Mode. Play never builds,
starts, restarts, or stops the daemon. Entering Play connects a generic client;
@ -31,15 +36,17 @@ being debugged.
## Normal loop
1. Press **Start daemon** and wait for the window to report the live endpoint.
2. Enter and leave Unity Play Mode normally. The daemon remains running across
1. Press **Build daemon** after changing daemon code. Use **Reimport state &
build** only when the isolated development state must be replaced.
2. Press **Start daemon** and wait for the window to report the live endpoint.
3. Enter and leave Unity Play Mode normally. The daemon remains running across
client sessions.
3. Edit and inspect the generic EveUnity-lowered world in Play Mode.
4. Use Unity Pause to submit the advertised `simulation.pause` action to the
4. Edit and inspect the generic EveUnity-lowered world in Play Mode.
5. Use Unity Pause to submit the advertised `simulation.pause` action to the
daemon. Unity unpause submits `simulation.rate.realtime`.
5. While paused, use **Advance one step** to commit exactly one fixed daemon
6. While paused, use **Advance one step** to commit exactly one fixed daemon
simulation step.
6. Stop, restart, or reimport the isolated state explicitly from the same
7. Stop or restart the daemon explicitly from the same
window.
Unity's editor clock is never gameplay authority. The pause and step controls