diff --git a/.gitignore b/.gitignore
index 4b2b86558..36c3850b7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -107,6 +107,8 @@ Aetheria.State.Unity/bin/
Aetheria.State.Unity/obj/
Aetheria.State.Unity.Smoke/bin/
Aetheria.State.Unity.Smoke/obj/
+Aetheria.State.Replica/bin/
+Aetheria.State.Replica/obj/
Aetheria.State.Verify/bin/
Aetheria.State.Verify/obj/
diff --git a/Aetheria.State.Replica/Aetheria.State.Replica.csproj b/Aetheria.State.Replica/Aetheria.State.Replica.csproj
new file mode 100644
index 000000000..41b539514
--- /dev/null
+++ b/Aetheria.State.Replica/Aetheria.State.Replica.csproj
@@ -0,0 +1,15 @@
+
+
+ Exe
+ net10.0
+ enable
+ enable
+ latest
+ Replica sync worker for pulling daemon-owned Aetheria Verse state into a local cache-only .cc witness.
+
+
+
+
+
+
+
diff --git a/Aetheria.State.Replica/Program.cs b/Aetheria.State.Replica/Program.cs
new file mode 100644
index 000000000..314dab576
--- /dev/null
+++ b/Aetheria.State.Replica/Program.cs
@@ -0,0 +1,120 @@
+using Aetheria.State;
+using GameCult.Aetheria.State.Unity;
+
+return await ProgramMainAsync(args).ConfigureAwait(false);
+
+static async Task ProgramMainAsync(string[] args)
+{
+ if (args.Length == 0)
+ {
+ PrintUsage();
+ return 1;
+ }
+
+ var mode = args[0].Trim();
+ var options = ParseOptions(args.Skip(1));
+ var endpoint = RequireOption(options, "endpoint");
+ var runtimeId = ReadOption(options, "runtime-id", "aetheria-verse-replica");
+ var replicaPath = ResolveReplicaPath(options);
+
+ switch (mode)
+ {
+ case "sync":
+ {
+ var appliedSequence = await AetheriaVerseReplica
+ .SyncSnapshotAsync(replicaPath, endpoint, runtimeId)
+ .ConfigureAwait(false);
+ Console.WriteLine($"Synced Aetheria replica to {replicaPath} from {endpoint} at shard sequence {appliedSequence}.");
+ return 0;
+ }
+ case "follow":
+ {
+ var pollSeconds = ReadDoubleOption(options, "poll-seconds", 1d);
+ using var cancellation = new CancellationTokenSource();
+ Console.CancelKeyPress += (_, eventArgs) =>
+ {
+ eventArgs.Cancel = true;
+ cancellation.Cancel();
+ };
+
+ Console.WriteLine(
+ $"Following Aetheria replica at {replicaPath} from {endpoint} every {pollSeconds:0.###} seconds. Press Ctrl+C to stop.");
+ await AetheriaVerseReplica
+ .RunReplicaAsync(replicaPath, endpoint, TimeSpan.FromSeconds(pollSeconds), cancellation.Token, runtimeId)
+ .ConfigureAwait(false);
+ return 0;
+ }
+ default:
+ Console.Error.WriteLine($"Unknown mode '{mode}'.");
+ PrintUsage();
+ return 1;
+ }
+}
+
+static string ResolveReplicaPath(IReadOnlyDictionary options)
+{
+ var explicitPath = ReadOption(options, "replica", "");
+ if (!string.IsNullOrWhiteSpace(explicitPath))
+ return Path.GetFullPath(explicitPath);
+
+ var gameDataRoot = RequireOption(options, "game-data-root");
+ var verseId = RequireOption(options, "verse-id");
+ return AetheriaRuntimeStateBoundary.GetReplicaStateFilePath(
+ new DirectoryInfo(Path.GetFullPath(gameDataRoot)),
+ verseId);
+}
+
+static Dictionary ParseOptions(IEnumerable args)
+{
+ var options = new Dictionary(StringComparer.OrdinalIgnoreCase);
+ string? pendingKey = null;
+ foreach (var arg in args)
+ {
+ if (arg.StartsWith("--", StringComparison.Ordinal))
+ {
+ pendingKey = arg[2..];
+ options[pendingKey] = "true";
+ continue;
+ }
+
+ if (!string.IsNullOrWhiteSpace(pendingKey))
+ {
+ options[pendingKey] = arg;
+ pendingKey = null;
+ }
+ }
+
+ return options;
+}
+
+static string RequireOption(IReadOnlyDictionary options, string key)
+{
+ var value = ReadOption(options, key, "");
+ if (!string.IsNullOrWhiteSpace(value))
+ return value;
+
+ throw new InvalidOperationException($"Missing required option --{key}.");
+}
+
+static string ReadOption(IReadOnlyDictionary options, string key, string fallback)
+{
+ return options.TryGetValue(key, out var value) && !string.IsNullOrWhiteSpace(value)
+ ? value
+ : fallback;
+}
+
+static double ReadDoubleOption(IReadOnlyDictionary options, string key, double fallback)
+{
+ var value = ReadOption(options, key, "");
+ return double.TryParse(value, out var parsed) && parsed > 0
+ ? parsed
+ : fallback;
+}
+
+static void PrintUsage()
+{
+ Console.WriteLine("Usage:");
+ Console.WriteLine(" sync --endpoint cultnet://host:3075 --replica path-to-replica.cc");
+ Console.WriteLine(" sync --endpoint cultnet://host:3075 --game-data-root GameData --verse-id verse.id");
+ Console.WriteLine(" follow --endpoint cultnet://host:3075 --replica path-to-replica.cc [--poll-seconds 1]");
+}
diff --git a/Aetheria.State.Verify/Program.cs b/Aetheria.State.Verify/Program.cs
index dd5401104..2cf01dede 100644
--- a/Aetheria.State.Verify/Program.cs
+++ b/Aetheria.State.Verify/Program.cs
@@ -51,6 +51,7 @@ RequireNoDeadPopupShells(root);
RequirePlayerSettingsEveSurface(root);
RequireVerseHostSettingsAuthority(root);
RequireClientTargetBootAuthority(root);
+RequireVerseReplicaTool(root);
RequireVerseSettingsShellAndBridge(root);
RequireMainMenuVerseHostProjection(root);
RequireMainMenuContinueRunState(root);
@@ -539,6 +540,7 @@ Console.WriteLine("NameTools editor shell: the remaining name helper window lowe
Console.WriteLine("Runtime state reader authority: Unity gameplay/UI read typed state through a shared runtime reader instead of direct store spelunking");
Console.WriteLine("Verse host authority: daemon-owned typed verse host settings now drive provider advertisement, operations telemetry, and served Verse discovery");
Console.WriteLine("Client target boot authority: Unity boot resolves the active Verse through a typed client target instead of local path folklore");
+Console.WriteLine("Verse replica authority: remote client targets resolve to cache-only replica .cc files fed from the daemon");
Console.WriteLine("Verse settings shell: client target edits and Verse-host visibility commands lower through typed Eve surfaces");
Console.WriteLine("Main-menu Verse projection: the Unity Eve shell lowers daemon-owned verse identity instead of ad-libbing local menu copy");
Console.WriteLine("Runtime simulation tuning authority: UI writes flow through gameplay checkpoint commits");
@@ -3935,9 +3937,11 @@ static void RequireClientTargetBootAuthority(string root)
var requiredBoundarySymbols = new[]
{
"RuntimeClientTargetFileName = \"aetheria-client.cc\"",
+ "RuntimeReplicaDirectoryName = \"Verses\"",
"RuntimeStatePathOverrideEnvironmentVariable = \"AETHERIA_STATE_PATH\"",
"LegacyRuntimeStatePathOverrideEnvironmentVariable = \"AETHERIA_EVE_STATE_PATH\"",
"GetClientTargetPath",
+ "GetReplicaStateFilePath",
"ResolveStatePathOverride"
};
var missingBoundarySymbols = requiredBoundarySymbols
@@ -3962,6 +3966,7 @@ static void RequireClientTargetBootAuthority(string root)
"DiscoveredVerses",
"LastDiscoveryAtUtc",
"LastDiscoveryError",
+ "ReplicaStateFilePath",
"ReadOrInitialize",
"CreateDefault",
"Write(string clientTargetPath, AetheriaRuntimeClientTargetDocument document)",
@@ -3988,10 +3993,13 @@ static void RequireClientTargetBootAuthority(string root)
"DiscoveredVerses",
"LastDiscoveryAtUtc",
"LastDiscoveryError",
+ "ReplicaStateFilePath",
"TargetLabel",
"AetheriaRuntimeClientTargetStore.ReadOrInitialize",
"AetheriaRuntimeStateBoundary.ResolveStatePathOverride()",
"AetheriaRuntimeClientTargetKinds.CultMeshVerse",
+ "GetReplicaStateFilePath",
+ "Sync the local replica",
"state-path-override",
"client-target"
};
@@ -4073,6 +4081,7 @@ static void RequireClientTargetBootAuthority(string root)
"stateBoot.DiscoveredVerses",
"stateBoot.LastDiscoveryAtUtc",
"stateBoot.LastDiscoveryError",
+ "stateBoot.ReplicaStateFilePath",
"\"Client Target\"",
"\"Transport\"",
"\"Target Source\""
@@ -4121,6 +4130,99 @@ static void RequireClientTargetBootAuthority(string root)
}
}
+static void RequireVerseReplicaTool(string root)
+{
+ var replicaToolProjectPath = Path.Combine(root, "Aetheria.State.Replica", "Aetheria.State.Replica.csproj");
+ var replicaToolProgramPath = Path.Combine(root, "Aetheria.State.Replica", "Program.cs");
+ var replicaHostPath = Path.Combine(root, "Aetheria.State", "AetheriaVerseReplica.cs");
+ var stateReadmePath = Path.Combine(root, "Aetheria.State", "README.md");
+
+ var requiredFiles = new[]
+ {
+ replicaToolProjectPath,
+ replicaToolProgramPath,
+ replicaHostPath,
+ stateReadmePath
+ };
+
+ var missingFiles = requiredFiles
+ .Where(path => !File.Exists(path))
+ .Select(path => Path.GetRelativePath(root, path))
+ .ToArray();
+ if (missingFiles.Length > 0)
+ {
+ throw new InvalidOperationException(
+ "Verse replica tool cannot be verified because required files are missing: " +
+ string.Join(", ", missingFiles));
+ }
+
+ var replicaToolProject = File.ReadAllText(replicaToolProjectPath);
+ var replicaToolProgram = File.ReadAllText(replicaToolProgramPath);
+ var replicaHost = File.ReadAllText(replicaHostPath);
+ var stateReadme = File.ReadAllText(stateReadmePath);
+
+ var requiredProjectSymbols = new[]
+ {
+ "",
+ ""
+ };
+ var missingProjectSymbols = requiredProjectSymbols
+ .Where(symbol => !replicaToolProject.Contains(symbol, StringComparison.Ordinal))
+ .ToArray();
+ if (missingProjectSymbols.Length > 0)
+ {
+ throw new InvalidOperationException(
+ "Verse replica tool project is incomplete: " +
+ string.Join(", ", missingProjectSymbols));
+ }
+
+ var requiredProgramSymbols = new[]
+ {
+ "sync",
+ "follow",
+ "AetheriaVerseReplica",
+ "GetReplicaStateFilePath",
+ "--endpoint",
+ "--replica"
+ };
+ var missingProgramSymbols = requiredProgramSymbols
+ .Where(symbol => !replicaToolProgram.Contains(symbol, StringComparison.Ordinal))
+ .ToArray();
+ if (missingProgramSymbols.Length > 0)
+ {
+ throw new InvalidOperationException(
+ "Verse replica tool program is incomplete: " +
+ string.Join(", ", missingProgramSymbols));
+ }
+
+ var requiredReplicaHostSymbols = new[]
+ {
+ "public static class AetheriaVerseReplica",
+ "SyncSnapshotAsync",
+ "RunReplicaAsync",
+ "CultNetSchemaShardSnapshotFetcher",
+ "CultNetSchemaShardLogFetcher",
+ "CultNetShardReplicator",
+ "ApplyShardSnapshotResponseAsync"
+ };
+ var missingReplicaHostSymbols = requiredReplicaHostSymbols
+ .Where(symbol => !replicaHost.Contains(symbol, StringComparison.Ordinal))
+ .ToArray();
+ if (missingReplicaHostSymbols.Length > 0)
+ {
+ throw new InvalidOperationException(
+ "Verse replica host is incomplete: " +
+ string.Join(", ", missingReplicaHostSymbols));
+ }
+
+ if (!stateReadme.Contains("Aetheria.State.Replica", StringComparison.Ordinal) ||
+ !stateReadme.Contains("GameData\\Verses\\.cc", StringComparison.Ordinal))
+ {
+ throw new InvalidOperationException(
+ "Aetheria.State README does not describe the cache-only Verse replica workflow.");
+ }
+}
+
static void RequireVerseSettingsShellAndBridge(string root)
{
var unityFacadeProjectPath = Path.Combine(root, "Aetheria.State.Unity", "Aetheria.State.Unity.csproj");
@@ -4248,6 +4350,7 @@ static void RequireVerseSettingsShellAndBridge(string root)
"\"Target Fields\"",
"\"Verse Discovery\"",
"\"Daemon Verse Host\"",
+ "\"Replica State File\"",
"AetheriaRuntimeClientTargetCommands.SetStateFilePath",
"AetheriaRuntimeClientTargetCommands.SetDiscoveryEndpoints",
"AetheriaRuntimeClientTargetCommands.DiscoverVerses",
diff --git a/Aetheria.State/AetheriaVerseReplica.cs b/Aetheria.State/AetheriaVerseReplica.cs
new file mode 100644
index 000000000..1069e06c4
--- /dev/null
+++ b/Aetheria.State/AetheriaVerseReplica.cs
@@ -0,0 +1,110 @@
+using GameCult.Caching;
+using GameCult.Caching.MessagePack;
+using GameCult.Mesh;
+using GameCult.Networking;
+
+namespace Aetheria.State;
+
+public static class AetheriaVerseReplica
+{
+ private const string ReplicaShardId = "primary";
+ private const string ReplicaOwnerRuntimeId = "aetheria-remote";
+
+ public static async Task SyncSnapshotAsync(
+ string replicaStatePath,
+ string endpoint,
+ string runtimeId = "aetheria-verse-replica")
+ {
+ using var node = await OpenReplicaNodeAsync(replicaStatePath, endpoint, runtimeId).ConfigureAwait(false);
+ var shard = BuildReplicaShard(endpoint);
+ var fetcher = new CultNetSchemaShardSnapshotFetcher();
+ var snapshot = await fetcher.FetchAsync(shard).ConfigureAwait(false);
+ var appliedSequence = await node.Database.ApplyShardSnapshotResponseAsync(shard, snapshot).ConfigureAwait(false);
+ await node.FlushAsync().ConfigureAwait(false);
+ return appliedSequence;
+ }
+
+ public static async Task RunReplicaAsync(
+ string replicaStatePath,
+ string endpoint,
+ TimeSpan pollInterval,
+ CancellationToken cancellationToken,
+ string runtimeId = "aetheria-verse-replica")
+ {
+ using var node = await OpenReplicaNodeAsync(replicaStatePath, endpoint, runtimeId).ConfigureAwait(false);
+ var shard = BuildReplicaShard(endpoint);
+ var snapshotFetcher = new CultNetSchemaShardSnapshotFetcher();
+ var logFetcher = new CultNetSchemaShardLogFetcher();
+
+ var snapshot = await snapshotFetcher.FetchAsync(shard).ConfigureAwait(false);
+ await node.Database.ApplyShardSnapshotResponseAsync(shard, snapshot).ConfigureAwait(false);
+ await node.FlushAsync().ConfigureAwait(false);
+
+ using var replicator = new CultNetShardReplicator(
+ node.Database,
+ new CultNetShardReplicatorOptions
+ {
+ PollInterval = pollInterval,
+ Fetcher = logFetcher,
+ SnapshotFetcher = snapshotFetcher
+ });
+ replicator.Start();
+
+ try
+ {
+ await Task.Delay(Timeout.Infinite, cancellationToken).ConfigureAwait(false);
+ }
+ catch (OperationCanceledException)
+ {
+ }
+ finally
+ {
+ await node.FlushAsync().ConfigureAwait(false);
+ }
+ }
+
+ private static CultNetShardDescriptor BuildReplicaShard(string endpoint)
+ {
+ if (string.IsNullOrWhiteSpace(endpoint))
+ throw new ArgumentException("Replica endpoint must be non-empty.", nameof(endpoint));
+
+ return new CultNetShardDescriptor(
+ ReplicaShardId,
+ ReplicaOwnerRuntimeId,
+ epoch: 1,
+ isPrimary: false,
+ primaryEndpoints: new[] { endpoint.Trim() });
+ }
+
+ private static Task OpenReplicaNodeAsync(
+ string replicaStatePath,
+ string endpoint,
+ string runtimeId)
+ {
+ if (string.IsNullOrWhiteSpace(replicaStatePath))
+ throw new ArgumentException("Replica state path must be non-empty.", nameof(replicaStatePath));
+
+ var shard = BuildReplicaShard(endpoint);
+ var cacheRegistry = AetheriaDocumentRegistry.CreateCultCacheRegistry();
+ return CultMesh.CreateNodeAsync(
+ replicaStatePath,
+ new CultMeshNodeOptions
+ {
+ StartServer = false,
+ EnableDurableShardLogs = true,
+ CacheOptions = new CultCacheOpenOptions
+ {
+ Registry = cacheRegistry,
+ PullOnOpen = true,
+ StoreFlushOnDispose = true,
+ UseDirectoryStore = true
+ },
+ DatabaseOptions = new CultNetDatabaseOptions
+ {
+ RuntimeId = string.IsNullOrWhiteSpace(runtimeId) ? "aetheria-verse-replica" : runtimeId,
+ Shards = new[] { shard },
+ DocumentRegistry = AetheriaDocumentRegistry.CreateCultNetRegistry(cacheRegistry)
+ }
+ });
+ }
+}
diff --git a/Aetheria.State/README.md b/Aetheria.State/README.md
index 27f578115..c1e86d769 100644
--- a/Aetheria.State/README.md
+++ b/Aetheria.State/README.md
@@ -411,6 +411,18 @@ advertisement still publishes `gamecult.eve.provider_advertisement.v1` for the
`aetheria` provider, advertising the catalog, operations, and player-settings
surfaces plus the typed schemas witnessed by the local `.cc` state file.
+Remote Unity clients should not pretend a public Verse is local authority. Use
+`Aetheria.State.Replica` to pull a cache-only local witness from the daemon:
+
+```powershell
+dotnet run --project .\Aetheria.State.Replica\Aetheria.State.Replica.csproj -- sync --endpoint cultnet://host:3075 --game-data-root .\GameData --verse-id aetheria.public
+```
+
+That writes `GameData\Verses\.cc` as a replica projection of daemon
+truth. The selected remote client target resolves to that replica path. The
+daemon still owns accepted state; the replica is only the local read surface
+Unity lowers from.
+
`Aetheria.State.ApplyPending` is the smaller local operator applicator for
queued Unity runtime commits and Eve commands when the server host is not being
used. It also republishes the typed drain status, operations surface,
diff --git a/Assets/Scripts/UI/MainMenu.cs b/Assets/Scripts/UI/MainMenu.cs
index ccb7648d1..bee0d1c53 100644
--- a/Assets/Scripts/UI/MainMenu.cs
+++ b/Assets/Scripts/UI/MainMenu.cs
@@ -453,6 +453,7 @@ public class MainMenu : MonoBehaviour
stateBoot.VerseId,
stateBoot.CultMeshAddress,
stateBoot.StateFilePath,
+ stateBoot.ReplicaStateFilePath,
string.Join(", ", stateBoot.DiscoveryEndpoints ?? Array.Empty()),
stateBoot.DiscoveredVerses ?? Array.Empty(),
stateBoot.LastDiscoveryAtUtc,
diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeClientTargetStore.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeClientTargetStore.cs
index 4db81371b..d55630f3e 100644
--- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeClientTargetStore.cs
+++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeClientTargetStore.cs
@@ -1,6 +1,7 @@
using System;
using System.Buffers;
using System.IO;
+using System.Linq;
using MessagePack;
#nullable enable
@@ -32,6 +33,7 @@ namespace GameCult.Aetheria.State.Unity
[Key(8)] public AetheriaRuntimeDiscoveredVerse[] DiscoveredVerses { get; set; } = Array.Empty();
[Key(9)] public string LastDiscoveryAtUtc { get; set; } = "";
[Key(10)] public string LastDiscoveryError { get; set; } = "";
+ [Key(11)] public string ReplicaStateFilePath { get; set; } = "";
}
[MessagePackObject]
@@ -70,6 +72,7 @@ namespace GameCult.Aetheria.State.Unity
public static AetheriaRuntimeClientTargetDocument CreateDefault(string defaultStateFilePath)
{
+ var gameDataDirectory = ResolveGameDataDirectory(defaultStateFilePath);
return new AetheriaRuntimeClientTargetDocument
{
Schema = AetheriaRuntimeClientTargetDocument.SchemaId,
@@ -78,6 +81,7 @@ namespace GameCult.Aetheria.State.Unity
VerseId = "aetheria.local",
CultMeshAddress = "asgard.local.aetheria/eve",
StateFilePath = defaultStateFilePath ?? "",
+ ReplicaStateFilePath = AetheriaRuntimeStateBoundary.GetReplicaStateFilePath(gameDataDirectory, "aetheria.local"),
UpdatedAtUtc = DateTime.UtcNow.ToString("O")
};
}
@@ -91,6 +95,7 @@ namespace GameCult.Aetheria.State.Unity
document.DiscoveredVerses ??= Array.Empty();
document.LastDiscoveryAtUtc ??= "";
document.LastDiscoveryError ??= "";
+ document.ReplicaStateFilePath = NormalizeReplicaStateFilePath(document, clientTargetPath, document.ReplicaStateFilePath);
foreach (var verse in document.DiscoveredVerses)
{
if (verse == null)
@@ -130,6 +135,7 @@ namespace GameCult.Aetheria.State.Unity
var document = ReadOrInitialize(clientTargetPath, defaultStateFilePath);
mutate(document);
+ document.ReplicaStateFilePath = NormalizeReplicaStateFilePath(document, clientTargetPath, document.ReplicaStateFilePath);
Write(clientTargetPath, document);
return document;
}
@@ -313,5 +319,31 @@ namespace GameCult.Aetheria.State.Unity
File.Move(tempPath, path);
}
+
+ private static string NormalizeReplicaStateFilePath(
+ AetheriaRuntimeClientTargetDocument document,
+ string clientTargetPath,
+ string configuredPath)
+ {
+ if (!string.IsNullOrWhiteSpace(configuredPath))
+ return Path.GetFullPath(configuredPath);
+
+ var gameDataDirectory = ResolveGameDataDirectoryFromClientTarget(clientTargetPath);
+ return AetheriaRuntimeStateBoundary.GetReplicaStateFilePath(gameDataDirectory, document?.VerseId ?? "");
+ }
+
+ private static DirectoryInfo ResolveGameDataDirectory(string defaultStateFilePath)
+ {
+ var fullPath = Path.GetFullPath(string.IsNullOrWhiteSpace(defaultStateFilePath) ? "." : defaultStateFilePath);
+ var directory = Path.GetDirectoryName(fullPath);
+ return new DirectoryInfo(string.IsNullOrWhiteSpace(directory) ? "." : directory);
+ }
+
+ private static DirectoryInfo ResolveGameDataDirectoryFromClientTarget(string clientTargetPath)
+ {
+ var fullPath = Path.GetFullPath(string.IsNullOrWhiteSpace(clientTargetPath) ? "." : clientTargetPath);
+ var directory = Path.GetDirectoryName(fullPath);
+ return new DirectoryInfo(string.IsNullOrWhiteSpace(directory) ? "." : directory);
+ }
}
}
diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeClientTargetSurfaceBuilder.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeClientTargetSurfaceBuilder.cs
index 5b3d1237f..b51b40a40 100644
--- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeClientTargetSurfaceBuilder.cs
+++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeClientTargetSurfaceBuilder.cs
@@ -12,6 +12,7 @@ namespace GameCult.Aetheria.State.Unity
string targetVerseId,
string targetCultMeshAddress,
string targetStateFilePath,
+ string targetReplicaStateFilePath,
string discoveryEndpointsText,
IReadOnlyList discoveredVerses,
string lastDiscoveryAtUtc,
@@ -30,6 +31,7 @@ namespace GameCult.Aetheria.State.Unity
TargetVerseId = targetVerseId ?? "";
TargetCultMeshAddress = targetCultMeshAddress ?? "";
TargetStateFilePath = targetStateFilePath ?? "";
+ TargetReplicaStateFilePath = targetReplicaStateFilePath ?? "";
DiscoveryEndpointsText = discoveryEndpointsText ?? "";
DiscoveredVerses = discoveredVerses ?? Array.Empty();
LastDiscoveryAtUtc = lastDiscoveryAtUtc ?? "";
@@ -49,6 +51,7 @@ namespace GameCult.Aetheria.State.Unity
public string TargetVerseId { get; }
public string TargetCultMeshAddress { get; }
public string TargetStateFilePath { get; }
+ public string TargetReplicaStateFilePath { get; }
public string DiscoveryEndpointsText { get; }
public IReadOnlyList DiscoveredVerses { get; }
public string LastDiscoveryAtUtc { get; }
@@ -90,6 +93,7 @@ namespace GameCult.Aetheria.State.Unity
"",
"",
"",
+ "",
Array.Empty(),
"",
"",
@@ -209,6 +213,10 @@ namespace GameCult.Aetheria.State.Unity
"State File Path",
state.TargetStateFilePath,
AetheriaRuntimeClientTargetCommands.SetStateFilePath),
+ Metric(
+ "aetheria.clientTarget.target.replicaStateFilePath",
+ "Replica State File",
+ state.TargetReplicaStateFilePath),
ButtonRow(
"aetheria.clientTarget.target.actions",
Button(
diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeStateBoot.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeStateBoot.cs
index 4008698b8..508df3d98 100644
--- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeStateBoot.cs
+++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeStateBoot.cs
@@ -14,6 +14,7 @@ namespace GameCult.Aetheria.State.Unity
string verseId,
string cultMeshAddress,
string stateFilePath,
+ string replicaStateFilePath,
bool stateFileExists,
bool supportsLocalStateFileRead,
string failureMessage,
@@ -29,6 +30,7 @@ namespace GameCult.Aetheria.State.Unity
VerseId = verseId;
CultMeshAddress = cultMeshAddress;
StateFilePath = stateFilePath;
+ ReplicaStateFilePath = replicaStateFilePath;
StateFileExists = stateFileExists;
SupportsLocalStateFileRead = supportsLocalStateFileRead;
FailureMessage = failureMessage;
@@ -45,6 +47,7 @@ namespace GameCult.Aetheria.State.Unity
public string VerseId { get; }
public string CultMeshAddress { get; }
public string StateFilePath { get; }
+ public string ReplicaStateFilePath { get; }
public bool StateFileExists { get; }
public bool SupportsLocalStateFileRead { get; }
public string FailureMessage { get; }
@@ -87,17 +90,23 @@ namespace GameCult.Aetheria.State.Unity
var supportsLocalStateFileRead = true;
var failureMessage = "";
string stateFilePath;
+ string replicaStateFilePath;
if (!string.IsNullOrWhiteSpace(configuredOverride))
{
stateFilePath = Path.GetFullPath(configuredOverride);
+ replicaStateFilePath = target.ReplicaStateFilePath ?? "";
}
else if (string.Equals(targetKind, AetheriaRuntimeClientTargetKinds.CultMeshVerse, StringComparison.Ordinal))
{
- stateFilePath = "";
- supportsLocalStateFileRead = false;
- failureMessage =
- $"Selected client Verse target '{BuildTargetLabel(targetTitle, targetVerseId)}' points at CultMesh address '{targetCultMeshAddress}', but Unity still boots from local typed state until daemon transport lands.";
+ replicaStateFilePath = string.IsNullOrWhiteSpace(target.ReplicaStateFilePath)
+ ? AetheriaRuntimeStateBoundary.GetReplicaStateFilePath(gameDataDirectory, targetVerseId)
+ : Path.GetFullPath(target.ReplicaStateFilePath);
+ stateFilePath = replicaStateFilePath;
+ supportsLocalStateFileRead = File.Exists(replicaStateFilePath);
+ failureMessage = supportsLocalStateFileRead
+ ? ""
+ : $"Selected client Verse target '{BuildTargetLabel(targetTitle, targetVerseId)}' follows remote CultMesh endpoint '{targetCultMeshAddress}'. Sync the local replica at '{replicaStateFilePath}' before booting Unity from that Verse.";
}
else
{
@@ -105,6 +114,9 @@ namespace GameCult.Aetheria.State.Unity
? defaultStateFilePath
: target.StateFilePath;
stateFilePath = Path.GetFullPath(configuredStateFilePath);
+ replicaStateFilePath = string.IsNullOrWhiteSpace(target.ReplicaStateFilePath)
+ ? AetheriaRuntimeStateBoundary.GetReplicaStateFilePath(gameDataDirectory, targetVerseId)
+ : Path.GetFullPath(target.ReplicaStateFilePath);
}
return new AetheriaRuntimeStateBootReport(
@@ -115,6 +127,7 @@ namespace GameCult.Aetheria.State.Unity
targetVerseId,
targetCultMeshAddress,
stateFilePath,
+ replicaStateFilePath,
supportsLocalStateFileRead && File.Exists(stateFilePath),
supportsLocalStateFileRead,
failureMessage,
diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeStateBoundary.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeStateBoundary.cs
index 349311c66..f9afb240d 100644
--- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeStateBoundary.cs
+++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeStateBoundary.cs
@@ -1,4 +1,5 @@
using System.IO;
+using System.Linq;
namespace GameCult.Aetheria.State.Unity
{
@@ -6,6 +7,7 @@ namespace GameCult.Aetheria.State.Unity
{
public const string RuntimeStateFileName = "aetheria-world.cc";
public const string RuntimeClientTargetFileName = "aetheria-client.cc";
+ public const string RuntimeReplicaDirectoryName = "Verses";
public const string RuntimeStatePathOverrideEnvironmentVariable = "AETHERIA_STATE_PATH";
public const string LegacyRuntimeStatePathOverrideEnvironmentVariable = "AETHERIA_EVE_STATE_PATH";
@@ -19,6 +21,23 @@ namespace GameCult.Aetheria.State.Unity
return Path.Combine(gameDataDirectory.FullName, RuntimeClientTargetFileName);
}
+ public static string GetReplicaStateFilePath(DirectoryInfo gameDataDirectory, string verseId)
+ {
+ var safeVerseId = string.IsNullOrWhiteSpace(verseId)
+ ? "unknown-verse"
+ : new string((verseId ?? "")
+ .Select(ch => char.IsLetterOrDigit(ch) || ch == '-' || ch == '_' || ch == '.'
+ ? ch
+ : '-')
+ .ToArray())
+ .Trim('-');
+
+ if (string.IsNullOrWhiteSpace(safeVerseId))
+ safeVerseId = "unknown-verse";
+
+ return Path.Combine(gameDataDirectory.FullName, RuntimeReplicaDirectoryName, $"{safeVerseId}.cc");
+ }
+
public static string ResolveStatePathOverride()
{
var configured = System.Environment.GetEnvironmentVariable(RuntimeStatePathOverrideEnvironmentVariable);