From 87793044999446b618d7f35738171708e4aed221 Mon Sep 17 00:00:00 2001
From: Meta Vens
Date: Sun, 18 Oct 2026 17:28:36 +0200
Subject: [PATCH 001/916] Galaxy generation refuses seed 0: delete the clock
fallback and the seed defaults
GalaxyStage.SeedFrom is the one minter of a run's seed; both generation
constructors now take progressCallback and seed without defaults and throw
ArgumentOutOfRangeException on zero instead of reading the clock.
Co-Authored-By: Claude Sonnet 5.5
---
Assets/Scripts/ServerShared/Galaxy.cs | 12 ++++++------
tests/Aetheria.Shared.Tests/RunStartTests.cs | 10 ++++++++++
2 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/Assets/Scripts/ServerShared/Galaxy.cs b/Assets/Scripts/ServerShared/Galaxy.cs
index 0b2f71387..b2d1e5dd0 100644
--- a/Assets/Scripts/ServerShared/Galaxy.cs
+++ b/Assets/Scripts/ServerShared/Galaxy.cs
@@ -96,15 +96,15 @@ public class Galaxy
SectorBackgroundSettings background,
CultCache cache,
Action log,
- Action progressCallback = null,
- uint seed = 0)
+ Action progressCallback,
+ uint seed)
{
_cache = cache;
IsPrelude = false;
Background = background;
Log = log;
var factions = cache.GetAll();
- Seed = seed == 0 ? (uint) (DateTime.Now.Ticks % uint.MaxValue) : seed;
+ Seed = seed != 0 ? seed : throw new ArgumentOutOfRangeException(nameof(seed), "a generated galaxy takes its run's seed from GalaxyStage, never zero");
var random = new Random(Seed);
Factions = factions.OrderBy(x => random.NextFloat()).Take(settings.MegaCount).ToArray();
foreach (var f in Factions) FactionRelationships[f] = FactionRelationship.Neutral;
@@ -163,15 +163,15 @@ public class Galaxy
PlayerSettings playerSettings,
DirectoryInfo narrativeDirectory,
Action log,
- Action progressCallback = null,
- uint seed = 0)
+ Action progressCallback,
+ uint seed)
{
_cache = cache;
IsPrelude = true;
Background = background;
Log = log;
- Seed = seed == 0 ? (uint) (DateTime.Now.Ticks % uint.MaxValue) : seed;
+ Seed = seed != 0 ? seed : throw new ArgumentOutOfRangeException(nameof(seed), "a generated galaxy takes its run's seed from GalaxyStage, never zero");
var random = new Random(Seed);
var factions = new List();
diff --git a/tests/Aetheria.Shared.Tests/RunStartTests.cs b/tests/Aetheria.Shared.Tests/RunStartTests.cs
index efedc20dd..7c22bb911 100644
--- a/tests/Aetheria.Shared.Tests/RunStartTests.cs
+++ b/tests/Aetheria.Shared.Tests/RunStartTests.cs
@@ -115,6 +115,16 @@ public sealed partial class RunStartTests : IDisposable
private const float Freezing = 273.15f;
+ // One minter: a generated galaxy never reads the clock, so seed 0 is refused by both generation constructors.
+ [Fact]
+ public void AGeneratedGalaxyRefusesSeedZero()
+ {
+ Assert.Throws(() =>
+ new Galaxy(new SectorGenerationSettings(), new SectorBackgroundSettings(), _cache, _ => { }, null, 0));
+ Assert.Throws(() =>
+ new Galaxy(new TutorialGenerationSettings(), new SectorBackgroundSettings(), _cache, new PlayerSettings(), new DirectoryInfo(_root), _ => { }, null, 0));
+ }
+
// A main-sector galaxy: each station's gear must come from manufacturers its faction can reach, the makers its
// allegiance names, present in the galaxy or not.
private Galaxy MainSectorGalaxy()
From 020dc58a812c04d6e8fb983d32d1bf0a1d3095ee Mon Sep 17 00:00:00 2001
From: Meta Vens
Date: Sun, 18 Oct 2026 17:29:17 +0200
Subject: [PATCH 002/916] The run's seed rides the save: SavedGame key 14,
written by Capture, read by Continue
Galaxy.Seed on a continued run is the saved seed instead of zero. A save
written before run-seed decodes Seed 0.
Co-Authored-By: Claude Sonnet 5.5
---
Assets/Scripts/ServerShared/Galaxy.cs | 5 ++-
Assets/Scripts/ServerShared/GalaxyStage.cs | 3 +-
Assets/Scripts/ServerShared/SavedGame.cs | 8 +++-
.../DemoTerminusTests.cs | 2 +
tests/Aetheria.Shared.Tests/RunSaveTests.cs | 37 +++++++++++++++++++
5 files changed, 51 insertions(+), 4 deletions(-)
diff --git a/Assets/Scripts/ServerShared/Galaxy.cs b/Assets/Scripts/ServerShared/Galaxy.cs
index b2d1e5dd0..e9e75b239 100644
--- a/Assets/Scripts/ServerShared/Galaxy.cs
+++ b/Assets/Scripts/ServerShared/Galaxy.cs
@@ -28,8 +28,8 @@ public class Galaxy
private Action Log { get; }
public bool IsPrelude { get; }
- // The seed this galaxy was generated at, which also seeds its run's item draws (RunStart); zero for a galaxy
- // restored from a save.
+ // The run's seed, minted once by GalaxyStage.SeedFrom and carried by the save (SavedGame.Seed). It seeds
+ // generation, the run's item draws (RunStart) and the zone's drop dice (Zone.DropSeed).
public uint Seed { get; }
private GalaxyZone[] _exitPath;
@@ -51,6 +51,7 @@ public class Galaxy
_cache = cultCache;
Log = log;
Background = savedGame.Background;
+ Seed = savedGame.Seed;
Factions = savedGame.Factions.Select(faction => cultCache.Get(faction)).ToArray();
for (var i = 0; i < Factions.Length; i++)
diff --git a/Assets/Scripts/ServerShared/GalaxyStage.cs b/Assets/Scripts/ServerShared/GalaxyStage.cs
index cd8feefed..a93e25f89 100644
--- a/Assets/Scripts/ServerShared/GalaxyStage.cs
+++ b/Assets/Scripts/ServerShared/GalaxyStage.cs
@@ -46,7 +46,8 @@ public sealed class GalaxyStage
_clock = clock ?? (() => (uint) (DateTime.Now.Ticks % uint.MaxValue));
}
- // The seed this generation runs at, never zero: the scenario's, or the clock's when the scenario's is zero.
+ // The run's one minter: the scenario's seed, or the clock's when the scenario's is zero, never zero. Galaxy carries
+ // what it mints and SavedGame keeps it, so Continue rolls the same drops.
public uint Seed { get; private set; }
internal void SeedFrom(Scenario scenario)
diff --git a/Assets/Scripts/ServerShared/SavedGame.cs b/Assets/Scripts/ServerShared/SavedGame.cs
index ba819e6ec..1758074fa 100644
--- a/Assets/Scripts/ServerShared/SavedGame.cs
+++ b/Assets/Scripts/ServerShared/SavedGame.cs
@@ -50,6 +50,11 @@ public class SavedGame
[Key(13)]
public int Credits;
+
+ // The run's seed (Galaxy.Seed), minted once by GalaxyStage.SeedFrom. Written only by RunSave.Capture and read only
+ // by Galaxy's save constructor; 0 in a save written before run-seed, which then rolls name-only drops.
+ [Key(14)]
+ public uint Seed;
}
// The run's lifecycle over the run store. Only Commit creates SavedGame, SavedZone and ProvenanceLedger records;
@@ -79,7 +84,8 @@ public static class RunSave
Exit = Array.IndexOf(galaxy.Zones, galaxy.Exit),
IsTutorial = galaxy.IsPrelude,
ActionBarBindings = actionBar,
- Credits = credits
+ Credits = credits,
+ Seed = galaxy.Seed
};
// A zone generated earlier but not loaded this session has no live Contents; its packed contents carry over.
diff --git a/tests/Aetheria.Shared.Tests/DemoTerminusTests.cs b/tests/Aetheria.Shared.Tests/DemoTerminusTests.cs
index ae1895e75..54f46a57c 100644
--- a/tests/Aetheria.Shared.Tests/DemoTerminusTests.cs
+++ b/tests/Aetheria.Shared.Tests/DemoTerminusTests.cs
@@ -51,6 +51,8 @@ public sealed partial class RunStartTests
var (game, zones) = RunSave.Capture(_cache, galaxy, arena, staged.Player, new SavedActionBarBinding[0], 0);
RunSave.Commit(_cache, game, zones, _items.Lots);
var restored = new Galaxy(_cache, _cache.GetGlobal(), _ => { });
+ Assert.NotEqual(0u, galaxy.Seed);
+ Assert.Equal(galaxy.Seed, restored.Seed);
Dictionary Standing(Galaxy g) => g.Factions.ToDictionary(faction => faction.Name, faction => g.FactionRelationships[faction]);
Assert.Equal(new Dictionary
diff --git a/tests/Aetheria.Shared.Tests/RunSaveTests.cs b/tests/Aetheria.Shared.Tests/RunSaveTests.cs
index 3bd075724..1320b7ddd 100644
--- a/tests/Aetheria.Shared.Tests/RunSaveTests.cs
+++ b/tests/Aetheria.Shared.Tests/RunSaveTests.cs
@@ -170,6 +170,43 @@ public sealed class RunSaveTests : IDisposable
Assert.Equal(4242, cache.GetGlobal().Credits);
}
+ // The run's seed rides the save: Continue restores it, Capture writes it back, and a save from before run-seed
+ // restores zero.
+ [Fact]
+ public void TheRunSeedRidesTheSave()
+ {
+ using (var cache = Open())
+ {
+ var game = Game(cache);
+ game.Seed = 0xC0FFEEu;
+ RunSave.Commit(cache, game, Zones(2, StageZoneContents(cache), 0), new ProvenanceLedger());
+ }
+
+ using (var cache = Open())
+ {
+ var galaxy = new Galaxy(cache, cache.GetGlobal(), _ => { });
+ Assert.Equal(0xC0FFEEu, galaxy.Seed);
+ var itemManager = new ItemManager(cache, new ProvenanceLedger(), TestSettings(), _ => { });
+ galaxy.Zones[0].Contents = new Zone(itemManager, new PlanetSettings(), new ZonePack(), galaxy.Zones[0], galaxy);
+ var (game, zones) = RunSave.Capture(cache, galaxy, galaxy.Zones[0].Contents, null, new SavedActionBarBinding[0], 0);
+ Assert.Equal(0xC0FFEEu, game.Seed);
+ RunSave.Commit(cache, game, zones, RunSave.Lots(cache));
+ }
+
+ using (var cache = Open())
+ Assert.Equal(0xC0FFEEu, cache.GetGlobal().Seed);
+
+ // A save written before run-seed holds no seed, and continues on name-only drops.
+ using (var cache = Open())
+ RunSave.Commit(cache, Game(cache), Zones(2, StageZoneContents(cache), 0), new ProvenanceLedger());
+
+ using (var cache = Open())
+ {
+ Assert.Equal(0u, cache.GetGlobal().Seed);
+ Assert.Equal(0u, new Galaxy(cache, cache.GetGlobal(), _ => { }).Seed);
+ }
+ }
+
[Fact]
public void ClearRemovesEveryRunRecord()
{
From f23d3c654204ccbebed90995883ab8e6976f8351 Mon Sep 17 00:00:00 2001
From: Meta Vens
Date: Sun, 18 Oct 2026 17:30:50 +0200
Subject: [PATCH 003/916] Drops roll on the run's seed: Zone.DropSeed feeds the
loot and mine dice
DropSeed = CombatSeed ^ Mix(Galaxy.Seed), derived at construction. A zone with
no galaxy, or a restored seed of 0, keeps its dice bit for bit; CombatSeed
still roots shot, patrol and range-sample dice. RunSeedFixture builds a test
zone's galaxy through RunSave.Commit and the Continue constructor.
Co-Authored-By: Claude Sonnet 5.5
---
Assets/Scripts/ServerShared/FireControl.cs | 4 +--
Assets/Scripts/ServerShared/Zone.cs | 9 +++--
tests/Aetheria.Shared.Tests/LootTests.cs | 33 +++++++++++++++++--
tests/Aetheria.Shared.Tests/MineTests.cs | 28 +++++++++++++---
tests/Aetheria.Shared.Tests/RunSaveTests.cs | 9 ++++-
tests/Aetheria.Shared.Tests/RunSeedFixture.cs | 26 +++++++++++++++
6 files changed, 98 insertions(+), 11 deletions(-)
create mode 100644 tests/Aetheria.Shared.Tests/RunSeedFixture.cs
diff --git a/Assets/Scripts/ServerShared/FireControl.cs b/Assets/Scripts/ServerShared/FireControl.cs
index 5e0a0dcc5..5ea06f455 100644
--- a/Assets/Scripts/ServerShared/FireControl.cs
+++ b/Assets/Scripts/ServerShared/FireControl.cs
@@ -775,7 +775,7 @@ public static class FireControl
// Lays a mine for a mine layer: freezes the payload as evaluated now (stats, the item's blast radius, the
// layer and its faction) and hands the body to Zone.Lay, the one adder. It launches at the shooter's velocity
// plus the mount direction turned by a dice angle within +-Spread/2, times Velocity; the dice are the mine's
- // own (zone seed, MineStream, body id), so no other roll is perturbed. No target, no PendingShot, no price:
+ // own (the zone's DropSeed, MineStream, body id), so no other roll is perturbed. No target, no PendingShot, no price:
// InstantWeapon has already paid. A layer whose item has no blast radius lays nothing.
public static void Lay(Weapon weapon, EquippedItem item, Entity source)
{
@@ -789,7 +789,7 @@ public static class FireControl
var id = zone.NextBodyId();
var half = weapon.Spread / 2f;
- var angle = radians(SimulationDice.For(zone.CombatSeed, SimulationDice.MineStream, id.Value).NextFloat(-half, half));
+ var angle = radians(SimulationDice.For(zone.DropSeed, SimulationDice.MineStream, id.Value).NextFloat(-half, half));
var s = sin(angle);
var c = cos(angle);
var mount = MountDirection(item).xz;
diff --git a/Assets/Scripts/ServerShared/Zone.cs b/Assets/Scripts/ServerShared/Zone.cs
index 4db63be46..719c37e6f 100644
--- a/Assets/Scripts/ServerShared/Zone.cs
+++ b/Assets/Scripts/ServerShared/Zone.cs
@@ -126,11 +126,15 @@ public class Zone
// of touching a shared stream.
public uint CombatSeed { get; }
+ // The zone's drop dice (loot and mine scatter): CombatSeed mixed with its run's seed (ruling loot-seed-in-save), so a
+ // new game drops differently and a reloaded save repeats. Mix(0) is 0, so a zone with no galaxy rolls on CombatSeed.
+ public uint DropSeed { get; }
+
// The one source of floating item and mine ids: zone-scoped, from 1, never reused. Runtime state, not saved.
private uint _lastBodyId;
public FloatingBodyId NextBodyId() => new FloatingBodyId(++_lastBodyId);
- // The death ordinal of the loot dice: the nth death in this zone rolls on SimulationDice.For(CombatSeed, LootStream, n).
+ // The death ordinal of the loot dice: the nth death in this zone rolls on SimulationDice.For(DropSeed, LootStream, n).
private uint _deaths;
// The zone-scoped agent ordinal, from 1, never reused: the key of a pilot's own dice.
@@ -152,6 +156,7 @@ public class Zone
Settings = settings;
_orbitPositionAt = OrbitPositionAt;
CombatSeed = galaxyZone?.Name.StableHash() ?? 1337u;
+ DropSeed = CombatSeed ^ SimulationDice.Mix(galaxy?.Seed ?? 0u);
var cache = itemManager.ItemData;
// Cut 5, 5.6 (docs/fire-control-cut.md, Soul finding 7; operator ruling Q3): death removes the ship,
@@ -452,7 +457,7 @@ public class Zone
private void DropLoot(Entity dead)
{
var settings = _itemManager.GameplaySettings;
- var random = SimulationDice.For(CombatSeed, SimulationDice.LootStream, ++_deaths);
+ var random = SimulationDice.For(DropSeed, SimulationDice.LootStream, ++_deaths);
var at = new float2(dead.Position.x, dead.Position.z);
float2 Heading() { var angle = random.NextFloat() * 2f * PI; return float2(cos(angle), sin(angle)); }
foreach (var equipped in dead.Equipment.ToArray())
diff --git a/tests/Aetheria.Shared.Tests/LootTests.cs b/tests/Aetheria.Shared.Tests/LootTests.cs
index f0b52f4ce..ae47f6b32 100644
--- a/tests/Aetheria.Shared.Tests/LootTests.cs
+++ b/tests/Aetheria.Shared.Tests/LootTests.cs
@@ -61,7 +61,7 @@ public sealed class LootTests : IDisposable
}
private Lab Build(string zoneName = "Loot", float probability = .5f, float lifetime = 30f, float velocity = 25f,
- bool well = false, float spread = 0f)
+ bool well = false, float spread = 0f, uint? runSeed = null)
{
var settings = new GameplaySettings
{
@@ -104,6 +104,7 @@ public sealed class LootTests : IDisposable
cache.Upsert(new CargoBayData { Name = "Crate", Shape = new Shape(), InteriorShape = Solid(4, 4), Durability = 4 });
cache.Upsert(new SimpleCommodityData { Name = "Ore", Shape = Solid(1, 1), MaxStack = 100 });
cache.FlushAsync().Wait();
+ var galaxy = runSeed.HasValue ? RunSeedFixture.Continue(cache, zoneName, runSeed.Value) : null;
var ledger = new ProvenanceLedger();
for (var i = 1; i <= 9000; i++) ledger.Lots[i] = new Lot { Origin = new Attributed(), Quality = 1 };
@@ -111,7 +112,9 @@ public sealed class LootTests : IDisposable
var planets = new PlanetSettings();
var pack = new ZonePack { Radius = well ? 1000 : 0 };
if (well) WellFixture.Dig(cache, pack, planets, 300, 100);
- var zone = new Zone(items, planets, pack, new GalaxyZone { Name = zoneName, Owner = null }, null);
+ var zone = galaxy != null
+ ? new Zone(items, planets, pack, galaxy.Zones[0], galaxy)
+ : new Zone(items, planets, pack, new GalaxyZone { Name = zoneName, Owner = null }, null);
return new Lab { Items = items, Zone = zone };
}
@@ -209,6 +212,32 @@ public sealed class LootTests : IDisposable
Assert.True(Differ(dropsA, Released(first, count)));
}
+ private List<(string Item, float2 Position, float2 Velocity)> DropsAt(string zoneName, uint runSeed)
+ {
+ var lab = Build(zoneName, runSeed: runSeed);
+ Kill(Spawn(lab, float3(31, 0, -17)));
+ return Released(lab, 0);
+ }
+
+ // A new game rolls different drops from other games: the same ship, killed in the same zone, at another run seed.
+ [Fact]
+ public void ANewGameRollsDifferentDrops()
+ {
+ var one = DropsAt("Dice", 1);
+ Assert.True(one.Count > 2, "the fixture must drop enough for a draw to show");
+ Assert.True(Differ(one, DropsAt("Dice", 2)));
+ }
+
+ // Reloading one save repeats its drops, and the run's other zones still roll on their own names.
+ [Fact]
+ public void ReloadingASaveRepeatsItsDrops()
+ {
+ var first = DropsAt("Dice", 7);
+ Assert.True(first.Count > 2, "the fixture must drop enough for a draw to show");
+ AssertSameDrops(first, DropsAt("Dice", 7));
+ Assert.True(Differ(first, DropsAt("Other dice", 7)));
+ }
+
[Fact]
public void GearDropsByProbabilityCargoAlways()
{
diff --git a/tests/Aetheria.Shared.Tests/MineTests.cs b/tests/Aetheria.Shared.Tests/MineTests.cs
index a2deeb5cf..24269af1a 100644
--- a/tests/Aetheria.Shared.Tests/MineTests.cs
+++ b/tests/Aetheria.Shared.Tests/MineTests.cs
@@ -67,7 +67,7 @@ public sealed class MineTests : IDisposable
private Lab Build(float blast = 4f, float arming = 2f, float fuse = 2f, float life = 30f, float spread = 0f, float velocity = 0f,
float damage = 100f, float range = 1000f, float cooldown = 1000f, Faction layerFaction = null,
WeaponFuse? fuseKind = WeaponFuse.Proximity, bool well = false, float3? layerAt = null, int magazine = 100,
- float minRange = 0f)
+ float minRange = 0f, uint? runSeed = null)
{
var settings = new GameplaySettings
{
@@ -114,6 +114,7 @@ public sealed class MineTests : IDisposable
cache.Upsert(Gear("Shield", new ShieldData { Efficiency = Constant(1), EnergyUsage = Constant(1), Capacity = Constant(1000000), RefillDuration = Constant(.01f), RestoreDuration = Constant(.01f) }, 10));
cache.Upsert(Gear("TinyShield", new ShieldData { Efficiency = Constant(1), EnergyUsage = Constant(1), Capacity = Constant(.001f), RefillDuration = Constant(.01f), RestoreDuration = Constant(.01f) }, 10));
cache.FlushAsync().Wait();
+ var galaxy = runSeed.HasValue ? RunSeedFixture.Continue(cache, "Mines", runSeed.Value) : null;
var ledger = new ProvenanceLedger();
for (var i = 1; i <= 500; i++) ledger.Lots[i] = new Lot { Origin = new Attributed(), Quality = 1 };
@@ -121,7 +122,9 @@ public sealed class MineTests : IDisposable
var planets = new PlanetSettings();
var pack = new ZonePack { Radius = well ? 1000 : 0 };
if (well) WellFixture.Dig(cache, pack, planets, 300, 100);
- var zone = new Zone(items, planets, pack, new GalaxyZone { Name = "Mines", Owner = null }, null);
+ var zone = galaxy != null
+ ? new Zone(items, planets, pack, galaxy.Zones[0], galaxy)
+ : new Zone(items, planets, pack, new GalaxyZone { Name = "Mines", Owner = null }, null);
var lab = new Lab { Items = items, Zone = zone, Data = data, ItemData = cache.GetByName("Mine Layer") };
var layerRef = items.ItemData.RefOf(items.ItemData.GetByName("Layer"));
@@ -683,6 +686,23 @@ public sealed class MineTests : IDisposable
Assert.False(FireControl.Refuses(lab.Weapon, lab.Layer));
}
+ // A new game scatters its mines differently: the same lay, at another run seed, launches at another velocity.
+ [Fact]
+ public void ANewGameScattersMinesDifferently()
+ {
+ float2 LaunchAt(uint runSeed)
+ {
+ var lab = Build(spread: 40f, velocity: 5f, layerFaction: A, runSeed: runSeed);
+ var atLay = default(KinematicBody);
+ using var sub = lab.Zone.Mines.ObserveAdd().Subscribe(e => atLay = e.Value.Body);
+ lab.Layer.Direction = normalize(float2(1, 2));
+ LayOne(lab);
+ return atLay.Velocity;
+ }
+
+ Assert.NotEqual(LaunchAt(1), LaunchAt(2));
+ }
+
[Fact]
public void TheLaunchAngleIsTheMinesOwnDice()
{
@@ -697,9 +717,9 @@ public sealed class MineTests : IDisposable
var mine = LayOne(lab);
- // The angle is the first draw of (zone seed, mine stream, body id), in +-Spread/2, turning the mount
+ // The angle is the first draw of (the zone's DropSeed, mine stream, body id), in +-Spread/2, turning the mount
// counterclockwise in the (x, y) plane.
- var degreesTurned = SimulationDice.For(lab.Zone.CombatSeed, SimulationDice.MineStream, mine.Id.Value).NextFloat(-20f, 20f);
+ var degreesTurned = SimulationDice.For(lab.Zone.DropSeed, SimulationDice.MineStream, mine.Id.Value).NextFloat(-20f, 20f);
var a = radians(degreesTurned);
var m = FireControl.MountDirection(lab.WeaponItem).xz;
var turned = float2(m.x * cos(a) - m.y * sin(a), m.x * sin(a) + m.y * cos(a));
diff --git a/tests/Aetheria.Shared.Tests/RunSaveTests.cs b/tests/Aetheria.Shared.Tests/RunSaveTests.cs
index 1320b7ddd..7e32c9928 100644
--- a/tests/Aetheria.Shared.Tests/RunSaveTests.cs
+++ b/tests/Aetheria.Shared.Tests/RunSaveTests.cs
@@ -188,6 +188,8 @@ public sealed class RunSaveTests : IDisposable
Assert.Equal(0xC0FFEEu, galaxy.Seed);
var itemManager = new ItemManager(cache, new ProvenanceLedger(), TestSettings(), _ => { });
galaxy.Zones[0].Contents = new Zone(itemManager, new PlanetSettings(), new ZonePack(), galaxy.Zones[0], galaxy);
+ // The zone's drop dice are its name's seed mixed with the run's.
+ Assert.Equal("Zone 0".StableHash() ^ SimulationDice.Mix(0xC0FFEEu), galaxy.Zones[0].Contents.DropSeed);
var (game, zones) = RunSave.Capture(cache, galaxy, galaxy.Zones[0].Contents, null, new SavedActionBarBinding[0], 0);
Assert.Equal(0xC0FFEEu, game.Seed);
RunSave.Commit(cache, game, zones, RunSave.Lots(cache));
@@ -203,7 +205,12 @@ public sealed class RunSaveTests : IDisposable
using (var cache = Open())
{
Assert.Equal(0u, cache.GetGlobal().Seed);
- Assert.Equal(0u, new Galaxy(cache, cache.GetGlobal(), _ => { }).Seed);
+ var galaxy = new Galaxy(cache, cache.GetGlobal(), _ => { });
+ Assert.Equal(0u, galaxy.Seed);
+ var itemManager = new ItemManager(cache, new ProvenanceLedger(), TestSettings(), _ => { });
+ var zone = new Zone(itemManager, new PlanetSettings(), new ZonePack(), galaxy.Zones[0], galaxy);
+ Assert.Equal("Zone 0".StableHash(), zone.CombatSeed);
+ Assert.Equal(zone.CombatSeed, zone.DropSeed);
}
}
diff --git a/tests/Aetheria.Shared.Tests/RunSeedFixture.cs b/tests/Aetheria.Shared.Tests/RunSeedFixture.cs
new file mode 100644
index 000000000..0152584b7
--- /dev/null
+++ b/tests/Aetheria.Shared.Tests/RunSeedFixture.cs
@@ -0,0 +1,26 @@
+using System.Collections.Generic;
+using GameCult.Caching;
+
+// A fixture's run at a fixed seed, restored as Continue restores it: one zone, committed through RunSave.Commit and
+// read back by the Galaxy save constructor, so a test's galaxy carries the seed the way a real run's does.
+internal static class RunSeedFixture
+{
+ public static Galaxy Continue(CultCache cache, string zoneName, uint seed)
+ {
+ var game = new SavedGame
+ {
+ Seed = seed,
+ Factions = new CultRecordRef[0],
+ Relationships = new FactionRelationship[0],
+ HomeZones = new Dictionary(),
+ BossZones = new Dictionary(),
+ DiscoveredZones = new[] { 0 },
+ ActionBarBindings = new SavedActionBarBinding[0],
+ Entrance = 0,
+ Exit = -1
+ };
+ var zone = new SavedZone { Name = zoneName, AdjacentZones = new int[0], Factions = new int[0], Owner = -1 };
+ RunSave.Commit(cache, game, new[] { zone }, new ProvenanceLedger());
+ return new Galaxy(cache, cache.GetGlobal(), _ => { });
+ }
+}
From 727c4096595cf589658c59d83a8fcf226b1b1888 Mon Sep 17 00:00:00 2001
From: Meta Vens
Date: Sun, 18 Oct 2026 17:33:11 +0200
Subject: [PATCH 004/916] Pin the dice of a zone without a run seed at their
pre-run-seed values
A zone with no galaxy and a zone of a save written before run-seed (seed 0)
drop the items and scatter the mines they did at eb27ced1; values computed
at that base.
Co-Authored-By: Claude Sonnet 5.5
---
tests/Aetheria.Shared.Tests/LootTests.cs | 25 ++++++++++++++++++
tests/Aetheria.Shared.Tests/MineTests.cs | 32 ++++++++++++++++--------
2 files changed, 47 insertions(+), 10 deletions(-)
diff --git a/tests/Aetheria.Shared.Tests/LootTests.cs b/tests/Aetheria.Shared.Tests/LootTests.cs
index ae47f6b32..e8a5016a7 100644
--- a/tests/Aetheria.Shared.Tests/LootTests.cs
+++ b/tests/Aetheria.Shared.Tests/LootTests.cs
@@ -238,6 +238,31 @@ public sealed class LootTests : IDisposable
Assert.True(Differ(first, DropsAt("Other dice", 7)));
}
+ // Pinned at eb27ced1, before run-seed: a zone with no galaxy, and a zone of a save written before run-seed (seed 0),
+ // roll on the zone's name alone and drop exactly what they dropped.
+ [Theory]
+ [InlineData(false)]
+ [InlineData(true)]
+ public void AZoneWithoutARunSeedKeepsItsDrops(bool restoredFromAnOldSave)
+ {
+ var drops = restoredFromAnOldSave ? DropsAt("Dice", 0) : Released(KillInNewLab("Dice"), 0);
+ Assert.Equal(new[] { "Spare", "Orex7", "Spare" }, drops.Select(d => d.Item));
+ Assert.All(drops, d => Assert.Equal(new float2(31, -17), d.Position));
+ var velocities = new[] { float2(-17.977364f, 17.372805f), float2(-5.908107f, 24.291857f), float2(-24.228783f, -6.1616626f) };
+ for (var i = 0; i < velocities.Length; i++)
+ {
+ Assert.Equal(velocities[i].x, drops[i].Velocity.x, 3);
+ Assert.Equal(velocities[i].y, drops[i].Velocity.y, 3);
+ }
+ }
+
+ private Lab KillInNewLab(string zoneName)
+ {
+ var lab = Build(zoneName);
+ Kill(Spawn(lab, float3(31, 0, -17)));
+ return lab;
+ }
+
[Fact]
public void GearDropsByProbabilityCargoAlways()
{
diff --git a/tests/Aetheria.Shared.Tests/MineTests.cs b/tests/Aetheria.Shared.Tests/MineTests.cs
index 24269af1a..137d3f84a 100644
--- a/tests/Aetheria.Shared.Tests/MineTests.cs
+++ b/tests/Aetheria.Shared.Tests/MineTests.cs
@@ -690,19 +690,31 @@ public sealed class MineTests : IDisposable
[Fact]
public void ANewGameScattersMinesDifferently()
{
- float2 LaunchAt(uint runSeed)
- {
- var lab = Build(spread: 40f, velocity: 5f, layerFaction: A, runSeed: runSeed);
- var atLay = default(KinematicBody);
- using var sub = lab.Zone.Mines.ObserveAdd().Subscribe(e => atLay = e.Value.Body);
- lab.Layer.Direction = normalize(float2(1, 2));
- LayOne(lab);
- return atLay.Velocity;
- }
-
Assert.NotEqual(LaunchAt(1), LaunchAt(2));
}
+ private float2 LaunchAt(uint? runSeed)
+ {
+ var lab = Build(spread: 40f, velocity: 5f, layerFaction: A, runSeed: runSeed);
+ var atLay = default(KinematicBody);
+ using var sub = lab.Zone.Mines.ObserveAdd().Subscribe(e => atLay = e.Value.Body);
+ lab.Layer.Direction = normalize(float2(1, 2));
+ LayOne(lab);
+ return atLay.Velocity;
+ }
+
+ // Pinned at eb27ced1, before run-seed: a zone with no galaxy, and a zone of a save written before run-seed (seed 0),
+ // scatter their mines on the zone's name alone.
+ [Theory]
+ [InlineData(false)]
+ [InlineData(true)]
+ public void AZoneWithoutARunSeedKeepsItsMineScatter(bool restoredFromAnOldSave)
+ {
+ var velocity = LaunchAt(restoredFromAnOldSave ? 0u : (uint?) null);
+ Assert.Equal(3.2546253f, velocity.x, 3);
+ Assert.Equal(3.795711f, velocity.y, 3);
+ }
+
[Fact]
public void TheLaunchAngleIsTheMinesOwnDice()
{
From 47f834ea23b4c8939316972c9033b208e57c4cfb Mon Sep 17 00:00:00 2001
From: Meta Vens
Date: Sun, 18 Oct 2026 17:39:52 +0200
Subject: [PATCH 005/916] Pin all five pre-run-seed drops of the dice zone (the
first pin kept three)
Co-Authored-By: Claude Sonnet 5.5
---
tests/Aetheria.Shared.Tests/LootTests.cs | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/tests/Aetheria.Shared.Tests/LootTests.cs b/tests/Aetheria.Shared.Tests/LootTests.cs
index e8a5016a7..ecd65f8e1 100644
--- a/tests/Aetheria.Shared.Tests/LootTests.cs
+++ b/tests/Aetheria.Shared.Tests/LootTests.cs
@@ -246,9 +246,13 @@ public sealed class LootTests : IDisposable
public void AZoneWithoutARunSeedKeepsItsDrops(bool restoredFromAnOldSave)
{
var drops = restoredFromAnOldSave ? DropsAt("Dice", 0) : Released(KillInNewLab("Dice"), 0);
- Assert.Equal(new[] { "Spare", "Orex7", "Spare" }, drops.Select(d => d.Item));
+ Assert.Equal(new[] { "Spare", "Spare", "Spare", "Orex7", "Spare" }, drops.Select(d => d.Item));
Assert.All(drops, d => Assert.Equal(new float2(31, -17), d.Position));
- var velocities = new[] { float2(-17.977364f, 17.372805f), float2(-5.908107f, 24.291857f), float2(-24.228783f, -6.1616626f) };
+ var velocities = new[]
+ {
+ float2(-14.870228f, -20.096674f), float2(-4.9265895f, -24.509768f), float2(-17.977364f, 17.372805f),
+ float2(-5.908107f, 24.291857f), float2(-24.228783f, -6.1616626f)
+ };
for (var i = 0; i < velocities.Length; i++)
{
Assert.Equal(velocities[i].x, drops[i].Velocity.x, 3);
From 49853d3166bdeaaf1f784d447501eeff62efcf15 Mon Sep 17 00:00:00 2001
From: Meta Vens
Date: Sun, 18 Oct 2026 17:58:51 +0200
Subject: [PATCH 006/916] ProductBin: a binned product names its maker's line
and a floor; the mint draws above that floor
FactionProductData slot 7 Bin (schema id unchanged, additive as slot 6). Mint derives a bin's
distributions from its line on every lot, truncated by NextGaussianAbove (64 tries, then the cutoff).
Co-Authored-By: Claude Sonnet 5.5
---
Assets/Scripts/ServerShared/Extensions.cs | 15 ++
Assets/Scripts/ServerShared/FactionProduct.cs | 32 +++-
Assets/Scripts/ServerShared/ItemManager.cs | 19 +-
.../Aetheria.Shared.Tests/ProductBinTests.cs | 175 ++++++++++++++++++
4 files changed, 230 insertions(+), 11 deletions(-)
create mode 100644 tests/Aetheria.Shared.Tests/ProductBinTests.cs
diff --git a/Assets/Scripts/ServerShared/Extensions.cs b/Assets/Scripts/ServerShared/Extensions.cs
index 656e85ba2..97433a299 100644
--- a/Assets/Scripts/ServerShared/Extensions.cs
+++ b/Assets/Scripts/ServerShared/Extensions.cs
@@ -180,6 +180,21 @@ public static class Extensions
return mean + deviation * sqrt(-2 * log(u1)) * cos(2 * PI * u2);
}
+ // NextGaussian truncated below mean + floorDeviations * deviation: draws until one clears that cutoff, at most 64 times,
+ // then returns the cutoff itself. Exact for any reachable floor and bounded and deterministic per seed for an unreachable
+ // one. A binned product's fills and assembly (ProductBin). Callers clamp, as with NextGaussian.
+ public static float NextGaussianAbove(this ref Random random, float mean, float deviation, float floorDeviations)
+ {
+ var cutoff = mean + floorDeviations * deviation;
+ for (var tries = 0; tries < 64; tries++)
+ {
+ var draw = random.NextGaussian(mean, deviation);
+ if (draw >= cutoff) return draw;
+ }
+
+ return cutoff;
+ }
+
public static float NextUnbounded(this ref Random random) => 1 / (1 - random.NextFloat()) - 1;
public static float NextUnbounded(this ref Random random, float bias, float power, float ceiling) => 1 / (1 - pow(min(random.NextFloat(), ceiling), 1 - pow(clamp(bias,0,.99f), 1 / power))) - 1;
diff --git a/Assets/Scripts/ServerShared/FactionProduct.cs b/Assets/Scripts/ServerShared/FactionProduct.cs
index cdaed4f28..b9a3f0009 100644
--- a/Assets/Scripts/ServerShared/FactionProduct.cs
+++ b/Assets/Scripts/ServerShared/FactionProduct.cs
@@ -8,9 +8,9 @@ using GameCult.Caching;
using MessagePack;
using Newtonsoft.Json;
-// A manufacturer's branded variant of a generic design: its name, its flavor text, and how it builds each of
-// the design's roles. Which products exist is what a faction makes, so market segmentation and regional
-// progression are authored here rather than as duplicate item entries.
+// What a manufacturer sells of a generic design: its name, its flavor text, and either a line (how the maker builds each of the
+// design's roles) or a bin of one of its own lines (maker-design-tiers-allowed). Which products exist is what a faction makes, so
+// market segmentation and regional progression are authored here rather than as duplicate item entries.
[CultDocument("aetheria.factionproductdata", "1"), Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
public class FactionProductData
{
@@ -29,16 +29,21 @@ public class FactionProductData
[Inspectable, JsonProperty("roles"), Key(5)]
public List Roles = new List();
- // This line's own final test (maker-design-tiers-allowed): a binned or premium line is a better assembly as well as better
- // parts. Null assembles as its maker does.
+ // This line's own final test (maker-design-tiers-allowed): a premium line is a better assembly as well as better parts.
+ // Null assembles as its maker does. A binned product leaves it null and reads its line's.
[Inspectable, JsonProperty("assembly"), Key(6)]
public AssemblyDistribution Assembly;
+
+ // Set on a binned product: the line it bins and the floor above which it takes that line's output. A bin authors no Roles and
+ // no Assembly; the mint derives both from the line.
+ [Inspectable, JsonProperty("bin"), Key(7)]
+ public ProductBin Bin;
}
// How good this product's part is in one of its design's roles: a pseudo-gaussian distribution whose mean is
// the technology the manufacturer puts in and whose standard deviation is their quality control. A market
-// segment is a second product with a role pumped up; what makes that part better is the flavor text's to tell,
-// because a part here carries quality and nothing else.
+// segment is a bin of the line (ProductBin), not a second product with a role pumped up; what makes a part better is the
+// flavor text's to tell, because a part here carries quality and nothing else.
[MessagePackObject, JsonObject(MemberSerialization.OptIn)]
public class ProductRole
{
@@ -52,6 +57,19 @@ public class ProductRole
public float StandardDeviation = .15f;
}
+// A bin of one of the maker's lines (ruling maker-design-tiers-allowed): the line it bins (the same design and maker, itself
+// unbinned) and the floor, in standard deviations above the mean of each of the line's distributions, below which the bin
+// takes nothing. 0 is the top half of the line, .67 the top quarter.
+[MessagePackObject, JsonObject(MemberSerialization.OptIn)]
+public class ProductBin
+{
+ [Inspectable, JsonProperty("line"), Key(0)]
+ public CultRecordRef Line;
+
+ [Inspectable, JsonProperty("floor"), Key(1)]
+ public float Floor;
+}
+
// How well a maker puts the thing together: the technology and quality control of final assembly. A lot's own quality is drawn
// from it, and it is the ceiling on every role the lot fills. Defaults are a middling maker.
[MessagePackObject, JsonObject(MemberSerialization.OptIn)]
diff --git a/Assets/Scripts/ServerShared/ItemManager.cs b/Assets/Scripts/ServerShared/ItemManager.cs
index 12d45d101..b33b17224 100644
--- a/Assets/Scripts/ServerShared/ItemManager.cs
+++ b/Assets/Scripts/ServerShared/ItemManager.cs
@@ -121,6 +121,9 @@ public class ItemManager
// Builds one of a manufacturer's branded products (quality-is-assembly-over-supply-chain): the unit's own quality is its
// final assembly, drawn from the product's assembly distribution, else its maker's, else AssemblyDistribution's defaults,
// and each of the design's roles is filled with a part whose quality is drawn from the product's distribution for it.
+ // A binned product (maker-design-tiers-allowed) has no distributions of its own: it is its line's, derived here on every
+ // mint, with each draw (the assembly and every fill) truncated below the line's mean + Bin.Floor deviations. The lot is
+ // still the bin's: its Product, its title and so its brand.
public int CreateLot(FactionProductData product) => Mint(product, null);
// The same lot at a stated quality: the assembly and every role fill are that quality and nothing is drawn, so a staged
@@ -130,29 +133,37 @@ public class ItemManager
private int Mint(FactionProductData product, float? stated)
{
var design = ItemData.Get(product.Design);
- var assembly = product.Assembly ?? ItemData.Get(product.Manufacturer)?.Assembly ?? new AssemblyDistribution();
+ var line = product.Bin != null ? ItemData.Get(product.Bin.Line) : null;
+ if (product.Bin != null && line == null)
+ Log("A binned product names a line the catalog does not hold; it mints as a product with no roles of its own.");
+ var source = line ?? product;
+ var floor = line != null ? product.Bin.Floor : (float?) null;
+ var assembly = source.Assembly ?? ItemData.Get(product.Manufacturer)?.Assembly ?? new AssemblyDistribution();
var lot = new Lot
{
Design = ItemData.RefOf(design),
Origin = new Attributed { Faction = product.Manufacturer },
Product = ItemData.RefOf(product),
- Quality = stated ?? clamp(Random.NextGaussian(assembly.Mean, assembly.StandardDeviation), .01f, 1),
+ Quality = stated ?? clamp(Draw(assembly.Mean, assembly.StandardDeviation, floor), .01f, 1),
Roles = new List()
};
if (design.Roles != null)
foreach (var role in design.Roles)
{
- var build = product.Roles?.FirstOrDefault(b => b.Role == role.Name) ?? new ProductRole();
+ var build = source.Roles?.FirstOrDefault(b => b.Role == role.Name) ?? new ProductRole();
lot.Roles.Add(new RoleFill
{
Role = role.Name,
- Quality = stated ?? clamp(Random.NextGaussian(build.Mean, build.StandardDeviation), .01f, 1)
+ Quality = stated ?? clamp(Draw(build.Mean, build.StandardDeviation, floor), .01f, 1)
});
}
return Lots.Add(lot);
}
+ private float Draw(float mean, float deviation, float? floorDeviations) =>
+ floorDeviations is { } floor ? Random.NextGaussianAbove(mean, deviation, floor) : Random.NextGaussian(mean, deviation);
+
// No branded product: a lot attributed to maker (which may be unset) with no role fills, e.g. console `give`.
public int CreateLot(CraftedItemData design, CultRecordRef maker, float quality)
{
diff --git a/tests/Aetheria.Shared.Tests/ProductBinTests.cs b/tests/Aetheria.Shared.Tests/ProductBinTests.cs
new file mode 100644
index 000000000..44bbfe077
--- /dev/null
+++ b/tests/Aetheria.Shared.Tests/ProductBinTests.cs
@@ -0,0 +1,175 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using GameCult.Caching;
+using Xunit;
+
+// A bin is a product of its maker's line above a floor (aetheria-release, cut product-tiers; ruling maker-design-tiers-allowed):
+// the mint derives its distributions from the line on every lot, truncated below line mean + Floor deviations, and the lot is
+// still the bin's. Lots here come from CreateLot(product), the production mint, on the AssemblyFromMakerTests fixture.
+public sealed class ProductBinTests : IDisposable
+{
+ private readonly string _root = Path.Combine(Path.GetTempPath(), "aetheria-bins-" + Guid.NewGuid().ToString("N"));
+ private readonly CultCache _cache;
+ private readonly ItemManager _items;
+ private readonly CultRecordRef _lens;
+ private readonly List _log = new List();
+
+ public ProductBinTests()
+ {
+ Directory.CreateDirectory(_root);
+ _cache = AetheriaStores.Open(Path.Combine(_root, "Aetheria.cc"), catalogWritable: true);
+ var gear = _cache.Upsert(new GearData
+ {
+ Name = "Lensed", Hardpoint = HardpointType.Sensors, Shape = new Shape(), Price = 10,
+ Roles = { new ItemRole { Name = "lens" } }
+ });
+ _lens = new CultRecordRef(gear.Key);
+ _items = new ItemManager(_cache, new ProvenanceLedger(), RunSaveTests.TestSettings(), _log.Add) { Random = new CultMath.Random(7u) };
+ }
+
+ public void Dispose()
+ {
+ _cache.Dispose();
+ Directory.Delete(_root, true);
+ }
+
+ private static AssemblyDistribution A(float mean, float deviation) => new AssemblyDistribution { Mean = mean, StandardDeviation = deviation };
+
+ // A maker at assembly .6 +- .1 and a line of the Lensed design at lens .5 +- .1.
+ private FactionProductData Line(string name = "Line", float lensMean = .5f, float lensDeviation = .1f, AssemblyDistribution own = null, float makerMean = .6f)
+ {
+ var maker = _cache.Upsert(new Faction { Name = name + " Maker", Assembly = A(makerMean, .1f) });
+ _cache.Upsert(new FactionProductData
+ {
+ Name = name, Design = _lens, Manufacturer = maker, Assembly = own,
+ Roles = { new ProductRole { Role = "lens", Mean = lensMean, StandardDeviation = lensDeviation } }
+ });
+ return _cache.GetAll().Single(p => p.Name == name);
+ }
+
+ private FactionProductData Bin(FactionProductData line, string name, float floor)
+ {
+ _cache.Upsert(new FactionProductData
+ {
+ Name = name, Design = line.Design, Manufacturer = line.Manufacturer,
+ Bin = new ProductBin { Line = _cache.RefOf(line), Floor = floor }
+ });
+ return _cache.GetAll().Single(p => p.Name == name);
+ }
+
+ private Lot[] Mint(FactionProductData product, int count) =>
+ Enumerable.Range(0, count).Select(_ => _items.Lots[_items.CreateLot(product)]).ToArray();
+
+ private static float[] Fills(Lot[] lots) => lots.Select(l => l.Roles.Single().Quality).ToArray();
+
+ // Floor 0 is the top half of the line: nothing under the line's mean, in the fills or in the assembly.
+ [Fact]
+ public void BinnedFillsAndAssemblyNeverFallBelowTheFloor()
+ {
+ var lots = Mint(Bin(Line(), "Top Half", 0), 400);
+ Assert.All(lots, lot =>
+ {
+ Assert.True(lot.Roles.Single().Quality >= .5f - 1e-5f, "a fill fell under the line's mean");
+ Assert.True(lot.Quality >= .6f - 1e-5f, "an assembly fell under the maker's mean");
+ });
+ Assert.InRange(Fills(lots).Average(), .55f, .60f);
+ }
+
+ // The floor is in the line's standard deviations: .67 on .5 +- .1 cuts at .567 and the truncated mean is .627.
+ [Fact]
+ public void FloorIsInDeviations()
+ {
+ var fills = Fills(Mint(Bin(Line(), "Top Quarter", .67f), 400));
+ Assert.All(fills, fill => Assert.True(fill >= .567f - 1e-5f, "a fill fell under mean + floor deviations"));
+ Assert.InRange(fills.Average(), .61f, .645f);
+ }
+
+ // A bin keeps no distribution of its own: after it exists, the line and the maker move and the bin follows.
+ [Fact]
+ public void BinDerivesFromItsLineNotACopy()
+ {
+ var line = Line();
+ var bin = Bin(line, "Follower", 0);
+ Assert.Empty(bin.Roles);
+ Assert.Null(bin.Assembly);
+ line.Roles.Single().Mean = .7f;
+ var maker = _cache.Get(line.Manufacturer);
+ maker.Assembly = A(.8f, .1f);
+ _cache.Commit(batch =>
+ {
+ batch.Upsert(typeof(FactionProductData), line, _cache.RefOf(line).Key);
+ batch.Upsert(typeof(Faction), maker, _cache.RefOf(maker).Key);
+ });
+ var lots = Mint(bin, 300);
+ Assert.All(lots, lot =>
+ {
+ Assert.True(lot.Roles.Single().Quality >= .7f - 1e-5f, "the bin read a copy of its line's fill");
+ Assert.True(lot.Quality >= .8f - 1e-5f, "the bin read a copy of its maker's assembly");
+ });
+ }
+
+ // A line's own assembly is the final test a bin of it sits: the maker's is read only when the line sets none.
+ [Fact]
+ public void BinReadsTheLinesOwnAssemblyBeforeTheMakers()
+ {
+ var bin = Bin(Line(own: A(.85f, .05f), makerMean: .4f), "Certified", 0);
+ Assert.All(Mint(bin, 300), lot => Assert.True(lot.Quality >= .85f - 1e-5f, "the bin assembled as its maker, not its line"));
+ }
+
+ // 6 deviations above a .2 +- .01 line is out of reach in 64 draws: the mint returns the cutoff, .26, and does not loop.
+ [Fact]
+ public void UnreachableFloorMintsAtTheCutoff()
+ {
+ var bin = Bin(Line(lensMean: .2f, lensDeviation: .01f, own: A(.2f, .01f)), "Unreachable", 6);
+ Assert.All(Mint(bin, 20), lot =>
+ {
+ Assert.Equal(.26f, lot.Roles.Single().Quality, 5);
+ Assert.Equal(.26f, lot.Quality, 5);
+ });
+ }
+
+ // Snapshot of the first five assemblies and fills at base, before the bin existed (seed 20261018, lens .5 +- .1, maker .6 +- .1).
+ [Fact]
+ public void UnbinnedMintConsumesTheStreamAsBefore()
+ {
+ var line = Line();
+ _items.Random = new CultMath.Random(20261018u);
+ var lots = Mint(line, 5);
+ var assemblies = new[] { .59560823f, .68289334f, .57563853f, .5639112f, .59828424f };
+ var fills = new[] { .6311789f, .5835483f, .47641385f, .46416125f, .45124212f };
+ for (var i = 0; i < 5; i++)
+ {
+ Assert.Equal(assemblies[i], lots[i].Quality, 5);
+ Assert.Equal(fills[i], lots[i].Roles.Single().Quality, 5);
+ }
+ }
+
+ // The lot is the bin's: its product, its title, and the line's maker as its brand.
+ [Fact]
+ public void ABinnedLotIsBrandedAsTheBin()
+ {
+ var line = Line();
+ var bin = Bin(line, "Premiere", 0);
+ var lotId = _items.CreateLot(bin);
+ Assert.Equal(_cache.RefOf(bin), _items.Lots[lotId].Product);
+ var instance = _items.CreateInstance(lotId);
+ Assert.Equal("Premiere", _items.Title(instance));
+ var (maker, product) = _items.Brand(instance);
+ Assert.Equal(_cache.Get(line.Manufacturer).Name, maker.Name);
+ Assert.Equal("Premiere", product.Name);
+ }
+
+ // A bin whose line the catalog does not hold mints as a product with no roles of its own, and says so.
+ [Fact]
+ public void ABinOfALineTheCatalogLacksMintsAtDefaultsAndLogs()
+ {
+ var line = Line();
+ var bin = Bin(line, "Orphan", 0);
+ _cache.Remove(_cache.RefOf(line).Key);
+ var lots = Mint(bin, 5);
+ Assert.Equal(5, lots.Length);
+ Assert.NotEmpty(_log);
+ }
+}
From 7f09b05725f3f8fd6106e1955fe1a09a6c01228e Mon Sep 17 00:00:00 2001
From: Meta Vens
Date: Sun, 18 Oct 2026 18:04:08 +0200
Subject: [PATCH 007/916] ProductWeight: a bin takes its pass fraction of its
maker's preference and its line the rest (ruling bin-share-by-floor)
Phi comes from CultMath's math.erf.
Co-Authored-By: Claude Sonnet 5.5
---
.../Scripts/ServerShared/LoadoutGenerator.cs | 17 ++++++-
.../ProductChoiceTests.cs | 51 ++++++++++++++++++-
2 files changed, 65 insertions(+), 3 deletions(-)
diff --git a/Assets/Scripts/ServerShared/LoadoutGenerator.cs b/Assets/Scripts/ServerShared/LoadoutGenerator.cs
index 55eea27f8..0206935fb 100644
--- a/Assets/Scripts/ServerShared/LoadoutGenerator.cs
+++ b/Assets/Scripts/ServerShared/LoadoutGenerator.cs
@@ -252,8 +252,21 @@ public class LoadoutGenerator
Galaxy == null || Faction == null ||
ItemManager.ItemData.Get(product.Manufacturer) == Faction || Faction.Allegiance.ContainsKey(product.Manufacturer);
- // How much this outfitter favors a product: its maker's preference. The one weight of generation and of ChooseProduct.
- public float ProductWeight(FactionProductData product) => ManufacturerPreference(product.Manufacturer);
+ // How much this outfitter favors a product: its maker's preference times the product's share of it. The one weight of
+ // generation and of ChooseProduct. A bin takes the share of its maker's stock that would pass its floor and its line takes
+ // the rest (ruling bin-share-by-floor), so binning never changes a maker's presence for the design.
+ public float ProductWeight(FactionProductData product) => ManufacturerPreference(product.Manufacturer) * Share(product);
+
+ // 1 - Phi(floor): the fraction of a normal draw that lies at least floor deviations above its mean.
+ private static float PassFraction(float floor) => .5f * (1 - erf(floor / sqrt(2f)));
+
+ private float Share(FactionProductData product)
+ {
+ if (product.Bin != null) return PassFraction(product.Bin.Floor);
+ var key = ItemManager.ItemData.RefOf(product).Key;
+ var binned = ItemManager.ItemData.GetAll().Where(other => other.Bin != null && other.Bin.Line.Key.Equals(key)).Sum(bin => PassFraction(bin.Bin.Floor));
+ return max(0f, 1 - binned);
+ }
// The product a design named without one is built as (ruling loadout-product-optional-context-chooses): among the
// products of the design this outfitter can get, one draw from the run's seeded Random weighted by ProductWeight;
diff --git a/tests/Aetheria.Shared.Tests/ProductChoiceTests.cs b/tests/Aetheria.Shared.Tests/ProductChoiceTests.cs
index 888634f8e..a11708393 100644
--- a/tests/Aetheria.Shared.Tests/ProductChoiceTests.cs
+++ b/tests/Aetheria.Shared.Tests/ProductChoiceTests.cs
@@ -63,7 +63,10 @@ public sealed class ProductChoiceTests : IDisposable
}
}
- private Rig Build(params string[] lampOrder)
+ private Rig Build(params string[] lampOrder) => Build(new float[0], lampOrder);
+
+ // binFloors adds one bin of lamp-a's line per floor, named "lamp-a bin" and "lamp-a bin 2"..., by the same maker.
+ private Rig Build(float[] binFloors, string[] lampOrder)
{
var root = Path.Combine(_root, "rig" + _catalogs++);
Directory.CreateDirectory(root);
@@ -97,6 +100,12 @@ public sealed class ProductChoiceTests : IDisposable
// lampOrder holds product names; the record key of the i-th inserted is "k" + i, so keys and insertion order
// both follow the permutation.
for (var i = 0; i < lampOrder.Length; i++) Sell(lampOrder[i], lamp.Key, makers[lampOrder[i]], "k" + i);
+ for (var i = 0; i < binFloors.Length; i++)
+ seed.Commit(batch => batch.Upsert(typeof(FactionProductData), new FactionProductData
+ {
+ Name = i == 0 ? "lamp-a bin" : "lamp-a bin " + (i + 1), Design = new CultRecordRef(lamp.Key), Manufacturer = alpha,
+ Bin = new ProductBin { Line = new CultRecordRef(new CultRecordKey("k" + Array.IndexOf(lampOrder, "lamp-a"))), Floor = binFloors[i] }
+ }, new CultRecordKey("bin" + i)));
seed.FlushAsync().Wait();
}
@@ -249,6 +258,46 @@ public sealed class ProductChoiceTests : IDisposable
Assert.InRange(MakerDraws(rig, rig.OutEven, 1, "lamp-a", 300), 80, 120);
}
+ // Ruling bin-share-by-floor: a bin of lamp-a's line takes the fraction of lamp-a's stock that would pass its floor, 1 - Phi(Floor),
+ // of lamp-a's preference, and the line keeps the rest, so the maker's presence for the design is what it was without the bin.
+ [Fact]
+ public void ABinTakesItsPassFractionOfItsMakersPreference()
+ {
+ var alone = Build("lamp-z", "lamp-a");
+ var preference = alone.Outfitter(alone.OutEven, 1, 0).ProductWeight(alone.Product("lamp-a"));
+ Assert.True(preference > 0);
+
+ var quarter = Build(new[] { .67f }, new[] { "lamp-z", "lamp-a" });
+ var generator = quarter.Outfitter(quarter.OutEven, 1, 0);
+ Assert.Equal(.2514f * preference, generator.ProductWeight(quarter.Product("lamp-a bin")), 3);
+ Assert.Equal(.7486f * preference, generator.ProductWeight(quarter.Product("lamp-a")), 3);
+ Assert.Equal(preference, generator.ProductWeight(quarter.Product("lamp-a bin")) + generator.ProductWeight(quarter.Product("lamp-a")), 3);
+
+ var half = Build(new[] { 0f }, new[] { "lamp-z", "lamp-a" });
+ generator = half.Outfitter(half.OutEven, 1, 0);
+ Assert.Equal(.5f * preference, generator.ProductWeight(half.Product("lamp-a bin")), 3);
+ Assert.Equal(.5f * preference, generator.ProductWeight(half.Product("lamp-a")), 3);
+
+ // The maker keeps its presence: Alpha's line and bin together draw as lamp-a alone did.
+ var lamp = quarter.Cache.GetByName("Lamp");
+ var alpha = Enumerable.Range(1, 300).Count(i => quarter.Cache.Get(quarter.Outfitter(quarter.OutEven, Seed(i), 0).ChooseProduct(lamp).Manufacturer).Name == "Alpha");
+ Assert.InRange(alpha, 180, 220);
+ }
+
+ // A line gives up the sum of its bins' pass fractions and no more: two top-half bins leave it nothing, and a third does not
+ // take it below nothing.
+ [Fact]
+ public void ALineKeepsWhatItsBinsLeaveAndNeverLessThanNothing()
+ {
+ var two = Build(new[] { 0f, .67f }, new[] { "lamp-z", "lamp-a" });
+ var alone = Build("lamp-z", "lamp-a");
+ var preference = alone.Outfitter(alone.OutEven, 1, 0).ProductWeight(alone.Product("lamp-a"));
+ Assert.Equal((1 - .5f - .2514f) * preference, two.Outfitter(two.OutEven, 1, 0).ProductWeight(two.Product("lamp-a")), 3);
+
+ var three = Build(new[] { 0f, 0f, 0f }, new[] { "lamp-z", "lamp-a" });
+ Assert.Equal(0f, three.Outfitter(three.OutEven, 1, 0).ProductWeight(three.Product("lamp-a")));
+ }
+
// A weight that read the allegiance alone would give 1 : .25 here, an 80% draw; the zone and allegiance together
// give 1 : .125 for alpha at its own zone, 89%.
[Fact]
From 2806b443c9c20f58c7ffc615d1e672f73b358d59 Mon Sep 17 00:00:00 2001
From: Meta Vens
Date: Sun, 18 Oct 2026 18:06:07 +0200
Subject: [PATCH 008/916] Census, roles-migrate and roles-backfill skip a bin:
it authors no roles, it reads its line's
RolesMigrate takes an optional root, as RolesBackfill does, so its bin skip has a test.
Co-Authored-By: Claude Sonnet 5.5
---
.../Aetheria.Shared.Tests/CatalogRoleTests.cs | 8 +--
.../RolesBackfillCommandTests.cs | 53 +++++++++++++++++++
tools/AetherDb/Program.cs | 10 ++--
3 files changed, 64 insertions(+), 7 deletions(-)
diff --git a/tests/Aetheria.Shared.Tests/CatalogRoleTests.cs b/tests/Aetheria.Shared.Tests/CatalogRoleTests.cs
index b50e0142d..10056b421 100644
--- a/tests/Aetheria.Shared.Tests/CatalogRoleTests.cs
+++ b/tests/Aetheria.Shared.Tests/CatalogRoleTests.cs
@@ -36,7 +36,7 @@ public sealed class CatalogRoleTests
}
// The whole of CB-R1 over every design in the catalog: each non-flat stat reads exactly one declared role, every
- // declared role is read, and every seller authors each role once. Weapons, and designs of a kind the tool keeps a role
+ // declared role is read, and every seller authors each role once (a bin authors none: it reads its line's). Weapons, and designs of a kind the tool keeps a role
// map for, must also carry a non-flat stat (a design with no stat at all has nothing for quality to vary).
[Fact]
public void ShippedCatalogRolesAreLive()
@@ -59,13 +59,15 @@ public sealed class CatalogRoleTests
broken.Add($"{design.Name}: declares [{string.Join(", ", declared)}] but non-flat stats read [{string.Join(", ", read)}]");
if (varying.Length == 0 && stats.Length > 0 && (design is WeaponItemData || Program.HasRoleMap(design)))
broken.Add($"{design.Name}: every stat is flat");
- foreach (var product in products.Where(p => p.Design.Key.Equals(cache.RefOf(design).Key)))
+ foreach (var product in products.Where(p => p.Bin == null && p.Design.Key.Equals(cache.RefOf(design).Key)))
{
var authored = (product.Roles ?? new List()).Select(r => r.Role).OrderBy(r => r, StringComparer.Ordinal).ToArray();
if (!authored.SequenceEqual(declared))
broken.Add($"{design.Name}: product \"{product.Name}\" authors [{string.Join(", ", authored)}], not each of [{string.Join(", ", declared)}] once");
}
}
+ foreach (var bin in products.Where(p => p.Bin != null))
+ if (bin.Roles?.Count > 0 || bin.Assembly != null) broken.Add($"bin \"{bin.Name}\" authors roles or an assembly of its own");
Assert.True(broken.Count == 0, string.Join("\n", broken));
}
@@ -264,7 +266,7 @@ public sealed class CatalogRoleTests
var profiles = new Dictionary(Program.MakerProfiles) { ["Pirates"] = (.45f, .22f) };
foreach (var design in new[] { autocannon, lrm, srm, mine, drive })
{
- var sellers = cache.GetAll().Where(p => p.Design.Key.Equals(cache.RefOf(design).Key)).ToArray();
+ var sellers = cache.GetAll().Where(p => p.Bin == null && p.Design.Key.Equals(cache.RefOf(design).Key)).ToArray();
Assert.NotEmpty(sellers);
foreach (var product in sellers)
{
diff --git a/tests/Aetheria.Shared.Tests/RolesBackfillCommandTests.cs b/tests/Aetheria.Shared.Tests/RolesBackfillCommandTests.cs
index 1f276c639..1f0f974f5 100644
--- a/tests/Aetheria.Shared.Tests/RolesBackfillCommandTests.cs
+++ b/tests/Aetheria.Shared.Tests/RolesBackfillCommandTests.cs
@@ -207,6 +207,59 @@ public sealed class RolesBackfillCommandTests : IDisposable
finally { db.Cache.Dispose(); }
}
+ // A bin authors no roles (ProductBin): the backfill that restores its line's missing roles leaves the bin's list empty.
+ [Fact]
+ public void A_binned_seller_gains_no_roles()
+ {
+ Reset(flattened: false, unnamed: false);
+ var db = AetherDb.Open(catalogWritable: true, root: _root);
+ var autocannon = db.Cache.GetAll().Single(weapon => weapon.Name == "Autocannon");
+ var seller = db.Cache.GetAll().OrderBy(p => p.Name, StringComparer.Ordinal).First(p => p.Design.Key.Equals(db.Cache.RefOf(autocannon).Key) && p.Roles.Count == 2);
+ var sellerName = seller.Name;
+ seller.Roles = new List { seller.Roles.OrderBy(r => r.Role, StringComparer.Ordinal).First() };
+ var bin = new FactionProductData
+ {
+ Name = "Binned " + sellerName, Design = seller.Design, Manufacturer = seller.Manufacturer,
+ Bin = new ProductBin { Line = db.Cache.RefOf(seller), Floor = 0f }
+ };
+ db.Cache.Commit(batch =>
+ {
+ batch.Upsert(typeof(FactionProductData), seller, db.Cache.RefOf(seller).Key);
+ batch.Upsert(typeof(FactionProductData), bin);
+ });
+ db.Cache.Dispose();
+
+ Assert.Equal(0, Program.RolesBackfill(apply: true, root: _root));
+ db = AetherDb.Open(root: _root);
+ try
+ {
+ Assert.Equal(2, db.Cache.GetAll().Single(p => p.Name == sellerName).Roles.Count);
+ Assert.Empty(db.Cache.GetAll().Single(p => p.Name == "Binned " + sellerName).Roles);
+ }
+ finally { db.Cache.Dispose(); }
+ }
+
+ // roles-migrate authors a role on every product that sells a design lacking one; a bin sells none of its own.
+ [Fact]
+ public void A_binned_seller_gains_no_roles_from_roles_migrate()
+ {
+ var db = AetherDb.Open(catalogWritable: true, root: _root);
+ var autocannon = db.Cache.GetAll().Single(weapon => weapon.Name == "Autocannon");
+ var seller = db.Cache.GetAll().OrderBy(p => p.Name, StringComparer.Ordinal).First(p => p.Design.Key.Equals(db.Cache.RefOf(autocannon).Key));
+ var bin = new FactionProductData
+ {
+ Name = "Binned " + seller.Name, Design = seller.Design, Manufacturer = seller.Manufacturer,
+ Bin = new ProductBin { Line = db.Cache.RefOf(seller), Floor = 0f }
+ };
+ db.Cache.Commit(batch => batch.Upsert(typeof(FactionProductData), bin));
+ db.Cache.Dispose();
+
+ Assert.Equal(0, Program.RolesMigrate(apply: true, root: _root));
+ db = AetherDb.Open(root: _root);
+ try { Assert.Empty(db.Cache.GetAll().Single(p => p.Name == "Binned " + seller.Name).Roles); }
+ finally { db.Cache.Dispose(); }
+ }
+
[Fact]
public void A_design_the_catalog_does_not_hold_refuses_and_lands_nothing()
{
diff --git a/tools/AetherDb/Program.cs b/tools/AetherDb/Program.cs
index 5df9ed99c..46a812ba2 100644
--- a/tools/AetherDb/Program.cs
+++ b/tools/AetherDb/Program.cs
@@ -132,7 +132,8 @@ public static class Program
foreach (var item in items.Where(i => i.Roles != null && i.Roles.Count > 0))
{
var design = db.Cache.RefOf(item).Key;
- var sellers = products.Where(p => p.Design.Key.Equals(design)).ToArray();
+ // A bin authors no spread: it reads its line's (ProductBin).
+ var sellers = products.Where(p => p.Bin == null && p.Design.Key.Equals(design)).ToArray();
foreach (var product in sellers)
{
var covered = new HashSet((product.Roles ?? new List()).Select(r => r.Role));
@@ -309,9 +310,9 @@ public static class Program
// Dry run unless passed "apply", which alone opens the catalog writable; every record must derive cleanly or
// nothing is written, the same all-or-nothing contract ShieldMigrate and BrownoutMigrate already use. Prints
// the operator review table (grouped by item kind) either way.
- private static int RolesMigrate(bool apply)
+ public static int RolesMigrate(bool apply, string root = null)
{
- var db = AetherDb.Open(catalogWritable: apply);
+ var db = AetherDb.Open(catalogWritable: apply, root: root);
var items = db.Cache.GetAll().ToArray();
var products = db.Cache.GetAll().ToArray();
var changedDesigns = new List<(object Document, CultRecordKey Key)>();
@@ -366,6 +367,7 @@ public static class Program
var byDesign = items.ToDictionary(i => db.Cache.RefOf(i).Key, i => i);
foreach (var product in products.OrderBy(p => p.Name, StringComparer.Ordinal))
{
+ if (product.Bin != null) continue; // a bin authors no roles; the mint reads its line's
if (!byDesign.TryGetValue(product.Design.Key, out var design) || design.Roles == null || design.Roles.Count == 0)
continue;
var existing = new HashSet((product.Roles ?? new List()).Select(r => r.Role));
@@ -2218,7 +2220,7 @@ public static class Program
var changedProducts = new List<(FactionProductData Document, CultRecordKey Key)>();
foreach (var design in targets)
- foreach (var product in products.Where(p => p.Design.Key.Equals(db.Cache.RefOf(design).Key)).OrderBy(p => p.Name, StringComparer.Ordinal))
+ foreach (var product in products.Where(p => p.Bin == null && p.Design.Key.Equals(db.Cache.RefOf(design).Key)).OrderBy(p => p.Name, StringComparer.Ordinal))
{
var maker = db.Cache.Get(product.Manufacturer);
var profile = maker?.Name == "Pirates" ? PirateProfile
From 6768cdcb954d0ff018d82b70eebf58f1c0588d2c Mon Sep 17 00:00:00 2001
From: Meta Vens
Date: Sun, 18 Oct 2026 18:08:56 +0200
Subject: [PATCH 009/916] product-lines tiers: authors the six bins from a
table of (line, bin, floor, text)
A bin gets its line's design and maker, Bin = { Line, Floor }, and no roles or assembly. Resolve-then-write
as the other lines do; a replay is a no-op. The catalog is not yet applied.
Co-Authored-By: Claude Sonnet 5.5
---
.../ProductTiersCommandTests.cs | 177 ++++++++++++++++++
tools/AetherDb/ProductLinesCommand.cs | 88 ++++++++-
tools/AetherDb/Program.cs | 2 +-
3 files changed, 263 insertions(+), 4 deletions(-)
create mode 100644 tests/Aetheria.Shared.Tests/ProductTiersCommandTests.cs
diff --git a/tests/Aetheria.Shared.Tests/ProductTiersCommandTests.cs b/tests/Aetheria.Shared.Tests/ProductTiersCommandTests.cs
new file mode 100644
index 000000000..856cca7dc
--- /dev/null
+++ b/tests/Aetheria.Shared.Tests/ProductTiersCommandTests.cs
@@ -0,0 +1,177 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using GameCult.Caching;
+using GameCult.Caching.MessagePack;
+using Xunit;
+
+// AetherDb's product-lines tiers command (cut product-tiers; rulings maker-design-tiers-allowed, bin-share-by-floor), run on a
+// scratch copy of the shipped catalog with the table's bins removed from it. A standalone class: a tier row is not a Row.
+public sealed class ProductTiersCommandTests : IDisposable
+{
+ private static readonly string[] Apply = { "tiers", "apply" };
+ private static readonly string[] DryRun = { "tiers" };
+
+ private readonly string _root = Path.Combine(Path.GetTempPath(), "product-tiers-command-" + Guid.NewGuid().ToString("N"));
+ private string CatalogPath => Path.Combine(_root, "GameData", "Aetheria.cc");
+ private readonly string[] _names = ProductLinesCommand.TierTable().Select(r => r.Name).ToArray();
+
+ public ProductTiersCommandTests()
+ {
+ Directory.CreateDirectory(Path.Combine(_root, "GameData"));
+ Directory.CreateDirectory(Path.Combine(_root, "Assets", "Resources"));
+ var shipped = AetherDb.FindRoot();
+ File.Copy(Path.Combine(shipped, "GameData", "Aetheria.cc"), CatalogPath);
+ File.Copy(Path.Combine(shipped, "Assets", "Resources", "Settings.asset"), Path.Combine(_root, "Assets", "Resources", "Settings.asset"));
+ using var cache = Open();
+ foreach (var bin in cache.GetAll().Where(p => _names.Contains(p.Name)).ToArray()) Assert.True(cache.Remove(cache.RefOf(bin).Key));
+ cache.FlushAsync().Wait();
+ }
+
+ public void Dispose() => Directory.Delete(_root, true);
+
+ private CultCache Open()
+ {
+ var cache = new CultCache(TestCatalog.Registry());
+ cache.AddBackingStore(new SingleFileMessagePackBackingStore(CatalogPath), AetheriaStores.CatalogTypes);
+ return cache;
+ }
+
+ private Dictionary Records() =>
+ CultDocumentMessagePackSerialization.DeserializeSnapshot(File.ReadAllBytes(CatalogPath)).Records.ToDictionary(r => r.Key, StringComparer.Ordinal);
+
+ private FactionProductData[] Bins()
+ {
+ using var cache = Open();
+ return cache.GetAll().Where(p => _names.Contains(p.Name)).ToArray();
+ }
+
+ // Edits the scratch catalog before a refusal case; the bins the table authors stay out of it.
+ private void Edit(Action edit)
+ {
+ using var cache = Open();
+ edit(cache);
+ cache.FlushAsync().Wait();
+ }
+
+ // The command refuses the row with a message naming the rule, and the catalog's bytes are as they were.
+ private void Refused(ProductLinesCommand.TierRow row, string phrase)
+ {
+ var before = File.ReadAllBytes(CatalogPath);
+ var error = Assert.Throws(() => ProductLinesCommand.RunTiers(new[] { row }, true, _root));
+ Assert.Contains(phrase, error.Message);
+ Assert.Equal(before, File.ReadAllBytes(CatalogPath));
+ }
+
+ [Fact]
+ public void A_dry_run_writes_nothing_and_apply_lands_the_table_once_and_replays_as_a_no_op()
+ {
+ var before = File.ReadAllBytes(CatalogPath);
+ Assert.Empty(Bins());
+
+ Assert.Equal(0, ProductLinesCommand.Run(DryRun, _root));
+ Assert.Equal(before, File.ReadAllBytes(CatalogPath));
+
+ Assert.Equal(0, ProductLinesCommand.Run(Apply, _root));
+ var landed = File.ReadAllBytes(CatalogPath);
+ Assert.NotEqual(before, landed);
+ Assert.Equal(6, Bins().Length);
+
+ Assert.Equal(0, ProductLinesCommand.Run(Apply, _root));
+ Assert.Equal(landed, File.ReadAllBytes(CatalogPath));
+ Assert.Equal(0, ProductLinesCommand.Run(DryRun, _root));
+ Assert.Equal(landed, File.ReadAllBytes(CatalogPath));
+ }
+
+ [Fact]
+ public void Each_bin_is_its_lines_design_and_maker_at_its_floor_with_nothing_of_its_own()
+ {
+ Assert.Equal(0, ProductLinesCommand.Run(Apply, _root));
+ using var cache = Open();
+ foreach (var row in ProductLinesCommand.TierTable())
+ {
+ var bin = Assert.Single(cache.GetAll(), p => p.Name == row.Name);
+ var line = Assert.Single(cache.GetAll(), p => p.Name == row.Line);
+ Assert.Equal(cache.RefOf(line).Key, bin.Bin.Line.Key);
+ Assert.Equal(line.Design.Key, bin.Design.Key);
+ Assert.Equal(line.Manufacturer.Key, bin.Manufacturer.Key);
+ Assert.Equal(row.Floor, bin.Bin.Floor);
+ Assert.Equal(row.Description, bin.Description);
+ Assert.Empty(bin.Roles);
+ Assert.Null(bin.Assembly);
+ Assert.Null(line.Bin);
+ }
+ }
+
+ [Fact]
+ public void Apply_writes_only_the_records_it_authors()
+ {
+ var before = Records();
+ Assert.Equal(0, ProductLinesCommand.Run(Apply, _root));
+ var after = Records();
+ Assert.Equal(before.Count + 6, after.Count);
+ foreach (var (key, record) in before)
+ {
+ Assert.True(after.TryGetValue(key, out var kept), "a record the command did not author is gone");
+ Assert.Equal(record.StoredAt, kept.StoredAt);
+ Assert.True(record.Payload.AsSpan().SequenceEqual(kept.Payload), "a record the command did not author has changed bytes");
+ }
+ }
+
+ [Fact]
+ public void A_bin_already_authored_at_another_floor_is_refused()
+ {
+ Assert.Equal(0, ProductLinesCommand.Run(Apply, _root));
+ Refused(new ProductLinesCommand.TierRow("Sparrow", "Goldcrest", .5f, "x"), "already belongs");
+ }
+
+ [Fact]
+ public void A_line_the_catalog_does_not_hold_is_refused()
+ {
+ Refused(new ProductLinesCommand.TierRow("No Such Line", "Fresh Bin", 0f, "x"), "found 0");
+ }
+
+ [Fact]
+ public void An_ambiguous_line_is_refused()
+ {
+ Edit(cache =>
+ {
+ var sparrow = cache.GetAll().Single(p => p.Name == "Sparrow");
+ cache.Upsert(new FactionProductData { Name = "Sparrow", Design = sparrow.Design, Manufacturer = sparrow.Manufacturer });
+ });
+ Refused(new ProductLinesCommand.TierRow("Sparrow", "Fresh Bin", 0f, "x"), "found 2");
+ }
+
+ [Fact]
+ public void A_line_that_is_itself_a_bin_is_refused()
+ {
+ Assert.Equal(0, ProductLinesCommand.Run(Apply, _root));
+ Refused(new ProductLinesCommand.TierRow("Goldcrest", "Fresh Bin", 0f, "x"), "itself a bin");
+ }
+
+ [Theory]
+ [InlineData(-.1f)]
+ [InlineData(float.NaN)]
+ [InlineData(float.PositiveInfinity)]
+ public void A_floor_that_is_negative_or_not_finite_is_refused(float floor)
+ {
+ Refused(new ProductLinesCommand.TierRow("Sparrow", "Fresh Bin", floor, "x"), "finite number");
+ }
+
+ [Theory]
+ [InlineData("Spotlight")]
+ [InlineData("SPOTLIGHT")]
+ public void A_bin_name_held_by_another_product_is_refused_ignoring_case(string name)
+ {
+ Refused(new ProductLinesCommand.TierRow("Sparrow", name, 0f, "x"), "already belongs");
+ }
+
+ [Fact]
+ public void A_bin_name_that_is_a_designs_is_refused()
+ {
+ string design;
+ using (var cache = Open()) design = cache.GetAll().First().Name;
+ Refused(new ProductLinesCommand.TierRow("Sparrow", design.ToUpperInvariant(), 0f, "x"), "name of a design");
+ }
+}
diff --git a/tools/AetherDb/ProductLinesCommand.cs b/tools/AetherDb/ProductLinesCommand.cs
index 911f01ffb..5ee316a38 100644
--- a/tools/AetherDb/ProductLinesCommand.cs
+++ b/tools/AetherDb/ProductLinesCommand.cs
@@ -16,9 +16,13 @@ using GameCult.Caching;
// carries no quality numbers. A row already in the catalog (same name, design and maker) is skipped, so the same command is the
// first apply, the second apply and the replay onto a merged catalog. A maker that already sells the design is not refused: a
// tier is allowed. Dry run unless passed "apply".
+// product-lines tiers [apply] (cut product-tiers; rulings maker-design-tiers-allowed, bin-share-by-floor): authors the bins of
+// those lines. A tier row is (line product name, bin name, floor, text); the bin gets Design and Manufacturer from its line,
+// Bin = { Line, Floor }, and no Roles or Assembly of its own: the mint derives both from the line.
public static class ProductLinesCommand
{
internal sealed record Row(string Design, string Name, string Maker, string Description);
+ internal sealed record TierRow(string Line, string Name, float Floor, string Description);
private static readonly Row[] Weapons =
{
@@ -85,6 +89,19 @@ public static class ProductLinesCommand
new("Industrial Thermostatic Heater", "WarmUp+-", "NiteLife", "Room temperature, whatever the room."),
};
+ // The bins of the shipped lines. The names and text are drafts the operator may rename.
+ private static readonly TierRow[] Tiers =
+ {
+ new("Sparrow", "Goldcrest", .67f, "Only the Sparrows that sang on the test bench. The rest still fly."),
+ new("Spotlight", "Spotlight Premiere", 0f, "Hand-picked for opening night."),
+ new("Rattler", "Rattler Select", 0f, "Pick of the batch. Still loud."),
+ new("SM-6 Marksman", "SM-6C Marksman Certified", 0f, "Individually certified to published tolerance.*"),
+ new("PowerHour 2.0", "PowerHour 2.0 VIP", .67f, "Skip the line. Same party, better parts."),
+ new("Juggernaut", "Juggernaut Guards", 0f, "The column's best drives go to the front of the column."),
+ };
+
+ internal static IReadOnlyList TierTable() => Tiers;
+
// Every line the command knows, by the word that follows "product-lines".
private static readonly Dictionary Lines = new() { ["weapons"] = Weapons, ["minor-powers"] = MinorPowers, ["gear"] = Gear };
@@ -93,16 +110,19 @@ public static class ProductLinesCommand
// A product's record key is derived from its name, so the same table lands the same records every time it is applied: the
// replay at a merge reproduces the branch's blob, and nothing that orders products by key reads a different order after it.
- private static CultRecordKey KeyOf(Row row) =>
- new(new Guid(SHA256.HashData(Encoding.UTF8.GetBytes("product-line:" + row.Name)).AsSpan(0, 16)).ToString("N"));
+ private static CultRecordKey KeyOf(Row row) => KeyOf(row.Name);
+
+ private static CultRecordKey KeyOf(string name) =>
+ new(new Guid(SHA256.HashData(Encoding.UTF8.GetBytes("product-line:" + name)).AsSpan(0, 16)).ToString("N"));
public static int Run(string[] args, string root = null)
{
var apply = args.Contains("apply");
var line = args.FirstOrDefault(a => a != "apply");
+ if (line == "tiers") return RunTiers(Tiers, apply, root);
if (line == null || !Lines.TryGetValue(line, out var rows))
{
- Console.WriteLine($"usage: product-lines {string.Join("|", Lines.Keys)} [apply]");
+ Console.WriteLine($"usage: product-lines {string.Join("|", Lines.Keys)}|tiers [apply]");
return 1;
}
@@ -178,4 +198,66 @@ public static class ProductLinesCommand
Console.WriteLine($"\nAuthored {missing.Length} products in Aetheria.cc");
return 0;
}
+
+ // The tiers line has Run's shape: resolve every row first, so a refusal leaves the catalog untouched, then land the missing
+ // bins in one batch that expects each of their keys absent. A bin already in the catalog (this line, this floor) is skipped,
+ // so the same command is the first apply and the replay onto a merged catalog.
+ internal static int RunTiers(IReadOnlyList tiers, bool apply, string root)
+ {
+ var db = AetherDb.Open(catalogWritable: apply, root: root);
+ var designs = db.Cache.GetAll().ToArray();
+ var products = db.Cache.GetAll().ToArray();
+
+ var resolved = new List<(TierRow Row, FactionProductData Line, bool Present)>();
+ for (var i = 0; i < tiers.Count; i++)
+ {
+ var row = tiers[i];
+ var lines = products.Where(p => p.Name == row.Line).ToArray();
+ if (lines.Length != 1) throw new InvalidOperationException($"Tier row {i}: expected exactly one line product, found {lines.Length}.");
+ var parent = lines[0];
+ if (parent.Bin != null) throw new InvalidOperationException($"Tier row {i}: the line is itself a bin.");
+ if (!float.IsFinite(row.Floor) || row.Floor < 0) throw new InvalidOperationException($"Tier row {i}: the floor is not a finite number of at least 0.");
+
+ var named = products.Where(p => string.Equals(p.Name, row.Name, StringComparison.OrdinalIgnoreCase)).ToArray();
+ var present = named.Length == 1 && named[0].Name == row.Name && named[0].Bin != null &&
+ named[0].Bin.Line.Key.Equals(db.Cache.RefOf(parent).Key) && named[0].Bin.Floor == row.Floor;
+ if (named.Length != 0 && !present) throw new InvalidOperationException($"Tier row {i}: the bin name already belongs to another product.");
+ if (!present && designs.Any(d => string.Equals(d.Name, row.Name, StringComparison.OrdinalIgnoreCase)))
+ throw new InvalidOperationException($"Tier row {i}: the bin name is the name of a design.");
+ resolved.Add((row, parent, present));
+ }
+
+ var missing = resolved.Where(r => !r.Present).ToArray();
+ if (missing.Length == 0)
+ {
+ Console.WriteLine("The tiers are already authored; nothing to do.");
+ return 0;
+ }
+
+ Console.WriteLine("Product tiers:");
+ foreach (var (row, parent, present) in resolved)
+ Console.WriteLine($" {(present ? "present" : "new ")} {row.Line} -> \"{row.Name}\" by {db.Cache.Get(parent.Manufacturer)?.ShortName}, floor {row.Floor:0.##}: {row.Description}");
+ if (!apply)
+ {
+ Console.WriteLine($"\nDry run. Pass \"apply\" to author {missing.Length} bins.");
+ return 0;
+ }
+
+ if (!db.Cache.Commit(batch =>
+ {
+ foreach (var (row, _, _) in missing) batch.Expect(KeyOf(row.Name), null);
+ foreach (var (row, parent, _) in missing)
+ batch.Upsert(typeof(FactionProductData), new FactionProductData
+ {
+ Name = row.Name,
+ Description = row.Description,
+ Design = parent.Design,
+ Manufacturer = parent.Manufacturer,
+ Bin = new ProductBin { Line = db.Cache.RefOf(parent), Floor = row.Floor },
+ }, KeyOf(row.Name));
+ }))
+ throw new InvalidOperationException("The catalog changed while the tiers were being authored; nothing was written. Run it again.");
+ Console.WriteLine($"\nAuthored {missing.Length} bins in Aetheria.cc");
+ return 0;
+ }
}
diff --git a/tools/AetherDb/Program.cs b/tools/AetherDb/Program.cs
index 46a812ba2..d88718817 100644
--- a/tools/AetherDb/Program.cs
+++ b/tools/AetherDb/Program.cs
@@ -63,7 +63,7 @@ public static class Program
return PlaceNamesCommand.Run(args.Skip(1).ToArray());
case "doctrine-catalog": return DoctrineCatalog.Run(AetherDb.Open(catalogWritable: args.Contains("apply")).Cache, args.Contains("apply"), Console.Out);
default:
- Console.WriteLine("commands: census, factions, station-fit, hardpoint-fit, loadout [seed], save, settings, settings-dump, dangling [clear ]... [apply], shield-migrate [apply], brownout-migrate [apply], roles-migrate [apply], firing-arc-migrate [apply], range-falloff [apply] [--effective ] [--end ], targeting-catalog [apply], targeting-catalog-6c [apply], targeting-catalog-6d [apply], ship-authoring create|inspect|validate|compose, field-kinds [apply], mine-launcher [apply], smoke-hull [apply], smoke-rounds [apply], roles-backfill [apply], pd-gear [apply], consumables-first-set [apply], launch-suppressor [apply], pirates-faction [apply], verse-grammar [apply], generic-designs [apply], sensor-stat-set [apply], inspection-scanner [apply], minor-power-factions [apply], place-names [apply], product-lines weapons|minor-powers|gear [apply], doctrine-catalog [apply], assembly-from-maker [apply]");
+ Console.WriteLine("commands: census, factions, station-fit, hardpoint-fit, loadout [seed], save, settings, settings-dump, dangling [clear ]... [apply], shield-migrate [apply], brownout-migrate [apply], roles-migrate [apply], firing-arc-migrate [apply], range-falloff [apply] [--effective ] [--end ], targeting-catalog [apply], targeting-catalog-6c [apply], targeting-catalog-6d [apply], ship-authoring create|inspect|validate|compose, field-kinds [apply], mine-launcher [apply], smoke-hull [apply], smoke-rounds [apply], roles-backfill [apply], pd-gear [apply], consumables-first-set [apply], launch-suppressor [apply], pirates-faction [apply], verse-grammar [apply], generic-designs [apply], sensor-stat-set [apply], inspection-scanner [apply], minor-power-factions [apply], place-names [apply], product-lines weapons|minor-powers|gear|tiers [apply], doctrine-catalog [apply], assembly-from-maker [apply]");
return 1;
}
}
From 9b7a1c00dc2b7034a16a61c436463008f4fa9996 Mon Sep 17 00:00:00 2001
From: Meta Vens
Date: Sun, 18 Oct 2026 18:11:11 +0200
Subject: [PATCH 010/916] Catalog: the six tier bins (product-lines tiers
apply); TierRowsAreShipped; the tier step pinned from both sides
Aetheria.cc written only by the command, on the pinned CultLib. Replay the command at merges; never merge the blob.
Co-Authored-By: Claude Sonnet 5.5
---
GameData/Aetheria.cc | 4 +-
tests/Aetheria.Shared.Tests/LoadoutTests.cs | 7 +++
.../ProductLinesCatalogTests.cs | 59 +++++++++++++++++++
3 files changed, 68 insertions(+), 2 deletions(-)
diff --git a/GameData/Aetheria.cc b/GameData/Aetheria.cc
index 9f9ff69e5..a2ddaad5d 100644
--- a/GameData/Aetheria.cc
+++ b/GameData/Aetheria.cc
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:22342ea360c7f453de500da8650e6a23648f8c1250eb22e724765bbcf619eac0
-size 186037
+oid sha256:c327ef1bbabbd34ddb7b9f643f5db8cc54aa5730f232bd42a1fa5f2b03973e89
+size 189753
diff --git a/tests/Aetheria.Shared.Tests/LoadoutTests.cs b/tests/Aetheria.Shared.Tests/LoadoutTests.cs
index 5673b205d..86bf4e698 100644
--- a/tests/Aetheria.Shared.Tests/LoadoutTests.cs
+++ b/tests/Aetheria.Shared.Tests/LoadoutTests.cs
@@ -622,6 +622,13 @@ public sealed class LoadoutTests : IDisposable
var result = items.GetTier((CraftedItemInstance) items.CreateInstance(lot));
Assert.Equal(settings.Tiers[0].Name, result.tier.Name);
Assert.Equal(2, result.upgrades);
+
+ // The same width from the other side (follow-up tier-upgrade-step-two-sided): two steps less a hair is one upgrade, so a
+ // step narrower than .0499 reads two and a wider one reads none.
+ var under = items.Lots.Add(new Lot { Design = cache.RefOf(lamp), Origin = new Attributed(), Quality = settings.Tiers[0].Quality + 2 * .0499f - .0001f, Roles = new List() });
+ var below = items.GetTier((CraftedItemInstance) items.CreateInstance(under));
+ Assert.Equal(settings.Tiers[0].Name, below.tier.Name);
+ Assert.Equal(1, below.upgrades);
}
// S7 (docs/stats-and-power-cut.md Cut 1 findings): a Quality term must raise the lot's quality to its own
diff --git a/tests/Aetheria.Shared.Tests/ProductLinesCatalogTests.cs b/tests/Aetheria.Shared.Tests/ProductLinesCatalogTests.cs
index 6a91bb457..7ce78218f 100644
--- a/tests/Aetheria.Shared.Tests/ProductLinesCatalogTests.cs
+++ b/tests/Aetheria.Shared.Tests/ProductLinesCatalogTests.cs
@@ -2,6 +2,8 @@ using System;
using System.Collections.Generic;
using System.Linq;
using GameCult.Caching;
+using GameCult.Caching.MessagePack;
+using MessagePack;
using Xunit;
// The weapon product lines the shipped catalog holds (campaign aetheria-release, cut product-lines-weapons; rulings
@@ -99,4 +101,61 @@ public sealed class ProductLinesCatalogTests
}
}
}
+ // Cut product-tiers: the six bins of the command's tier table are in the catalog, each a single product that names its line.
+ [Fact]
+ public void TierRowsAreShipped()
+ {
+ using var cache = RestoredHullsTests.OpenCatalog();
+ var table = ProductLinesCommand.TierTable();
+ Assert.Equal(6, table.Count);
+ foreach (var row in table)
+ {
+ var bin = Assert.Single(cache.GetAll(), p => p.Name == row.Name);
+ var line = Assert.Single(cache.GetAll(), p => p.Name == row.Line);
+ Assert.Equal(cache.RefOf(line).Key, bin.Bin.Line.Key);
+ Assert.Equal(line.Design.Key, bin.Design.Key);
+ Assert.Equal(line.Manufacturer.Key, bin.Manufacturer.Key);
+ Assert.Equal(row.Floor, bin.Bin.Floor);
+ Assert.Equal(row.Description, bin.Description);
+ Assert.Empty(bin.Roles);
+ Assert.Null(bin.Assembly);
+ }
+ }
+
+ // A bin bins an unbinned line of its own design and maker, and the catalog holds no bin the table does not author.
+ [Fact]
+ public void BinsBinAnUnbinnedLineOfTheirOwnDesignAndMaker()
+ {
+ using var cache = RestoredHullsTests.OpenCatalog();
+ var bins = cache.GetAll().Where(p => p.Bin != null).ToArray();
+ Assert.Equal(ProductLinesCommand.TierTable().Select(r => r.Name).OrderBy(n => n, StringComparer.Ordinal), bins.Select(b => b.Name).OrderBy(n => n, StringComparer.Ordinal));
+ foreach (var bin in bins)
+ {
+ var line = cache.Get(bin.Bin.Line);
+ Assert.NotNull(line);
+ Assert.Null(line.Bin);
+ Assert.Equal(line.Design.Key, bin.Design.Key);
+ Assert.Equal(line.Manufacturer.Key, bin.Manufacturer.Key);
+ Assert.True(bin.Bin.Floor >= 0 && float.IsFinite(bin.Bin.Floor));
+ }
+ }
+
+ // FactionProductData slot 7 is additive under the same schema id: a bin round-trips, and a record written before the slot
+ // existed (an array one element shorter) reads no bin.
+ [Fact]
+ public void BinIsSlotSevenAndACatalogWithoutItReadsNoBin()
+ {
+ var options = CultDocumentMessagePackSerialization.OptionsFor(typeof(FactionProductData).Assembly);
+ var binned = MessagePackSerializer.Deserialize(
+ MessagePackSerializer.Serialize(new FactionProductData { Name = "Binned", Bin = new ProductBin { Floor = .67f } }, options), options);
+ Assert.Equal(.67f, binned.Bin.Floor);
+
+ var bytes = MessagePackSerializer.Serialize(new FactionProductData { Name = "Old", Description = "d" }, options);
+ Assert.Equal(0x98, bytes[0]);
+ Assert.Equal(0xC0, bytes[^1]);
+ var before = new byte[] { 0x97 }.Concat(bytes.Skip(1).Take(bytes.Length - 2)).ToArray();
+ var old = MessagePackSerializer.Deserialize(before, options);
+ Assert.Equal("Old", old.Name);
+ Assert.Null(old.Bin);
+ }
}
From aec7b3c019edfdc13e4b6c71cee04d9497a98be0 Mon Sep 17 00:00:00 2001
From: Meta Vens
Date: Sun, 18 Oct 2026 18:16:27 +0200
Subject: [PATCH 011/916] product-lines tiers lists every row, present or new,
before it reports there is nothing to do
Co-Authored-By: Claude Sonnet 5.5
---
tools/AetherDb/ProductLinesCommand.cs | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/tools/AetherDb/ProductLinesCommand.cs b/tools/AetherDb/ProductLinesCommand.cs
index 5ee316a38..2c82d5ebf 100644
--- a/tools/AetherDb/ProductLinesCommand.cs
+++ b/tools/AetherDb/ProductLinesCommand.cs
@@ -228,15 +228,15 @@ public static class ProductLinesCommand
}
var missing = resolved.Where(r => !r.Present).ToArray();
- if (missing.Length == 0)
- {
- Console.WriteLine("The tiers are already authored; nothing to do.");
- return 0;
- }
-
Console.WriteLine("Product tiers:");
foreach (var (row, parent, present) in resolved)
Console.WriteLine($" {(present ? "present" : "new ")} {row.Line} -> \"{row.Name}\" by {db.Cache.Get(parent.Manufacturer)?.ShortName}, floor {row.Floor:0.##}: {row.Description}");
+ if (missing.Length == 0)
+ {
+ Console.WriteLine("\nThe tiers are already authored; nothing to do.");
+ return 0;
+ }
+
if (!apply)
{
Console.WriteLine($"\nDry run. Pass \"apply\" to author {missing.Length} bins.");
From fb7b95fb0659fbf8bff77787bc997c4662d2b47f Mon Sep 17 00:00:00 2001
From: Meta Vens
Date: Sun, 18 Oct 2026 18:19:00 +0200
Subject: [PATCH 012/916] ProductChoiceTests: a bin takes nothing from another
maker's product
Co-Authored-By: Claude Sonnet 5.5
---
tests/Aetheria.Shared.Tests/ProductChoiceTests.cs | 2 ++
1 file changed, 2 insertions(+)
diff --git a/tests/Aetheria.Shared.Tests/ProductChoiceTests.cs b/tests/Aetheria.Shared.Tests/ProductChoiceTests.cs
index a11708393..5061d4603 100644
--- a/tests/Aetheria.Shared.Tests/ProductChoiceTests.cs
+++ b/tests/Aetheria.Shared.Tests/ProductChoiceTests.cs
@@ -272,6 +272,8 @@ public sealed class ProductChoiceTests : IDisposable
Assert.Equal(.2514f * preference, generator.ProductWeight(quarter.Product("lamp-a bin")), 3);
Assert.Equal(.7486f * preference, generator.ProductWeight(quarter.Product("lamp-a")), 3);
Assert.Equal(preference, generator.ProductWeight(quarter.Product("lamp-a bin")) + generator.ProductWeight(quarter.Product("lamp-a")), 3);
+ // Another maker's product, whose line has no bin, weighs what it did without any bin in the catalog.
+ Assert.Equal(alone.Outfitter(alone.OutEven, 1, 0).ProductWeight(alone.Product("lamp-z")), generator.ProductWeight(quarter.Product("lamp-z")), 3);
var half = Build(new[] { 0f }, new[] { "lamp-z", "lamp-a" });
generator = half.Outfitter(half.OutEven, 1, 0);
From beb733f4b50f556012983d7bb60d43760721c891 Mon Sep 17 00:00:00 2001
From: Meta Vens
Date: Sun, 18 Oct 2026 18:46:05 +0200
Subject: [PATCH 013/916] Census role gaps become RoleGaps, so a bin skipped by
the census has a test; a bin authored on another line is refused
Co-Authored-By: Claude Sonnet 5.5
---
.../ProductTiersCommandTests.cs | 7 ++++
.../RolesBackfillCommandTests.cs | 30 ++++++++++++++++
tools/AetherDb/Program.cs | 34 ++++++++++++-------
3 files changed, 58 insertions(+), 13 deletions(-)
diff --git a/tests/Aetheria.Shared.Tests/ProductTiersCommandTests.cs b/tests/Aetheria.Shared.Tests/ProductTiersCommandTests.cs
index 856cca7dc..2899737e0 100644
--- a/tests/Aetheria.Shared.Tests/ProductTiersCommandTests.cs
+++ b/tests/Aetheria.Shared.Tests/ProductTiersCommandTests.cs
@@ -126,6 +126,13 @@ public sealed class ProductTiersCommandTests : IDisposable
Refused(new ProductLinesCommand.TierRow("Sparrow", "Goldcrest", .5f, "x"), "already belongs");
}
+ [Fact]
+ public void A_bin_already_authored_on_another_line_is_refused()
+ {
+ Assert.Equal(0, ProductLinesCommand.Run(Apply, _root));
+ Refused(new ProductLinesCommand.TierRow("Spotlight", "Goldcrest", .67f, "x"), "already belongs");
+ }
+
[Fact]
public void A_line_the_catalog_does_not_hold_is_refused()
{
diff --git a/tests/Aetheria.Shared.Tests/RolesBackfillCommandTests.cs b/tests/Aetheria.Shared.Tests/RolesBackfillCommandTests.cs
index 1f0f974f5..31152b63c 100644
--- a/tests/Aetheria.Shared.Tests/RolesBackfillCommandTests.cs
+++ b/tests/Aetheria.Shared.Tests/RolesBackfillCommandTests.cs
@@ -239,6 +239,36 @@ public sealed class RolesBackfillCommandTests : IDisposable
finally { db.Cache.Dispose(); }
}
+ // The census reports a seller that authors no spread for a role of its design as a gap, and never a bin: a bin reads its line's.
+ [Fact]
+ public void The_census_reports_a_roleless_seller_and_never_a_bin()
+ {
+ var db = AetherDb.Open(catalogWritable: true, root: _root);
+ var autocannon = db.Cache.GetAll().Single(weapon => weapon.Name == "Autocannon");
+ var seller = db.Cache.GetAll().OrderBy(p => p.Name, StringComparer.Ordinal).First(p => p.Design.Key.Equals(db.Cache.RefOf(autocannon).Key));
+ var sellerName = seller.Name;
+ seller.Roles = new List();
+ db.Cache.Commit(batch =>
+ {
+ batch.Upsert(typeof(FactionProductData), seller, db.Cache.RefOf(seller).Key);
+ batch.Upsert(typeof(FactionProductData), new FactionProductData
+ {
+ Name = "Binned " + sellerName, Design = seller.Design, Manufacturer = seller.Manufacturer,
+ Bin = new ProductBin { Line = db.Cache.RefOf(seller), Floor = 0f }
+ });
+ });
+ db.Cache.Dispose();
+
+ db = AetherDb.Open(root: _root);
+ try
+ {
+ var gaps = Program.RoleGaps(db.Cache, db.Cache.GetAll().ToArray(), db.Cache.GetAll().ToArray()).ToArray();
+ Assert.Contains(gaps, gap => gap.Product.Name == sellerName && gap.Missing.Length == 2);
+ Assert.DoesNotContain(gaps, gap => gap.Product.Name == "Binned " + sellerName);
+ }
+ finally { db.Cache.Dispose(); }
+ }
+
// roles-migrate authors a role on every product that sells a design lacking one; a bin sells none of its own.
[Fact]
public void A_binned_seller_gains_no_roles_from_roles_migrate()
diff --git a/tools/AetherDb/Program.cs b/tools/AetherDb/Program.cs
index d88718817..7a28b1aa0 100644
--- a/tools/AetherDb/Program.cs
+++ b/tools/AetherDb/Program.cs
@@ -129,25 +129,33 @@ public static class Program
// or a product added after roles landed), so every sold, role-bearing design is checked against every
// product that actually sells it, not only the ones this run's roles-migrate happened to touch.
var roleGaps = 0;
- foreach (var item in items.Where(i => i.Roles != null && i.Roles.Count > 0))
+ foreach (var (product, item, missing) in RoleGaps(db.Cache, items, products))
{
- var design = db.Cache.RefOf(item).Key;
- // A bin authors no spread: it reads its line's (ProductBin).
- var sellers = products.Where(p => p.Bin == null && p.Design.Key.Equals(design)).ToArray();
- foreach (var product in sellers)
- {
- var covered = new HashSet((product.Roles ?? new List()).Select(r => r.Role));
- var missing = item.Roles.Select(r => r.Name).Where(r => !covered.Contains(r)).ToArray();
- if (missing.Length == 0) continue;
- roleGaps++;
- Console.WriteLine($" GAP: {product.Name} sells {item.Name} but authors no spread for: {string.Join(", ", missing)}" +
- " -- a newly minted lot rolls the ProductRole default (mean .5) for these, not this maker's own quality");
- }
+ roleGaps++;
+ Console.WriteLine($" GAP: {product.Name} sells {item.Name} but authors no spread for: {string.Join(", ", missing)}" +
+ " -- a newly minted lot rolls the ProductRole default (mean .5) for these, not this maker's own quality");
}
Console.WriteLine($"\n{roleGaps} (product, role) pairs where a sold, role-bearing design's product authors no matching spread");
return 0;
}
+ // Every seller of a role-bearing design that authors no spread for one of its roles. A bin authors no spread: it reads its
+ // line's (ProductBin), so it is never a gap.
+ internal static IEnumerable<(FactionProductData Product, EquippableItemData Design, string[] Missing)> RoleGaps(
+ GameCult.Caching.CultCache cache, IEnumerable items, IEnumerable products)
+ {
+ foreach (var item in items.Where(i => i.Roles != null && i.Roles.Count > 0))
+ {
+ var design = cache.RefOf(item).Key;
+ foreach (var product in products.Where(p => p.Bin == null && p.Design.Key.Equals(design)))
+ {
+ var covered = new HashSet((product.Roles ?? new List()).Select(r => r.Role));
+ var missing = item.Roles.Select(r => r.Name).Where(r => !covered.Contains(r)).ToArray();
+ if (missing.Length > 0) yield return (product, item, missing);
+ }
+ }
+ }
+
// Cut 7 (docs/stats-and-power-cut.md): "products author quality, designs author roles." Zero designs
// declared a role and zero products authored role quality before this command; every field->role table below
// is the one place that content is decided, so the operator reviews a legible table instead of hand-picking
From 9457e4c8f93e90fb5e6b6857667f7bd9d2f097f3 Mon Sep 17 00:00:00 2001
From: Meta Vens
Date: Sun, 18 Oct 2026 19:51:40 +0200
Subject: [PATCH 014/916] ProductBinTests: the search's 64-draw bound and its
stop at the first clearing draw, and the missing-line log, are pinned
Co-Authored-By: Claude Sonnet 5.5
---
.../Aetheria.Shared.Tests/ProductBinTests.cs | 25 ++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)
diff --git a/tests/Aetheria.Shared.Tests/ProductBinTests.cs b/tests/Aetheria.Shared.Tests/ProductBinTests.cs
index 44bbfe077..03762fdf2 100644
--- a/tests/Aetheria.Shared.Tests/ProductBinTests.cs
+++ b/tests/Aetheria.Shared.Tests/ProductBinTests.cs
@@ -130,6 +130,27 @@ public sealed class ProductBinTests : IDisposable
});
}
+ // The search draws at most 64 times, and stops at the first draw that clears the cutoff: the stream after it is what shows how
+ // many draws it took. An unreachable cutoff takes exactly 64, a deviation of 0 (draw equal to the cutoff) takes 1.
+ [Fact]
+ public void TheSearchDrawsAtMostSixtyFourTimesAndStopsAtTheFirstDrawThatClearsTheCutoff()
+ {
+ float AfterDraws(int draws)
+ {
+ var random = new CultMath.Random(11u);
+ for (var i = 0; i < draws; i++) random.NextGaussian(0, 1);
+ return random.NextGaussian(0, 1);
+ }
+
+ var unreachable = new CultMath.Random(11u);
+ Assert.Equal(40f, unreachable.NextGaussianAbove(0, 1, 40f));
+ Assert.Equal(AfterDraws(64), unreachable.NextGaussian(0, 1));
+
+ var immediate = new CultMath.Random(11u);
+ Assert.Equal(.5f, immediate.NextGaussianAbove(.5f, 0, 0));
+ Assert.Equal(AfterDraws(1), immediate.NextGaussian(0, 1));
+ }
+
// Snapshot of the first five assemblies and fills at base, before the bin existed (seed 20261018, lens .5 +- .1, maker .6 +- .1).
[Fact]
public void UnbinnedMintConsumesTheStreamAsBefore()
@@ -137,6 +158,7 @@ public sealed class ProductBinTests : IDisposable
var line = Line();
_items.Random = new CultMath.Random(20261018u);
var lots = Mint(line, 5);
+ Assert.Empty(_log);
var assemblies = new[] { .59560823f, .68289334f, .57563853f, .5639112f, .59828424f };
var fills = new[] { .6311789f, .5835483f, .47641385f, .46416125f, .45124212f };
for (var i = 0; i < 5; i++)
@@ -170,6 +192,7 @@ public sealed class ProductBinTests : IDisposable
_cache.Remove(_cache.RefOf(line).Key);
var lots = Mint(bin, 5);
Assert.Equal(5, lots.Length);
- Assert.NotEmpty(_log);
+ Assert.Equal(5, _log.Count);
+ Assert.All(_log, message => Assert.False(string.IsNullOrWhiteSpace(message)));
}
}
From 0ed0605aa5a88af20af27ebe200c0814d8a908ca Mon Sep 17 00:00:00 2001
From: Meta Vens
Date: Sun, 18 Oct 2026 20:13:03 +0200
Subject: [PATCH 015/916] Pin the run seed's edges: AI dice stay on CombatSeed,
full-width seed, refusal names its field, refusal test cannot hang
- ConsumableAiTests.ThePilotsDiceDoNotMoveWithTheRunSeed: sample offset and patrol circuit equal at different run seeds.
- RunSaveTests.TheRunSeedRidesTheSave uses a seed with the top bit set.
- RunStartTests.AGeneratedGalaxyRefusesSeedZero builds from authored settings (small ZoneCount) so a constructor that stops refusing fails by assertion, and pins ParamName and no ActualValue.
Co-Authored-By: Claude Sonnet 5.5
---
.../ConsumableAiTests.cs | 31 +++++++++++++++++--
tests/Aetheria.Shared.Tests/RunSaveTests.cs | 10 +++---
tests/Aetheria.Shared.Tests/RunStartTests.cs | 22 ++++++++++---
3 files changed, 50 insertions(+), 13 deletions(-)
diff --git a/tests/Aetheria.Shared.Tests/ConsumableAiTests.cs b/tests/Aetheria.Shared.Tests/ConsumableAiTests.cs
index 6ad889fda..2f5863958 100644
--- a/tests/Aetheria.Shared.Tests/ConsumableAiTests.cs
+++ b/tests/Aetheria.Shared.Tests/ConsumableAiTests.cs
@@ -50,6 +50,7 @@ public sealed class ConsumableAiTests : IDisposable
public GearData HeavyGun;
public CultRecordRef Maker;
public float Optimum;
+ public CultRecordKey[] Circuit;
public void Store(ConsumableItemData design) =>
Assert.True(Hold.TryStore((ItemInstance) Items.CreateInstance(Items.CreateLot(design, Maker, .5f))));
@@ -97,7 +98,7 @@ public sealed class ConsumableAiTests : IDisposable
}
};
- private Scene Build(bool carryVent = false, bool carryOverdrive = false, bool carryDecoy = false, int stackableVents = 0, float effective = 500f)
+ private Scene Build(bool carryVent = false, bool carryOverdrive = false, bool carryDecoy = false, int stackableVents = 0, float effective = 500f, uint? runSeed = null, int orbits = 1)
{
var cache = AetheriaStores.Open(Path.Combine(_root, Guid.NewGuid().ToString("N") + ".cc"), catalogWritable: true);
_caches.Add(cache);
@@ -150,7 +151,10 @@ public sealed class ConsumableAiTests : IDisposable
var maker = cache.RefOf(cache.GetByName("Maker"));
EquippableItem Make(string name) where T : CraftedItemData =>
(EquippableItem) items.CreateInstance(items.CreateLot(cache.GetByName(name), maker, .5f));
- var zone = new Zone(items, new PlanetSettings(), new ZonePack(), new GalaxyZone { Name = "Test Zone", Owner = null }, null);
+ var galaxy = runSeed.HasValue ? RunSeedFixture.Continue(cache, "Test Zone", runSeed.Value) : null;
+ var zone = galaxy != null
+ ? new Zone(items, new PlanetSettings(), new ZonePack(), galaxy.Zones[0], galaxy)
+ : new Zone(items, new PlanetSettings(), new ZonePack(), new GalaxyZone { Name = "Test Zone", Owner = null }, null);
Ship NewShip(string gear)
{
var ship = new Ship(items, zone, Make("Skiff"), new EntitySettings())
@@ -174,8 +178,10 @@ public sealed class ConsumableAiTests : IDisposable
// The agent joins as the zone admits a piloted ship (its Minion and CombatState come from production); the
// locker is a gun ship nobody pilots.
// One fixed orbit far from the fight, before the agent joins: a pilot that is not engaged patrols it, as production's would.
- zone.Orbits.Add(new CultRecordKey("test-orbit"), new Orbit(new OrbitData { FixedPosition = float2(0, 5000) }));
+ for (var i = 0; i < orbits; i++)
+ zone.Orbits.Add(new CultRecordKey(orbits == 1 ? "test-orbit" : "test-orbit-" + i), new Orbit(new OrbitData { FixedPosition = float2(0, 5000) }));
zone.Admit(scene.Agent, piloted: true);
+ scene.Circuit = ((PatrolOrbitsTask) zone.Agents.Single().Task).Circuit;
zone.Admit(scene.Prey, piloted: false);
zone.Admit(scene.Locker, piloted: false);
// The flight is the only writer of the agent's Target: the agent senses the prey and holds a grudge on it, so the
@@ -356,6 +362,25 @@ public sealed class ConsumableAiTests : IDisposable
// The production path for the optimum: a ship the zone admits as piloted derives it from its gun's live stats
// before it needs it, and re-derives it when its loadout changes. The gun's effective range is 500 and the
// heavy gun's is 800, so the optimum moves with the weapons it has now.
+ // The run seed feeds drops and mines only (ruling run-seed-drops-only): the same pilot in the same zone samples its
+ // range with the same offset and draws the same patrol circuit at every run seed. Kills: the combat-sample dice or
+ // the patrol dice read DropSeed.
+ [Theory]
+ [InlineData(1u, 2u)]
+ [InlineData(0xC0FFEE42u, 0x2468ACE1u)]
+ public void ThePilotsDiceDoNotMoveWithTheRunSeed(uint first, uint second)
+ {
+ var a = Build(runSeed: first, orbits: 8);
+ var b = Build(runSeed: second, orbits: 8);
+ a.AssertInCombat();
+ b.AssertInCombat();
+ Assert.NotEqual(a.Zone.DropSeed, b.Zone.DropSeed);
+ Assert.Equal(a.Zone.CombatSeed, b.Zone.CombatSeed);
+ Assert.Equal(a.Optimum, b.Optimum);
+ Assert.Equal(4, a.Circuit.Length);
+ Assert.Equal(a.Circuit, b.Circuit);
+ }
+
[Fact]
public void ASpawnedShipsOptimumFollowsItsWeaponsAndNeverReadsZero()
{
diff --git a/tests/Aetheria.Shared.Tests/RunSaveTests.cs b/tests/Aetheria.Shared.Tests/RunSaveTests.cs
index 7e32c9928..456561d76 100644
--- a/tests/Aetheria.Shared.Tests/RunSaveTests.cs
+++ b/tests/Aetheria.Shared.Tests/RunSaveTests.cs
@@ -178,25 +178,25 @@ public sealed class RunSaveTests : IDisposable
using (var cache = Open())
{
var game = Game(cache);
- game.Seed = 0xC0FFEEu;
+ game.Seed = 0xC0FFEE42u;
RunSave.Commit(cache, game, Zones(2, StageZoneContents(cache), 0), new ProvenanceLedger());
}
using (var cache = Open())
{
var galaxy = new Galaxy(cache, cache.GetGlobal(), _ => { });
- Assert.Equal(0xC0FFEEu, galaxy.Seed);
+ Assert.Equal(0xC0FFEE42u, galaxy.Seed);
var itemManager = new ItemManager(cache, new ProvenanceLedger(), TestSettings(), _ => { });
galaxy.Zones[0].Contents = new Zone(itemManager, new PlanetSettings(), new ZonePack(), galaxy.Zones[0], galaxy);
// The zone's drop dice are its name's seed mixed with the run's.
- Assert.Equal("Zone 0".StableHash() ^ SimulationDice.Mix(0xC0FFEEu), galaxy.Zones[0].Contents.DropSeed);
+ Assert.Equal("Zone 0".StableHash() ^ SimulationDice.Mix(0xC0FFEE42u), galaxy.Zones[0].Contents.DropSeed);
var (game, zones) = RunSave.Capture(cache, galaxy, galaxy.Zones[0].Contents, null, new SavedActionBarBinding[0], 0);
- Assert.Equal(0xC0FFEEu, game.Seed);
+ Assert.Equal(0xC0FFEE42u, game.Seed);
RunSave.Commit(cache, game, zones, RunSave.Lots(cache));
}
using (var cache = Open())
- Assert.Equal(0xC0FFEEu, cache.GetGlobal().Seed);
+ Assert.Equal(0xC0FFEE42u, cache.GetGlobal().Seed);
// A save written before run-seed holds no seed, and continues on name-only drops.
using (var cache = Open())
diff --git a/tests/Aetheria.Shared.Tests/RunStartTests.cs b/tests/Aetheria.Shared.Tests/RunStartTests.cs
index 7c22bb911..4b181f67e 100644
--- a/tests/Aetheria.Shared.Tests/RunStartTests.cs
+++ b/tests/Aetheria.Shared.Tests/RunStartTests.cs
@@ -115,14 +115,26 @@ public sealed partial class RunStartTests : IDisposable
private const float Freezing = 273.15f;
- // One minter: a generated galaxy never reads the clock, so seed 0 is refused by both generation constructors.
+ // One minter: a generated galaxy never reads the clock, so seed 0 is refused by both generation constructors, naming
+ // the field and echoing no input (no ActualValue). The settings are the authored ones: a galaxy that stops refusing must be able to
+ // finish generating, so the test fails by assertion rather than wedging in the generator.
[Fact]
public void AGeneratedGalaxyRefusesSeedZero()
{
- Assert.Throws(() =>
- new Galaxy(new SectorGenerationSettings(), new SectorBackgroundSettings(), _cache, _ => { }, null, 0));
- Assert.Throws(() =>
- new Galaxy(new TutorialGenerationSettings(), new SectorBackgroundSettings(), _cache, new PlayerSettings(), new DirectoryInfo(_root), _ => { }, null, 0));
+ var authored = AuthoredSettings.Load(FindRepoRoot());
+ var background = authored.Read("SectorBackgroundSettings");
+ var sector = authored.Read("SectorGenerationSettings");
+ sector.ZoneCount = 8;
+ var tutorial = authored.Read("TutorialGenerationSettings");
+
+ var main = Assert.Throws(() => new Galaxy(sector, background, _cache, _ => { }, null, 0));
+ var prelude = Assert.Throws(() =>
+ new Galaxy(tutorial, background, _cache, new PlayerSettings(), new DirectoryInfo(_root), _ => { }, null, 0));
+ foreach (var refusal in new[] { main, prelude })
+ {
+ Assert.Equal("seed", refusal.ParamName);
+ Assert.Null(refusal.ActualValue);
+ }
}
// A main-sector galaxy: each station's gear must come from manufacturers its faction can reach, the makers its
From cb1c093e84b90ea634a708a0eb6bf06ba30f0dce Mon Sep 17 00:00:00 2001
From: Meta Vens
Date: Sun, 18 Oct 2026 20:21:31 +0200
Subject: [PATCH 016/916] ConsumableAiTests: open the run store so a scene can
continue a run at a fixed seed
Co-Authored-By: Claude Sonnet 5.5
---
tests/Aetheria.Shared.Tests/ConsumableAiTests.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/Aetheria.Shared.Tests/ConsumableAiTests.cs b/tests/Aetheria.Shared.Tests/ConsumableAiTests.cs
index 2f5863958..7478b3440 100644
--- a/tests/Aetheria.Shared.Tests/ConsumableAiTests.cs
+++ b/tests/Aetheria.Shared.Tests/ConsumableAiTests.cs
@@ -100,7 +100,7 @@ public sealed class ConsumableAiTests : IDisposable
private Scene Build(bool carryVent = false, bool carryOverdrive = false, bool carryDecoy = false, int stackableVents = 0, float effective = 500f, uint? runSeed = null, int orbits = 1)
{
- var cache = AetheriaStores.Open(Path.Combine(_root, Guid.NewGuid().ToString("N") + ".cc"), catalogWritable: true);
+ var cache = AetheriaStores.Open(Path.Combine(_root, Guid.NewGuid().ToString("N") + ".cc"), Path.Combine(_root, Guid.NewGuid().ToString("N") + ".run.cc"), catalogWritable: true);
_caches.Add(cache);
cache.Upsert(new VerseGrammar { Revision = 1 });
cache.Upsert(new Faction { Name = "Maker", ShortName = "MKR" });
From 129e5ff4dc506737721e28c2e1a46445bf8a03d1 Mon Sep 17 00:00:00 2001
From: Meta Vens
Date: Sun, 18 Oct 2026 21:08:09 +0200
Subject: [PATCH 017/916] ProductWeight is the one weight of every design-only
draw; a line's bin shares are read once per pass
The all-weights-zero branch of ChooseProduct and the required-item fallback of RandomProducts weighed
every product 1, so a bin doubled its maker's presence there. Both now weigh by Share alone (the
preference drops out, the bins' shares do not). The sum of a line's bins' pass fractions is computed
once per weighting pass instead of scanning the product table per candidate.
Co-Authored-By: Claude Sonnet 5.5
---
.../Scripts/ServerShared/LoadoutGenerator.cs | 29 +++++++++----
.../ProductChoiceTests.cs | 42 +++++++++++++++++++
2 files changed, 62 insertions(+), 9 deletions(-)
diff --git a/Assets/Scripts/ServerShared/LoadoutGenerator.cs b/Assets/Scripts/ServerShared/LoadoutGenerator.cs
index 0206935fb..834e4dc7c 100644
--- a/Assets/Scripts/ServerShared/LoadoutGenerator.cs
+++ b/Assets/Scripts/ServerShared/LoadoutGenerator.cs
@@ -176,8 +176,9 @@ public class LoadoutGenerator
public (FactionProductData product, T design)[] RandomProducts(int count, float sizeExponent, Predicate filter = null, bool required = false) where T : CraftedItemData
{
var (available, preferManufacturers) = AvailableProducts(filter, required);
+ var shares = BinShares();
return available.WeightedRandomElements(ref Random, entry =>
- (preferManufacturers ? ProductWeight(entry.product) : 1) *
+ Weight(entry.product, shares, preferManufacturers) *
pow(entry.design.Shape.Coordinates.Length, sizeExponent) / // Prioritize larger items
pow(entry.design.Price, PriceExponent), // Penalize item price to a controllable degree
count);
@@ -255,22 +256,31 @@ public class LoadoutGenerator
// How much this outfitter favors a product: its maker's preference times the product's share of it. The one weight of
// generation and of ChooseProduct. A bin takes the share of its maker's stock that would pass its floor and its line takes
// the rest (ruling bin-share-by-floor), so binning never changes a maker's presence for the design.
- public float ProductWeight(FactionProductData product) => ManufacturerPreference(product.Manufacturer) * Share(product);
+ public float ProductWeight(FactionProductData product) => Weight(product, BinShares(), true);
+
+ // The one weight, with the share of the stock computed from shares (BinShares, once per weighting pass). A draw that has
+ // fallen back to any manufacturer weighs by share alone: the maker's preference no longer applies, its bins' shares still do.
+ private float Weight(FactionProductData product, Dictionary shares, bool preferManufacturers) =>
+ (preferManufacturers ? ManufacturerPreference(product.Manufacturer) : 1) * Share(product, shares);
// 1 - Phi(floor): the fraction of a normal draw that lies at least floor deviations above its mean.
private static float PassFraction(float floor) => .5f * (1 - erf(floor / sqrt(2f)));
- private float Share(FactionProductData product)
+ // Each line's key to the sum of its bins' pass fractions: read from the catalog once per weighting pass, never kept.
+ private Dictionary BinShares() => ItemManager.ItemData.GetAll()
+ .Where(product => product.Bin != null)
+ .GroupBy(product => product.Bin.Line.Key.Value)
+ .ToDictionary(group => group.Key, group => group.Sum(bin => PassFraction(bin.Bin.Floor)));
+
+ private float Share(FactionProductData product, Dictionary shares)
{
if (product.Bin != null) return PassFraction(product.Bin.Floor);
- var key = ItemManager.ItemData.RefOf(product).Key;
- var binned = ItemManager.ItemData.GetAll().Where(other => other.Bin != null && other.Bin.Line.Key.Equals(key)).Sum(bin => PassFraction(bin.Bin.Floor));
- return max(0f, 1 - binned);
+ return max(0f, 1 - shares.GetValueOrDefault(ItemManager.ItemData.RefOf(product).Key.Value));
}
// The product a design named without one is built as (ruling loadout-product-optional-context-chooses): among the
// products of the design this outfitter can get, one draw from the run's seeded Random weighted by ProductWeight;
- // null when none, and uniform over them when every weight is 0. Candidates are ordered by name so the draw's
+ // null when none, and by share alone when every weight is 0. Candidates are ordered by name so the draw's
// enumeration, and so its result, never depends on record keys. All of the policy is this body.
public FactionProductData ChooseProduct(CraftedItemData design)
{
@@ -280,8 +290,9 @@ public class LoadoutGenerator
.OrderBy(product => product.Name, StringComparer.Ordinal)
.ToArray();
if (candidates.Length == 0) return null;
- var uniform = candidates.All(product => ProductWeight(product) <= 0);
- return candidates.WeightedRandomElements(ref Random, product => uniform ? 1 : ProductWeight(product), 1)[0];
+ var shares = BinShares();
+ var uniform = candidates.All(product => Weight(product, shares, true) <= 0);
+ return candidates.WeightedRandomElements(ref Random, product => Weight(product, shares, !uniform), 1)[0];
}
// Prioritize products from the zone faction and its allies, penalizing distance to the manufacturer's headquarters.
diff --git a/tests/Aetheria.Shared.Tests/ProductChoiceTests.cs b/tests/Aetheria.Shared.Tests/ProductChoiceTests.cs
index 5061d4603..89f262c62 100644
--- a/tests/Aetheria.Shared.Tests/ProductChoiceTests.cs
+++ b/tests/Aetheria.Shared.Tests/ProductChoiceTests.cs
@@ -300,6 +300,48 @@ public sealed class ProductChoiceTests : IDisposable
Assert.Equal(0f, three.Outfitter(three.OutEven, 1, 0).ProductWeight(three.Product("lamp-a")));
}
+ // Ruling bin-share-by-floor holds on every draw of a design, not only the preference-weighted one. When every reachable maker
+ // weighs 0 the ChooseProduct draw is by share alone, and Alpha's line and bin together keep the half they held as one product.
+ [Fact]
+ public void ABinLeavesItsMakersShareOfTheAllZeroWeightDrawUnchanged()
+ {
+ int AlphaDraws(Rig rig)
+ {
+ var lamp = rig.Cache.GetByName("Lamp");
+ var zero = rig.Cache.GetByName("OutZero");
+ return Enumerable.Range(1, 1000).Count(i => rig.Cache.Get(rig.Outfitter(zero, Seed(i), 0).ChooseProduct(lamp).Manufacturer).Name == "Alpha");
+ }
+
+ Assert.InRange(AlphaDraws(Build("lamp-z", "lamp-a")), 440, 560);
+ Assert.InRange(AlphaDraws(Build(new[] { .67f }, new[] { "lamp-z", "lamp-a" })), 440, 560);
+ Assert.InRange(AlphaDraws(Build(new[] { 0f }, new[] { "lamp-z", "lamp-a" })), 440, 560);
+ }
+
+ // The same for a required item that has fallen back to any manufacturer (OutNone is allied to nobody, so no product is on offer
+ // and the fallback weighs every product alike, but for the bins' shares).
+ [Fact]
+ public void ABinLeavesItsMakersShareOfTheRequiredFallbackDrawUnchanged()
+ {
+ int AlphaDraws(Rig rig)
+ {
+ var log = new List();
+ var items = new ItemManager(rig.Cache, new ProvenanceLedger(), RunSaveTests.TestSettings(), log.Add);
+ var lamp = rig.Cache.GetByName("Lamp");
+ var alpha = Enumerable.Range(1, 1000).Count(i =>
+ {
+ var random = new Random(Seed(i));
+ var generator = new LoadoutGenerator(ref random, items, rig.Galaxy, null, rig.OutNone, .5f);
+ return rig.Cache.Get(generator.RandomProduct(0, design => design == lamp, required: true).product.Manufacturer).Name == "Alpha";
+ });
+ Assert.NotEmpty(log);
+ return alpha;
+ }
+
+ Assert.InRange(AlphaDraws(Build("lamp-z", "lamp-a")), 440, 560);
+ Assert.InRange(AlphaDraws(Build(new[] { .67f }, new[] { "lamp-z", "lamp-a" })), 440, 560);
+ Assert.InRange(AlphaDraws(Build(new[] { 0f }, new[] { "lamp-z", "lamp-a" })), 440, 560);
+ }
+
// A weight that read the allegiance alone would give 1 : .25 here, an 80% draw; the zone and allegiance together
// give 1 : .125 for alpha at its own zone, 89%.
[Fact]
From f73507ff2fa847ac0cd0d0eafcc9d02f32e7f78e Mon Sep 17 00:00:00 2001
From: Meta Vens
Date: Sun, 18 Oct 2026 21:08:10 +0200
Subject: [PATCH 018/916] Catalog read refuses a bin with a non-finite Floor, a
missing Line or a Line that is a bin; a bin mints from exactly its named line
(tested)
The runtime no longer trusts the authoring tool for a bin: a NaN Floor weighed NaN and nulled every
draw of its design. AetheriaStores.Open names the field and echoes no value.
Co-Authored-By: Claude Sonnet 5.5
---
Assets/Scripts/ServerShared/AetheriaStores.cs | 19 +++++
.../Aetheria.Shared.Tests/ProductBinTests.cs | 78 +++++++++++++++++++
2 files changed, 97 insertions(+)
diff --git a/Assets/Scripts/ServerShared/AetheriaStores.cs b/Assets/Scripts/ServerShared/AetheriaStores.cs
index 4afb00b1d..525894ac9 100644
--- a/Assets/Scripts/ServerShared/AetheriaStores.cs
+++ b/Assets/Scripts/ServerShared/AetheriaStores.cs
@@ -41,6 +41,7 @@ public static class AetheriaStores
foreach (var data in cache.GetAll()) CultRecordRefs.Validate(data);
foreach (var data in cache.GetAll()) CultRecordRefs.Validate(data);
VerseGrammarValidation.ValidateAll(cache.GetAll());
+ ValidateBins(cache);
return cache;
}
catch
@@ -49,6 +50,24 @@ public static class AetheriaStores
throw;
}
}
+
+ // The mint and the weighting trust a bin: they never check its Floor or its Line. So the catalog read refuses one whose Floor is
+ // not a finite number (it would weigh NaN and poison every draw of its design), whose Line names no product the catalog holds, or
+ // whose Line is itself a bin (a bin is of a line, never of a bin). The refusals name the field and echo no value.
+ private static void ValidateBins(CultCache cache)
+ {
+ foreach (var product in cache.GetAll())
+ {
+ if (product.Bin == null) continue;
+ if (!float.IsFinite(product.Bin.Floor))
+ throw new InvalidOperationException("A product bin's Floor is not a finite number.");
+ var line = cache.Get(product.Bin.Line);
+ if (line == null)
+ throw new InvalidOperationException("A product bin's Line names no product this catalog holds.");
+ if (line.Bin != null)
+ throw new InvalidOperationException("A product bin's Line names another bin; a bin is of a line.");
+ }
+ }
}
public static class CultRecordRefs
diff --git a/tests/Aetheria.Shared.Tests/ProductBinTests.cs b/tests/Aetheria.Shared.Tests/ProductBinTests.cs
index 03762fdf2..c7b7de1fb 100644
--- a/tests/Aetheria.Shared.Tests/ProductBinTests.cs
+++ b/tests/Aetheria.Shared.Tests/ProductBinTests.cs
@@ -183,6 +183,84 @@ public sealed class ProductBinTests : IDisposable
Assert.Equal("Premiere", product.Name);
}
+ // The line a bin draws from is the one Bin.Line names, not another line of the design: three lines of one design, by three
+ // makers, with the bin on the middle one by name, so a bin that reads the first or the last line of the design is far off.
+ [Fact]
+ public void ABinMintsFromExactlyTheLineItNames()
+ {
+ Line("A line", lensMean: .3f, makerMean: .2f);
+ var middle = Line("M line", lensMean: .6f, makerMean: .5f);
+ Line("Z line", lensMean: .9f, makerMean: .9f);
+ var lots = Mint(Bin(middle, "Middle Premiere", 0), 400);
+ Assert.All(lots, lot =>
+ {
+ Assert.True(lot.Roles.Single().Quality >= .6f - 1e-5f, "a fill came from a line below the named one");
+ Assert.True(lot.Quality >= .5f - 1e-5f, "an assembly came from a maker below the named line's");
+ });
+ Assert.InRange(Fills(lots).Average(), .64f, .72f);
+ Assert.InRange(lots.Average(lot => lot.Quality), .55f, .62f);
+ }
+
+ private const string Canary = "canary-7f3a91";
+
+ private enum Damage { None, LineRemoved, LineIsBin }
+
+ // A catalog on disk holding one line and a bin of it, damaged as asked, for AetheriaStores.Open to read.
+ private string DamagedCatalog(float floor, Damage damage)
+ {
+ var path = Path.Combine(_root, Guid.NewGuid().ToString("N"), "Aetheria.cc");
+ Directory.CreateDirectory(Path.GetDirectoryName(path));
+ using var seed = AetheriaStores.Open(path, catalogWritable: true);
+ seed.Upsert(new VerseGrammar { Revision = 1 });
+ var maker = seed.Upsert(new Faction { Name = Canary + " Maker" });
+ var gear = seed.Upsert(new GearData { Name = "Lensed", Hardpoint = HardpointType.Sensors, Shape = new Shape(), Price = 10, Roles = { new ItemRole { Name = "lens" } } });
+ var design = new CultRecordRef(gear.Key);
+ var line = seed.Upsert(new FactionProductData { Name = Canary + " Line", Design = design, Manufacturer = maker, Roles = { new ProductRole { Role = "lens" } } });
+ var bin = seed.Upsert(new FactionProductData { Name = Canary, Design = design, Manufacturer = maker, Bin = new ProductBin { Line = line, Floor = floor } });
+ if (damage == Damage.LineIsBin)
+ seed.Upsert(new FactionProductData { Name = Canary + " Nested", Design = design, Manufacturer = maker, Bin = new ProductBin { Line = bin, Floor = 0 } });
+ if (damage == Damage.LineRemoved) seed.Remove(line.Key);
+ seed.FlushAsync().Wait();
+ return path;
+ }
+
+ // The runtime does not trust authoring for a bin: a NaN floor would weigh NaN and null every draw of its design.
+ [Theory]
+ [InlineData(float.NaN)]
+ [InlineData(float.PositiveInfinity)]
+ [InlineData(float.NegativeInfinity)]
+ public void ACatalogWhoseBinFloorIsNotFiniteIsRefusedWhereItIsRead(float floor)
+ {
+ var refusal = Assert.Throws(() => AetheriaStores.Open(DamagedCatalog(floor, Damage.None)));
+ Assert.Contains("Floor", refusal.Message);
+ Assert.DoesNotContain(Canary, refusal.Message);
+ Assert.DoesNotContain(floor.ToString(), refusal.Message);
+ }
+
+ [Fact]
+ public void ACatalogWhoseBinNamesNoLineIsRefusedWhereItIsRead()
+ {
+ var refusal = Assert.Throws(() => AetheriaStores.Open(DamagedCatalog(.67f, Damage.LineRemoved)));
+ Assert.Contains("Line", refusal.Message);
+ Assert.DoesNotContain(Canary, refusal.Message);
+ }
+
+ [Fact]
+ public void ACatalogWhoseBinNamesAnotherBinIsRefusedWhereItIsRead()
+ {
+ var refusal = Assert.Throws(() => AetheriaStores.Open(DamagedCatalog(.67f, Damage.LineIsBin)));
+ Assert.Contains("Line", refusal.Message);
+ Assert.DoesNotContain(Canary, refusal.Message);
+ }
+
+ // The refusals are of damage, not of bins: a sound bin on a sound line reads.
+ [Fact]
+ public void ACatalogWithASoundBinIsRead()
+ {
+ using var cache = AetheriaStores.Open(DamagedCatalog(.67f, Damage.None));
+ Assert.Equal(.67f, cache.GetAll().Single(product => product.Name == Canary).Bin.Floor);
+ }
+
// A bin whose line the catalog does not hold mints as a product with no roles of its own, and says so.
[Fact]
public void ABinOfALineTheCatalogLacksMintsAtDefaultsAndLogs()
From 8d65e957f81764605416202aab1f31b7f6125678 Mon Sep 17 00:00:00 2001
From: Meta Vens
Date: Sun, 18 Oct 2026 21:08:11 +0200
Subject: [PATCH 019/916] sensor-stat-set skips a bin, as the other role
writers do; it takes an optional root for its test
Co-Authored-By: Claude Sonnet 5.5
---
.../RolesBackfillCommandTests.cs | 21 +++++++++++++++++++
tools/AetherDb/Program.cs | 6 +++---
2 files changed, 24 insertions(+), 3 deletions(-)
diff --git a/tests/Aetheria.Shared.Tests/RolesBackfillCommandTests.cs b/tests/Aetheria.Shared.Tests/RolesBackfillCommandTests.cs
index 31152b63c..58c823af4 100644
--- a/tests/Aetheria.Shared.Tests/RolesBackfillCommandTests.cs
+++ b/tests/Aetheria.Shared.Tests/RolesBackfillCommandTests.cs
@@ -290,6 +290,27 @@ public sealed class RolesBackfillCommandTests : IDisposable
finally { db.Cache.Dispose(); }
}
+ // sensor-stat-set authors an emission-discipline role on every product of a sensor design; a bin of one authors none.
+ [Fact]
+ public void A_binned_seller_gains_no_roles_from_sensor_stat_set()
+ {
+ var db = AetherDb.Open(catalogWritable: true, root: _root);
+ var sensor = db.Cache.GetAll().Where(d => d.Behaviors != null && d.Behaviors.OfType().Any()).OrderBy(d => d.Name, StringComparer.Ordinal).First();
+ var seller = db.Cache.GetAll().OrderBy(p => p.Name, StringComparer.Ordinal).First(p => p.Bin == null && p.Design.Key.Equals(db.Cache.RefOf(sensor).Key));
+ var bin = new FactionProductData
+ {
+ Name = "Binned " + seller.Name, Design = seller.Design, Manufacturer = seller.Manufacturer,
+ Bin = new ProductBin { Line = db.Cache.RefOf(seller), Floor = 0f }
+ };
+ db.Cache.Commit(batch => batch.Upsert(typeof(FactionProductData), bin));
+ db.Cache.Dispose();
+
+ Assert.Equal(0, Program.SensorStatSet(apply: true, root: _root));
+ db = AetherDb.Open(root: _root);
+ try { Assert.Empty(db.Cache.GetAll().Single(p => p.Name == "Binned " + seller.Name).Roles); }
+ finally { db.Cache.Dispose(); }
+ }
+
[Fact]
public void A_design_the_catalog_does_not_hold_refuses_and_lands_nothing()
{
diff --git a/tools/AetherDb/Program.cs b/tools/AetherDb/Program.cs
index 7a28b1aa0..fec3d6d3e 100644
--- a/tools/AetherDb/Program.cs
+++ b/tools/AetherDb/Program.cs
@@ -1719,9 +1719,9 @@ public static class Program
// product of such a design authors that role, and the Passive Array (a generic listener gear, ListenerData) is
// authored with two products from the stealth makers. Prints the sensor census first. Dry run unless passed
// "apply"; idempotent, so a second apply writes nothing and a catalog another cut changed is rerun, never merged.
- private static int SensorStatSet(bool apply)
+ internal static int SensorStatSet(bool apply, string root = null)
{
- var db = AetherDb.Open(catalogWritable: apply);
+ var db = AetherDb.Open(catalogWritable: apply, root: root);
var designs = db.Cache.GetAll().ToArray();
var products = db.Cache.GetAll().ToArray();
Faction MakerOf(FactionProductData p) => db.Cache.Get(p.Manufacturer);
@@ -1760,7 +1760,7 @@ public static class Program
design.Roles ??= new List();
if (!design.Roles.Any(r => r.Name == EmissionDiscipline)) { design.Roles.Add(new ItemRole { Name = EmissionDiscipline }); designChanged = true; }
if (designChanged) changedDesigns.Add((design, key));
- foreach (var product in products.Where(p => p.Design.Key.Equals(key)))
+ foreach (var product in products.Where(p => p.Bin == null && p.Design.Key.Equals(key)))
{
var maker = MakerOf(product) ?? throw new InvalidOperationException($"Product \"{product.Name}\" has no maker.");
product.Roles ??= new List();
From 0769314ee6479401e323c0cd39ae9098ea025693 Mon Sep 17 00:00:00 2001
From: Meta Vens
Date: Sun, 18 Oct 2026 21:11:01 +0200
Subject: [PATCH 020/916] aetheria-release map: boss loadout replaces boss hull
derived (Faction.BossLoadout, off-market by product)
Co-Authored-By: Claude Opus 5.5
---
docs/aetheria-release-map.md | 285 +++++++++++++----------------------
1 file changed, 103 insertions(+), 182 deletions(-)
diff --git a/docs/aetheria-release-map.md b/docs/aetheria-release-map.md
index b5e91ddaa..37344be87 100644
--- a/docs/aetheria-release-map.md
+++ b/docs/aetheria-release-map.md
@@ -888,8 +888,8 @@ name. Per ruling `no-save-compatibility-before-players` nothing reads key 11.
|---|---|---|---|
| Pirates `Faction` | Catalog record, name `Pirates` | Authored once by `AetherDb pirates-faction apply`; doctrine is added by faction-play r2 | Ruling `pirates-record-content`; the operator sees the dry run |
| Package product | `mod-product::` in the package's `ship.cc` | Written by `AetherDb ship-authoring product`; copied verbatim by compose; Blender never edits it | The package author |
-| Boss hull | `HullData.Boss` (key 33) | Set by `ship-authoring boss`; a faction's boss hulls are derived per generation from the products it makes | The package author; `BossHullsOf` derives |
-| `Faction.BossHull` (key 10) | Retired | Deleted by `boss-hull-derived` | none |
+| Boss loadout | `Faction.BossLoadout` (key 22), a reference to one Loadout; the Loadout names its hull by design | Set by an agent-authored catalog write (follow-up `zhestokost-boss-loadout`); resolved by `Loadouts.BossOf`, which refuses Unset or Missing | Agents write it, the operator tweaks in Studio (rulings `faction-boss-is-a-loadout-reference`, `boss-loadouts-agent-authored`) |
+| `Faction.BossHull` (key 10) | Retired, never reused | Deleted by `boss-loadout` (the derived-boss design with `HullData.Boss` was withdrawn unmerged) | none |
| Pirates products | 8 `FactionProductData`, emoji names, over other makers' designs | Authored with the faction in one commit | Ruling `pirates-record-content` |
| Package hull price | `HullData.Price` | Written by `ship-authoring price` (or `create --like`) | The package author |
| Emoji font file | `Assets/Fonts/Emoji/.ttf` + `emoji-font.lock` | Rebuilt only by `tools/emoji` at a new pinned version | The operator's `emoji-art-set` ruling |
@@ -10784,194 +10784,115 @@ worktree C:\aeth-wt\ag6-quality-readers at 70c7a497. Catalog: GameData/Aetheria.
quality-layers-combine, not in the spec, so the spec does not wait on it. context-pack: 14
anchors SAME.
-## Boss hull derived
+## Boss loadout
-r3's probes and source reads were made by imagination-ag6-boss-hull (session self-2026-10-18-ag6),
-2026-10-18, in the detached worktree `C:\aeth-wt\ag6-boss-hull` at `origin/master` `eb27ced1`
-(BH1-BH11). r4's probes were made by imagination-ag6-boss-hull-r4 in the same worktree at the
-branch head `095baf2f`, which is r3's h1 (BH12-BH17). Read by `cut-boss-hull-derived.r4`. This
-section supersedes the anchors of "Demo hulls, the Pirates and the boss" H7 (`@2a5fc00b`) and of
-Products PL6. Under Rationale below, r4 replaces r3's boss-loadout path. Ruling
-`boss-gear-is-a-loadout` revokes that path; it replaced `boss-gear-is-fixed`.
+This section replaces "Boss hull derived" (the `cut-boss-hull-derived` r1-r4 design: `HullData.Boss`,
+`BossHullsOf`, a Loadout found by hull product). Ruling `faction-boss-is-a-loadout-reference` replaced that
+design; r4 is withdrawn. Branch `eureka/aetheria-release-boss-hull-derived` (head `90f977bf`, reports h1, h2)
+is unmerged evidence only. Probes and source reads by imagination-ag6-boss-loadout (session
+self-2026-10-18-ag6), 2026-10-18, in the detached worktree `C:\aeth-wt\ag6-boss-loadout` at `origin/master`
+`a40072d9`, then `d28ce42d` (that commit adds one research doc only; every anchor below is the same at both).
+Read by `cut-boss-loadout.r1`. The model-page row `Faction.BossHull (key 10)` (about line 892) and the r4
+table row (about line 10958) now say: retired by `boss-loadout`, never reuse; add the row
+`Faction.BossLoadout (key 22) | CultRecordRef | the one owner of which Loadout is a faction's boss`.
### Body facts
-- **BH1. What the cut waits on is on master.** boss-gate is merged at `39c7508e`
- (cut-boss-gate r2, verdict s3). faction-play-1 is merged at `d7f30ed1` (r3, h6), and its catalog
- replay is at `aa12cbac`. minor-power-factions is merged at `c486b06d`. pirates-record is merged
- at `2c065937` and package-product at `3535660c`.
-- **BH2. Faction keys at `eb27ced1`** (`Corporations.cs`): 1-5, 7, 8, a retired-key comment for 9
- (`:39`), `BossHull` Key(10) at `:42-43`, then 11-15, 17 (Doctrine), 19 (Assembly) and 21
- (Places). h1 deleted `BossHull` and retired key 10.
-- **BH3. HullData keys** (`ItemData.cs:531-556` at `eb27ced1`): 23, 24, 25, retired 26, 27, 28,
- 29 and 32 (`Visual`). h1 added `Boss` at Key(33) (`ItemData.cs:557-560` at `095baf2f`).
-- **BH4. Every BossHull reader at `eb27ced1`** was `Galaxy.cs:293`,
- `LoadoutGenerator.cs:212-230`, `tools/AetherDb/Program.cs:586` and `:709-712`, and
- `RunGoalTests.cs:74-115` and `:199-202`. h1 removed every one.
-- **BH5. Retiring a key with stored values needs no catalog rewrite.** Precedents: `1d689adf`
- (Faction key 9) and `be7f2b07` (HullData key 26).
-- **BH6. Every generation hull draw goes through one availability rule**, `AvailableProducts`
- (`LoadoutGenerator.cs:196-219` at `095baf2f`). Its candidate filter carries h1's
- `!(entry.design is HullData { Boss: true })` (`:204`) ahead of the any-manufacturer fallback.
- `ChooseProduct` (`:278-289`) has its own `Where` and does not exclude Boss hulls. r4 never asks
- it for a hull, because `BossOf` returns only a Loadout whose `HullProduct` is set.
-- **BH7. Explicit hull draws.** `ScenarioStage.Generated` (`ScenarioStage.cs:93`) and AetherDb
- `loadout` reach `AvailableProducts`. Many tests call `GenerateShipLoadout(h => h == hull)` on
- shipped hulls, and none of those hulls is a Boss hull.
-- **BH8. The boss path at `095baf2f`.** `ZoneGenerator.cs:401-411` calls
- `GetLoadoutGenerator(bossFaction).GenerateBossLoadout()` for every `BossZones` entry in the zone.
- It logs "No boss could be generated" on null and otherwise marks the pack `Boss` and the zone
- `BossSpawned`. `:414-415` logs exit-without-boss. `GetLoadoutGenerator` (`:282-287`) caches one
- generator per faction over the zone's `random`. `GenerateBossLoadout` (`LoadoutGenerator.cs:221-233`)
- builds `BossHullsOf[0]` through `ShipLoadout(product)` (`:55-66`: instance, Ship,
- `OutfitEntity`, `EquipPickup`, `StockConsumables`, Pack). Otherwise it logs "makes no boss
- hull" and generates the priciest ship hull on offer. Its readers are only `ZoneGenerator.cs:403`
- and AetherDb `loadout` (`Program.cs:815`).
-- **BH9. The package writer.** `ShipAuthoringCommands.cs`: `Usage` at `:11`; h1 added `boss
- on|off`. Compose copies a package's HullData verbatim.
- `ShipProductTests.ABossPackageIsItsMakersBossAfterCompose` passes at `095baf2f`.
-- **BH10. Zhestokost makes no ship hull, and the shipped catalog has no Boss hull.** Products PL6
- still holds. Today's demo boss is the generated fallback: the priciest ordinary ship hull
- Zhestokost can be offered. Under r4 there is no fallback, so the demo exit has no boss until a
- Zhestokost Boss hull and its Loadout exist (question `demo-boss-before-its-hull`).
-- **BH11. Which hulls can be bosses.** Ruling `hull-programmer-art-reads-as-stand-in` (it
- supersedes `hull-programmer-art-stopgap`) leaves the stopgap mechanism open. The Eyes facts file
- at `ac835a8a` places stopgap art on the package path. Nothing in either derivation reads
- `Prefab`, `Visual` or a model.
-- **BH12. The three failures in h1 are a fixture defect.** Probe p1 ran ygg-verify at `095baf2f`
- with the filter of the three tests and the detailed console logger. All three throw
- `InvalidOperationException: Sequence contains no matching element` at
- `RunStartTests.FactionNamed` (`RunGoalTests.cs:75`), called with `"Lucent"` at `:130`, `:149`
- and `:185`. The shipped faction is `"Lucent Media"`, and `"Lucent"` is its ShortName
- (`DemoTerminusTests.cs:23`, `CatalogRoleTests.cs:368`). Probes p2 and p3 used a scratch clone
- with only that string changed (`f683baa4`). All three passed: `Passed
- A_boss_hull_two_makers_sell_is_a_boss_of_each`, `Passed Boss_hulls_are_never_stock_or_traffic`
- and `Passed Another_factions_boss_hull_is_never_used`. The h1 job hid the messages because its
- grep kept only `Assert|Expected|Actual` lines. Verdicts:
- - `Boss_hulls_are_never_stock_or_traffic` is a real fixture defect. Its rule (ruling
- `boss-hulls-exclusive`) holds once the name is fixed, and the test survives unchanged
- otherwise.
- - `Another_factions_boss_hull_is_never_used` is a real fixture defect. Its fallback assertions
- die with the revoked path. Its rule, that another maker's Boss hull is not this faction's,
- survives as a `NoBossHull` refusal.
- - `A_boss_hull_two_makers_sell_is_a_boss_of_each` is a real fixture defect. Its `BossHullsOf`
- rule survives. Its last assertion (the boss flies "Shared Boss") becomes "flies its Loadout".
-- **BH13. The Loadout record already carries the key from a boss hull to its gear.** `Loadout`
- (`Loadout.cs:14-22`, schema `aetheria.loadout` v1) has `Name` (Key 0), `Hull` (Key 1),
- `Slots` (Key 2: `Position`, `Rotation`, `Design`, optional `Product`), `WeaponGroups` (Key 3)
- and `HullProduct` (Key 4, optional). `HullProduct` names the product, and therefore the maker,
- of the hull. So "the Loadout whose `HullProduct` is the faction's boss hull product" needs no new
- field on `Loadout`, `Faction`, `FactionProductData` or `HullData`. It also tells apart two makers
- of one shared Boss hull.
-- **BH14. `Loadouts.Materialize` is already the builder a fixed boss needs.** It is all or
- nothing, pins a set product as named, and builds a design-only slot through the passed chooser.
- Its doc says a game spawner passes `LoadoutGenerator.ChooseProduct`. It builds a Ship from a ship
- hull with the given zone, null included, as `ShipLoadout` did, and pads to `WeaponGroupCount`.
- It adds no pickup, consumables or outfit. Its callers today are `ScenarioStage.cs:179` (fits)
- and the capture round trip in tests.
-- **BH15. A catalog Loadout cannot name a package hull.** `Loadouts.Commit` (`Loadout.cs:78-98`)
- is the only writer of Loadout records, through the in-game capture command
- (`ActionGameManager.cs:643`). It refuses any loadout whose hull or slot design is a mod key.
- Package hulls and products are keyed `mod-hull:`, `mod-product:` and `mod-ship:`
- (`ShipModCatalog.cs:23-30`), and "the shipped catalog ... never reference[s] one". A package
- carries only its HullData, its ShipAuthoring and its products (`ShipModCatalog.Package`,
- `:13-21`). So a boss Loadout for a package Boss hull has to ride in the package. That is the
- next cut line below, not r4.
-- **BH16. Boss-dependent tests.** `RunGoalTests.cs` holds 18 tests. Those that read the demo's
- fallback boss are `Boss_spawns_once_in_boss_zone`, `Boss_spawns_in_a_zone_that_is_not_ambient`,
- `Exit_sealed_until_boss_dies`, `Boss_mark_survives_continue` and
- `Exit_open_after_save_of_a_slain_boss`. `Exit_sealed_when_no_ship_hull_is_on_offer` pins the
- fallback's null branch. No other test file references `IsBoss`, `BossSpawned` or `ExitOpen`.
-- **BH17. CultCache variants are not available to Aetheria yet.** CultLib `src` has variant
- records (`CultCache.cs:59-60`, `CultVariantDelta`, "a variant record (slot 4): its base and
- overrides"). Aetheria pins CultLib `45c2f4006f5f` (`Directory.Build.props:6`), and
- `git grep CultVariantDelta 45c2f40` finds nothing. An interim Boss hull copied from a shipped
- hull would be a plain copy until the pin moves. "Variant" is that record kind, never a loadout
- (ruling `boss-gear-is-a-loadout`).
+- **BL1. What decides the boss today.** `ZoneGenerator.GenerateZone`'s boss block (`ZoneGenerator.cs:423-439`)
+ calls `LoadoutGenerator.GenerateBossLoadout` (`LoadoutGenerator.cs:212-230`). That method flies
+ `Faction.BossHull` (`Corporations.cs:42-43`, key 10) through `GenerateShipLoadout`. When that is unset or
+ unsold it flies the dearest ship hull on offer. So every demo boss today is the generated fallback. The
+ main galaxy picks boss factions by `BossHull.IsSet()` (`Galaxy.cs:291-295`). AetherDb `factions` prints the
+ hull (`Program.cs:700-718`), and the `dangling` comment names it (`:586`).
+- **BL2. Catalog state (probe: msgpack decode of `GameData/Aetheria.cc`, 186,037 bytes).** There are 15 Faction
+ rows, each a 22-element array (keys 0-21). Index 10 is `''` (unset) on all 15, so deleting `BossHull`
+ loses no data. Index 20 is nil on all; it was `assemblyDeviation`, retired by `30597b0e`, with no
+ never-reuse note in the source. The catalog holds no `aetheria.loadout` records. The new reference
+ therefore takes key **22**.
+- **BL3. A Loadout names its hull by design.** `Loadout.Hull` (key 1) is the design and `HullProduct` (key 4)
+ the optional brand (`Loadout.cs:14-22`). `Loadouts.Materialize` (`:113-167`) builds hull and slots through
+ `Resolve` (`:174-214`). A pinned product is built as named whatever the chooser says. A design with no
+ product at all is built unbranded, with no maker, at `UnbrandedQuality` .95. Otherwise the chooser picks.
+ So a boss Loadout needs no format change, and the boss is built by the same builder as scenario fits and
+ capture. Header and comments still say "preset (a variant)", which ruling `boss-gear-is-a-loadout`
+ corrects. `ActionGameManager.cs:645-647` prints "Preset '...'".
+- **BL4. What is on the market today (probe: every enumeration of designs and products).** Every generated
+ draw goes through `LoadoutGenerator.AvailableProducts` (`:188-210`): hulls, gear, station stock and
+ consumables. It enumerates `FactionProductData` and filters by `IsAvailable` (`:251-253`), the design's
+ price > 0 and a gear home. `ChooseProduct` (`:262-272`) is the chooser for design-only slots. It
+ enumerates products and filters by the same `IsAvailable`. `SoldHulls` (`:237-238`), the hulls that
+ give gear a home, enumerates products. No game path offers a design except through a product. The design
+ enumerations found are `ShipModShips.cs:44` (visual prototypes), `ShipAuthoring.cs:181` (package load),
+ `ShipModCatalog.cs:139`, `ZoneGenerator.cs:274` (station reach), console `give` (`ActionGameManager.cs:539`)
+ and AetherDb reports. None of them stocks, spawns or sells. So **an item is on the market iff some product
+ of it is on offer** is already the rule, and its one owner is the product set read through
+ `AvailableProducts`, `ChooseProduct` and `SoldHulls`. The price-0 filter in `AvailableProducts` is a
+ second, partial gate. `ChooseProduct` and `SoldHulls` ignore it, and package validation refuses price 0
+ for a hull with products (`ShipAuthoring.cs:220-229`). It is value, not market membership, and is not a
+ candidate mechanism.
+- **BL5. "No product" already has a meaning.** Scenarios ruling Q3 (`docs/scenarios-cut.md:20`, `:155`) says
+ "a design no product sells is a scenario test design and nothing else". `ScenarioTests.cs:576-610`
+ (`EveryUnsoldDesignIsAScenarioTestDesign`) and `ProductLinesCatalogTests.cs:14-34` (weapon designs: Smoke
+ only) pin it. A package hull may ship with no products (`ShipAuthoring.cs:222`, `if (products.Length == 0)
+ return;`).
+- **BL6. Brand rulings.** `designs-are-tech-nodes`: flavour names belong to products.
+ `catalog-grows-generic-designs-branded-products`: branding lives in products. With no product, a boss
+ hull's only name is its design's, and its quality is .95 rather than drawn from its maker's
+ `Faction.Assembly` (key 19).
+- **BL7. Boss consumers that stay.** `Galaxy.PlaceGate` (`Galaxy.cs:148-151`) maps the demo antagonist's home
+ to `BossZones` and `Exit` whatever the antagonist flies. `RunGoal` (`RunGoal.cs:10-17`) opens the gate only
+ when the exit zone spawned a boss and it is dead (it fails closed). `EntityPack.Boss` and
+ `EntitySerializer` (`:31`, `:85`) are unchanged. `ActionGameManager.cs:365` says "Its guardian holds it
+ shut" when no boss is present.
+- **BL8. Tests on the old path.** `RunGoalTests.cs` (329 lines): `Boss_hull_from_BossHull_else_fallback`
+ (`:73-97`), `Boss_hull_nobody_sells_falls_back` (`:99-115`) and `Exit_sealed_when_no_ship_hull_is_on_offer`
+ (`:214-228`) pin the fallback. `Exit_open_only_in_the_exit_zone` (`:193-212`) sets `BossHull`. Five tests
+ rely on a demo boss existing on the bare catalog (`:41-71`, `:116-160`, `:230-240`). No other test reads
+ `BossHull` or `GenerateBossLoadout` (grep). Other tests touch `BossZones` only as saved-game fields.
+- **BL9. Reusable from `90f977bf`.** The Loadout.cs header rewrite (`git show 90f977bf:Assets/Scripts/ServerShared/Loadout.cs`,
+ lines 9-13). The ZoneGenerator boss block shape (Materialize with `liveZone: null` and
+ `GetLoadoutGenerator(bossFaction).ChooseProduct`; green in h2's full run at `d912cf44`, 2431 passed).
+ The fixture pattern `MakeBossLoadout` (capture a generated fit, keep its weapon slots, renumber groups) and
+ `StoreLoadout` through `_cache.Commit(batch => batch.Upsert(typeof(Loadout), ...))` (`fc992f5a`).
+ h2's diagnosis that three r3 failures were the fixture name "Lucent" for "Lucent Media". h2's
+ `LoadoutCommitCommand` (125 lines, plus 210 lines of tests) takes a hull *product*. It is for the next
+ cut and must accept a hull design.
-### Rationale (r4)
+### Rationale (r1)
-- **One owner of what a boss flies:** `Loadouts.BossOf(CultCache, Faction, out BossRefusal)`, in
- `Loadout.cs` beside the other owners of Loadout records. It takes `BossHullsOf(items, faction)[0]`
- and returns the Loadout whose `HullProduct` key is that product's key, first by Name ordinal.
- When there is none, it returns null with `NoBossHull` or `NoLoadout`. It reads no `Random`, no
- model and no availability rule. `ZoneGenerator`'s boss block, `Galaxy.PlaceFactionsMain` and
- AetherDb `factions` all call it. `LoadoutGenerator.BossHullsOf` stays the one owner of which hull
- is a boss.
-- **Keyed on the product, not the hull** (BH13). A Boss hull two makers sell is a boss of each,
- and each maker's boss is the Loadout on its own product. No field on Faction or the product
- points at a Loadout, so no second record can disagree with the Loadout.
-- **No generator on the boss path.** `GenerateBossLoadout`, its priciest-hull fallback and
- `ShipLoadout(product)` are deleted. `GenerateShipLoadout` gets back its single body, because the
- boss was `ShipLoadout`'s only other caller. The boss is built by `Loadouts.Materialize`, the one
- builder from a Loadout (BH14). It carries exactly its cells: no tractor pickup, no consumables
- and no outfit pass.
-- **The chooser is not a draw of gear.** Materialize needs a chooser only for a design-only slot.
- Ruling `loadout-product-optional-context-chooses` says that slot's product is chosen by context,
- and `ChooseProduct` is that rule's owner. It never picks a design, a cell or the hull. The
- negative check forbids every generator draw on the boss path (`GenerateShipLoadout`,
- `RandomHull`, `RandomProduct(s)`, `OutfitEntity`, `EquipPickup`, `StockConsumables`). An agent
- who wants the brand fixed pins the slot's product.
-- **A typed refusal, never a fallback.** `BossRefusal { None, NoBossHull, NoLoadout }`.
- `Loadouts.Describe` names the missing field (`HullData.Boss`, `Loadout.HullProduct`) and echoes
- no product name or record key. The zone logs ` has no boss: it .`, spawns
- nothing and leaves `BossSpawned` false, so the exit gate fails closed through boss-gate's
- existing rule. A Loadout that does not fit is logged with Materialize's failures and also spawns
- nothing.
-- **Galaxy picks factions that have a boss to fly.** In the main galaxy, a faction with a Boss
- hull but no Loadout gets no boss zone. That keeps a placed boss zone from being empty by
- construction.
-- **Authoring** (ruling `boss-loadouts-agent-authored`). AetherDb `loadout-commit [,,,[@]]... [--group i,j]... [--replace]` writes one
- Loadout through `Loadouts.Commit`, which stays the only writer. The command first resolves every
- name exactly and test-materializes the Loadout, so a typo or a misfit refuses before anything is
- written. The operator adjusts the record in Studio afterwards. The command is argument-driven,
- not a coded table like `product-lines tiers`. A coded table replayed at merges would fight her
- Studio edits. The record in the catalog is the authority, and the commit message records the
- command line for a merge replay.
-- **Vocabulary.** `Loadout.cs` says "Loadout" throughout. "Preset" and "variant" go from its
- comments and messages. The wider sweep (the `capturepreset` console command, `ScenarioStage`,
- `Provenance`, `LoadoutGenerator` and `ActionGameManager` comments) is follow-up
- `loadout-vocabulary-sweep`.
-- **Kept from r3 (h1, landed):** Faction.BossHull is deleted with key 10 retired, `HullData.Boss`
- Key(33) stays, `BossHullsOf` stays, the exclusive clause in `AvailableProducts` stays (ruling
- `boss-hulls-exclusive`), and `ship-authoring boss`, the compose test and the no-authored-model
- test stay (ruling `hull-programmer-art-reads-as-stand-in`).
-- **Revoked from r3:** `GenerateBossLoadout` through `BossHullsOf` and `ShipLoadout(product)`, the
- AetherDb `loadout` boss branch, `Boss_without_a_boss_hull_falls_back`, and the "makes no boss
- hull" log.
-- **Prior art (from memory, medium confidence; no Eyes pass this round):** Starsector's unique
- bosses (for example the Ziggurat and the Omega flagships) fly hand-authored variant files
- attached to a scripted fleet, never the faction's autofit. EVE's officer and faction-commander
- spawns have fixed fittings per NPC type. Both match a fixed record keyed to the boss, with no
- generator.
+- **Which Loadout is a faction's boss.** One owner: the field `Faction.BossLoadout` (key 22), authored in
+ Studio or by an agent command (ruling `boss-loadouts-agent-authored`). `Loadouts.BossOf(items, faction, out
+ BossRefusal)` is its one resolver (Unset, Missing). ZoneGenerator, Galaxy's main-galaxy pick and AetherDb
+ `factions` call it. Nothing derives a boss from hulls, products or flags.
+- **What a boss flies.** Its Loadout, through `Loadouts.Materialize`, whose chooser
+ (`ChooseProduct`) only brands a design-only slot (ruling `loadout-product-optional-context-chooses`). No
+ generator draw sits on the boss path, and nothing is outfitted, picked up or stocked.
+- **What is on the market.** BL4: on the market iff a product of the item is on offer, owned by the product
+ set through `AvailableProducts`, `ChooseProduct` and `SoldHulls`. A boss hull reaches a ship only through a
+ Loadout, which names it by design (`Loadout.Hull`) or pins its product. This cut adds no off-market code. No
+ boss hull exists yet (ruling `demo-boss-hull-invented`), so nothing in this cut depends on how an
+ off-market item is marked. Question `off-market-items-keep-a-maker` asks whether an off-market item keeps a
+ maker, a brand and a drawn quality. If it does, its product carries one general not-offered field read by
+ `IsAvailable` and `SoldHulls`. If it does not, it has no product, and the Q3 census accepts a design a
+ Loadout names. The recommendation is the field (BL5, BL6). The answer lands with the boss-hull authoring
+ cut.
+- **The demo exit meanwhile.** After this cut and until a Zhestokost boss Loadout is authored, the demo exit
+ zone logs "Zhestokost has no boss: it sets no Faction.BossLoadout." and the exit-without-boss line. No boss
+ spawns, `BossSpawned` stays false, and the gate stays sealed (RunGoal fails closed). **The demo cannot be
+ won.** The sealed-gate dialog says "Its guardian holds it shut", which is wrong while no guardian exists.
+ That stands until the boss lands; it is not reworded here.
+- **Rejected.** A boss flag on hulls (operator, ruling `faction-boss-is-a-loadout-reference`). Excluding
+ hulls named by any boss Loadout from `AvailableProducts`: a boss-specific clause, barred by ruling
+ `off-market-is-general`. Price 0 as the off-market mark (BL4). Keeping a generated fallback: barred by
+ rulings `boss-gear-is-a-loadout` and `demo-boss-hull-invented`.
-### Model page rows
+### Cut sequence (boss strand)
-Replace the rows in "Demo scope, Model page rows" (`Boss hull`, `Faction.BossHull`), and add the
-boss Loadout row:
-
-| Kind | Identity | Lifecycle | Authority |
-|---|---|---|---|
-| Boss hull | `HullData.Boss` (key 33, bool) on any HullData: shipped, package, or agent-built stopgap | Set by `ship-authoring boss on\|off` on packages, or in Studio's inspector on catalog hulls. Derived per generation; stored nowhere | The hull's author sets the flag. `LoadoutGenerator.BossHullsOf` derives the faction from the product's maker |
-| Boss Loadout | A `Loadout` record (`aetheria.loadout` v1) whose `HullProduct` is a faction's Boss hull product, at `Loadouts.KeyOf(name)` | Written by AetherDb `loadout-commit` (agents) or the in-game capture, both through `Loadouts.Commit`. Studio edits after that. Read at zone generation by `Loadouts.BossOf` | `Loadouts.BossOf` alone decides what a boss flies, and `Loadouts.Materialize` builds it. No generator draw |
-| `Faction.BossHull` (key 10) | Retired; never reuse | Deleted by `boss-hull-derived`. The shipped records keep `''` in the slot (BH5) | none |
-
-### Cut sequence
-
-- `boss-hull-derived` (spec `cut-boss-hull-derived.r4`, branch at `095baf2f`). Its merge waits on
- question `demo-boss-before-its-hull`.
-- If `interim-catalog-boss` is chosen: `zhestokost-interim-boss`, a sibling content cut that lands
- with r4. Through AetherDb it writes a catalog Boss hull copied from the hull today's demo boss
- flies (BH10), plus its Zhestokost product and its Loadout (`loadout-commit`). It is replayed at
- merges and replaced when the real Zhestokost Boss hull lands.
-- `package-boss-loadout`: a package carries its boss Loadout, as it carries its product (ruling
- `package-carries-product`, BH15). `ship.cc` gains Loadout records, Compose writes them under a
- `mod-loadout:` key that `IsModKey` knows, and `ship-authoring loadout` writes them. It is needed
- before the first package Boss hull can be a boss. `BossOf` already matches it unchanged, by
- `HullProduct` key in the composed cache.
-- `demo-cast-hulls`'s "Waits on" reads "boss-hull-derived (spec cut-boss-hull-derived.r4)" until it
- merges.
+- `boss-loadout` (spec `cut-boss-loadout.r1`): `Faction.BossLoadout` replaces `BossHull`;
+ `GenerateBossLoadout` is deleted; the boss refuses typed.
+- Next: boss Loadout authoring. AetherDb `loadout-commit` (from h2, taking a hull design with an optional
+ `@product`) and a way to set `Faction.BossLoadout`. It lands with the answer to
+ `off-market-items-keep-a-maker` and the invented Zhestokost hull (follow-up `zhestokost-boss-loadout`).
## Product tiers
From 900fa51e437f1a140b548e292135fa083836b47e Mon Sep 17 00:00:00 2001
From: Meta Vens
Date: Sun, 18 Oct 2026 21:12:58 +0200
Subject: [PATCH 021/916] Delete Faction.BossHull (key 10 retired),
GenerateBossLoadout and the three tests that pin its fallback
A boss is a Loadout the faction references, never drawn (rulings faction-boss-is-a-loadout-reference,
boss-gear-is-a-loadout, demo-boss-hull-invented). This commit does not build: ZoneGenerator, Galaxy,
AetherDb and the tests still read the deleted members; the next commit replaces them.
Co-Authored-By: Claude Sonnet 5.5
---
Assets/Scripts/ServerShared/Corporations.cs | 3 +-
.../Scripts/ServerShared/LoadoutGenerator.cs | 20 -------
tests/Aetheria.Shared.Tests/RunGoalTests.cs | 60 -------------------
3 files changed, 1 insertion(+), 82 deletions(-)
diff --git a/Assets/Scripts/ServerShared/Corporations.cs b/Assets/Scripts/ServerShared/Corporations.cs
index c242e3e42..9d24bc39e 100644
--- a/Assets/Scripts/ServerShared/Corporations.cs
+++ b/Assets/Scripts/ServerShared/Corporations.cs
@@ -39,8 +39,7 @@ public class Faction
// Key 9 was the faction's name-file link, retired by ruling faction-curated-place-names; never reuse it.
- [Inspectable, JsonProperty("bossHull"), Key(10)]
- public CultRecordRef BossHull;
+ // Key 10 was the faction's boss hull reference, retired by ruling faction-boss-is-a-loadout-reference; never reuse it.
[Inspectable, JsonProperty("influence"), Key(11)]
public int InfluenceDistance = 4;
diff --git a/Assets/Scripts/ServerShared/LoadoutGenerator.cs b/Assets/Scripts/ServerShared/LoadoutGenerator.cs
index 55eea27f8..7de56b40b 100644
--- a/Assets/Scripts/ServerShared/LoadoutGenerator.cs
+++ b/Assets/Scripts/ServerShared/LoadoutGenerator.cs
@@ -209,26 +209,6 @@ public class LoadoutGenerator
return (available, preferManufacturers);
}
- // A faction's boss: its BossHull when the faction sets one and a product sells it, else the most expensive ship hull
- // the faction can be offered, with the gap logged. Null only when no ship hull is on offer at all.
- public EntityPack GenerateBossLoadout()
- {
- var bossHull = Faction != null && Faction.BossHull.IsSet() ? ItemManager.ItemData.Get(Faction.BossHull) : null;
- if (bossHull != null)
- {
- var boss = GenerateShipLoadout(hull => hull == bossHull);
- if (boss != null) return boss;
- ItemManager.Log($"{Faction.Name}'s BossHull {bossHull.Name} is not sold by any product; its boss flies the most expensive ship hull instead.");
- }
- else
- ItemManager.Log($"{Faction?.Name ?? "This faction"} has no BossHull; its boss flies the most expensive ship hull instead.");
-
- var (available, _) = AvailableProducts(hull => hull.HullType == HullType.Ship, required: true);
- if (available.Length == 0) return null;
- var priciest = available.OrderByDescending(entry => entry.design.Price).ThenBy(entry => entry.design.Name, StringComparer.Ordinal).First().design;
- return GenerateShipLoadout(hull => hull == priciest);
- }
-
// Hardpoint gear that no hull in the catalog can mount has no home (operator, 2026-09-30: "we'll need to author a
// bunch more hulls before all the gear variety in the game has a home"): generation never offers it, so no station
// stocks it. It gains one the moment a hull with a hardpoint that takes it exists. Tool gear goes in any interior.
diff --git a/tests/Aetheria.Shared.Tests/RunGoalTests.cs b/tests/Aetheria.Shared.Tests/RunGoalTests.cs
index 25b46fdd3..4c51eca72 100644
--- a/tests/Aetheria.Shared.Tests/RunGoalTests.cs
+++ b/tests/Aetheria.Shared.Tests/RunGoalTests.cs
@@ -70,50 +70,6 @@ public sealed partial class RunStartTests
Assert.DoesNotContain(pack.Entities, entity => !entity.Boss && entity is ShipPack);
}
- [Fact]
- public void Boss_hull_from_BossHull_else_fallback()
- {
- var galaxy = DemoGalaxy(1);
- var antagonist = Zhestokost(galaxy);
- var hulls = SoldShipHulls().OrderByDescending(hull => hull.Price).ThenBy(hull => hull.Name, StringComparer.Ordinal).ToArray();
- var priciest = hulls.First();
- var cheaper = hulls.Last();
- Assert.True(cheaper.Price < priciest.Price, "the catalog needs two ship hulls of different price for this test to tell them apart");
-
- // Set and sold: the boss flies it, and nothing is logged about a gap.
- antagonist.BossHull = _cache.RefOf(cheaper);
- var log = new List();
- var items = LoggingItems(log);
- var boss = Assert.Single(BossZonePack(galaxy, items, galaxy.Exit).Entities, entity => entity.Boss);
- Assert.Equal(cheaper.Name, HullName(items, boss));
- Assert.DoesNotContain(log, line => line.Contains("BossHull"));
-
- // Unset: the most expensive ship hull on offer, and the log names the missing BossHull.
- antagonist.BossHull = default;
- log.Clear();
- boss = Assert.Single(BossZonePack(galaxy, items, galaxy.Exit).Entities, entity => entity.Boss);
- Assert.Equal(priciest.Name, HullName(items, boss));
- Assert.Contains(log, line => line.Contains("Zhestokost") && line.Contains("no BossHull"));
- }
-
- // Set but sold by no product: the boss falls back the same way, and the log says which hull has no seller.
- [Fact]
- public void Boss_hull_nobody_sells_falls_back()
- {
- var galaxy = DemoGalaxy(1);
- var antagonist = Zhestokost(galaxy);
- var sold = SoldShipHulls();
- // A ship hull no product sells, dearer than any that is sold: the fallback must not pick it.
- var unsold = new HullData { Name = "Unsold Test Hull", HullType = HullType.Ship, Price = sold.Max(hull => hull.Price) + 1 };
- _cache.Upsert(unsold);
- antagonist.BossHull = _cache.RefOf(unsold);
- var log = new List();
- var items = LoggingItems(log);
- var boss = Assert.Single(BossZonePack(galaxy, items, galaxy.Exit).Entities, entity => entity.Boss);
- Assert.Equal(sold.OrderByDescending(hull => hull.Price).ThenBy(hull => hull.Name, StringComparer.Ordinal).First().Name, HullName(items, boss));
- Assert.Contains(log, line => line.Contains(unsold.Name) && line.Contains("BossHull"));
- }
-
[Fact]
public void Exit_sealed_until_boss_dies()
{
@@ -211,22 +167,6 @@ public sealed partial class RunStartTests
Assert.False(RunGoal.ExitOpen(zone));
}
- // A boss that cannot be generated (no ship hull on offer at all) never marks the zone as having spawned one.
- [Fact]
- public void Exit_sealed_when_no_ship_hull_is_on_offer()
- {
- var galaxy = DemoGalaxy(1);
- foreach (var product in _cache.GetAll().Where(product => _cache.Get(product.Design) is HullData { HullType: HullType.Ship }).ToArray())
- Assert.True(_cache.Remove(_cache.RefOf(product).Key));
- var log = new List();
- var items = LoggingItems(log);
- var pack = BossZonePack(galaxy, items, galaxy.Exit, ambient: false);
- Assert.False(pack.BossSpawned);
- Assert.DoesNotContain(pack.Entities, entity => entity.Boss);
- Assert.Contains(log, line => line.Contains("No boss could be generated for Zhestokost"));
- Assert.False(RunGoal.ExitOpen(new Zone(items, _planetSettings, pack, galaxy.Exit, galaxy)));
- }
-
// A boss killed before the save stays dead after it, and the gate stays open: the spawn fact travels with the zone.
[Fact]
public void Exit_open_after_save_of_a_slain_boss()
From 352e221453bd2d5962c3ba2801d3f1d4ed37d66f Mon Sep 17 00:00:00 2001
From: Meta Vens
Date: Sun, 18 Oct 2026 21:14:09 +0200
Subject: [PATCH 022/916] Faction.BossLoadout (key 22): the boss is its
faction's Loadout, resolved by Loadouts.BossOf and built by Materialize
BossOf refuses typed (BossRefusal Unset or Missing, Describe names the field and echoes no input).
ZoneGenerator builds the boss from the Loadout with ChooseProduct as the chooser; a refused or
unbuildable boss logs and spawns none. Galaxy picks boss factions through BossOf; AetherDb factions
prints the boss Loadout. Loadout vocabulary: no preset, no variant. Production builds; the tests
project does not until the next commit (RunGoalTests still sets BossHull).
Co-Authored-By: Claude Sonnet 5.5
---
Assets/Scripts/Gameplay/ActionGameManager.cs | 6 +-
Assets/Scripts/ServerShared/Corporations.cs | 7 ++-
Assets/Scripts/ServerShared/Galaxy.cs | 4 +-
Assets/Scripts/ServerShared/Loadout.cs | 60 ++++++++++++++-----
.../Scripts/ServerShared/LoadoutGenerator.cs | 2 +
Assets/Scripts/ServerShared/ZoneGenerator.cs | 21 +++++--
tools/AetherDb/Program.cs | 11 ++--
7 files changed, 78 insertions(+), 33 deletions(-)
diff --git a/Assets/Scripts/Gameplay/ActionGameManager.cs b/Assets/Scripts/Gameplay/ActionGameManager.cs
index e24a6e395..9b4c6ad59 100644
--- a/Assets/Scripts/Gameplay/ActionGameManager.cs
+++ b/Assets/Scripts/Gameplay/ActionGameManager.cs
@@ -642,9 +642,9 @@ public class ActionGameManager : MonoBehaviour
{
var written = Loadouts.Commit(CatalogPath, Loadouts.Capture(ItemManager, ship, name), replace);
console.AppendLogLine(written
- ? $"Preset '{name}' written to {CatalogPath}. This session sees it after the catalog reloads (next launch). " +
- "Reopen CultCache Studio before saving there: a Studio session opened earlier overwrites captured presets."
- : $"Preset '{name}' changed on disk since load; nothing written");
+ ? $"Loadout '{name}' written to {CatalogPath}. This session sees it after the catalog reloads (next launch). " +
+ "Reopen CultCache Studio before saving there: a Studio session opened earlier overwrites captured loadouts."
+ : $"Loadout '{name}' changed on disk since load; nothing written");
}
catch (InvalidOperationException e)
{
diff --git a/Assets/Scripts/ServerShared/Corporations.cs b/Assets/Scripts/ServerShared/Corporations.cs
index 9d24bc39e..3b676aef4 100644
--- a/Assets/Scripts/ServerShared/Corporations.cs
+++ b/Assets/Scripts/ServerShared/Corporations.cs
@@ -65,7 +65,7 @@ public class Faction
// The maker's final assembly: the distribution every lot of theirs draws its own quality from, and the hard ceiling on each
// of its roles (quality-lean-assembly-hard-ceiling). Null is not authored: a lot of theirs assembles at AssemblyDistribution's
// defaults. assembly-from-maker derives it once at the part mean plus a tolerance margin (quality-min-tolerance-binned-assembly);
- // tune it in Studio after that. Key 16 is reserved for Relations and 18 for Livery.
+ // tune it in Studio after that. Key 16 is reserved for Relations and 18 for Livery. Key 20 was assemblyDeviation (retired); never reuse it.
[Inspectable, JsonProperty("assembly"), Key(19)]
public AssemblyDistribution Assembly;
@@ -73,6 +73,11 @@ public class Faction
// Authored by AetherDb place-names, which restores the table on every apply.
[Inspectable, JsonProperty("places"), Key(21)]
public FactionPlace[] Places = Array.Empty();
+
+ // The Loadout this faction's boss flies; unset means the faction has no boss (ruling faction-boss-is-a-loadout-reference).
+ // The one owner of which Loadout is its boss, read through Loadouts.BossOf.
+ [Inspectable, JsonProperty("bossLoadout"), Key(22)]
+ public CultRecordRef BossLoadout;
}
// Historical, narrative and strategic intent join as keys 2+ when economics-driven placement lands (ruling faction-curated-place-names).
diff --git a/Assets/Scripts/ServerShared/Galaxy.cs b/Assets/Scripts/ServerShared/Galaxy.cs
index 0b2f71387..ce7b30630 100644
--- a/Assets/Scripts/ServerShared/Galaxy.cs
+++ b/Assets/Scripts/ServerShared/Galaxy.cs
@@ -288,9 +288,9 @@ public class Galaxy
progressCallback?.Invoke("Placing Factions");
if (progressCallback != null) Thread.Sleep(500); // Inserting Delay to make it seem like it's doing more work lmao
- // Choose some megas to have bosses placed based on whether a boss hull is assigned
+ // Choose some megas to have bosses placed: the factions whose boss Loadout resolves
var bossMegas = Factions
- .Where(m => m.BossHull.IsSet())
+ .Where(m => Loadouts.BossOf(_cache, m, out _) != null)
.Take(bossCount)
.ToArray();
diff --git a/Assets/Scripts/ServerShared/Loadout.cs b/Assets/Scripts/ServerShared/Loadout.cs
index bf8a2ac47..592c827e2 100644
--- a/Assets/Scripts/ServerShared/Loadout.cs
+++ b/Assets/Scripts/ServerShared/Loadout.cs
@@ -6,11 +6,11 @@ using GameCult.Caching;
using MessagePack;
using CultMath;
-// A ship preset (a variant): the hull's design, and per hull cell a design and its rotation. A slot names a design and
-// may name a product of it; a design-only slot is open on purpose, and whoever materializes the preset chooses its
-// product from the galaxy it is built in (ruling loadout-product-optional-context-chooses), which keeps a preset
-// portable across galaxies. A preset that needs a brand names it. Authored catalog data: written in CultCache Studio or by the editor capture
-// command, read at runtime.
+// A Loadout: a hull together with item designs or products equipped to specific cells (ruling boss-gear-is-a-loadout).
+// A slot names a design, and names a product only where the loadout demands one; a design-only slot's product is chosen
+// by whoever materializes it from the galaxy it is built in (ruling loadout-product-optional-context-chooses), which
+// keeps a loadout portable across galaxies. A faction's boss flies one (Faction.BossLoadout). Authored catalog data:
+// written in CultCache Studio or by the AetherDb and editor capture commands, read at runtime.
[CultDocument("aetheria.loadout", "1"), MessagePackObject]
public class Loadout
{
@@ -30,6 +30,9 @@ public class LoadoutSlot
[Key(3)] public CultRecordRef Product; // unset: design-only, chosen at materialization
}
+// Why a faction has no boss Loadout to build; see Loadouts.BossOf.
+public enum BossRefusal { None, Unset, Missing }
+
// The owner of loadouts: capture from a live ship, the only writer, and the only builder of an entity from a loadout.
public static class Loadouts
{
@@ -66,30 +69,54 @@ public static class Loadouts
private static CultRecordRef ProductRef(ItemManager itemManager, CraftedItemInstance unit) =>
itemManager.Brand(unit).Product is { } product ? itemManager.ItemData.RefOf(product) : default;
- // A preset's key derives from its name, so capturing the same name again addresses the same record.
+ // A loadout's key derives from its name, so capturing the same name again addresses the same record.
public static CultRecordKey KeyOf(string name) => new CultRecordKey("loadout:" + name);
- // The only writer of presets. It opens its own short-lived cache over the catalog file, writable, and disposes it
+ // The one resolver of a faction's boss reference (ruling faction-boss-is-a-loadout-reference): the Loadout
+ // Faction.BossLoadout names. The boss is never generated, so this reads nothing but the reference and the catalog. Null with
+ // Unset when the faction sets none, and null with Missing when it sets one the catalog does not hold.
+ public static Loadout BossOf(CultCache items, Faction faction, out BossRefusal refusal)
+ {
+ if (!faction.BossLoadout.IsSet())
+ {
+ refusal = BossRefusal.Unset;
+ return null;
+ }
+
+ var loadout = items.Get(faction.BossLoadout);
+ refusal = loadout == null ? BossRefusal.Missing : BossRefusal.None;
+ return loadout;
+ }
+
+ // Names the faction's field, and echoes no key or name of the input.
+ public static string Describe(BossRefusal refusal) => refusal switch
+ {
+ BossRefusal.Unset => "sets no Faction.BossLoadout",
+ BossRefusal.Missing => "names a Faction.BossLoadout that is not in the catalog",
+ _ => ""
+ };
+
+ // The only writer of Loadout records. It opens its own short-lived cache over the catalog file, writable, and disposes it
// after the one commit. No other cache is touched, so no catalog instance play holds (or has mutated) can reach the
- // file; a cache that already has the catalog open sees the preset only once it reloads.
- // Throws and writes nothing when the loadout names a mod design (hull or slot), when the file is missing (capture never creates a catalog), when a preset of this name
+ // file; a cache that already has the catalog open sees the loadout only once it reloads.
+ // Throws and writes nothing when the loadout names a mod design (hull or slot), when the file is missing (capture never creates a catalog), when a loadout of this name
// exists under another key, or when one exists under KeyOf(Name) and replace is not set. The commit is conditional
- // on the record at KeyOf(Name), so a preset changed on disk since this open is not clobbered: returns false then.
+ // on the record at KeyOf(Name), so a loadout changed on disk since this open is not clobbered: returns false then.
public static bool Commit(string catalogPath, Loadout loadout, bool replace)
{
var modDesigns = new[] { loadout.Hull.Key }.Concat(loadout.Slots.Select(slot => slot.Design.Key)).Where(ShipModCatalog.IsModKey).Select(key => key.Value).Distinct().ToArray();
if (modDesigns.Length > 0)
- throw new InvalidOperationException($"Preset '{loadout.Name}' names mod designs ({string.Join(", ", modDesigns)}); the shipped catalog never references a mod, so a mod ship cannot be captured as a preset.");
+ throw new InvalidOperationException($"Loadout '{loadout.Name}' names mod designs ({string.Join(", ", modDesigns)}); the shipped catalog never references a mod, so a mod ship cannot be captured as a loadout.");
if (!File.Exists(catalogPath))
- throw new InvalidOperationException($"Catalog {catalogPath} does not exist; a preset capture never creates one.");
+ throw new InvalidOperationException($"Catalog {catalogPath} does not exist; a loadout commit never creates one.");
using var cache = AetheriaStores.Open(catalogPath, catalogWritable: true);
var key = KeyOf(loadout.Name);
var namesake = cache.GetAll().FirstOrDefault(other => other.Name == loadout.Name && !cache.RefOf(other).Key.Equals(key));
if (namesake != null)
- throw new InvalidOperationException($"Preset '{loadout.Name}' already exists under key {cache.RefOf(namesake).Key}; rename or remove it first.");
+ throw new InvalidOperationException($"Loadout '{loadout.Name}' already exists under key {cache.RefOf(namesake).Key}; rename or remove it first.");
var existing = cache.Get(key);
if (existing != null && !replace)
- throw new InvalidOperationException($"Preset '{loadout.Name}' already exists; replace it explicitly.");
+ throw new InvalidOperationException($"Loadout '{loadout.Name}' already exists; replace it explicitly.");
return cache.Commit(batch =>
{
batch.Expect(key, existing);
@@ -104,7 +131,8 @@ public static class Loadouts
// WeaponGroupCount weapon groups, and every group index names a weapon slot. Every failure is listed; on any failure
// nothing is returned and the zone and cache are unchanged, but a failed fit has already drawn from
// itemManager.Random. How each design is built is Resolve's rule. A design-only slot is chosen by choose; a game
- // spawner is to pass LoadoutGenerator.ChooseProduct, with no fallback to any manufacturer; RunStart does. The hull's type
+ // spawner is to pass LoadoutGenerator.ChooseProduct, with no fallback to any manufacturer; RunStart does, and so does the
+ // boss in ZoneGenerator, which is built here too from its faction's Loadout (Loadouts.BossOf). The hull's type
// picks the entity: a ship hull builds a Ship, a turret hull an OrbitalEntity with no orbit, which stays where it is
// put; a station hull is refused. The entity always gets exactly WeaponGroupCount groups; a loadout with fewer is
// padded with empty groups. A failed materialization leaves any minted lots in the live ledger; they are not roots,
@@ -119,7 +147,7 @@ public static class Loadouts
var hullBuild = Resolve(itemManager, loadout.Hull, loadout.HullProduct, choose, "hull", failures, quality);
var hullData = cache.Get(loadout.Hull);
if (hullData is { HullType: HullType.Station })
- failures.Add($"hull: {hullData.Name} is a station hull; a preset builds a ship or a turret");
+ failures.Add($"hull: {hullData.Name} is a station hull; a loadout builds a ship or a turret");
var slotBuilds = loadout.Slots.Select(slot => Resolve(itemManager, slot.Design, slot.Product, choose, Cell(slot), failures, quality)).ToArray();
var groups = loadout.WeaponGroups ?? new int[0][];
var groupCount = itemManager.GameplaySettings.WeaponGroupCount;
diff --git a/Assets/Scripts/ServerShared/LoadoutGenerator.cs b/Assets/Scripts/ServerShared/LoadoutGenerator.cs
index 7de56b40b..849f0c352 100644
--- a/Assets/Scripts/ServerShared/LoadoutGenerator.cs
+++ b/Assets/Scripts/ServerShared/LoadoutGenerator.cs
@@ -183,6 +183,8 @@ public class LoadoutGenerator
count);
}
+ // An item is on offer only through a product, so a design no product makes is never drawn, stocked or chosen; it reaches a ship
+ // only through a Loadout (ruling off-market-is-general).
// The products this faction can be offered for a design kind (only gear needs a home), and whether manufacturer preference applies (it does
// not once a required item has fallen back to any manufacturer). The one availability rule for every selection.
private ((FactionProductData product, T design)[] available, bool preferManufacturers) AvailableProducts(Predicate filter, bool required) where T : CraftedItemData
diff --git a/Assets/Scripts/ServerShared/ZoneGenerator.cs b/Assets/Scripts/ServerShared/ZoneGenerator.cs
index 4d4c2613e..089ce3026 100644
--- a/Assets/Scripts/ServerShared/ZoneGenerator.cs
+++ b/Assets/Scripts/ServerShared/ZoneGenerator.cs
@@ -421,22 +421,33 @@ public static class ZoneGenerator
}
// A boss zone gets its faction's boss whether or not the zone is ambient: the boss is the run's goal, not
- // wandering traffic. RunGoal reads the mark; nothing else decides whether a boss lives.
+ // wandering traffic. The boss is its faction's boss Loadout, built whole by Loadouts.Materialize and never drawn
+ // (ruling boss-gear-is-a-loadout); ChooseProduct only brands a design-only slot. RunGoal reads the mark; nothing
+ // else decides whether a boss lives.
foreach (var bossFaction in galaxy.BossZones.Where(entry => entry.Value == galaxyZone).Select(entry => entry.Key))
{
- var boss = GetLoadoutGenerator(bossFaction).GenerateBossLoadout();
- if (boss == null)
+ var loadout = Loadouts.BossOf(itemManager.ItemData, bossFaction, out var refusal);
+ if (loadout == null)
{
- itemManager.Log($"No boss could be generated for {bossFaction.Name}; its boss zone has no boss to kill!");
+ itemManager.Log($"{bossFaction.Name} has no boss: it {Loadouts.Describe(refusal)}. Its boss zone has no boss to kill.");
continue;
}
+ var failures = new List();
+ var entity = Loadouts.Materialize(itemManager, null, loadout, GetLoadoutGenerator(bossFaction).ChooseProduct, failures);
+ if (entity == null)
+ {
+ itemManager.Log($"{bossFaction.Name}'s boss Loadout {loadout.Name} cannot be built: {string.Join("; ", failures)}");
+ continue;
+ }
+ entity.Faction = bossFaction;
+ var boss = EntitySerializer.Pack(entity);
boss.Boss = true;
pack.Entities.Add(boss);
pack.BossSpawned = true;
}
if (galaxyZone == galaxy.Exit && !pack.BossSpawned)
- itemManager.Log("Galaxy.Exit has no boss: Galaxy.BossZones does not map a boss faction to the exit zone, or its boss could not be generated (ZoneGenerator exit-without-boss). The exit gate stays sealed.");
+ itemManager.Log("Galaxy.Exit has no boss: Galaxy.BossZones does not map a boss faction to the exit zone, or its boss Loadout is unset, missing or cannot be built (ZoneGenerator exit-without-boss). The exit gate stays sealed.");
if (!ambient) return pack;
diff --git a/tools/AetherDb/Program.cs b/tools/AetherDb/Program.cs
index 5df9ed99c..103915d86 100644
--- a/tools/AetherDb/Program.cs
+++ b/tools/AetherDb/Program.cs
@@ -583,7 +583,7 @@ public static class Program
// Every CultRecordRef in the catalog that resolves to nothing, as " -> ".
// Each "clear " argument unsets that member's dangling refs, or removes that dictionary's
- // dangling keys (Faction.BossHull clears boss hulls that would claim a chokepoint no boss can spawn in). Dry
+ // dangling keys (a faction's BossLoadout member clears boss references that name no Loadout). Dry
// run unless passed "apply", which alone opens the catalog writable and lands every changed record in one commit.
private static int Dangling(string[] args)
{
@@ -701,15 +701,14 @@ public static class Program
{
var db = AetherDb.Open();
var products = db.Cache.GetAll().ToArray();
- Console.WriteLine($"{"faction",-26} {"short",-13} {"places",-22} {"boss hull",-14} {"influence",-9} {"doctrine",-10} products");
+ Console.WriteLine($"{"faction",-26} {"short",-13} {"places",-22} {"boss loadout",-14} {"influence",-9} {"doctrine",-10} products");
var broken = 0;
foreach (var faction in db.Cache.GetAll().OrderBy(f => f.Name))
{
var key = db.Cache.RefOf(faction).Key;
- var boss = !faction.BossHull.IsSet()
- ? "none"
- : db.Cache.Get(faction.BossHull)?.Name ?? "DANGLING";
- if (boss == "DANGLING") broken++;
+ var loadout = Loadouts.BossOf(db.Cache, faction, out var refusal);
+ var boss = refusal == BossRefusal.Unset ? "none" : loadout?.Name ?? "MISSING";
+ if (refusal == BossRefusal.Missing) broken++;
Console.WriteLine($"{faction.Name,-26} {faction.ShortName,-13} {faction.Places.Length,-22} {boss,-14} {faction.InfluenceDistance,-9} {(faction.Doctrine == null ? "none" : faction.Doctrine.EngageOn.ToString()),-10} " +
products.Count(p => p.Manufacturer.Key.Equals(key)));
}
From e6a17a5e01dd4d34722de7d857f2ecb95f5f1203 Mon Sep 17 00:00:00 2001
From: Meta Vens
Date: Sun, 18 Oct 2026 21:14:14 +0200
Subject: [PATCH 023/916] ProductLinesCommandTests: the bins of a removed line
go with it, as the catalog read now requires
Co-Authored-By: Claude Sonnet 5.5
---
tests/Aetheria.Shared.Tests/ProductLinesCommandTests.cs | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/tests/Aetheria.Shared.Tests/ProductLinesCommandTests.cs b/tests/Aetheria.Shared.Tests/ProductLinesCommandTests.cs
index 53b8fe773..fd8e02aa1 100644
--- a/tests/Aetheria.Shared.Tests/ProductLinesCommandTests.cs
+++ b/tests/Aetheria.Shared.Tests/ProductLinesCommandTests.cs
@@ -42,7 +42,9 @@ public abstract class ProductLinesCommandTests : IDisposable
Assert.Equal(Names.Length, products.Length);
_shipped = products.Select(p => Describe(cache, p)).OrderBy(x => x, StringComparer.Ordinal).ToArray();
_shippedKeys = products.Select(p => cache.RefOf(p).Key.Value).OrderBy(x => x, StringComparer.Ordinal).ToArray();
- foreach (var product in products) Assert.True(cache.Remove(cache.RefOf(product).Key));
+ // A bin cannot outlive its line (the catalog read refuses it), so the bins of the removed lines go with them.
+ var binned = cache.GetAll().Where(p => p.Bin != null && products.Any(line => cache.RefOf(line).Key.Equals(p.Bin.Line.Key))).ToArray();
+ foreach (var product in products.Concat(binned)) Assert.True(cache.Remove(cache.RefOf(product).Key));
cache.FlushAsync().Wait();
}
From e2b1b9ca7b2cc9735ca72c5dbffdf2e1d38aad19 Mon Sep 17 00:00:00 2001
From: Meta Vens
Date: Sun, 18 Oct 2026 21:17:05 +0200
Subject: [PATCH 024/916] RunGoalTests: the boss flies its faction's boss
Loadout; refusals, exact cells, brand by context, market rule, main-galaxy
pick
Co-Authored-By: Claude Sonnet 5.5
---
tests/Aetheria.Shared.Tests/RunGoalTests.cs | 292 +++++++++++++++++++-
1 file changed, 285 insertions(+), 7 deletions(-)
diff --git a/tests/Aetheria.Shared.Tests/RunGoalTests.cs b/tests/Aetheria.Shared.Tests/RunGoalTests.cs
index 4c51eca72..d2bc84a8f 100644
--- a/tests/Aetheria.Shared.Tests/RunGoalTests.cs
+++ b/tests/Aetheria.Shared.Tests/RunGoalTests.cs
@@ -12,13 +12,13 @@ using UniRx;
using Xunit;
// The demo's goal (aetheria-release, cut boss-gate): the boss zone spawns its faction's boss, and the exit gate opens
-// only when that boss is dead. Every input is the production one: the demo galaxy, GenerateZone, the Zone death path,
+// only when that boss is dead. The boss flies its faction's boss Loadout (cut boss-loadout). Every input is the production one: the demo galaxy, GenerateZone, the Zone death path,
// and the run save.
public sealed partial class RunStartTests
{
- private ZonePack BossZonePack(Galaxy galaxy, ItemManager items, GalaxyZone zone, bool ambient = true)
+ private ZonePack BossZonePack(Galaxy galaxy, ItemManager items, GalaxyZone zone, bool ambient = true, uint seed = 7)
{
- items.Random = new CultMath.Random(7);
+ items.Random = new CultMath.Random(seed);
return ZoneGenerator.GenerateZone(items, _zoneSettings, _planetSettings, galaxy, zone, galaxy.IsPrelude, ambient);
}
@@ -38,12 +38,87 @@ public sealed partial class RunStartTests
.Where(hull => hull != null && hull.HullType == HullType.Ship && hull.Price > 0)
.Distinct().ToArray();
+ // A hull no product makes, so the market never offers it: a MessagePack copy of the first sold ship hull by name, renamed. It has
+ // no authored model, which a boss does not need. Stored once; asking again returns the same record.
+ private HullData BossTestHull()
+ {
+ var existing = _cache.GetAll().FirstOrDefault(hull => hull.Name == "Boss Test Hull");
+ if (existing != null) return existing;
+ var options = CultDocumentMessagePackSerialization.OptionsFor(typeof(HullData).Assembly);
+ var like = SoldShipHulls().OrderBy(hull => hull.Name, StringComparer.Ordinal).First();
+ var boss = MessagePack.MessagePackSerializer.Deserialize(MessagePack.MessagePackSerializer.Serialize(like, options), options);
+ boss.Name = "Boss Test Hull";
+ boss.Prefab = null;
+ boss.Visual = default;
+ return _cache.Get(_cache.Upsert(boss));
+ }
+
+ // A Loadout record at Loadouts.KeyOf(Name), the key Loadouts.Commit writes it under.
+ private void StoreLoadout(Loadout loadout) =>
+ Assert.True(_cache.Commit(batch => batch.Upsert(typeof(Loadout), loadout, Loadouts.KeyOf(loadout.Name))));
+
+ // A boss's fixed Loadout (ruling boss-gear-is-a-loadout), by the production capture: a seed-11 generated fit of the first sold
+ // ship hull by name, captured (Loadouts.Capture), cut down to its weapons so it is smaller than any generated fit (the tractor
+ // pickup and the rest are not in it), moved onto the given hull with no hull product, and stored under its name.
+ private Loadout MakeBossLoadout(HullData hull, string name)
+ {
+ var like = SoldShipHulls().OrderBy(h => h.Name, StringComparer.Ordinal).First();
+ var random = new CultMath.Random(11);
+ var generator = new LoadoutGenerator(ref random, _items, null, null, null, .5f);
+ var ship = (Ship) EntitySerializer.Unpack(_items, null, generator.GenerateShipLoadout(h => h == like));
+ var fit = Loadouts.Capture(_items, ship, name);
+ var armed = fit.Slots.Select((slot, index) => (slot, index))
+ .Where(entry => _cache.Get(entry.slot.Design).Behaviors.Any(behavior => behavior is WeaponData)).ToArray();
+ Assert.NotEmpty(armed);
+ Assert.True(armed.Length < fit.Slots.Count, "the generated fit needs gear besides weapons for this fixture to tell a Loadout from a fit");
+ var renumbered = armed.Select((entry, number) => (entry.index, number)).ToDictionary(entry => entry.index, entry => entry.number);
+ fit.WeaponGroups = fit.WeaponGroups.Select(group => group.Where(renumbered.ContainsKey).Select(index => renumbered[index]).ToArray()).ToArray();
+ fit.Slots = armed.Select(entry => entry.slot).ToList();
+ fit.Hull = _cache.RefOf(hull);
+ fit.HullProduct = default;
+ StoreLoadout(fit);
+ return fit;
+ }
+
+ private static void SetBoss(Faction faction, Loadout loadout) => faction.BossLoadout = new CultRecordRef(Loadouts.KeyOf(loadout.Name));
+
+ // The demo's antagonist gets a boss Loadout on a hull nothing sells: the shipped catalog authors none.
+ private Loadout GiveAntagonistABoss(Galaxy galaxy)
+ {
+ var boss = MakeBossLoadout(BossTestHull(), "Antagonist Boss");
+ SetBoss(Zhestokost(galaxy), boss);
+ return boss;
+ }
+
+ // What a ship carries, cell by cell, as a Loadout would name it: position, rotation, design, product.
+ private static string[] Cells(ItemManager items, EntityPack pack)
+ {
+ var captured = Loadouts.Capture(items, (Ship) EntitySerializer.Unpack(items, null, pack), "probe");
+ return captured.Slots.OrderBy(slot => slot.Position.x).ThenBy(slot => slot.Position.y)
+ .Select(slot => $"{slot.Position.x},{slot.Position.y},{slot.Rotation},{items.ItemData.Get(slot.Design).Name},{(slot.Product.IsSet() ? items.ItemData.Get(slot.Product).Name : "-")}").ToArray();
+ }
+
+ private static string[] LoadoutCells(CultCache cache, Loadout loadout) =>
+ loadout.Slots.OrderBy(slot => slot.Position.x).ThenBy(slot => slot.Position.y)
+ .Select(slot => $"{slot.Position.x},{slot.Position.y},{slot.Rotation},{cache.Get(slot.Design).Name},{(slot.Product.IsSet() ? cache.Get(slot.Product).Name : "-")}").ToArray();
+
+ private LoadoutGenerator GeneratorFor(Galaxy galaxy, ItemManager items, Faction faction, uint seed)
+ {
+ var random = new CultMath.Random(seed);
+ return new LoadoutGenerator(ref random, items, galaxy, galaxy.Exit, faction, .5f);
+ }
+
+ // What the pack holds, in order, by hull and faction: two zone packs that drew the same stream hold the same list.
+ private static string[] Roster(ItemManager items, ZonePack pack) =>
+ pack.Entities.Select(entity => $"{HullName(items, entity)}|{(entity.Faction.IsSet() ? entity.Faction.Key.ToString() : "-")}").ToArray();
+
[Fact]
public void Boss_spawns_once_in_boss_zone()
{
foreach (var seed in DemoSeeds.Take(3))
{
var galaxy = DemoGalaxy(seed);
+ GiveAntagonistABoss(galaxy);
var antagonist = Zhestokost(galaxy);
foreach (var zone in galaxy.Zones)
{
@@ -53,6 +128,7 @@ public sealed partial class RunStartTests
var boss = Assert.Single(bosses);
Assert.IsType(boss);
Assert.Same(antagonist, _cache.Get(boss.Faction));
+ Assert.Equal("Boss Test Hull", HullName(_items, boss));
// Generation is repeatable per zone: the same zone yields the same boss hull.
var again = Assert.Single(BossZonePack(galaxy, _items, zone).Entities, entity => entity.Boss);
Assert.Equal(HullName(_items, boss), HullName(_items, again));
@@ -65,15 +141,215 @@ public sealed partial class RunStartTests
public void Boss_spawns_in_a_zone_that_is_not_ambient()
{
var galaxy = DemoGalaxy(1);
+ GiveAntagonistABoss(galaxy);
var pack = BossZonePack(galaxy, _items, galaxy.Exit, ambient: false);
Assert.Single(pack.Entities, entity => entity.Boss);
Assert.DoesNotContain(pack.Entities, entity => !entity.Boss && entity is ShipPack);
}
+ // Faction.BossLoadout owns the boss. A decoy Loadout sorts before it by name and by key, so a resolver that takes the first
+ // Loadout in the cache, or any Loadout but the referenced one, flies the wrong hull.
+ [Fact]
+ public void Boss_flies_its_factions_boss_loadout()
+ {
+ var galaxy = DemoGalaxy(1);
+ var antagonist = Zhestokost(galaxy);
+ var sold = SoldShipHulls().OrderBy(hull => hull.Name, StringComparer.Ordinal).First();
+ StoreLoadout(new Loadout { Name = "Aaa Decoy", Hull = _cache.RefOf(sold) });
+ var loadout = GiveAntagonistABoss(galaxy);
+
+ Assert.Same(_cache.Get(antagonist.BossLoadout), Loadouts.BossOf(_cache, antagonist, out var refusal));
+ Assert.Equal(BossRefusal.None, refusal);
+ Assert.Equal("Antagonist Boss", loadout.Name);
+ var boss = Assert.Single(BossZonePack(galaxy, _items, galaxy.Exit).Entities, entity => entity.Boss);
+ Assert.IsType(boss);
+ Assert.Same(antagonist, _cache.Get(boss.Faction));
+ Assert.Equal("Boss Test Hull", HullName(_items, boss));
+ var again = Assert.Single(BossZonePack(galaxy, _items, galaxy.Exit).Entities, entity => entity.Boss);
+ Assert.Equal(Cells(_items, boss), Cells(_items, again));
+ }
+
+ // Ruling boss-gear-is-a-loadout: the boss carries exactly its Loadout, nothing drawn. The Loadout is weapons only, so any
+ // pickup, extra gear, cargo or consumable on the boss is a generator pass that should not run.
+ [Fact]
+ public void Boss_carries_exactly_its_loadouts_cells()
+ {
+ var galaxy = DemoGalaxy(1);
+ var loadout = GiveAntagonistABoss(galaxy);
+ Assert.True(loadout.Slots.Count > 1);
+ Assert.All(loadout.Slots, slot => Assert.True(slot.Product.IsSet(), "a captured fit pins every product"));
+
+ foreach (var seed in new uint[] { 7, 8 })
+ {
+ var items = LoggingItems(new List());
+ var boss = Assert.Single(BossZonePack(galaxy, items, galaxy.Exit, seed: seed).Entities, entity => entity.Boss);
+ Assert.Equal(LoadoutCells(_cache, loadout), Cells(items, boss));
+ Assert.All(boss.Equipment, entry => Assert.DoesNotContain(items.GetData(entry.item).Behaviors, behavior => behavior is PickupData));
+ Assert.Empty(boss.CargoContents.SelectMany(bay => bay));
+ Assert.Empty(boss.DockingBayContents.SelectMany(bay => bay));
+
+ var captured = Loadouts.Capture(items, (Ship) EntitySerializer.Unpack(items, null, boss), "probe");
+ string[][] Groups(Loadout l) => l.WeaponGroups.Select(group => group.Select(i => $"{l.Slots[i].Position.x},{l.Slots[i].Position.y}").OrderBy(x => x, StringComparer.Ordinal).ToArray()).Where(group => group.Length > 0).ToArray();
+ Assert.Equal(Groups(loadout), Groups(captured));
+ }
+ }
+
+ // Ruling loadout-product-optional-context-chooses: a design-only slot takes the brand the boss's faction can get. The design has
+ // an outsider's product that sorts first by name, so a chooser that takes the first product by name builds the wrong brand.
+ [Fact]
+ public void A_design_only_boss_slot_takes_a_brand_its_faction_can_get()
+ {
+ var galaxy = DemoGalaxy(1);
+ var antagonist = Zhestokost(galaxy);
+ var loadout = GiveAntagonistABoss(galaxy);
+ var outfitter = GeneratorFor(galaxy, _items, antagonist, 1);
+ var open = loadout.Slots.First(slot => _cache.GetAll().Any(product => product.Design.Key.Equals(slot.Design.Key) && outfitter.IsAvailable(product)));
+ var template = _cache.GetAll().First(product => product.Design.Key.Equals(open.Design.Key));
+ open.Product = default;
+ StoreLoadout(loadout);
+
+ var options = CultDocumentMessagePackSerialization.OptionsFor(typeof(HullData).Assembly);
+ var outsider = MessagePack.MessagePackSerializer.Deserialize(MessagePack.MessagePackSerializer.Serialize(template, options), options);
+ outsider.Name = "Aaa Outsider";
+ foreach (var faction in _cache.GetAll().OrderBy(faction => faction.Name, StringComparer.Ordinal))
+ {
+ outsider.Manufacturer = _cache.RefOf(faction);
+ if (!outfitter.IsAvailable(outsider)) break;
+ }
+ Assert.False(outfitter.IsAvailable(outsider), "the outsider's maker is neither Zhestokost nor in its allegiance");
+ _cache.Upsert(outsider);
+
+ var gettable = _cache.GetAll().Where(product => product.Design.Key.Equals(open.Design.Key) && outfitter.IsAvailable(product)).Select(product => product.Name).ToArray();
+ Assert.NotEmpty(gettable);
+ foreach (var seed in new uint[] { 1, 2, 3, 4, 5 })
+ {
+ var items = LoggingItems(new List());
+ var boss = Assert.Single(BossZonePack(galaxy, items, galaxy.Exit, seed: seed).Entities, entity => entity.Boss);
+ var cell = Assert.Single(Cells(items, boss), c => c.StartsWith($"{open.Position.x},{open.Position.y},"));
+ var brand = cell.Split(',').Last();
+ Assert.NotEqual("Aaa Outsider", brand);
+ Assert.Contains(brand, gettable);
+ }
+ }
+
+ // No generated fallback (rulings boss-gear-is-a-loadout, demo-boss-hull-invented): the shipped catalog authors no boss Loadout,
+ // so Zhestokost has no boss. The refusal happens before anything is drawn.
+ [Fact]
+ public void Boss_without_a_boss_loadout_is_refused()
+ {
+ var galaxy = DemoGalaxy(1);
+ var antagonist = Zhestokost(galaxy);
+ Assert.Null(Loadouts.BossOf(_cache, antagonist, out var refusal));
+ Assert.Equal(BossRefusal.Unset, refusal);
+
+ var log = new List();
+ var items = LoggingItems(log);
+ var pack = BossZonePack(galaxy, items, galaxy.Exit);
+ Assert.False(pack.BossSpawned);
+ Assert.DoesNotContain(pack.Entities, entity => entity.Boss);
+ Assert.Contains(log, line => line.Contains("Zhestokost has no boss") && line.Contains("sets no Faction.BossLoadout"));
+ Assert.Contains(log, line => line.Contains("Galaxy.Exit") && line.Contains("exit-without-boss"));
+ Assert.False(RunGoal.ExitOpen(new Zone(items, _planetSettings, pack, galaxy.Exit, galaxy)));
+
+ // Nothing was drawn for the refused boss: the zone is the zone with no boss mapped at all.
+ galaxy.BossZones.Clear();
+ var bare = BossZonePack(galaxy, LoggingItems(new List()), galaxy.Exit);
+ Assert.NotEmpty(bare.Entities);
+ Assert.Equal(Roster(items, bare), Roster(items, pack));
+ }
+
+ // A reference to a Loadout the catalog does not hold is refused like no reference, and the log names the field, not the value.
+ [Fact]
+ public void A_missing_boss_loadout_is_refused()
+ {
+ var galaxy = DemoGalaxy(1);
+ var antagonist = Zhestokost(galaxy);
+ antagonist.BossLoadout = new CultRecordRef(Loadouts.KeyOf("No Such Loadout"));
+ Assert.Null(Loadouts.BossOf(_cache, antagonist, out var refusal));
+ Assert.Equal(BossRefusal.Missing, refusal);
+
+ var log = new List();
+ var items = LoggingItems(log);
+ var pack = BossZonePack(galaxy, items, galaxy.Exit);
+ Assert.False(pack.BossSpawned);
+ Assert.DoesNotContain(pack.Entities, entity => entity.Boss);
+ Assert.Contains(log, line => line.Contains("Zhestokost has no boss") && line.Contains("names a Faction.BossLoadout that is not in the catalog"));
+ Assert.DoesNotContain(log, line => line.Contains("No Such Loadout") || line.Contains("sets no"));
+ Assert.DoesNotContain(log, line => line.Contains("Zhestokost has no boss") && line.Contains("No Such"));
+ }
+
+ // A boss Loadout whose slots do not fit gives no boss: the log names the Loadout and every fit failure, and the gate stays sealed.
+ [Fact]
+ public void An_unbuildable_boss_loadout_spawns_no_boss()
+ {
+ var galaxy = DemoGalaxy(1);
+ var loadout = GiveAntagonistABoss(galaxy);
+ loadout.Slots[0].Position = new int2(999, 999);
+ loadout.Slots[1].Position = new int2(998, 998);
+ StoreLoadout(loadout);
+
+ var log = new List();
+ var items = LoggingItems(log);
+ var pack = BossZonePack(galaxy, items, galaxy.Exit, ambient: false);
+ Assert.False(pack.BossSpawned);
+ Assert.DoesNotContain(pack.Entities, entity => entity.Boss);
+ var refusal = Assert.Single(log, line => line.Contains("Antagonist Boss") && line.Contains("does not fit"));
+ Assert.Equal(2, Regex.Matches(refusal, "does not fit").Count);
+ Assert.Contains("; ", refusal);
+ Assert.False(RunGoal.ExitOpen(new Zone(items, _planetSettings, pack, galaxy.Exit, galaxy)));
+ }
+
+ // The existing market rule (ruling off-market-is-general): an item is on offer iff a product of it is. A hull no product makes
+ // is never drawn, stocked or chosen, yet the boss whose Loadout names it flies it.
+ [Fact]
+ public void A_hull_no_product_makes_is_never_on_offer()
+ {
+ var galaxy = DemoGalaxy(1);
+ var hull = BossTestHull();
+ GiveAntagonistABoss(galaxy);
+ Assert.DoesNotContain(hull, LoadoutGenerator.SoldHulls(_cache));
+ var items = LoggingItems(new List());
+
+ for (uint seed = 1; seed <= 20; seed++)
+ {
+ var generator = GeneratorFor(galaxy, items, Zhestokost(galaxy), seed);
+ var ship = generator.GenerateShipLoadout();
+ Assert.NotNull(ship);
+ Assert.NotEqual(hull.Name, HullName(items, ship));
+ var station = generator.GenerateStationLoadout();
+ Assert.DoesNotContain(EntitySerializer.Items(station), item => items.GetData(item).Name == hull.Name);
+ Assert.Null(generator.ChooseProduct(hull));
+ Assert.Null(generator.GenerateShipLoadout(candidate => candidate == hull));
+ }
+
+ var boss = Assert.Single(BossZonePack(galaxy, items, galaxy.Exit).Entities, entity => entity.Boss);
+ Assert.Equal(hull.Name, HullName(items, boss));
+ }
+
+ // PlaceFactionsMain reads BossOf: with no reference set there is no boss zone, a reference to nothing places none, and the one
+ // faction whose boss Loadout resolves is the one entry though another faction sorts first.
+ [Fact]
+ public void Main_galaxy_bosses_are_factions_with_a_boss_loadout()
+ {
+ Assert.Empty(RunStart.Generate(new MainGalaxy(), Inputs(() => 1)).BossZones);
+
+ var factions = _cache.GetAll().OrderBy(faction => faction.Name, StringComparer.Ordinal).ToArray();
+ factions[0].BossLoadout = new CultRecordRef(Loadouts.KeyOf("No Such Loadout"));
+ Assert.Empty(RunStart.Generate(new MainGalaxy(), Inputs(() => 1)).BossZones);
+
+ var armed = MakeBossLoadout(BossTestHull(), "Main Boss");
+ SetBoss(factions[1], armed);
+ var galaxy = RunStart.Generate(new MainGalaxy(), Inputs(() => 1));
+ var bossFaction = Assert.Single(galaxy.BossZones.Keys);
+ Assert.Equal(factions[1].Name, bossFaction.Name);
+ Assert.NotNull(Loadouts.BossOf(_cache, bossFaction, out _));
+ }
+
[Fact]
public void Exit_sealed_until_boss_dies()
{
var galaxy = DemoGalaxy(1);
+ GiveAntagonistABoss(galaxy);
var exit = ZoneOf(galaxy, galaxy.Exit);
var boss = Assert.Single(exit.Entities, entity => entity.IsBoss);
Assert.True(RunGoal.BossAlive(exit));
@@ -96,6 +372,7 @@ public sealed partial class RunStartTests
{
var (galaxy, arena, staged, failures) = Launch(new DemoTerminus(), Inputs(() => 1));
Assert.True(failures.Count == 0, string.Join("; ", failures));
+ GiveAntagonistABoss(galaxy);
galaxy.Entrance.Contents = arena;
galaxy.Exit.Contents = ZoneOf(galaxy, galaxy.Exit);
var before = Assert.Single(galaxy.Exit.Contents.Entities, entity => entity.IsBoss);
@@ -131,7 +408,7 @@ public sealed partial class RunStartTests
}
}
- // The same for a demo exit whose boss could not be generated: the zone logs the gap by name and the gate stays sealed.
+ // The same for a demo exit whose boss could not be built: the zone logs the gap by name and the gate stays sealed.
[Fact]
public void Exit_sealed_and_logged_when_the_boss_cannot_be_generated()
{
@@ -152,10 +429,10 @@ public sealed partial class RunStartTests
public void Exit_open_only_in_the_exit_zone()
{
var galaxy = RunStart.Generate(new MainGalaxy(), Inputs(() => 1));
- // The shipped catalog sets no BossHull outside the demo's antagonist, so the main galaxy places no boss: give a
- // faction one and a boss zone that is not the exit, as the generator would for a faction with a boss hull.
+ // The shipped catalog sets no boss Loadout, so the main galaxy places no boss: give a faction one and a boss zone that is
+ // not the exit, as the generator would for a faction with a boss Loadout.
var faction = galaxy.Factions.First();
- faction.BossHull = _cache.RefOf(SoldShipHulls().First());
+ SetBoss(faction, MakeBossLoadout(SoldShipHulls().First(), "Gate Boss"));
var bossZone = galaxy.Zones.First(zone => zone != galaxy.Exit);
galaxy.BossZones[faction] = bossZone;
var zone = ZoneOf(galaxy, bossZone);
@@ -172,6 +449,7 @@ public sealed partial class RunStartTests
public void Exit_open_after_save_of_a_slain_boss()
{
var galaxy = DemoGalaxy(1);
+ GiveAntagonistABoss(galaxy);
var exit = ZoneOf(galaxy, galaxy.Exit);
Assert.Single(exit.Entities, entity => entity.IsBoss).HeatstrokeDeath.OnNext(Unit.Default);
var repacked = exit.PackZone();
From e5485bb3e0c18eb452374764447fef6106ca2f8c Mon Sep 17 00:00:00 2001
From: Meta Vens
Date: Sun, 18 Oct 2026 21:17:42 +0200
Subject: [PATCH 025/916] aetheria-release map: agent-built hulls replace the
stand-in section (form languages, probe, first cut)
Co-Authored-By: Claude Opus 5.5
---
docs/aetheria-release-map.md | 315 +++++++++++++++++------------------
1 file changed, 150 insertions(+), 165 deletions(-)
diff --git a/docs/aetheria-release-map.md b/docs/aetheria-release-map.md
index 37344be87..50128adac 100644
--- a/docs/aetheria-release-map.md
+++ b/docs/aetheria-release-map.md
@@ -11190,197 +11190,182 @@ with the wider scope taken when the FusedRounds premise is fixed.
`no-save-compatibility-before-players` the cut may refuse it, but a refusal gate would be code
written for nobody.
-## Stand-in hulls (SI)
+## Agent-built hulls
-**Superseded 2026-10-18 by ruling `hull-art-communicates-form`:** the placeholder-look goal and the schematic-generated body below are set aside; agent-built hulls are low-poly models that communicate each ship's form and faction, beside hero assets. The probe's package path, anchors and replace-by-real-art lifecycle are evidence for the re-map; its visual grammar and cut sequence are not live.
+Replaces section "Stand-in hulls (SI)". Imagination pass `imagination-ag6-hull-art2`, session `self-2026-10-18-ag6`,
+2026-10-18, pinned to Aetheria `origin/master` d28ce42d (worktree `C:\aeth-wt\ag6-hull-art2`). Serves ruling
+`hull-art-communicates-form`. It supersedes `hull-programmer-art-reads-as-stand-in`. The ruling asks for agent-built
+low-poly hulls that communicate each ship's intended form and its faction ("A Zhestokost ammo tender shouldn't look the
+same as a Pirate fighter"). It also asks for a couple of fully produced hero assets to compare them with, so that hull
+variety is not gated on the operator's manual throughput. Research:
+`docs/research/2026-10-18-agent-built-hull-art-prior-art.md` and `docs/research/2026-10-18-faction-form-language-prior-art.md`.
-Imagination pass `imagination-ag6-hull-art`, session `self-2026-10-18-ag6`, 2026-10-18. Pinned to Aetheria
-`origin/master` 6d10331c (worktree `C:\aeth-wt\ag6-hull-art`). Serves ruling
-`hull-programmer-art-reads-as-stand-in`, which supersedes `hull-programmer-art-stopgap`.
-Research input: `docs/research/2026-10-18-agent-built-hull-art-prior-art.md`. That file surveys making agent-built
-art look good or deliberate. This ruling asks for the opposite, so the research's §B3 (low poly that reads as
-deliberate) is evidence about what to avoid. The greybox "dev texture" convention below comes from general practice,
-not from that file (one of the gaps listed at the end).
+Kept from SI: the package path, the anchor rules (SI-B1 to SI-B3), and replace-by-real-art as one act by one owner.
+Dropped from SI: the body generated from the schematic, the grey grid mark, and glyphs by mount kind.
-Scratch root `S` = `C:\Users\Meta\AppData\Local\Temp\claude\F--Projects-CultLib\1b477360-19e3-41e2-bde4-8932ace0b8fd\scratchpad\imagination-ag6-hull-art`.
+Scratch root `S` = `C:\Users\Meta\AppData\Local\Temp\claude\F--Projects-CultLib\1b477360-19e3-41e2-bde4-8932ace0b8fd\scratchpad\imagination-ag6-hull-art2`.
### Renders for the operator
-- `S\probe\out\longinus_top_standin_vs_existing.png`: top view, stand-in (left) and the shipped `Longinus.fbx` (right), each at its own scale.
-- `S\probe\out\longinus_iso_standin_vs_existing.png`: three-quarter view, same pair.
-- `S\probe\out\longinus_combat_zoom_proxy.png`: both top views at ship lengths of 48, 80 and 128 px.
-- `S\probe\out\longinus_top_same_metres.png`: both in one 40 m frame. The stand-in uses 2 m cells and the shipped mesh about 1 m per cell (SI-B5).
+- `S\out\sheets\1_pair_same_scale.png`: the two probe hulls in three views (three-quarter, top, port side). Both use
+ the same camera, light and metres per pixel. On the left is the Zhestokost ammo tender "Podvoz", 23 m. On the right
+ is the Pirate fighter "Markdown", 15 m, built on a stolen Rossum & Douglas wedge.
+- `S\out\sheets\3_pirate_vs_djinni_hero.png`: the Pirate fighter beside `Djinni.fbx`, the shipped Rossum & Douglas
+ hull. Djinni is grey because its materials are not read.
+- `S\out\sheets\4_zhestokost_vs_operator_art.png`: the tender beside the operator's Zhestokost faction sheet
+ (`Asset Sources/Zhestokost.png`, cropped) and the shipped `Turret.fbx`.
+- `S\out\sheets\5_combat_zoom_proxy.png`: both top views at ship lengths of 48, 80 and 128 px.
+- `S\out\sheets\2_pair_own_framing.png`: each hull framed to its own size.
-All four come from one scratch rasterizer (`S\probe\render.py`) with the same camera and light. The stand-in side is
-read back from the `ship.glb` the package path accepted, so it is not a separate preview.
+All renders come from one scratch flat-shaded rasterizer (`S\render.py`). They are read back from the `ship.glb`
+files that the package path accepted.
-### What the game reads (body facts)
+### Probe (AH-P)
-- **SI-B1. Package shape.** A mod hull is `GameData/Mods//ship.cc` plus `ship.glb`. The `.cc` holds `HullData`
- (`mod-hull:`) and `ShipAuthoring` (`mod-ship:`; `ModelAsset`, `Anchors`, `SchematicLines`, `Joints`).
- Source: `ShipAuthoring.cs:12-21`, `docs/moddable-ship-authoring.md:160-200`.
-- **SI-B2. Anchors the game needs.** Exactly one each of `map-icon`, `hull-collider`, `shield` and `tractor`
- (`ShipAuthoring.cs:288-290`). Each visible hardpoint has a mount anchor whose id is its mount id: `thruster-emitter`,
- `radiator-mesh` or `weapon-mount`. Each weapon needs at least one `weapon-muzzle` whose ParentId is the mount
- (`:325-356`). These nodes must carry a mesh: thruster-emitter, radiator-mesh, map-icon and hull-collider. The
- shield node needs three positive scale radii (`ShipModCatalog.cs:256-262`). Weapon mounts and the tractor may be
- empties. Internal hardpoints have no anchor. Every hardpoint needs a non-empty mount id.
-- **SI-B3. Frame.** Blender Ship Root has the nose toward -Y, starboard toward -X and Z up. Cell (x, y) is centred at
- `origin - 2(x, y)`, schematic +x is starboard and +y is forward, so row 0 is the stern
- (`tools/blender/aetheria_ships/hull_grid.py:3-20`). Package exports with `export_yup` (`__init__.py:791`), so the
- glTF nose is +Z. Hardpoint `Rotation` gives the facing: 0 nose, 1 port, 2 aft, 3 starboard
- (`hull_grid.py:141-145`). A footprint shape is stored as placed, and validation reads it at `Position` without
- rotating it (`ShipAuthoring.cs:310-320`).
-- **SI-B4. Longinus HullData** (decoded from `GameData/Aetheria.cc` with cultcache-py, `S\grid.py`). It is 6 x 17
- cells, symmetric, with 13 hardpoints. Visible: Th.L and Th.R (2x2, rows 0-1, aft), Th.CW and Th.CCW (1x2, row 14,
- port and starboard), En.L and En.R (1x2, row 8), La.L and La.R (1x3, flanks, rows 5-7), Ra.L and Ra.R (1x2,
- row 2). Internal: Reactor, ControlModule, and Sensors, which has a **null mount id**. Because of that null id, a
- package copy of the shipped Longinus is refused until the Sensors hardpoint is given an id (`ship_cc.replace_layout`
- raised "needs 7 typed fields and a stable mount ID"). The probe gave it the id `Sensors`.
-- **SI-B5. Scale.** The add-on authors at 2 m per cell (`hull_grid.py:11`, "Settings.SchematicCellSize"; New Ship
- sizes "this many 2 m cells"). The shipped `Longinus.fbx` body is 5.2 x 16.8 m for 6 x 17 cells, about 1 m per cell
- (`S\fbx.py`, mesh `Cube.043`). Ruling `schematic-and-model-are-separate-spaces` already allows the two to differ.
- The stand-in uses the add-on's 2 m.
-- **SI-B6. Materials today.** `ShipModVisual` imports the GLB with glTFast and keeps its glTF materials. The only
- material it adds is the schematic line material (`ShipModVisual.cs:55-64`). `Aetheria/Hull` and the UV0 livery mask
- belong to `ships-hull-material`, which has a spec but has not landed. So a stand-in's look today is whatever its
- glTF materials say.
-- **SI-B7. `ship-authoring create --like`** copies a shipped hull's stats with an empty shape and no hardpoints
- (`ShipAuthoringCommands.cs:57-75`, `HullLike` clears `Shape` and `Hardpoints`). The layout comes from Blender or
- from `ship_cc.replace_layout`.
-- **SI-B8. OpenSCAD over LevelDsl, decided from source.** The Geometry.Csg `LevelDsl` has box, cut box, oriented box,
- cylinder_z, dome_cap_z and floret_arm, with no hull or free-axis cone (research, Internal fit), and it needs a
- cargo build. OpenSCAD nightly with Manifold is installed, and brush-tree's `openscad-target` already rules
- OpenSCAD-shaped text. LevelDsl was not probed.
+The probe has three layers, each a separate file:
+- **Faction languages**, in `S\lang\`. `zhestokost.kit.scad`, `rnd.kit.scad` and `pirate.kit.scad` hold the shape
+ vocabulary as OpenSCAD modules. `*.lang.json` holds the identity and forbidden lines quoted from the lore, the
+ proportion ranges, the symmetry rule and the palette zones. The target folds each faction's JSON into its `.scad`;
+ see cut `agent-hull-source`.
+- **Role briefs**, in `S\hulls\*.brief.json`. Each gives the faction, donor, role, the play line from
+ `Faction Play.md`, the reads the hull must show, the size class, the triangle budget and the mounts.
+- **Hull sources**, in `S\hulls\*.scad`, written by the agent. They are about 40 lines each, compose only kit modules,
+ are split by colour zone, and echo their anchors.
-### The probe (Longinus)
+`S\build.py` renders each part through `openscad.com --backend Manifold --render all`, one process at a time. All 28
+PIDs are in `S\out\pids.log`, the first 3404 and the last 20348. It then writes `ship.glb` and runs the checks.
-The stand-in source has three files (`S\probe\`):
-- `standin.scad`: the vocabulary. Glyph per kind, kind colours, cell frame, part dispatch.
-- `longinus.layout.scad`: generated from HullData by `gen_layout.py`, and never edited by hand. It holds the visible
- mounts: id, kind, position, placed footprint and rotation.
-- `longinus.standin.scad`: agent-authored, 25 lines. Four `hull()` segments make the body (stern block, flared
- weapons section, spine, nose), plus a `deck()` height function.
+- **AH-P1. Checks.** All pass (`S\out\\checks.json`).
+ - Tender: 3468 triangles. The bbox is 10.5 x 23.4 x 5.9 m, inside its 18-28 m size class. Body h/w is 0.42 and w/l
+ is 0.61, inside Zhestokost's ranges [0.25, 0.6] and [0.35, 0.75]. Bilateral symmetry has a worst mirror miss of
+ 0.0000 m. It has five mount anchors, and every weapon has a muzzle nose-ward of its mount.
+ - Fighter: 1466 triangles and 15 m long. The donor body's h/w is 0.20 and w/l 0.69, inside the R&D ranges. The
+ asymmetry rule holds.
+ - The vertex-based asymmetry figure (0.91 unmirrored) is too lenient, because tessellation alone breaks vertex
+ pairs. The silhouette measure below is the one to keep.
+- **AH-P2. Package path, on Yggdrasil, GREEN** (`S\ygg-agenthull-2.log`). The run used the scratch clone
+ `...\imagination-ag6-hull-art\vclone` at a10b5d64. That is 6d10331c plus throwaway commits, never pushed;
+ `git diff 6d10331c d28ce42d` touches no ship code. The job:
+ 1. `ship-authoring create --like Longinus` for `agent.zhammotender` and `agent.pifighter`.
+ 2. A gameplay layout authored separately, with mount ids matching the hull source's anchors.
+ 3. `ship_cc.replace_visual` with the anchors.
+ 4. `validate`: "7 hardpoints, 10 anchors" and "5 hardpoints, 8 anchors (records and model)".
+ 5. `compose`: "Composed 2 mod ships".
-`build.py` renders each part separately with `openscad.com --backend Manifold --render all -D part="…"` (one process
-at a time, about 22 runs). It then writes `ship.glb`: a flat-faceted mesh per part, UV0 as a top-down projection in
-cell units, and nodes tagged `extras.aetheria.id`. It also writes `anchors.json`.
+ Run 1 was red because it had no `/pins` or `/lfs` mounts (the `DOCKER_ARGS` recipe in briefs.md).
+- **AH-P3. Silhouettes** (`S\out\sheets\metrics.json`). The silhouettes are scaled to their own bounding box, so the
+ comparison is of shape, not size. Tender against fighter: IoU 0.69 from the top and 0.52 from the side. Mirror IoU
+ from the top: tender 1.00, fighter 0.80, Djinni 1.00. These numbers are guardrails, not the judge.
+- **AH-P4. What the renders show.**
+ - The two read as different ships at every size, including 48 px. The tender is a dark, broad stepped block with
+ twin handling booms and eight oxide-red magazines hung outboard. A top-down camera sees those magazines; the
+ first version hung them under the booms, where they were hidden from above, and was moved. The fighter is a pale
+ wedge with a gun as long as the hull on the port side, a mismatched bell drive on the starboard quarter, a teal
+ crew slash and primer plates.
+ - The faction read holds without labels:
+ - Zhestokost shows stepped masses, deep seams, plates, tow lugs, recessed machinery and a low broad body.
+ - The Pirate fighter shows the donor wedge plus additions, each with a mount: a saddle under the gun, struts on
+ the drive, a strut under the sensor pod. A cable run joins the gun to the drive.
+ - Weaknesses:
+ - The charcoal Zhestokost body is low-contrast on dark space at 48 px.
+ - The fighter's thin side profile carries little.
+ - Nothing yet has the operator's one-segment-bevel and weighted-normal finish. Box chamfers stand in for it.
+ Blender's Bevel and Weighted Normal at Package would supply the real finish (`shippable-part-bar`, brush-tree).
+- **AH-P5. Not proven.**
+ - Unity: the ships were not flown, and `ShipModPlaySmoke` was not run.
+ - Blender was not in the loop.
+ - The real combat camera was not used.
+ - Only one agent authored both hulls. No second hull per faction tests whether the language holds a family
+ together; that is the next probe line.
-- **SI-P1. Measurements** (`S\probe\build.py` output):
- - The body has 104 triangles. 0 of its 60 vertices lie outside the hull cells, and the worst miss of the mirror
- test is 0.0000 m (the body is symmetric).
- - The GLB is 84 KB, with 28 nodes and 18 anchors.
- - All 10 visible mounts project into their own footprint: weapons and radiators at the footprint centre, thrusters
- on the footprint edge they face.
- - The probe checked vertices, not edges, against the cells. Each segment is convex inside a rectangular run of
- cells, which is why the vertex check suffices here; a stepped outline needs an edge check.
-- **SI-P2. Package path, on Yggdrasil.** `ygg-verify` ran on a scratch clone at `2329782244d3`. That clone is
- 6d10331c plus `standin-probe/`; its commits are throwaway and were never pushed to origin. Image
- `mcr.microsoft.com/dotnet/sdk:10.0`, with pins `/pins/cultlib-git-45c2f40` and `/pins/cultlib-9c1b06cd` and the
- `/lfs` catalog. Log: `S\ygg-standin-6.log`, GREEN. The steps were:
- 1. `ship-authoring create … --like Longinus`.
- 2. `ship_cc.replace_layout` with Longinus' shape and hardpoints, then `ship_cc.replace_visual` with the 18 anchors
- (the add-on's own Python).
- 3. `validate`, which reported "13 hardpoints, 18 anchors, 0 lines (records and model)", meaning
- `ShipModCatalog.ReadPackage` judged the GLB.
- 4. `compose`, which reported "Composed 1 mod ships", with no exclusions.
+### Body facts found on the way (AH-B)
- Runs 1-5 were red on job plumbing: LFS pointer, CultLib pins, empty layout from `--like`, and the null Sensors id.
-- **SI-P3. Not proven.** The Unity side was not run: `ShipModPreview.Smoke -assemble` and `ShipModPlaySmoke.Run`
- (thrusters, weapons with muzzles, collider, map icon). The probe's GLB writer is scratch Python, not the add-on's
- Package Ship. Blender was not in the loop, because no current Blender is on Starfire (only 2.77 and 2.78 under
- `D:\Applications`). Glyph proportions were checked only in the proxy renders, never at the real combat camera.
-- **SI-P4. What the renders show.**
- - From above, the stand-in states where every gun, launcher, engine and radiator is, by colour. At 48 px the
- shipped mesh reads only as a silhouette.
- - The body reads as an unfinished blockout: slab facets, a cell grid, no surface detail. Nobody would take it for
- the shipped hull.
- - The grid is texture noise at 48 px. In engine, mips average it away at distance.
- - The first radiator fins were edge-on from above and vanished. They became panels tilted 30° outward. Energy
- barrels were thickened from 0.14 to 0.28 m for the same reason.
+- **AH-B1. A current Blender is installed.** `C:\Program Files (x86)\Steam\steamapps\common\Blender\blender.exe`
+ exists. Follow-up `blender-pin-operator` records it as Steam's 5.2.2 LTS. The brief's premise ("only 2.77/2.78")
+ came from `D:\Applications` and is wrong, so no install question is raised.
+- **AH-B2. Package already derives map-icon, shield and tractor** (`_regenerate_anchors`, `__init__.py:1009`). A
+ hull source therefore emits only mounts and mesh anchors. That subtracts four anchors from what the probe built.
+- **AH-B3. The add-on derives schematic Positions from the placement of model mounts.** `_plan_mounts`
+ (`__init__.py:409`) writes the HullData Position from where a weapon-mount empty sits. This conflicts with
+ `schematic-and-model-are-separate-spaces`, under which nothing is derived from model geometry, and it is pre-existing.
+ Cut `agent-hull-source` measures it first and reports it as a fork rather than bypassing it. Its owner is the
+ hardpoint walkthrough (`hardpoint-work-held-for-walkthrough`).
+- **AH-B4. No shipped ship embodies a current faction language.**
+ - Djinni (R&D) is a rounded, bulbous body, not the lore's flying wedge.
+ - The operator said of Longinus (Alakrita) that she would be happy never to see it again.
+ - Turret is a Zhestokost turret, not a ship.
-### Visual grammar (proposal; the look is question `standin-visual-mark`)
+ So the heroes are a real fork (question `agent-hull-hero-assets`).
+- **AH-B5. The two Zhestokost sources disagree.**
+ - The lore page gives charcoal, iron and oxide, a low broad hull, and identity "without relying on red paint".
+ - The operator's faction sheet shows a tan body with dark breakup, orange-red stripes, a tall stepped tower, and a
+ forward boom with hanging magazines.
-1. **Body.** A few convex `hull()` segments that follow the hull's outline and its concept (Concept Mill image or
- description). Flat facets at `$fn = 8`. No bevels, panel lines, greebles or invented surface detail. One neutral
- grey, carrying a dark line every 2 m cell on UV0, which is projected top-down in cell units. The grid is the
- greybox mark, and because the cells are the schematic's, it also states size class.
-2. **Mount glyphs by kind,** each in one saturated colour, on its footprint, facing its Rotation:
- - energy: a puck and one long barrel;
- - ballistic: a puck and two short thick barrels;
- - launcher: a box with tube mouths on its facing face;
- - thruster: a bell opening toward its facing, whose mouth disc is the `thruster-emitter` mesh;
- - radiator: a panel tilted outward, which is itself the `radiator-mesh`.
+ The probe took its palette from the lore and the boom and magazines from the sheet (question
+ `zhestokost-language-source`).
+- **AH-B6. A Pirate language is a composition.** The lore makes the Pirate body another faction's hull ("an
+ identifiable donor hull"). Bench 3 names donors: an AU miner, an R&D wedge. So the Pirate language is an additions
+ kit plus a donor language, never a body of its own. The checker reads the donor's proportions and the Pirates'
+ asymmetry rule.
+- **AH-B7. The prompt-lab leak finding does not carry over to meshes.** For image models, shape motifs in a faction
+ block leak onto every hull (prompt-lab rule 3). For meshes nothing applies itself: a kit module appears only where a
+ hull source calls it. The language file can therefore hold shape vocabulary, and the role decides which pieces a
+ hull uses.
- Internal hardpoints are not drawn, because the schematic UI owns them.
-3. **Size.** Model metres are cells x 2 m (the add-on's rule).
-4. **Faction.** None in the mesh. Once `ships-hull-material` lands, the body's UV0 is where the livery mask goes
- (primary channel on the body). Until then the body is neutral grey.
+### Pipeline (target)
-### Model (SKILL step 0b): rows for the persistent kinds this adds
+1. **Faction language** `tools/blender/aetheria_ships/factions/.scad`. One file holds the kit modules and a
+ header of constants: zone palette, symmetry rule, proportion ranges (a Pirate hull uses its donor's). The lore
+ sources are cited in comments. The operator owns it; agents draft it.
+2. **Hull source** `GameData/Mods//hull.scad`. Its brief header gives faction, donor, role, length range, budget
+ and reads. It has one part per zone, and its anchors are echoed. An agent owns it.
+3. **Build From Hull Source**, a new add-on operator. It runs OpenSCAD per part, one process at a time, and checks
+ against the language. It then makes the zone meshes (one material per zone) and the anchor objects under Ship Root.
+4. **Save Layout** (the gameplay schematic, authored separately) and **Package Ship**, both existing:
+ - Package writes `ship.glb`, derives the map icon, shield and tractor, writes the anchors and runs validate.
+ - Zones become livery mask channels when `ships-hull-material` lands (`hull-paint-mask-texture`).
+5. **Render and compare.** A contact sheet puts the hull beside its faction's hero and beside a different-faction
+ hull, at one scale and at combat size. A model reads the sheet and judges whether the hull reads as its faction and
+ role. No rule decides that, because it is a question of meaning. The operator rules on the first few.
+
+### Model (SKILL step 0b)
| Kind | Identity | Lifecycle | Authority |
|---|---|---|---|
-| Stand-in source, `GameData/Mods//standin.scad` | The package directory, which equals `ShipAuthoring.Id`, names it. One per package, at a fixed name. Injective because package ids are. | Created by an agent pass for a hull with no operator art. Revised by agents. Deleted in the same change that lands operator art for that package. | The agent pass (Imagination for content, Hands for the cut) authors the body. The operator decides when it dies, by packaging her art. Forbidden writer: nothing hand-edits the layout. |
-| Layout, generated | Derived from that package's HullData. | Regenerated on every build. Not committed, never edited. | HullData. Owner only under `standin-layout-follows-schematic` = follow-schematic. Under free-like-real-art this row disappears and the source holds mount placement. |
-| Shared vocabulary, `tools/blender/aetheria_ships/standin/standin.scad` | Single file. | Revised by cuts; a revision re-renders every stand-in at its next build. | The ship add-on (Aetheria). |
-| `ship.glb` | `ShipAuthoring.ModelAsset`: one slot per package. | While `standin.scad` exists, a build output of it. Afterwards, the output of the operator's Package. | Exactly one writer at a time. The slot holds one mesh, so two meshes can never both decide. |
-| "This hull is a stand-in" | The presence of `standin.scad` in the package. **No new field.** | Ends when the file is deleted. | Derived. Build Stand-in refuses a package without the file, so it can never overwrite operator art. Any "which hulls are still stand-ins" view is a directory listing. |
-| Anchors | `ShipAuthoring.Anchors`, ids = mount ids. | Rewritten by Package on each build, stand-in or art. Ids are stable across the swap. | Package Ship (`ship_cc.replace_visual`). The same anchor ids keep loadouts and saves valid across the swap. |
+| Faction language, `factions/.scad` | The faction slug. One file per faction. A Pirate hull includes its donor's file as well. | Drafted by an agent from the lore and the operator's art, marked draft, then approved by an operator ruling. A revision rebuilds every hull of that faction at its next Build. | The operator decides the language (`zhestokost-language-source` is the first). Agents propose; nothing else edits it. |
+| Hull source, `GameData/Mods//hull.scad` | The package id, equal to `ShipAuthoring.Id`. One per package. | Created by an agent pass for a hull with no operator art and revised by agents. Deleted by Package in the same act that packages operator art into that package. | Agents (Imagination designs, Hands lands). The operator decides when it dies, by packaging her art. |
+| "Agent-built" status | Presence of `hull.scad`. No field. | Ends when the file is deleted. | Derived. "Which hulls are agent-built" is a directory listing. |
+| Zone meshes and anchor objects in Blender | Marked `aetheria.hull_source`, with ids `aetheria.id`. | Replaced on every Build. Never hand-edited. | Build From Hull Source. Build refuses a collection holding meshes it did not make. |
+| `ship.glb` and ShipAuthoring anchors | `ShipAuthoring.ModelAsset`, with anchor ids equal to mount ids. | Rewritten by every Package, whether from an agent hull or operator art. The ids are stable across the swap, so loadouts and saves survive it. | Package Ship, the only writer. |
+| HullData layout (schematic) | `mod-hull:`. | Authored through Save Layout. Linked to the model by mount name only. | The schematic author: agents for agent hulls, the operator for hers. Never Build. AH-B3 is the open conflict. |
+| Hero asset | A package with no `hull.scad` that is named as its faction's hero. | Set by an operator ruling (`agent-hull-hero-assets`). | The operator. |
-Replacement when real art arrives: the operator packages her collection into the same package. Package writes
-`ship.glb` and the anchors, and the same change deletes `standin.scad`. That is one act and one owner.
-Open choice inside the cut, not an operator fork: whether Package deletes `standin.scad` itself or refuses until it is
-deleted. Recommendation: Package deletes it when the bound collection was not built by Build Stand-in, and says so.
+### Questions admitted
-`standin.scad` ships inside the mod directory, so it may reach player builds. That is harmless, and it doubles as an
-example for modders. The alternative is `tools/standin/hulls/.scad`, which breaks "presence in the package is the
-status".
+- `aetheria-release:question:agent-hull-hero-assets`: which meshes are the heroes. Recommended: `keepers-finished`.
+- `aetheria-release:question:zhestokost-language-source`: whether Zhestokost follows the lore text, the faction sheet,
+ or both. Recommended: `sheet-palette-both-shapes`.
-### Rationale
+Neither blocks the first cut.
-- **Why not Tripo or "deliberate low poly".** The ruling's test is "never mistaken for final art". Every element of
- the grammar is chosen to fail the polish test on purpose: the grid, flat facets, kind colours, and no surface
- detail. Each element also carries information (scale, mount kind, facing), so the look is utility.
-- **Why the layout is generated.**
- - Readability: the mounts the player sees agree with the schematic UI.
- - Upkeep: a schematic edit re-renders the stand-in with no agent pass.
- - Opus's weak spot: spatial placement is the failure mode the prior art documents most (LL3M §5; CAD
- valid-but-wrong), and generation leaves only the body to judgment.
+### Cut sequence
- This is model geometry derived from cells, against `schematic-and-model-are-separate-spaces`, hence question
- `standin-layout-follows-schematic`.
-- **Why Blender for the target, not the probe's Python.** Package Ship already writes `ship.glb` and the anchors,
- and runs validate. A second GLB writer would be a second authority over the same file. The cut imports OpenSCAD
- part meshes into the bound collection with role tags, then calls Package. Brush-tree's `bake-only` and
- `lowered-hull-through-package` point the same way.
-
-### Cut sequence (one line each; no spec admitted, because `standin-build` waits on both questions)
-
-1. `standin-build`. Add-on operator Build Stand-in (headless-capable): checks that `standin.scad` exists, generates
- the layout from the bound `ship.cc`, runs `openscad.com` per part, imports the parts into the bound collection with
- `aetheria.role`/`aetheria.id` tags, and calls Package Ship. It carries the vocabulary file and Longinus as its test
- hull, gives the shipped Longinus Sensors hardpoint a mount id (SI-B4), and adds a `smoke_standin.py` beside
- `smoke_package.py`. Verification:
- - `ShipModPreview.Smoke -assemble` and `ShipModPlaySmoke.Run` on the package;
- - the in-cells, mirror and in-footprint checks from SI-P1 (the last only under follow-schematic).
-
- Deploy owner: OpenSCAD in whatever image runs Blender smokes on Yggdrasil. Not established, because the Blender
- smoke's host was not found.
-2. `standin-package-retire`. Package Ship, on a package that still has `standin.scad`, deletes the file when the
- collection is the operator's (model row above). It can fold into cut 1 if small.
-3. `standin-role-hulls` (content). Stand-ins for the demo role hulls as their HullData land (follow-up
- `demo-role-hulls`), and for the cast flyables until her art arrives. Each body is authored from the hull's
- Concept Mill keeper or description (follow-up `hulls-through-concept-mill`).
-4. After `ships-hull-material`: the stand-in mask, with primary channel = body, so faction liveries colour stand-ins.
- A line in that spec's next revision, not a cut of its own.
+- `agent-hull-source` (spec `aetheria-release:cut_spec:cut-agent-hull-source.r1`): the factions folder,
+ `hull_source.py`, Build From Hull Source, and Package deleting `hull.scad` when it packages operator art. The two
+ probe hulls become fixtures. Its first step measures AH-B3.
+- `agent-hull-family-probe`: one more hull for each of the two factions (a Zhestokost gunboat, a Pirate tender on an
+ AU miner donor). It tests whether a language holds a family together, judged on a sheet beside the hero. Waits on
+ agent-hull-source.
+- `agent-hulls-demo-roles`: hull sources for the demo's role hulls (follow-up `demo-role-hulls`) and the invented
+ Zhestokost boss hull (`demo-boss-hull-invented`), as packages through Package. Waits on agent-hull-family-probe,
+ `mods-in-tree` and `zhestokost-language-source`.
+- `agent-hull-finish`: Bevel and Weighted Normal on agent hulls at Package, and zones into the livery mask. Waits on
+ `ships-hull-material`.
### Gaps
-- Combat camera distance and angle were not read, so the zoom panel is a proxy.
-- The greybox dev-texture convention is general practice, not evidence in the Eyes file.
-- Where a current Blender runs headless for agents is not established on Starfire. The Package smoke's host was
- not checked.
-- Settings.SchematicCellSize = 2 m is cited from `hull_grid.py`, not read from `Settings.asset`.
-- Scope reading, not a ruling: stand-ins are for hulls without operator art (demo role hulls; cast flyables until
- hers land). Shipped legacy hulls keep their meshes.
+- No Unity flight of either hull.
+- No real combat camera.
+- The model read was one agent judging its own sheets.
+- Lucent and AU languages are not drafted.
+- The hero comparison is weak until the heroes exist.
From ad503059e5f75d3ff298ff90bf7673c4f7340fc9 Mon Sep 17 00:00:00 2001
From: Meta Vens
Date: Sun, 18 Oct 2026 21:18:20 +0200
Subject: [PATCH 026/916] RunGoalTests: LoadoutCells reads the fixture's cache
Co-Authored-By: Claude Sonnet 5.5
---
tests/Aetheria.Shared.Tests/RunGoalTests.cs | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/tests/Aetheria.Shared.Tests/RunGoalTests.cs b/tests/Aetheria.Shared.Tests/RunGoalTests.cs
index d2bc84a8f..9db173508 100644
--- a/tests/Aetheria.Shared.Tests/RunGoalTests.cs
+++ b/tests/Aetheria.Shared.Tests/RunGoalTests.cs
@@ -98,9 +98,9 @@ public sealed partial class RunStartTests
.Select(slot => $"{slot.Position.x},{slot.Position.y},{slot.Rotation},{items.ItemData.Get(slot.Design).Name},{(slot.Product.IsSet() ? items.ItemData.Get(slot.Product).Name : "-")}").ToArray();
}
- private static string[] LoadoutCells(CultCache cache, Loadout loadout) =>
+ private string[] LoadoutCells(Loadout loadout) =>
loadout.Slots.OrderBy(slot => slot.Position.x).ThenBy(slot => slot.Position.y)
- .Select(slot => $"{slot.Position.x},{slot.Position.y},{slot.Rotation},{cache.Get(slot.Design).Name},{(slot.Product.IsSet() ? cache.Get(slot.Product).Name : "-")}").ToArray();
+ .Select(slot => $"{slot.Position.x},{slot.Position.y},{slot.Rotation},{_cache.Get(slot.Design).Name},{(slot.Product.IsSet() ? _cache.Get(slot.Product).Name : "-")}").ToArray();
private LoadoutGenerator GeneratorFor(Galaxy galaxy, ItemManager items, Faction faction, uint seed)
{
@@ -183,7 +183,7 @@ public sealed partial class RunStartTests
{
var items = LoggingItems(new List());
var boss = Assert.Single(BossZonePack(galaxy, items, galaxy.Exit, seed: seed).Entities, entity => entity.Boss);
- Assert.Equal(LoadoutCells(_cache, loadout), Cells(items, boss));
+ Assert.Equal(LoadoutCells(loadout), Cells(items, boss));
Assert.All(boss.Equipment, entry => Assert.DoesNotContain(items.GetData(entry.item).Behaviors, behavior => behavior is PickupData));
Assert.Empty(boss.CargoContents.SelectMany(bay => bay));
Assert.Empty(boss.DockingBayContents.SelectMany(bay => bay));
From d2ec3a6678f9c549f956bfdb6c80db624ff5bdb0 Mon Sep 17 00:00:00 2001
From: Meta Vens
Date: Sun, 18 Oct 2026 21:18:49 +0200
Subject: [PATCH 027/916] RunGoalTests: using GameCult.Caching
Co-Authored-By: Claude Sonnet 5.5
---
tests/Aetheria.Shared.Tests/RunGoalTests.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/tests/Aetheria.Shared.Tests/RunGoalTests.cs b/tests/Aetheria.Shared.Tests/RunGoalTests.cs
index 9db173508..8c283213f 100644
--- a/tests/Aetheria.Shared.Tests/RunGoalTests.cs
+++ b/tests/Aetheria.Shared.Tests/RunGoalTests.cs
@@ -8,6 +8,7 @@ using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using CultMath;
+using GameCult.Caching;
using UniRx;
using Xunit;
From 3ad3fcc505288f926dbc7ce63c39eddb33d9df6e Mon Sep 17 00:00:00 2001
From: Meta Vens
Date: Sun, 18 Oct 2026 21:19:14 +0200
Subject: [PATCH 028/916] RunGoalTests: using GameCult.Caching.MessagePack
Co-Authored-By: Claude Sonnet 5.5
---
tests/Aetheria.Shared.Tests/RunGoalTests.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/tests/Aetheria.Shared.Tests/RunGoalTests.cs b/tests/Aetheria.Shared.Tests/RunGoalTests.cs
index 8c283213f..ef714a5e4 100644
--- a/tests/Aetheria.Shared.Tests/RunGoalTests.cs
+++ b/tests/Aetheria.Shared.Tests/RunGoalTests.cs
@@ -9,6 +9,7 @@ using System.Linq;
using System.Text.RegularExpressions;
using CultMath;
using GameCult.Caching;
+using GameCult.Caching.MessagePack;
using UniRx;
using Xunit;
From f235eea3d98ad2b0bd886aed97c1885fa1954fe3 Mon Sep 17 00:00:00 2001
From: Meta Vens
Date: Sun, 18 Oct 2026 21:22:05 +0200
Subject: [PATCH 029/916] Exit_open_only_in_the_exit_zone: the faction with the
boss Loadout is one that can get its hull's brand
Co-Authored-By: Claude Sonnet 5.5
---
tests/Aetheria.Shared.Tests/RunGoalTests.cs | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/tests/Aetheria.Shared.Tests/RunGoalTests.cs b/tests/Aetheria.Shared.Tests/RunGoalTests.cs
index ef714a5e4..804576a46 100644
--- a/tests/Aetheria.Shared.Tests/RunGoalTests.cs
+++ b/tests/Aetheria.Shared.Tests/RunGoalTests.cs
@@ -432,9 +432,12 @@ public sealed partial class RunStartTests
{
var galaxy = RunStart.Generate(new MainGalaxy(), Inputs(() => 1));
// The shipped catalog sets no boss Loadout, so the main galaxy places no boss: give a faction one and a boss zone that is
- // not the exit, as the generator would for a faction with a boss Loadout.
- var faction = galaxy.Factions.First();
- SetBoss(faction, MakeBossLoadout(SoldShipHulls().First(), "Gate Boss"));
+ // not the exit, as the generator would for a faction with a boss Loadout. The Loadout leaves its hull's brand to the
+ // context, so the faction is one that can get a product of the hull: its own maker.
+ var hull = SoldShipHulls().OrderBy(h => h.Name, StringComparer.Ordinal).First();
+ var maker = _cache.Get(_cache.GetAll().First(product => _cache.Get(product.Design) == hull).Manufacturer);
+ var faction = galaxy.Factions.Single(candidate => candidate.Name == maker.Name);
+ SetBoss(faction, MakeBossLoadout(hull, "Gate Boss"));
var bossZone = galaxy.Zones.First(zone => zone != galaxy.Exit);
galaxy.BossZones[faction] = bossZone;
var zone = ZoneOf(galaxy, bossZone);
From d8afb9d18478847d150c567ea2481beabfa59bdf Mon Sep 17 00:00:00 2001
From: Meta Vens
Date: Sun, 18 Oct 2026 21:24:46 +0200
Subject: [PATCH 030/916] Exit_open_only_in_the_exit_zone: a failed boss build
reports the log
Co-Authored-By: Claude Sonnet 5.5
---
tests/Aetheria.Shared.Tests/RunGoalTests.cs | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/tests/Aetheria.Shared.Tests/RunGoalTests.cs b/tests/Aetheria.Shared.Tests/RunGoalTests.cs
index 804576a46..d4e865d9e 100644
--- a/tests/Aetheria.Shared.Tests/RunGoalTests.cs
+++ b/tests/Aetheria.Shared.Tests/RunGoalTests.cs
@@ -440,8 +440,10 @@ public sealed partial class RunStartTests
SetBoss(faction, MakeBossLoadout(hull, "Gate Boss"));
var bossZone = galaxy.Zones.First(zone => zone != galaxy.Exit);
galaxy.BossZones[faction] = bossZone;
- var zone = ZoneOf(galaxy, bossZone);
- Assert.True(zone.Pack.BossSpawned);
+ var log = new List();
+ var items = LoggingItems(log);
+ var zone = new Zone(items, _planetSettings, BossZonePack(galaxy, items, bossZone), bossZone, galaxy);
+ Assert.True(zone.Pack.BossSpawned, string.Join("; ", log));
Assert.NotEmpty(zone.Entities.Where(entity => entity.IsBoss));
foreach (var boss in zone.Entities.Where(entity => entity.IsBoss).ToArray())
boss.HeatstrokeDeath.OnNext(Unit.Default);
From 40db8291d874536152584fc1d0409f0787ec8dbc Mon Sep 17 00:00:00 2001
From: Meta Vens
Date: Sun, 18 Oct 2026 21:25:21 +0200
Subject: [PATCH 031/916] Exit_open_only_in_the_exit_zone: the gate boss pins
its hull's brand, so any faction builds it
Co-Authored-By: Claude Sonnet 5.5
---
tests/Aetheria.Shared.Tests/RunGoalTests.cs | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/tests/Aetheria.Shared.Tests/RunGoalTests.cs b/tests/Aetheria.Shared.Tests/RunGoalTests.cs
index d4e865d9e..34eb50c69 100644
--- a/tests/Aetheria.Shared.Tests/RunGoalTests.cs
+++ b/tests/Aetheria.Shared.Tests/RunGoalTests.cs
@@ -432,12 +432,14 @@ public sealed partial class RunStartTests
{
var galaxy = RunStart.Generate(new MainGalaxy(), Inputs(() => 1));
// The shipped catalog sets no boss Loadout, so the main galaxy places no boss: give a faction one and a boss zone that is
- // not the exit, as the generator would for a faction with a boss Loadout. The Loadout leaves its hull's brand to the
- // context, so the faction is one that can get a product of the hull: its own maker.
+ // not the exit, as the generator would for a faction with a boss Loadout. This Loadout pins its hull's brand, so any faction
+ // builds it whatever it can get.
+ var faction = galaxy.Factions.First();
var hull = SoldShipHulls().OrderBy(h => h.Name, StringComparer.Ordinal).First();
- var maker = _cache.Get(_cache.GetAll().First(product => _cache.Get(product.Design) == hull).Manufacturer);
- var faction = galaxy.Factions.Single(candidate => candidate.Name == maker.Name);
- SetBoss(faction, MakeBossLoadout(hull, "Gate Boss"));
+ var gate = MakeBossLoadout(hull, "Gate Boss");
+ gate.HullProduct = _cache.RefOf(_cache.GetAll().OrderBy(product => product.Name, StringComparer.Ordinal).First(product => _cache.Get(product.Design) == hull));
+ StoreLoadout(gate);
+ SetBoss(faction, gate);
var bossZone = galaxy.Zones.First(zone => zone != galaxy.Exit);
galaxy.BossZones[faction] = bossZone;
var log = new List();
From f17b04ec1a9b8b2689972f29ce225278b9879eb8 Mon Sep 17 00:00:00 2001
From: soul
Date: Sun, 18 Oct 2026 21:31:57 +0200
Subject: [PATCH 032/916] FlightTests: Faction's wire array ends at slot 22
(BossLoadout), so it is 23 long
Co-Authored-By: Claude Sonnet 5.5
---
tests/Aetheria.Shared.Tests/FlightTests.cs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tests/Aetheria.Shared.Tests/FlightTests.cs b/tests/Aetheria.Shared.Tests/FlightTests.cs
index b9ee7c09e..dc3f4da10 100644
--- a/tests/Aetheria.Shared.Tests/FlightTests.cs
+++ b/tests/Aetheria.Shared.Tests/FlightTests.cs
@@ -910,7 +910,7 @@ public sealed class FlightTests : IDisposable
Assert.Equal(turns, turn != 0f);
}
- // Faction.Doctrine rides at wire slot 17; slot 16 is reserved for Relations; Places rides at 21, which sets the array's length.
+ // Faction.Doctrine rides at wire slot 17; slot 16 is reserved for Relations; BossLoadout rides at 22, which sets the array's length.
// Kills: the key moved.
[Fact]
public void TheFactionDoctrineRidesAtWireSlot17()
@@ -920,7 +920,7 @@ public sealed class FlightTests : IDisposable
var slots = MessagePack.MessagePackSerializer.Deserialize