diff --git a/src/GameCult.Caching/CultSoa.cs b/src/GameCult.Caching/CultSoa.cs
new file mode 100644
index 00000000..5abd53bd
--- /dev/null
+++ b/src/GameCult.Caching/CultSoa.cs
@@ -0,0 +1,630 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Reflection;
+using System.Linq;
+using System.Runtime.InteropServices;
+using System.Text;
+using System.Threading.Tasks;
+
+[assembly: GameCult.Caching.CultGeneratedDocumentMetadataProvider(typeof(GameCult.Caching.CultSoaGeneratedDocumentMetadataProvider))]
+
+namespace GameCult.Caching
+{
+ ///
+ /// CultCache document that stores a CPU-local structure-of-arrays chunk.
+ ///
+ [CultDocument("gamecult.soa_chunk", "gamecult.soa_chunk.v1")]
+ public sealed class CultSoaChunkDocument
+ {
+ ///
+ /// Gets or sets the stable chunk identifier.
+ ///
+ [CultName]
+ public string ChunkId { get; set; } = string.Empty;
+
+ ///
+ /// Gets or sets the layout/archetype identifier shared by chunks with the same columns.
+ ///
+ [CultIndex("archetype")]
+ public string ArchetypeId { get; set; } = string.Empty;
+
+ ///
+ /// Gets or sets the number of live rows in this chunk.
+ ///
+ public int Count { get; set; }
+
+ ///
+ /// Gets or sets the live row entity ids. The array length is the chunk capacity.
+ ///
+ public ulong[] EntityIds { get; set; } = Array.Empty();
+
+ ///
+ /// Gets or sets the contiguous component columns owned by this chunk.
+ ///
+ public CultSoaColumnDocument[] Columns { get; set; } = Array.Empty();
+ }
+
+ ///
+ /// One contiguous column inside a structure-of-arrays chunk.
+ ///
+ public sealed class CultSoaColumnDocument
+ {
+ ///
+ /// Gets or sets the stable column name, usually a component field path.
+ ///
+ public string Name { get; set; } = string.Empty;
+
+ ///
+ /// Gets or sets the CLR element type name stored in the column.
+ ///
+ public string ElementType { get; set; } = string.Empty;
+
+ ///
+ /// Gets or sets the size of one element in bytes.
+ ///
+ public int ElementByteLength { get; set; }
+
+ ///
+ /// Gets or sets the contiguous column payload.
+ ///
+ public byte[] Data { get; set; } = Array.Empty();
+ }
+
+ ///
+ /// Runtime view over a CultCache SoA chunk document.
+ ///
+ public sealed class CultSoaChunk
+ {
+ private readonly Dictionary _columns;
+
+ private CultSoaChunk(CultSoaChunkDocument document)
+ {
+ Document = document ?? throw new ArgumentNullException(nameof(document));
+ ValidateDocument(document);
+ _columns = document.Columns.ToDictionary(column => column.Name, StringComparer.Ordinal);
+ }
+
+ ///
+ /// Gets the underlying CultCache document.
+ ///
+ public CultSoaChunkDocument Document { get; }
+
+ ///
+ /// Gets the stable chunk identifier.
+ ///
+ public string ChunkId => Document.ChunkId;
+
+ ///
+ /// Gets the layout/archetype identifier.
+ ///
+ public string ArchetypeId => Document.ArchetypeId;
+
+ ///
+ /// Gets the number of live rows.
+ ///
+ public int Count => Document.Count;
+
+ ///
+ /// Gets the maximum row count this chunk can hold without reallocating.
+ ///
+ public int Capacity => Document.EntityIds.Length;
+
+ ///
+ /// Gets all entity ids, including unused capacity.
+ ///
+ public Span EntityIds => Document.EntityIds.AsSpan();
+
+ ///
+ /// Gets live entity ids.
+ ///
+ public Span ActiveEntityIds => Document.EntityIds.AsSpan(0, Document.Count);
+
+ ///
+ /// Creates an empty SoA chunk with the supplied capacity.
+ ///
+ public static CultSoaChunk Create(string chunkId, string archetypeId, int capacity)
+ {
+ if (string.IsNullOrWhiteSpace(chunkId)) throw new ArgumentException("Value must be non-empty.", nameof(chunkId));
+ if (string.IsNullOrWhiteSpace(archetypeId)) throw new ArgumentException("Value must be non-empty.", nameof(archetypeId));
+ if (capacity < 0) throw new ArgumentOutOfRangeException(nameof(capacity));
+
+ return new CultSoaChunk(new CultSoaChunkDocument
+ {
+ ChunkId = chunkId,
+ ArchetypeId = archetypeId,
+ Count = 0,
+ EntityIds = new ulong[capacity],
+ Columns = Array.Empty()
+ });
+ }
+
+ ///
+ /// Wraps a persisted SoA chunk document.
+ ///
+ public static CultSoaChunk Wrap(CultSoaChunkDocument document)
+ {
+ return new CultSoaChunk(document);
+ }
+
+ ///
+ /// Sets the live row count after validating all columns have enough capacity.
+ ///
+ public void SetCount(int count)
+ {
+ if (count < 0 || count > Capacity)
+ {
+ throw new ArgumentOutOfRangeException(nameof(count));
+ }
+
+ Document.Count = count;
+ }
+
+ ///
+ /// Appends one entity row and returns its row index.
+ ///
+ public int AddEntity(ulong entityId)
+ {
+ if (Document.Count >= Capacity)
+ {
+ throw new InvalidOperationException($"SoA chunk '{ChunkId}' is full.");
+ }
+
+ var row = Document.Count;
+ Document.EntityIds[row] = entityId;
+ Document.Count++;
+ return row;
+ }
+
+ ///
+ /// Adds a contiguous typed column.
+ ///
+ public CultSoaColumn AddColumn(string name) where T : unmanaged
+ {
+ if (string.IsNullOrWhiteSpace(name)) throw new ArgumentException("Value must be non-empty.", nameof(name));
+ if (_columns.ContainsKey(name))
+ {
+ throw new InvalidOperationException($"SoA chunk '{ChunkId}' already has a '{name}' column.");
+ }
+
+ var column = new CultSoaColumnDocument
+ {
+ Name = name,
+ ElementType = CultSoaTypeName.For(),
+ ElementByteLength = Marshal.SizeOf(),
+ Data = new byte[checked(Capacity * Marshal.SizeOf())]
+ };
+
+ var columns = Document.Columns.ToList();
+ columns.Add(column);
+ Document.Columns = columns.ToArray();
+ _columns[name] = column;
+ return new CultSoaColumn(this, column);
+ }
+
+ ///
+ /// Gets an existing typed column.
+ ///
+ public CultSoaColumn Column(string name) where T : unmanaged
+ {
+ if (!_columns.TryGetValue(name, out var column))
+ {
+ throw new KeyNotFoundException($"SoA chunk '{ChunkId}' has no '{name}' column.");
+ }
+
+ var expectedType = CultSoaTypeName.For();
+ var expectedByteLength = Marshal.SizeOf();
+ if (!string.Equals(column.ElementType, expectedType, StringComparison.Ordinal) ||
+ column.ElementByteLength != expectedByteLength)
+ {
+ throw new InvalidOperationException(
+ $"SoA column '{name}' stores {column.ElementType}/{column.ElementByteLength} bytes, not {expectedType}/{expectedByteLength}.");
+ }
+
+ var expectedLength = checked(Capacity * expectedByteLength);
+ if (column.Data.Length != expectedLength)
+ {
+ throw new InvalidOperationException(
+ $"SoA column '{name}' has {column.Data.Length} bytes, expected {expectedLength} for chunk capacity {Capacity}.");
+ }
+
+ return new CultSoaColumn(this, column);
+ }
+
+ private static void ValidateDocument(CultSoaChunkDocument document)
+ {
+ if (string.IsNullOrWhiteSpace(document.ChunkId))
+ {
+ throw new ArgumentException("SoA chunk documents require a chunk id.", nameof(document));
+ }
+
+ if (string.IsNullOrWhiteSpace(document.ArchetypeId))
+ {
+ throw new ArgumentException("SoA chunk documents require an archetype id.", nameof(document));
+ }
+
+ document.EntityIds ??= Array.Empty();
+ document.Columns ??= Array.Empty();
+ if (document.Count < 0 || document.Count > document.EntityIds.Length)
+ {
+ throw new ArgumentOutOfRangeException(nameof(document), "SoA chunk count must fit inside entity id capacity.");
+ }
+
+ foreach (var column in document.Columns)
+ {
+ if (column == null) throw new ArgumentException("SoA chunk columns cannot contain null entries.", nameof(document));
+ if (string.IsNullOrWhiteSpace(column.Name)) throw new ArgumentException("SoA columns require names.", nameof(document));
+ if (string.IsNullOrWhiteSpace(column.ElementType)) throw new ArgumentException($"SoA column '{column.Name}' requires an element type.", nameof(document));
+ if (column.ElementByteLength <= 0) throw new ArgumentOutOfRangeException(nameof(document), $"SoA column '{column.Name}' requires a positive element byte length.");
+ column.Data ??= Array.Empty();
+ var expectedLength = checked(document.EntityIds.Length * column.ElementByteLength);
+ if (column.Data.Length != expectedLength)
+ {
+ throw new ArgumentException(
+ $"SoA column '{column.Name}' has {column.Data.Length} bytes, expected {expectedLength}.",
+ nameof(document));
+ }
+ }
+ }
+ }
+
+ ///
+ /// Typed contiguous view over one SoA column.
+ ///
+ public readonly struct CultSoaColumn where T : unmanaged
+ {
+ private readonly CultSoaChunk _owner;
+ private readonly CultSoaColumnDocument _column;
+
+ internal CultSoaColumn(CultSoaChunk owner, CultSoaColumnDocument column)
+ {
+ _owner = owner;
+ _column = column;
+ }
+
+ ///
+ /// Gets the column name.
+ ///
+ public string Name => _column.Name;
+
+ ///
+ /// Gets the full column capacity as a typed span.
+ ///
+ public Span Span => MemoryMarshal.Cast(_column.Data.AsSpan());
+
+ ///
+ /// Gets the live rows as a typed span.
+ ///
+ public Span ActiveSpan => Span.Slice(0, _owner.Count);
+ }
+
+ ///
+ /// Convenience extensions for storing SoA chunks in CultCache.
+ ///
+ public static class CultSoaCacheExtensions
+ {
+ ///
+ /// Adds or replaces a SoA chunk document in a CultCache.
+ ///
+ public static Task> UpsertSoaChunkAsync(
+ this CultCache cache,
+ CultSoaChunk chunk,
+ CultRecordHandle? handle = null)
+ {
+ if (cache == null) throw new ArgumentNullException(nameof(cache));
+ if (chunk == null) throw new ArgumentNullException(nameof(chunk));
+ return cache.UpsertAsync(chunk.Document, handle);
+ }
+
+ ///
+ /// Gets a SoA chunk view by record key.
+ ///
+ public static CultSoaChunk? GetSoaChunk(this CultCache cache, CultRecordKey key)
+ {
+ if (cache == null) throw new ArgumentNullException(nameof(cache));
+ var document = cache.Get(key);
+ return document == null ? null : CultSoaChunk.Wrap(document);
+ }
+
+ ///
+ /// Projects ordinary typed CultCache documents into contiguous unmanaged columns for hot CPU loops.
+ ///
+ public static CultSoaDocumentTable ProjectSoa(this CultCache cache) where TDocument : class
+ {
+ if (cache == null) throw new ArgumentNullException(nameof(cache));
+ return CultSoaDocumentTable.From(cache);
+ }
+ }
+
+ ///
+ /// Structure-of-arrays projection over ordinary CultCache documents.
+ ///
+ public sealed class CultSoaDocumentTable where TDocument : class
+ {
+ private readonly Dictionary _columns;
+
+ private CultSoaDocumentTable(
+ CultRecordKey[] keys,
+ TDocument[] documents,
+ Dictionary columns)
+ {
+ Keys = keys;
+ Documents = documents;
+ _columns = columns;
+ }
+
+ ///
+ /// Gets the projected record keys in row order.
+ ///
+ public IReadOnlyList Keys { get; }
+
+ ///
+ /// Gets the projected document references in row order.
+ ///
+ public IReadOnlyList Documents { get; }
+
+ ///
+ /// Gets the row count.
+ ///
+ public int Count => Documents.Count;
+
+ ///
+ /// Builds a contiguous projection from all documents of this type in the cache.
+ ///
+ public static CultSoaDocumentTable From(CultCache cache)
+ {
+ if (cache == null) throw new ArgumentNullException(nameof(cache));
+ var stored = cache.AllStoredDocuments
+ .Where(entry => entry.Document is TDocument)
+ .OrderBy(entry => entry.Key.Value, StringComparer.Ordinal)
+ .ToArray();
+ var keys = stored.Select(entry => entry.Key).ToArray();
+ var documents = stored.Select(entry => (TDocument)entry.Document).ToArray();
+ var columns = new Dictionary(StringComparer.Ordinal);
+
+ foreach (var member in CultSoaDocumentMember.Discover(typeof(TDocument)))
+ {
+ columns[member.Name] = member.Project(documents);
+ }
+
+ return new CultSoaDocumentTable(keys, documents, columns);
+ }
+
+ ///
+ /// Gets a contiguous projected column by field or property name.
+ ///
+ public CultSoaDocumentColumn Column(string name) where TValue : unmanaged
+ {
+ if (!_columns.TryGetValue(name, out var column))
+ {
+ throw new KeyNotFoundException($"SoA projection for {typeof(TDocument).Name} has no '{name}' column.");
+ }
+
+ if (column is not TValue[] values)
+ {
+ throw new InvalidOperationException(
+ $"SoA projection column '{name}' stores {column.GetType().GetElementType()?.FullName}, not {typeof(TValue).FullName}.");
+ }
+
+ return new CultSoaDocumentColumn(name, values);
+ }
+ }
+
+ ///
+ /// Contiguous projected column from ordinary CultCache documents.
+ ///
+ public readonly struct CultSoaDocumentColumn where TValue : unmanaged
+ {
+ internal CultSoaDocumentColumn(string name, TValue[] values)
+ {
+ Name = name;
+ Values = values;
+ }
+
+ ///
+ /// Gets the projected field or property name.
+ ///
+ public string Name { get; }
+
+ ///
+ /// Gets the backing array.
+ ///
+ public TValue[] Values { get; }
+
+ ///
+ /// Gets the column as a contiguous span.
+ ///
+ public Span Span => Values.AsSpan();
+ }
+
+ internal sealed class CultSoaDocumentMember
+ {
+ private CultSoaDocumentMember(string name, Type valueType, Func