Commit graph CultLib/src/GameCult.Mesh/CultMeshPrimitives.cs
Author SHA1 Message Date
Meta Vens
825b4f7d26 Mirror snapshots carry the cache Sequence they reflect
ObserveAsync, ReactiveAsync and RefreshAsync read a snapshot without a
Sequence, so an older change admitted before the read but delivered after it
overwrote the newer value.

CultCache.GetWithSequence(key) returns the document and the cache's Sequence,
read together under the gate. A cache-backed CultMesh handle passes it to its
mirrors; each mirror subscribes first, then adopts the sequenced read under its
own gate and takes that Sequence as applied, so a straggler at or below it
drops. RefreshAsync on both mirrors uses the same adoption path. Public Mesh
surface unchanged. The read is non-generic because the Mesh route needs the
untyped document for same-schema conversion.

Contract: only Watch/WatchRecord changes carry Sequence; OnUpdate-derived
CultNet streams have no ordering or stale protection; schema-alias handles and
removals are not stale-protected; the sequence constructor argument changed
CultCacheDocumentChange<T>'s binary signature.

Tests: ObserveAfterNewerSnapshotIgnoresStraggler and
RefreshIgnoresStragglerOlderThanSnapshot (observed and reactive cases) fail on
4562340; SequencedReadReflectsEveryChangeAtOrBelowItsSequence.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-13 21:02:49 +02:00
Meta Vens
456234018f Carry order as data: per-cache change Sequence, no delivery scheduler
bcae483 made the cache a delivery scheduler (tickets, _deliveryGate turn
waits, per-thread delivery queues). It deadlocked inside CultLib: a load's
delivery reaching a CultNetDatabaseSubscriptionServer observer that needs
_lifecycleGate, while a subscribe's demand handler holding that gate writes
the cache and waits for the delivery's turn.

The cache now owns order as data. Every admitted change takes the next value
of a per-cache in-memory sequence under the gate, published as
CultCacheDocumentChange<T>.Sequence. Delivery is the 544c087/b653f68 rule:
each call publishes its own changes on its own thread after releasing the
gate; nothing waits on another call's delivery. Cross-thread delivery order is
not guaranteed.

Deleted: ticket counter, _delivered, _deliveryGate, Monitor.Wait turns,
per-thread delivery queues, per-ticket catch-all, and the save-order contract
text with its observer-must-not-block rule.

Consumer: a cache-backed CultMesh document handle hands its observed and
reactive mirrors each snapshot's Sequence; ApplyCanonicalSnapshot drops one
not newer than the last applied.

Tests: SequenceIncreasesInAdmissionOrder,
ObserverWritingTheSameCacheDoesNotWaitOnOtherDeliveries,
SubscriptionDemandHandlerWritingCacheDuringDeliveryDoesNotDeadlock,
WatchRecordIgnoresStaleSequence. The last three time out on bcae483.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-13 20:43:11 +02:00
Meta Vens
4f6e95bb3d Carry editable field authority in CultMesh bindings 2026-08-22 00:05:57 +02:00
Meta Vens
fbf93f3570 Measure and bound reactive document cost 2026-08-18 02:37:13 +02:00
Meta Vens
ba680020b9 Prove reactive scheduling scales with edits 2026-08-18 00:44:41 +02:00
Meta Vens
98bec47d75 Make CultMesh document writes authority-explicit 2026-08-17 19:47:10 +02:00
Meta Vens
3e223ceecd Negotiate exact hot-body transport demand 2026-07-19 03:17:11 +01:00
Meta Vens
581c5d0249 Read legacy CultMesh route records 2026-07-13 16:53:22 +01:00
Meta Vens
36323c7154 Make CultMesh transport records serializable 2026-07-10 05:05:27 +01:00
Meta Vens
964a3ff1f8 Add schema-aware collection catalogs 2026-06-27 22:33:50 +01:00
Meta Vens
26159f9cfa Index C# document catalogs by schema id 2026-06-27 22:16:26 +01:00
Meta Vens
8a88ae547d Expand CultMesh reactive sync edge tests 2026-06-27 20:05:56 +01:00
Meta Vens
e3e07dfc58 Add CultMesh reactive reconciliation deltas 2026-06-27 19:56:08 +01:00
Meta Vens
8cdfdb656c Detect direct edits in CultMesh reactive documents 2026-06-27 19:50:30 +01:00
Meta Vens
ccd5a0e9cf Add managed CultMesh reactive documents 2026-06-27 19:19:09 +01:00
Meta Vens
1758a9c52f Add transparent CultMesh document mutation 2026-06-27 18:58:19 +01:00
Meta Vens
52ff632d70 Add CultMesh document catalog mutations 2026-06-27 16:28:42 +01:00
Meta Vens
a08a66a66e Add CultMesh document prediction submissions 2026-06-27 16:20:19 +01:00
Meta Vens
b6d4ebc920 Add synchronous CultMesh document reads 2026-06-27 16:03:10 +01:00
Meta Vens
8bb85d7c47 Add document surface diagnostics 2026-06-27 15:35:12 +01:00
Meta Vens
eb52b56088 Add CultMesh collection handles 2026-06-27 15:09:36 +01:00
Meta Vens
df079f2cab Add CultMesh document catalogs 2026-06-27 15:01:23 +01:00
Meta Vens
60a3fa9f82 Add cache-backed CultMesh document handles 2026-06-27 14:43:00 +01:00
Meta Vens
c911eb561d Add CultMesh typed document handles 2026-06-27 14:30:59 +01:00