Commit Graph

1270 Commits

Author SHA1 Message Date
Joseph Doherty 3d79207be4 Merge Galaxy gRPC write follow-ups: per-export AllowSecuredWrites opt-in (migration AddDataExportAllowSecuredWrites) required alongside the driver option (#1084); Galaxy reports gRPC write outcomes definitively + caller-aware write interfaces guarded by the analyzer (#1091) 2026-12-04 15:08:57 -05:00
Joseph Doherty 8e2a793000 feat(grpc-data): #1084 secured writes over a data connection need an export-level opt-in; #1091 Galaxy reports gRPC write outcomes definitively
#1084 - DataExport.AllowSecuredWrites (default false; migration AddDataExportAllowSecuredWrites, a bit NOT NULL DEFAULT 0
column, no constraint => no MigrationPreChecks twin; the preflight's legacy-schema tolerance covers the missing column).
- Valid only with Write: validator code DataExportSecuredWriteInvalid at authoring, the deploy gate and on a deployed
  row (an artifact row breaking it fails closed), modelled on AllowGalaxyServiceAck.
- LocalExportCatalog keeps it per rule (counts only with Write) and answers AllowsSecuredWrite(principal, node): an
  export of the principal, in the node's realm, granting Write, opted in, whose root contains the node.
- DataWriteExecutor stamps DataWriteAdmission.AllowsSecuredWrite (new, default false) from the catalog generation that
  admitted the write (re-checked by the dispatch gate's commit), never from the request.
- DriverInstanceActor.RichCaller returns null without it, so the driver gets NO caller: the driver option
  MxAccess.SecuredWritesOverDataConnections alone no longer lets a forwarding consumer cluster's link key write
  SecuredWrite attributes. Fail closed by default.
- AdminUI export editor: "Allow secured writes under this peer's key identity" checkbox (enabled only with Write).

#1091 (a) - GalaxyDriver implements IWriteOutcomeCapability + ICallerAwareWriteOutcomeCapability. GalaxyWriteOutcomes
maps BadUserAccessDenied and the OnWriteComplete verdicts BadNotWritable/BadTypeMismatch/BadOutOfRange/
BadConfigurationError to DriverConfirmedFailure, Good to AcceptedUnconfirmed (a provisional Good is indistinguishable),
everything else to OutcomeUnknown. A refused secured write is now a definite BadUserAccessDenied, not OutcomeUnknown.
- RunRichWriteAsync precedence: caller-aware outcome overload (caller present) -> outcome overload -> ICallerAwareWritable
  (caller present) -> IWritable. Both earlier behaviours kept; the OPC UA path is unchanged.

Tests (each failed before its fix where applicable):
- End to end through the runtime path (artifact -> catalog -> DataWriteRuntime executor -> ActorDataWriteRoute ->
  DriverInstanceActor behind the real dispatch gate -> real GalaxyDriver): export opt-in x driver option matrix; only
  both commit as the key's identity, either alone refuses BadUserAccessDenied definitively with no identity lookup.
  Ignoring the flag in RichCaller fails 3 tests.
- Catalog scope (root containment, Write, principal), artifact round-trip + fail-closed row, validator, migration SQL +
  no pending model changes, AdminUI checkbox enable/save (bUnit), actor precedence, Galaxy outcome mapping.
- ScriptForeignKeysAndExternalIdUniquenessMigrationTests now migrate to THEIR migration, not the latest.

Docs: DataConnections.md (two-gate table), Galaxy.md, security.md, rules/drivers.md.
2026-12-04 14:58:16 -05:00
Joseph Doherty 2ec0e780a6 Merge historian follow-up (#1089): HistorianUnreachable on /alarms-historian + otopcua.alarm_historian.unreachable gauge; per-writer reachability tests; SqlServer writer no longer counts login/connection failures as answered 2026-12-04 14:34:06 -05:00
Joseph Doherty 4916a6f177 feat(alarm-historian): #1089 surface HistorianUnreachable (AdminUI badge + unreachable gauge); per-writer NoteAnswered tests; SqlServer/QuestDB no longer count login/connection failures as answered 2026-12-04 14:33:54 -05:00
Joseph Doherty 12198e137b fix(ablegacy): #1087 cache read plans whose only unresolved refs are deterministic (malformed address / config-rejected); transient misses still uncached 2026-12-04 14:30:13 -05:00
Joseph Doherty 29ad36c028 feat(galaxy): #1074 secured writes over gRPC data connections are a separate opt-in, default off
- WriteCaller gains an additive Origin (WriteCallerOrigin: Unspecified (default) | OpcUaSession | DataConnection),
  stamped by the runtime at the receiving seam: OtOpcUaNodeManager -> OpcUaSession, the rich (gRPC data-connection)
  write path -> DataConnection. Never parsed from the principal/key.
- New driver-config option MxAccess.SecuredWritesOverDataConnections (default false; factory key
  mxAccess.securedWritesOverDataConnections; AdminUI "Also for gRPC data-connection writes", owned path). The
  Galaxy driver gives a caller an identity source only in ApiKeyIdentity mode AND for an allowed origin:
  OpcUaSession always, DataConnection only with the option, Unspecified never (fail closed). Off => a secured write
  over a data connection is refused exactly as before #1074 (local BadUserAccessDenied, no identity lookup; the gRPC
  caller sees the same OutcomeUnknown as before).
- Tests: option off refuses a gRPC write end to end into the real GalaxyDriver (with an OPC UA positive control on
  the same driver); option-on end-to-end kept; driver-level origin matrix incl. Unspecified; factory binding; AdminUI
  round-trip; node-manager callers now carry OpcUaSession.
- Docs: Galaxy.md (origin table, opt-in, forwarded-write delegation caveat, live-gate leg), security.md,
  DataConnections.md, Configuration.md, rules/drivers.md.
2026-12-03 16:51:26 -05:00
Joseph Doherty ed6531a0bc Merge historian follow-ups: QuestDB WaitAsync give-up seam + tests (#1072), stalled alarm S&F queue qualified by historian reachability (#1071), QuestDB fixture prefix registry + stale sweep, 134 leaked tables dropped (#1062) 2026-12-03 16:36:40 -05:00
Joseph Doherty 0ae5240341 feat(historian): #1071 alarm S&F stall is qualified by historian reachability: an outage is HistorianUnreachable, not a stuck queue 2026-12-03 16:31:16 -05:00
Joseph Doherty 8230302765 perf(ablegacy): #1073 memoise the read plan per ordered reference list (bounded, dropped on reinit/shutdown, refusals applied at use) 2026-12-03 16:30:13 -05:00
Joseph Doherty 98dc4c24a1 refactor(sql): #1076 one shared Sql DriverConfig JSON options (Sql.Contracts SqlDriverConfigJson) for driver factory and deploy gate; parity test 2026-12-03 16:28:04 -05:00
Joseph Doherty 5652ed43e8 test(historian): #1072 QuestDB WAL visibility give-up paths are testable (probe/delay/clock seam) and covered: warning + counter + health gauge 2026-12-03 16:27:43 -05:00
Joseph Doherty c64b5ec654 Merge Galaxy/AdminUI/Client follow-ups: opt-in SecuredWrite under the caller's API-key Galaxy identity, VerifiedWrite still refused (#1017), Galaxy form keeps KeepAlive keys (#1045), explicit empty ack password (#1050), Client.UI batched recursive subscribe + CLI --reconnect-timeout exit 3 (#1048) 2026-12-03 15:29:27 -05:00
Joseph Doherty 13521354cc feat(galaxy): #1017 SecuredWrite attributes can be written as the calling API key's Galaxy identity (opt-in); VerifiedWrite stays refused
- MxAccess.SecuredWrites = Refuse (default, unchanged #991 local BadUserAccessDenied) |
  ApiKeyIdentity. Opted in, a SecuredWrite runs as the calling key's own /api-keys Galaxy
  identity (ResolveKeyIdentityAsync: no fallback account; anonymous / no identity / broken
  identity refused before the wire): own plain-advised handle (apart from the raw path's
  supervisory handle) -> AuthenticateUser every write -> WriteSecured(userId, 0), the sequence
  mxaccessgw live-captured committing. Auth failure / user id 0 -> BadUserAccessDenied; password
  only in the AuthenticateUser command, scrubbed from every log. Identity resolved once per batch.
- VerifiedWrite is refused in every mode: an OPC UA Write carries no verifier (MXAccess refuses
  no verifier 1008 / self-verifier 8018), and a stored verifier would defeat the two-person rule.
- Caller plumbing: WriteCaller + optional ICallerAwareWritable (Core.Abstractions); node manager
  passes principal + key id -> IOpcUaNodeWriteGateway caller overload (default drops it) ->
  RouteNodeWrite.Caller -> WriteAttribute.Caller -> ICallerAwareWritable. The gRPC data-connection
  write path carries no caller yet (secured writes refused there).
- AdminUI Galaxy form 'Secured writes' select (owned path); enum serialises as its name; factory
  refuses an unknown value. Docs: Galaxy.md design + live-gate checklist. Not live-gated.
2026-12-03 15:29:02 -05:00
Joseph Doherty 9bdfe796f5 Merge driver follow-ups A: Modbus RTU response correlation + cancel redial + rebuild e2e (#1029/#1055), MTConnect malformed-item BadDecodingError + cross-chunk condition severity (#1055/#1037), TwinCAT write fail-fast + retired-client reads (#1035), OpcUaClient skipped-tag ledger append + zone-qualified IPv6 probe (#1039) 2026-12-03 15:25:42 -05:00
Joseph Doherty 152ae44174 Merge scripting follow-ups: deploy gate warm + 45 s deploy ask (#1024), editor predicate mode (#1025), {{equip}} in verbatim/raw/interpolated literal refused (#1056), ScriptRunGuardTests timing cause (#1038), returned sequences materialised + capped (#1059) 2026-12-03 15:23:46 -05:00
Joseph Doherty eff2b8e573 fix(opcuaclient): #1039 subscribe-time refusals ride the skipped-tag report (SkippedTagLedger.Append/Withdraw); probe preflight keeps an IPv6 zone
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-12-03 15:20:27 -05:00
Joseph Doherty d8cf9723d1 fix(twincat): #1035 writes to a gone device fail fast per call; a read in flight on a retired client is re-read on a fresh one
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-12-03 15:14:49 -05:00
Joseph Doherty f3f24f2984 fix(scripting): #1059 materialise a returned lazy sequence inside the guarded run with an element cap (Scripting:MaxResultElements); document the in-process sandbox boundary 2026-12-03 15:12:37 -05:00
Joseph Doherty 13ce6184f0 fix(mtconnect): #1037 condition value word from MTConnectConditionTracker (cross-chunk + same-chunk multi-code); #1055 malformed observation marks its item BadDecodingError
The value tag of a CONDITION item now reads the tracker's derived word (most severe active nativeCode across chunks),
so Warning(B) can no longer mask a still-active Fault(A) and a same-chunk Fault(A),Warning(B) no longer reads Warning.
A skipped observation that still names its dataItemId (unparseable/missing timestamp) is reported in
MTConnectStreamsResult.MalformedDataItemIds; the index marks the item BadDecodingError and the driver publishes it.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-12-03 15:11:03 -05:00
Joseph Doherty 6dfaacecc6 Merge driver follow-ups B: MQTT ISO-8601 DateTime writes (#1044), FOCAS short payload BadTypeMismatch (#1036), AbCip alloc trims (#1032), AbLegacy address memo + bounded RMW gates + identity eviction (#1031), Sql docs (#1042/#1043) 2026-12-03 15:09:51 -05:00
Joseph Doherty eb859fda52 perf(ablegacy): #1031 memoise the parsed address per authored tag; bound RMW gates and refusal log by the authored set; identity-checked single-tag eviction 2026-12-03 15:06:28 -05:00
Joseph Doherty 0245641720 fix(modbus): #1029 RTU reply must answer its request (FC + write-echo address); e2e rebuild-with-kept-driver; #1055 AutoReconnect=false redials once after a caller-cancel discard
#1029: ModbusRtuFraming.ReadResponsePduAsync takes the request PDU and refuses a CRC-valid, right-unit reply whose
function code (exception frames included) or write-echo start address differs (new DesyncReason.ResponseMismatch).
Runtime.Tests e2e: a full rebuild with a kept real ModbusDriver (deadbanded tag, same device value) leaves no node at
BadWaitingForInitialData; falsified by removing the S-2 baseline clear. V3ArtifactSeeder gained driverConfigByDriver.

#1055 (Modbus half): the RTU transport's caller-cancel teardown now grants ONE redial even with AutoReconnect=false, so
an unsubscribe/probe cancel no longer leaves the transport dead until the 90 s watchdog re-init; a link fault still stays down.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-12-03 15:04:36 -05:00
Joseph Doherty 870f7b28dd perf(abcip): #1032 reuse the constant offset-0 read request per tag runtime; no boxed tuple per cancellable scheduler request 2026-12-03 14:58:46 -05:00
Joseph Doherty 52d2acad25 fix(focas): #1036 a short macro/parameter payload publishes BadTypeMismatch, not BadCommunicationError 2026-12-03 14:56:28 -05:00
Joseph Doherty bd973f2ea7 feat(historian): #1046 a QuestDB WAL visibility give-up is a metric (counter + recent-failure gauge), not only a log line
Also records the #1008 finding in docs: the fixture's 0-row readback was the designed visibility timeout under host load, not a writer/reader defect.
2026-12-03 14:56:16 -05:00
Joseph Doherty 4dbacd840c fix(mqtt): #1044 plain DateTime writes publish ISO-8601 UTC, not the invariant MM/dd/yyyy form 2026-12-03 14:54:02 -05:00
Joseph Doherty 763ca0eedd Merge security review fixes: sandbox refuses async/stackalloc/MethodImpl, unwinding-overflow guard, deep-data types (#971); T-SQL ScriptDom single-SELECT guard (#974); Auth 0.5.0 directory re-query on revalidation (#975); fleet-diagnostics target check (#973) 2026-12-03 12:27:35 -05:00
Joseph Doherty 35d14936ac fix(sql): #974 review — parse SqlServer/Odbc named queries as T-SQL; ';' is not a statement boundary
The named-query guard's only statement boundary was ';', but T-SQL runs
';'-less batches: 'SELECT 1 COMMIT KILL 55', '... COMMIT DISABLE TRIGGER ALL ON
DATABASE', '... COMMIT SHUTDOWN WITH NOWAIT' and a TEXTPTR/WRITETEXT write were
all accepted for SqlServer AND Odbc — a COMMIT ending the rolled-back
transaction, then anything not on the keyword list.

For SqlServer, and for Odbc / no provider (backend unknown: strictest reading),
SqlReadOnlyStatement now also parses the statement with
Microsoft.SqlServer.TransactSql.ScriptDom 180.154.0 (central package pin; both
QUOTED_IDENTIFIER settings) and requires exactly one batch holding exactly one
SelectStatement, no INTO, and no OPENQUERY/OPENROWSET/OPENDATASOURCE. Odbc '?'
markers are read as variables for the parse. The lexical guard stays as a
second layer.

Tests: SqlReadOnlyStatementTransactSqlTests (11 batch strings x SqlServer/Odbc/
none, pass-through rowsets — all failed first; CTE/subquery/window/param/UNION/
FOR XML/OPTION and ODBC '?' positive controls). SqlNamedQueryTests' SQLite-backed
Odbc stand-in used the T-SQL reserved word 'top' as an alias (renamed).
Live (SQL Server 10.100.0.35,14330): SqlServerNamedQueryBatchLiveTests proves
'SELECT 1 AS v COMMIT UPDATE ...' commits the old way, the guard refuses it,
and a CTE+window+subquery+@param query reads Good; SqlServerReadTests /
write-mode / trigger suites unchanged (30/30). Class comment and
docs/drivers/Sql.md corrected.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-12-03 12:21:23 -05:00
Joseph Doherty 568d466303 Merge driver review fixes: MQTT deterministic host claim + re-assert (#988), Galaxy secured-write refusal + re-advise session guard (#991), Heidenhain host-status/dispose (#990), MicroLogix L files (#984), Modbus DI<n> (#981), AbCip latch + probe init bound (#983) 2026-12-03 12:09:42 -05:00
Joseph Doherty eb78875c24 fix(galaxy): #991 review — a re-advise pass never dials on a swapped session; dropped-event resync is rate-limited and coalesced
- ReadviseSubscriptionAsync: a reconnect completing between two subscriptions of a pass
  (dropped-event resync loop had no per-iteration check) sent the next SubscribeBulk to the
  NEW gateway session under the OLD session number; TryRebind refused it (SessionChanged)
  and the live new-session advises were never bound or released, then duplicated by the
  replay. The pass now refuses to dial once its session moved. Releasing afterwards was
  rejected: once the session moved, which session issued the reply's handles is ambiguous and
  old numbers are reused (#861); not dialling is the unambiguous fix.
- Dropped-event resync passes are at least 5 s apart (DropResyncMinInterval); drops reported
  meanwhile coalesce into the next pass, so repeated overflow bursts no longer churn
  re-advises into the overflowing channel.
- Test seams: ResyncDroppedHandlesForTestsAsync, NotifyEventsDroppedForTests,
  DropResyncMinIntervalForTests; AdvisingSubscriber gained after-subscribe/unsubscribe hooks.
2026-12-03 12:07:28 -05:00
Joseph Doherty 5dcb766fd1 fix(abcip): #983 review — probe timeout bounds only the probe read, not the cold initialisation
P-22 moved the probe's own short timeout (default 2 s) onto the probe runtime's cold
InitializeAsync too — on the native transport the TCP connect + RegisterSession + Forward
Open, which the pooled connection bounds with the driver's Timeout. A slow-but-healthy open
longer than the probe timeout never completed: the probe re-created and timed out every
tick and the host stayed Stopped. Initialisation now runs under the loop token only; the
probe timeout bounds the read.
2026-12-03 12:03:49 -05:00
Joseph Doherty 84a0226bfa fix(abcip): #983 review — per-call device latch only on real connection failures; never evict handles that were not attempted
- On libplctag each tag is its own request with its own timeout: one tag's Timeout latched
  the whole device for the call, failing (and evicting) every later sibling. The latch now
  fires on BadConnection/Abort/socket-IO failures always, and on Timeout only on the native
  transport, where a reply timeout faults the device's one shared channel
  (AbCipRefusals.LatchesDevice).
- Items latched out were never attempted: their handles are kept (evicting re-created, and
  for a sole lease holder re-Forward-Opened, each one next poll). The failed item's handle is
  still evicted, and a throttled cold create now latches the device so kept warm handles
  fail fast instead of each paying a timeout.
- AbCipDeadDeviceBatchTests recovery leg: the device's kept warm handles answer again.
2026-12-03 12:03:14 -05:00
Joseph Doherty 1c7e06502f fix(historian): #976 review — Gateway alarm writer isolates an unrecognised batch failure per event
#976 made StatusCode.Unknown (the gateway's handler threw) and non-RPC non-transport exceptions
RetryPlease. On the SendEvents path a RetryPlease marked the whole chunk and every later chunk
RetryPlease; with no Ack the sink treats the drain as an outage and counts nothing, so ONE such
event at the queue head stalled all Gateway alarm history until the 1,000,000-row capacity evicted
it silently. The SQL writers already isolate unrecognised failures (AlarmBatchWrite); the Gateway
writer had no equivalent.

Gateway: a RetryPlease failure that is not a known outage (IsSystemicFailure: Unavailable,
DeadlineExceeded, Cancelled, ResourceExhausted, Aborted, auth codes, typed Unavailable/auth client
exceptions, or a socket/IO/HTTP/disposed/timeout/cancellation cause) re-sends the chunk singly at
once: siblings Ack, the culprit keeps RetryPlease and dead-letters via MaxAttempts. If no single
Acks it is treated as systemic (later chunks not sent) — bounded to one chunk of singles per drain.

SQL (LOW): AlarmBatchWrite stops isolating at the first single that fails with a known outage
error; the SQL Server alarm writer passes the wider SqlHistorianConnection.IsOutage (login failed
18456/18452, unreachable/refused 2/40/53/64/121/10061/10065/-1, severity >= 20, pool timeout) —
IsTransient is unchanged for its retry callers. Fixes the false claim in docs/AlarmHistorian.md.

Tests: GatewayAlarmPoisonDrainTests (real LocalDb sink + real writer: poison at the queue head ⇒
siblings Ack on the first drain, poison dead-letters via MaxAttempts; positive control: Unavailable
outage ⇒ no single sends, nothing dead-lettered), writer-level isolation + bounded fan-out tests,
AlarmBatchWrite early-stop + no-stop-on-adjacent-poison control, SqlOutageClassificationTests.
2026-12-03 12:01:24 -05:00
Joseph Doherty 7374fdd0e4 fix(modbus): #981 review — MELSEC no longer claims the generic DI<n> discrete-input mnemonic
The S-8 gate (no generic mnemonic fallback once a family grammar claimed the address) made
the MELSEC D-register grammar, which claimed every D prefix, reject DI100 as a malformed
D-register. MELSEC has no DI device, so DI... is no longer claimed; every other D... stays
native and DL205's non-octal C rejection is untouched.
2026-12-03 11:58:15 -05:00
Joseph Doherty b74b5162d2 fix(ablegacy): #984 review — MicroLogix profile supports L files
MicroLogix 1100/1200/1400/1500 all have L (32-bit integer) files (only the ML 1000 lacks
them, and the family flag cannot tell it apart — an ML 1000 refuses an L read itself, per
tag). SupportsLongFile: false made the P-5 per-tag rule refuse every Long tag on the family
the parser, coalescer and L-bit RMW already handle. The per-tag rejection tests now pin
PLC-5, the one family without L files. Pending hardware confirmation: one L-tag read on an
ML 1400 (Vitamine press fleet).
2026-12-03 11:57:09 -05:00
Joseph Doherty 2d28f5ea8a fix(heidenhain): #990 review — host-facing state keyed by host:port survives re-init; dispose cancels before closing the session
- _facing was keyed by runtime instance: it grew one entry per re-init (watchdog every ~90 s
  while a control is down) and each new runtime restarted at Unknown, so a down control's
  status flapped Stopped -> Unknown -> Stopped across every re-init. Now keyed by host:port,
  pruned to the configured hosts at init and cleared at shutdown; a runtime no longer in
  _devices (being stopped by re-init/shutdown) announces nothing.
- DeviceRuntime.DisposeAsync cancels the loop BEFORE closing the session: closing first woke
  an in-flight read while the token was live, and the loop's normal tail set Backoff (host
  Stopped) for a plain stop. Seam AfterSessionCloseForTests makes the race deterministic.
2026-12-03 11:55:28 -05:00
Joseph Doherty 7a6e623485 fix(galaxy): #991 review — refuse SecuredWrite/VerifiedWrite locally with BadUserAccessDenied; gateway caller refusals are access refusals
G-1 routed secured/verified writes to WriteSecured, which cannot succeed (no AuthenticateUser
identity, no supervisory advise for it, the key needs invoke:secure), and the gateway's
refusal surfaced as BadCommunicationError.

- WriteOneAsync refuses SecuredWrite/VerifiedWrite BadUserAccessDenied before AddItem/advise/
  Write (one Warning per attribute, no health impact). InvokeWriteSecuredAsync removed until a
  real per-caller identity flow exists.
- gRPC PermissionDenied/Unauthenticated on the write or its supervisory advise ->
  BadUserAccessDenied (handle still forgotten; not counted as advise_failed).
- The classification seed is KEPT: it is what makes the refusal local. Unseeded, a secured
  attribute takes the supervisory raw path and the refusal would rest on MXAccess answering
  MX_E_SecuredWrite (1012) to a supervisory write, a code no live capture has shown.
- docs/drivers/Galaxy.md + Configuration.md updated.
2026-12-03 11:52:22 -05:00
Joseph Doherty f7a0dad7e3 fix(mqtt): #988 review — deterministic primary-host claim id per (hostId, group) + re-assert over a foreign OFFLINE
The M-3 fix made the blank-clientId claim id random per instance, breaking single-claim
exclusivity on a redundant pair: a Secondary cold-starting before its cluster join claimed
alongside the Primary, and its stand-down OFFLINE was left retained, newer than the
Primary's ONLINE, with nothing to correct it.

- Claim id = spbhost-<12 hex of SHA-256(hostId, groupId)>: a pair shares one id (broker
  takeover keeps the claim single; the evicted Primary reconnects and re-asserts), distinct
  groups/hosts differ; 20 chars.
- The claim subscribes to its own STATE topic. An OFFLINE seen while the claim is held (its
  own stand-down detaches first, so the echo is ignored) is re-asserted: ts <= session ts ->
  republish the session's ONLINE; newer ts -> fresh claim whose timestamp out-dates it
  (Sparkplug 3.0 edges ignore older STATE). Coalesced, <= 1 per 2 s. Reconnect re-subscribes
  before republishing so the takeover's leftover is seen.
- MiniBroker can inject a PUBLISH and records SUBSCRIBE filters; live pair test against the
  Mosquitto fixture.
2026-12-03 11:49:06 -05:00
Joseph Doherty f111d14bfb Merge #995: alarm predicates compiled once outside the gate, node-indexed stood-down items, kept drivers not re-subscribed, artifact parsed once, VirtualTag/Calculation evaluation coalesced 2026-12-03 11:16:21 -05:00
Joseph Doherty 67682af520 fix(opcuaclient): #992 name the BadTimeout constant after its OPC UA status (StatusCodeParityTests) 2026-12-03 11:07:59 -05:00
Joseph Doherty 2827a4c3bf fix(calculation): #995 change-triggered evaluations coalesce latest-wins per calc tag, so a poll cycle evaluates once against all its new inputs and the queue is bounded by the tag count
At most one evaluation is pending per calc tag; a re-trigger only moves its
timestamp forward and the dependency snapshot is taken when the pump dequeues
it. Previously every dependency arrival enqueued a separate evaluation per
dependent with a trigger-time snapshot: k inputs of one cycle ran k times
(publishing intermediates computed from mixed old/new inputs) and the queue had
no bound when triggers outpaced the pump. The out-of-process batch pump now
dequeues every pending tag once per batch.
2026-12-03 11:05:32 -05:00
Joseph Doherty 8e57311f97 Merge #993: Gateway read refusals keep historian healthy, QuestDB capped reverse events read finds its cut first, allocation-free time-weighted aggregate, QuestDB fixture visibility wait 2026-12-03 10:40:49 -05:00
Joseph Doherty aecd2461c1 Merge #991: Galaxy secured-write map filled at init, dropped pump events resync, deploy-watch backoff, replay-gap handle release, HTTP/2 keep-alive on driver channels 2026-12-03 10:36:36 -05:00
Joseph Doherty b9955f6946 Merge #988: MQTT bad filter isolated per tag, Sparkplug primary-host unique id + re-claim, rebirth counter fixed, subscribe replay race, browse honours refusals 2026-12-03 10:35:43 -05:00
Joseph Doherty 028e68edb0 fix(mqtt): #988 one bad filter/tag no longer takes the driver dark; Sparkplug rebirth cap, primary-host claim and browse verdicts behave correctly
- M-2: malformed topic filters are rejected at the reader + deploy gate (MqttTopicFilterRules);
  the manager re-checks, chunks SUBSCRIBEs at 100 filters and bisects content refusals only.
- Found while pinning M-2: retain handling rides only a 5.0 SUBSCRIBE; on 3.1.1 one
  retainSeed:false tag made MQTTnet refuse the whole batch.
- M-1: metadata rebirths capped per scope, counted when sent, re-armed only by clean data
  (not by the NBIRTH a request provokes); gap rebirths escalate to 5 min after 3 in a row.
- M-3: blank clientId => random per-instance spbhost-<12 hex> claim id (was literal -spbhost).
- M-6: a Faulted/Disposed claim connection is not held; it is disposed and re-claimed.
- M-9: subscribe-time replay re-raises a value pushed mid-replay (plain + Sparkplug).
- M-11: same-type Sparkplug arrays are served by copy, not boxed element by element.
- M-12: span JSONPath walk; span pre-filter for unauthored Sparkplug nodes; guarded Debug
  logs; WarnOnce without ConcurrentDictionary.Count.
- M-13: handles a later subscribe fully took over are retired.
- M-14: browse open fails on a refused CONNACK or root SUBACK.
- M-15: Scalar/Raw booleans publish true/false.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-03 10:35:21 -05:00
Joseph Doherty afaf6b97d5 fix(galaxy): #991 G-19 gateway channels send HTTP/2 keep-alive pings so a silently dead connection faults the event stream 2026-12-03 10:34:51 -05:00
Joseph Doherty c6dec9ed7f Merge #974 + #987: dialect-aware Sql read-only guard + read-only execution (13 bypasses closed), provider-semantics key matching, trigger-safe SQL Server rowcount 2026-12-03 10:34:08 -05:00
Joseph Doherty 65c4330a68 fix(sql): #974 #987 named queries are lexed per dialect and run read-only + single-statement; key rows attribute by server semantics; SQL Server writes count only the target statement
#974 (S-7) — the named-query guard had one lexer for five dialects and took live SQL for literal text
where a provider ends a literal earlier (MySQL backslash escapes, PostgreSQL dollar quotes, T-SQL ]],
nested comments, MySQL # / "--x", bare-CR line comments, Oracle q'..'). All 13 bypass strings were
accepted; the MySQL and PostgreSQL ones were executed against the live fixtures and the smuggled
UPDATE committed past the always-rolled-back transaction.
- SqlReadOnlyStatement (own file) lexes per provider and REFUSES constructs dialects disagree on;
  Odbc / no provider = every dialect must agree. Factory and AdminUI form pass the provider; the form
  re-validates queries on a provider change.
- ISqlDialect.BeginNamedQueryAsync / SealNamedQueryCommand / EndNamedQueryAsync: PostgreSQL and Oracle
  SET TRANSACTION READ ONLY; MySQL read-only session + transaction (restored after); PostgreSQL rewrites
  @name markers to positional $n (a parameterless query gets one unused typed $1) so Npgsql sends the
  text unsplit and the server refuses a second statement.

#987 (S-6) — key-value rows are attributed by SqlKeyMatcher (exact, then typed / padding-insensitive,
then case/accent-insensitive — only for rows the server matched); a named query's rowKey uses the
exact + representational stages only.
#987 (S-10) — SQL Server table writes read the target statement's own @@ROWCOUNT through an OUTPUT
parameter; SqlClient's ExecuteNonQuery sums trigger DML (reproduced: 1 + 2 audit rows = 3, every write
rolled back BadConfigurationError).

Tests: per-dialect bypass theory + positive controls, matcher + SQLite collation/affinity attribution,
Postgres seal, dialect-hook wiring, SQL Server write-plan capture; live NamedQueryBypassLiveTests
(PG/MySQL/Oracle), SqlServerTriggerWriteLiveTests, MySQL writing-function now refused.
2026-12-03 10:33:45 -05:00
Joseph Doherty d66aa5e9ff fix(galaxy): #991 G-5 the per-event subscriber lookup no longer allocates and the pump reuses one handle per subscription 2026-12-03 10:28:36 -05:00
Joseph Doherty 9ba33e7caa fix(galaxy): #991 G-1 authored SecuredWrite/VerifiedWrite tags route to WriteSecured without DiscoverAsync (security map seeded at init and on redeploy) 2026-12-03 10:25:53 -05:00