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

25 KiB
Raw Blame History

P07 remote lifecycle Astra review

Final disposition: approved for P07. The final reconciliation below closes the historical remote and deployment-runtime findings. The superseding full P07 run 20261116T160335.804917Z-5a4994c32d15 passed 393/393 applicable tests with zero failures/skips; Runtime passed 220/220. Later integration/scaling/full-implementation gates remain pending.

Initial checkpoint disposition (historical): the initial remote packet was not approved; the findings below required correction and focused evidence. This source review covered the frozen DataConnectionManager, GrpcDataConnection, ClusterEndpointSelector, DataConnectionRoleAdapter, and their initial tests. New regression test preparation began while review continued; no new failing/passing result was inferred from test source. No builds, tests, Docker commands, or commits were run by this reviewer. The earlier coordinator run 20261116T125221.449960Z-a59846699d1c recorded 59/59 passed, zero failed/skipped, for the initial focused packet and affected session/role tests; its run record was independently read. It did not close the new findings or establish final Host integration.

Findings

P1 — Retired channels are uncharged while physical cleanup can remain blocked

RetireAll clears the entire active channel dictionary, discards each CancelAsync task, and queues a separate Channel.Dispose callback (GrpcDataConnection.cs:70-78). A subsequent acquisition can immediately create another channel under the same maxChannels allowance. Repeated security changes while a handler's Dispose is blocked accumulate old physical channels, callbacks, and queued disposal work without a bound tied to admission.

Keep retired physical ownership charged until cleanup actually completes, with a bounded/coalesced retirement path and explicit admission behavior while saturated. Do not make a global lock wait for arbitrary transport disposal. Regress one allowed channel, gated handler disposal, repeated security rotations/new acquisitions, and eventual progress after releasing cleanup. A logical dictionary removal or cancellation request is not physical completion.

P1 — Scope revision churn admits unlimited unresolved cancellation generations

DataConnectionManager.ApplyScope removes the old State, starts and discards CancelAsync, then immediately admits the replacement (DataConnectionManager.cs:44-50). Dispose similarly drops all states before cancellation callbacks complete; ScopeLease.Dispose has no ownership effect (:63-76). With maximumConnections=1, a blocked registered cancellation callback and repeated revisions create an unbounded sequence of retained old states/tasks while the active dictionary still contains only one entry.

Give retired scope generations explicit bounded ownership through actual callback/lifetime cleanup and coalesce newer desired revisions. Retire outside the global lock while preserving immediate denial of the old generation. A replacement must not evade capacity merely by changing its revision or ID. Regress blocked cleanup, repeated same/different IDs, outstanding leases, and recovery to the latest desired revision after cleanup completes. Preserve stale-generation denial after scope removal/readdition.

P2 — Discovery and failover renew an item's original write budget

The client records one batch start time but sends each item with min(original item.RemainingBudget, remaining batch budget) (GrpcDataConnection.cs:249-251). It never subtracts elapsed discovery, first-attempt, or retry-metadata time from the item's own original budget. An item with 500 ms remaining in a five-second batch can still be dispatched for another 500 ms after discovery already consumed 600 ms.

Track each original item expiry against the same monotonic start and reduce it across all work/attempts. Do not dispatch an expired item; retain the proper no-dispatch result without preventing still-live items from progressing. Regress delayed capabilities and retry metadata with fake time, including mixed short/long item budgets and the original batch deadline. Never restart the item budget when changing endpoints or semantic preconditions for a proven rejection.

P2 — The receiver accepts retired-handle reuse and sample-version regressions

Ack validation rejects collisions only with the currently active _handles dictionary (GrpcDataConnection.cs:417-443). Remove and Modify delete old entries, so a later acknowledgment can reuse a retired numeric handle/revision for another view. A late old value then passes the ordinary handle lookup. Separately, ReadAllAsync validates frame sequence and serving identity but does not track per-handle sample versions before yielding values (:384-399, :454-457). A new frame sequence with a lower sample version is therefore exposed.

Enforce the contract's epoch-local no-reuse and monotonic value rules with bounded state and an explicit reset/admission policy when its bound is reached. Do not assume opaque handles are ordered unless that becomes an explicit negotiated contract. Regress remove/add and modify reuse, a late old value after the attempted reuse, and sample version 100 followed by 99 under the next valid frame sequence. A legitimate new stream epoch/new handle must still establish a fresh baseline.

P2 — Acknowledged commands retain timers and caller-owned payload graphs

Every SendAsync stores the original caller command and starts an independent expiration task (GrpcDataConnection.cs:350-368). Successful acknowledgment removes only the pending dictionary entry (:447-451); the delay task still captures the complete command until the original timeout or stream cancellation. A healthy acknowledged burst can retain up to the lifetime command cap (100,000) worth of item lists/timers, with no pending-byte charge. The pending-count limit does not bound this already-acknowledged retention.

The command's IReadOnlyList may also be backed by a mutable caller collection. Because pending state retains that same object, mutation after SendAsync can change later acknowledgment expectations even though different items were actually sent.

Admit bounded owned command state before asynchronous work, copying the necessary semantic/ack identity and enforcing local count/byte limits. Release its deadline and retained state on acknowledgment or failure. A bounded shared deadline scheduler or correctly canceled per-command ownership can work; successful ACKs must not leave full payload graphs sleeping until timeout. Regress acknowledged churn with long timeouts and bounded outstanding work/bytes, plus caller collection mutation after send. Retain duplicate-command fencing without allowing unlimited historical IDs.

Source properties and remaining evidence

  • The selector now requires the expected cluster, explicit Node pin, ready state, and either Primary or an explicitly permitted Secondary replica read. Unknown roles deny. The role adapter delegates Warm/Hot decisions without performing an election. These helpers do not establish final Host role gating by themselves.
  • Channel identity includes credential version and trust fingerprint. A generation captured before security resolution is checked before installation, which rejects a retired security snapshot. The initial test source includes rotation during resolution. Preserve this when introducing owned retirement accounting.
  • Unary response envelopes and nested read samples are checked against selected provenance. Mutation retries are limited to explicit rejected items; initial lost replies become OutcomeUnknown. The implemented demotion exception accepts only an entirely rejected batch from the same node/boot. This is a conservative subset of the contract discussion, not permission to replay other items after a role mismatch.
  • Original per-item budget handling above remains incorrect despite the correctly retained batch start. A passing lost-reply test does not establish all retry/deadline semantics.
  • Stream count must have a receiver-owned local ceiling independent of a peer-advertised MaxStreams. A new test for this was being authored during review; its production/API repair and actual result are not claimed here.
  • The initial tests mainly cover selector/scope helpers, unary fake-wire paths, and security-resolution generation. Add actual duplex fake-wire lifecycle cases for command ownership, acknowledgment timeout, handle reuse/version regression, retirement while reads/writes are blocked, and final release of stream/transport work. Cancellation that stops waiting must not release quota for still-owned physical work or allow unlimited replacements.
  • Verify bounded no-ready-primary backoff, channel retirement under failure/churn, scope/revision removal, and fresh stream epochs/snapshots after role or endpoint changes at the completed connection-manager boundary. No ready-endpoint or reconnect behavior is established by an immediate one-pass selector loop alone.
  • Credential/trust rotation may close the client route and produce an ambiguous result, but cannot replay or relabel an already dispatched mutation. The original origin-side bounded outcome observer must survive; final Host/remote tests must establish that composition rather than infer it from token cancellation.

These are source findings and concrete regression requirements, not a final network/TLS/Docker review. Packet closure requires frozen repairs and actual focused results, followed by the full P07 gate and integrated source review.

Follow-up: physical HTTP ownership, 2026-11-16

The current source repairs the initial channel/scope accounting direction: retired channels remain included in channel admission until both cancellation callbacks and actual channel disposal finish; retired manager states retain their slots until cancellation completes and all scope leases release. GrpcDataConnection.DisposeAsync retains its scope lease until its active work, streams, and retired channels drain. These observations supersede the old implementation descriptions above; full packet evidence/disposition remains pending.

The coordinator reported Runtime run 20261116T132916.652106Z-dca2192d7e9c as 22 passed / 3 failed. Two failures were the deliberately unbound prepared-publication guard regressions. The ignored-HTTP-cancellation case timed out because it awaited the first unary result before releasing its intentionally blocked handler. That timeout is not evidence that unary admission was released early. The repaired handle/list/sample-version and original-item-budget cases passed in that reported run. This reviewer did not run the tests.

Unary Send/body reads: no demonstrated need for a raw HTTP tracker

The exact pinned grpc-dotnet v2.76.0 GrpcCall source was independently inspected. CancelCall (lines 424–450) completes the overall _callTcs and requests cancellation but does not complete unary _responseTcs. RunCall directly awaits raw HTTP SendAsync (493–496) and, for a unary response, the body read (563–568). Its response task is completed only afterward (602/647). Current QueryAsync and WriteAsync retain _unaryCapacity and _activeWork through that actual ResponseAsync await. An ignored Send cancellation or body-read cancellation therefore keeps the current unary admission charged. Do not add a blanket HTTP wrapper on the basis of the timeout above.

The correct regression holds the raw work, asserts the first unary task is still incomplete and another call is rejected by unary admission, then releases raw work before awaiting the first task and proves recovery. A handler's Disposed signal alone precedes completion of FinishChannelRetirementAsync; a generic capacity exception can otherwise accidentally assert the retiring-channel charge instead of the unary charge.

P1 — Duplex disposal can release its slot before preheaders HTTP work ends

Current SubscribeAsync returns immediately after starting the duplex call (GrpcDataConnection.cs:397–408). RemoteSubscription.ClosePhysicalAsync marks _physicalClosed when lifetime.Cancel and call.Dispose return. With no active Send/MoveNext, this releases _activeStreams, although the pinned gRPC RunCall can still be awaiting a raw /Subscribe SendAsync that ignores cancellation. A MoveNext waiting for response headers does not fix this: cancellation eagerly cancels ClientStreamReader.HttpResponseTcs, allowing that operation to finish before raw Send ends. Repeated open/dispose on one unchanged channel can therefore exceed the configured physical stream bound.

A narrow completion receipt is available without a raw handler/content wrapper: retain the owned stream through call.ResponseHeadersAsync as well as disposal and current operation counts. In the pinned source, GetResponseHeadersCoreAsync:308 awaits the distinct _httpResponseTcs, which is set only after raw Send completes or throws (RunCall:497/637). Neither cancellation, deadline cancellation, nor Dispose eagerly completes that TCS. This proves preheaders Send completion, not body-read/write completion; keep the existing operation ownership for those phases. Require actual no-reader and preheaders-reader negative regressions, bounded replacement denial, and recovery after releasing the handler. Repair/evidence are pending.

P1 — Subscription discovery runs before bounded admission

SubscribeAsync:375–391 increments the unbounded _activeWork counter, then performs SelectAsync/GetCapabilities before reserving _activeStreams; it never takes _unaryCapacity. Concurrent subscription setup can thus launch arbitrarily many blocked capabilities HTTP operations despite both local limits being one. Reserve a bounded local stream/setup slot before discovery, validate the peer limit after discovery, and transfer that same reservation into the returned stream. Release it only after actual setup/owned transport work settles, including failure and cancellation. A deterministic regression must block capabilities discovery and prove a second setup is rejected without invoking another Send. Repair/evidence are pending.

These two new findings are confined to duplex/setup ownership. They do not justify changing the already-held unary path, and neither the source direction nor the reported partial run constitutes full P07 approval.

Frozen repair checkpoint: 192 selected tests

The reviewer independently read 20261116T134802.525866Z-44c634f2fd5c/unit/P07/run.json and all five TRX files: 192 passed, zero failed/skipped (Host 66, Runtime 82, Commons 41, Configuration 2, ControlPlane 1). This is a component checkpoint, not completed P07 integration. Host mapping, DI/actor composition, and deployed-scope/bundle activation remain unimplemented at this point.

The frozen remote source now retains channel retirement through actual disposal/cancellation and manager scope retirement through callbacks plus outstanding leases. Per-item write time is reduced by elapsed discovery/attempt time. ACK expectations use an owned copy from the encoded command; retired numeric handles remain fenced with bounded history, and sample versions cannot regress. The focused cases for those changes passed. Query/discovery backoff has bounded exponential delay with jitter, security change clears it, and a bounded per-connection stream-ID/epoch fence denies reuse. The normal installed-stream path now awaits the exact pinned gRPC ResponseHeadersAsync receipt before physical-close completion; both no-reader/preheaders-reader regressions passed. Local stream reservation now precedes discovery, and its blocked-discovery regression passed. Ignored unary Send and body-read cases passed while keeping existing unary admission charged. No raw HTTP wrapper was added or is required by those cases.

P1 — Disposal between duplex creation and registration bypasses the new receipt

In SubscribeAsync, the raw duplex call and RemoteSubscription (which captures _headersReceipt) are created before _sync is acquired to install the stream. If connection disposal wins that race, the _disposed branch calls call.Dispose() and throws. The catch disposes lifetime and the outer finally releases the setup reservation and _activeWork, without awaiting the constructed subscription's headers receipt. An ignored preheaders raw Send can therefore outlive all stream/scope ownership on this failure path. The passing installed-stream tests do not cover it.

Require a deterministic after-call-creation/before-installation race with connection disposal and an ignored raw Send. Every path after raw call creation must transfer ownership to a closing subscription or retain/await its physical completion before releasing setup/scope charges. Do not wait for transport cleanup under _sync. Source repair and actual regression are pending.

P2 — Canceled command timers still capture uncharged acknowledged metadata

ExpireUnacknowledgedAsync(PendingCommand pending) captures the record containing ClientIds/Removed arrays across Task.Delay. A successful ACK removes that record and releases _pendingBytes, then cancels/disposes the timer. Its queued cancellation continuation can still retain the record and arrays until it executes. A rapid ACK burst can therefore retain substantially more metadata than the current pending-byte allowance while only the much smaller historical command-ID charge remains. The mutable-list test establishes copying, but there is no acknowledged-churn/retained-byte regression in this checkpoint.

Make the expiration task capture only a small command ID plus timer/identity token, using the pending dictionary to resolve live work at expiry, or retain the byte charge until the actual expiration task exits. Add deterministic delayed-cleanup/ACK-churn coverage. This is a command-state ownership issue; it does not call for a transport wrapper. Repair/evidence are pending.

Remote repair closure: Runtime 103/103

The reviewer independently read run 20261116T141626.988288Z-e977454116c3 and its TRX: 103 Runtime cases passed, zero failed/skipped, including the two latest regressions and the earlier installed/preheaders/discovery/ignored-cancellation cases. The frozen GrpcDataConnection and manager repairs close the remote findings recorded above at this component boundary.

  • Failed stream installation now transfers the reservation to the created subscription even when connection disposal wins; asynchronous cleanup remains outside _sync, the captured headers receipt still owns preheaders raw Send, and the stream remains counted until that receipt and active operations complete. The deterministic disposal-before-install regression verifies connection disposal and scope replacement remain blocked until the raw handler is released.
  • The expiry task now receives only command ID, timeout, and timer; it compares timer identity against the live dictionary entry. It does not capture PendingCommand or its item arrays across the delay. The regression delays the canceled timer continuation and uses a WeakReference to prove the acknowledged PendingCommand can be collected before that continuation resumes.

No additional actionable defect was found in this frozen remote client/manager rereview. This is not P07 approval: the newly authored deployment registry/activation path was explicitly outside this review, and real Host DI, deployed scope/bundle application, final role authority, and integrated gates remain outstanding. The separately reviewed observed-role actor issue is recorded in p07-contract-astra-review.md.

Deployment-runtime source checkpoint — availability findings open

The registry now owns one reconciliation worker, bounded desired definitions, the existing manager's active/retiring capacity, and connection retirement tasks through physical client cleanup. BeginAttempt denies routes before fallible local artifact processing, and matching attempt/generation checks prevent old asynchronous scope activation from reopening them. No additional physical-transport ownership defect was established in this inspection. The scope-store retry defect already under coordinator repair is not counted again here.

P2 — A transient role-read failure can permanently empty the connection manager

Registration's coherent role capture uses TryEnter, returning Unknown on temporary dispatch-fence contention. ApplyManagerScopeLocked converts that one false eligibility observation into an empty manager scope (DataConnectionDeploymentRuntime.cs:175–180). ReconcileAsync can subsequently observe an active role and valid credentials but calls manager.Acquire against the still-empty scope; the denial is swallowed and no retry or scope reinstatement follows (:277–314). The same transient false during reconciliation can exit its only worker pass. No actual role transition need occur to wake it again.

Keep acquisition fail-closed during contention, but reconcile the manager's desired scope after a current eligible observation and retain one bounded retry for temporary uncertainty. Regress false only on the initial eligibility read, as well as contention lasting through the first reconciliation pass; after release, the configured route must become acquirable without another artifact, credential, or role event. Source repair and observed regression results are pending.

The scope retry alone does not cover ResolveAsync failures: reconciliation catches those exceptions or receives null and leaves that configured connection absent without another wake. The concrete Host credential resolver deliberately converts store exceptions into false/null, so retrying only thrown runtime exceptions is insufficient. Extend the existing owned backoff mechanism to a typed temporary resolution result or bounded retries for unresolved current entries, preserving immediate event wakeups and disarming on newer attempt/disposal. Regress a fail-once local credential/trust store read with no unrelated external event. This is part of the availability repair, not a request for per-entry tasks or extra device/network polls.

No P07 approval is granted at this checkpoint; tests/builds were not run by the reviewer.

Final Runtime repair closure

The reviewer independently verified the frozen final P07 run and all five TRXs: 392/392 passed, including Runtime 219/219. Candidate identity is reconciled in p07-contract-astra-review.md. Earlier Runtime 218/218 in 20261116T154535.379541Z-6ea9fe4e2f4b established the original scope-store, transient-role, and null/exception security-resolution repairs, but did not close the subsequently discovered two-link case.

That final case was observed failing in 20261116T155211.129165Z-316e31f82ca8 (deployment activation 22/23): rotating A during a transient false role read canceled B's manager token while retaining B as a Ready entry. The repaired ApplyManagerScopeLocked now always represents the validated configured consumer allowlist, independent of role observation. A's security change advances only A's route revision. B's lease remains current, while A retires and recovers. The same regression passes in the final gate.

This separation does not open Standby access: reconciliation checks current role before creating a client, TryAcquire checks it before issuing a handle, and every borrowed-operation boundary checks it again. The raw manager/client entry remains private. Explicit NotifyConsumerRoleChanged still clears all entries and advances every route revision to drain prior physical work; BeginAttempt still applies an empty manager scope before parsing a newer artifact. Existing actual owner/role and Warm tests remain green.

One owned timer and one coalesced worker now recover current unresolved local material and transient role/scope reads with bounded backoff. Null and thrown security results are both covered; newer attempts and disposal disarm the timer, and delayed results must match the latest generation. No per-entry retry task or device poll was added. Existing physical channel/stream/header-receipt/cancellation accounting and command metadata ownership remain verified by the full selected gate.

No actionable remote/runtime finding remains for P07. This approval does not claim deployed network failover, TLS behavior, CLI interoperability, or capacity measurements; those remain P10/P11, with final integrated review in P12.

The later pre-commit credential-expiry lease finding is closed in the superseding 393-case candidate. Browse branch leases and continuations now share a duration capped by the original target credential's remaining lifetime; GetMetadata objects carry no standalone lease. Source identity, actual RED, all five final TRXs, and the reaffirmed approval are recorded in p07-contract-astra-review.md. No remote transport/lifetime source changed for that narrow repair.