F5: name AetherDb's Dangling-apply validation gap; F6: note Quality's gap

F5: ItemData.cs's comment claimed every tool, test and migration writes
through CultRecordRefs.Upsert. tools/AetherDb/Program.cs's Dangling command
does not -- it commits repaired records through CultCache's own batch API,
keyed explicitly to preserve identity, bypassing the validating extension.
That path can land an EquippableItemData or ConsumableItemData with an
invalid heat response or an unresolvable stat modifier reference, refused
only the next time someone reopens the file. Named as a second exception
alongside Studio's already-documented one, since routing the fix through the
generic Upsert<T> extension would need a way to change an existing record's
key-preserving write path that this pass did not have visibility into --
correcting the comment is the honest option available now.

F6: nothing invalidates StatSource.Quality (no InvalidateSource call for it
anywhere). Harmless today because EquippedItem.Lot is set once in the
constructor and never reassigned. Sec 0b designs an upgrade as a lot swap the
resolver must see; recorded at the read site so the cut that adds the repoint
finds the obligation waiting for it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-09-18 20:42:21 +02:00
commit 529a3b40c4

View file

@ -650,6 +650,14 @@ public class PerformanceStat
{
factor *= term.Source switch
{
// F6 (docs/stats-and-power-cut.md Cut 2 Soul pass): nothing ever calls Resolver.InvalidateSource
// for StatSource.Quality. Harmless today because EquippedItem.Lot is set once in the constructor
// and never reassigned, so the value this reads never actually moves under a live resolver entry.
// §0b designs an upgrade as a lot swap the resolver must see ("an upgrade mints a new lot and
// repoints the item, which the resolver sees as a quality-source change") -- that repoint does not
// exist yet. Whichever cut adds it must also call InvalidateSource(item, StatSource.Quality) at
// the point EquippedItem.Lot is reassigned, or every Quality-termed stat keeps the pre-upgrade
// value forever.
StatSource.Quality => pow(context.Lot.QualityForRole(term.Role), term.Exponent),
StatSource.Heat => context.HeatFactor(term.Exponent),
StatSource.Durability => context.DurabilityFactor(term.Exponent),
@ -664,11 +672,17 @@ public class PerformanceStat
// Cut 1's loud refusal: the heat-response shape (min, max, optimum, plateau width) must describe a coherent
// range. Runs at catalog load (AetheriaStores.Open) and at every catalog write that goes through
// CultRecordRefs.Upsert (AetheriaStores.cs) -- every tool, test and migration script in this repository writes
// through that one path, so an authoring error is refused before it reaches disk, not just the next time
// someone reopens the file. The one hole this does not close: CultCache Studio's generic document editor
// writes straight through CultCache, bypassing Upsert, and Studio exposes no per-document validation hook to
// attach to yet. That gap is named here rather than silently assumed closed.
// CultRecordRefs.Upsert (AetheriaStores.cs). That is not, in fact, every catalog write in this repository: two
// named holes exist, not one.
// - CultCache Studio's generic document editor writes straight through CultCache, bypassing Upsert, and Studio
// exposes no per-document validation hook to attach to yet.
// - tools/AetherDb/Program.cs's Dangling command (:271-274) lands its repaired records through
// `db.Cache.Commit(batch => batch.Upsert(document.GetType(), document, key))` -- CultCache's own batch API,
// keyed explicitly to preserve the record's existing identity, not the validating extension method above. A
// dangling-ref fixup can therefore land an EquippableItemData or ConsumableItemData with an invalid heat
// response or an unresolvable stat modifier reference, and `Open` would refuse it only the next time someone
// reopens the file, not at the moment `apply` writes it. Both gaps are named here rather than silently assumed
// closed.
public static class StatValidation
{
public static void ValidateHeatResponse(EquippableItemData data)