diff --git a/.voidbot/state/aetheria.cc b/.voidbot/state/aetheria.cc index 0992fc63e..6a64baad9 100644 Binary files a/.voidbot/state/aetheria.cc and b/.voidbot/state/aetheria.cc differ diff --git a/Aetheria.State.Verify/Program.cs b/Aetheria.State.Verify/Program.cs index e82c3793e..37d578a4b 100644 --- a/Aetheria.State.Verify/Program.cs +++ b/Aetheria.State.Verify/Program.cs @@ -10,6 +10,7 @@ var statePath = args.Length > 1 RequireGameplaySourcePurity(root); RequirePackageSerializerBoundary(root); RequireTypedPendingCommitKeys(root); +RequireTypedRuntimeFactionKeys(root); RequireEveRuntimeBootstrap(root); RequireNoRendererLocalConsole(root); RequireNoRendererLocalDebugPanels(root); @@ -622,6 +623,45 @@ static void RequireTypedPendingCommitKeys(string root) } } +static void RequireTypedRuntimeFactionKeys(string root) +{ + var checkedFiles = new[] + { + Path.Combine(root, "Assets", "Scripts", "ServerShared", "EntityConstructionBlueprintProjector.cs"), + Path.Combine(root, "Assets", "Scripts", "Gameplay", "ActionGameManager.cs") + }; + + var forbiddenSymbols = new[] + { + "public Guid Faction", + "blueprint.Faction =", + "blueprint.Faction)", + "blueprint.Faction,", + "blueprint.Faction;", + "ResolveFaction(blueprint.Faction", + "LegacyId(blueprint.Faction", + "ReferenceKey(blueprint.FactionKey", + "CorporationKey(entity.Faction?.ID", + "CorporationKey(pair.Key.ID", + "private static string CorporationKey" + }; + + var hits = checkedFiles + .Where(File.Exists) + .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()}") + .ToArray(); + + if (hits.Length > 0) + { + throw new InvalidOperationException( + "Runtime faction commits must use typed FactionKey authority, not legacy GUID fallback: " + + string.Join("; ", hits)); + } +} + static void RequireEveRuntimeBootstrap(string root) { var bootstrapPath = Path.Combine( diff --git a/Aetheria.State/README.md b/Aetheria.State/README.md index 790563a77..93f2d7028 100644 --- a/Aetheria.State/README.md +++ b/Aetheria.State/README.md @@ -105,10 +105,9 @@ item GUID fields. Unity runtime commit DTOs now carry typed `FactionKey` only for loadout entities, run entity snapshots, and faction relationship state. The old pending-command `CorporationLegacyId` fallback fields are deleted. -`EntityConstructionBlueprint` also carries `FactionKey` now. Loadout restore and -entity construction resolve factions by typed key first, with the old GUID -field kept as compatibility for construction callers that have not yet been -lowered. +`EntityConstructionBlueprint` also carries `FactionKey` only. Loadout restore, +entity construction, run entity snapshots, and faction relationship commits no +longer rebuild corporation references from legacy `Faction.ID` GUIDs. 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 diff --git a/Assets/Scripts/Gameplay/ActionGameManager.cs b/Assets/Scripts/Gameplay/ActionGameManager.cs index bc4c15120..63ea74426 100644 --- a/Assets/Scripts/Gameplay/ActionGameManager.cs +++ b/Assets/Scripts/Gameplay/ActionGameManager.cs @@ -235,7 +235,6 @@ public class ActionGameManager : MonoBehaviour blueprint.Name = entity.Name; blueprint.FactionKey = entity.FactionKey ?? ""; - blueprint.Faction = ParseLegacyGuidFromReferenceKey(blueprint.FactionKey, "aetheria.corporation"); blueprint.Hull = hull; blueprint.Equipment = CreateEquippableSlots(entity.Equipment); blueprint.CargoBays = CreateEquippableSlots(entity.CargoBays); @@ -277,7 +276,6 @@ public class ActionGameManager : MonoBehaviour blueprint.Name = entity.Name ?? ""; blueprint.FactionKey = entity.FactionKey ?? ""; - blueprint.Faction = ParseLegacyGuidFromReferenceKey(blueprint.FactionKey, "aetheria.corporation"); blueprint.Hull = hull; blueprint.Equipment = CreateEquippableSlots(entity.Equipment); blueprint.CargoBays = CreateEquippableSlots(entity.CargoBays); @@ -559,7 +557,7 @@ public class ActionGameManager : MonoBehaviour { Name = blueprint.Name ?? "", Kind = blueprint is ShipConstructionBlueprint ? "ship" : blueprint is OrbitalEntityConstructionBlueprint ? "orbital" : "entity", - FactionKey = ReferenceKey(blueprint.FactionKey ?? "", "aetheria.corporation", LegacyId(blueprint.Faction)), + FactionKey = blueprint.FactionKey ?? "", Hull = ProjectLoadoutItem(blueprint.Hull), Equipment = ProjectSlots(blueprint.Equipment), CargoBays = ProjectSlots(blueprint.CargoBays), @@ -687,7 +685,7 @@ public class ActionGameManager : MonoBehaviour .OrderBy(pair => pair.Key.ID) .Select(pair => new AetheriaRuntimeFactionRelationshipCommit { - FactionKey = CorporationKey(pair.Key.ID), + FactionKey = pair.Key.FactionKey ?? "", Relationship = pair.Value.ToString(), Standing = (int)pair.Value }) @@ -958,7 +956,7 @@ public class ActionGameManager : MonoBehaviour TractorPower = entity.TractorPower, Heatstroke = entity.Heatstroke, Hypothermia = entity.Hypothermia, - FactionKey = CorporationKey(entity.Faction?.ID ?? Guid.Empty), + FactionKey = entity.Faction?.FactionKey ?? "", HullItemKey = entity.Hull?.ItemKey ?? "", Equipment = ProjectEquippedSlots(entity.Equipment), CargoBays = ProjectEquippedSlots(entity.CargoBays), @@ -1396,16 +1394,6 @@ public class ActionGameManager : MonoBehaviour .ToArray() ?? Array.Empty(); } - private static string LegacyId(Guid id) - { - return id == Guid.Empty ? "" : id.ToString("D"); - } - - private static string CorporationKey(Guid id) - { - return id == Guid.Empty ? "" : $"aetheria.corporation:legacy:{id:D}"; - } - private static string OrbitKey(Guid id) { return id == Guid.Empty ? "" : $"aetheria.orbit:legacy:{id:D}"; @@ -1559,18 +1547,6 @@ public class ActionGameManager : MonoBehaviour .ToArray(); } - private static string ReferenceKey(string prefix, string legacyId) - { - return string.IsNullOrWhiteSpace(legacyId) ? "" : $"{prefix}:legacy:{legacyId}"; - } - - private static string ReferenceKey(string typedKey, string prefix, string legacyId) - { - return !string.IsNullOrWhiteSpace(typedKey) - ? typedKey - : ReferenceKey(prefix, legacyId); - } - private void OnApplicationQuit() => QueueRunCheckpoint("application-quit"); private void QueueRunCheckpoint(string reason) diff --git a/Assets/Scripts/ServerShared/EntityConstructionBlueprintProjector.cs b/Assets/Scripts/ServerShared/EntityConstructionBlueprintProjector.cs index edb11cd6b..98f6838fc 100644 --- a/Assets/Scripts/ServerShared/EntityConstructionBlueprintProjector.cs +++ b/Assets/Scripts/ServerShared/EntityConstructionBlueprintProjector.cs @@ -29,8 +29,7 @@ public static class EntityConstructionBlueprintProjector blueprint.Hull = entity.Hull; blueprint.Name = entity.Name; - blueprint.Faction = entity.Faction?.ID ?? Guid.Empty; - blueprint.FactionKey = entity.Faction?.FactionKey ?? CorporationKey(blueprint.Faction); + blueprint.FactionKey = entity.Faction?.FactionKey ?? ""; blueprint.Equipment = entity.Equipment.Select(e => (e.Position, e.EquippableItem)).ToArray(); blueprint.CargoBays = entity.CargoBays.Select(e => (e.Position, e.EquippableItem)).ToArray(); blueprint.DockingBays = entity.DockingBays.Select(e => (e.Position, e.EquippableItem)).ToArray(); @@ -116,12 +115,7 @@ public static class EntityConstructionBlueprintProjector { return galaxy == null ? null - : galaxy.ResolveFactionByKey(blueprint.FactionKey) ?? galaxy.ResolveFaction(blueprint.Faction); - } - - private static string CorporationKey(Guid id) - { - return id == Guid.Empty ? "" : $"aetheria.corporation:legacy:{id:D}"; + : galaxy.ResolveFactionByKey(blueprint.FactionKey); } } @@ -152,7 +146,6 @@ public abstract class EntityConstructionBlueprint public (int2 position, ItemInstance item)[][] DockingBayContents; public EntityConstructionBlueprint[] Children; public EntitySettings Settings; - public Guid Faction; public string FactionKey; public int[][] WeaponGroups; diff --git a/docs/aetheria-perfect-machine-map.md b/docs/aetheria-perfect-machine-map.md index 531af90f3..ed26b833b 100644 --- a/docs/aetheria-perfect-machine-map.md +++ b/docs/aetheria-perfect-machine-map.md @@ -1007,9 +1007,10 @@ First Aetheria surfaces to publish: decide generated sector factions or zone names. - Done: move entity faction restore to `Galaxy.ResolveFactionByKey` through `EntityConstructionBlueprint.FactionKey`, so typed loadout readback and - entity construction resolve corporation identity by typed key first. The - old blueprint `Faction` GUID remains compatibility/fallback for callers - that have not yet been lowered. + entity construction resolve corporation identity by typed key only. The + old blueprint `Faction` GUID compatibility field is deleted, and runtime + entity/faction-relationship commits no longer rebuild faction keys from + legacy `Faction.ID` GUIDs. - Done: move package and canonical manufacturer/corporation/name-file lookup to typed keys (`ManufacturerKey`, `CorporationKey`, `GeonameFileKey`, and `NameFileKey`), and move loadout manufacturer-distance weighting to @@ -1731,6 +1732,9 @@ First Aetheria surfaces to publish: `AetheriaRuntimePendingCultCacheStore`, `AetheriaRuntimeStateCommitDocument`, and `AetheriaRuntimeEveCommandDocument` until CultLib generated serializers become the Unity runtime owner. +- `Aetheria.State.Verify` also guards runtime faction identity ownership: + construction blueprints cannot carry a legacy faction GUID, and runtime + entity/faction commits cannot rebuild `FactionKey` from `Faction.ID`. - Unity batchmode compile returned cleanly after the runtime blueprint rename; live Unity source has no `EntityPack`, `ShipPack`, `OrbitalEntityPack`, `ZonePack`, `PackedContents`, `PackZone`, `EntitySerializer.Pack`, or