From 5d91d886dfba01f59f239806e1d2efb6abc7a9b7 Mon Sep 17 00:00:00 2001 From: Joseph Doherty Date: Tue, 24 Nov 2026 15:21:57 -0500 Subject: [PATCH] =?UTF-8?q?docs(grpc-data):=20A2=20review=20round=201=20ev?= =?UTF-8?q?idence=20=E2=80=94=20findings,=20resolutions,=20red/green,=20A1?= =?UTF-8?q?=20root=20cause,=20gates?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/plans/evidence/grpc-data-ext/A2.md | 62 +++++++++++++++++++++++-- 1 file changed, 59 insertions(+), 3 deletions(-) diff --git a/docs/plans/evidence/grpc-data-ext/A2.md b/docs/plans/evidence/grpc-data-ext/A2.md index 618dbdd32..7ab49fc6e 100644 --- a/docs/plans/evidence/grpc-data-ext/A2.md +++ b/docs/plans/evidence/grpc-data-ext/A2.md @@ -1,5 +1,57 @@ # A2 — progress log and evidence +## Review round 1 (Fable, A2a range `68a9d518..81cee9b5e`, approve-with-changes) — progress log + +- Commits on `a2-wire` after `95d90c19`: `fbf9f7b8` (A1 F5 diagnostic defect), `69014cc4` (B1), `7694eb67` (N3), + `20bf9372` (S2/S3/S4/S5/N1/N2/N4/N5/N6 + S1 tests), `c709fbc1` (N5 test sharpened), `0b827a3f` (plan text), this evidence. +- Not merged, not pushed. + +| Finding | Resolution | Test / red-green | +|---|---|---| +| **B1** full queue ⇒ reset every tick | `budget = Max(0, …)`: a full condition queue produces nothing (the dequeue re-ticks the pump) | `A_backlog_above_the_pending_frame_limit_back_pressures_a_stalled_sink_instead_of_resetting` (25 chunks vs 16 frames, 20 stalled ticks): **red** before ("No condition frame" — the stream had reset), green after | +| **S1** deploy ⇒ delta records unreachable | Lifetime unchanged. Plan §5.5 states the rule (a deploy ends the stream; consumer re-snapshots; A3 relies on it); A2 test list and this file corrected. Fixture test renamed `A_listing_change_under_an_unchanged_serving_identity_arrives_as_delta_records`, fixture `Deploy` → `SwapListingWithoutAttempt` with a ⚠️ doc | `A_real_catalog_republish_ends_the_condition_stream`: a real `LocalCatalogCoordinator` over a deployment artifact (one alarm tag, AlarmSubscribe export); snapshot read, then `BeginAttempt`/`InstallAuthority`/`Stage`/`Complete` ⇒ no condition frame, stream ended. Documents existing behaviour (no code change, so no revert) | +| **S2** unbounded condition items | One item per (stream, root) ⇒ `InvalidArgument` "A condition item for this root is already open on this stream."; `SubscriptionSessionLimits.MaxConditionItems` (default 32) ⇒ `LimitExceeded`; each snapshot's estimated bytes charged against the principal's snapshot memory (`SubscriptionTransportCapacity.Snapshots`, same budget as v1 snapshots) from copy until its last chunk is delivered (refusal ⇒ nothing materialised on the stream, retried ≥ 1 s apart, counted as a capacity rejection) | `A_second_condition_item_on_the_same_root_is_refused_and_the_per_stream_cap_holds` (red with either check reverted), `A_snapshot_is_charged_against_the_principals_memory_budget` (red with the charge reverted; also proves release after delivery) | +| **S3** raw name to UNS peers | Runtime `ConditionItemStream.Map`: a native condition in a UNS listing takes `ConditionName` = the placement's browse name (effective name); a raw-derived message (the raw name NM seeds, the raw leaf, text containing the RawPath) becomes the effective name; a driver's own message passes. (NM unchanged: the raw name is still right for Raw listings and local clients.) | `A_uns_listing_with_a_display_name_override_carries_no_raw_leaf_name` (snapshot + delta, no `Alarm…` anywhere in the encoded record; driver text passes through): red with the mapping reverted. The fixture source now seeds `Message` with the raw name like NM does | +| **S4** limit frozen at admission | `ConditionItemScope.Limit`, re-read from the catalog the listing comes from; a changed limit re-admits through a fresh snapshot | `The_item_limit_is_re_read_with_the_listing_not_frozen_at_admission` (export limit drops 1000 → 2 under 3 conditions ⇒ begin `total` 3, no record): red with the admission limit restored | +| **S5** 256 KiB chunk vs small limits | Chunk budget = `min(256 KiB, MaxPendingBytes, MaxMessageBytes) − (2048 + 4·len(subscription id) + 1024)`; below 4 KiB the item is refused `LimitExceeded`. A record above the budget has message, then comment, then client user id truncated (never splitting a surrogate pair); one that cannot fit even bare resets the stream with "A condition record exceeds the stream's message limits." instead of failing every frame | `Chunks_fit_small_pending_and_message_limits_and_an_oversized_message_is_truncated` (MaxMessageBytes 20,000, a 50,000-char message): red with the 256 KiB cap restored; `A_record_that_cannot_fit_even_without_free_text_is_reported_not_queued` (unit) | +| **N1** starvation | `ConditionFramesPerValueFrame` = 8: after 8 condition frames in a row a queued v1 frame goes next | `Condition_frames_do_not_starve_queued_values` (12 condition frames + 1 value ⇒ value 9th): red reverted | +| **N2** removal version = watermark | Code unchanged; the rule is now explicit (code doc on `Removal`, plan §5.5 "Version rule"): `removed` records and snapshot begin bypass the per-key version gate — A3 must implement that | — (doc) | +| **N3** full partition scan | Partition records its tail; a reader at/past it returns empty without scanning | behaviour-preserving; hub tests green (no red-on-revert: a scan cost) | +| **N4** per-hold size | `min(limit, OtOpcUaNodeManager.DefaultMaxConditionsPerHold)` for snapshots and joiners | existing slice tests green (3,000-record snapshots now take 3 holds) | +| **N5** leaked waiters | The loop keeps the losing `WaitToReadAsync` task and reuses it until it completes | `The_delivery_loop_does_not_pile_up_channel_waiters` (40 value wake-ups with conditions idle): condition-queue waits ≤ 1; **19** with the fix reverted (the first cut of this test counted both queues and passed reverted — sharpened) | +| **N6** test code in production | `ConditionTestAssertions` deleted; `EnqueuePriorityProbesForTests` replaced by three internal primitive seams (value / heartbeat / condition probe, InternalsVisibleTo only), composed in the test; the session partial's class doc moved back onto the class | priority test rewritten on the primitives | +| **N7** Secondary advertises conditions | Note only (no change, per brief): a Secondary advertises field 17 (`rootScopeItems`, `maxConditions`) while refusing condition items `Unavailable` (smoke `a2a-cond-2`); A3 must pick a Primary endpoint for condition items | — | +| **N8** operator identity to the peer | Note only (no change, per brief): `ClientUserId` / comment / ack identity on records reaching a peer is the ORIGIN's principal (service principal for remote calls, the local operator for local acks) — A3/A4 to decide whether a UNS peer should see local operator names | — | +| Plan §5.1 "Control NotReady" | Replaced by the implemented rule (readiness = withheld `snapshot_complete`) — accepted by the reviewer | — | +| Plan §5.5 | Lifetime rule (S1), version rule (N2), "A3 removes an item whose `total` exceeds its mapping limit" | — | + +**A1 phase-run failure — root cause (not a flake).** `A_native_transition_leaves_the_F5_pending_set_like_the_node_manager` failed +3/3 in full A1 runs with `Unsignalled[...].Conditions` 2 instead of 1 (4 s duration). Under the phase run's load, the 600 ms F5 +window closed BEFORE the driver's transition was processed: `OnConditionSignalTimedOut` raised the diagnostic with 2 pending, then +the transition removed A from `Pending` — but `NoteConditionsEstablished` only cleared the diagnostic when `Pending` emptied, so a +raised diagnostic kept its count from when it was raised and claimed a condition the node manager held established. A real +(diagnostic-accuracy) defect that only the loaded ordering exposed. Fix: `ConditionStateHub.UpdateUnsignalled` (updates an existing +diagnostic only, does not charge the counter again) called when `Pending` shrinks while the diagnostic is raised. New +deterministic test `A_native_transition_after_the_F5_window_closed_lowers_the_raised_diagnostic` (200 ms window closes first, +then A ⇒ 1, then B ⇒ cleared): **red** before the fix, green after. The original test now awaits the node manager's count +(either order is legal) instead of reading the first value it sees. + +**Mutation record (all restored):** B1 `Max(1,…)` ⇒ B1 test red; one run with the per-stream cap, memory charge, chunk cap, N1 +fairness, N5 reuse, S3 mapping and S4 re-read all reverted ⇒ exactly the six targeted tests red, the other 16 green (N5's test +was green — sharpened, then red at 19 alone); duplicate-root check reverted alone ⇒ its test red. + +### Review round 1 — gates + +| Gate | Result | +|---|---| +| `dotnet build ZB.MOM.WW.OtOpcUa.slnx` | 0 warnings, 0 errors | +| `run-unit-phase.py` A2 / H2 / X0 | passed / passed / passed | +| `run-unit-phase.py` A1 ×3 (consecutive, after the F5 fix) | passed / passed / passed (before the fix: failed 3/3, and once more at the start of this round) | +| Host.Tests `.DataConnections.` (both v1 gates) | 205 passed; `git diff master -- '*Goldens.cs'` empty (never re-recorded) | +| Runtime.Tests (`Category!=E2E&Category!=LiveIntegration`) | 2012 passed, 3 skipped | +| OpcUaServer.Tests (same filter) | 1447 passed, 1 skipped | +| Live `conditions_smoke.py` | LIVE_PLACEHOLDER | + ## A2b (condition methods) — progress log (resume from here) - `1e78c64b` contract + RPC + origin (NM `TryExecuteConditionMethod`, Runtime facade, registry, audit, Galaxy rule, bits). @@ -213,7 +265,9 @@ the `AddDataConnectionConditions` migration. Condition METHODS are stage A2b (a - Deltas: per-partition cursors from `StartCursor`, skip a delta at/below its condition's slice watermark, removal only for a condition sent before, `info` on first appearance. - Catalog change: leaving conditions get a synthesised removal record (version = hub watermark), joining ones a small - snapshot sent as delta records. + snapshot sent as delta records. ⚠️ **Corrected by review round 1 (S1):** this path is not reachable by a production + deploy — every deploy begins a catalog attempt, which changes the serving identity and ENDS the stream; the consumer + reconnects and takes a complete snapshot (plan §5.5 lifetime rule). Only a listing swap without an attempt reaches it. - **`AlarmSubscribe` end to end.** `DataOperationSets.Understood`, validator known set, `Implemented(target)` (only while servable), capabilities/metadata decode (bit 64 without field 17 is no grant; metadata never carries 64), migration `AddDataConnectionConditions`, AdminUI checkbox + limits (helper agent: `ac945563`, `ee1556ac`, `6272c7cf`). @@ -237,7 +291,7 @@ MaxConditions × 49 > 122,500 per consumer node; shown on the AdminUI mappings p | Key | Project | Classes | |---|---|---| -| R | Runtime | `GrpcDataConditionStreamTests` (12): snapshot begin/total/records/complete + delta; total over the limit first and only (no `SnapshotConditions` call); slice cut with deltas between holds (no gap, no duplicate); hub reader reset ⇒ fresh snapshot; overflow while the snapshot is undelivered ⇒ stream `Reset`; priority (control at head, then condition, then value; a control behind a value keeps v1 order); revocation mid-snapshot ⇒ no further condition record, stream ends, item released; deploy add/remove ⇒ delta records (`removed`); UNS listing carries no RawPath/driver id; non-Primary ⇒ `Unavailable`, no grant ⇒ `Denied`; incomplete apply ⇒ snapshot without `snapshot_complete`, retaken complete; capabilities only with a key secret | +| R | Runtime | `GrpcDataConditionStreamTests` (12): snapshot begin/total/records/complete + delta; total over the limit first and only (no `SnapshotConditions` call); slice cut with deltas between holds (no gap, no duplicate); hub reader reset ⇒ fresh snapshot; overflow while the snapshot is undelivered ⇒ stream `Reset`; priority (control at head, then condition, then value; a control behind a value keeps v1 order); revocation mid-snapshot ⇒ no further condition record, stream ends, item released; deploy add/remove ⇒ delta records (`removed`) — ⚠️ fixture-only, renamed in review round 1 (S1); UNS listing carries no RawPath/driver id; non-Primary ⇒ `Unavailable`, no grant ⇒ `Denied`; incomplete apply ⇒ snapshot without `snapshot_complete`, retaken complete; capabilities only with a key secret | | — | Commons | `GrpcDataConditionCodecTests` (6): 17/4/9 pinned with their real types (replaces the X0 tripwire), full-field round trip, begin `total` presence, malformed frames refused, bit 64 without field 17 is no grant, a plain item stays v1 bytes | | v1 gate | Host | `GrpcDataV1CompatibilityTests` / `GrpcDataV1RealOriginCompatibilityTests`: both origins now serve conditions (fake: field 17 + bit 64 + an arm-9 frame for a scoped item; real: AlarmSubscribe exports + a condition source over the HighTemp alarm). Header-less ⇒ golden bytes on every RPC, including a Subscribe whose items carry `condition_scope` (no arm 9); with the header ⇒ field 17/bit 64 and (fake) arm 9. `git diff master -- *Goldens.cs` is empty | | F | Configuration | `GrpcDataConditionConfigurationTests` (22) + updated `GrpcDataReservedOperationAuthoringTests` | @@ -347,9 +401,11 @@ editor modals were not driven — no bUnit, needs a browser drive in A4 or the n - Q4 (A2b): `NativeAlarmInitialStateSignalTests.A_native_transition_leaves_the_F5_pending_set_like_the_node_manager` fails in full A1 phase runs (3/3 here, 1 in A2a) and passes alone — file a test-flake issue against A1 (600 ms signal timeout). + **RESOLVED in review round 1 — not a flake, a real defect** (see "Review round 1"). - Q5 (A2b): the consumer's `ConditionMethodTimeout` is a connection-level property until A3 binds the mapping's value. -- Q1: Should §5.1 drop "Control NotReady" (decision 1) or should a later phase add the kind? +- Q1: Should §5.1 drop "Control NotReady" (decision 1) or should a later phase add the kind? **Resolved (review round 1): + the reviewer accepted decision 1; §5.1 now states readiness = withheld `snapshot_complete`.** - Q2: Wire `ConditionCapacityWarnings` into the deploy path (non-blocking log) — A2b or A3? - Q3: The probe/consumer advertise `conditions` on every capabilities probe now; an origin that advertises conditions gets the `conditions` header on every RPC of that consumer (no behaviour change until a condition item is opened).