Commit Graph

1848 Commits

Author SHA1 Message Date
Joseph Doherty 23f7468b4b fix(dataconn): #1026 the fake origin snapshots every item an Add carries (Two_demands_of_one_node flake)
Two_demands_of_one_node_in_one_cohort_both_renew_from_one_tick failed intermittently on merged master (a 60 s hang in
NextPublishedRenewal). Reproduced under CPU load (14 busy cores: 4 of 6 runs failed) with a failure dump of the
renewal state. Every failure showed the same thing, and it was not a deadlock: both renewals had committed
(RenewalStarted+2, RenewalSucceeded+2, joined=1, no claim left in _overlapRenewals), both demands were valid on the
same successor, but the cohort's attempt then ended "Renewal snapshot did not establish a complete baseline" and the
stream reopened (opens 2), with only one rebind snapshot ever published.

Cause: the test fixture. FakeSubscriptions answered an Add of several items with a snapshot value for the FIRST item
only. Whether the two demands' rebinds are re-added by one Add command or two depends on timing (they are batched
when both RenewedEvents are handled before the cohort flushes); in one command the second item had no baseline, which
the consumer treats as a failed renewal (by design), and the reopened stream's recovery Add again valued one item.
A real origin sends a value for every ready item of a snapshot. The fake now does the same (EmitValueCore takes the
handle; EmitValue/EmitValueWithoutSourceTimestamp keep the first-added item).

Tests: The_fake_origin_snapshots_every_item_one_add_command_carries (fails on the old fixture); the flaky test also
asserts the renewal kept the physical stream (Opens 1) and, on timeout, throws a dump of the published updates,
counter deltas, demand bindings and pending overlap claims instead of a bare 60 s cancellation.

Loops: the test 30/30 under 14-core load (was 2 of 6 passing); GrpcDataConfiguredDiscoveryWireTests 3/3 (160 each);
full Runtime.Tests (Category!=SlowUnit) 2387 passed, 0 failed.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-12-05 07:15:58 -05:00
Joseph Doherty 851b2b8c20 Merge #1026: 2048-item projected mappings open and survive an origin restart — origin binding re-check no longer invalidates live sources; consumer lease renewal batched per cohort; batch/joiner deadlock fixed; an interrupted renewal no longer strands its item; every source invalidation + origin reset names its cause (reviewed) 2026-12-05 06:26:13 -05:00
Joseph Doherty 3b6a82b4ee fix(dataconn): #1026 an interrupted lease renewal no longer strands its item; name the pin holders of a refused renewal
The previous #1026 commit left one failure: on a fresh rig (s1026-h run 1) only 852 of 1888 large-mapping items
recovered after the SOURCE restart; the rest stayed BadUserAccessDenied because every renewal failed in the catalog
cache's bound of one retained predecessor per node (RenewalFail.Cache.PredecessorChain 81 163).

Cause: a renewal interrupted mid-cycle. The demand had rebound onto the successor S (RenewedEvent) but the stream ended
before S's baseline reached the node's SourceState, so the idle source still served (and pinned) the predecessor P.
Once both leases lapsed, every between-attempt renewal of S needed P unpinned (P retired+pinned, S pinned, new = 3 > 2),
and nothing ever released the idle source: its pins go only when GetSource replaces an invalid source, which needs a
valid demand, which needs the renewal. An origin restart does this to every batch in flight (~1000 items here).

Fix: between attempts, before renewing, retire an idle source whose own proof lapsed AND is no longer the node's current
proof (it fell behind its demands), exactly as GetSource retires an invalid source; the next attempt creates a fresh one.
A source that is on the node's current proof keeps its overlap predecessor (expired-overlap recovery parking relies on
it: releasing it broke Two_cadences_release_expired_overlap_without_borrowing_witnesses_during_failover).

Diagnostics: catalog pins carry a holder kind (demand/read/binding/source/parked); a refused chain counts
RenewalFail.Chain.<role>.<holder>. Commit-closure failures are split (Canceled/Deadline/Fence/Cache), the cache's own
refusals named (RenewalFail.Cache.<reason>).

Test: A_renewal_interrupted_before_the_successor_baseline_still_recovers_after_both_leases_lapse (holds the rebind's
remove ack, lets both leases lapse; never recovers without the fix).

Live (OrbStack rig s1026-j, fresh, 160 + 1888 items, 4 Hz churn, SOURCE pair restart), three consecutive gate runs:
PASS / PASS / PASS. Open 10.2 / 10.7 / 3.1 s, post-restart recovery 1.54 / 1.52 / 1.54 s, consumer Reset /
ResetHistory / ResetSourceInvalidated / ResetInterestLost deltas 0 in every run, no history-expired or
source-invalidated log line, origin invalidations 0 (only InterestHistoryGap catch-ups).

Co-Authored-By: Claude <noreply@anthropic.com>
2026-12-05 06:15:39 -05:00
Joseph Doherty 8c28506d96 fix(dataconn): #1026 name every origin reset cause; stop binding checks invalidating live sources; renew cohort leases in batches
Gate #1026 (2048 projected items, rig seed --scale 2048) still failed after #1115. Three defects, found by
first making the origin and the consumer say why:

Diagnostics (origin + consumer)
- SourceInvalidationReason (bounded enum, classified from the publisher's reason constants): counted per
  reason (`otopcua.dataconn.source.invalidations{reason}`, `Invalidate.<Reason>` in SourceIngressDiagnostics),
  recorded on the source and logged at Debug (PartitionedSampleHub.Logger).
- An interest lease records why it stopped; the origin Subscribe stream's Reset text names it ("Source
  invalidated (<reason>).", "Source retired.", "Source interest released.", "Source routing changed.",
  "Source partition reset.", "Source binding replaced.") instead of always "Source change history expired.";
  logged at Information (Released at Debug). The texts are for people/counters only: the consumer classifies
  them into ResetSourceInvalidated / ResetInterestLost (no peer branches on them; the rig probe whitelist is
  updated).
- Consumer: renewal started/succeeded/failed/budget/slot counters, RenewalFail.<point> and
  AttemptEnd.<reason> (bounded, constant keys).

1. Origin: a binding check invalidated live sources. The driver actor's source-binding retry re-walks every
   desired reference (offset 0, every <= 30 s once any one failed); for an already-bound reference it took the
   source's serialization gate, and when the poll thread was publishing that source both sides invalidated it
   (BindingContention / SerializationContention) and reset every origin stream holding it. Live s1026-c: the
   only invalidation reasons were those two (5+5 during the open, recurring every ~30 s). EnsureDriverBinding now
   answers an already-bound, current source without the gate. Live after: 0 BindingContention.

2. Consumer: per-item metadata lease renewal could not keep up. Each projected item renewed its 15 s lease with
   its own capabilities + GetMetadata pair holding a 256 KiB unary reservation; at the default 1 MiB budget four
   ran at once and the rest retried on the next 250 ms tick (~16 items/s). Live s1026-d: 155 703 renewals
   started, 153 019 refused by the unary budget, 2 564 committed; ~1900 of 2048 items stood down
   BadUserAccessDenied; 0 recovered after the origin restart. RemoteNamespaceResolver.RenewExactBatchAsync renews
   many items with one capabilities call and one GetMetadata per origin MaxBatchItems (the single-item renewal is
   now the batch of one: same checks, lease bound and commit); a cohort renews every due item of a tick in
   batches of 128, and the between-attempt renewal (every item after an origin restart) is batched too.

3. Consumer: two demands of one node in one cohort deadlocked the batch: the second joined (#969) the first's
   claim, and the batch waited for the joiner before publishing its verdict. The batch now publishes first.

Live (OrbStack rig, 160 + 1888 items, 4 Hz churn, SOURCE pair restart): s1026-f run 1 open 10.2 s, recovery
1.5 s, 0 resets of any kind; s1026-h run 2 PASS (open 3.1 s, recovery 3.6 s, 0 resets, no history-expired or
source-invalidated log line). Remaining (not fixed here): s1026-h run 1 recovered only 852 of 1888 large-mapping
items after the restart: their renewals fail in the catalog cache's predecessor-chain bound
(RenewalFail.Cache.PredecessorChain 81 163).

Tests: GrpcData1026BindingContentionTests (fails without the fast path), GrpcData1026RenewalBatchWireTests
(one tick renews all due items in one metadata call - fails with per-item renewals; two demands of one node -
fails without the ordering fix), GrpcData1026ResetReasonTests.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-12-05 05:43:03 -05:00
Joseph Doherty a670627270 Merge #1115: grpc-data rig scale profile (rig.py seed --scale N, 4096-register block, scale_gate.py for #1026); fix: an in-flight snapshot is no longer reset when the partition change history rolls past it (interest lease covers catch-up; reviewed, session-level no-delta-loss tests) 2026-12-05 04:11:15 -05:00
Joseph Doherty 2b0a0bc029 test(dataconn): #1115 review — session-level pins that a snapshot outlived by history rollover still ends on the latest value
Drives Open, Modify-replacement and freshness-challenge snapshots on the origin session while the 1-entry change
history rolls ~20-40 times past the capture watermark (own and same-partition sibling traffic), and requires the
client to end on the source's latest value with no reset. Fails before 0dfe8371b (reset) and fails if the #994
history-gap catch-up drops own changes (silent loss), so it pins both halves of the safety property.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-12-05 04:10:52 -05:00
Joseph Doherty 81406c9760 Merge #1114: a late Failed from a re-sent node holds the seal up to 10 s for the retry's Applied; deploy deadlines/re-send window on a monotonic clock; Failed-apply doc wording; SQL test DB harnesses get 300 s/60 s timeouts + one retry on a lost migration applock; artifact-fetch test binds port 0 (no release/rebind race) 2026-12-05 03:38:47 -05:00
Joseph Doherty 0dfe8371b7 fix(dataconn): #1115 a snapshot is not reset by the partition change history rolling past it
The #1026 scale gate (2048 projected items, rig seed --scale 2048) never opened: every
cohort snapshot reset with 'Snapshot catch-up expired' while ~1024 changes of any source
(even the cohort's own first values) landed on its partition. SnapshotLease required the
bounded change history (MaxSnapshotCatchUpItems) to still reach its capture watermark,
but nothing reads that history for a snapshot: every production capture comes with its
interest lease, which already catches up from each own source's last change when the
history rolled past it (#994). Live: with the history bound raised to 262144 the same
cohort opened all 2048 items Good in 4.6 s; at the default it never got past ~120.

Drops the reach check (epoch/control/own-source checks unchanged) and the now-unread
per-item cursor positions. The old pin that asserted the reset now asserts no reset and
that the interest still reports both changed sources.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-12-05 03:34:02 -05:00
Joseph Doherty 4ea26b1296 test(host): #1114 artifact-fetch boundary test binds port 0 instead of probe-release-rebind
RightKey_FetchesAndReassembles... failed once in 58 ms (a fast null = the fetch
reached no/the wrong listener). Not reproduced: 30x alone, and 36 runs across 6
concurrent processes, all green on the original. The one race in the test is
the TOCTOU in GetFreePort (probe a free port, release it, re-bind it in Kestrel)
against the ~28 other probe-a-port call sites in this assembly running in
parallel classes and outgoing ephemeral source ports. Kestrel now binds
127.0.0.1:0 and the test reads the bound port back from IServerAddressesFeature;
the failover test's dead endpoint is a bound-never-listened socket held for the
test (refuses connects, cannot be taken); endpoints use 127.0.0.1, not localhost.
30x green after the change.
2026-12-05 03:17:25 -05:00
Joseph Doherty 082eaf4390 Merge #1113: gRPC origin already retires a respawned driver's samples (pinned by test); config-change respawn keeps the comms latch trimmed to kept refs; audit warning names the real status; stubbed drivers' value nodes read BadConfigurationError; slow-connect behaviour documented 2026-12-05 03:06:25 -05:00
Joseph Doherty 399deea32f fix(runtime): #1113 a stubbed driver's value nodes read BadConfigurationError, not BadWaitingForInitialData forever
Item 4. A stub child (no factory for the type, a factory that rejected the
config, or a type not allowed on the node's roles) never publishes, so its
nodes sat at BadWaitingForInitialData forever. StampStubbedDriverValueNodes
stamps BadConfigurationError (new OpcUaStatus constant, 0x80890000) on the raw +
UNS value nodes of every stubbed child after each apply's RebuildAddressSpace
Tell (deploy, boot-from-cache, bootstrap restore) - same host->publish-actor
pair, so the publish actor defers it behind that plan and replays it onto the
nodes the apply (re)creates - and after an operator Restart into a stub. A
config-change respawn into a stub gets the respawn's BadWaitingForInitialData
first, then this. Status-only, not latched; a stub drops any inherited latch.

Tests: Restart + config-change into a stub, and a fresh deploy of a stub
(all fail with the stamp disabled).
2026-12-05 03:05:41 -05:00
Joseph Doherty 4a5407f88f fix(runtime): #1113 the comms-recovery audit names the status the latched nodes actually carry
Item 3. After a respawn / Restart re-stamped a comms-lost driver's nodes
BadWaitingForInitialData (#1112), the kept-latch audit still said the refs were
'still BadNoCommunication'. The host now records that the latched nodes were
re-stamped (_commsLatchReplaced; cleared with the latch and by a fresh
comms-loss stamp) and the Warning reads 'still BadWaitingForInitialData' in
that case, 'still BadNoCommunication' otherwise.

Tests: new Restart-of-a-comms-lost-driver case; the #1053 Restart test and the
item-2 test expect the new wording; the no-audit absence checks match any
'ref(s) still' so they cannot pass vacuously on the wording change.
2026-12-05 03:05:35 -05:00
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 5aa7d24db6 test(sql): #1114 SQL test DB harnesses: 300 s migration / 60 s connect timeouts; retry once on a lost migration applock
Item 4: Configuration.Tests SchemaComplianceFixture + MigrationScratchDatabase
and AdminUI.Tests AdminUiSqlServerFixture get the same 300 s migration command /
60 s connect timeouts ControlPlane.Tests' SqlServerTestDatabase got in #1111.
(Server.Tests / Host.Tests have no SQL Server test-DB harness.)

Item 5: all three harnesses (and ControlPlane's) retry database creation ONCE
under a fresh database name when the migration fails with a lost
__EFMigrationsLock (SQL 1223, 'Cannot release the application lock ... not
currently held'), dropping the half-migrated database first. Any other failure
behaves as before. Recognition is unit-tested in ControlPlane.Tests.
2026-12-05 02:58:36 -05:00
Joseph Doherty 59b17a39a6 fix(deploy): #1114 hold a late-Failed PartiallyFailed seal for a re-sent node's retry; monotonic deadline clock
Item 1: when every Failed ack that completes the expected set came from a node
this deployment was re-sent to (so a #1111 retry may be in flight), the
coordinator holds the PartiallyFailed seal for DefaultFailedSealGrace (10 s,
capped by the remaining apply deadline, once per deployment). An Applied from
that node inside the grace replaces its Failed and the deployment seals;
otherwise it closes PartiallyFailed when the grace ends. A Failed from a node
never re-sent to, a recovered deployment, the deadline and a zero grace all
close at once as before. Nothing sealed is ever reopened.

Item 2: the re-send window, DeadlineRemaining, the persist-deferral cap and the
grace are measured on TimeProvider.GetTimestamp (injectable) instead of
DateTime.UtcNow; only crash recovery still compares against the persisted
CreatedAtUtc. Tested with a fake TimeProvider whose wall clock jumps +/-1 day
while its monotonic counter is stepped explicitly.
2026-12-05 02:46:38 -05:00
Joseph Doherty 1261333180 fix(deploy): #1116 log a deadline/cancel dispatch as delivery-outcome-unknown, not NOT delivered 2026-12-05 02:37:50 -05:00
Joseph Doherty 961ca2897c Merge #1111 SQL recovery test: no product race (flip is row-version bound; mutation proves the test catches a reopen); test now waits for coordinator Ready, surfaces closure exceptions + a context timeline; SQL test DB migration gets 300 s command / 60 s connect timeouts 2026-12-05 01:09:37 -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 47d1c93b82 Merge #1112 (owner decision: brief Bad on restart): on a driver config-change respawn or operator Restart the raw + UNS value nodes go BadWaitingForInitialData until the new driver's first value; the retired child's late disconnect no longer stamps/latches value nodes while a replacement exists 2026-12-05 00:49:27 -05:00
Joseph Doherty ae9d917b73 test(controlplane): #1111 guard-and-flip reopen test: wait for recovery, prove non-vacuity, capture the interleaving
On_sql_server_a_closure_between_guard_and_flip_is_not_reopened failed once with no message. Interleaving
analysis + repro found no product race (the guard-RowVersion-conditioned flip held in every run, and
removing that conditioning makes the test fail), but three test-side defects:

- Vacuous interleaving: ResolveOne returns once PreStart ran, while the recovery load runs after a
  Task.Yield on the pool. A late load could take the interposer's first countdown slot, so the closure
  fired BEFORE the guard read and the test passed without exercising the race. The test now waits for
  ConfigPublishCoordinatorReadiness == Ready and asserts both counted contexts came from DispatchWrites.
- A throwing closure (shared SQL refusing / timing out) surfaced only as a bare "Fired should be true"
  timeout; it is now captured and reported with its exception.
- No context on failure: every assertion now carries a timeline of context hand-outs (offset, thread,
  countdown, calling coordinator frame), the closure outcome and a dump of both rows.

The reproduced failures were all in SqlServerTestDatabase construction: transport errors / connection
refused while the shared central SQL was stopped, and a migration statement (sp_releaseapplock)
overrunning the 30 s default command timeout while several SQL-backed classes migrate in parallel on a
loaded server. Migration now runs with a 300 s command timeout and a 60 s connect timeout.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-12-05 00:45:50 -05:00
Joseph Doherty 9be85f5a94 fix(deploy): #1111 review — cover the held-ack retry guard; clamp deadline_remaining_ms off the wire
- The _pendingAcks.Count == 0 guard (a stale re-send of an older FAILED deployment must not
  re-apply it while a NEWER apply's Applied ack is held on its address-space outcome) had no
  test: mutating it to true left every Runtime test green. New test fails under that mutation
  (the older revision is re-fetched and applied over the newer one, whose held Applied ack
  then goes out for a rolled-back node).
- MeshTransportDtoMapper.FromProto clamps deadline_remaining_ms to [0, 1 day]: a long.MaxValue
  wire value threw from TimeSpan.FromMilliseconds; a hugely negative one could overflow the
  node's TimeSpan subtraction in HandleDispatchFromSteady (actor restart = remembered acks lost).
- Doc fix: _lastAnsweredDeploymentId is moved by RememberAck only, not by a replay.
2026-12-05 00:40:47 -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 27712eef3a test(harness): #1111 guard AllHostTopics against missing DPS Subscribe topics; document lazy-topic convergence wait 2026-12-05 00:11:41 -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 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 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 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 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 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 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 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 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 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