CultCache: element ids on every object-list element (C2a)

[CultElementId] marks a string member; the registry refuses a document type
whose list element type (union bases included) lacks one, naming the type and
member. A write mints a random 12-hex id for each unset id and refuses a
duplicate within one list. A store written before ids loads with ids minted in
memory from SHA-256(record key, element path), so every reader and every reload
agrees; they persist on the store's first write. CultCache.MintElementIds()
rewrites the records whose ids exist only in memory.

CultLib's own list-element types gain an id (Geometry, Mesh body, discovery,
entity prefab). CultMeshCdnChunkRef and the CultWitness* elements are pinned by
cross-runtime vectors and are left alone; see the C2a report.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
x 2026-09-29 12:31:12 +02:00
commit 0d2645d056
7 changed files with 646 additions and 0 deletions

View file

@ -80,6 +80,10 @@ namespace GameCult.Mesh
[MessagePackObject]
public sealed class CultMeshEntityPrefabComponent
{
[Key(2)]
[CultElementId]
public string Id { get; set; } = string.Empty;
/// <summary>Portable component kind or runtime adapter type.</summary>
[Key(0)]
public string Type { get; set; } = string.Empty;
@ -95,6 +99,10 @@ namespace GameCult.Mesh
[MessagePackObject]
public sealed class CultMeshEntityPrefabAssetRef
{
[Key(6)]
[CultElementId]
public string Id { get; set; } = string.Empty;
/// <summary>Stable source asset id inside the prefab package.</summary>
[Key(0)]
public string AssetId { get; set; } = string.Empty;
@ -126,6 +134,10 @@ namespace GameCult.Mesh
[MessagePackObject]
public sealed class CultMeshEntityPrefabNode
{
[Key(10)]
[CultElementId]
public string Id { get; set; } = string.Empty;
/// <summary>Stable node id inside the package.</summary>
[Key(0)]
public string NodeId { get; set; } = string.Empty;