diff --git a/docs/plans/evidence/grpc-data-ext/H3.md b/docs/plans/evidence/grpc-data-ext/H3.md index f27bfbe42..464425720 100644 --- a/docs/plans/evidence/grpc-data-ext/H3.md +++ b/docs/plans/evidence/grpc-data-ext/H3.md @@ -139,7 +139,7 @@ while held, 0 after the session closed; `down` ⇒ 0/0/0/0 for both runs. **Found on the re-run (pre-existing v1 projection behaviour, not an H3 defect — for a follow-up):** an idle projected node's authority lapses with its 15 s `MetadataLeaseMilliseconds`; any read after that is `BadUserAccessDenied` — a value Read exactly as a HistoryRead (reproduced in the Runtime harness) — and a re-browse served from the still-cached browse page does not renew it -(live: the H06 rebuild leg denied right after a re-browse). The gate now starts each held leg right after a deploy + re-browse. +(live: the H06 rebuild leg denied right after a re-browse). The gate now starts each held leg right after a deploy + re-browse. **Fixed by #922** (`fu922.md`): a lapsed lease now renews on demand. The gate no longer re-browses before H04's resume, and H06(c) idles past the lease on purpose. ## Review round 3 (approve-with-changes) — fixes diff --git a/docs/plans/evidence/grpc-data-ext/fu922.md b/docs/plans/evidence/grpc-data-ext/fu922.md new file mode 100644 index 000000000..a763a0c1b --- /dev/null +++ b/docs/plans/evidence/grpc-data-ext/fu922.md @@ -0,0 +1,70 @@ +# #922 — a lapsed projected metadata lease is not an access denial + +Found in the H3 live gate (`H3.md` §"Found on the re-run"). Pre-existing v1 projection behaviour (95c5e484). + +## Root cause + +A projected node's authority is its catalog proof, bound to a `BoundProjectionLease` whose remote `MetadataAuthorityLease` lasts +`MetadataLeaseMilliseconds` (15 s on the rig) from the browse that fetched it. Only a **subscription** ever renewed it +(`RemoteNamespaceResolver.RenewExactAsync`, Subscribe only). After the lease lapsed: + +- `ProjectedCatalogCache.TryResolveProjected` / `Valid` required `Lease.IsValid`, so `ProjectedDataAccess.TryAcquire` returned + `false`, and the node manager's Read pre-loop mapped **every** `false` to `BadUserAccessDenied`. A lapse looked the same as an + ACL denial. +- HistoryRead: `AuthorizeHistoryRead` → `DataPlaneAuthorizer` → `MappedSubjectResolver` (`TryResolveProjected`) returned + `Deny` ⇒ `BadUserAccessDenied`. +- Re-browse: a cached parent page is served while its own lease holds, and nothing renews on a cache hit. A re-browse just + before the page's lease ran out therefore renewed nothing, and the nodes lapsed seconds later (the H06 observation). + +## Fix + +| Piece | Change | +|---|---| +| `BoundProjectionLease.Renewable` | the lease is invalid ONLY because it is transient: the remote time ran out or the route was replaced, while the local catalog authority, mapping binding and cache generation are current and nothing called `Invalidate` | +| `ProjectedCatalogCache.TryResolveForRenewal` | the retained, non-retired proof that is valid or `Renewable` (every `ValidCore` fence except the lease) | +| `OtOpcUaNodeManager.TryResolveForRenewal` (+ `IProjectedNodeLookup`, sinks) | the committed live definition without the authority check (lock-free snapshot), so the renewal commits against the exact SDK node | +| `DataOperationPolicy.AuthorizeMappedSubject` | `AuthorizeMapped` minus the lease checks. Classifies a refusal only and serves nothing | +| `IProjectedDataAccess.RenewLapsed` → `ProjectedLapseOutcome {Denied, Renewing, Unavailable}` | `Denied` unless the node is lapsed-renewable AND the caller holds the grant for the operation (local grant + mapping bit + op-specific checks). Otherwise starts ONE exact renewal per node (`RenewExactAsync` generalised to `authorizeAs`/`required` = Read or HistoryRead; the subscription default is unchanged), off the request thread, inside the unary budget, with a 250 ms back-off after a failure. A successful Read renewal then schedules a read so the retry is served from cache | +| Read pre-loop | `Denied` ⇒ `BadUserAccessDenied` (unchanged); `Renewing` ⇒ `BadWaitingForInitialData` (as for a cold read); `Unavailable` ⇒ `BadResourceUnavailable`. A non-Value attribute of a lapsed node ⇒ `BadResourceUnavailable` | +| `AuthorizeHistoryRead` | renews lapsed projected handles within the request (one block-bridged wait per batch, ≤ 5 s, no `Lock` held — the SDK released it before dispatching, as H3 recorded), re-authorizes, then serves. A renewal that does not complete ⇒ `BadResourceUnavailable` | +| `ProjectedBrowseAccess` | an initial cached page past half its lease is served AND refreshed in the background (one in flight per page key) | + +The node-manager `Lock` is never held across a network renewal. The Read path only starts the task. The renewal commits +through `IProjectedNamespacePageSink.TryRenewExact`, which takes `Lock` briefly and performs no I/O. + +## Red / green (Runtime harness, `GrpcDataLeaseLapseWireTests`, `Trait Issue=922`, real consumer SDK session + projection stack) + +| Test | master (`05f431f5d` src) | fix | +|---|---|---| +| value Read after the lease lapses ⇒ retryable, renews on demand without a browse (twice), attribute read not denied | **FAIL** (`BadUserAccessDenied`) | pass | +| no local Read grant ⇒ still `BadUserAccessDenied` after the lapse; no metadata/read call; renewal counter 0 (counted synchronously at admission) | pass | pass | +| HistoryRead after the lapse ⇒ renewed in the request, Good, 3 values | **FAIL** (`BadUserAccessDenied`) | pass | +| lapsed HistoryRead with the origin unreachable ⇒ `BadResourceUnavailable`, nothing read; Good after recovery | **FAIL** (`BadUserAccessDenied`) | pass | +| no local HistoryRead grant ⇒ still `BadUserAccessDenied` after the lapse, unsent | pass | pass | +| re-browse of a cached page past half its lease renews (origin browse call, lease holds at t0+20 s) | **FAIL** (no origin call) | pass | + +Real ACL denial and lease lapse are tested both ways. The lapse cases are red on master and the ACL-denial controls are green on +both. 8 consecutive green runs of the six tests after the final assertion fix. +Harness note: the fixture origin observes its single sample once, so the sample's origin age grows with the manual clock. The +value tests use a stale timeout and client maxAge longer than the idle gaps, so that age stays out of the result under test. + +## Gates + +`dotnet build -c Release` (solution) 0 errors. Runtime.Tests 2096 passed / 3 skipped / **2 failed** under machine load average +100–150: `VirtualTagActorTimerTests.Ticks_during_a_slow_run_coalesce_instead_of_piling_up` and +`GrpcDataConfiguredDiscoveryWireTests.Failed_sdk_item_construction_releases_candidate_and_fanout_ownership` (its first +subscription publish was not Good, and it calls no code path changed here). Once load dropped, both passed 12/12 on master `src` +and 12/12 on the fix. Cause not established, so this is recorded as load-correlated, not as a flake. OpcUaServer.Tests 1460 passed +(+2 skips). Host.Tests 497 passed, including `GrpcDataV1CompatibilityTests` (goldens untouched). Core.Tests 385 passed (+1 skip). + +## Live (grpc-data rig, OrbStack, run `f922a-sqlserver`, `--history --history-backend sqlserver`) + +`history_gate.py` with the workaround removed: H04 no longer re-browses before its resume, and H06(c) now deliberately idles +`LEASE_LAPSE_SECONDS = 20` (> the 15 s lease) after its restore before the held read. **H01–H06 all PASS** (47/34/35/44/58/238 +assertions). + +Value-Read probe (one browse, then never again; Client CLI `read --max-age 10000` on CONSUMER, raw/counter and uns/scalar): +the fresh-lease control and both idle legs (20 s and 40 s, i.e. past the lease) answer `BadWaitingForInitialData` then Good on +the next read, with **no `BadUserAccessDenied` anywhere**. With the CLI's default `--max-age 0`, every projected read (lapsed or +not) stays `BadWaitingForInitialData`, because the v1 Read path never serves `maxAge = 0` from cache. That is separate from this +fix and is filed as a follow-up. `rig.py down` ⇒ 0 containers / volumes / networks / images.