ReadBulk served a tag from the cache only when it was advised and cached;
every other tag took the AddItem + Advise + wait + UnAdvise + RemoveItem
snapshot lifecycle. If AddItem ever returned the caller's existing handle,
the teardown would unadvise and remove the caller's subscription.
ReadBulk now resolves a tag the session already holds to the session's
own item handle in phase 1:
- advised but uncached: wait on the caller's subscription for its first
OnDataChange (baseline taken in phase 1, before any phase-2 pump can
dispatch it); no COM call, no teardown.
- added but not advised: advise temporarily, then unadvise only; the item
stays registered, and the value the temporary advice cached is dropped
so it cannot later be served as was_cached = true.
- not held: unchanged snapshot lifecycle. An AddItem that returns a handle
the registry already tracks is treated as the caller's (not
re-registered, not removed).
Duplicate sharing, pump cadence, the shared deadline, timeout reporting
and was_cached semantics are unchanged.
Live repro on the windev rig (330 advised + 40 added-only tags, immediate
250-tag ReadBulk chunks x4 parallel, 60 s observation): unfixed and fixed
workers both keep 290/330 handles delivering. The 40 silent handles are
TestHistoryValue, which does not change within the window on either
build. The installed MXAccess hands out a distinct handle per AddItem
even for an address already added, and UnAdvise/RemoveItem of the second
handle leaves the first delivering. So the #238 teardown path does not
silence subscriptions on this MXAccess, and this change does not explain
the vd03 rate drop. The fix stays as a guard, and it saves an extra item
and four COM calls per uncached held tag.
Docs: gateway.md, Contracts.md, DesignDecisions.md,
MxAccessWorkerInstanceDesign.md and the five client ReadBulk doc comments.
The worker logged its MXSTATUS_PROXY record-info pin outcome only to its own
stderr, which the gateway's launcher does not capture, so operators never saw
whether the pin took.
- Contract (additive, internal IPC): WorkerReady.record_info_pin_status = 5.
No protocol version bump; an older peer ignores it or sends it empty.
Regenerated Contracts/Generated, the client protoset, the Rust vendored
proto, and the Go/Python/Java worker bindings (real delta only).
- Worker: the handshake copies MxStatusProxyRecordInfoPin.Status into
WorkerReady unless the runtime already set it.
- Gateway: WorkerClient records it (IWorkerClient.RecordInfoPinStatus, default
null) and logs it at Information when pinned, Warning otherwise; empty is
not logged. Shown as "Record-info pin" in the dashboard session details
Worker table via DashboardSessionSummary.WorkerRecordInfoPinStatus.
- Tests: drain-thread cancellation (task ends Canceled; RunAsync cancels,
runtime disposed, thread exits, no EventDrain stop-failure log) and fault
(exception on the thread faults RunAsync with the same instance) paths;
WorkerReady carries the pin status; gateway logging/recording and the
dashboard projection.
- Docs: gateway.md STA thread model (drain thread, pin step in COM lifetime),
MxAccessWorkerInstanceDesign, GatewayProcessDesign, GatewayDashboardDesign,
WorkerFrameProtocol.
MXAccess reads the VT_DATE time argument of Write2, WriteSecured2 and their
bulk forms as box-local time and converts it to UTC itself. The worker passed
the proto Timestamp's UTC clock fields (the COM marshaler ignores
DateTime.Kind), so on vd03 (UTC-5) a Write2 sent at 01:33:00Z was stored at
06:33:00Z.
VariantConverter.ConvertToComTimestamp converts a timestamp_value instant with
TimeZoneInfo.ConvertTimeFromUtc into the worker's zone (TimeZoneInfo.Local by
default, DST included; an injectable zone for tests). The executor uses it for
the time argument only: value conversion is unchanged, and the read direction
(MXAccess reports UTC; ToTimestamp treats it as UTC) is unchanged. The one
residual loss is MXAccess-side: the repeated fall-back hour cannot be told
apart in an offset-less VT_DATE.
Tests: VariantConverterTimestampTests (UTC-5, US-Eastern DST both edges,
UTC+05:30, UTC, fall-back ambiguity, value path unchanged); the four executor
forwarding tests inject a fixed UTC-5 zone; the windev live Write2 smoke now
sends a past whole-second timestamp and asserts the stored one when applied.
Claude-Session: https://claude.ai/code/session_01GT67ACmpMR7b9LGRPLijMi
On the DEV gateway (wonder-app-vd03, 2b13564e), Write2 after
AdviseSupervisory applied the value to MESReceiver_025.MoveInBatchID
(0 -> 212212, OnWriteComplete Ok), and the value was restored to 0. After a
plain Advise, the same Write2 got SecurityError/1008, which is exactly what
the windev run saw. So that refusal came from the plain advise. It does not
show that windev has no writable attribute.
- Client.Tests: add the opt-in LiveGatewayWrite2Tests (gated by
LiveGatewayWriteFact: endpoint, key file and write item env vars). It runs
supervisory advise -> Write2 -> readback -> restore. The value test passed
live on vd03. The timestamp-parity test needs a second opt-in; it fails on
a non-UTC host until #228 is fixed.
- IntegrationTests: the windev Write2 smoke now uses AdviseSupervisory and
restores the original value. It has not been re-run on windev.
- GatewayTesting.md: document the env vars. code-reviews IntegrationTests-033:
correct the "no writable attribute" limit.
The run also found that the Write2 timestamp is read as host-local time
(stored +5 h on the UTC-5 box); filed as #228.
Claude-Session: https://claude.ai/code/session_01GT67ACmpMR7b9LGRPLijMi
A fresh StreamEvents is never replayed, so an initial value published before
the gateway registers the stream's subscriber is lost (lmxopcua#865 —
slow-changing ScanState). Clients had nothing deterministic to wait on.
Contract (additive, proto3):
- StreamEventsRequest.emit_stream_attached = 3 (bool, default false)
- MxEvent.stream_attached = 15 (optional StreamAttached)
- message StreamAttached { uint64 live_after_sequence = 1; }
- OpenSessionReply capability "stream-events-attached-ack"
(GatewayCapabilities.StreamEventsAttachedAck)
When requested, EventStreamService yields the sentinel as the FIRST message,
after AttachEventSubscriber/AttachEventSubscriberWithReplay has returned, so
receipt implies registration; refused attaches never see it. It precedes the
ReplayGap sentinel and replay on a resume. Shape mirrors ReplayGap: family
UNSPECIFIED, no body, worker_sequence 0.
Opt-in rather than always-on: ScadaBridge's MxGateway adapter stores every
streamed event's worker_sequence as its resume cursor, so an unrequested
sentinel would reset it to 0. Default wire behaviour is unchanged.
.NET client: StreamEventsAsync/StreamEventItemsAsync(after, emitStreamAttached),
MxEventStreamItem.IsStreamAttached, MxGatewaySession.SupportsStreamAttachedAck,
and OpenEventStreamAsync -> MxGatewayEventStream (awaits the sentinel, with
attach timeout; refuses older gateways).
Regenerated Contracts/Generated, the client protoset, Go and Python bindings
(also picks up comment-only drift already on main), synced the Rust vendored
proto and set emit_stream_attached in the Rust StreamEventsRequest literals.
No package versions bumped.
Tests: ordering (sentinel first, then events), race proof (event fanned right
after the sentinel is delivered — mutation-checked: fails when the sentinel is
yielded before registration), resume-with-gap order, refused attach emits no
sentinel, default emits none, contract field numbers, capability, and .NET
client wire tests (await, no-capability, older gateway, timeout).
Event-queue overflow, alarm-feed overflow, subscriber cap, session limit and
oversized commands all surfaced as ResourceExhausted. The status code is
unchanged; the gateway now attaches a machine-readable `mxgw-reason` trailer
(constants in Contracts ResourceExhaustedReasons). The .NET client maps
ResourceExhausted to MxGatewayResourceExhaustedException (an
MxGatewayException subclass; additive) exposing Reason/IsOverflow/
IsSubscriberLimit. Documented in docs/ClientBehaviorFixtures.md; the other
clients get a doc note only.
Claude-Session: https://claude.ai/code/session_01GT67AEHd2Acv1YPwGfXEoV
Pure move: cli definition, per-group handlers (session, bulk, bench, events,
galaxy, smoke, batch) and shared output/parse/connect helpers now live in
their own modules. No behaviour or CLI surface change; --help of all 33
commands is byte-identical, clippy clean, tests unchanged.
Claude-Session: https://claude.ai/code/session_01GT67AEHd2Acv1YPwGfXEoV
ExecuteSafeUnaryAsync capped the whole retry pipeline at one DefaultCallTimeout
while each attempt carried the same deadline, so a DeadlineExceeded first
attempt consumed the whole budget and no retry ever ran. The outer cap is now
MaxAttempts x DefaultCallTimeout + (MaxAttempts-1) x MaxDelay in both
MxGatewayClient and GalaxyRepositoryClient. Adds a slow-first-attempt test
(fails without the fix) and a budget unit test.
0.2.1 on the feed predates the 488649c AcknowledgeAlarmRequest
operator_password/operator_domain fields; 0.3.0 ships them so OtOpcUa can
adopt operator-authenticated alarm ack (lmxopcua#749).
Stream E made the worker wait once for all uncached tags. Fix the Go, Python, Rust, Java
and .NET library docs and CLI help text, the proto comment (default is the worker's
1000 ms), and the worker design doc. Regenerated Contracts Generated/ and the Java
generated protos; both diffs are comment-only.
- eventQueueCapacity option (default 1024, was hard-coded 16)
- overflow retains buffered events and delivers the error after them
- interrupt cancels the gRPC call and restores the interrupt flag
- ping/getSessionState/getWorkerInfo/drainEvents on MxGatewaySession
- AlarmAckWriter: classify AuthenticateUser and AddItem/Advise/Write
failures by HRESULT for any interop exception (ArgumentException for
E_INVALIDARG, UnauthorizedAccessException, COMException); server-gone
HRESULTs at AuthenticateUser tear down the registration and report
WriteRejected.
- Bound the ack item cache with a 256-entry LRU (eviction best-effort
UnAdvise+RemoveItem).
- After an Unconfirmed ack, drop and re-add the item before the next
write so a late OnWriteComplete on the old handle is not credited.
- Pass StaRuntime.PumpPendingMessages to the ack writer through a
pump-aware alarm handler factory so long completion waits refresh the
STA watchdog heartbeat.
- Rust CLI: --operator is required for acknowledge-alarm.
- Docs: full ack status table, credential-oracle trade-off, upgrade note.
Claude-Session: https://claude.ai/code/session_016J6isfcgqy4SB2RK3ZvFvT
Tracking IDs are review bookkeeping that rots in shipped source; the rationale they tagged is kept. Comment-only change (CommentChecker 458 -> 16 false positives).