From 0aea729eff6da8424385a2875308af449f226cc1 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Tue, 16 Jun 2026 11:00:56 +0100 Subject: [PATCH] Name behavior body state as typed keys --- .voidbot/state/aetheria.cc | Bin 163351 -> 166347 bytes Aetheria.State.Smoke/Program.cs | 8 ++-- Aetheria.State.Unity.Smoke/Program.cs | 8 ++-- Aetheria.State.Verify/Program.cs | 38 ++++++++++++++++++ .../AetheriaRuntimeCommitLogApplier.cs | 4 +- .../AetheriaRuntimeStateDocuments.cs | 4 +- Aetheria.State/README.md | 7 ++-- Assets/Scripts/Gameplay/ActionGameManager.cs | 25 +++++------- .../Runtime/AetheriaRuntimeCatalogSnapshot.cs | 12 +++--- .../Runtime/AetheriaRuntimeCatalogStore.cs | 8 ++-- docs/aetheria-perfect-machine-map.md | 9 ++++- 11 files changed, 82 insertions(+), 41 deletions(-) diff --git a/.voidbot/state/aetheria.cc b/.voidbot/state/aetheria.cc index d6dcc4fbbbdba8444b4aaff2fd67c6a487286a83..a0ea9adcc5dfac6d76c0446d4fd21ddf72e0cf1d 100644 GIT binary patch delta 2923 zcmai0U2GIp6lSIb`H=$3j}W1^2oHts_RmuKBiK?P8z7LnXsMELJ9E2xWoGX7-aB2E zAR9w`(wOKF=S5xwl^7E7Xi^he!oshch9N z!+f904o99h|0|alffI7JGOcI&PoX{tM6zxgqt0lsv zl1JhDCC=U?PW0tp>#HW20GC9Oslz2m4i^Z@Iu4|OUBcUSz`|#z3Bp1UE-4E{7Uhcs zG0#N>0!dK^9m8CZ!=!+n%E6Gj2O#J%Q(P5nk$5HedKnAk5|2pY4p!0efJy~|kSwi! zC;$rmmP**Xq#j^_2XIIP1x8NDp}-OyJf0iPC_n(Q2^Ijl8dOtJ76vZnmF(w|1Omdo zbJrZA1d^>XK1o&93KBtP2!}dC_JQoEv&5hS07LQufTx}Ze^tCHI+Pm~0E8qwz@ArW zM}p}Hbs(o9Y(Eq-y){XozECAsU0?_wNnR)yNq{_7hB5{PBr7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bJQ{%BctcNU0n9^0!lt8&i83FCN2%HIE?BZ)62KNDvW8O;vmXRIcjF>Kv z34?Vt>4ZFDz!F{OC!s*!a3x(*L|w3)vtz_PZtRU1PaGp_G8H~m9DMjW6<#RS3Tx@R z`#O2^5IQ>YbYq3Rl5)jX`WTwj&`1WL+jCIwQek9G{zpCg_cEH#|9A+UKYZlMpa?*s zzD!N6KTgfYFX9Q3q-zn^;b5Re>N$@?BjQ7Q&qTI&2Hm)NwX9L{Svs>^C*s^!+p{J$ zw;9tdM-9}G&Sq=fy|g)IZ0|`lp8eXWWXaB0_R>4!`L!wZ)Tu*Xuyx0}$NH>X%zk=c zCb!Gz@|3-;@Ox*s>-}9AqA7MFp<06|g+&T|ra_;95Lx}lb^F6>_?Z22168cOhCj>i zZK4Te|M~_!Y(MOw(+|Q)nmJpo!%6zc&;Zm(^Iv+XUO5=UVQ^aA-FG~%zm0->_N@*4 zs6A)!L7Q*jBjt^noh^^qw`J(@@{m>R&zo2d!}CSv%UifthUR8m= 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()}") + .ToArray(); + + if (hits.Length > 0) + { + throw new InvalidOperationException( + "Runtime behavior body references must be named typed BodyKey surfaces; GUID parsing is confined to ParseBodyGuidFromKey: " + + string.Join("; ", hits)); + } +} + static void RequireEveRuntimeBootstrap(string root) { var bootstrapPath = Path.Combine( diff --git a/Aetheria.State/AetheriaRuntimeCommitLogApplier.cs b/Aetheria.State/AetheriaRuntimeCommitLogApplier.cs index c8dbd0df1..98923425f 100644 --- a/Aetheria.State/AetheriaRuntimeCommitLogApplier.cs +++ b/Aetheria.State/AetheriaRuntimeCommitLogApplier.cs @@ -569,13 +569,13 @@ public static class AetheriaRuntimeCommitLogApplier AetherDriveMaximumRpm = state.AetherDriveMaximumRpm, AetherDriveThrustDirectionX = state.AetherDriveThrustDirectionX, AetherDriveThrustDirectionY = state.AetherDriveThrustDirectionY, - ResourceScannerTargetBodyId = state.ResourceScannerTargetBodyKey ?? "", + ResourceScannerTargetBodyKey = state.ResourceScannerTargetBodyKey ?? "", ResourceScannerAsteroidIndex = state.ResourceScannerAsteroidIndex, ResourceScannerScanTime = state.ResourceScannerScanTime, ResourceScannerRange = state.ResourceScannerRange, ResourceScannerMinimumDensity = state.ResourceScannerMinimumDensity, ResourceScannerScanDuration = state.ResourceScannerScanDuration, - MiningToolAsteroidBeltId = state.MiningToolAsteroidBeltKey ?? "", + MiningToolAsteroidBeltKey = state.MiningToolAsteroidBeltKey ?? "", MiningToolAsteroidIndex = state.MiningToolAsteroidIndex, MiningToolRange = state.MiningToolRange, ThrusterAxis = state.ThrusterAxis, diff --git a/Aetheria.State/Documents/AetheriaRuntimeStateDocuments.cs b/Aetheria.State/Documents/AetheriaRuntimeStateDocuments.cs index 5aa1c5bcc..78c348545 100644 --- a/Aetheria.State/Documents/AetheriaRuntimeStateDocuments.cs +++ b/Aetheria.State/Documents/AetheriaRuntimeStateDocuments.cs @@ -818,7 +818,7 @@ public sealed class AetheriaBehaviorStateSnapshot public double AetherDriveThrustDirectionY { get; set; } [Key(31)] - public string ResourceScannerTargetBodyId { get; set; } = ""; + public string ResourceScannerTargetBodyKey { get; set; } = ""; [Key(32)] public int ResourceScannerAsteroidIndex { get; set; } = -1; @@ -836,7 +836,7 @@ public sealed class AetheriaBehaviorStateSnapshot public double ResourceScannerScanDuration { get; set; } [Key(37)] - public string MiningToolAsteroidBeltId { get; set; } = ""; + public string MiningToolAsteroidBeltKey { get; set; } = ""; [Key(38)] public int MiningToolAsteroidIndex { get; set; } = -1; diff --git a/Aetheria.State/README.md b/Aetheria.State/README.md index 52bec2192..15b482e04 100644 --- a/Aetheria.State/README.md +++ b/Aetheria.State/README.md @@ -114,9 +114,10 @@ resolver are deleted from the simulation shell. Run checkpoint commit DTOs carry typed `OrbitKey`, `ParentOrbitKey`, and `BodyKey` only for zone orbit/body snapshots. The old pending-command `OrbitLegacyId`, `ParentLegacyId`, and `BodyLegacyId` fallback fields are -deleted. Behavior-state runtime commits carry typed body keys for resource -scanner targets and mining tool asteroid belts; the old raw body ID commit -fields are deleted. +deleted. Behavior-state runtime commits and readback snapshots carry typed +body-key fields for resource scanner targets and mining tool asteroid belts; +the old raw body ID commit/readback field names are deleted. Unity still parses +those body keys into GUIDs only at the current `Zone` body runtime boundary. The package runtime catalog snapshot indexes items by canonical item key; Unity gameplay, HUD, inventory, trade, ship, and zone helper lookups use `ItemKey` directly instead of deriving `ItemId` and searching by legacy GUID. diff --git a/Assets/Scripts/Gameplay/ActionGameManager.cs b/Assets/Scripts/Gameplay/ActionGameManager.cs index 63ea74426..ead3a6712 100644 --- a/Assets/Scripts/Gameplay/ActionGameManager.cs +++ b/Assets/Scripts/Gameplay/ActionGameManager.cs @@ -349,21 +349,16 @@ public class ActionGameManager : MonoBehaviour return instance; } - private static Guid ParseLegacyGuidFromReferenceKey(string key, string documentName) + private static Guid ParseBodyGuidFromKey(string bodyKey) { - var legacyId = ParseLegacyIdFromReferenceKey(key, documentName); - return Guid.TryParse(legacyId, out var id) ? id : Guid.Empty; - } + if (string.IsNullOrWhiteSpace(bodyKey)) + return Guid.Empty; - private static string ParseLegacyIdFromReferenceKey(string key, string documentName) - { - if (string.IsNullOrWhiteSpace(key)) - return ""; - - var prefix = $"{documentName}:legacy:"; - return key.StartsWith(prefix, StringComparison.OrdinalIgnoreCase) - ? key.Substring(prefix.Length) - : key; + const string bodyPrefix = "aetheria.body:legacy:"; + var runtimeBodyId = bodyKey.StartsWith(bodyPrefix, StringComparison.OrdinalIgnoreCase) + ? bodyKey.Substring(bodyPrefix.Length) + : bodyKey; + return Guid.TryParse(runtimeBodyId, out var id) ? id : Guid.Empty; } public static Galaxy CurrentGalaxy; @@ -2820,7 +2815,7 @@ public class ActionGameManager : MonoBehaviour break; case ResourceScanner resourceScanner: resourceScanner.RestoreRuntimeState( - ParseLegacyGuidFromReferenceKey(behaviorState.ResourceScannerTargetBodyId, "aetheria.body"), + ParseBodyGuidFromKey(behaviorState.ResourceScannerTargetBodyKey), behaviorState.ResourceScannerAsteroidIndex, (float)behaviorState.ResourceScannerScanTime, (float)behaviorState.ResourceScannerRange, @@ -2829,7 +2824,7 @@ public class ActionGameManager : MonoBehaviour break; case MiningTool miningTool: miningTool.RestoreRuntimeState( - ParseLegacyGuidFromReferenceKey(behaviorState.MiningToolAsteroidBeltId, "aetheria.body"), + ParseBodyGuidFromKey(behaviorState.MiningToolAsteroidBeltKey), behaviorState.MiningToolAsteroidIndex, (float)behaviorState.MiningToolRange); break; diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeCatalogSnapshot.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeCatalogSnapshot.cs index d6d52748d..e020dae79 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeCatalogSnapshot.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeCatalogSnapshot.cs @@ -1211,13 +1211,13 @@ namespace GameCult.Aetheria.State.Unity double aetherDriveMaximumRpm, double aetherDriveThrustDirectionX, double aetherDriveThrustDirectionY, - string resourceScannerTargetBodyId, + string resourceScannerTargetBodyKey, int resourceScannerAsteroidIndex, double resourceScannerScanTime, double resourceScannerRange, double resourceScannerMinimumDensity, double resourceScannerScanDuration, - string miningToolAsteroidBeltId, + string miningToolAsteroidBeltKey, int miningToolAsteroidIndex, double miningToolRange, double thrusterAxis, @@ -1267,13 +1267,13 @@ namespace GameCult.Aetheria.State.Unity AetherDriveMaximumRpm = aetherDriveMaximumRpm; AetherDriveThrustDirectionX = aetherDriveThrustDirectionX; AetherDriveThrustDirectionY = aetherDriveThrustDirectionY; - ResourceScannerTargetBodyId = resourceScannerTargetBodyId; + ResourceScannerTargetBodyKey = resourceScannerTargetBodyKey; ResourceScannerAsteroidIndex = resourceScannerAsteroidIndex; ResourceScannerScanTime = resourceScannerScanTime; ResourceScannerRange = resourceScannerRange; ResourceScannerMinimumDensity = resourceScannerMinimumDensity; ResourceScannerScanDuration = resourceScannerScanDuration; - MiningToolAsteroidBeltId = miningToolAsteroidBeltId; + MiningToolAsteroidBeltKey = miningToolAsteroidBeltKey; MiningToolAsteroidIndex = miningToolAsteroidIndex; MiningToolRange = miningToolRange; ThrusterAxis = thrusterAxis; @@ -1324,13 +1324,13 @@ namespace GameCult.Aetheria.State.Unity public double AetherDriveMaximumRpm { get; } public double AetherDriveThrustDirectionX { get; } public double AetherDriveThrustDirectionY { get; } - public string ResourceScannerTargetBodyId { get; } + public string ResourceScannerTargetBodyKey { get; } public int ResourceScannerAsteroidIndex { get; } public double ResourceScannerScanTime { get; } public double ResourceScannerRange { get; } public double ResourceScannerMinimumDensity { get; } public double ResourceScannerScanDuration { get; } - public string MiningToolAsteroidBeltId { get; } + public string MiningToolAsteroidBeltKey { get; } public int MiningToolAsteroidIndex { get; } public double MiningToolRange { get; } public double ThrusterAxis { get; } diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeCatalogStore.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeCatalogStore.cs index 2e03036c6..97e850b61 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeCatalogStore.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeCatalogStore.cs @@ -987,13 +987,13 @@ namespace GameCult.Aetheria.State.Unity var aetherDriveMaximumRpm = ReadFieldDouble(ref reader, behaviorFields, 28); var aetherDriveThrustDirectionX = ReadFieldDouble(ref reader, behaviorFields, 29); var aetherDriveThrustDirectionY = ReadFieldDouble(ref reader, behaviorFields, 30); - var resourceScannerTargetBodyId = ReadFieldString(ref reader, behaviorFields, 31); + var resourceScannerTargetBodyKey = ReadFieldString(ref reader, behaviorFields, 31); var resourceScannerAsteroidIndex = ReadFieldInt32(ref reader, behaviorFields, 32); var resourceScannerScanTime = ReadFieldDouble(ref reader, behaviorFields, 33); var resourceScannerRange = ReadFieldDouble(ref reader, behaviorFields, 34); var resourceScannerMinimumDensity = ReadFieldDouble(ref reader, behaviorFields, 35); var resourceScannerScanDuration = ReadFieldDouble(ref reader, behaviorFields, 36); - var miningToolAsteroidBeltId = ReadFieldString(ref reader, behaviorFields, 37); + var miningToolAsteroidBeltKey = ReadFieldString(ref reader, behaviorFields, 37); var miningToolAsteroidIndex = ReadFieldInt32(ref reader, behaviorFields, 38); var miningToolRange = ReadFieldDouble(ref reader, behaviorFields, 39); var thrusterAxis = ReadFieldDouble(ref reader, behaviorFields, 40); @@ -1044,13 +1044,13 @@ namespace GameCult.Aetheria.State.Unity aetherDriveMaximumRpm, aetherDriveThrustDirectionX, aetherDriveThrustDirectionY, - resourceScannerTargetBodyId, + resourceScannerTargetBodyKey, resourceScannerAsteroidIndex, resourceScannerScanTime, resourceScannerRange, resourceScannerMinimumDensity, resourceScannerScanDuration, - miningToolAsteroidBeltId, + miningToolAsteroidBeltKey, miningToolAsteroidIndex, miningToolRange, thrusterAxis, diff --git a/docs/aetheria-perfect-machine-map.md b/docs/aetheria-perfect-machine-map.md index 90e386991..4e59f4624 100644 --- a/docs/aetheria-perfect-machine-map.md +++ b/docs/aetheria-perfect-machine-map.md @@ -1348,7 +1348,10 @@ First Aetheria surfaces to publish: - In progress: convert domain references from GUID/base-class patterns to typed record refs. Item instances, cargo inventory indexes, weapon ammo references, item-use behavior references, and runtime commit item/hull - surfaces now carry typed item keys; remaining broader simulation paths + surfaces now carry typed item keys. Runtime behavior resource-scanner and + mining-tool body references are named and serialized as typed body keys + through commit/readback state, with GUID parsing confined to the current + Unity `Zone` body runtime boundary. Remaining broader simulation paths still derive legacy GUIDs until those structures move to typed keys. - Done: delete the `ItemInstance.ItemId` legacy-GUID projection; diagnostics now report `ItemKey` so item instances expose only typed item-key identity. @@ -1752,6 +1755,10 @@ First Aetheria surfaces to publish: - `Aetheria.State.Verify` guards Unity runtime catalog lookup authority: package snapshots may expose typed-key lookup only, while legacy-ID lookup remains quarantined in canonical migration/catalog inspection APIs. +- `Aetheria.State.Verify` guards behavior body reference naming: + resource-scanner and mining-tool runtime state surfaces use `BodyKey` fields; + old `*BodyId` readback names and generic legacy reference parsers may not + return. - Unity batchmode compile returned cleanly after the runtime blueprint rename; live Unity source has no `EntityPack`, `ShipPack`, `OrbitalEntityPack`, `ZonePack`, `PackedContents`, `PackZone`, `EntitySerializer.Pack`, or