Merge fix/review-2026-12-phase4 (2026-12-02 review fix plan)

This commit is contained in:
Joseph Doherty
2026-12-03 10:18:43 -05:00
13 changed files with 783 additions and 178 deletions
+18 -8
View File
@@ -768,7 +768,10 @@ Parity tests need stable command-specific request and reply shapes.
Both commands set `Hresult` to `0` only after the COM call returns normally.
COM exceptions flow through `StaCommandDispatcher`, which captures the thrown
HRESULT and converts the reply to `ProtocolStatusCode.MxaccessFailure`.
HRESULT and converts the reply to `ProtocolStatusCode.MxaccessFailure`. A request
the worker rejects before calling MXAccess replies `InvalidRequest` with no
HRESULT, and a work item the STA runtime refuses at shutdown replies
`WorkerUnavailable`; see the status mapping in `WorkerConversion.md`.
`MxAccessStaSession.GetRegisteredServerHandlesAsync` returns an STA-read
snapshot of tracked server handles for diagnostics and future cleanup logic.
@@ -814,13 +817,20 @@ caches the event sink fills: `RemoveItem` drops the handle pair's
removes the server's items with it, so the per-item eviction never runs for
them). Without this, an `AddItem` → `Write` → `RemoveItem` churn grew the
completion cache by one entry per cycle for the life of the worker.
`AddItem`, `AddItem2`, and `AddBufferedItem` also drop both cache entries for
the handle they receive when the registry does not already track it. An
`OnDataChange` or `OnWriteComplete` that was queued when `RemoveItem` or
`Unregister` ran is dispatched after the eviction and recreates the entry;
when MXAccess later reuses that item id, `ReadBulk`'s cached path would
otherwise serve the stale value as `was_cached = true`. A handle the
registry still tracks belongs to a live item, so its entries are kept. Failed advice and cleanup calls
An `OnDataChange` or `OnWriteComplete` that was queued when `RemoveItem` or
`Unregister` ran is dispatched after the eviction. `MxAccessSession.Create`
binds the session's handle registry to the production event sink, and the sink
writes a cache entry only for an item handle the registry still holds; the
event itself is still forwarded to the gateway. Without the check the late
callback re-created the entry, and because MXAccess hands out strictly
increasing item handles within a registration, nothing evicted it again before
`Unregister`: a `ReadBulk` poll loop or subscribe/unsubscribe churn leaked one
entry per cycle in the 32-bit worker (MXA-004). As a backstop for a sink that is
not bound to a registry, `AddItem`, `AddItem2`, and `AddBufferedItem` also drop
both cache entries for the handle they receive when the registry does not
already track it, so a reused id never serves a stale value as
`was_cached = true`. A handle the registry still tracks belongs to a live item,
so its entries are kept. Failed advice and cleanup calls
leave registry state unchanged so diagnostics continue to reflect the last
successful MXAccess-owned state transition.