F7: route AetherDb's identity-preserving repairs through the same validation
CultRecordRefs.Upsert is the one function every catalog write is supposed to go through, but tools/AetherDb/Program.cs's Dangling, ShieldMigrate and BrownoutMigrate commands each repair an existing record in place and must preserve its key -- Upsert's own cache.UpsertAsync(document) cannot take a caller-supplied key, so all three wrote raw and unvalidated through `db.Cache.Commit(batch => batch.Upsert(document.GetType(), document, key))`. `brownout-migrate apply` is how the shipped catalog's PowerSupply terms were actually authored, unvalidated, the whole time. Extracted Upsert's validation body into CultRecordRefs.Validate(object), and call it directly from all three tool commands immediately before their own identity-preserving commit -- the same rules, invoked where Upsert itself cannot reach. The comment above StatValidation naming the write-bypass holes (landed with F6) now names all four instead of two: CultCache Studio's generic editor (still open -- not this repository's to patch) plus the three tool commands above (closed). Pinned in tests/Aetheria.Shared.Tests/AetheriaStoresTests.cs: ValidateRefusesAnEquippableItemWithAZeroSpanHeatRangeTheSameWayUpsertWould and ValidateRefusesAPowerRequestCarryingAPowerSupplyTermTheSameWayUpsertWould pin that the extracted method actually refuses what Upsert would (fail under a reverted Validate that is a no-op); ValidateIsANoOpForADocumentTypeItDoesNotGovern pins that a document type it has no opinion about doesn't crash it. Verified tools/AetherDb/AetherDb.csproj still builds clean against the pinned CultLib worktree. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
02e2ca9556
commit
e3e228e036
3 changed files with 84 additions and 6 deletions
|
|
@ -270,6 +270,11 @@ public static class Program
|
|||
return 0;
|
||||
}
|
||||
|
||||
// F7 (docs/stats-and-power-cut.md, Soul pass 2026-09-19): this repair must preserve the record's existing
|
||||
// key, which the validating CultRecordRefs.Upsert extension does not support (see AetheriaStores.cs's own
|
||||
// Validate comment) -- so it calls the same validation directly, right before the identity-preserving
|
||||
// write, instead of writing raw and unvalidated the way this line used to.
|
||||
foreach (var (document, _) in changed) CultRecordRefs.Validate(document);
|
||||
db.Cache.Commit(batch =>
|
||||
{
|
||||
foreach (var (document, key) in changed) batch.Upsert(document.GetType(), document, key);
|
||||
|
|
@ -552,6 +557,11 @@ public static class Program
|
|||
return 0;
|
||||
}
|
||||
|
||||
// F7 (docs/stats-and-power-cut.md, Soul pass 2026-09-19): this repair must preserve the record's existing
|
||||
// key, which the validating CultRecordRefs.Upsert extension does not support (see AetheriaStores.cs's own
|
||||
// Validate comment) -- so it calls the same validation directly, right before the identity-preserving
|
||||
// write, instead of writing raw and unvalidated the way this line used to.
|
||||
foreach (var (document, _) in changed) CultRecordRefs.Validate(document);
|
||||
db.Cache.Commit(batch =>
|
||||
{
|
||||
foreach (var (document, key) in changed) batch.Upsert(document.GetType(), document, key);
|
||||
|
|
@ -643,6 +653,11 @@ public static class Program
|
|||
return 0;
|
||||
}
|
||||
|
||||
// F7 (docs/stats-and-power-cut.md, Soul pass 2026-09-19): this repair must preserve the record's existing
|
||||
// key, which the validating CultRecordRefs.Upsert extension does not support (see AetheriaStores.cs's own
|
||||
// Validate comment) -- so it calls the same validation directly, right before the identity-preserving
|
||||
// write, instead of writing raw and unvalidated the way this line used to.
|
||||
foreach (var (document, _) in changed) CultRecordRefs.Validate(document);
|
||||
db.Cache.Commit(batch =>
|
||||
{
|
||||
foreach (var (document, key) in changed) batch.Upsert(document.GetType(), document, key);
|
||||
|
|
|
|||
Loading…
Reference in a new issue