fix(worker): ReadBulk never tears down a caller's item or subscription (#238)

ReadBulk sent every advised-but-uncached and added-but-not-advised tag
down the snapshot path. MXAccess returns the caller's existing handle for
a re-added address, so the snapshot's AddItem/Advise ran on the caller's
own item and the symmetric teardown then UnAdvised and RemoveItem'd it:
the subscription delivered one value and went silent.

Teardown is now ownership-scoped: it unadvises only advices the read's
own Advise created and removes only items the read's own AddItem created.
A tag the session already holds is read through the caller's handle with
no AddItem: advised-but-uncached waits on the existing subscription with
no COM call; added-but-not-advised is advised for the read and unadvised
afterwards (back to its prior state), never removed. A snapshot AddItem
that returns a handle the registry already tracks (differently spelled
address) is treated as the caller's item and never removed.

Adds MxAccessSessionTests regressions; updates gateway.md, Contracts,
DesignDecisions, MxAccessWorkerInstanceDesign.
This commit is contained in:
Joseph Doherty
2026-12-01 19:25:19 -05:00
parent 54367e7408
commit 7a41d9edea
8 changed files with 520 additions and 78 deletions
+7 -4
View File
@@ -88,10 +88,13 @@ of items per round trip while preserving MXAccess parity per entry.
`was_successful`, `was_cached`, `value`, `quality`, `source_timestamp`,
`repeated MxStatusProxy statuses`, and `error_message`. MXAccess has no
synchronous `Read`, so `ReadBulk` is dual-mode per entry: when a tag is
already advised in the session the worker returns the cached
`OnDataChange` payload without touching the subscription
(`was_cached = true`); otherwise the worker takes a full
`AddItem` + `Advise` + wait-for-first-`OnDataChange` + `UnAdvise` +
already advised in the session and has a cached value the worker returns
the cached `OnDataChange` payload without touching the subscription
(`was_cached = true`); a tag the session holds without a cached value is
read through the caller's own item handle — waiting on its existing
subscription, or advising an added-only item for the read and
unadvising it after — and is never removed; otherwise the worker takes a
full `AddItem` + `Advise` + wait-for-first-`OnDataChange` + `UnAdvise` +
`RemoveItem` snapshot lifecycle and returns the result
(`was_cached = false`). The asymmetry that `BulkReadResult` has no
`hresult` field is intentional — `ReadBulk` outcomes are timeout / cache