From bbb25814a25323b1cfab1c11982ea6755f41f0ad Mon Sep 17 00:00:00 2001 From: soul Date: Thu, 26 Nov 2026 00:59:31 +0100 Subject: [PATCH] Fix Soul s1 findings: MunitionsFeed finds the renamed ores by key, hold bound at midpoint, ruling citation MunitionsFeed named Rock and New Metals by name and was refused after the rename; it now takes DemoOre's keys, with a dry-run test at head. The hold-value bound is the midpoint of the shipped reading and the least claimed mutant on each side. DemoOre cites regolith-demo-retune (in force) instead of the superseded gear-scale ruling. Co-Authored-By: Claude Sonnet 5.5 --- .../DemoOreSheetTests.cs | 23 ++++++++++++++++++- tools/AetherDb/Economy/DemoOre.cs | 10 ++++---- tools/AetherDb/Economy/MunitionsFeed.cs | 13 ++++++++--- 3 files changed, 38 insertions(+), 8 deletions(-) diff --git a/tests/Aetheria.Shared.Tests/DemoOreSheetTests.cs b/tests/Aetheria.Shared.Tests/DemoOreSheetTests.cs index a9b520151..0ca185844 100644 --- a/tests/Aetheria.Shared.Tests/DemoOreSheetTests.cs +++ b/tests/Aetheria.Shared.Tests/DemoOreSheetTests.cs @@ -54,7 +54,14 @@ public sealed class DemoOreSheetTests : IDisposable var now = Cell(yields.Select(y => ((double) y.weight, (double) y.data.Price, (double) y.data.MaxStack))); var oldPrice = new Dictionary { ["Regolith"] = (6, 200), ["Nickel-Iron"] = (3, 1000), ["Gold"] = (1, 5000) }; var before = Cell(yields.Select(y => (oldPrice[y.data.Name].weight, oldPrice[y.data.Name].price, (double) y.data.MaxStack))); - Assert.InRange(now, before * .9, before * 1.1); + // Bounds (deterministic-bound-margin, by analogy from RenderCheck): the midpoint between the shipped reading and the least claimed mutant on each + // side. Shipped 9005 against before 9200 (0.9788). Low side: the old 6/3/1 yields left at price 1 read 8006 (0.8702), so the edge is 8505.5 + // (0.9245); it also kills Gold 4500 (8505) but not Nickel-Iron 900 (8605) or 5/3/1 (8894). High side: 4/5/1 yields read 10004 (1.0874), + // so the edge is 9504.5 (1.033). Neither side reaches the 1.2 separation the ruling asks (1.125 low, 1.111 high): a hold value that is meant to + // be 'about' the old one cannot pin the sheet tighter than this. The exact yields are pinned by AsteroidYieldsThreeOresInKeyOrder, and the + // price of Regolith by the assertion above. + Assert.InRange(now, 8505.5, 9504.5); + Assert.Equal(9200, before); } [Fact] @@ -93,6 +100,20 @@ public sealed class DemoOreSheetTests : IDisposable } } + // MunitionsFeed names its outputs by name, except the two ores this sheet renames, which it finds by DemoOre's keys: a name lookup refused at head + // ("0 items are named 'Rock'"). A dry run at the shipped catalog succeeds and changes nothing. + [Fact] + public void MunitionsFeedDryRunSucceedsAtHeadAndChangesNothing() + { + var path = Path.Combine(_root, "Feed.cc"); + File.Copy(Path.Combine(RestoredHullsTests.FindRepoRoot(), "GameData", "Aetheria.cc"), path); + var before = File.ReadAllBytes(path); + var output = new StringWriter(); + Assert.Equal(0, EconomyCommand.Author(path, new List { new MunitionsFeed() }, false, output, TestCatalog.Registry(), _root)); + Assert.Equal(before, File.ReadAllBytes(path)); + Assert.DoesNotContain("are named", output.ToString()); + } + [Fact] public void TheSheetConverges() { diff --git a/tools/AetherDb/Economy/DemoOre.cs b/tools/AetherDb/Economy/DemoOre.cs index 14d49bca6..739b9782a 100644 --- a/tools/AetherDb/Economy/DemoOre.cs +++ b/tools/AetherDb/Economy/DemoOre.cs @@ -5,10 +5,12 @@ using GameCult.Caching; // Interim ore sheet (ruling mining-demo-ore-minimal-yields-now): the Asteroid field kind yields Regolith, Nickel-Iron and Gold, and those // three can be held (a 1x1 shape, a mass) and are sold (a price). The economy ores batch may rewrite the yields by element id. -// Prices are ruling mining-demo-ore-prices-gear-scale, gear-scale so the mine, sell, repair loop closes: a retune is an edit here and a rerun. +// Prices are ruling regolith-demo-retune (it superseded mining-demo-ore-prices-gear-scale), gear-scale so the mine, sell, repair loop closes: a retune +// is an edit here and a rerun. When the ores batch lands with the 100x gear rescale its prices take over (aetheria-living-world ruling +// ore-batch-keeps-prices-gear-rescaled) and this sheet retires. // Ruling regolith-demo-retune (rock-becomes-regolith): Rock becomes Regolith at price 1 and New Metals becomes Nickel-Iron; yield shifts toward // Nickel-Iron so a full hold sells for about what it did (expected 900.5 a unit against 920). The names and descriptions are the ores batch's. -// Munitions and MunitionsFeed never rewrite these three commodities, so rerunning them does not clobber this sheet. +// Munitions and MunitionsFeed never rewrite these three commodities (MunitionsFeed finds the two renamed ores by the keys above), so rerunning them does not clobber this sheet. public sealed class DemoOre : EconomyBatch { private const int RegolithPrice = 1; @@ -16,8 +18,8 @@ public sealed class DemoOre : EconomyBatch private const int GoldPrice = 5000; // The two renamed records are found by key, so a rerun converges after the rename (the ores batch finds them the same way). - private static readonly CultRecordKey RegolithKey = new CultRecordKey("043997a8-0661-4206-ab8a-10215ecf4efc"); - private static readonly CultRecordKey NickelIronKey = new CultRecordKey("00b5b3b2-2fc5-4adb-a1d7-c1a35d19afd3"); + public static readonly CultRecordKey RegolithKey = new CultRecordKey("043997a8-0661-4206-ab8a-10215ecf4efc"); + public static readonly CultRecordKey NickelIronKey = new CultRecordKey("00b5b3b2-2fc5-4adb-a1d7-c1a35d19afd3"); // Authored element ids (the cache takes a hand-written id only as 12 lowercase hex): asteroid regolith, nickel-iron, gold. The ids keep // their first names; the ores batch rewrites yields by element id. diff --git a/tools/AetherDb/Economy/MunitionsFeed.cs b/tools/AetherDb/Economy/MunitionsFeed.cs index eab9c16cc..182bae4bf 100644 --- a/tools/AetherDb/Economy/MunitionsFeed.cs +++ b/tools/AetherDb/Economy/MunitionsFeed.cs @@ -17,9 +17,9 @@ public sealed class MunitionsFeed : EconomyBatch _a = author; // Extraction: no inputs, so these are the chain's raw goods. - var rock = Make("Rock", "mining", 300, 10, 8, + var rock = Make(DemoOre.RegolithKey, "mining", 300, 10, 8, "Nobody on a mining station calls it rock; it is the overburden, the slag, the thing the real cargo was buried in. It is also what every smelter, board shop and cement yard starts from, so the cheapest hold in the verse is the one that decides who can build."); - var metals = Make("New Metals", "mining", 300, 12, 6, + var metals = Make(DemoOre.NickelIronKey, "mining", 300, 12, 6, "The ore that built the cities: whoever holds the claim feeds every foundry downstream, which is why mining rights are the one commodity the garrisons will not leave unguarded."); var gold = Make("Gold", "mining", 600, 8, 2, "Gold has a use besides vanity: it does not corrode in a contact. Boards bound for a hull in a cold or wet corridor are gold-plated, and a prospector who finds a seam sells it to the board shops before the jewellers."); @@ -61,12 +61,19 @@ public sealed class MunitionsFeed : EconomyBatch (steel, 2), (board, 1)); } + // The two ores DemoOre renames are named by its keys, so a rerun converges after the rename; every other output by its unique name. private CultRecordRef Make(string name, string kind, float cycle, int workforce, int count, string lore, params (CultRecordRef Commodity, int Count)[] inputs) { var named = _a.Catalog.GetAll().Where(i => i.Name == name).ToArray(); if (named.Length != 1) throw new InvalidOperationException($"{named.Length} items are named '{name}'; the munitions feed needs exactly one."); - var output = new CultRecordRef(_a.Catalog.RefOf(named[0]).Key); + return Make(_a.Catalog.RefOf(named[0]).Key, kind, cycle, workforce, count, lore, inputs); + } + + private CultRecordRef Make(CultRecordKey outputKey, string kind, float cycle, int workforce, int count, string lore, + params (CultRecordRef Commodity, int Count)[] inputs) + { + var output = new CultRecordRef(outputKey); _a.Put(new RecipeData { Output = output,