Files
lmxopcua/docs/plans/evidence/grpc-data/p05-astra-review.md
T

14 KiB

P05 Astra implementation review

Disposition: approved for P05 source freeze. All three findings below are resolved in the reviewed correction candidate and complete applicable gate. The final gate passed 910 tests with zero failures/skips. This is a P05 checkpoint, not approval of the complete data-connection feature.

The review is read-only except this evidence document. No reviewer builds, tests, production changes, migration execution or Docker work were performed. Scope covers Task 11/12 admission, actual actor invocation, publication fencing, operation retention, physical resource lifetime, SDK rich completion, Modbus rich no-resend handling and exact value/metadata fingerprints. The plan, design obligations and execution ledger informed the review.

Candidate and verification evidence

Final complete gate artifacts/grpc-data/20261116T084759.594405Z-42a294fc7f4f/unit/P05/run.json reports 910 passed, zero failures/skips: Runtime 195, SDK 70, Core 29, Modbus 593 and Core.Abstractions 23. Every new and required existing class is represented in execution; this gate has no platform exclusions. Before this final review-document edit, the reviewed checkout matched its recorded baseline 70f50201e9140aa51b64b289e608c3bea4061003, tracked binary-diff SHA-256 5c12ff3d22f130314af6e84055bb94200682167f6decfe841c0fd57ca77fcd5a and all 19 recorded untracked file hashes. That includes 16 source/test files and three review documents. This document's disposition update is the sole reviewer change after reconciliation.

The preceding complete gate 20261116T082435.847137Z-41e436e72d95 passed 906 tests but did not cover the three issues found during source review. Its tracked diff SHA-256 was 8f3d9145aeff119443b6b9d9028e6ee897f1c0be8455962f235a968631f6968a; its 18 recorded untracked hashes also matched the then-reviewed checkout. The additional correction regressions are included in the final 910-test gate.

The execution ledger records the actual failing tests preceding the existing corrections. Relevant evidence includes physical same-target RED 20261116T072907.706321Z-c0a3b2178516, late-retention RED 20261116T072347.015611Z-61960f01d936, observer-expiry RED 20261116T074826.305696Z-f170f189f3b8, real actor ordering RED 20261116T071731.988476Z-ab7eaaea4c9b, membership callback ordering RED 20261116T080834.575675Z-a81b507a518b, SDK RED 20261116T065427.180129Z-23fa1d306a25, and canonical metadata hashing RED 20261116T082102.902677Z-dd7a6a847714. The complete gate covers their corrected candidates.

H1 — Mismatched Modbus exception can trigger a second mutation

Severity: High. Status: resolved. In the initially reviewed src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Modbus/ModbusDriver.cs:1568, SingleSendWriteTransport correctly declined to classify a mismatched exception function as a definitive refusal, but rethrew the original ModbusException. TryWriteViaFc23Async at line 1830 caught every exception with code 0x01, without matching the requested function, and returned false. WriteOneAsync then sent FC16 as its fallback.

Consequently an FC23 request followed by a matching transaction/unit but mismatched exception function, for example FC6/code1, can issue a second mutation after an ambiguous first response. Transport-level retry is disabled, but this driver-level fallback still violates the rich no-replay boundary. The existing wrong-function test mutates a normal FC23 response and does not exercise the exception catch.

Reject a mismatched exception function as an invalid/ambiguous response before the rich path reaches the legacy fallback, or constrain that fallback to the exact requested FC23 function. Preserve fallback after a valid FC23 Illegal Function response, which proves that request did not perform the write. Add a regression with an exact physical send/effect count: malformed exception response must yield Unknown and one send; valid FC23 Illegal Function may still lead to the safe FC16 fallback. A real TCP fixture is preferred because this crosses the response parser and fallback together.

Resolution: the rich wrapper now converts a mismatched write exception function to InvalidDataException before the FC23 fallback catch. Its definitive-refusal flag remains false and the outcome is Unknown. Actual RED 20261116T083756.925253Z-ac0395f545eb passed 21 tests and failed this new case by incorrectly reporting confirmed success. Focused gate 20261116T084606.160092Z-73c1868a8b65 then passed all 22. The real TCP regression verifies an FC23 effect followed by 0x86/0x01 produces one request, one effect and Unknown; its positive counterpart verifies exact 0x97/0x01 permits two requests but one effect through FC16. Both pass in the complete final gate. The change is confined to the rich wrapper and preserves legacy behavior.

H2 — Current key expiry is not rechecked at dispatch commitment

Severity: High. Status: resolved. The initially reviewed src/Server/ZB.MOM.WW.OtOpcUa.Runtime/DataConnections/DataWriteDispatchGate.cs:36 checked current key usability before acquiring the publication fence. The final fenced check at line 49 checked only the ticket's original CredentialExpiresUtc. Current key expiry can be earlier than that original timestamp, or the original timestamp can be absent: changing a deployed key's expiry does not change its secret-derived credential version.

A context authenticated under a nonexpiring/later-expiring key can remain usable after its key's expiry has been shortened. If the current key is still valid during policy evaluation but expires while this invocation waits for the fence, authority/catalog references remain unchanged and the final check can commit dispatch after current key expiry. The existing expiry regression advances time before policy evaluation and uses the caller expiry, so does not establish this boundary.

Inside the final short fence, recheck the already captured immutable authority's key binding and expiry against the current time, as well as the original context expiry. Keep permission evaluation and callbacks outside the fence; expose a bounded immutable credential check rather than invoking the evaluator there. A deterministic regression should hold the fence after policy succeeds, advance UTC across the current key expiry while original expiry is null/later, release it, and verify a terminal undispatched rejection with zero backend calls.

Resolution: the gate captures current enabled key facts and verifies principal/credential version from its captured immutable authority before policy evaluation. It keeps the current key expiry as a local value. After acquiring the fence it checks both this expiry and the original context expiry against one fresh UTC sample, while the authority identity check ensures those captured facts remain authoritative. Hashing, key copying and permission evaluation remain outside the fence. Actual RED 20261116T084157.535508Z-509aba58e961 passed 22 tests and failed the real actor/current-key-expiry case by confirming the write. That regression holds the fence, waits for the last successful policy UTC read, advances time beyond current key expiry with a null original expiry, and verifies rejection/zero device calls; it passes in the final complete gate. Taking the UTC sample at the start of this short fenced block is acceptable: the remaining checks are bounded immutable reads with no await, permission evaluator or driver callback. The correction closes the demonstrated fence-wait expiry gap without promising an atomic wall-clock-and-CAS instruction.

M1 — Role-wrapper refresh makes acquisition callbacks block again

Severity: Medium. Status: resolved. The initially reviewed src/Server/ZB.MOM.WW.OtOpcUa.Runtime/DataConnections/LocalCatalogCoordinator.cs:61 called blocking DispatchFence.Enter() when Current had to replace its cached serving-role wrapper. P04 approved that accessor as a bounded lock-free read/CAS path. SourceSamplePublisher.TryPublish calls its supplied serving provider at SourceSamplePublisher.cs:338 while in the producer callback and per-source gate; the coordinator-backed provider traverses Serving and Current.

A role mismatch while another thread holds the dispatch fence therefore makes the new ingress wait, despite the surrounding source and hub gates using nonblocking acquisition. The scope is the production coordinator-backed source provider; it does not depend on an arbitrary malicious callback.

Use a nonblocking fence acquisition for read-side wrapper refresh and return an appropriate unavailable/provisional identity on contention, or arrange control-side publication with lock-free reads. Preserve current producer identity and actual acquisition timestamps; dropping a contended acquisition must not replay it later as fresh. Add the composed regression: coordinator-backed publisher, cached role mismatch, another thread holding the dispatch fence, and a producer callback that completes without waiting for that holder.

Resolution: DataWriteDispatchFence.TryEnter uses Monitor.TryEnter with no wait. The bounded Current refresh returns null on contention; Serving then provides actual process identity/current role with provisional zero epochs, as permitted by the P04 acquisition boundary. Source publisher and hub remain unchanged. Actual RED 20261116T084419.395301Z-6c55e8767242 passed 19 tests and failed the new callback case because it waited for the fence. The composed publisher/coordinator regression now completes before the held fence is released, preserves the active producer, and verifies a subsequent real acquisition's value and original source timestamp. It passes in the final complete gate. Public serving still requires the established catalog/authority validation; provisional raw retention does not make a public catalog ready.

Resolved earlier findings and reviewed behavior

  • The earlier physical-lifetime review is superseded for its two findings: LateWriteObserver now reserves the global slot and (driver ID, reference) key together, using driver OrdinalIgnoreCase and reference Ordinal. Release follows actual raw invocation completion, including synchronous blocking before a task is returned. Caller timeout, observer expiry and actor replacement do not release that target. Real actor regressions use capacity two, prove another target progresses, and cover replacement driver ID case variation. Local actor slots can still be abandoned as in the legacy path.
  • Accepted definitive LateRefine updates the retained-result timestamp before physical completion becomes visible. The one-minute registry/five-minute observer regression confirms a result arriving after two minutes remains Existing for its new result-retention window. Previously completed Unknown waiter tasks stay immutable; current retained outcome supplies the refinement.
  • The actual rich driver call is inside the non-idempotent resilience invoker delegate. Ticket validation runs there immediately before the dispatch CAS. Driver code, permission evaluation and authority notifications run outside the short publication fence. Authority/catalog/route/lifetime and primary-generation publications share the fence; remap-away-and-back and demote/promote do not revive old proofs. H2 now also checks current-key expiry after fence acquisition.
  • Dispatch and proven no-call rejection compete through the claim transition. Released queued tickets cannot later invoke the driver. The raw-task observer alone publishes definitive dispatched results; outer Ask/invoker replies can establish no-call rejection or Unknown but cannot refine beyond observer retention. Payload and physical capacity remain charged until the actual invocation exits.
  • Executor admission uses authenticated context, resolved catalog view and trusted route, enforces authorization/export/write/type readiness before dispatch, retains its own value lease, joins duplicate operation IDs without tying shared work to a waiter's cancellation, and preserves per-item input order. Registry principal comparison matches case-insensitive principal identity while operation IDs remain ordinal. Internal canonical fingerprints preserve typed shape, ordinal UTF-16 including unpaired surrogates and floating-point bits without a payload-sized hashing copy.
  • SDK rich completion is asynchronous and uses the exact node/write stamp. Rejection/confirmed failure restores prior authoritative value, status and source timestamp. Unknown/AcceptedUnconfirmed restores the prior value/time with UncertainLastUsableValue. Equal-valued fresh source updates, newer writes and recreated nodes cannot be overwritten by stale completions. No optimistic value is published to the sample hub by this seam.
  • Modbus rich TCP and RTU-over-TCP calls disable transport resend after ambiguous loss and keep legacy recovery behavior. Valid normal echoes/readback shape are checked, and real TCP dropped-reply-after-effect evidence exists. H1's mismatched-exception fallback hole is resolved by the rich wrapper and actual TCP regression.
  • Runtime DI supplies one shared dispatch fence without overriding an explicit registration. Production data service wiring belongs to P07; the SDK hook remains unbound until the authorized P08 mapping route exists. Real endpoint failover belongs to P07/P08, not a fabricated P05 client.

The target exclusion guarantee is limited to rich-to-rich known pending raw tasks in this process. It does not promise universal device ordering against legacy abandoned operations, different references naming the same device storage, fire-and-forget application after a task returns, or another process. Those limitations do not excuse replay of a known ambiguous mutation or dispatch using expired current credentials.

The focused correction rereview and reconciled complete applicable gate satisfy the P05 checkpoint. No P05 findings remain open; dependent implementation may proceed subject to its own planned gates and review.