refactor(server): unify first-boot prompts into the ConfigurePrompts phase

Move the engine's own first-boot prompts (data directories, listeners, server
name, expansion + map selection) out of ServerConfiguration.Load and into
ServerConfiguration.ConfigurePrompts() [CallPriority(0)], so all first-boot
prompting -- engine and content -- runs through the single
AssemblyHandler.Invoke("ConfigurePrompts") phase. Load now only reads/creates
the config file.

- Feasible because assembly loading uses AssemblyDirectories (default
  ./Assemblies), not DataDirectories, so assemblies load before the now-later
  data-dir prompt.
- UOClient.Load() (client-file discovery) moves with the data-dir prompt.
- Core.Expansion is now assigned in ConfigurePrompts (every non-mocked boot);
  nothing between LoadAssemblies and that phase reads it (type initializers run
  lazily, not at load).
- CallPriority(0) keeps engine prompts (incl. map selection) ahead of content
  prompts like the pathfinding pre-bake (priority 50).

Main.cs already invokes the ConfigurePrompts phase, so no startup-ordering edit.
Tests are unaffected: fixtures call Load(true), which now just reads config, and
set expansion/data dirs directly; ConfigurePrompts is gated on m_Mocked.
Updates dev-docs/server-lifecycle.md to reflect the unified design.

NOTE: Main.cs startup ordering isn't covered by the fixture-based test suite, so
this needs a first-boot runtime check (fresh modernuo.json) before merge.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Kamron Batman 2026-06-07 16:27:14 -07:00
parent 16bf3016fb
commit 5df8d0bdae
2 changed files with 35 additions and 17 deletions

View file

@ -218,11 +218,13 @@ public static class ServerConfiguration
Save();
}
// If mock is enabled we skip the console readline.
// Reads (or creates) the configuration file. The interactive first-boot prompts live in
// ConfigurePrompts (run later via AssemblyHandler.Invoke("ConfigurePrompts")) so all
// first-boot prompting — engine and content — shares one phase/wiring. mocked skips prompts
// entirely (ConfigurePrompts is gated on m_Mocked and isn't invoked by the test fixtures).
public static void Load(bool mocked = false)
{
m_Mocked = mocked;
var updated = false;
if (File.Exists(m_FilePath))
{
@ -239,15 +241,27 @@ public static class ServerConfiguration
}
else
{
updated = true;
_settings = new ServerSettings();
}
}
if (mocked)
// First-boot interactive configuration, discovered + run by AssemblyHandler.Invoke(
// "ConfigurePrompts") after assemblies load but before Serilog's first log line, so the
// console prompts are not interleaved with the async console sink (see
// dev-docs/server-lifecycle.md). CallPriority(0) so the engine's own prompts (data dirs,
// listeners, server name, expansion + map selection) run before any content ConfigurePrompts
// that build on them (e.g. map selection before a pathfinding pre-bake prompt). Also resolves
// Core.Expansion on every non-mocked boot.
[CallPriority(0)]
public static void ConfigurePrompts()
{
if (m_Mocked)
{
return;
}
var updated = false;
if (_settings.DataDirectories.Count == 0)
{
updated = true;