Commit Graph

5758 Commits

Author SHA1 Message Date
Joseph Doherty df2e3e3b27 Merge #1109 flake: respawn/restart dependent gap was a real race (#1070 stale-connectivity drop vs #1041's PostStop Bad) — host now tells dependents BadNoCommunication directly at child stop/restart; deterministic regression test 2026-12-04 22:36:18 -05:00
Joseph Doherty c28e5564d7 fix(runtime): #1109 a respawn/Restart tells mux dependents the ref is not Good itself, instead of racing the stopped child
#1041 relied on the stopped child's PostStop ConnectivityChanged(false) to hand dependency-mux
dependents (VTs, scripted alarms, Calculation) BadNoCommunication until the new driver object
publishes. #1070 later (correctly) drops that announcement once the replacement has connected —
and the two children's messages are unordered, so whenever the old child reaches its stop late
(busy in a synchronous driver call, or a loaded dispatcher) the Bad edge was dropped and
dependents kept the stopped object's last Good until the new driver published: indefinitely for
an on-change source that does not republish an unchanged value. That is the #1109 flake (and its
operator-Restart sibling): pre-fix 15 of 30 CPU-stressed runs of the two #1041 tests failed at the
gap FishForMessage (11 config-change, 8 Restart); post-fix 30/30 pass.

StopChild and HandleRestartDriver now fan BadNoCommunication for the driver's value refs to the
mux themselves (TellDependentsDriverObjectEnded), on the host->mux pair the new incarnation's
values travel and before SourceRemoved (so it is never retained/replayed). Value nodes keep the
#1070 rule. DriverHostRespawnDependentGapTests makes the interleaving deterministic (old child
wedged in GetHostStatuses until the replacement subscribed), for both legs; mutation-checked —
it fails in ~3 s with the fan removed.
2026-12-04 22:27:46 -05:00
Joseph Doherty 720b150691 Merge #1109 code items: proxy-fabricated Unimplemented no longer flips the gateway alarm writer to single sends (and no longer dead-letters a single send); sink-path test for the #1102 in-flight re-consider; byte[][] script results get a dedicated refusal reason; worker result-type check kept as tested defence-in-depth 2026-12-04 22:23:09 -05:00
Joseph Doherty 810a7c26cf Merge #1108: TwoNodeClusterHarness waits for every boot-time pub/sub topic to converge (requiredTopics override; lazy topics opt-in); reflection registry read kept (no public Akka 1.5.62 API) and fails loudly on internals drift 2026-12-04 22:15:56 -05:00
Joseph Doherty 5ea223e8ef test(harness): #1108 wait for every boot-time pub/sub topic, not just deploy topics; clearer reflection-failure message
Co-Authored-By: Claude <noreply@anthropic.com>
2026-12-04 22:15:42 -05:00
Joseph Doherty e12ff456e8 test(script-worker): #1109 keep the worker's result UNSUPPORTED_TYPE check as defence in depth, and pin it
Since #1100/#1104 the shared ScriptResultMaterializer refuses every type the
wire cannot carry, so the worker's result-encoding error branch is unreachable
from a script. Kept (not removed): PublishableScalarTypes and VariantCodec's tags
are separate lists, and the branch turns any future drift into a reported
UNSUPPORTED_TYPE failure instead of a value silently missing from the frame.
Moved into VariantCodec.SetScriptResult (the worker's only result-encoding path,
same message) with a comment saying so, and called directly by ProtocolTests.
2026-12-04 22:14:18 -05:00
Joseph Doherty ec17a83aea fix(scripting): #1109 byte[][] stays refused with a ByteString-specific reason
A script result has no ByteString-array form (its only byte shape is one flat
Byte array) and the worker wire has no ByteString or nested-array tag, so
byte[][] is left refused with every other jagged array (no new wire tag). Its
reason now says it is not an array of ByteStrings and offers both forms that
publish: a flat byte[] (SelectMany) or a string[] of Base64 blobs. Pinned by
ScriptResultMaterializerTests.
2026-12-04 22:09:47 -05:00
Joseph Doherty fce51769a4 test(grpc-data): #1109 pin the #1102 in-flight-commit re-consider through the sink delivery path
Parks the first live value inside sink.WriteAsync (RunDeliveryAsync -> DeliverAsync,
past eligibility + publication gate, before Commit) while a whole tick considers a
newer version. A newer value equal to the old baseline is delivered after the
commit; a differing one is delivered exactly once. Disabling the OnCommit
re-consider fails both baseline-equal cases on this path. No production bug found.
2026-12-04 22:06:41 -05:00
Joseph Doherty e38b9030b7 fix(historian): #1109 a proxy-fabricated Unimplemented on SendEvents is an outage, not a missing batch RPC
IsSystemicFailure (which covers client-fabricated statuses) now runs before the
Unimplemented probe, so a proxy 404 retries the batch instead of flipping the
writer to single sends for its lifetime. Classify also treats a client-fabricated
status as RetryPlease, so a fabricated Unimplemented/InvalidArgument on a single
SendEvent no longer dead-letters an event the gateway never judged. (#1103)
2026-12-04 22:02:14 -05:00
Joseph Doherty da23fd970d Merge #1106: deploy-seal timeouts were a lost dispatch — harness declared the cluster formed before DistributedPubSub registries converged; harness now waits for deployments/deployment-acks registries, timeouts dump lost-vs-slow diagnostics, deterministic slow-gossip regression test
v2-ci / unit-tests (push) Has started running
2026-12-04 20:49:42 -05:00
Joseph Doherty 36380d3c9d test(harness): #1106 wait for the deploy topics to gossip before reporting the cluster formed
The deploy-seal timeouts (#843/#1106) were a lost dispatch, not a slow one. Reproduced 3 times
under CPU stress (load 250-430, 1 in ~3-18 runs) with new diagnostics: node B's DriverHost never
logged "reading artifact", its row stayed Applying, and the deployment was still AwaitingApplyAcks
60 s after the wait gave up. The deploy was published 13 ms after node B came Up - before node A's
DistributedPubSub mediator had received B's registry bucket (exchanged on its own 1 s gossip tick,
independent of cluster membership), so the Publish reached node A's driver host only.

TwoNodeClusterHarness.StartAsync / RestartNodeBAsync now also wait until both nodes' DPS
registries carry both nodes' `deployments` subscriptions and the same non-empty
`deployment-acks` set (read off the mediator by reflection; test-only).

Regression test: with pub-sub gossip-interval = 10s a deploy started right after StartAsync
fails deterministically without the wait (exact #1106 signature) and seals with it.

Diagnostics: the seal-timeout message (now on DeployHappyPathTests too) carries each node's DPS
registry view for the deploy topics, both nodes' recent Akka log events / dead letters, and a
60 s late-seal watch that says "slow, not lost" vs "lost, not slow".

Production note: the same window exists on the DPS transport (fire-and-forget dispatch, no
re-dispatch; the 120 s apply deadline closes it TimedOut). Follow-up to be filed.
2026-12-04 20:44:16 -05:00
Joseph Doherty 83e9812d62 Merge #1104: jagged-array script results refused identically by both runners (flatten hint); ContainmentTests bounds assert ordering and are sized for ~1 s whole-process stalls 2026-12-04 20:31:42 -05:00
Joseph Doherty 79d080c4a9 test(script-worker): #1104 size ContainmentTests' non-heartbeat latency bounds for ~1 s whole-process stalls
Same treatment #1100 gave the heartbeat bounds, each assertion keeping its meaning:
- Runaway soft answer (was softElapsed < T + 400 ms): now an ORDERING fact - the worker has not
  exited when the caller is answered (answered before the hard kill) - plus < T + G. Grace 500 ms ->
  2.5 s so a stall cannot push the soft notice past T + G ("script worker unresponsive").
- Kill timing: lower bound T + G - 50 ms unchanged (stall-proof); upper slack 1.5 s -> 2 s, still
  < 2 x G and well under the 10 s Exited wait.
- Host CPU window: 1.5 s window / 1 s CPU absolute -> 3 s window, CPU < half the MEASURED wall time
  (a spinning orphan burns ~wall; a stall stretches the window, never adds CPU).
- Pipe-close exit (was < 2 s): bound dropped; the meaning is the exit CODE (ExitPipeClosed is only the
  worker's own EOF exit), waits 5 s -> 10 s.

Stall check (temporary harness, not committed: SIGSTOP/SIGCONT of the test host + worker pids for
1.2 s every ~2.3 s): new bounds passed 3/3; the old file failed the runaway test 2/2 under the same
harness.
2026-12-04 20:31:25 -05:00
Joseph Doherty d81990bcbf fix(scripting): #1104 a jagged-array script result is refused identically in both runners
int[][] / byte[][] used to be the one result divergence left after #1100: in process
ScriptResultMaterializer passed it (SdkValueBoundary.FromClr carries it as an array of Variants),
while the worker's wire has no nested-array tag and answered "unsupported type". A script-fed node
has a scalar DataType, so a Variant-of-arrays value is not what it declares either; not documented as
a feature anywhere (only noted as the known divergence). Decision: refuse, via the shared rule.

- IsPublishable: a 1-D array's element must be a PublishableScalarTypes scalar (no recursion).
- EnsurePublishable: a nested array gets its own reason, still "... which an OPC UA node cannot
  carry: an array of arrays ...", with a flatten hint (SelectMany). Same "script threw: ..." text in
  both runners.
- SdkValueBoundaryScriptResultTests: int[][] leaves the rule==FromClr theory; a separate fact pins
  the one deliberate difference (FromClr takes it, the rule refuses).
- ParityTests: "jagged array" + "jagged byte array" rows. ShadowModeTests census: the jagged script
  now MATCHES; the unsupported_type mismatch is exercised by a decimal INPUT (design §14 #11), the
  real remaining worker-only refusal.
- ContainmentTests.Unsupported_input_and_result_types: jagged now expects the materializer reason.

Mutation: restoring the recursive element check fails 4 tests (2 parity rows, shadow census,
containment unsupported-type).

Behaviour change: a value script returning a jagged array now fails (Bad + script log) in process
too, instead of publishing a Variant array onto a scalar-typed node.
2026-12-04 20:31:25 -05:00
Joseph Doherty 22dc196291 Merge #1102: a commit re-considers the source when the client filter suppressed a newer version against the baseline that commit replaced — client no longer holds a superseded value
# Conflicts:
#	docs/DataConnections.md
2026-12-04 20:28:31 -05:00
Joseph Doherty db8e00a6af fix(grpc-data): #1102 a client-filter suppression made against an in-flight value's old baseline is re-considered at its commit
The filter compares a newer source version against the last COMMITTED value, but the reader may hold an
earlier value past IsEligible and not yet committed. A tick in that window dropped a newer value equal to
the old baseline; the earlier value then committed and the client held it until the source changed again.

The worker now records the version it suppressed (cleared when a later version is queued). ValueDelivery.OnCommit,
committing a value older than that, rewinds LastConsidered and marks the source dirty so the next tick
re-evaluates against the new baseline. Pre-existing (predates #1098); independent of shared serving.

Tests (GrpcData1102FilterBaselineTests) park the in-flight value at the reader's pre-commit seam and run the
tick that considers the newer version to completion: value-equal and deadband cases fail without the fix
([2] instead of [2, 1]); a control pins that a queued newer value is still delivered exactly once.
2026-12-04 20:27:16 -05:00
Joseph Doherty a83d0d7096 Merge #1105: cohort event channel carries a CohortMessage struct instead of a FrameEvent record (~1685 -> ~1655 B/value, queue step 0 B); remaining records are public API/ownership — declined, documented 2026-12-04 20:25:15 -05:00
Joseph Doherty b03e01dae1 perf(grpc-data): #1105 a queued cohort frame rides the channel as a struct, not a FrameEvent record
Release, 10k cohort: ~1.69 KB -> 1.65-1.67 KB per delivered value process-wide; queue section 40 B -> 0 B per value.

- ProjectedDataAccess's cohort channel carries a CohortMessage struct (control Event, or frame + charge + received
  timestamp); control events convert implicitly, so every writer is unchanged. Slot release, charge and dispose obligations
  on the read, drain and finally paths are unchanged.
- GrpcDataWave3PerfTests asserts queue 0 B/value, build < 192 B/value and (Release) < 1.8 KB/value process-wide.

Declined (documented in docs/DataConnections.md): ProjectedValueUpdate+DataValueSnapshot (public publish API, retained by the
publisher), the one-element publish list (reuse needs an ownership promise IProjectedValuePublisher does not make), origin
frame records (public Core.Abstractions contract; the frame is owned by the reader), CachedSourceRead (public, escapes,
identity-based once-only guards).
2026-12-04 20:25:00 -05:00
Joseph Doherty 06221c1f43 Merge #1103: gateway alarm writer's IsSystemicFailure treats a client/proxy-fabricated status as a path outage — one IsClientFabricated authority shared with IsGatewayAnswer 2026-12-04 20:16:25 -05:00
Joseph Doherty f7a0c4aef5 fix(historian-gateway): #1103 IsSystemicFailure shares the client-fabricated-status classification with IsGatewayAnswer 2026-12-04 20:16:15 -05:00
Joseph Doherty ce0133b03c Merge gRPC data publish-path follow-up (#1098): ~2.2 -> ~1.7 KB/value — hub read hands its sample to the delivery, FrameSlotWindow + single-waiter re-arm fix, scalar latest-sample cache keeps the update, alloc-free frame sizing/dispose; pooling declined (ownership leaves the session) 2026-12-04 17:48:39 -05:00
Joseph Doherty 1523a97708 perf(grpc-data): #1098 cut ~0.55 KB per projected value without pooling
Release, 10k cohort, 5 runs each: 2.21-2.31 KB -> 1.68-1.72 KB per delivered value, process-wide.

- A live value takes over its hub read's sample lease and charge (CachedSourceRead.TryTransferSample:
  same amount, same budget; the read keeps its source guard until disposed) instead of retaining a
  second copy and reserving a second charge. Re-stamped with the item's serving only when it differs.
- ValueLease holds a reference on the item's SharedSessionLease directly (no Hold per value); the
  release order (charge, item, snapshot) and once-only guard are unchanged.
- The latest-sample cache keeps the published update itself for a scalar payload (arrays still copied).
- The cohort's frame window is a FrameSlotWindow (SemaphoreSlim semantics: over-release throws, a
  cancelled wait takes no slot) on one reused SlotWaiter and one registration per attempt; the pump
  waited for nearly every frame, each wait allocating a task, state machine and registration.
- SlotWaiter (moved out of the session) now makes a re-arm wait out a signaller still inside SetResult,
  so the old signal cannot complete the next wait; it is hot now (one wait per frame under load).
- Indexed loops for the pump's frame sizing and DataSubscriptionValues.Dispose (no boxed enumerators).
- ClientFilterState keeps its baseline's compared fields and value lease, not a re-wrapped sample.

Pooling ValueLease/ValueDelivery (~150 B) is declined: the lease escapes as the public
DataSubscriptionValues.ResourceLease and a delivery's Gate is handed to the gRPC sink as a publication
guard, so a recycled object could release or authorize for another value.

Tests (GrpcData1098OwnershipTests) fail on a read releasing a transferred sample, a lease not holding
its item, a frame-window double release / lost wakeup, and a re-arm racing a completing signal.
2026-12-04 17:48:12 -05:00
Joseph Doherty dc1352758f Merge scripting follow-ups: Guid crosses the worker wire, results an OPC UA node cannot carry are refused identically in both runners (#1100), stall-sized liveness bounds in ScriptWorker.Tests (#1100), scripted-alarm load uses the shared tag-path rule (#1101) 2026-12-04 17:42:54 -05:00
Joseph Doherty 424963b39d test(script-worker): #1100 the shadow census's unsupported-type example is a jagged array — a decimal is now refused by both runners alike and matches
ShadowModeTests counted 'return 1.5m;' as an unsupported_type mismatch (in process Ok decimal, worker
'unsupported type'). Since 9dbccf231 both runners refuse it with the same reason, so it matches; the one
result the worker alone still refuses is a jagged array (no nested-array wire tag), which takes its place.
2026-12-04 17:42:28 -05:00
Joseph Doherty d28ea4a66a refactor(scripted-alarms): #1101 the alarm load refuses a predicate's tag paths through ScriptCompileRules, not its own copy of the rule
ScriptedAlarmEngine.PreparePredicates called DependencyExtractor and refused on !IsValid — a second copy of
the rule ScriptCompileRules owns since #1083 (RefusesNonLiteralTagPaths / TagPathFindings), which the deploy
gate and the editor read. Now ScriptCompileRules.PathRefusals(kind, source, extraction?) is the one verdict
and text ("dependency extraction rejected — …") for both the gate (RoslynDeployScriptChecker) and the engine.
TagPathFindings takes an optional extraction so the engine, which still needs the extraction's Reads, parses
once. Behaviour identical: for AlarmPredicate every rejection refuses with its extractor message, joined "; ".

ScriptedAlarmEngineTagPathRuleParityTests runs 8 predicates (literal, two literals, variable, concatenated,
interpolated, empty, two refusals, dynamic beside a literal) through the gate and a real engine load and
asserts refused <=> refused with the gate's exact text; plus a control that the table holds both outcomes.
Mutation: an engine rule that refuses only empty paths fails 6 of 8 rows.
2026-12-04 17:38:16 -05:00
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 59be7378d6 test(script-worker): #1100 size the remaining tight liveness bounds for ~1 s whole-process stalls, each still failing on its defect
Audit of the heartbeat / silence / liveness-kill bounds in ScriptWorker.Tests after cb5250fac (#1092):
- PipeFaultTests (reader stalls, heartbeats continue): silence 5 x 200 ms = 1 s -> 2 s, write-stall 2 s -> 5 s.
  The silence limit must stay below the write-stall limit or "killed unresponsive, not for silence" proves
  nothing. Mutation (worker stops heartbeating when its reader stalls): KilledHeartbeat at ~2 s, test fails.
- WorkerSoftClockTests.The_progress_ceiling_leaves_a_worker_that_keeps_answering_alone: ceiling 1 s over
  20 x 150 ms -> 2.5 s over 40 x 150 ms. Mutation (no progress stamp on a Results frame): killed
  KilledUnresponsive, queued runs complete null, test fails.
- SupervisionTests burst test: kept at 3 s (production's limit; frames every 50 ms, so only a ~2.95 s stall
  trips it; raising it would stop it catching the 3 s windev defect). Comment records the decision.
- The two #1092 tests (1.5 s) and the never-reports-progress test (lower bound only) are already stall-safe.

Stall check, temporary instrumentation (libc kill SIGSTOP/SIGCONT of the worker pid, not committed): a 1.2 s
stall failed the old PipeFault bounds 3/3 and a 1 s stall failed the old ceiling bounds; the new bounds passed
1.2 s stalls 3/3 each. (A first attempt that spawned /bin/kill measured a 2.5 s stall, not 1 s — process
spawn on the loaded box — and was discarded.)
2026-12-04 17:35:30 -05:00
Joseph Doherty 9dbccf231e fix(scripting): #1100 a script result is what an OPC UA node can carry, in both runners — Guid crosses the wire, unpublishable types are refused alike
Where an in-process result really ends up: VirtualTagActor -> VirtualTagHostActor -> OpcUaPublishActor ->
OtOpcUaNodeManager.WriteValueLocked -> SdkValueBoundary.FromClr (VariantHelper.TryCastFrom). Probed against
SDK 2.0.1: Guid / Guid[] become an OPC UA Guid scalar/array; KeyValuePair<,>[] (a returned Dictionary),
decimal, enum, TimeSpan, char, DateTimeOffset, tuples, Nullable<T>[] and rank>1 arrays are refused, so the
node write threw, OpcUaPublishActor logged a Warning, and the node kept its PREVIOUS value and status (a
silent freeze, possibly under Good) while the worker answered "unsupported type".

Decision, per type, by what a client can see:
- Guid (scalar + 1-D array): representable -> the wire gains an additive GUID tag (15, `bytes g = 10`,
  16 ToByteArray bytes; a wrong length is a protocol fault). Guid INPUTS cross too. protocol_version stays 1:
  the worker ships in the host's script-worker/ folder, and an unknown tag already fails closed.
- Everything FromClr refuses: refused identically in both runners by ScriptResultMaterializer, inside the run,
  with one reason ("script threw: The script returned a value of type 'KeyValuePair<Int32, Double>[]', which
  an OPC UA node cannot carry; return ..."). A lazy unpublishable sequence is refused before it runs.
  ScriptResultMaterializer.PublishableScalarTypes / IsPublishable own the set.

Pins: SdkValueBoundaryScriptResultTests (OpcUaServer.Tests, new Core.Scripting ref) checks IsPublishable ==
"FromClr takes it" over 34 values; ProtocolTests checks the wire carries every publishable type scalar + array;
ParityTests gains guid / guid array / guid list / dictionary / KVP[] / lazy KVPs / KVP / decimal / decimal[] /
enum / TimeSpan / char[] / 2-D rows, a Guid unboxing row, and a positive+negative control. Mutations: with the
type check disabled 11 parity tests fail; with Guid not encoded 9 protocol/parity tests fail.

Behaviour change: a value script returning a Dictionary, decimal, enum, TimeSpan, char or tuple now fails
(Bad + script log) in process too, instead of "succeeding" and leaving its node frozen. Remaining divergence:
a jagged array (publish path carries it as Variant[], worker answers "unsupported type") — follow-up.
2026-12-04 17:27:22 -05:00
Joseph Doherty 665693e0ce Merge AdminUI test follow-up (#1097): page-level assertion that the Raw Local-parent picker renders no tag nodes, with export-root positive control 2026-12-04 17:21:19 -05:00
Joseph Doherty f5dfca1c7f Merge historian follow-up (#1096): Gateway alarm writer counts only genuine gateway replies as answered (client-fabricated Internal/Unknown, proxy replies and status-less faults are not); BatchUnsupported seam replaces test reflection 2026-12-04 17:20:51 -05:00
Joseph Doherty abd536034e fix(alarm-historian): #1096 Gateway writer reachability counts only genuine gateway answers; BatchUnsupported test seam replaces reflection 2026-12-04 17:20:32 -05:00
Joseph Doherty b617fb9678 test(adminui): #1097 page-level assertion that the mapping Local-parent Raw picker offers no Tag nodes (+ export-root positive control) 2026-12-04 17:20:29 -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 cb5250face test(script-worker): #1092 the two "slow caller does not starve the reader" tests use a 1.5 s silence limit (3.5 s block) — measured worker-side whole-process stalls, not heartbeat starvation
SupervisionTests.A_caller_that_blocks_after_its_result_does_not_starve_the_reader and its
WorkerSoftClockTests sibling killed a healthy worker for "sent nothing for ~344 ms" at a
300 ms limit (3 x 100 ms) on a loaded macOS box. Investigated before loosening, with
send-stamped heartbeats (temporary instrumentation, not committed):
- the late beats were late at the WORKER (290-380 ms between sends, 1-150 ms transit), mid
  run, not during startup;
- a cold worker beat every 100 +/- 8 ms from its first beat in 50 isolated runs at load
  60-200, with and without 28 CPU burners, and in full-suite runs under 40 burners, with the
  heartbeat on the thread pool or on a dedicated thread alike (A/B) — no JIT / Roslyn /
  pool-injection starvation to fix;
- the stalls appeared only in a full-suite run under the real load of other agents, with the
  box 24 of 25.6 GB into swap: whole-process stalls no worker change removes.
So the tests take a 1.5 s limit (production: 3 s) and block the caller 3.5 s. Mutation still
caught: with callers resumed inline on the reader both fail (the Supervision test by the
heartbeat kill itself). 20/20 runs of the pair pass.
2026-12-04 15:40:40 -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 395fb0fe2a Merge driver debt follow-ups: AbLegacy caches plans with deterministic malformed references, never transient ones (#1087); no other private driver JSON options found (#1088); FailoverApiKey in the secrets table (#1086) 2026-12-04 14:30:47 -05:00
Joseph Doherty 66d58d51d5 docs(security): #1086 add Security:FailoverApiKey to the secrets table 2026-12-04 14:30:36 -05:00
Joseph Doherty 722279c21e docs(ablegacy): #1087 read-plan cache note 2026-12-04 14:30:16 -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