Deliver reactive subscriptions without replica writes

This commit is contained in:
Meta Vens 2026-07-19 08:07:48 +01:00
commit 42402ab64b
17 changed files with 186 additions and 36 deletions

View file

@ -2859,7 +2859,8 @@ namespace GameCult.Mesh
public static Task<IReadOnlyList<object>> SubscribeHotBodyAsync(
CultNetDatabaseSubscriptionClient subscriptions,
IEnumerable<CultMeshBodyTransportKind> supportedBodyTransports,
CultMeshHotBodySubscription subscription)
CultMeshHotBodySubscription subscription,
CultNetDatabaseSubscriptionDeliveryMode deliveryMode = CultNetDatabaseSubscriptionDeliveryMode.ReplicateToCache)
{
if (subscriptions == null) throw new ArgumentNullException(nameof(subscriptions));
if (supportedBodyTransports == null) throw new ArgumentNullException(nameof(supportedBodyTransports));
@ -2873,17 +2874,19 @@ namespace GameCult.Mesh
schemaIds: subscription.SchemaIds,
consumerRuntimeId: subscription.ConsumerRuntimeId,
bodyIds: new[] { subscription.BodyId },
supportedBodyTransports: transports.Select(value => value.ToString()));
supportedBodyTransports: transports.Select(value => value.ToString()),
deliveryMode: deliveryMode);
}
/// <summary>Opens an exact hot-body subscription using a resolver's readable planes.</summary>
public static Task<IReadOnlyList<object>> SubscribeHotBodyAsync(
CultNetDatabaseSubscriptionClient subscriptions,
CultMeshBodyPublicationResolver bodyResolver,
CultMeshHotBodySubscription subscription)
CultMeshHotBodySubscription subscription,
CultNetDatabaseSubscriptionDeliveryMode deliveryMode = CultNetDatabaseSubscriptionDeliveryMode.ReplicateToCache)
{
if (bodyResolver == null) throw new ArgumentNullException(nameof(bodyResolver));
return SubscribeHotBodyAsync(subscriptions, bodyResolver.SupportedTransports, subscription);
return SubscribeHotBodyAsync(subscriptions, bodyResolver.SupportedTransports, subscription, deliveryMode);
}
/// <summary>Resolves a CultMesh URI or RUDP endpoint into a concrete RUDP endpoint.</summary>

View file

@ -926,6 +926,37 @@ can actually open, ordered shared-memory first; the server combines those
capabilities with observed peer locality. Applications do not hand-assemble
transport-name arrays or request one snapshot per frame.
### Reactive document delivery body map
**Owner:** the subscription declaration owns whether a selected typed document
is durable replica state or an ephemeral live value. The provider still owns
the value; the transport and renderer own neither its persistence nor meaning.
**Inputs:** exact record/schema filters and an explicit
`CultNetDatabaseSubscriptionDeliveryMode`. `ReplicateToCache` materializes
bootstrap and durable state before notification. `Live` validates and decodes
the same typed payload, then notifies the subscriber without a replica write.
**Outputs:** both modes produce the same typed initial values and change event.
Only durable replication mutates the consumer's CultCache.
**Derived state:** renderer-local presentation and reactive variables are
derived from live notifications. They are not database records merely because
CultNet carried them.
**Forbidden writers:** renderers and products cannot add polling, keepalive
writes, or broad snapshots to repair callback latency. Ephemeral receipts,
input facts, and frame-layout notifications cannot silently become disk-backed
replica history.
**Shared paths:** exact subscription filters, wire schema validation,
deserialization, unsubscribe, disconnect cleanup, and body-demand negotiation
are identical in both modes. Only the final materialization decision differs.
**Cut line:** `CultNetDatabaseSubscriptionClient` no longer requires every
received document to complete a CultCache write before the consumer may see it.
Durable documents retain the existing replica path; live values bypass it.
**Cut line:** local frame publication writes directly into a mapped write lease
and commits its descriptor. The compatibility byte-array publisher is copy-in
only. The current remote frame representation may still use the verified CDN