feat(grpc-data): A2a — AlarmSubscribe joins DataOperationSets.Understood; A2 progress log

This commit is contained in:
Joseph Doherty
2026-11-24 11:59:20 -05:00
parent 68a9d5184b
commit a74a1aeef9
4 changed files with 35 additions and 14 deletions
+19
View File
@@ -0,0 +1,19 @@
# A2a (condition streaming) — progress log and evidence
Stage A2a of phase A2 in `docs/plans/2026-11-23-grpc-data-connections-history-alarms-plan.md` (revision 7): condition items on
Subscribe, root-scoped `condition_scope`, origin streaming from the A1 `ConditionStateHub`, the `AlarmSubscribe` bit end to end,
the `AddDataConnectionConditions` migration. Condition METHODS are stage A2b (a later agent, same worktree `a2-wire`).
## Progress log (resume from here)
- **Done:** `DataOperationSets.Understood` += `AlarmSubscribe` (X0 tolerance tests updated).
- **In progress:** contracts/proto/mapper; configuration slice (helper agent).
- **Next:** origin streaming in the session; host negotiation; tests; v1 gates; live smoke.
## Decisions
## Deviations
## Seams for A2b
## Questions (tracked, not asked)
@@ -237,7 +237,7 @@ public sealed record DataBudget(TimeSpan Timeout, int MaxItems, long MaxBytes)
None = 0, Browse = 1, Metadata = 2, Read = 4, Write = 8, Subscribe = 16,
/// <summary>H2: Raw/Processed/AtTime history reads.</summary>
HistoryRead = 32,
/// <summary>Reserved (A2): root-scoped condition items (origin-side grant).</summary>
/// <summary>A2: root-scoped condition items (origin-side grant; plan §5.5).</summary>
AlarmSubscribe = 64,
/// <summary>Reserved (A2): Acknowledge and AddComment.</summary>
AlarmAcknowledge = 128,
@@ -254,11 +254,13 @@ public static class DataOperationSets
DataOperations.Write | DataOperations.Subscribe;
/// <summary>
/// What tolerant readers keep; every other bit is dropped fail-closed. Grows only in the phase that implements
/// a bit (H2 added <see cref="DataOperations.HistoryRead"/>; A2 adds the alarm bits).
/// a bit (H2 added <see cref="DataOperations.HistoryRead"/>; A2a <see cref="DataOperations.AlarmSubscribe"/>; A2b
/// the method bits).
/// </summary>
public const DataOperations Understood = V1 | DataOperations.HistoryRead;
/// <summary>Bits reserved by X0 that no phase has implemented yet (H2 took <see cref="DataOperations.HistoryRead"/> out).</summary>
public const DataOperations Reserved = DataOperations.AlarmSubscribe |
public const DataOperations Understood = V1 | DataOperations.HistoryRead | DataOperations.AlarmSubscribe;
/// <summary>Bits reserved by X0 that no phase has implemented yet (H2 took <see cref="DataOperations.HistoryRead"/> out,
/// A2a <see cref="DataOperations.AlarmSubscribe"/>).</summary>
public const DataOperations Reserved =
DataOperations.AlarmAcknowledge | DataOperations.AlarmConfirm | DataOperations.AlarmShelve;
}
/// <summary>
@@ -75,7 +75,7 @@ public sealed class GrpcDataTolerantDecodeTests
var wire = DataProtoMapper.EncodeMetadata(new DataMetadata(View, "x", "Variable", DataValueKind.Int32, -1, [], true,
DataOperations.Read | DataOperations.Subscribe, 1, null, null, false));
// 32 (HistoryRead) is understood since H2; the still-reserved and unknown bits are dropped.
wire.AllowedOperations |= 64u | 128u | 256u | 512u | (1u << 20) | 0x8000_0000u;
wire.AllowedOperations |= 128u | 256u | 512u | (1u << 20) | 0x8000_0000u;
var decoded = DataProtoMapper.DecodeMetadata(wire);
decoded.AllowedOperations.ShouldBe(DataOperations.Read | DataOperations.Subscribe);
}
@@ -96,7 +96,7 @@ public sealed class GrpcDataTolerantDecodeTests
{
var response = DataProtoMapper.EncodeMetadataResponse([new("0", DataItemStatus.Good, new DataMetadata(View, "x", "Variable",
DataValueKind.Int32, -1, [], false, DataOperations.Read, 1, null, null, false), null)]);
response.Items[0].Value.AllowedOperations |= 64u;
response.Items[0].Value.AllowedOperations |= 128u; // still reserved after A2a (64 = AlarmSubscribe is understood)
var decoded = DataProtoMapper.DecodeMetadataResponse(response, new(16, 65536, 1000));
decoded.ShouldHaveSingleItem().Value!.AllowedOperations.ShouldBe(DataOperations.Read);
W.Metadata.Descriptor.FindFieldByName("allowed_operations").FieldNumber.ShouldBe(8);
@@ -35,21 +35,21 @@ public sealed class GrpcDataOperationToleranceTests
}
[Fact]
public void H2_understands_v1_plus_HistoryRead_and_still_reserves_the_four_alarm_bits()
public void A2a_understands_v1_plus_HistoryRead_and_AlarmSubscribe_and_still_reserves_the_three_method_bits()
{
DataOperationSets.V1.ShouldBe(DataOperations.Browse | DataOperations.Metadata | DataOperations.Read | DataOperations.Write | DataOperations.Subscribe);
// X0 understood V1 only; H2 grew it by HistoryRead (with the validator and Implemented(target)), A2 grows the rest.
DataOperationSets.Understood.ShouldBe(DataOperationSets.V1 | DataOperations.HistoryRead);
DataOperationSets.Reserved.ShouldBe(DataOperations.AlarmSubscribe | DataOperations.AlarmAcknowledge
| DataOperations.AlarmConfirm | DataOperations.AlarmShelve);
// X0 understood V1 only; H2 grew it by HistoryRead, A2a by AlarmSubscribe (each with the validator and
// Implemented(target)); A2b grows the method bits.
DataOperationSets.Understood.ShouldBe(DataOperationSets.V1 | DataOperations.HistoryRead | DataOperations.AlarmSubscribe);
DataOperationSets.Reserved.ShouldBe(DataOperations.AlarmAcknowledge | DataOperations.AlarmConfirm | DataOperations.AlarmShelve);
(DataOperationSets.Reserved & DataOperationSets.Understood).ShouldBe(DataOperations.None);
((int)DataOperationSets.Reserved).ShouldBe(0x3C0);
((int)DataOperationSets.Reserved).ShouldBe(0x380);
}
[Fact]
public void Capabilities_mask_unknown_bits_on_construction_instead_of_throwing()
{
var unknown = DataOperations.Read | DataOperations.AlarmShelve | DataOperations.AlarmSubscribe | (DataOperations)(1 << 20);
var unknown = DataOperations.Read | DataOperations.AlarmShelve | DataOperations.AlarmConfirm | (DataOperations)(1 << 20);
var capabilities = Create(unknown);
capabilities.Operations.ShouldBe(DataOperations.Read);
Should.NotThrow(capabilities.Validate);