# A2 — progress log and evidence ## Security review (A2b) fixes — progress log - Commit `91f1f729` on `a2-wire` (code + tests), then this evidence. Not merged, not pushed. | # | Finding | Resolution | Test | Red on revert | |---|---|---|---|---| | 1 | Exception after apply reported as "nothing applied", claim leaked, audit skipped | Only `OriginConditionSourceUnavailableException` (new, thrown by `DeferredOriginConditionSource` when the server is down) counts as nothing-applied. Any other exception from the port ⇒ claim marked dispatched + completed `OutcomeUnknown` (`BadInternalError`), joiners get the same. A `finally` always finishes the claim, and the outer `finally` always writes the audit record (`OutcomeUnknown` if no result), with the audit call guarded so it cannot throw | `An_exception_after_dispatch_answers_OutcomeUnknown_finishes_the_claim_and_is_audited`; `A_node_manager_that_is_not_running_is_nothing_applied_and_retains_no_entry` | **yes**: catch widened back to `InvalidOperationException` ⇒ the first test is red (M1) | | 2 | One principal can exhaust the 4096-entry registry | `WriteOperationRegistry` gains `maxEntriesPerPrincipal` (case-insensitive per-principal count) and `ReleaseUndispatched` (removes only an entry completed as rejected before dispatch). Facade/NM refusals release their entry, and refusals before the claim never touch the registry. Limits: `DataConnections:MaxConditionMethodOperations` (4096) / `MaxConditionMethodOperationsPerPrincipal` (256), validated (1..65536, per-principal ≤ total), via `LocalDataRuntimeLimits` → `LocalDataServices.ConditionMethodMaxOperations[PerPrincipal]`. The write path keeps its old behaviour (per-principal cap defaults to the global cap) | `One_principal_cannot_exhaust_the_registry_for_another`, `The_global_registry_cap_holds_across_principals`, `Refusals_retain_no_registry_capacity`, registry unit `A2b_the_per_principal_cap_…_release_frees_the_slot` | **yes**: per-principal check removed ⇒ 2 red (M2); global check removed ⇒ global test red (M3); release removed ⇒ refusal + not-running tests red (M4) | | 3 | Audit category unused, default logger possibly NullLogger | `DataConnectionRegistration.AddDataConnectionAuditLog` registers `IDataConnectionAuditLog` = `LoggerDataConnectionAuditLog.Create(ILoggerFactory)` (category `ZB.MOM.WW.OtOpcUa.DataConnections.Audit`). `LocalDataRuntimeComposition` takes it and sets `Services.Audit` | Host `The_registered_audit_log_writes_on_its_own_category_from_the_real_logger_factory` (real registered graph + capturing provider: the composition's `Audit` is the DI instance, and one line lands on the audit category) | **yes**: composition ignoring the passed audit ⇒ red (M7) | | 4 | Only `on_behalf_of` sanitised | The audit entry is built with every caller-supplied string sanitised (`OperationId`, placement cluster/namespace/identifier kind/identifier/subject/mapping id, principal, key id), max 512 UTF-16 units each. `LoggerDataConnectionAuditLog` sanitises again (defence in depth). No other log site prints these strings | `Every_caller_supplied_audit_string_is_sanitised` (CR/LF/BEL/U+2028/NUL in op id and placement) | **yes**: field sanitiser → identity ⇒ red (M6) | | 5 | Activation sequence restarts at 0 for a re-created condition | `_activationSequenceSource`: one monotonic counter for the node-manager lifetime (= `ConditionIncarnation`'s lifetime). Every fresh `ActivationEntry` and every bump draws `++counter`, and rebuild carry-over keeps its value. A sequence now only grows, by any step (the T3 test asserts "moves", not "+1") | `A_condition_removed_and_re_created_never_accepts_a_marker_of_its_previous_incarnation` (remove + re-materialise + same-shape raise ⇒ the old marker gets `BadEventIdUnknown`, nothing routed) | **yes**: per-entry `0` + `Sequence++` ⇒ red (M10) | | 6 | Mutation-test gaps | Cross-principal join: `Principal_B_reusing_principal_As_operation_id_never_joins_As_operation`. Native AddComment off-Primary, plus scripted AddComment off-Primary: `AddComment_is_refused_off_Primary_for_a_native_and_a_scripted_condition`. Scripted AddComment on Warm Standby: `A_scripted_AddComment_is_refused_on_a_Warm_Standby`. Capacity, incarnation and exception-after-dispatch: rows 1, 2, 5 | see left | cross-principal: **yes** (registry key ignoring principal ⇒ red, M5). AddComment off-Primary: **yes** (NM Primary gate disabled ⇒ red, M11). Warm Standby AddComment: **no for one layer** (the TryExecute standby check alone is masked by the handler's `HandleAlarmCommand` standby check, M12), **yes with both layers disabled** (M12b) | | 7 (nit) | AddComment status text | A native AddComment now says "AcceptedUnconfirmed: the comment was applied at the origin (not sent to the driver) …". It is not driver-routed, and the old "routed to the driver" text was wrong. State unchanged (`AcceptedUnconfirmed`) | covered by existing facade tests | text only, no mutation test | | 8 (nit) | Sanitiser: lone surrogates / private-use / format | Drops Cc, Cf, Co (BMP **and** planes 15/16), Cn, Zl, Zp and lone surrogates. Never splits a pair at the cap, so the output is always well-formed UTF-16 | `SanitizeAuditText_drops_private_use_and_lone_surrogates_and_stays_well_formed` (strict UTF-8 round trip) | **yes**: PrivateUse dropped from the set ⇒ red (M8) | | 9 (nit) | TOCTOU between authorization and apply | Documented on `CallConditionMethodAsync` (``). The window is one synchronous hop with no I/O, the same as a local client's call. Revocation stops later calls. Serving-identity changes are re-checked under `Lock` (Primary, Warm Standby), and the activation marker refuses a re-created condition. Not closed: a grant revoked inside that hop is not re-checked | — | doc | | 10 (nit) | Unbounded origin wait on NM `Lock` | `TryExecuteConditionMethod` uses `Monitor.TryEnter(Lock, ConditionMethodLockTimeout)` (default 5 s = the consumer's default `ConditionMethodTimeoutMilliseconds`). Not acquired ⇒ `BadTimeout`, nothing applied | `A_remote_call_waits_a_bounded_time_for_the_Lock_and_is_refused_unapplied` (Lock held on another thread, 100 ms bound) | **yes**: `Monitor.Enter` ⇒ red after the 30 s holder (M13) | | 11 (nit) | Consumer cancel after send must be OutcomeUnknown | The `OperationCanceledException` rethrow is removed: any failure after the request reaches the transport, a caller cancel included, answers `OutcomeUnknown` (`BadCommunicationError`) | `A_caller_cancel_after_the_request_was_sent_is_OutcomeUnknown_not_a_clean_failure` | **no**: Grpc.Net.Client surfaces a caller cancel as `RpcException(Cancelled)` (the channel does not set `ThrowOperationCanceledOnCancellation`), which was already mapped to `OutcomeUnknown`. The removed rethrow was reachable only by a bare `OperationCanceledException`. The test pins the behaviour but is green with the rethrow restored (M9) | **Mutation record (all restored, tree clean afterwards):** M1–M8, M10, M11, M12b, M13 each turned their target test(s) red. M9 and M12 (single layer) stayed green, as explained above. M5 also reddened the existing registry test `Hash_is_copied_and_conflicting_payload_or_stale_incarnation_cannot_dispatch`. New configuration keys (Host, `DataConnections` section): `MaxConditionMethodOperations` (default 4096) and `MaxConditionMethodOperationsPerPrincipal` (default 256). Both are validated at startup. AdminUI and Configuration were not touched. ### Security review (A2b) — gates | Gate | Result | |---|---| | `dotnet build ZB.MOM.WW.OtOpcUa.slnx` | 0 warnings, 0 errors | | `run-unit-phase.py` A2 / A1 / H2 / X0 (one at a time) | passed / passed / passed / passed | | Host.Tests `.DataConnections.` + options (both v1 gates) | 206 passed; `git diff master -- '*Goldens.cs'` empty (never re-recorded) | | Runtime.Tests (`Category!=E2E&Category!=LiveIntegration`) | 2022 passed, 3 skipped | | OpcUaServer.Tests (same filter) | 1451 passed, 1 skipped | | AdminUI.Tests / Configuration.Tests | not run (neither project nor what they cover was touched) | | Live `conditions_smoke.py` | **PASS**, run `a2s1-cond-1` at `91f1f729` (clean tree, `source_tree_hash` `452965d34713…`): up `--conditions` → seed → ~85 s → deploy → smoke → down. source-1 (Primary): ops 31 without the header, 479 with it; snapshot v3 active/unacked marker `f708524d:2`, which is the node-manager-wide sequence and no longer starts at 1. Remote ack `DriverConfirmedSuccess` (2); the duplicate joins and is equal; header-less ⇒ `FailedPrecondition`; deltas v4/v5 acked, comment "A2b remote ack", `clientUserId` fixture-consumer, v6 inactive; no RawPath. source-2 (Secondary): ack refused "not the redundancy Primary"; ops 87. Origin subscriber: 4 ScalarHigh events, exactly one Active+Acknowledged. Audit lines on source-1: the ack and the same line `(joined)`. `rig.py down`: no run-labelled containers, volumes or networks left | ## 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` | **PASS**, run `a2r1-cond-1` at `5d91d886` (clean tree, `source_tree_hash` `ddaeb60c1a82…`): up → seed → ~85 s → deploy → smoke → down. source-1 (Primary): with header ops 479 + `{rootScopeItems, methods 7, maxConditions 1000}` (without: 31, no field 17); condition item ack Good, begin `total` 1, `ScalarHigh` record (active, unacked, known, scripted, UNS placement), `snapshot_complete`; remote ack `DriverConfirmedSuccess` (2), duplicate joins equal, header-less `FailedPrecondition`; deltas v4/v5 (acked, comment "A2b remote ack", `clientUserId` fixture-consumer) and v6 inactive; no RawPath. source-2 (Secondary): item `Unavailable`, ack refused "not the redundancy Primary" (N7: still advertises field 17). Origin subscriber: 4 ScalarHigh events, exactly one Active+Acknowledged. `rig.py down`: no run-labelled containers left. (The rig's only condition is scripted, so S3's native-in-UNS rename is covered by the unit test, not live.) | ## A2b (condition methods) — progress log (resume from here) - `1e78c64b` contract + RPC + origin (NM `TryExecuteConditionMethod`, Runtime facade, registry, audit, Galaxy rule, bits). - `f6c9c9d7` consumer client call, validator/AdminUI bits + Galaxy checkbox, capacity warnings at the deploy gate. - Tests: NM, Runtime facade + client, codecs, F/P/U, both recorded-v1 gates, manifest — committed; mutation checks done. - Gates done (see "A2b — tests and gates"); X0 found one more test using 256 as "unknown" (fixed). - Live smoke PASS (run `a2b-cond-2`, build `90db1e68`), AdminUI editor driven live (save round-trips) — **A2b complete**, pending review. Not merged, not pushed. ## A2b — what changed - **Contract (§4.2 numbers as planned).** `rpc CallConditionMethod(ConditionMethodRequest) returns (ConditionMethodResponse)`, appended 8th; request fields 1–8, response 1–4 exactly §4.2. `method` is a single bit of `DataConditionMethods` (1 Acknowledge, 2 AddComment, 4 Confirm — §4.2 left the values open; the same values are the `methods` / `supported_methods` masks). `state` reuses `DataWriteState` (1 RejectedBeforeDispatch, 2 applied/scripted `DriverConfirmedSuccess`, 4 native `AcceptedUnconfirmed`, 5 `OutcomeUnknown`). Codecs in `DataConditionProtoMapper`. `DataConnectionEndpoints.Methods` lists it; the codec pins moved 7 → 8. - **Negotiation.** The host refuses `CallConditionMethod` FAILED_PRECONDITION unless the call negotiated `conditions` AND the origin is condition-capable (`ConditionsNegotiated`) — a header-less / history-only / v1 caller never reaches the origin. Bits 128/256 travel only with field 17 (`DataOperationSets.ConditionGrants` = 64|128|256: stripped from capabilities and metadata on a non-negotiated call; the decoder drops them without field 17). - **Bits.** `Understood` += AlarmAcknowledge|AlarmConfirm, `Reserved` = AlarmShelve only, validator `KnownOperations`, `Implemented(target)` (`ConditionMethodsServable`), AdminUI `AuthorableOperations`. `DataCapabilitiesProvider` and `CanPublishCapabilities` strip the method bits off-Primary (like Write). `DataConditionCapabilities.Methods` = the methods the caller's exports grant (0 off-Primary / unservable); `ConditionInfo.supported_methods` per condition = kind support (native: Ack|AddComment) ∩ the principal's export grants on its placements, minus Ack/AddComment for a Galaxy native condition without the opt-in (`LocalExportCatalog.MethodsFor`). - **Origin facade** (`LocalDataServices.ConditionMethods.cs`, `LocalDataConnection : IDataConditionMethodService`). Order, each refusal `RejectedBeforeDispatch` with no state change: servable → catalog ready (+ target role) → **Primary** (`BadInvalidState`) → expected serving incarnation → budget → caller usable → placement resolves (`TryResolveConditionPlacement`) AND an export grants the method's bit on it (else `BadNodeIdUnknown`, existence not disclosed) → origin ACL `AlarmAcknowledge`/`AlarmConfirm` on the **placement's** subject (a UNS placement ⇒ its equipment; `BadUserAccessDenied`) → native Confirm (`BadNotSupported`) → **Galaxy opt-in** (`BadUserAccessDenied`) → registry → node manager. - **Node manager** (`OtOpcUaNodeManager.ConditionMethods.cs`). `TryExecuteConditionMethod` takes `Lock` and checks: exists, Warm Standby, `NativeAlarmAckPrimaryGate` (both kinds), method supported, **activation marker** (`ConditionIncarnation` + per-condition sequence; mismatch ⇒ `BadEventIdUnknown`); then invokes the condition's **wrapped** method `OnCall` (the `WireMethodTransitionReporting` / `ReportAfterMethod` wrapper → SDK handler → `HandleNativeAlarmAck` / `HandleAlarmCommand`) with the condition's current EventId and an internal `RemoteConditionMethodContext` (a `ServerSystemContext` carrying a role-less `RoleCarryingUserIdentity` for the service principal + its `ApiKeyId`). `AlarmCaller` skips `EvaluateAlarmCommandGate` only for that context type AND only for the very condition it was built for; Warm Standby, Primary gate, native preflight (#760/#765) and the routers run unchanged. So the SDK path and the remote path share one body: one event, the native Confirmed/Retain re-assert, `NativeAlarmAck` (OperatorUser = principal, `ApiKeyId` = service key — the Galaxy ack identity lookup of §6), an unchanged `AlarmCommand` (User = principal, Comment = the Part 9 comment), `ClientUserId` = principal. Never waits under `Lock`. - **Operation registry.** A per-serving-incarnation `WriteOperationRegistry` (4096 entries, 8 MiB, retention 5 min) keyed (principal, operation id) with a SHA-256 of (placement, method, expected marker, comment) — never the audit text. A duplicate joins (awaits/returns the stored outcome, audited `Joined`); the same id with another call ⇒ `BadInvalidArgument`. - **Consumer client** (`GrpcDataConnection.ConditionMethods.cs`, `IDataConditionMethodService`). Deadline = min(remaining budget, `ConditionMethodTimeout` — the mapping's `ConditionMethodTimeoutMilliseconds`, default 5 s). Only a Primary endpoint that advertised the method and serves `expected_serving_incarnation` is eligible. After the request is handed to the transport, any failure ⇒ `OutcomeUnknown` (`BadCommunicationError`) and **no other endpoint is tried**; a FAILED_PRECONDITION/UNIMPLEMENTED/INVALID_ARGUMENT/PERMISSION_DENIED answer ⇒ `RejectedBeforeDispatch`. - **Audit (§6).** `IDataConnectionAuditLog` (default `LoggerDataConnectionAuditLog`, category `ZB.MOM.WW.OtOpcUa.DataConnections.Audit`): principal, key id, placement address, operation id, method, outcome, joined, sanitised `on_behalf_of` (Cc/Cf/Zl/Zp/unassigned and unpaired surrogates removed, capped at 128 chars without splitting a pair). The text reaches nothing else: `OriginConditionMethodCall` has no field for it. - **Galaxy (§6, Q2).** `LocalConditionPlacement.DriverType` (from the backing driver at compile) + `IsGalaxy`; `ExportRule.GalaxyServiceAck` = `AllowGalaxyServiceAck && AlarmAcknowledge`; AdminUI export editor checkbox "Allow remote acknowledge of Galaxy alarms" (disabled unless AlarmAcknowledge is ticked) with the secret-path hint. - **Capacity warning at the deploy gate (Q2 of A2a).** `DataConnectionValidator.DeployWarnings` (= `ConditionCapacityWarnings`) is logged non-blocking by `AdminOperationsActor.StartDeployment`, the established deploy-gate warning channel (the validator's error list has none). The AdminUI mappings panel keeps showing it. - **Metric.** `otopcua.dataconn.condition_methods{method,outcome}`. ## A2b — decisions 1. **One body, two callers.** The remote path calls the SAME wrapped SDK `OnCall` a local client's call runs, rather than re-implementing apply + report: §5.6's "factored out of `HandleNativeAlarmAck` + `ReportAfterMethod` so neither goes around the other" is met by making the session gate the only thing that differs (`AlarmCaller`). 2. **The activation-marker incarnation is NM's `ConditionIncarnation`** (the A1 open question): it is what the stream carries and what changes on any NM restart; the serving incarnation is checked separately (`expected_serving_incarnation`). 3. **Ungranted ≡ unknown placement** (`BadNodeIdUnknown`): a caller without the export grant learns nothing; with the grant, an ACL or Galaxy refusal is `BadUserAccessDenied` (§6 names it). 4. **Remote methods are Primary-only for both kinds**: the Runtime checks the serving role and NM applies `NativeAlarmAckPrimaryGate` to scripted conditions too (local scripted calls are unchanged). 5. **No state applied on a refusal**: NM refusals return before `OnCall`; SDK refusals (bad EventId etc.) fail before the SDK applies; the facade maps every non-applied verdict to `RejectedBeforeDispatch`. ## A2b — deviations (for the reviewer) - **"Control NotReady" (A2a decision 1, restated).** §5.1 says the stream sends a `Control NotReady` until the origin is ready; **the implementation sends no such control** — `DataStreamControlKind` has no `NotReady` member and adding one is a new v1-decoder shape. Readiness is expressed by withholding `snapshot_complete`; the item retakes the snapshot (≥ 1 s apart) once apply-complete + Primary. Plan text and implementation disagree; the reviewer should either accept this and amend §5.1 or schedule the kind in a later phase (Q1). - **`ConditionMethodTimeoutMilliseconds` is enforced by the consumer client** (`GrpcDataConnection.ConditionMethodTimeout`, default 5 s, per-call deadline); binding the per-mapping value to the import is A3 (no consumer registry yet). The origin enforces the request's `remaining_budget_ticks` (≤ 0 ⇒ `BadTimeout`, clamped to `UnaryTimeout`). - **"Driver failure revert seen in the stream"** is proven at the node manager (the #760 revert is DriverHostActor's `WriteAlarmCondition` re-projection: origin event + an unacked record with the bumped marker in the condition sink, which is the hub's input); a full DriverHostActor + failing driver run is not part of A2b (not live-gated). - **Bits 128/256 = AlarmAcknowledge/AlarmConfirm.** AlarmShelve (512) stays reserved (the brief's "Shelve" wording vs the plan's table — the plan's names were used). - **Standby refusal is two layers** (the TryExecute pre-check and the handler's own): mutating either alone is masked by the other; mutating both turns the standby test red. ## A2b — tests and gates | Key | Project | Classes | |---|---|---| | H wire (NM) | OpcUaServer | `ConditionMethodNodeManagerTests` (8): remote native ack ⇒ exactly one origin event, routed once (principal, ApiKeyId, comment), Confirmed re-asserted, `ClientUserId` = principal; #760 revert ⇒ origin event + unacked record with the bumped marker, old marker `BadEventIdUnknown`; native AddComment stored + one event + unchanged `AlarmCommand`; scripted ack/confirm route unchanged `AlarmCommand`s; native Confirm / unknown ⇒ refused, no record; off-Primary (both kinds) and Warm Standby ⇒ refused, no state, nothing routed; T3 (message-only re-projection and a scripted re-assert keep the marker ackable; a changed-message re-raise and another incarnation ⇒ `BadEventIdUnknown`); a role-less local session is still denied (pre-authorization bound to its own context) | | H wire (facade) | Runtime | `GrpcDataConditionMethodTests` (17): native ack ⇒ `AcceptedUnconfirmed` + the exact NM call; capabilities bits/mask Primary only; Secondary / NM refusal ⇒ `RejectedBeforeDispatch`; Galaxy without opt-in ⇒ `BadUserAccessDenied`, NM never called (with it ⇒ accepted with the key id; Confirm-only export ⇒ no grant); UNS placement ⇒ (Raw, RawPath) condition, authorized on the EQUIPMENT grant, a raw-subject grant does not authorize it; ungranted/unknown/native Confirm/stale/expired/ACL-denied refused unsent; marker mismatch passes `BadEventIdUnknown`; duplicate id joins (one NM call, audit `Joined`), reused id ⇒ `BadInvalidArgument`; audit text sanitised + capped, audit only; sanitiser cases; listing `supported_methods` (native 3, Galaxy w/o opt-in 0, with 3, ungranted 0) | | H wire (consumer) | Runtime | `GrpcDataConditionMethodClientTests` (4): transport drop after send ⇒ `OutcomeUnknown`, 1 call, the second eligible endpoint never called; `conditions` header + deadline ≤ ConditionMethodTimeout; Secondary / no method / other incarnation ⇒ nothing dispatched; FAILED_PRECONDITION ⇒ `RejectedBeforeDispatch` | | — | Commons | `GrpcDataConditionCodecTests` (+2): RPC 8th with §4.2 numbers, request/response round trip, malformed refused, method bits without field 17 no grant; `GrpcDataProtoContractTests`, `GrpcDataHistoryCodecTests` 7 → 8 | | v1 gate | Host | `GrpcDataV1CompatibilityTests` (+1) / `GrpcDataV1RealOriginCompatibilityTests` (+3): both origins now grant 128/256 and implement the method port; header-less / history-only `CallConditionMethod` ⇒ FAILED_PRECONDITION, port never called; with `conditions` ⇒ served (real origin: bits 384 + mask 7, one port call); every header-less golden unchanged (`git diff master -- '*Goldens.cs'` empty) | | F | Configuration | `GrpcDataConditionConfigurationTests` (128/256 authorable, mapping ⊆ connection, shelve reserved, Galaxy opt-in only with AlarmAcknowledge, `DeployWarnings`), `GrpcDataReservedOperationAuthoringTests` (reserved = 512) | | P | Runtime | `GrpcDataConditionArtifactReadTests` (Galaxy opt-in + 128/256 ride the artifact; 512 tolerated, no grant); `GrpcDataArtifactReadTests`, `GrpcDataUnknownOperationToleranceTests`, `GrpcDataCatalogStagingTests` moved their "unknown" bit off 128/256 | | U | AdminUI | `GrpcDataConditionEditorTests` / `GrpcDataHistoryEditorTests`: 128/256 authorable, 512 not, Galaxy opt-in default off | | — | Core.Abstractions | `GrpcDataOperationToleranceTests`: Understood/Reserved/ConditionGrants pins | Manifest key `A2` gained the new Runtime classes, `GrpcDataUnknownOperationToleranceTests` and an OpcUaServer entry. **Mutation checks (red, then restored green):** Runtime — placement ACL check disabled ⇒ UNS-subject + ACL-denied tests red; Galaxy opt-in disabled ⇒ Galaxy test red; Primary check disabled ⇒ off-Primary test red. NM — activation-marker check disabled ⇒ revert + T3 tests red; Primary gate limited to native ⇒ Primary/standby test red; pre-authorization widened to any context ⇒ local-session test red (the first version of that test passed for the wrong reason — anonymous context — and was strengthened to a role-less authenticated identity); Warm Standby: each layer alone is masked by the other, both disabled ⇒ red. | Gate | Result | |---|---| | `dotnet build ZB.MOM.WW.OtOpcUa.slnx` | 0 warnings, 0 errors | | `run-unit-phase.py` A2 / H2 / X0 | passed / passed / passed (X0 first failed on `GrpcDataCatalogStagingTests` using 256 as "unknown" — fixed) | | `run-unit-phase.py` A1 | **failed 3/3 phase runs on one test**, `NativeAlarmInitialStateSignalTests.A_native_transition_leaves_the_F5_pending_set_like_the_node_manager` (A1, 600 ms signal timeout vs. the transition under load; A2a hit it too, before any A2b code). The same Runtime A1 entry with the phase's own filter, Release config and runsettings passes 2/2, the class alone 3/3; A2b touches nothing on that path (DriverHostActor initial-state tracking). Recorded as a pre-existing timing flake — Q4 | | Host.Tests `.DataConnections.` | 205 passed (both v1 gates) | | Runtime.Tests (`Category!=E2E&Category!=LiveIntegration`) | 2001 passed, 3 skipped | | OpcUaServer.Tests (same filter) | 1447 passed, 1 skipped | | AdminUI / Configuration / Commons / Core.Abstractions | 2703 / 339 / 512 / 860 passed | ## A2b — live smoke (rig) — run `a2b-cond-2`, PASS Standalone rig (OrbStack), build `90db1e68b` (clean tree, `source_tree_hash` `560a15cd4f0fe8ba…`), normal build-hash checks. ```bash python3 scripts/validation/grpc-data/rig.py up --run-id a2b-cond-2 --conditions --timeout 1200 python3 scripts/validation/grpc-data/rig.py seed --run-id a2b-cond-2 # ~85 s for CONTROL's ClusterNode contact refresh python3 scripts/validation/grpc-data/rig.py deploy --run-id a2b-cond-2 --timeout 300 python3 scripts/validation/grpc-data/conditions_smoke.py --run-id a2b-cond-2 python3 scripts/validation/grpc-data/rig.py down --run-id a2b-cond-2 ``` The conditions profile now grants 64|128|256 on the SOURCE exports. The probe acknowledges the active scripted alarm through `CallConditionMethod` (placement from the listing, the record's marker, the selected serving incarnation, `on_behalf_of` carrying a BEL), repeats the same operation id, tries it header-less, waits for the acked delta, then clears the alarm. `conditions_smoke.py` runs the CLI `alarms --refresh` against the SOURCE Primary's own OPC UA endpoint meanwhile. | Item | Observed | Result | |---|---|---| | Capabilities, Primary (source-1) | without header ops 31, no field 17; with `conditions` ops 479 (= 31+64+128+256), `{rootScopeItems, methods 7, maxConditions 1000}` | PASS | | Capabilities, Secondary (source-2) | with header ops 87 (64 only — method bits stripped off-Primary), no methods mask | PASS | | Remote ack (Primary, scripted ScalarHigh via its UNS placement `source-scalar-high`) | state 2 (applied), status Good; duplicate op id ⇒ identical answer; header-less ⇒ `FailedPrecondition` | PASS | | Stream | snapshot v3 active/unacked (marker `0fa526c0:1`) → delta v4 active/**acked**, comment "A2b remote ack", ClientUserId `fixture-consumer` (the service principal) → v5 identical state-only record (the engine's re-projection; no event) → v6 inactive/acked; marker unchanged throughout; no RawPath | PASS | | **Origin's own subscriber** (CLI `alarms` on source-1) | ScalarHigh events: Active/Unacknowledged (refresh), **exactly one Active/Acknowledged**, Inactive/Acknowledged, Active/Unacknowledged (the probe's restore) | PASS | | Audit log (source-1 container) | `Data-connection condition method Acknowledge by fixture-consumer (key …) on Uns:…:source-scalar-high op a2b-ack-source-1-…: DriverConfirmedSuccess 0x00000000; on behalf of probeoperator` and the same line `(joined)` — BEL stripped | PASS | | Secondary | `RejectedBeforeDispatch`, `BadInvalidState` "This server is not the redundancy Primary."; condition item `Unavailable` | PASS | | Teardown | no run-labelled containers, volumes or networks left | — | Earlier attempt `a2b-cond-1` (kept as history): the remote ack, stream and origin count were already right (origin: exactly one Active/Acknowledged), but the probe expected the NATIVE outcome (4) for the scripted alarm, required exactly one acked delta (the engine's state-only re-projection makes two records, one event) and required the method bits on the Secondary; probe fixed (harness only), the edit changed the image inputs, so the run was torn down and `a2b-cond-2` brought up fresh. **AdminUI driven live** (CONTROL admin port, login disabled, Chrome): `/clusters/SOURCE/data-connections` server-renders the exports; the export editor shows AlarmSubscribe / **AlarmAcknowledge / AlarmConfirm** and **"Allow remote acknowledge of Galaxy alarms"** with the seeded values. Save round-trip 1 (export-uns): Galaxy opt-in on, AlarmConfirm off, conditions per subscription 777 ⇒ "Draft saved"; after a reload the editor shows exactly those values. Save round-trip 2 (CONSUMER map-uns): condition method timeout 4321 ms ⇒ saved, reload shows 4321; the mapping editor lists the two method bits. (Drafts only; no deploy of the edits.) # 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 (A2a complete on this branch):** `Understood` += AlarmSubscribe (`a74a1aee`); config slice — migration/validator/ AdminUI/F-P-U tests (`ac945563`, `ee1556ac`, `6272c7cf`, helper agent); contract + codecs (`73142e52`); origin streaming + host negotiation + consumer decode (`5b03c8a2`); R tests (`14ab6be3`); codec pins (`6bb8fa69`); v1 gates extended (fake + real origin); manifest key `A2`; rig `--conditions` profile + probe scenario + `conditions_smoke.py`; byte-bounded chunks (`1977d8ce`); live smoke PASS (run `a2a-cond-2`). - **Next (A2b):** condition methods — see "Seams for A2b". ## What changed - **Contract (§4.2 numbers as planned).** `CapabilitiesResponse.conditions = 17` (`ConditionCapabilities{root_scope_items=1, methods=2, max_conditions=3}` — §4.2 left these unnumbered), `SubscriptionItem.condition_scope = 4` (`ConditionScope`), `SubscriptionFrame` arm 9 `condition_states` (`ConditionStates`, `ConditionState`, `ConditionInfo`, `ActivationMarker`, exactly §4.2). Domain types in `Core.Abstractions/DataConnections/DataConditionContracts.cs`; codecs `Commons/DataConnections/DataConditionProtoMapper.cs`. `GrpcDataConditionCodecTests` replaces the X0 tripwire for 17/4/9. - **Negotiation.** `SupportedFeatures = History | Conditions`. Effective `conditions` = header ∩ origin-servable (`caps.Conditions` present). Without it: field 17 and bit 64 are stripped from capabilities, bit 64 from metadata, and every `condition_scope` is cleared from incoming stream commands BEFORE decode (a v1 server ignores field 4, so the item is the v1 value item it would have been) — the session can therefore never produce arm 9 for a header-less stream; the `GrpcDeliverySink` refuses a condition frame on such a stream as defence in depth. - **Origin streaming.** `LocalDataServices.Conditions.cs` (servability, capabilities, `AuthorizeConditionItem`), `ConditionItemStream.cs` (per-item producer, the A1 replay contract), `DataSubscriptionSession.Conditions.cs` (items, activation after the ack is delivered, the bounded condition queue, priority selection), `OpcUaServer/OriginConditionSource.cs` (`IOriginConditionSource` over `SnapshotConditions`, resolved like the H2 history port), `LocalExportCatalog.ListConditionScope` / `ConditionLimitFor` / `MaxConditionsFor`. - Authorization (§5.5 service principal): servable, catalog ready, **Primary** (else `Unavailable`), caller usable, root resolves, an AlarmSubscribe export of the root's realm contains it (else `Denied`); per placement the export rule AND the origin ACL `CreateMonitoredItems` on the placement's scope. Re-listed only when the catalog object changes. - Snapshot: listing first; `> limit` ⇒ begin frame with `total` and nothing else, no `SnapshotConditions` call; otherwise slices of ≤ limit (NM clamps 5,000), begin frame (`total`, no records), ≤ 128-record / ≤ 256 KiB chunks, `snapshot_complete` iff `IsSnapshotCompleteFor(slices)`. - 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. ⚠️ **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`). - **Consumer decode.** `GrpcDataConnection.ClientFeatures = History | Conditions` (the probe asks for both); `conditions` is requested per endpoint iff it advertised field 17; arm 9 is decoded only on such a stream and only for a held handle. No consumer registry (A3). - **Metrics.** `otopcua.dataconn.conditions.items` (up/down), `…resyncs`, `…capacity_rejections`. ## Schema (helper agent) `20261124170120_AddDataConnectionConditions`: `DataExport.MaxConditions` (1000), `DataExport.AllowGalaxyServiceAck` (false), `RemoteNamespaceMapping.MaxConditions` (1000), `ConditionStaleTimeoutMilliseconds` (30000), `ConditionMethodTimeoutMilliseconds` (5000), `ConditionSnapshotTimeoutMilliseconds` (30000); NOT NULL with SQL defaults, check constraints `> 0`. Up/down/up on SQL Server `10.100.0.35,14330` (scratch DB, dropped), defaults verified in `sys.default_constraints`. Limits ride the artifact's entity JSON (pre-A2 artifact parses with defaults) and are not in `DataConnectionScopeRevision`. Validator: MaxConditions 1..5000 (export and mapping), timeouts 1..3,600,000 ms, `DataExportGalaxyAckInvalid` (AllowGalaxyServiceAck only with AlarmAcknowledge, so it stays false until A2b), and `DataConnectionValidator.ConditionCapacityWarnings` (Σ mapping MaxConditions × 49 > 122,500 per consumer node; shown on the AdminUI mappings panel, not yet logged on deploy). ## Tests (Phase A2 traits; manifest key `A2`) | 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`) — ⚠️ 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` | | P | Runtime | `GrpcDataConditionArtifactReadTests` (10) | | U | AdminUI | `GrpcDataConditionEditorTests` (5) | Also updated for the new understood bit/probe header: `GrpcDataOperationToleranceTests`, `GrpcDataFeatureHeaderTests`, `GrpcDataFeatureHeaderClientTests`, `GrpcDataHistoryClientTests`, `GrpcDataUnknownOperationToleranceTests`, `GrpcDataArtifactReadTests`, `GrpcDataHistoryEditorTests` (each now uses a still-reserved bit, 128+, as "unknown"). **Mutation checks (red, then restored green):** skipping the slice-watermark check ⇒ the slice-cut, deploy tests red; `snapshot_complete := true` ⇒ the incomplete-apply test red; removing `StripConditionScopes` in the host ⇒ both header-less arm-9 gates red (fake and real origin); helper agent: AllowGalaxyServiceAck rule, mapping MaxConditions bound, AlarmSubscribe authorability. ## Gates | Gate | Result | |---|---| | `dotnet build ZB.MOM.WW.OtOpcUa.slnx` | 0 warnings, 0 errors | | `run-unit-phase.py` A2, A1, H2, X0 | all passed (A1 failed once in an earlier run on `NativeAlarmInitialStateSignalTests.A_native_transition_leaves_the_F5_pending_set…`, an A1 timing test untouched here; 6/6 green alone, then green in the final phase run) | | Host.Tests `.DataConnections.` | 201 passed (both v1 gates included) | | Runtime.Tests (`Category!=E2E&Category!=LiveIntegration`) | 1980 passed, 3 skipped (first run: the revocation test raced the worker teardown — fixed by awaiting `Completion`; `VirtualTagActorTimerTests.Ticks_during_a_slow_run…` failed once under load, 3/3 green alone, unrelated) | | OpcUaServer.Tests | 1439 passed, 1 skipped | | Commons / Core.Abstractions / Configuration / AdminUI | 510 / 860 / 343 / 2703 passed | | `test_unit_phase_runner.py` + `tests/test_compose_fixture.py` | 35 passed | ## Live smoke (rig) — run `a2a-cond-2`, PASS Standalone rig (OrbStack), build `d3a4e70f6` (clean tree, recorded `source_tree_hash` `b6c0019b8b01b7f9…`; normal build-hash checks, no pinning). ```bash python3 scripts/validation/grpc-data/rig.py up --run-id a2a-cond-2 --conditions --timeout 1200 python3 scripts/validation/grpc-data/rig.py seed --run-id a2a-cond-2 # ~80 s for CONTROL's ClusterNode contact refresh python3 scripts/validation/grpc-data/rig.py deploy --run-id a2a-cond-2 --timeout 300 python3 scripts/validation/grpc-data/conditions_smoke.py --run-id a2a-cond-2 python3 scripts/validation/grpc-data/rig.py down --run-id a2a-cond-2 ``` | Item | Observed | Result | |---|---|---| | Capabilities without / with `conditions` | source-1 (Primary): ops 31 / 95, no field 17 / `{rootScopeItems, maxConditions 1000}`; source-2 (Secondary): 23 / 87, same field | PASS | | Primary: condition item on the UNS equipment root | ack Good; begin `total` 1; one record `ScalarHigh` — active, `state_known`, severity 500, info `{nsu=http://opcfoundation.org/UA/;i=2915, ScalarHigh, SCRIPTED, uns|source-scalar-high}`; `snapshot_complete`; frames Ack, ConditionStates ×3 | PASS | | Delta | probe sets scalar 0 ⇒ one delta record, same key, version 3 → 4, inactive, known, no info | PASS | | No RawPath on the UNS stream | no `modbus/plc` in any record | PASS | | Secondary | condition item ack `Unavailable` (Primary-only) | PASS | | Teardown | `rig.py down`; no run-labelled containers, volumes or networks left | — | Earlier attempts (kept as history): `a2a-cond-1` — first the smoke script lacked `ScenarioRunner.publish()`/deadline; then the probe addressed the equipment root by path instead of its catalog identifier (`NotFound`) and with the wrong subject (`Denied`); fixed in `d3a4e70f6` (harness only), then a fresh run. The CONSUMER's AdminUI page now shows "Negotiated features Conditions" (the consumer probe asks for `conditions`; nothing else changes until a condition item is opened). **Not verified live:** the AdminUI condition editor fields (the page returns 200 with the prerendered diagnostics; the editor modals were not driven — no bUnit, needs a browser drive in A4 or the next rig session). ## Decisions 1. **No `Control NotReady` kind.** §5.1 says "until then the stream sends a Control NotReady"; `DataStreamControlKind` has no such member and a new kind would be a new v1-decoder shape. Readiness is expressed by withholding `snapshot_complete`; the item retakes the snapshot (≥ 1 s apart) once the hub reports apply-complete + Primary. 2. **Priority = control/ack at the head, then conditions, then the v1 queue in FIFO order.** A v1 control queued behind a value keeps its v1 position (snapshot begin/end ordering depends on it); conditions overtake queued values and never a control/ack that is next. 3. **Overflow.** Production is pull-based (≤ the 16-frame condition queue), so the session queue never overflows; the hub is the buffer. A hub reader reset ⇒ the item re-snapshots (counted as a resync). A reset while the item's previous snapshot is still undelivered ⇒ stream `Reset` ("Condition stream overflow; retry later."). 4. **Over capacity parks the item** (begin frame with `total` only) until the catalog object changes (a deploy). 5. **AlarmSubscribe without Subscribe opens a stream** when the call negotiated `conditions`; header-less keeps the v1 `PERMISSION_DENIED`. 6. **Origin ACL per placement = `CreateMonitoredItems`** (what v1 Subscribe checks; ReadOnly includes it). 7. **`ConditionStateRecord` gained `ConditionType` (`nsu=…;i=…`), `ConditionName`, `ConditionClass`** (ns=0 class id) for `ConditionInfo` / `condition_class`; `BuildConditionRecord` fills them. 8. **Migration carries every A2 column**, including `AllowGalaxyServiceAck` and `ConditionMethodTimeoutMilliseconds`, so A2b needs no schema change. ## Deviations - The plan's `MaxConditions` per hold is the **export's** `MaxConditions` at the origin (the request carries no mapping limit); the mapping's own `MaxConditions` is the consumer's admission (A3). - The capacity warning helper is not wired into the deploy path (`AdminOperationsActor.StartDeployment`) — question Q2. - AdminUI live verification on the rig's admin port is not done (see "Live smoke"). ## Seams for A2b - **Bits:** `DataOperationSets.Understood`/`Reserved` (`DataContracts.cs`), `DataConnectionValidator.KnownOperations`, and `LocalDataServices.Implemented(target)` (gate on `ConditionsServable`) — add 128/256 together; `GrpcDataOperationToleranceTests` pins the sets. `DataOperationAuthoring.AuthorableOperations` (AdminUI) for the checkboxes. - **Columns already present:** `DataExport.AllowGalaxyServiceAck` (+ validator rule `DataExportGalaxyAckInvalid`, not in the catalog `ExportRule` and not in the AdminUI yet), `RemoteNamespaceMapping.ConditionMethodTimeoutMilliseconds`. - **Capabilities:** `DataConditionCapabilities.Methods` (0 today, `LocalDataServices.ConditionCapabilitiesFor`) and `DataConditionInfo.SupportedMethods` (0 today, `ConditionItemStream.Map`). - **Origin port:** `IOriginConditionSource` / `DeferredOriginConditionSource` / `SdkAddressSpaceSink` — put `TryExecuteConditionMethod` beside `SnapshotConditions`, same deferred resolution. - **Placement resolution:** `LocalExportCatalog.TryResolveConditionPlacement` (A1) + `AllowsConditionPlacement(principal, placement, operation)`; the ACL pattern is `LocalDataServices.AuthorizeConditionItem`'s placement filter. - **Activation marker:** the wire carries NM's `ConditionIncarnation` GUID verbatim in `ActivationMarker.incarnation` (A1 open question: serving incarnation vs NM lifetime GUID — decide in A2b). - **RPC:** proto has no `CallConditionMethod`; `GrpcDataConditionCodecTests` and `GrpcDataHistoryCodecTests` pin 7 methods. Add it to `DataConnectionEndpoints.Methods` (H2 lesson) and refuse it without `conditions` (`ConditionsNegotiated`). - **Recorded-v1 gates:** both fake and real origins now serve conditions (`conditions: true` default in `V1CompatibilityHarness` / `RealOrigin`); extend them for the method shapes the same way. ## Questions (tracked, not asked) - 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? **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).