Cut C: delete ItemData.Manufacturer, derive census makers from products

The manufacturer does not belong to a design (operator ruling); it lives on
FactionProductData and branding is derived, never stored on the design.

- Delete ItemData.cs key 3 (Manufacturer), with a retired-key comment.
- AetherDb census now attributes a design's maker to the first product (in
  record-key order) that sells it, matching ItemManager.Brand's rule; a
  design no product sells shows "(none)".
- AetheriaStoresTests' catalog fixture moves its Manufacturer reference onto
  a FactionProductData selling the design, and FactionIsASingletonInstance
  reads it from there.
- mutation_tests.py gets a paired mutation for that fixture wiring.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-09-17 12:03:15 +02:00
commit 333a73709a
4 changed files with 35 additions and 8 deletions

View file

@ -276,9 +276,9 @@ public abstract class ItemData
[Inspectable, CultInspectorTextArea, JsonProperty("description"), Key(2)]
public string Description;
[Inspectable, JsonProperty("creator"), Key(3)]
public CultRecordRef<Faction> Manufacturer;
// MessagePack key 3 belonged to a removed creator/faction reference field; do not reuse it. That provenance
// now lives on FactionProductData, and branding is derived, never stored on the design.
[Inspectable, JsonProperty("mass"), Key(4)]
public float Mass;

View file

@ -29,7 +29,8 @@ public sealed class AetheriaStoresTests : IDisposable
var faction = new Faction { Name = "Adrasteia", ShortName = "ADR", PrimaryColor = new float3(1, .5f, .25f) };
faction.Allegiance[cache.Upsert(faction)] = 1;
cache.Upsert(faction);
cache.Upsert(new WeaponItemData { Name = "Lance", Manufacturer = cache.RefOf(faction) });
var lance = cache.Upsert(new WeaponItemData { Name = "Lance" });
cache.Upsert(new FactionProductData { Name = "Lance", Design = new CultRecordRef<CraftedItemData>(lance.Key), Manufacturer = cache.RefOf(faction) });
cache.Upsert(new InputLayout { Rows = new InputLayoutRow[] { new InputLayoutRowSpacer { Height = 1 } } });
cache.FlushAsync().Wait();
}
@ -106,7 +107,7 @@ public sealed class AetheriaStoresTests : IDisposable
{
using var cache = AetheriaStores.Open(Catalog);
var faction = cache.GetAll<Faction>().Single();
Assert.Same(faction, cache.Get(cache.GetAll<WeaponItemData>().Single().Manufacturer));
Assert.Same(faction, cache.Get(cache.GetAll<FactionProductData>().Single().Manufacturer));
Assert.Same(faction, cache.Get(faction.Allegiance.Keys.Single()));
Assert.Same(faction, cache.GetByName<Faction>("Adrasteia"));
}

View file

@ -1,5 +1,5 @@
#!/usr/bin/env python3
"""Mutation tests for the Cut B provenance rules (docs/item-provenance-cut.md).
"""Mutation tests for the Cut B and Cut C provenance rules (docs/item-provenance-cut.md).
For each rule this applies its named mutation to an exact, unique anchor of
source text, runs the one test that should catch it, restores the file
@ -259,6 +259,22 @@ MUTATIONS: list[Mutation] = [
test="RunSaveTests.CommitTakesRootsFromEveryZone",
expect="red",
),
# --- Cut C: the manufacturer moves from the design to the product; the catalog fixture and its
# round-trip assertion (FactionIsASingletonInstance) must actually depend on that wiring. ---
Mutation(
rule="the catalog fixture's product carries the maker, not an unset reference",
file="tests/Aetheria.Shared.Tests/AetheriaStoresTests.cs",
anchor=(
'cache.Upsert(new FactionProductData { Name = "Lance", '
"Design = new CultRecordRef<CraftedItemData>(lance.Key), Manufacturer = cache.RefOf(faction) });"
),
mutated=(
'cache.Upsert(new FactionProductData { Name = "Lance", '
"Design = new CultRecordRef<CraftedItemData>(lance.Key), Manufacturer = default });"
),
test="AetheriaStoresTests.FactionIsASingletonInstance",
expect="red",
),
]

View file

@ -40,7 +40,17 @@ public static class Program
{
var db = AetherDb.Open();
var items = db.Cache.GetAll<EquippableItemData>().ToArray();
var products = db.Cache.GetAll<FactionProductData>().ToArray();
var products = db.Cache.GetAll<FactionProductData>()
.OrderBy(p => db.Cache.RefOf(p).Key.Value, StringComparer.Ordinal).ToArray();
// The manufacturer no longer lives on the design: it is derived the way Brand() derives it, from the
// first product in record-key order that sells the design. A design no product sells shows "(none)".
string MakerOf(EquippableItemData item)
{
var design = db.Cache.RefOf(item).Key;
var product = products.FirstOrDefault(p => p.Design.Key.Equals(design));
return product == null ? "(none)" : db.Cache.Get(product.Manufacturer)?.ShortName ?? "(none)";
}
var kinds = new Dictionary<string, List<string>>();
foreach (var item in items)
@ -51,7 +61,7 @@ public static class Program
: item is WeaponItemData weapon ? $"Weapon/{weapon.HardpointType}"
: item.HardpointType.ToString();
if (!kinds.TryGetValue(kind, out var makers)) kinds[kind] = makers = new List<string>();
makers.Add(db.Cache.Get(item.Manufacturer)?.ShortName ?? "(none)");
makers.Add(MakerOf(item));
}
Console.WriteLine($"{items.Length} designs, {products.Length} products\n");