Guard gameplay source purity

This commit is contained in:
Meta Vens 2026-06-15 20:43:59 +01:00
commit 9714f36e61
4 changed files with 54 additions and 1 deletions

Binary file not shown.

View file

@ -7,6 +7,8 @@ var statePath = args.Length > 1
? Path.GetFullPath(args[1])
: AetheriaStatePaths.ResolveDefaultStatePath(root);
RequireGameplaySourcePurity(root);
await using var node = await AetheriaStateNode.OpenAsync(statePath, "aetheria-state-verify");
var ledger = await node.GetMigrationLedgerAsync()
@ -442,6 +444,7 @@ Console.WriteLine($"Corporations: {corporations.Length}");
Console.WriteLine($"Described/geoname-linked corporations: {describedCorporations}/{corporationNameLinks}");
Console.WriteLine($"Corporation allegiance edges: {corporationAllegianceEdges}");
Console.WriteLine($"Name files: {nameFiles.Length}");
Console.WriteLine("Live gameplay source purity: no serializer or legacy database symbols in Assets/Scripts");
static void RequireCount(AetheriaMigrationLedger ledger, string documentType, int actual)
{
@ -458,6 +461,47 @@ static void RequireCount(AetheriaMigrationLedger ledger, string documentType, in
}
}
static void RequireGameplaySourcePurity(string root)
{
var gameplayRoot = Path.Combine(root, "Assets", "Scripts");
if (!Directory.Exists(gameplayRoot))
{
throw new InvalidOperationException($"Cannot verify live gameplay source purity; missing path: {gameplayRoot}");
}
var forbiddenSymbols = new[]
{
"MessagePack",
"MessagePackObject",
"MessagePackSerializer",
"MessagePackReader",
"IMessagePackFormatter",
"JsonConvert",
"Newtonsoft",
"JsonKnownTypes",
"RethinkDB",
"DatabaseEntry",
"DatabaseLink",
"[Union(",
"[Key("
};
var hits = Directory.EnumerateFiles(gameplayRoot, "*.cs", SearchOption.AllDirectories)
.SelectMany(path => File.ReadLines(path)
.Select((line, index) => new { Path = path, LineNumber = index + 1, Line = line }))
.Where(line => forbiddenSymbols.Any(symbol => line.Line.Contains(symbol, StringComparison.Ordinal)))
.Select(line => $"{Path.GetRelativePath(root, line.Path)}:{line.LineNumber}: {line.Line.Trim()}")
.Take(10)
.ToArray();
if (hits.Length > 0)
{
throw new InvalidOperationException(
"Live gameplay source still contains serializer or legacy database symbols: " +
string.Join("; ", hits));
}
}
static bool ContainsBehaviorValueKind(AetheriaBehaviorValue value, string kind)
{
return string.Equals(value.Kind, kind, StringComparison.OrdinalIgnoreCase) ||

View file

@ -280,7 +280,11 @@ payload tree, and the published Eve catalog surface. The current catalog
materializes 65 behavior payloads, 661 behavior fields, and 18 behavior-side
legacy-ID references. Legacy content currently includes at least one overhanging
hardpoint; the verifier preserves the payload and checks hardpoint local masks
rather than silently converting content repair into migration.
rather than silently converting content repair into migration. The verifier also
fails if live `Assets/Scripts` source grows back serializer or legacy database
symbols such as MessagePack, Newtonsoft, JsonKnownTypes, RethinkDB, or old
`DatabaseEntry`/`DatabaseLink` references; the remaining MessagePack usage is a
named package/import CultCache transport boundary, not gameplay state authority.
Use it after import when `GameData/aetheria-world.cc` changes.
`Aetheria.State.Unity.Smoke` opens the materialized state through the runtime

View file

@ -1596,6 +1596,11 @@ First Aetheria surfaces to publish:
auto-reference; `Assets/Scripts` and `Assets/Editor` have no `using
MessagePack`, `MessagePackSerializer`, `[MessagePackObject]`, or
`IMessagePackFormatter` hits.
- `Aetheria.State.Verify` now enforces the gameplay-source purity invariant:
live `Assets/Scripts` cannot contain MessagePack, Newtonsoft,
JsonKnownTypes, RethinkDB, old database-link symbols, or serializer metadata.
Package/import MessagePack usage remains explicitly bounded to CultCache
transport and migration.
- Unity batchmode compile returned cleanly after the runtime blueprint rename;
live Unity source has no `EntityPack`, `ShipPack`, `OrbitalEntityPack`,
`ZonePack`, `PackedContents`, `PackZone`, `EntitySerializer.Pack`, or