Commit Graph

3460 Commits

Author SHA1 Message Date
Joseph Doherty b9bd7960de test(grpc-data): #1098 attribute the consumer side of the projected publish path per thread
ProjectedDataAccess gets a test-only IProjectedPublishProbe (null in production) over six synchronous
sections: the stream pump, the frame queue, the cohort loop's dispatch, a value's build, its publication
and the frame's release. The perf harness prints them and the remainder against the process-wide figure.
Release, 10k cohort, 5 runs: the ~600-650 B/value that #1094 left unattributed is Pump 84-209 (the LINQ
Sum's boxed enumerator plus SemaphoreSlim.WaitAsync under a full frame window), Queue 40 (FrameEvent),
Build 184 (DataValueSnapshot + ProjectedValueUpdate), Publish 208 (the latest-sample cache re-wrapping
the update in two identical records, plus the one-element list), Release 55-88 (enumerators boxed by
the frame disposes); 15-51 B/value stays unattributed (other threads).
2026-12-04 17:36:54 -05:00
Joseph Doherty 50a2acb2be Merge scripting follow-ups: dynamic tag paths are editor warnings where the gate accepts them, one rule owns the split (#1083); returned collections materialised + capped identically in both runners, heartbeat tests sized for whole-process stalls (#1092); Calculation-mode {{equip}} hover (#1093) 2026-12-04 15:46:29 -05:00
Joseph Doherty 61546d5aab fix(scripting): #1092 a returned concrete collection (List<T>, HashSet<T>, ...) is materialised into the same typed array in both runners
ScriptResultMaterializer returned a non-array ICollection as-is (capped by Count only), so
in process the host got the List<double> itself while the out-of-process worker, whose wire
carries arrays but no collection type, answered "unsupported type" for the same script.
Every non-array, non-string sequence now goes through the one materialisation: a collection
is held to Scripting:MaxResultElements by its Count before it is copied, then becomes T[]
of its IEnumerable<T> element type; an open element type (List<object>, List<List<int>>) or
none (ArrayList) is refused like the lazy equivalent. Both runners give double[] for a
List<double>.

ParityTests.Result_materialisation_and_the_element_cap_agree gains list / at-cap / over-cap
/ hash set / queue / List<object> / nested-list rows plus a positive control (6 rows + the
control fail against the old materializer). ContainmentTests' "unsupported result type"
example moves from List<int> (now int[]) to KeyValuePair<int,int>.

Behaviour change: a script returning List<object> (or another open element type) now fails
the run (Bad + script log) in process too, as the lazy form already did.
2026-12-04 15:14:16 -05:00
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 bd4fff6444 fix(scripting): #1083 a dynamic tag path is an editor error only where the gate refuses it (predicate), a warning in value/Calculation mode; #1093 Calculation-mode {{equip}} hover says it is refused
#1083: OTSCRIPT_DYNPATH was an error in every editor mode while the deploy gate refuses a
non-literal tag path only for a scripted-alarm predicate (editor stricter than the gate).
Decision: do not make the gate stricter (it would reject configurations that deploy today).
ScriptCompileRules now owns the split — RefusesNonLiteralTagPaths(kind) and
TagPathFindings(kind, source), each finding carrying Refuses — the gate refuses on exactly
those findings and the editor draws them as errors (8) and the rest as warnings (4), whose
text says what the path does at runtime (not a declared input: not subscribed, does not
re-trigger, reads BadNodeIdUnknown unless also read literally). DependencyRejection gains
Kind + MethodName for that wording. EditorGateParityTests carries dynamic / concatenated /
interpolated / empty paths in all three modes (14 rows fail with the old always-error
severity).

#1093: hovering a {{equip}} path literal in Calculation mode showed the VirtualTag
"resolves ... when deployed" text, contradicting the OTSCRIPT_EQUIPCALC marker on the same
span. It now says the token is refused in a Calculation script and why (no owning
equipment, never substituted, the gate refuses it). The {{equip}} hover no longer needs a
tag catalog.
2026-12-04 15:02:41 -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 2f22003061 feat(analyzers): #1091 OTOPCUA0001 guards the caller-aware write capabilities
- ICallerAwareWritable and the new ICallerAwareWriteOutcomeCapability join the guarded-interface list. Each derives
  from a guarded interface but declares its OWN member, which is not an implementation of the base's, so
  callerAware.WriteAsync(writes, caller, ct) on an interface or concrete receiver passed unflagged.
- ICallerAwareWriteOutcomeCapability (Core.Abstractions.DataConnections): IWriteOutcomeCapability on behalf of a
  WriteCaller, for the gRPC data-connection write path (used by the Galaxy driver, next commit).
- Tests: unwrapped caller-aware WriteAsync trips on interface AND concrete receivers; the caller-aware outcome
  overload trips unwrapped and passes wrapped (positive control). Both failed (0 diagnostics) with the two
  entries removed from the list.
2026-12-04 14:58:00 -05:00
Joseph Doherty 52b126584c Merge gRPC data perf harness (#1094 test item): per-thread publish-path allocation sections, counter-based wait instead of copying polls 2026-12-04 14:38:16 -05:00
Joseph Doherty 77a78d5bd3 test(grpc-data): #1094 perf harness measures the publish path per thread and polls a counter instead of copying 10k values 2026-12-04 14:37:59 -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 5c2d06a94e Merge AdminUI follow-up: mapping Local parent becomes a cluster-scoped container tree picker; a realm switch clears the stale root/parent/remote root (#1090) 2026-12-04 14:32:19 -05:00
Joseph Doherty 3be3091908 feat(adminui): #1090 local-parent tree picker + clear realm-scoped roots on realm change 2026-12-04 14:32:11 -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 ec4eed337c Merge runtime follow-ups: a retired driver child's late ConnectivityChanged no longer overrules a connected replacement (#1070, race confirmed deterministically), node-manager-only wiring guard for the authorizer delegates (#1079) 2026-12-04 14:11:56 -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 be58573822 feat(grpc-data): #1074 gRPC data-connection writes carry the connection's caller to a caller-aware driver (Galaxy SecuredWrite)
- DriverInstanceActor's rich write path (RouteRichWrite -> WriteAttributeWithOutcome) now hands an
  ICallerAwareWritable driver WriteCaller(principal, apiKeyId) taken from the DataWriteAdmission, i.e.
  the connection's authenticated DataAuthenticatedContext (never the request payload), re-checked by the
  dispatch gate's commit. Same caller shape as the OPC UA path (#1017). No proto change: the identity was
  already server-side. IWriteOutcomeCapability keeps precedence (no driver implements both today).
- Fail-closed unchanged: Galaxy resolves only the key's own identity (no fallback); no identity => refused.
- Tests: rich write reaches the caller-aware overload with the admitted principal/key (failed before: the
  caller-less overload was used); OPC UA WriteAttribute and gRPC rich write deliver equal WriteCallers; a
  real GalaxyDriver in ApiKeyIdentity mode resolves the connection key's identity end to end.
- Docs: Galaxy.md (gRPC path, federated writes run as the LINK key's identity, refusal reported as
  OutcomeUnknown on the legacy path), DataConnections.md, security.md, rules/drivers.md.
2026-12-03 16:51:26 -05:00
Joseph Doherty 8cc9f8fc46 Merge gRPC data follow-ups (#1080): allocation-light projected publish (one ValueDelivery per value, synchronous enqueue when a slot is free, reused window waiter; ~20% fewer bytes/value), held connection's stale mark timed from the hold start 2026-12-03 16:50:07 -05:00
Joseph Doherty 00ac75e33a Merge scripting follow-ups: one shared compile rule for editor + gate, CS0161/injection now flagged in the editor (#1063), worker applies the result materialisation cap (#1064), {{equip}} in Calculation scripts refused at gate + editor (#1065) 2026-12-03 16:49:40 -05:00
Joseph Doherty bac7cfeaa9 perf(grpc-data): #1080 projected publish - per-value delivery without closures, sync enqueue, pooled full-window wait
- PendingDelivery is an abstract base: ValueDelivery carries a value's state in fields (was a closure +
  seven delegates per value), DelegateDelivery keeps the delegate form for controls/acks/conditions.
  One ValueLease replaces BudgetLease + one or two CompositeLeases (same release order).
- EnqueueAsync returns ValueTask and completes synchronously when a slot is free. A full window waits on
  the session's reused SlotWaiter (signalled by every dequeue and by Stop, which sets _closed first)
  instead of the channel's WriteAsync (a writer operation + cancellation registration per wait); the
  wait and TickAsync/PumpSnapshotsAsync/ConsiderAsync use PoolingAsyncValueTaskMethodBuilder, as do the
  reader's MoveNextAsync/NextPendingAsync. The #994 behaviour is unchanged: an ack meeting a full window
  waits for the reader and never resets the stream.
- ConsiderAsync decides 'already considered / not yet due' on a version peek before taking a full
  cache read (CachedSourceRead + sample copy + value).
- The tick signal is one shared immutable Work.

New test: a worker waiting on a full window ends when the stream stops and releases what it held
(fails if Stop does not wake the waiter).
2026-12-03 16:47:48 -05:00
Joseph Doherty 2ff8767487 fix(grpc-data): #1080 a held connection's stale mark is timed from the hold start, not the loop unwind
The held runner's stale timer was created only after its loop had unwound, so under load the
BadNoCommunication mark came a full stale timeout after a slow unwind - late, or skipped when the
MaxHold release (timed from the hold) ended the hold first. The timer now starts with the hold; a
mark due before the unwind waits for it (no late Good from that loop can follow the mark) and lands
at the unwind.

Tests (fake clock, ProjectedConditionAccess on ManualTimeProvider; the fixture can gate the runner's
lease release to model a slow unwind): the mark lands at the unwind when it fell due earlier, still
before MaxHold (failed before the fix: no mark, the release came first); and lands exactly at hold
start + stale timeout with a prompt unwind.
2026-12-03 16:47:41 -05:00
Joseph Doherty 73f49eaf32 fix(scripting): #1063 one compile-refusal authority for editor and deploy gate (ScriptCompileRules + the runtime's own wrapper text) — CS0161 and wrapper injection are now flagged in the editor; #1065 {{equip}} in a Calculation script is refused by the gate and by a new Calculation editor mode
#1063: the Monaco diagnostics dropped every Roslyn error located in the synthesized
wrapper as 'phantom', so CS0161 (not all code paths return a value, pinned on Run)
passed the editor and failed the deploy gate. ScriptCompileRules (Core.Scripting) now
states which diagnostics refuse (every Error, wherever located; LMX001/002 injection)
and which sources skip the compile (blank/passthrough value scripts); ScriptEvaluator
and the editor both use it, and the editor wraps with ScriptEvaluator.WrapperPreamble/
WrapperSuffix instead of its own copy. Wrapper-located refusals are drawn on the
script's last line. EditorGateParityTests runs one corpus through editor and gate in
all three modes.

#1065: a Calculation tag is raw/device-level with no equipment and its seam never
substitutes {{equip}}, so such a script deployed clean and read Bad forever. Refused
rather than substituted: EquipTokenLiteralScanner.FindInCalculation is run by
RoslynDeployScriptChecker for every Calculation use (before the passthrough shortcut,
outside the shared VT/Calc cache) and by the editor in the new 'calculation' mode
(Calculation tag editor; ScriptEdit defaults to it when a Calculation tag uses the
script).
2026-12-03 16:47:14 -05:00
Joseph Doherty 90ae995bf4 fix(runtime): #1070 a stopped incarnation's late ConnectivityChanged no longer overrules a connected replacement
Confirmed, deterministically: Context.Stop is asynchronous and messages from two children are unordered, so an operator
Restart's old child announced comms loss from PostStop AFTER the replacement had connected and pushed its initial values
(the old child reaches its stop only once a synchronous driver call returns). The host then stamped every value node
BadNoCommunication with nothing left to re-publish them, re-latched them and cancelled the new incarnation's recovery
audit - nodes stuck Bad, tripwire disarmed. Pre-fix the new test saw 2 status batches where 1 is correct.

Fix at the root, in DriverHostActor.OnDriverConnectivityChanged: IsStaleRetiredConnectivity drops, whole, any
Connected=true from a retired child, and its Connected=false once the current child of the same id has announced
Connected (new ChildEntry.Connected, set only from the current child's own edges). A retired Bad edge is still applied
while the replacement has not connected (or there is none) - the 03/S15 gap cover Restart/respawn rely on; same rule the
condition-signal tracker already applied. Senders that were never children are not filtered.

Tests (DriverHostStaleConnectivityTests): the race made deterministic by wedging the old child in a blocking
GetHostStatuses; positive control = a Force Reconnect of the current child must yield exactly one status batch before the
re-subscribe push. Companion: a retired Bad edge before the replacement connects still stamps Bad and the push recovers.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-12-03 16:40:11 -05:00
Joseph Doherty 6459cce846 Merge AdminUI follow-up: data-connection export/remote root pickers become cluster-scoped Raw/UNS tree pickers (#1077); keeps #1051's manual Kind|EntityId export-root entry 2026-12-03 16:38:16 -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 201ca44088 feat(adminui): #1077 tree pickers for data-connection export-root and remote-root
RawTree gains an opt-in single-select NodePickMode (any entity kind); new UnsRootPicker and
DataRootPickerModal; cluster-scoped trees built from the draft snapshot. Stored kinds and
validation unchanged.
2026-12-03 16:36:33 -05:00
Joseph Doherty a06dc8dd9f fix(scripting): #1064 the ScriptWorker applies the in-process result rule — a returned lazy sequence is materialised inside the run and held to Scripting:MaxResultElements (Hello.max_result_elements), same value and same failure text in both runners 2026-12-03 16:35:01 -05:00
Joseph Doherty dface0441e test(opcua-acl): #1079 guard: the node manager is the only wirer of the authorizer's ImportedConditionClassifier / MappedNamespacePredicate
The #1033 flag-off revalidation fast path (IsLocalNodeUngated) answers a local Raw/UNS item allow without the
authorizer, sound only while those two delegates are the node manager's own ClassifyImportedCondition /
IsProjectedDescendant. Source-scan guard over src/**/*.cs (RoleAuthorityGuardTests idiom): any assignment outside
OtOpcUaNodeManager.cs, or one there to another delegate, fails; non-vacuity counts the real wiring sites; a
falsification test feeds offending snippets. Mutation-checked against the real tree (a rogue assignment in
DataPlaneAuthorizer.cs fails it).

Co-Authored-By: Claude <noreply@anthropic.com>
2026-12-03 16:34:36 -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 7e55bd7366 Merge Sql/AbLegacy follow-ups: one shared Sql driver JSON options definition for driver + deploy gate (#1076), AbLegacy read-plan memoisation keyed on the exact reference list (#1073) 2026-12-03 16:30:26 -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 762bcd7b8d feat(admin): #1078 headless POST /api/cluster/failover (key-gated, same service+audit) and unattended SCM-restart gate
fix(install): #1075 worker identity gets read+execute (not Modify) on <PeCacheDir>\pe; re-run replaces the old grant
2026-12-03 16:29:27 -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 7c78a4f456 Merge gRPC data follow-ups (#1057): refuse LimitExceeded before ack, sibling invalidation no longer resets a snapshot, per-stream snapshot slots, ~20% fewer bytes per projected value; R2_S2 hold-stale test timing 2026-12-03 16:05:03 -05:00
Joseph Doherty 50a4887d83 Merge ControlPlane/core/authz follow-ups: coordinator DB writes off-thread + audit retry (#1051), resilience counts every failed attempt + zero-alloc scoped keys (#1052), AcquisitionSubscribe capability (#1047), audit drop metric + SCM restart test script (#1030), zero-alloc warm UNS ACL + unresolvable-ref backoff (#1053), flag-off revalidation fast path (#1033)
# Conflicts:
#	src/Server/ZB.MOM.WW.OtOpcUa.ControlPlane/AdminOperations/AdminOperationsActor.cs
2026-12-03 15:47:13 -05:00
Joseph Doherty 17dac6a536 Merge ConfigDb follow-ups: script FKs + ZTag/SAPID filtered unique indexes, ExternalIdReservation retired (#1040/#1049, migration ScriptForeignKeysAndExternalIdUniqueness with pre-check), SqlNamedQueryInvalid deploy rule (#1058), read-only otopcua-preflight upgrade tool (#1013/#1015/#1021)
# Conflicts:
#	docs/VirtualTags.md
2026-12-03 15:42:25 -05:00
Joseph Doherty 6cffffe673 feat(tooling): #1013 #1015 #1021 #1058 read-only upgrade preflight (otopcua-preflight)
One command, run from the NEW build against a ConfigDb BEFORE its migrations, that names every row
the upgrade or the next deploy would refuse; exit 1 if any, 2 if unreachable / not v3.
- migration:* — row-naming twins of the constraint-adding migrations' pre-checks
  (ConfigurationGapsIndexesAndRowVersions: duplicate NodeAcl / LdapGroupRoleMapping;
  ScriptForeignKeysAndExternalIdUniqueness: NULL ScriptId, dangling VT/alarm scripts, duplicate
  ZTag/SAPID, reservation rows). (#1021)
- deploy-gate — DeployGateRules, the gate's rule pass now extracted from AdminOperationsActor so
  both run the same code: every DraftValidator rule incl. VirtualTagNameInvalid /
  UnsEffectiveNameInvalid / *ScriptNotFound (#1015) and SqlNamedQueryInvalid (#1058), topology,
  TagConfig inspection.
- script-gate — DeployScriptGate through RoslynDeployScriptChecker, plus every unused stored
  script (Warning). (#1013)
An older schema is read through this build's model: tables a pending migration creates map to a
typed zero-row query, added columns are left out of the model (LegacySchemaTolerance). SNAPSHOT
read when allowed. Logic in ControlPlane/Preflight (Roslyn-free); the console shell binds Roslyn.
Real-SQL tests: an old-schema DB with every finding class (and nothing written), clean controls,
NULL ScriptId -> SnapshotUnreadable, non-v3 refused. docs/v2/upgrade-preflight.md records the dev
runs; production runs stay user-gated (wonder-box hold).
2026-12-03 15:41:30 -05:00
Joseph Doherty 288ca70c4a fix(sql): #1058 deploy gate refuses a named query the Sql driver would refuse at start (SqlNamedQueryInvalid)
The driver runs SqlNamedQueryRules.Describe over every queries entry with its provider at
construction, and one refused query fails the whole driver (every tag BadNodeIdUnknown). Since #974
that includes a T-SQL parse for SqlServer/Odbc/no-provider, so an Odbc query written in another
dialect (LIMIT, ILIKE, 'a'::text) that used to pass is refused after the upgrade. The gate now runs
the same rule over the same merged config (factory-equivalent JSON options), naming the instance.
Noted: a bare col::type PARSES as T-SQL static-member syntax and is accepted by both.
2026-12-03 15:41:21 -05:00
Joseph Doherty 36b90dfa31 Merge security follow-ups: host-side PE-cache signing, worker no longer holds the HMAC key (#1014); Akka remoting untrusted-mode + trusted-selection-paths by default, opt-in mutual TLS (#1003) 2026-12-03 15:40:32 -05:00
Joseph Doherty ef4e1668de feat(cluster): #1003 Akka remoting hardening — untrusted-mode on by default, mutual TLS opt-in
Follow-up of #973 (review 2026-12-02 A-1). New Cluster:Remoting section (AkkaRemotingOptions):

- UntrustedMode (default ON): akka.remote.untrusted-mode with trusted-selection-paths =
  every path this code base reaches by ActorSelection across nodes, enumerated from the Akka
  1.5.62 sources + src/: cluster core daemon + heartbeat receiver, remote-watcher, the DPS
  mediator, /user/{s} + /user/{s}/{s} for each ControlPlane singleton, /user/driver-host.
  Remote deployment and peer PoisonPill/Kill are dropped. Receive-side only, so a mixed
  old/new pair keeps working through a rolling upgrade. Drops (Akka logs them at Debug)
  become a Warning per path + otopcua.cluster.remoting.untrusted_drops.
  AdditionalTrustedSelectionPaths / UntrustedMode=false are the escape hatches.
- Tls (default OFF): mutual TLS on the DotNetty transport (PFX or store cert, mutual auth
  on by default, thumbprint pinning or chain validation, optional hostname check). Seeds and
  the diagnostics selection follow the transport scheme (akka.ssl.tcp); the bootstrap guard
  parses it. Validated at boot.

Proven on real clusters: pair formation, singleton via proxy + hand-over on leave, DPS, zero
drops; untrusted selection dropped (and delivered with the mode off); pinned TLS peers form,
an unpinned node cannot join; full two-node Host harness (deploys from both nodes,
diagnostics, node restart) with zero drops + positive control. Guards fail when a new
singleton or ActorSelection appears without its trusted path.
2026-12-03 15:35:56 -05:00
Joseph Doherty 355798cc8e Merge runtime follow-ups: timer VT drops scheduler catch-up tick bursts after a stall (#1061, real cause of the coalesce flake), late device confirmation after revert lands (#1041), artifact hash off the pinned thread + mux ConsumerRefs guard (#1054) 2026-12-03 15:32:07 -05:00
Joseph Doherty 7cda8dbb81 perf(opcua-acl): #1033 flag-off revalidation answers local items before the pass memo
With Security:Acl:Enabled=false a revalidation pass over local Raw/UNS items is an unconditional allow; it still paid a
(session, ns, id) memo entry and the full Permits walk per item. Measured over 10k items: ~6.5-7 ms and ~1.4 MB per pass
-> ~0.5-1 ms and ~0.2 KB. IsLocalNodeUngated mirrors exactly what Permits concludes there and excludes the one wiring
where it differs (mapped resolver without the projected predicate). The same shortcut inside the per-request Permits was
measured and NOT taken: a 1,000-node flag-off Read stayed ~1.5-1.9 ms either way (SDK read dominates).

Co-Authored-By: Claude <noreply@anthropic.com>
2026-12-03 15:31:38 -05:00
Joseph Doherty 6ea0f09614 perf(acl,grpc-data): #1053 alloc-free warm UNS ACL decisions; unresolvable configured refs back off; restart keeps the comms latch (decided)
U-8: a warm cached decision on a UNS node allocated 416-680 B/call ahead of the cache (live id-chain list, identifier
split, LINQ, segment array, string.Join key, DataCallerIdentity). Now 0 B: the live chain is cached per folder instance
(re-verified against the live ancestry every call), the generation hands out one segment array per path, the authorizer
keys its resolved cache keys on that array, reference variables key on their own identifier (scope = its split), and
the caller identity is built once per session identity.

R-25: ConfiguredProjectedInterestOwner re-ran discovery for an unresolvable configured reference every 1 s sweep forever;
a failed resolve now backs off 1 s doubling to 30 s (60 s unreachable: 61 discoveries -> 6). Publishing into the source hub
only for sources with interest is DECLINED: that cache answers a new subscription's first snapshot and projected Reads.

Restart comms latch (decided: keep): the nodes stay Bad across an operator Restart and the respawned incarnation must
re-publish them; the stopped child's PostStop announcement already re-latches and cancels the old audit. Pinned by test.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-12-03 15:31:38 -05:00
Joseph Doherty a6e5ae8aa2 perf(grpc-data): #1057 trim the projected publish path's per-value allocation; allocation-free catalog/subject resolve
Measured with GrpcDataWave3PerfTests (10k-item cohort, 100 source versions at 1k/s; numbers in the issue report).
- Core: MappedSubjectResolver.Resolve returns shared immutable resolutions (built once per subject) and compares
  scope/ancestry by index (no MappedSubjectResolution + 2 enumerators per call, several calls per value);
  DataOperationPolicy checks segments by index and builds its local scope key with one exact-length string.Create.
- Origin: LocalExportCatalog.TryResolve compares the view field by field instead of building 'view with { Address }'
  (and LocalAddress no longer copies an exactly-spelled address); the frame Eligible check peeks the latest READY
  version (PartitionedSampleHub.TryPeekReadyVersion) instead of retaining a second sample per value; TickAsync reuses
  worker-owned lists (interest groups, changes via SourceInterestLease.TryReadChanges(into), delivery slice via
  DeliveryScheduler.TakeSlice(into), due items) and the delivery index reuses one ready-list node per source.
- Consumer: PublishPacedAsync is a ValueTask; the cohort and RemoteSubscription walk frame items by index; renewal
  prunes expired witnesses in place.
2026-12-03 15:31:31 -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 ca5ee2ac57 fix(virtualtags): #1061 a scheduler catch-up burst evaluates a timer tag once, not once per missed tick
Root cause of the intermittent VirtualTagActorTimerTests coalesce failure (full suite only):
Akka's HashedWheelTimer does not skip ticks it missed while its thread was stalled (GC pause,
CPU starvation) - it delivers them all in one burst when it resumes. Measured with a parked
scheduler thread: a 600 ms stall => 12 ticks within the same millisecond. Ticks that fell due
during the gated run therefore landed just after the release, each a fresh evaluation, and broke
the post-release bound. In production the same burst multiplied every timer tag's script runs by
stall/interval after any stall.

VirtualTagActor now drops a tick that lands within half an interval of the last timer
evaluation (scheduler monotonic clock); the regular cadence is unaffected. New deterministic
test parks the scheduler thread for 600 ms with the release inside the stall: failed 3/3
before the fix, passes after, with a cadence positive control. The in-flight assertion
(Calls == 1 while gated) has no such mechanism - ticks during a run are dropped - and did not
fail in 3 full-suite + 12 class-scoped trx runs under load average ~490.
2026-12-03 15:25:10 -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