Add legacy catalog quarantine import

This commit is contained in:
Meta Vens 2026-06-13 05:53:18 +01:00
commit 27e6d08e14
9 changed files with 221 additions and 6 deletions

2
.gitignore vendored
View file

@ -99,6 +99,8 @@ Economy.Shared/bin/
Economy.Shared/obj/
Aetheria.State/bin/
Aetheria.State/obj/
Aetheria.State.Import/bin/
Aetheria.State.Import/obj/
Aetheria.State.Smoke/bin/
Aetheria.State.Smoke/obj/

View file

@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Aetheria.State\Aetheria.State.csproj" />
</ItemGroup>
</Project>

View file

@ -0,0 +1,97 @@
using System.Security.Cryptography;
using Aetheria.State;
using Aetheria.State.Documents;
using Aetheria.State.Migration;
var root = args.Length > 0 ? Path.GetFullPath(args[0]) : Directory.GetCurrentDirectory();
var statePath = args.Length > 1
? Path.GetFullPath(args[1])
: AetheriaStatePaths.ResolveDefaultStatePath(root);
var gameData = Path.Combine(root, "GameData");
var catalogPath = Path.Combine(gameData, "AetherDB.msgpack");
var nameFilesRoot = Path.Combine(gameData, "NameFile");
var capturedAtUtc = DateTimeOffset.UtcNow.ToString("O");
var catalog = CaptureFile(root, catalogPath);
var nameFiles = Directory.Exists(nameFilesRoot)
? Directory.EnumerateFiles(nameFilesRoot, "*.msgpack", SearchOption.TopDirectoryOnly)
.OrderBy(path => path, StringComparer.OrdinalIgnoreCase)
.Select(path => CaptureFile(root, path))
.ToArray()
: [];
await using var node = await AetheriaStateNode.OpenAsync(statePath, "aetheria-legacy-catalog-import");
await node.PutLegacyCatalogQuarantineAsync(new AetheriaLegacyCatalogQuarantine
{
RootPath = root,
CapturedAtUtc = capturedAtUtc,
CatalogFile = catalog.RelativePath,
CatalogFingerprint = catalog.Fingerprint,
CatalogBytes = catalog.Bytes,
NameFiles = nameFiles,
Notes =
[
"This document quarantines legacy catalog file facts only. It does not deserialize old DatabaseEntry payloads or grant old MessagePack files runtime state authority.",
"AetherDB.msgpack and NameFile/*.msgpack remain migration inputs until a bounded catalog mapper emits typed Aetheria item/faction/name documents."
]
});
await node.PutMigrationLedgerAsync(new AetheriaMigrationLedger
{
Source = LegacyMigrationBoundary.LegacyGameDataFile,
SourceFingerprint = catalog.Fingerprint,
LastMigrationAtUtc = capturedAtUtc,
Counts =
[
new AetheriaMigrationCount
{
DocumentType = "aetheria.legacy_catalog_quarantine.v1",
Count = 1
},
new AetheriaMigrationCount
{
DocumentType = "legacy.catalog_file",
Count = catalog.Bytes > 0 ? 1 : 0
},
new AetheriaMigrationCount
{
DocumentType = "legacy.name_file",
Count = nameFiles.Length
}
],
Notes =
[
"Legacy catalog quarantine captured file fingerprints into typed CultCache state without reading old DatabaseEntry payloads.",
$"State path: {statePath}"
]
});
await node.FlushAsync();
Console.WriteLine($"Aetheria legacy catalog quarantine captured: {statePath}");
Console.WriteLine($"Catalog: {catalog.RelativePath} {catalog.Bytes} bytes {catalog.Fingerprint}");
Console.WriteLine($"Name files: {nameFiles.Length}");
static AetheriaLegacyCatalogFile CaptureFile(string root, string path)
{
if (!File.Exists(path))
{
return new AetheriaLegacyCatalogFile
{
RelativePath = Path.GetRelativePath(root, path).Replace('\\', '/'),
Fingerprint = "missing",
Bytes = 0
};
}
using var stream = File.OpenRead(path);
var hash = SHA256.HashData(stream);
return new AetheriaLegacyCatalogFile
{
RelativePath = Path.GetRelativePath(root, path).Replace('\\', '/'),
Fingerprint = Convert.ToHexString(hash).ToLowerInvariant(),
Bytes = stream.Length
};
}

View file

@ -49,6 +49,25 @@ await using (var node = await AetheriaStateNode.OpenAsync(statePath, "aetheria-s
Notes = ["Smoke proves the new state owner can write, flush, reopen, and read without old JSON/Rethink authority."]
});
await node.PutLegacyCatalogQuarantineAsync(new AetheriaLegacyCatalogQuarantine
{
RootPath = root,
CapturedAtUtc = now,
CatalogFile = LegacyMigrationBoundary.LegacyGameDataFile,
CatalogFingerprint = "smoke",
CatalogBytes = 12,
NameFiles =
[
new AetheriaLegacyCatalogFile
{
RelativePath = "GameData/NameFile/smoke.msgpack",
Fingerprint = "smoke-name-file",
Bytes = 4
}
],
Notes = ["Smoke proves legacy catalog quarantine state is typed and durable."]
});
await node.PutSavedRunAsync(runKey, new AetheriaSavedRun
{
RunId = "smoke",
@ -82,6 +101,7 @@ await using (var reopened = await AetheriaStateNode.OpenAsync(statePath, "aether
{
var world = await reopened.GetWorldAsync();
var item = await reopened.GetItemDefinitionAsync(itemKey);
var quarantine = await reopened.GetLegacyCatalogQuarantineAsync();
var playerSettings = await reopened.GetPlayerSettingsAsync();
var savedRun = await reopened.GetSavedRunAsync(runKey);
@ -95,6 +115,11 @@ await using (var reopened = await AetheriaStateNode.OpenAsync(statePath, "aether
throw new InvalidOperationException("Item definition did not survive flush/reopen.");
}
if (quarantine?.CatalogFingerprint != "smoke" || quarantine.NameFiles.Length != 1)
{
throw new InvalidOperationException("Legacy catalog quarantine did not survive flush/reopen.");
}
if (playerSettings?.ActiveRunKey != runKey.ToString())
{
throw new InvalidOperationException("Player settings did not survive flush/reopen.");

View file

@ -30,6 +30,7 @@ public static class AetheriaDocumentRegistry
CultNetDocumentBinding.ForDocument<AetheriaPlayerProfile>(registry),
CultNetDocumentBinding.ForDocument<AetheriaRuntimeSession>(registry),
CultNetDocumentBinding.ForDocument<AetheriaMigrationLedger>(registry),
CultNetDocumentBinding.ForDocument<AetheriaLegacyCatalogQuarantine>(registry),
CultNetDocumentBinding.ForDocument<AetheriaPlayerSettings>(registry),
CultNetDocumentBinding.ForDocument<AetheriaSavedRun>(registry),
CultNetDocumentBinding.ForDocument<AetheriaSavedZone>(registry),
@ -45,6 +46,7 @@ public static class AetheriaDocumentRegistry
typeof(AetheriaPlayerProfile),
typeof(AetheriaRuntimeSession),
typeof(AetheriaMigrationLedger),
typeof(AetheriaLegacyCatalogQuarantine),
typeof(AetheriaPlayerSettings),
typeof(AetheriaSavedRun),
typeof(AetheriaSavedZone),

View file

@ -76,6 +76,18 @@ public sealed class AetheriaStateNode : IAsyncDisposable, IDisposable
return Database.PutAsync(new CultRecordKey("global:aetheria.migration_ledger.v1"), ledger);
}
public Task<CultRecordHandle<AetheriaLegacyCatalogQuarantine>> PutLegacyCatalogQuarantineAsync(
AetheriaLegacyCatalogQuarantine quarantine)
{
return Database.PutAsync(new CultRecordKey("global:aetheria.legacy_catalog_quarantine.v1"), quarantine);
}
public Task<AetheriaLegacyCatalogQuarantine?> GetLegacyCatalogQuarantineAsync()
{
return Database.GetAsync<AetheriaLegacyCatalogQuarantine>(
new CultRecordKey("global:aetheria.legacy_catalog_quarantine.v1"));
}
public Task<CultRecordHandle<AetheriaItemDefinition>> PutItemDefinitionAsync(
CultRecordKey key,
AetheriaItemDefinition item)

View file

@ -0,0 +1,48 @@
using GameCult.Caching;
using MessagePack;
namespace Aetheria.State.Documents;
[CultDocument("aetheria.legacy_catalog_quarantine", "aetheria.legacy_catalog_quarantine.v1")]
[CultGlobal]
[MessagePackObject]
public sealed class AetheriaLegacyCatalogQuarantine
{
[Key(0)]
[CultName]
public string Name { get; set; } = "Aetheria legacy catalog quarantine";
[Key(1)]
public string RootPath { get; set; } = "";
[Key(2)]
public string CapturedAtUtc { get; set; } = "";
[Key(3)]
public string CatalogFile { get; set; } = "";
[Key(4)]
public string CatalogFingerprint { get; set; } = "";
[Key(5)]
public long CatalogBytes { get; set; }
[Key(6)]
public AetheriaLegacyCatalogFile[] NameFiles { get; set; } = [];
[Key(7)]
public string[] Notes { get; set; } = [];
}
[MessagePackObject]
public sealed class AetheriaLegacyCatalogFile
{
[Key(0)]
public string RelativePath { get; set; } = "";
[Key(1)]
public string Fingerprint { get; set; } = "";
[Key(2)]
public long Bytes { get; set; }
}

View file

@ -33,6 +33,13 @@ longer exports `NameFile/*.msgpack`. `AetherDB.msgpack` and existing name files
remain legacy catalog inputs only; typed catalog migration is the next owner
move.
`Aetheria.State.Import` captures the legacy catalog files into typed quarantine
state: path, size, and SHA-256 fingerprint for `AetherDB.msgpack` plus
`NameFile/*.msgpack`, and a migration ledger update. It intentionally does not
deserialize old `DatabaseEntry` payloads. The next catalog migration step must
map the old union payloads into typed item/faction/name documents without making
`Aetheria.State` depend on Unity's legacy model.
Current rebuild notes:
- `MessagePack` 3.1.4 is pulled transitively through CultLib and is currently

View file

@ -33,6 +33,10 @@ local CultCache, and legacy UI paths should be migration-only or deleted.
deleted.
- `Economy.Server` now starts the modern `Aetheria.State` CultMesh node and no
longer owns RethinkDB/LiteNetLib state.
- `Aetheria.State.Import` writes a typed quarantine manifest and migration
ledger for the legacy catalog files. It records file facts only; it does not
deserialize old `DatabaseEntry` payloads or grant the old files runtime
authority.
- The old IMGUI DB inspector under `Assets/Scripts/CultCache/Editor/` has been
deleted. `NameTools` can still clean/generate names, but legacy NameFile
`.msgpack` export is disabled.
@ -155,10 +159,13 @@ First Aetheria surfaces to publish:
CultCache `.cc` file.
3. Legacy quarantine
- Move legacy readers into an explicit migration namespace/project.
- Read old `GameData/AetherDB.msgpack` and related files without granting
them runtime authority.
- Emit typed CultCache records plus a migration ledger.
- Done: capture old `GameData/AetherDB.msgpack` and related name files as a
typed quarantine manifest without granting them runtime authority.
- Done: emit typed CultCache records plus a migration ledger for the catalog
quarantine preflight.
- Remaining: implement a bounded payload mapper that converts old
`DatabaseEntry` union payloads into typed catalog documents without making
`Aetheria.State` depend on Unity's legacy model.
4. Runtime cutover
- Replace `ActionGameManager` cache bootstrap with the new state runtime.
@ -204,8 +211,10 @@ First Aetheria surfaces to publish:
resolution.
- CultMesh smoke proves node start, typed put/get, subscription, flush, and
reopen.
- Migration smoke proves old data can be read once and converted without old
readers remaining on the live runtime path.
- Quarantine import smoke proves old catalog file facts can be captured into
typed state without old readers remaining on the live runtime path.
- Migration smoke proves old catalog payloads can be read once and converted
without old readers remaining on the live runtime path.
- Unity play smoke proves runtime UI reads from Eve surfaces and sends commands
through the shared state service.
- UI Toolkit lowering parity compares Aetheria surfaces against the Eve browser