Commit Graph

1903 Commits

Author SHA1 Message Date
Joseph Doherty 77adf410df fix(runtime): #1113 a config-change respawn keeps the comms latch, trimmed to the refs the new composition still routes
Item 2. StopChild cleared the comms-loss latch unconditionally, so a
config-change respawn of an already comms-lost driver never audited its
replacement (an operator Restart does, #1053). StopChild(respawning: true) now
keeps it; every apply's reindex trims every outstanding latch to the refs still
routed for that driver (TrimCommsLatchesToIndex) and drops an emptied one, so a
ref the deploy dropped (no longer subscribed, cannot be re-published) never
raises a false audit Warning. Both run inside the same apply message, before the
replacement's Connected can arm the audit.

Tests: DriverHostRespawnValueNodeGapTests — kept latch audits the silent
replacement for exactly the kept ref (fails if the latch is cleared or not
trimmed), and a replacement re-publishing every kept ref stays silent (fails
without the trim).
2026-12-05 03:03:43 -05:00
Joseph Doherty 5ef8089e1f fix(runtime): #1113 pin that the gRPC origin hub never serves a stopped driver's last Good across a respawn/Restart
Item 1. Projected consumers (DataConnectionService read/subscribe) do not read
OPC UA node state; they read PartitionedSampleHub, fed by the driver callback
through SourceSamplePublisher. It is already covered by the producer fence:
StopChild / HandleRestartDriver call RetireCurrentDriver at the stop (sources
removed, cache released, readiness Invalidated) and the replacement's first
value binds a fresh generation. No product change; GrpcDataRespawnOriginGapTests
pins it end-to-end through DriverHostActor for both seams (Restart variant fails
with both fences removed). Docs: DriverLifecycle.md.
2026-12-05 03:01:51 -05:00
Joseph Doherty 767ce15cb1 Merge #1111 deploy re-send residuals: a re-send retries a Failed apply (newest-answered, no held ack); re-sends carry DeadlineRemaining so a late-reached node caps its address-space wait; coordinator keeps a node's Applied over a late stale Failed; in-memory acks + late-Failed-seal residual documented 2026-12-05 00:53:03 -05:00
Joseph Doherty 2fcaffd2ed fix(deploy): #1111 review — Applied wins over a late Failed
Since #1111 a node re-applies a deployment only after its own Failed (the re-send retry), so
two acks from one node for one deployment can differ, and the ORIGINAL Failed can still land
after the retry's Applied (GrpcApplyAckSender's endpoint walk: a timed-out call may have been
delivered). ConfigPublishCoordinator.HandleAck now discards a Failed from a node whose Applied
(clean or degraded) for the current deployment has arrived — counted, persisting, parked behind
a write, or held for a persist retry — before the row write, so neither the count nor the
NodeDeploymentState row flips back. A stale unpersisted Failed is dropped with it so the deadline
never waits on a retry the guard always discards. Applied after a counted Failed still wins.

Residual, documented in docs/Redundancy.md (not corrected after the fact): a late Failed that
CLOSES the deployment before the retry's Applied arrives — re-opening or late-sealing a terminal
deployment would break write-once terminal outcomes (L8) and latest-sealed ordering.

Tests: late Failed after a persisted Applied (clean + degraded), back-to-back Failed racing the
in-flight Applied write (all three fail with the guard disabled), and an Applied-after-Failed
positive control.
2026-12-05 00:52:44 -05:00
Joseph Doherty 89aee3268b fix(runtime): #1112 value nodes go BadWaitingForInitialData on a driver respawn/Restart until the new driver's first value
Owner decision 'Brief Bad on restart'. A config-change respawn (StopChild with
respawning=true, i.e. an id the planner both stops and spawns) and an operator
Restart now stamp BadWaitingForInitialData on the driver's raw NodeIds and every
referencing UNS NodeId at the stop, on the host->publish-actor pair the new
driver's values travel, so the new Good always lands after it.

Not a comms loss: the stamp is not latched (no recovery audit, no
comms_latched_refs, no driver status), and a retired child's late PostStop Bad no
longer stamps value nodes while a replacement exists (it used to latch them).
A Restart therefore cancels the old incarnation's armed audit itself (#1053
keeps the latch). Supervision restarts, deploy removals/disables, native
conditions and historization (mux-fed, #1109) are unchanged.

Tests: DriverHostRespawnValueNodeGapTests (config change + Restart, late and
early old-child stop, raw + UNS, no-latch with positive control);
DriverHostStaleConnectivityTests expectations updated for the host stamp.
Docs: DriverLifecycle.md quality contract + .claude/rules/drivers.md.
2026-12-05 00:24:50 -05:00
Joseph Doherty f5485f57d8 fix(deploy): #1111 retry a lost Failed ack on re-send; re-sends carry the remaining deadline
1. Node (DriverHostActor): a coordinator re-send of a deployment whose remembered ack is
   Failed now RE-ATTEMPTS the apply instead of replaying Failed — a failed apply left the
   node on last-good config, and a fetch failure and a lost ack usually share a cause.
   Once per re-send (a copy mid-retry is dropped by Applying), and only while that
   deployment is still the node's latest answer with no other ack held, so a stale re-send
   of an OLDER failed deployment replays Failed rather than rolling back a newer apply.
   Applied / Applied+degraded keep the replay (#601 unchanged).

2. DispatchDeployment gains additive DeadlineRemaining (proto optional int64
   deadline_remaining_ms = 5), set by ConfigPublishCoordinator on every re-send (relative,
   no clock agreement needed), unset on the original. A node whose apply was started by a
   re-send bounds its held Applied ack's address-space wait to remaining - 15 s from
   receipt (floor 1 s), so a node first reached at +35 s acks Applied (degraded) before
   central's deadline instead of sealing TimedOut. Old central -> field absent -> full
   105 s (today); old node ignores the field (limit documented).

3. Docs: remembered acks are in memory only (restart/supervision restart forgets them);
   Redundancy.md §Dispatch re-send + cluster-topology rule updated.

Tests: Failed-ack retry + later replay, stale older-failed guard with positive control,
re-send deadline bound with original-dispatch positive control (both behaviour tests
verified to fail with the change disabled), mapper presence round-trip, coordinator
DeadlineRemaining countdown.
2026-12-05 00:24:49 -05:00
Joseph Doherty 1cd98580ca Merge #1107: deploy dispatch is re-sent (+5/+15/+35 s, within half the remaining ApplyDeadline) to un-acked nodes only via TargetNodes; nodes replay a remembered ack instead of re-applying, ignore re-sends not addressed to them, and no longer double-apply a duplicate while an ack is held 2026-12-04 22:42:50 -05:00
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 ba20eabbfa fix(deploy): #1107 review — correct the rolling-upgrade residual: a pre-#1107 node re-applies its own re-send on either transport while its ack is held; upgrade driver nodes before central 2026-12-04 22:34:10 -05:00
Joseph Doherty 323bbd2a63 fix(deploy): #1107 re-send the deploy dispatch to nodes that have not acked
ConfigPublishCoordinator dispatched a deployment exactly once: on DPS a node whose
deployments registry entry had not gossiped to central missed it (#1106), on gRPC a
failed dial was dropped, and either way the deployment timed out at 120 s.

Coordinator: re-sends the same DispatchDeployment at +5/+15/+35 s (bounded by half the
remaining deadline) with the new additive TargetNodes naming only expected nodes whose
ack has not arrived (an ack still being persisted counts). Stops on last ack,
completion, time-out, supersede or schedule end; a recovered in-flight deployment gets
the same re-send. Counter otopcua.deploy.redispatched.

Transport: CentralCommunicationActor's gRPC fan dials only the named nodes; proto gains
repeated target_nodes = 4 (additive). On DPS, non-addressed nodes ignore the re-send.

Node (DriverHostActor): a re-send is idempotent per DeploymentId — ignored if not
addressed here or mid-apply; ANY copy of a deployment whose Applied ack is held on the
address-space outcome no longer starts a second apply; a re-send of a deployment it
already acked re-delivers the remembered ack (last 16) instead of re-applying (#601
would otherwise re-apply a degraded revision). Original dispatches are unchanged.

Docs: Redundancy.md §Dispatch re-send, Configuration.md, cluster-topology rule.
2026-12-04 22:29:17 -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 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 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 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 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 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 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 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 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 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 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 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 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 7c572811c6 docs(grpc-data): #1080 per-value allocation follow-ups and measurements in DataConnections.md 2026-12-03 16:49:09 -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