Commit Graph

1739 Commits

Author SHA1 Message Date
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 e967042fbb fix(runtime): #1054 the artifact hash moves off the OPC UA pinned thread; new mux readers are guarded into ConsumerRefs
#995 follow-up 1: OpcUaPublishActor still SHA-256'd every rebuild's artifact once on its pinned
thread (WithArtifactRevision). DriverHostActor already hashes the same bytes for its catalog
attempt, so it now stamps RebuildAddressSpace.ArtifactRevision at all three send sites (deploy
apply, boot-from-cache, bootstrap restore) from a per-blob ConditionalWeakTable memo (one hash
per blob instance, no lifetime extension). The publish actor's fallback hash stays for unstamped
senders and is observable through TestHooks.OnArtifactHashed.

#995 follow-up 2: DependencyMuxConsumerRegistrationGuardTests scans src for every
DependencyMuxActor.RegisterInterest sender; an unlisted one fails with the instruction to fold
its refs into DriverHostActor.ConsumerRefs, and each listed replay-opting consumer's composition
term must still appear in ConsumerRefs (mutation-checked). The historization recorder is the one
exempt, non-replay registrant.
2026-12-03 15:10:24 -05:00
Joseph Doherty 186b5d696d fix(opcua): #1041 a device confirmation arriving after a newer write's revert lands instead of being dropped
#979 follow-up 1: write A then B, B refused first (node reverts to the pre-A value P), the
device confirms A afterwards. The revert closed the overlap window and A's success was dropped
as an outcome from a closed window, so the node showed P while the device held A until the
next driver publication. EquipmentVariableState.CloseWindowAfterRevert now keeps the window's
still-pending older attempts (bounded like the window, carried across later reverts above the
confirmed floor); a late success of one lands its tuple (LateConfirm) when nothing touched the
node since the revert, or becomes the confirmed tuple of a window opened since. A driver
publication or a newer owner's success discards them.

#979 follow-up 2 (dependents keep last value during operator Restart / config respawn): not a
defect - the stopped child's PostStop comms-loss fan (03/S15) reaches the dependency mux and
hands dependents BadNoCommunication until the new driver object publishes. Pinned by two new
DriverHostActorSourceRemovedTests (identical-value recovery); mutation-checked: removing the
PostStop ConnectivityChanged fails both.
2026-12-03 15:10:17 -05:00
Joseph Doherty cc7155e5e9 test(virtualtags): diagnostic messages on the tick-coalescing assertions (intermittent full-suite failure) 2026-12-03 12:57:35 -05:00
Joseph Doherty 93ccbb6d83 Merge #994 fix: origin session waits for a delivery-window slot instead of resetting the stream when command acks meet a full window (cohort double-open race) 2026-12-03 12:30:13 -05:00
Joseph Doherty ded28d9e47 fix(grpc-data): a command ack that meets a full delivery window waits for the reader instead of resetting the stream
Root cause of the ~1-in-20 flake in GrpcDataCohortScaleTests.R2_a_cohort_above_1024_items_opens_on_one_origin_stream
(Opens = 2): a production race in the origin DataSubscriptionSession, not a fixture artifact.

The session's bounded outbound window (MaxPendingFrames) is shared by values, snapshot controls and command acks. The
snapshot pump leaves exactly one slot "for command acknowledgements", but a peer may have up to MaxCommands commands
in flight (the #994 projected cohort keeps 4 outstanding). When the reader was a few frames behind, an open/add's
snapshot filled the window, the next add's ack took the reserved slot, and the following ack's TryWrite failed;
EnqueueAsync then CloseWithReset("Pending control capacity exhausted.") the whole stream, and the cohort re-opened
all 1100 items on a second origin stream. Instrumented repro: the failing run's trace shows exactly that reset on the
1100-item cohort's first stream, then a second COHORT OPEN with epoch=2; the reset never appeared in passing runs.

Fix: EnqueueAsync (production callers all on the command worker) now awaits the window when it is full instead of
resetting — backpressure on the worker, never on the reader. A reader that never drains is still bounded by the ack
deadline, the session lifetime and the bounded command queue. The values cap (MaxPendingFrames - 2) still resets.

Regression: GrpcDataDeliveryWindowTests drives an 8-frame window with an unread open + 3 adds on a frozen clock; the
OutboundFullForTests seam proves an ack met a full window. Before the fix the stream ended with that reset; after it
every ack, SnapshotEnd and baseline arrives with no Reset.

Verified: GrpcDataCohortScaleTests + GrpcDataDeliveryWindowTests 30/30 consecutive passes (plus 30/30 instrumented
with zero "Pending control capacity" resets); full Runtime.Tests (Category!=SlowUnit) 2283 passed / 0 failed.
2026-12-03 12:30:00 -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 743d9e739d fix(adminui): #973 review — fleet-diagnostics target check: ASCII digits, \z anchor, TryParse
FleetDiagnosticsTargets.IsWellFormed used \d (any Unicode decimal digit, so
'host:٤٠٥٣' matched and int.Parse threw FormatException, crashing the page) and
$ (matches before a trailing '\n', which int.Parse then ignored, so
'host:4053\n' was 'well-formed' and could reach the akka.tcp address). Now
[0-9]{1,5}\z and int.TryParse(NumberStyles.None). Regression rows for trailing
newline, Arabic-Indic / full-width / mixed digits, and Resolve refusing them
without throwing (positive control kept); all failed first.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-12-03 12:27:03 -05:00
Joseph Doherty 81cf44cb90 fix(security): #975 review — re-read directory groups at each AdminUI session re-validation (Auth 0.5.0)
AdminSessionRevalidator re-mapped the groups frozen into the cookie at sign-in,
so removing a user from a directory group changed nothing until
MaxSessionMinutes ended the session.

Bump ZB.MOM.WW.Auth.{Abstractions,Ldap,AspNetCore} 0.4.1 -> 0.5.0 (additive
ILdapGroupLookup; 0.4.2-0.4.4 changes only affect BindMode=User / API-key SQL
stores, unused here; solution builds clean). OtOpcUaLdapAuthService now
implements ILdapGroupLookup with the same Enabled / DevStubMode / insecure-
transport rules as sign-in, registered as the same singleton (a stub
ILdapAuthService gets a NotSupported lookup).

At each re-validation interval the revalidator looks the user up: Found ->
fresh groups replace the session's otopcua:group claims and are mapped;
UserNotFound / UserDisabled / AmbiguousUser / Found-with-no-groups -> reject;
DirectoryUnavailable (or a lookup fault) -> fail-soft on the last known groups
(still re-mapped), bounded by MaxSessionMinutes; NotSupported / ProviderDisabled
-> previous behaviour. Never queried under DisableLogin.

Tests (directory rows failed first): group removal / addition picked up after
the window, unchanged membership kept (positive control), four end-the-session
statuses, outage keeps the session until the absolute cap, DisableLogin issues
no lookup (control: one lookup otherwise); wrapper lookup rules + DI
registration. docs/security.md drops the 'no password-less lookup' claim.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-12-03 12:25:41 -05:00
Joseph Doherty a164c76086 test(virtualtags): elapsed-relative bound for the tick-coalescing test (flaked under full-suite load) 2026-12-03 12:10:38 -05:00
Joseph Doherty ec9c0f2eb6 Merge review fixes: termination watchdog exits 1 on cluster leave/down under Akka.Hosting (#980, windev SCM gate passed); Gateway alarm writer isolates poison events (#976) 2026-12-03 12:01:50 -05:00
Joseph Doherty b8fadac80e Merge review fixes: superseded deployment's ack write no longer drops successor's ack (#996); degraded-apply repair re-pushes drivers (#995) 2026-12-03 12:01:14 -05:00
Joseph Doherty d40dd83517 Merge #994: projected cohorts batch + pace commands (multi-item cohorts work; 10k opens), per-source change scans/invalidations, backpressure not teardown, memoised per-frame authz, node-indexed publish, O(1) eviction 2026-12-03 12:01:14 -05:00
Joseph Doherty 48b5f9c466 fix(runtime): #995 review — a repair of a degraded apply re-pushes the drivers whose nodes it creates
OpcUaPublishActor reported AddressSpaceRebuilt only after a real full rebuild, so the empty-plan repair of a degraded
composition, the #977 R-4 whole-composition re-ensure, and the re-diff after a degraded non-rebuild all reported a
clean non-rebuild. The degraded apply's own re-push had run while the node it failed to place was missing; the apply
that finally created it skipped the node's driver (fingerprint unchanged), so the node stayed
BadWaitingForInitialData until its value changed — forever for a constant.

- The publish actor now reports AddressSpaceRebuilt=true when the apply ran a repair pass (either branch) or when the
  previous apply of any kind ended degraded (final outcome, completion + catalog included); DriverHostActor re-pushes
  the deploy's skipped drivers on it. A clean apply after the repair reports false again.
- DriverLifecycle.md / rules note the widened signal.

Tests: DriverHostActorDegradedRepairReseedTests (REAL publish actor: degraded add, degraded rebuild + empty-plan
repair, degraded rebuild + R-4 repair; skip still works afterwards) and OpcUaPublishActorApplyOutcomeTests (outcome
on both repair branches + after a degraded non-rebuild, with clean-no-op controls) — all six failed before the fix.
2026-12-03 12:00:32 -05:00
Joseph Doherty 5cccfd75ce fix(grpc-data): #994 projected cohorts batch, pace and scale past one item; busy origins no longer reset quiet streams
Wave 3 of the 2026-12-02 review (docs/reviews/2026-12-02/01-runtime.md R-2/3/7/8/9/10/12/13/21/22/23/24,
02-opcuaserver.md U-10/11/12/13).

Consumer (ProjectedDataAccess cohort):
- R-2: a cohort's OpenSubscription declared a snapshot budget of 1 item, which the origin uses to size the stream's
  handle table, so the 2nd item was refused LimitExceeded and the cohort re-opened in a loop (two projected items of
  one interval broke each other). Opens/adds/removes are now batched (IDataSubscriptionCommandLimits, <=256 items,
  bounded by estimated snapshot bytes) and paced (32 burst, 32/s, <=4 commands or snapshots outstanding).
- R-7: control events no longer share the bounded frame queue; a failed Remove can no longer Stop() the cohort.
- R-10: a local capacity refusal (TryPublishOrBackpressure -> CapacityExhausted) is retried for up to 2 s instead of
  invalidating healthy evidence and retiring the route.
- R-13: RemoteSubscription mutates its handle/version tables in place; the cohort caches the source per binding and
  drops the per-sample LINQ in EvidenceFor.
- R-8: only an unselectable endpoint arms the discovery backoff; a caller cancel is OperationCanceledException.
- R-24: the condition stream cancels and observes a pending frame read before disposing the enumerator.

Origin (DataSubscriptionSession / SamplePartition / SourceInterestLease):
- R-2 (found by the perf harness): the delivery index was sized MaxPendingFrames x 16 = 1024, so the 1025th item of a
  stream stopped the session after its ack; it now covers MaxMonitoredItems.
- R-3: interest reads count only own-ticket matches (scan budget separate), re-queue a lagging tick, and catch up from
  per-source last-change versions when the bounded history rolled off - no more "Source change history expired".
- R-9: a partition quiet bump resets a lease only when one of ITS sources was invalidated (per-source quiet version)
  or its binding retired; partition-wide invalidation still resets all.
- R-12: the per-item publish verdict is memoised per (catalog instance, authority generation) for <=1 s; Commit
  under the session lock re-checks identity only.
- R-21/R-22/R-23: registry prune is interval/capacity driven; a cleared history session refuses chunks; the snapshot
  barrier is decided and armed under the same gate its release is decided under.

Node manager: U-10 projected live items indexed by node; U-11 anchor removal / root-leaf swap tombstone the anchor's
own monitored node; U-12 per-parent child count; U-13 per-condition verdict index.

Also: Issue934_r1_N1 test clears its metadata failure before ending the stream (test-only sequencing race,
reproduced with a 200 ms delay; production behaviour correct).

Perf (Category=Perf, OTOPCUA_GRPCDATA_PERF=1): 10k-item cohort opens in 3.3 s / 80 commands / 1 stream (before: never
opens); 100 source versions at 1k/s -> 11,036 item values in 569 ms.
2026-12-03 11:59:26 -05:00
Joseph Doherty 645a8b9209 fix(host): #980 review — termination watchdog exits on a cluster leave/down under Akka.Hosting
The first #980 fix stayed quiet whenever ApplicationStopping was already cancelled. Akka.Hosting
1.5.62's AkkaHostedService hooks WhenTerminated earlier and, for ClusterLeavingReason /
ClusterDowningReason, sets Environment.ExitCode = -1 and calls StopApplication() BEFORE the
watchdog's continuation — so manual failover, endpoint step-down and auto-down all still ended in a
graceful stop (SERVICE_STOPPED, win32 exit 0 — SCM reads ServiceBase.ExitCode, not the -1) that
Windows SCM never restarts.

"Expected" is now decided from signals Akka.Hosting never produces: a host stop requested while
the ActorSystem still runs (SCM stop / Ctrl-C / GracefulClusterLeaveService), the watchdog's own
StopAsync before termination, or CoordinatedShutdown reason ClrExitReason. Everything else exits 1.
After an unexpected termination the watchdog's StopAsync holds host shutdown until the exit is
issued, so the service host cannot report SERVICE_STOPPED first. Registration moved to
AddOtOpcUaTerminationWatchdog (shared with tests).

Tests: TerminationWatchdogAkkaHostingTests — real AddAkka host + production cluster bootstrap +
GracefulClusterLeave: Leave(self)/Down(self) => exit 1 (both fail on the old logic); host StopAsync
and StopApplication-while-running => no exit. Live gate on windev SCM passed (7031 + restart; old
logic => Stopped, exit -1, no recovery; sc stop => clean stop).
2026-12-03 11:53:42 -05:00
Joseph Doherty b8b7b68d34 fix(controlplane): #996 review — a superseded deployment's in-flight ack write no longer drops the successor's ack
In-flight ack writes were tracked by node only and ResetForNext (supersede + every terminal path) cleared the
parked-behind acks but not the in-flight set. With deployment A's ack write for node N still running, B
superseding A (or A closing at the deadline-deferral cap) and N acking B parked B's ack behind A's write; A's
stale completion then deleted it and B timed out naming N, though N applied it.

- In-flight writes are per deployment: ResetForNext clears _persisting; an ack parks only behind a write of the
  SAME deployment; a completion removes only its own entry (reference match).
- The stale-completion branch starts a parked ack of the current deployment instead of dropping it.
- The deferral cap counts only current-deployment in-flight (and parked, newest-wins) acks; the deadline deferral
  and its early re-fire, and the retry-tick guard, consider only the current deployment's writes.

Tests: ConfigPublishCoordinatorSupersededAckWriteTests — supersede and deferral-cap variants (both failed before
the fix) plus a positive control.
2026-12-03 11:46:08 -05:00
Joseph Doherty ee9aa30ec0 fix(scripting): {{equip}} substitution escapes the RawPath it pastes into the string literal
A RawPath segment may contain backslash, quote, braces, line breaks or non-ASCII text.
SubstituteEquipmentToken pasted it raw into a regular C# string literal, so a device named
de\qv failed to compile and x\vy silently read a different tag path (\v became a vertical tab).

The paste is now encoded (EscapeForRegularLiteral) and the <RefName> / dependency refs are
decoded (TryDecodeRegularLiteral), so GetTag receives the exact RawPath at both compose seams
and the mux subscribes to the real key. The path-literal regex is escape-aware. The Monaco
OTSCRIPT_EQUIPREF diagnostic and completion share the same scan/escape. The deploy gate's
SubstitutionPreservesCompilation is now a verified round trip, so its pinned device-name case
flips from rejected to accepted.
2026-12-03 11:40:17 -05:00
Joseph Doherty 84789b33f3 Merge #971 follow-up: deploy-time script compile gate (allow-list refusals block the deploy, Error mode default) 2026-12-03 11:29:56 -05:00
Joseph Doherty 6e912bb070 feat(deploy): #971 follow-up deploy-time script compile gate
The deploy gate never compiled scripts, so a stored script the #971 allow-list
now refuses only failed after the deploy (VirtualTag/Calculation Bad "sandbox
violation", scripted-alarm load failing for every alarm on the node).

- Core.Scripting.Abstractions: IDeployScriptChecker (Roslyn-free) + request/result
  records; ScriptContextKind moved here (same namespace).
- Core.Scripting: ScriptEvaluator.Verify shares a private BuildCheckedCompilation
  factory with CompileToImage (wrap, injection guard, sandbox compile,
  ForbiddenTypeAnalyzer; no stack-guard rewrite, no emit). RoslynDeployScriptChecker
  checks per seam (VT/Calc as VirtualTagContext->object?, passthrough/blank skipped;
  predicates DependencyExtractor first then AlarmPredicateContext->bool), caches by
  (compile identity, SHA-256), parallel, bounded.
- ControlPlane: DeployScriptGate collects enabled VTs / enabled alarm predicates /
  Calculation tags, resolves {{equip}} through EquipmentReferenceMap exactly as the
  compose seams do (template compiled once when SubstitutionPreservesCompilation,
  else the resolved source), groups findings per script naming its users.
  AdminOperationsActor warms the cache before the snapshot transaction and runs the
  authoritative pass on the same snapshot; Deployment:ScriptCompileGateMode =
  Error (default) | Warn | Off; an absent checker or an internal failure never blocks.
- Host binds RoslynDeployScriptChecker on admin nodes.
- Docs: VirtualTags.md (gate + upgrade note), ScriptEditor.md, security.md, CLAUDE.md.

Found while testing: {{equip}} substitution pastes RawPaths into C# literals
unescaped, so a segment containing \ or " breaks (or silently alters) the
script; the gate now reports it at deploy.
2026-12-03 11:29:32 -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 e6bfbdb6e5 fix(runtime): #995 a deploy no longer re-subscribes untouched drivers, and apply-time artifact work runs once off the pinned thread
R-11: DriverHostActor skips the deploy bulk push for a kept child whose seeding
fingerprint (value refs + raw/UNS fan-out + historization + alarm refs) is unchanged
and none of whose refs gained a mux consumer (VirtualTag / scripted alarm /
IDependencyConsumer driver). Skipped drivers are re-pushed when the address-space
outcome reports a rebuild (new additive RebuildCompleted.AddressSpaceRebuilt,
default true), degraded, timed out, or the apply threw. Boot/restore still push all.

R-14: ParsedDeploymentArtifact memoises the data projection + its validation per node
id (a throw re-thrown to every caller), and the row parsers skip it when the three data
arrays are empty. OpcUaPublishActor hashes the artifact once (RebuildAddressSpace.
ArtifactRevision) and reads the cluster redundancy mode from the plan step's parse
instead of a second parse on the pinned thread. InjectScriptSource skips JsonNode.Parse
for tag configs without a scriptId.
2026-12-03 11:09:59 -05:00
Joseph Doherty 58b26b5fd0 Merge #1002: StopChild clears comms latch + timer, kept alarm marks replayed, recorder catch-up uncapped, HistoryRead bad interval refused, VirtualTag host re-applied after restart, EffectiveName everywhere 2026-12-03 11:08:24 -05:00
Joseph Doherty 070fd493f9 fix(runtime): #1002 StopChild drops comms latch/audit + holds health ledger; deferred known marks kept for kept conditions; backlog drain re-ticks; per-driver source index; unconvertible ProcessingInterval is BadInvalidArgument; VirtualTagHost re-applied after restart; empty DisplayNameOverride = tag name
Co-Authored-By: Claude <noreply@anthropic.com>
2026-12-03 11:08:07 -05:00
Joseph Doherty 9279078885 Merge #999: shelve expiry emits Unshelved first, script-owned timeouts surface as themselves, pipeline timeout visible to breaker, resilience config fallback, backoff floor, codec exceptions, worker frame cap split 2026-12-03 11:07:19 -05:00
Joseph Doherty a1b8312ea4 fix(virtualtags): #995 inputs held behind a slow run coalesce into one evaluation, array outputs dedup by value, and a failed source binding retries only the unbound tag with backoff
R-19: VirtualTagActor folds inputs that arrive during an in-flight evaluation
(latest value per input) and evaluates once when it completes, instead of
stashing one message per trigger and replaying one script run each (unbounded,
O(M^2) re-stash hops). One-dimensional array results compare element-wise in
the value dedup, so an unchanged array output is not republished, re-routed or
historized on every evaluation.

R-17: VirtualTagHostActor's source-binding retry re-attempts only the tags whose
binding failed (spawning the child / publishing the disabled status on
success), 250 ms doubling to 5 s, instead of re-delivering the whole
ApplyVirtualTags every 250 ms (quarantine reset, re-assert of every child,
BadOutOfService republish, cycle-graph recompute each time).
2026-12-03 11:05:32 -05:00
Joseph Doherty 677a680178 fix(opcua): #995 U-5 removing a node sweeps only that node's stood-down items, not every tracked item
Whenever any monitored item was stood down, each TombstoneMonitoredNode ended with a full scan of
_liveItems + _eventItems, and the rebuild ran it once per monitored node plus once more: removals were
O(nodes x items) under the node-manager Lock. Tracked items are now indexed by NodeId (a superset index
added on track, dropped on client delete, re-validated and pruned by the sweep, so it never has to
follow the Suppressed flips); a per-node sweep is a lookup, and TombstoneAllMonitoredNodes skips the
per-node sweep in favour of its single unfiltered one.

Measured (counter): removing 200 stood-down nodes one by one visited 20,300 tracked items before,
~201 after.
2026-12-03 11:02:44 -05:00
Joseph Doherty de185802d7 Merge #996: Deployment reads skip ArtifactBlob, narrow data-connections loader, coordinator ack writes off-thread, AdminOps I/O off mailbox, HistoryReadEvents page cap, reservations page bounded 2026-12-03 10:59:06 -05:00
Joseph Doherty ea976ffa81 fix(perf): #996 Wave 4 — blob-free health probes, narrow data-connections load, off-thread coordinator acks + AdminOps audit, events page cap, capped reservations page
C-6: DeploymentQueries projects Deployment without ArtifactBlob (DbHealthProbe, readiness, ClusterOverview, DriverHost boot).
C-11/A-5: DraftSnapshotFactory.FromConfigDbForDataConnectionsAsync + one-parse-per-artifact LoadAppliedAsync + capped pickers.
H-6: ConfigPublishCoordinator persists acks off the actor thread (AckPersisted); deadline backlog kicked in parallel.
H-3: Restart/Reconnect reply = dispatch; ConfigEdit audit written off-mailbox, failure logged not surfaced.
U-6: ServerHistorian:MaxEventsPerRead (default 10000) pages HistoryReadEvents; advertised as MaxReturnEventValues.
A-8: /reservations active-only by default, projected, capped at 200.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-12-03 10:58:50 -05:00
Joseph Doherty aa744f63a4 perf(grpc-data,script-runner): #999 K-11 value frames are sized once (preflight only); shard placement hashed once per key with no per-evaluation byte[] 2026-12-03 10:58:30 -05:00
Joseph Doherty 8e91d6503d fix(script-runner): #999 K-5 script-worker frames are cut at the frame cap; one oversized evaluation fails alone instead of killing the worker 2026-12-03 10:56:40 -05:00
Joseph Doherty 9d3d0f3ae9 Merge #997: UNS duplicate sibling names friendly + race-safe, Galaxy ack password kept on blank, reaper drains on stop, silent node telemetry not redialled, key delete reloads 2026-12-03 10:52:36 -05:00
Joseph Doherty 3773509888 fix(adminui): #997 duplicate sibling names, Galaxy ack password blanking, browse reaper drain, silent-node telemetry dial, key-delete cleanup now behave correctly
A-3: UnsTreeService pre-checks sibling (cluster,area,line) names on create/update/import, catches DbUpdateException, validates column lengths.
A-4: blank ack password keeps the stored one; first-time blank refused.
A-6: BrowseSessionReaper drains sessions in a finally on shutdown.
A-7: node flushes response headers; central treats them as established; deadline warning throttled.
A-9: key delete always reloads and names leftover ack secrets when cleanup fails.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-12-03 10:52:19 -05:00
Joseph Doherty c42eeb3c69 fix(codecs): #999 K-9 malformed wire values fail as each codec's documented exception (ArgumentException / ScriptWorkerProtocolException) 2026-12-03 10:49:44 -05:00
Joseph Doherty 6822fd3f5c Merge #977: restart restores last Applied deployment, planner covers every composition field, degraded/revision/restart bookkeeping, superseded deployment closed 2026-12-03 10:47:07 -05:00
Joseph Doherty a0f41a30d8 fix(deploy): #977 deploy/apply bookkeeping — planner sees every composition field, degraded/restarted applies repair, failed deploys restore the last applied revision, superseded deployments close
- U-2: planner diffs the rich scripted-alarm plans; an Enabled flip is a surgical add/remove of the one
  condition, a Name/AlarmType/Severity edit on an enabled alarm rebuilds.
- U-3: planner diffs UNS Areas/Lines in full; a Line moved to another Area rebuilds, added/removed
  Areas/Lines are surgical.
- U-9: removing the last VirtualTag in a FolderPath removes the sub-folder in place.
- AddressSpacePlannerFieldCoverageTests reflects over every composition list + record field.
- R-4: while the last applied composition is degraded, a non-rebuild apply re-ensures the full composition.
- R-20: a supervision restart of OpcUaPublishActor forces its first apply to rebuild.
- R-1: Direct boot with a Failed/orphan newest row restores the newest Applied deployment, then the cache.
- R-15: the revision advances after the last throwing apply step; a throw marks it unconfirmed.
- H-4: ConfigPublishCoordinator closes a superseded in-flight deployment (TimedOut + reason).

Co-Authored-By: Claude <noreply@anthropic.com>
2026-12-03 10:46:47 -05:00
Joseph Doherty be4f4f8f94 fix(resilience): #999 K-8 a wrong-shaped ResilienceConfig falls back to tier defaults instead of throwing out of driver spawn 2026-12-03 10:46:17 -05:00
Joseph Doherty 2f6f41441a fix(analyzers): #1001 OTOPCUA0001 now guards IAcknowledgedAcquisitionSource and IWriteOutcomeCapability
An unwrapped SubscribeAcquisitionAsync / WriteWithOutcomesAsync call now fails the build.
Full-solution build flags exactly one production site (DriverInstanceActor acquisition start),
suppressed inline with the reason the stock retrying/timeout pipeline cannot own that call,
and one wire-level Runtime test call.
2026-12-03 10:40:04 -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 23867ed9d7 Merge #979: refused write reverts to last confirmed value (raw+UNS); dependents of a removed input go BadWaitingForInitialData 2026-12-03 10:30:00 -05:00
Joseph Doherty e0f133f640 fix(runtime,opcua): #979 refused overlapping writes revert to the last confirmed value; dependents of a removed input go BadWaitingForInitialData
U-4: EquipmentVariableState tracks an overlap window per node — the confirmed
(value, status, source timestamp) snapshotted when the first optimistic commit
lands on an unowned node, advanced by an older attempt the device confirms
while a newer one owns it. A refused owner reverts to it (never to the
previous attempt's unconfirmed value at Good); audit OldValue follows. Applies
per NodeId, so raw and UNS mirrors each revert to the fanned value. Mapped
completions use the same tuple.

R-6: DriverHostActor diffs the value-ref index on apply and sends
DependencyMuxActor.ValueRefsRemoved; the mux (and VirtualTagOutputsRemoved)
hands every replay-opting dependent BadWaitingForInitialData (the recorder is
not told), and late bursts for removed refs are withheld until the next apply.

Tests: Sdk2EquipmentVariableTests (overlap both orders x both realms, confirmed
older write, interleaved raw+UNS), GrpcDataMappedWriteCompletionTests,
RemovedInputQualityTests, DriverHostActorSourceRemovedTests,
VirtualTagToVirtualTagFlowTests (Roslyn, identical-value recovery).
2026-12-03 10:29:38 -05:00
Joseph Doherty eef278fc3b Merge #978: one UNS leaf-name authority (modal = service = deploy gate), script-existence gate + in-use delete guard, VirtualTagHost skips invalid tags 2026-12-03 10:28:50 -05:00
Joseph Doherty d2818e2ef2 fix(uns): #978 one UNS name authority and a script-reference gate — an illegal VirtualTag name or override is refused in the editor and at publish, and an in-use script cannot be deleted
- V3NodeIds.ValidateSegment is the single rule Uns()/UnsChild() enforce; the VirtualTag modal
  ([UnsLeafName]), UnsTreeService (VirtualTag create/update, SetReferenceOverrideAsync) and the
  deploy gate (VirtualTagNameInvalid, UnsEffectiveNameInvalid) all call it (C-1, C-4).
- Effective name is stated once (EquipmentReferenceMap.EffectiveName): an empty override falls
  back to the tag name in the gate and the Monaco catalog, as at both compose seams (C-4).
- UnsSegment patterns anchored \A..\z, so a trailing newline is rejected (C-7).
- VirtualTagScriptNotFound / ScriptedAlarmScriptNotFound deploy-gate rules; ScriptEdit refuses to
  delete a script used by a VirtualTag, ScriptedAlarm or Calculation tag and names them (C-2).
- R-5 backstop: VirtualTagHostActor skips (Error log) a plan whose NodeId cannot be built instead
  of crashing on every apply; AddressSpaceApplier counts it as a failed node instead of aborting
  the VirtualTag materialise pass.
2026-12-03 10:28:27 -05:00
Joseph Doherty d82d0ff1f3 Merge #971: script sandbox is an allow-list; narrowed BCL reference set (K-1 closed) 2026-12-03 10:18:28 -05:00
Joseph Doherty 019ba96376 fix(adminui-auth): #975 AdminUI roles are re-validated on a timer (cookie OnValidatePrincipal + revalidating circuit provider); demoted users lose elevated policies within the window 2026-12-03 10:12:54 -05:00
Joseph Doherty c00ebf1320 fix(scripting): #971 the script sandbox is an allow-list — the K-1 bypasses (CreateDelegate, Expressions, XML/Tar I/O, X509Store, Timers/BackgroundWorker/AsParallel, Serilog.Log) are refused
ForbiddenTypeAnalyzer inverted from a BCL deny-list to an allow-list of types/members (ctx API, value/time/maths
types, collections, LINQ-to-objects, string/Regex/formatting; System.Type and CancellationToken with member
allow-lists). Every named type, expression type and used member (incl. return type and generic args) is checked;
__makeref/__arglist, lock and extern local functions refused syntactically. ScriptSandbox references only eight BCL
assemblies (defence in depth). The Monaco editor and the publish gate share both, so parity holds.

Tests: theory over the K-1 snippets (publish gate + analyzer alone against the full host), every-public-type
enumeration, shipped-sample + idiom regression, editor/publish parity. Differential over every script-shaped literal
in src/tests: all 511 previously-compiling scripts still compile (one expression-tree test intentionally refused).
PE cache signing by the host (option 4) deferred as a follow-up.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-12-03 10:09:39 -05:00
Joseph Doherty 03e85ab752 Merge #972: ACL revalidation honours Security:Acl:Enabled=false (no flag-off stand-downs); dead SecurityFilteringActive removed 2026-12-03 10:01:19 -05:00
Joseph Doherty 85d479e23e fix(opcua-acl): #972 revalidation no longer stands down subscriptions while Security:Acl:Enabled=false
IsSubscriptionStillPermitted now asks Permits(identity, CreateMonitoredItems, node) — the creation
gate's own seam and the one place the flag-off bypass lives — instead of the bypass-less
IsAllowedCached. Since 8ad03e9c5 the pass ran with the flag off (SecurityFilteringActive's
'|| NamespaceIndexes.Count >= 4' term was always true: five namespaces are always registered) and
stood every ungranted/Anonymous subscription down within 60 s or on the next deploy (review U-1).

- SecurityFilteringActive deleted: it was a dead toggle, and the gated request paths it guarded are
  also the projected-data routing path; Permits alone decides the flag.
- pass-local verdict memo keyed by namespace index (realm folded projected/imported ids into Raw/UNS).
- _authorizer null-guarded in the pass (no authorizer wired => no NRE).
- AclRevalidationTimer / AclOptions remarks, docs/security.md and the data-plane-auth rule corrected.

Tests: unit flag-off (keyed + Anonymous, empty authority, no authorizer) x5 passes with a flag-on
positive control; wire flag-off data + folder-event subscriptions survive 5 ticks + a no-grant deploy,
with flag-on controls on the same items.
2026-12-03 10:00:02 -05:00
Joseph Doherty 7e3dbbb122 Merge #973: fleet diagnostics only dials known cluster members (SSRF closed) 2026-12-03 09:50:38 -05:00