C#: receipt writes need a reliable, non-sequenced channel; a refusal without a record key or schema id carries a null detail value

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Libby 2026-11-08 17:01:59 +00:00
commit 40b34295e3
4 changed files with 58 additions and 3 deletions

View file

@ -3581,14 +3581,14 @@ namespace GameCult.Networking
}
/// <summary>
/// A put or delete that arrived on an unreliable channel of a receipt session (write-receipt.md, Reliable channel only):
/// A put or delete that arrived on an unreliable or sequenced channel of a receipt session (write-receipt.md, Reliable channel only):
/// answered <c>message_invalid</c>, details <c>channel</c>, fixed text, carrying the write's id, and not applied. True when
/// the frame was such a write and has been answered here.
/// </summary>
internal bool RefuseUnreliableWrite(ICultNetSchemaMessage message, DeliveryMethod method)
{
if (WriteReceipts == null) return false;
if (method is DeliveryMethod.ReliableOrdered or DeliveryMethod.ReliableUnordered or DeliveryMethod.ReliableSequenced) return false;
if (method is DeliveryMethod.ReliableOrdered or DeliveryMethod.ReliableUnordered) return false;
var messageId = message switch
{
CultNetDocumentPutRawMessage put => put.MessageId,

View file

@ -90,6 +90,8 @@ namespace GameCult.Networking
public static CultNetRememberedRefusal Of(CultNetErrorMessage error) =>
new(error.Code, error.Details != null, error.Details?.Field, error.RoutingHint);
private static string? NullIfEmpty(string value) => value.Length == 0 ? null : value;
/// <summary>The refusal, in fixed text, naming the write's own record key or schema id where its details do.</summary>
public CultNetErrorMessage ToError(string schemaId, string recordKey) => new()
{
@ -105,7 +107,7 @@ namespace GameCult.Networking
? new CultNetErrorDetails
{
Field = Field,
Value = Field switch { "recordKey" => recordKey, "schemaId" => schemaId, _ => null }
Value = Field switch { "recordKey" => NullIfEmpty(recordKey), "schemaId" => NullIfEmpty(schemaId), _ => null }
}
: null
};