Commit Graph

1221 Commits

Author SHA1 Message Date
Joseph Doherty bb63c8ba72 perf(worker): alarm poll loop parks until a subscription activates instead of ticking (MXA-011, #258)
ci / windows-x86 (push) Successful in 3m10s
ci / java (push) Failing after 11m14s
ci / portable (push) Failing after 19m30s
The poll loop skipped the STA hop while unsubscribed but its timer still woke
every interval (a Task.Delay timer plus a thread-pool continuation per tick on
every idle worker). It now parks on a semaphore while IsSubscribed is false and
is released by the handler's new SubscriptionActivated event; a subscribe that
races the park is kept by the semaphore count. While subscribed it never parks,
so failover polling and probes (MXA-001) are unchanged, and shutdown cancels a
parked loop like a sleeping one, so the MXA-003 join and grace bound hold. The
failure run resets when the loop parks.
2026-12-03 13:10:35 -05:00
Joseph Doherty a38578d0e2 perf(worker): alarm watch-list update diffs the subtag standby instead of rebuilding it (MXA-010, #258)
UpdateAlarmWatchList rebuilt the standby: a second MXAccess registration, an
AddItem/Advise for every watched subtag, then an Unregister of the old source —
work proportional to the whole list for a one-alarm change (reproduced by the
previous commit's test). The subtag standby now takes the list as a diff:
added alarms' subtags are advised on the existing source, removed alarms'
subtags are unadvised, and unchanged alarms keep their advice and state.

The update stays all-or-nothing: the list is validated and the additions
advised before the swap, and an advise failure unadvises what it added and
keeps the previous list. A changed target starts fresh and is initialised from
the last delivered subtag values (acked/priority before active, MXA-007; bad
quality still ignored, MXA-005). LmxSubtagAlarmSource tracks an item from
AddItem so an Advise failure is retryable and removable.
2026-12-03 13:10:31 -05:00
Joseph Doherty d8553b1ff7 test(worker): watch-list update rebuilds the whole subtag standby for a one-alarm change (MXA-010, #258)
ci / windows-x86 (push) Failing after 2m21s
ci / java (push) Failing after 15m7s
ci / portable (push) Failing after 19m6s
Reproducer: currently fails — the update builds a second source, re-advises all
102 subtags on it and disposes the first.
2026-12-03 13:04:58 -05:00
Joseph Doherty 6804341152 test(worker): mark the MXA-003 stuck-poll shutdown test subscribed so MXA-011's idle skip doesn't bypass the poll
ci / windows-x86 (push) Successful in 2m25s
ci / java (push) Failing after 9m54s
ci / portable (push) Failing after 16m26s
2026-12-03 10:21:18 -05:00
Joseph Doherty 0f2ae7f542 Merge fix/review-2026-12-phase6b (2026-12-02 review fix plan)
ci / windows-x86 (push) Failing after 3m4s
ci / portable (push) Failing after 29m12s
ci / java (push) Failing after 27m54s
2026-12-03 10:19:19 -05:00
Joseph Doherty e6c0706eff Merge fix/review-2026-12-phase6a (2026-12-02 review fix plan) 2026-12-03 10:19:19 -05:00
Joseph Doherty d5068c4e92 Merge fix/review-2026-12-phase5 (2026-12-02 review fix plan)
Conflicts resolved:
- WorkerClient: keep the WRK-003 deadline-bound enqueue and carry the WRK-010 pre-computed
  envelope size through both the TryWrite fast path and the slow path.
- AlarmsHub: prime each connection (DSH-005) and then count it for the idle-gated publisher
  (DSH-009); a connection that fails priming is never counted, so never decremented.
- GatewayDashboardDesign.md: describe both.
2026-12-03 10:19:19 -05:00
Joseph Doherty ece16a150a Merge fix/review-2026-12-phase4 (2026-12-02 review fix plan) 2026-12-03 10:18:43 -05:00
Joseph Doherty cc7a0c0b40 Merge fix/review-2026-12-phase3 (2026-12-02 review fix plan) 2026-12-03 10:18:43 -05:00
Joseph Doherty f616a551d2 Merge fix/review-2026-12-phase2 (2026-12-02 review fix plan) 2026-12-03 10:18:43 -05:00
Joseph Doherty c05bb904b4 Merge fix/review-2026-12-phase0 (2026-12-02 review fix plan) 2026-12-03 10:18:42 -05:00
Joseph Doherty 0ccf3d400b fix(alarms): diff across monitor restarts, version reconciles, cache the watch-list (SEC-005..SEC-010, #250, #254)
ci / windows-x86 (push) Successful in 3m34s
ci / java (push) Failing after 12m34s
ci / portable (push) Failing after 24m29s
- SEC-005: a lifecycle that ends keeps its cache as the previous
  generation; the next lifecycle's first reconcile diffs against it and
  broadcasts Clear for alarms gone during the gap (derived from the new
  worker snapshot, documented in gateway.md as a reconcile repair, not a
  synthesized event). The retired set is hidden from CurrentAlarms; gap
  joiners get the whole set. Each lifecycle start broadcasts its
  re-baselined provider status.
- SEC-006: live transitions stamp a sequence; a reconcile leaves alarms
  changed live after it was issued alone (no stale Clear / re-raise).
- SEC-007: an Acknowledge of an uncached alarm is broadcast but no longer
  inserts an ActiveAcked row; other non-Raise kinds do not touch the cache.
- SEC-009: a changed original raise time is a Raise repair; a non-OK
  reconcile is logged/surfaced and fails the initial reconcile.
- SEC-008: watch-list resolution cached per Galaxy deploy time and
  fingerprinted by SHA-256 once per resolution; refresh runs on its own
  loop; the failover-edge refresh is bounded to 10 s.
- SEC-010: restart backoff doubles from 5 s to a 5 min cap and resets on
  Monitoring; repeated identical faults log one summary line.
2026-12-03 10:08:07 -05:00
Joseph Doherty eb37565e59 fix(dashboard): prime new /hubs/alarms connections with the current snapshot (DSH-005, #254)
The publisher's single monitor subscription is primed once, normally
before any browser connects, so a later client saw only subsequent
transitions and never the standing alarms or provider status.
AlarmsHub.OnConnectedAsync now joins the group, sends the caller a
generation-0 AlarmFeedReset, then the status frames, active alarms and
snapshot_complete from a fresh subscription, redacted by ShowTagValues.
2026-12-03 10:08:07 -05:00
Joseph Doherty 8e720bc727 fix(worker): bound shutdown alarm steps by the grace; watchdog stands down while shutting down; startup handshake deadline (MXA-003, WIP-007, WIP-009, #253)
ci / windows-x86 (push) Failing after 11m18s
ci / java (push) Failing after 11m43s
ci / portable (push) Failing after 12m6s
2026-12-03 10:07:41 -05:00
Joseph Doherty eaa43cf42f test(worker): net48-compatible timeout helper in the dispatcher gate test (WIP-010) 2026-12-03 10:07:29 -05:00
Joseph Doherty a474d3219b fix(grpc): configure Kestrel HTTP/2 keepalive (60 s ping, 10 s timeout) under MxGateway:Protocol (SES-005, #253) 2026-12-03 10:03:53 -05:00
Joseph Doherty 87b8f8da09 fix(workers): orphan cleanup skips workers whose owning gateway is still running (WRK-009, #253) 2026-12-03 10:00:16 -05:00
Joseph Doherty 152a12cea9 fix(dashboard): enforce auth lifetimes on live hub connections and circuits (DSH-006)
Hub tokens and cookies bounded only the handshake: an open hub socket kept its
connect-time roles and tag grants indefinitely, and a Blazor circuit never
revisited its sign-in. The hub-token ticket now carries the token expiry and the
hubs are mapped with CloseOnAuthenticationExpiration. Circuits use
DashboardRevalidatingAuthenticationStateProvider, which signs a circuit out past
the cookie's 8-hour idle lifetime or when a role it holds is no longer granted
by GroupToRole. LDAP membership changes and sign-out in another tab are still
only picked up at the age limit or on reconnect (documented).
2026-12-03 09:59:08 -05:00
Joseph Doherty 9c3a4c0eae fix(sessions): drop per-session event metrics after the session dispose (WRK-008, #253) 2026-12-03 09:57:41 -05:00
Joseph Doherty 196465ef9c fix(workers): fail fast when the worker exits before connecting; launch-cleanup Kill never masks the launch error (WRK-002, WRK-006, #253) 2026-12-03 09:56:05 -05:00
Joseph Doherty 835ed0bd04 fix(auth): revoking, rotating or deleting a key ends its open gRPC streams (SEC-004)
A streaming call was authenticated only at open, and revoke/rotate/delete only
evicted the verification cache, so a leaked key's open StreamEvents/StreamAlarms
kept delivering after the revoke. The interceptor now registers every streaming
call by key id in ApiKeyStreamRegistry and gives the handler a call context
whose token also fires on revoke; the dashboard key actions call Revoke, and the
call ends with Unauthenticated.
2026-12-03 09:55:43 -05:00
Joseph Doherty c30ba69a6d perf(worker): alarm subtag source and ack writer tear down with Unregister alone (MXA-010, #256) 2026-12-03 09:54:11 -05:00
Joseph Doherty 04c772268a perf(worker): wnwrap poll skips the parse and diff when the alarm XML is unchanged (MXA-008, #256) 2026-12-03 09:53:39 -05:00
Joseph Doherty a17f24c817 perf(worker): completion waits tick at the 50 ms fallback and the bulk wait probes only pending handles (MXA-009, #256) 2026-12-03 09:52:52 -05:00
Joseph Doherty ad30daf6e2 perf(worker): alarm poll loop skips the STA hop while nothing is subscribed (MXA-011, #256) 2026-12-03 09:52:23 -05:00
Joseph Doherty 1c77ce4c5a fix(auth): normalize absent constraint lists to empty on load (SEC-013, #254)
ci / windows-x86 (push) Failing after 11m43s
ci / java (push) Failing after 12m0s
ci / portable (push) Failing after 14m46s
System.Text.Json leaves a positional-record list parameter that is absent
from (or null in) the stored blob as null, so a sparse constraints row
threw NullReferenceException in HasReadConstraints/HasWriteConstraints and
handed the browse-scope provider a null scope. Deserialize now normalizes
every list to empty. Reproduced with a sparse-blob test first.
2026-12-03 09:52:22 -05:00
Joseph Doherty 2ee57a70fe fix(config): bound Alarms:ReconcileIntervalSeconds and Events:ReplayRetentionSeconds (SEC-011, #254)
ReconcileIntervalSeconds must be 1..86400 when alarms are enabled (a huge
value faulted PeriodicTimer inside an unobserved task, silently ending
reconciliation); ReplayRetentionSeconds must be finite and at most a day
(Infinity passed startup and then threw in TimeSpan.FromSeconds on every
StreamEvents). A faulted reconcile loop is now logged and surfaced.
2026-12-03 09:52:22 -05:00
Joseph Doherty b74a231f75 fix(worker): hold subtag alarm state on bad quality; keep an initial-sync ack (MXA-005, MXA-007, #254)
LmxSubtagAlarmSource now passes the OnDataChange quality through. The
subtag state machine ignores InAlarm/Acked updates that are not good
quality or carry no value instead of coercing them to false (which read
as a Clear). An Acked=true buffered before the first InAlarm value is
the initial state of an already-acked alarm and survives the raise.
2026-12-03 09:52:22 -05:00
Joseph Doherty 58342efeab fix(worker): count an unsubscribed alarm primary as failing and rebuild it (MXA-001, #249)
A wnwrap primary whose Subscribe failed polls as a silent no-op, so the
failover counter reset and probes read as clean: failover never engaged
(threshold 3) or falsely recovered onto a dead primary (threshold 1).
FailoverAlarmConsumer now tracks whether the current primary subscribed;
an unsubscribed primary is replaced by a fresh instance from the consumer
factory and subscribed before it is polled or probed, and a failure there
counts. Without a factory it reports the original subscribe HRESULT.
2026-12-03 09:52:22 -05:00
Joseph Doherty 2c22ae6bd4 fix(workers): bound the heartbeat skip by heartbeat age on the monotonic clock; deadline covers the enqueue; a reply that wins the timeout race is returned (WRK-001, WRK-003, WRK-004, WRK-005, #253) 2026-12-03 09:52:19 -05:00
Joseph Doherty 5a207f622a fix(client-go): keepalive, stream error classification, auth composition, CLI batch reuse (CGO-001..008, #257)
- Dial/DialGalaxy set HTTP/2 keepalive (30 s / 10 s / PermitWithoutStream), configurable via
  Options.KeepAliveTime/KeepAliveTimeout (CGO-001, D7)
- auth installed with chain interceptors and attached per call by Client/GalaxyClient (CGO-002)
- a server-sent Canceled status or a context deadline ends a stream with a terminal error;
  only the caller's own cancellation is silent (CGO-003)
- stream context cancelled when the stream ends (CGO-004)
- dialConnected keeps the last connection error in the returned error (CGO-005)
- WatchDeployEvents closes events before errs; CLI drains buffered events (CGO-006)
- Register/AddItem/AddItem2 return MalformedReplyError on a payload-less reply (CGO-007)
- CLI batch reuses dialed connections; bench-read-bulk backs off on failures (CGO-008)
2026-12-03 09:51:57 -05:00
Joseph Doherty 0b93fe8263 perf(worker): start the STA dispatcher drain outside its gate so command logging cannot stall the read loop (WIP-010, #256) 2026-12-03 09:51:46 -05:00
Joseph Doherty 78bfc1b8a3 perf(workers): reuse the pre-check envelope size when framing; count pre-reply command failures (WRK-010, WRK-007, #256) 2026-12-03 09:51:12 -05:00
Joseph Doherty 824107a56b fix(auth): cached verifications skip the limiter; success no longer wipes the key aggregate (SEC-002, SEC-003, #245)
SEC-002: once a key id's cross-peer aggregate tripped, every request for it -
including the holder's cached ones - competed for one probe slot per interval,
so a spray of bad secrets against the public key id denied the key to its
holder. The interceptor and /metrics handler now serve a cached success before
consulting the limiter, and an address that verified the key in the window is
exempt from the aggregate on a cache miss.

SEC-003: Reset removed the aggregate on every success, so a key in steady use
never accumulated one. Success now clears only the caller's own partition; the
aggregate decays by window.

Also corrects the MetricsAuthenticationHandler remark left stale by SEC-001.
2026-12-03 09:51:08 -05:00
Joseph Doherty 16d9cc708b perf(sessions): check readiness before expanding a sparse write; share one default Timestamp (SES-008, #256) 2026-12-03 09:49:22 -05:00
Joseph Doherty 09da8063a9 fix(sessions): reject a StreamEvents resume cursor ahead of the stream with InvalidArgument (SES-006, #256) 2026-12-03 09:48:27 -05:00
Joseph Doherty a9f884f370 fix(auth): partition the API-key failure limiter on remote IP, not IP:port (SEC-001, #244)
ServerCallContext.Peer carries the client's ephemeral source port, so every new
connection was a fresh limiter partition and a sprayer could reconnect before
reaching the limit. Both auth surfaces (gRPC interceptor, /metrics handler) now
derive the partition address through ApiKeyThrottlePeer, which strips the port
and reduces IPv4-mapped IPv6 to IPv4.
2026-12-03 09:48:03 -05:00
Joseph Doherty 159524edd9 fix(dashboard): close the dropped live-read session; subscribe-and-track off the caller's token (DSH-002 #248, DSH-007, #253) 2026-12-03 09:47:46 -05:00
Joseph Doherty 855cd8a526 fix(client-python): CLI batch reuses one loop/channel; smoke attaches stream before advise (CPY-005, CPY-006, #257) 2026-12-03 09:47:40 -05:00
Joseph Doherty 9756ab843e perf(audit): indexed, chunked retention sweep that runs off the startup path (SEC-014, #256) 2026-12-03 09:46:43 -05:00
Joseph Doherty 27fdb576ba fix(dashboard): enforce page [Authorize] on in-circuit navigation via AuthorizeRouteView (DSH-001, #243)
Routes.razor used RouteView, which ignores [Authorize]. With the interactive
router, an in-circuit navigation never meets endpoint authorization, so anonymous
localhost could open /alarms and a Viewer could open /admin/secrets (secret
metadata list). Both were confirmed reachable by the new route test before the
change; AuthorizeRouteView now renders a Not Authorized panel instead.
2026-12-03 09:46:31 -05:00
Joseph Doherty 0673b0c76c fix(sessions): start the host session drain at ApplicationStopping, before Kestrel's drain (SES-001, #247) 2026-12-03 09:46:17 -05:00
Joseph Doherty 3173ad7083 fix(client-python): keepalive options, typed error mapping with status code, open-enum names, malformed-reply checks (CPY-001..004, #257) 2026-12-03 09:46:02 -05:00
Joseph Doherty 7ec4c20239 perf(auth): hash the cache key from a stack buffer and reuse the mapped identity on cache hits (SEC-012, #256) 2026-12-03 09:45:46 -05:00
Joseph Doherty d4231c4a6d fix(worker): skip cache writes for late callbacks on removed handles (MXA-004, #255)
ci / windows-x86 (push) Failing after 15m0s
ci / java (push) Failing after 15m13s
ci / portable (push) Failing after 15m21s
An OnDataChange/OnWriteComplete already queued on the STA is dispatched
after RemoveItem evicted the handle and re-created the cache entry; item
handles are never reused within a registration, so it leaked until
Unregister. MxAccessSession.Create now binds its handle registry to the
production sink, which only caches callbacks for handles the registry still
holds. The event is still forwarded. EvictStaleHandleState stays as the
backstop for unbound sinks.
2026-12-03 09:45:18 -05:00
Joseph Doherty 9adea04b37 fix(worker): report worker-side validation and STA shutdown without an MXAccess HRESULT (WIP-005, #255)
Per D9: a request the worker rejects before calling MXAccess (write value
with no kind, raw payload, empty MxArray) throws the new
WorkerRequestValidationException and replies INVALID_REQUEST with no
HRESULT. A plain ArgumentException stays MXACCESS_FAILURE with its HRESULT,
because the interop raises MXAccess E_INVALIDARG that way. The dispatcher
now converts executor exceptions on the STA, so anything the InvokeAsync
await throws is the runtime refusing the work item (shutdown, disposal,
dead loop, canceled at shutdown) and replies WORKER_UNAVAILABLE. No .proto
change. Status mapping documented in docs/WorkerConversion.md.
2026-12-03 09:45:14 -05:00
Joseph Doherty 62649047cf fix(worker): make array and FILETIME conversion total (WIP-003, WIP-004, #255)
Typed array projection no longer throws on an element that does not fit:
it falls back to the array's own element type, then to the raw projection
with a diagnostic naming the element index and CLR type. Time arrays parse
BSTR timestamps as MXAccess local time and reject 32-bit/double elements
instead of reading them as FILETIMEs near 1601; out-of-range FILETIMEs
(scalar and array) stay integers. Integer arrays widen like the scalar
path: uint/long/ulong use Int64Values, object[] retries as Int64 on
overflow, and a ulong above long.MaxValue takes the raw projection.
Conversion runs on the event path, where a throw faults the session.
2026-12-03 09:45:05 -05:00
Joseph Doherty 3f9ea6a86c perf(dashboard): AlarmsHubPublisher holds no monitor subscription while no hub client is connected (DSH-009, #256) 2026-12-03 09:44:51 -05:00
Joseph Doherty fafd79fa12 fix(client-java): keepalive 30s/10s, close() cancels streams, typed stream errors, malformed-reply checks, lenient TLS for Galaxy client (CJV-001..007, #257) 2026-12-03 09:44:43 -05:00
Joseph Doherty 31e16fbc80 fix(client-dotnet): keepalive, error mapping, lifecycle, CLI batch/redaction (CDN-001..011, #257)
- keepalive: 30 s ping / 10 s timeout / Always, configurable via KeepAlivePingDelay/Timeout (CDN-004, D7)
- GrpcStatusMapper shared by both transports: server Cancelled with a live token is no longer
  OperationCanceledException; NotFound/FailedPrecondition on session RPCs -> MxGatewaySessionException;
  MxGatewayException.GrpcStatusCode preserves the status (CDN-001, CDN-002)
- Register/AddItem/AddItem2 raise MxGatewayMalformedReplyException on a payload-less reply (CDN-008)
- MxGatewayEventStream.DisposeAsync waits for the in-flight read (CDN-003); session DisposeAsync
  is bounded to 5 s and swallows cancellation (CDN-005); owned handler + pinned CA disposed (CDN-006)
- ResourceExhausted no longer retried (CDN-007)
- CLI: batch reuses clients, stream/bench commands exempt from the 30 s timeout, OCE reported as
  an error with exit 1, --value redacted only for write-secured* and only as a whole token,
  bench backs off on failures (CDN-009, CDN-010, CDN-011)
2026-12-03 09:44:02 -05:00