From 73ffa6f8d0ba2132f001d28f444409912bcd9209 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Thu, 22 Oct 2026 23:54:54 +0200 Subject: [PATCH] Caching: CultElementIds.Plan, Holds and IdPlan are public, the third internal CultMesh reached CultMeshSingleFileDocuments mints, checks and counts element ids through CultElementIds, which the deleted GameCult.Mesh InternalsVisibleTo also granted; without the grant Mesh does not build. A cacheless typed writer has to plan ids before it serializes, so the three members it needs are public and nothing else of the class is. Co-Authored-By: Claude Sonnet 5.5 --- src/GameCult.Caching/CultElementIds.cs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/GameCult.Caching/CultElementIds.cs b/src/GameCult.Caching/CultElementIds.cs index 89ff651b..7088be09 100644 --- a/src/GameCult.Caching/CultElementIds.cs +++ b/src/GameCult.Caching/CultElementIds.cs @@ -53,13 +53,12 @@ namespace GameCult.Caching // non-empty. Either need only be unique within one list. A write mints a random id; a load of a store written before ids // existed mints from SHA-256(record key, element path), so every reader of the same store mints the same id and a reload is // identical to what was read. A write and a load refuse the same things. - internal static class CultElementIds + public static class CultElementIds { private const int IdBytes = 6; - // The ids a pass would fill, decided before anything is written: nothing changes until Apply, and Undo restores what - // Apply replaced. - internal sealed class IdPlan + /// The element ids a pass would fill, decided before anything changes. sets them; gives back what Apply replaced. + public sealed class IdPlan { private readonly List<(object Item, Shape Shape, string? Before, string Id)> _fills = new(); @@ -303,7 +302,10 @@ namespace GameCult.Caching // True when some element under root holds a non-empty id: the one fact a store marks its header by. It reads the value // as it is now, refuses nothing and changes nothing, so a writer asks it of exactly what it is about to write. The walk // follows declared types, as registration does; a value's own type picks only a union arm. - internal static bool Holds(Type declared, object? root) + /// True when some element under holds a non-empty id: the one fact a single-file store marks its header by. Reads the value as it is, refuses nothing and changes nothing. + /// The declared type of the root; the walk follows declared types, as registration does. + /// The document about to be written. + public static bool Holds(Type declared, object? root) { if (root == null) return false; @@ -340,7 +342,12 @@ namespace GameCult.Caching // that is not 12 lowercase hex characters, a duplicate id in one list, a derived id whose source is null or empty. // rootPath (the record key) seeds deterministic minting and names the record in a refusal. An element object that sits // twice in one list is refused too: planning would give it two ids and it would then be a duplicate on load. - internal static IdPlan Plan(Type declared, object? root, string rootPath, bool deterministic) + /// Decides every unset element id under and refuses what a cache write refuses (a malformed or duplicate id, an unusable derived source), without changing anything until . A cacheless single-file writer plans before it serializes, so the ids are in the bytes. + /// The declared type of the root. + /// The document being written or loaded. + /// The record key: it seeds deterministic minting and names the record in a refusal. + /// True on a load, which mints from the key and path so every reader of one store mints the same ids; false on a write, which mints random ones. + public static IdPlan Plan(Type declared, object? root, string rootPath, bool deterministic) { var plan = new IdPlan(); Visit(declared, root, rootPath);