feat(grpc-data): H2 consumer history client and deployed-connection history

GrpcDataConnection implements IDataHistoryService (explicitly; ReadHistoryAsync/ReleaseHistoryAsync avoid an overload
clash with ReadAsync): the capabilities probe always asks for history, other calls send it only when the selected
endpoint advertised it; per-call deadline min(remaining, HistoryTimeoutMilliseconds); FAILED_PRECONDITION/UNIMPLEMENTED
=> BadHistoryOperationUnsupported; chunks assembled within the request budget (BadTooManyOperations past it); page
tokens wrapped with the issuing endpoint + serving incarnation so a resumed read never moves; release forwarded. The
deployment lease gates history on the row's HistoryRead bit and carries HistoryTimeout. Decoded capabilities drop
HistoryRead without the history field. X0 tests that used bit 32 as the unknown bit now use a still-reserved bit.
This commit is contained in:
Joseph Doherty
2026-11-23 20:57:35 -05:00
parent d0756bb78e
commit b36c8d8716
10 changed files with 614 additions and 31 deletions
@@ -213,13 +213,14 @@ public sealed partial class GrpcDataConnection : IDataConnection
}
/// <summary>
/// The optional features to request from the SELECTED endpoint: only what that endpoint advertised, re-derived on
/// every selection so a failover follows the new endpoint. X0 reserves the negotiation; no capability field
/// advertises a feature yet, so this is always empty and the header is never sent.
/// every selection so a failover follows the new endpoint: this consumer's features ∩ what that endpoint's
/// capabilities advertised (H2: <c>history</c> iff <see cref="DataCapabilities.History"/> is present). The capabilities
/// PROBE itself always carries <see cref="ClientFeatures"/> (coordinator decision, plan §4.1).
/// </summary>
internal static DataFeatures RequestedFeatures(DataCapabilities capabilities)
{
ArgumentNullException.ThrowIfNull(capabilities);
return DataFeatures.None;
return capabilities.History is not null ? ClientFeatures & DataFeatures.History : DataFeatures.None;
}
private Metadata Headers(ChannelEntry channel, DataFeatures features = DataFeatures.None)
{
@@ -246,8 +247,9 @@ public sealed partial class GrpcDataConnection : IDataConnection
{
var channel = await ChannelAsync(endpoint, ct).ConfigureAwait(false);
using var linked = CancellationTokenSource.CreateLinkedTokenSource(ct, _scope.CancellationToken, channel.Retired.Token, _shutdown.Token);
// The probe asks for every feature this consumer understands; the endpoint answers with what it can serve.
var response = await channel.Client.GetCapabilitiesAsync(new W.CapabilitiesRequest { ProtocolMajor = 1, ProtocolMinor = 5 },
Options(channel, start, budget, linked.Token)).ResponseAsync.ConfigureAwait(false);
new CallOptions(Headers(channel, ClientFeatures), DateTime.UtcNow + Remaining(start, budget), linked.Token)).ResponseAsync.ConfigureAwait(false);
if (response.ValueKinds.Count > MaxCapabilityKinds || response.ValueKinds.Distinct().Count() != response.ValueKinds.Count)
throw new ArgumentException("Invalid capability value kinds.");
var caps = DataProtoMapper.DecodeCapabilities(response, new DataDecodeLimits(MaxCapabilityKinds, _maxMessageBytes));