Commit Graph

3257 Commits

Author SHA1 Message Date
Joseph Doherty ef782c29ae fix(scripting): #999 K-7 a script-thrown TimeoutException propagates as itself, not as a disposed-CTS fault or a guard timeout 2026-12-03 10:40:44 -05:00
Joseph Doherty 626d0b33c5 fix(alarms): #999 K-4 a timed shelve expiring on a predicate evaluation emits Unshelved + AutoUnshelve audit 2026-12-03 10:39:17 -05:00
Joseph Doherty b9955f6946 Merge #988: MQTT bad filter isolated per tag, Sparkplug primary-host unique id + re-claim, rebirth counter fixed, subscribe replay race, browse honours refusals 2026-12-03 10:35:43 -05:00
Joseph Doherty 028e68edb0 fix(mqtt): #988 one bad filter/tag no longer takes the driver dark; Sparkplug rebirth cap, primary-host claim and browse verdicts behave correctly
- M-2: malformed topic filters are rejected at the reader + deploy gate (MqttTopicFilterRules);
  the manager re-checks, chunks SUBSCRIBEs at 100 filters and bisects content refusals only.
- Found while pinning M-2: retain handling rides only a 5.0 SUBSCRIBE; on 3.1.1 one
  retainSeed:false tag made MQTTnet refuse the whole batch.
- M-1: metadata rebirths capped per scope, counted when sent, re-armed only by clean data
  (not by the NBIRTH a request provokes); gap rebirths escalate to 5 min after 3 in a row.
- M-3: blank clientId => random per-instance spbhost-<12 hex> claim id (was literal -spbhost).
- M-6: a Faulted/Disposed claim connection is not held; it is disposed and re-claimed.
- M-9: subscribe-time replay re-raises a value pushed mid-replay (plain + Sparkplug).
- M-11: same-type Sparkplug arrays are served by copy, not boxed element by element.
- M-12: span JSONPath walk; span pre-filter for unauthored Sparkplug nodes; guarded Debug
  logs; WarnOnce without ConcurrentDictionary.Count.
- M-13: handles a later subscribe fully took over are retired.
- M-14: browse open fails on a refused CONNACK or root SUBACK.
- M-15: Scalar/Raw booleans publish true/false.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-03 10:35:21 -05:00
Joseph Doherty c6dec9ed7f Merge #974 + #987: dialect-aware Sql read-only guard + read-only execution (13 bypasses closed), provider-semantics key matching, trigger-safe SQL Server rowcount 2026-12-03 10:34:08 -05:00
Joseph Doherty 65c4330a68 fix(sql): #974 #987 named queries are lexed per dialect and run read-only + single-statement; key rows attribute by server semantics; SQL Server writes count only the target statement
#974 (S-7) — the named-query guard had one lexer for five dialects and took live SQL for literal text
where a provider ends a literal earlier (MySQL backslash escapes, PostgreSQL dollar quotes, T-SQL ]],
nested comments, MySQL # / "--x", bare-CR line comments, Oracle q'..'). All 13 bypass strings were
accepted; the MySQL and PostgreSQL ones were executed against the live fixtures and the smuggled
UPDATE committed past the always-rolled-back transaction.
- SqlReadOnlyStatement (own file) lexes per provider and REFUSES constructs dialects disagree on;
  Odbc / no provider = every dialect must agree. Factory and AdminUI form pass the provider; the form
  re-validates queries on a provider change.
- ISqlDialect.BeginNamedQueryAsync / SealNamedQueryCommand / EndNamedQueryAsync: PostgreSQL and Oracle
  SET TRANSACTION READ ONLY; MySQL read-only session + transaction (restored after); PostgreSQL rewrites
  @name markers to positional $n (a parameterless query gets one unused typed $1) so Npgsql sends the
  text unsplit and the server refuses a second statement.

#987 (S-6) — key-value rows are attributed by SqlKeyMatcher (exact, then typed / padding-insensitive,
then case/accent-insensitive — only for rows the server matched); a named query's rowKey uses the
exact + representational stages only.
#987 (S-10) — SQL Server table writes read the target statement's own @@ROWCOUNT through an OUTPUT
parameter; SqlClient's ExecuteNonQuery sums trigger DML (reproduced: 1 + 2 audit rows = 3, every write
rolled back BadConfigurationError).

Tests: per-dialect bypass theory + positive controls, matcher + SQLite collation/affinity attribution,
Postgres seal, dialect-hook wiring, SQL Server write-plan capture; live NamedQueryBypassLiveTests
(PG/MySQL/Oracle), SqlServerTriggerWriteLiveTests, MySQL writing-function now refused.
2026-12-03 10:33:45 -05:00
Joseph Doherty 23867ed9d7 Merge #979: refused write reverts to last confirmed value (raw+UNS); dependents of a removed input go BadWaitingForInitialData 2026-12-03 10:30:00 -05:00
Joseph Doherty e0f133f640 fix(runtime,opcua): #979 refused overlapping writes revert to the last confirmed value; dependents of a removed input go BadWaitingForInitialData
U-4: EquipmentVariableState tracks an overlap window per node — the confirmed
(value, status, source timestamp) snapshotted when the first optimistic commit
lands on an unowned node, advanced by an older attempt the device confirms
while a newer one owns it. A refused owner reverts to it (never to the
previous attempt's unconfirmed value at Good); audit OldValue follows. Applies
per NodeId, so raw and UNS mirrors each revert to the fanned value. Mapped
completions use the same tuple.

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

Tests: Sdk2EquipmentVariableTests (overlap both orders x both realms, confirmed
older write, interleaved raw+UNS), GrpcDataMappedWriteCompletionTests,
RemovedInputQualityTests, DriverHostActorSourceRemovedTests,
VirtualTagToVirtualTagFlowTests (Roslyn, identical-value recovery).
2026-12-03 10:29:38 -05:00
Joseph Doherty eef278fc3b Merge #978: one UNS leaf-name authority (modal = service = deploy gate), script-existence gate + in-use delete guard, VirtualTagHost skips invalid tags 2026-12-03 10:28:50 -05:00
Joseph Doherty d2818e2ef2 fix(uns): #978 one UNS name authority and a script-reference gate — an illegal VirtualTag name or override is refused in the editor and at publish, and an in-use script cannot be deleted
- V3NodeIds.ValidateSegment is the single rule Uns()/UnsChild() enforce; the VirtualTag modal
  ([UnsLeafName]), UnsTreeService (VirtualTag create/update, SetReferenceOverrideAsync) and the
  deploy gate (VirtualTagNameInvalid, UnsEffectiveNameInvalid) all call it (C-1, C-4).
- Effective name is stated once (EquipmentReferenceMap.EffectiveName): an empty override falls
  back to the tag name in the gate and the Monaco catalog, as at both compose seams (C-4).
- UnsSegment patterns anchored \A..\z, so a trailing newline is rejected (C-7).
- VirtualTagScriptNotFound / ScriptedAlarmScriptNotFound deploy-gate rules; ScriptEdit refuses to
  delete a script used by a VirtualTag, ScriptedAlarm or Calculation tag and names them (C-2).
- R-5 backstop: VirtualTagHostActor skips (Error log) a plan whose NodeId cannot be built instead
  of crashing on every apply; AddressSpaceApplier counts it as a failed node instead of aborting
  the VirtualTag materialise pass.
2026-12-03 10:28:27 -05:00
Joseph Doherty f47ff00c92 Merge #992: OpcUaClient indexed recovery re-publish, safe unsubscribe ordering, Bad publish for refused refs, post-dispatch BadTimeout, IPv6 probe preflight 2026-12-03 10:21:21 -05:00
Joseph Doherty 888bc73c0d fix(opcuaclient): #992 G-10..G-15 recovery re-publish indexed, unsubscribe ordering, subscribe refusals published Bad, non-condition events dropped, post-dispatch write failures BadTimeout, dual-mode probe preflight
Co-Authored-By: Claude <noreply@anthropic.com>
2026-12-03 10:21:07 -05:00
Joseph Doherty d82d0ff1f3 Merge #971: script sandbox is an allow-list; narrowed BCL reference set (K-1 closed) 2026-12-03 10:18:28 -05:00
Joseph Doherty 9d1e6e8b86 Merge #989: MTConnect condition last-wins in /sample, subscription release on shutdown, restart re-baseline, parser skips bad observations, subscribe/unsubscribe races 2026-12-03 10:16:27 -05:00
Joseph Doherty af32984383 fix(mtconnect): #989 condition word last-wins on /sample, subscriptions released on shutdown, read-path restart re-baselines, malformed observation skipped not fatal, replay cannot overwrite a newer value, unsubscribe cannot kill a concurrent subscribe's pump
Review 2026-12-02 M-4, M-5, M-7, M-8, M-9 (MTConnect half), M-10.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-12-03 10:16:12 -05:00
Joseph Doherty abdb8f3ab0 Merge #975: AdminUI re-validates role grants every 5 min (cookie + open circuits), absolute session cap 2026-12-03 10:13:08 -05:00
Joseph Doherty 019ba96376 fix(adminui-auth): #975 AdminUI roles are re-validated on a timer (cookie OnValidatePrincipal + revalidating circuit provider); demoted users lose elevated policies within the window 2026-12-03 10:12:54 -05:00
Joseph Doherty cfd453ae34 fix(heidenhain): #990 deterministic control-loop stop, stable down-host status, throttled optional-role login, backoff survives re-init 2026-12-03 10:12:29 -05:00
Joseph Doherty c00ebf1320 fix(scripting): #971 the script sandbox is an allow-list — the K-1 bypasses (CreateDelegate, Expressions, XML/Tar I/O, X509Store, Timers/BackgroundWorker/AsParallel, Serilog.Log) are refused
ForbiddenTypeAnalyzer inverted from a BCL deny-list to an allow-list of types/members (ctx API, value/time/maths
types, collections, LINQ-to-objects, string/Regex/formatting; System.Type and CancellationToken with member
allow-lists). Every named type, expression type and used member (incl. return type and generic args) is checked;
__makeref/__arglist, lock and extern local functions refused syntactically. ScriptSandbox references only eight BCL
assemblies (defence in depth). The Monaco editor and the publish gate share both, so parity holds.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2026-12-03 10:09:39 -05:00
Joseph Doherty 89c7f5d49c fix(s7): #986 out-of-range/unconvertible scalar write values report BadOutOfRange/BadTypeMismatch without degrading health 2026-12-03 10:06:52 -05:00
Joseph Doherty be5641fc06 Merge #985: FOCAS closes session on protocol desync, refusals keep health, dead CNC no longer stalls others, slot indexes kept 2026-12-03 10:05:04 -05:00
Joseph Doherty e68d856fcb fix(focas): #985 refusals stay Healthy, protocol faults close the session, dead CNCs no longer stall others
- P-6: the wire adapter throws refused fixed-tree calls as FocasWireException carrying the rc
  (was InvalidOperationException, so a refusing control looked silent, degraded and was
  reconnect-looped by the #527 watchdog); a refused axis is per-node BadNoData and the tick continues.
- P-7: bootstrap capability probes latch only an ANSWER (rc, or session still up); a transport
  failure/timeout or a session dropped mid-pass retries the bootstrap.
- P-21: CoalesceRejected latches only range-shaped codes (not EW_BUSY/EW_SOCKET/EW_UNEXP/EW_HANDLE/unknown).
  Macro/param multi-block batching deferred (unproven on hardware).
- P-10: any fault once a request is on the wire closes the session (bad magic/version, unexpected
  PDU, malformed blocks); replies must echo the request's command ids in order (verified against
  every 31i-B capture). A refusal never closes the session.
- P-8: close handshake bounded to 1 s and run under the request gate (sync + async dispose).
- P-11: data-path callers check the backoff before ConnectGate and fail fast behind an in-flight
  reconnect to a device whose last connect failed.
- P-9: axes/spindles carry their wire slot (FocasAxisName/FocasSpindleName.Slot); cnc_rddynamic2 and
  the spindle-meter lookup use it.
- P-20: a truncated (>= 32) alarm list never clears/retriggers a told-active condition unless it
  shows a new key; unseen told keys are kept.
- P-25: a refused connect-time sysinfo is not cached; a short PARAM payload reads BadTypeMismatch.

Tests: loopback MockFocasWireServer drives the real wire client; every fix mutation-checked
(reverting it fails its test). FOCAS.Tests 619/619, FOCAS.IntegrationTests 19/19 vs the sim on
10.100.0.35, Runtime.Tests FOCAS 7/7, FOCAS.Cli.Tests 57/57.
2026-12-03 10:04:42 -05:00
Joseph Doherty 864843e4d9 Merge #982: TwinCAT re-resolves symbols after online change/download, dead device fails fast, refusal ≠ comms fault 2026-12-03 10:04:34 -05:00
Joseph Doherty 0eb620a223 fix(twincat): #982 symbol-table changes re-resolve on a fresh client; one dead device no longer stalls the rest
Review 2026-12-02 (09-ab-twincat-focas.md) TwinCAT findings:

- P-1: a stale client (ADS symbol-version event, a 1809, an invalidated
  notification, a probe non-Run -> Run transition, or a moved OnlineChangeCnt
  sampled every healthy probe tick) is never handed out again: the next call
  retires it (fresh Beckhoff symbol cache), native registrations replay on the
  fresh client (background or probe tick), its pushes are dropped, refused
  registrations re-arm, rediscovery is raised once per event. Verified against
  decompiled Beckhoff.TwinCAT.Ads 7.0.172: SymbolCache cleans itself only on
  the symbol-version event, which an online change does not raise.
- P-3: devices are read concurrently; the first comms failure on a device is
  checked against its ADS state once - gone => remaining tags fail fast with no
  wire attempt, alive => per-tag failure. Probe-unreachable devices fail fast;
  native subscribe applies the same rule.
- P-4: the probe connects without replaying registrations, probes, and
  re-registers only after the device answered; a replay against a dead device
  stops dialling it; one Warning per device per outage, Bad published once.
- P-12: unlisted device-layer ADS codes (0x700-0x73F) map to BadDeviceFailure
  (refusal, no health write, refusal backoff); 1817 DeviceTimeOut = BadTimeout;
  marshal/type read exceptions = BadTypeMismatch; the read guard refuses a
  scalar over a struct/FB (pointers/references still read as their address).
- P-19: symbol name / bit index pre-computed at init; health re-derived once
  per device per read call (health updates now serialised under a lock).
- P-22: the ADS client always carries the driver Timeout; the probe bounds
  only its own ReadState with Probe.Timeout.
- P-25: bit-indexed BOOL poll reads resolve the parent and read it at its own
  width; poll / notification / write agree on BadOutOfRange / BadTypeMismatch.

Tests: TwinCATReview20261202Tests (39 cases; the behavioural ones failed before
the fix). TwinCAT.Tests 712/712.
2026-12-03 10:04:09 -05:00
Joseph Doherty 77ba6d5f2b Merge #976: historian outages never dead-letter alarm history; gateway transient codes retry; outbox ack never drops an unindexed append 2026-12-03 10:03:50 -05:00
Joseph Doherty 07ee9e4888 fix(historian): #976 a historian outage no longer dead-letters alarm history, and an outbox ack never truncates an un-indexed value
G-16 / K-2 (LocalDbStoreAndForwardSink): a RetryPlease counts toward MaxAttempts only on a
drain where some event was Ack'd. A drain with no Ack is an outage: RetryPlease rows are left
untouched (no attempt, no dead letter), the backoff climbs to its 60 s cap, LastError reports
the deferral; PermanentFail rows still dead-letter. An outage longer than ~6.5 min used to
dead-letter the oldest queued alarm events, 100 more every ~10 min.

G-8 (GatewayAlarmHistorianWriter): only InvalidArgument/FailedPrecondition/OutOfRange/
NotFound/AlreadyExists/Unimplemented and unmappable events are PermanentFail; Cancelled,
Unknown, DataLoss, every unlisted code and every non-RPC transport exception retry (the
default used to be dead-letter, so a gateway restart dead-lettered a whole drained batch).

G-16 secondary (AlarmBatchWrite, both SQL writers): a multi-event chunk failing with an
error that is neither a recognised data error nor a known transient is re-sent event by
event, so one unrecognised poison event no longer drags its chunk-mates with it.

G-7 (FasterLogHistorizationOutbox): RemoveAsync of the newest indexed entry truncates to
that record's own end (recorded by the peek, else a one-record scan), never to the live
tail that may already hold an enqueued-but-unindexed append; peeks return only indexed
records so every peeked entry can be acked.

Tests: simulated multi-hour outage (fake clock, 200 drain cycles) loses 0 events and
drains in order on reconnect; positive controls for PermanentFail and a RetryPlease-forever
poison row getting exactly its MaxAttempts budget; gRPC/transport classification theory;
AlarmBatchWrite isolation + known-outage control; G-7 parked-append race + peek-only-indexed.
2026-12-03 10:03:25 -05:00
Joseph Doherty 03e85ab752 Merge #972: ACL revalidation honours Security:Acl:Enabled=false (no flag-off stand-downs); dead SecurityFilteringActive removed 2026-12-03 10:01:19 -05:00
Joseph Doherty 40637b9954 Merge #983: AbCip dead device fails fast, BOOL arrays read in DWORDs, throttled logging, RMW lock + probe fixes 2026-12-03 10:00:15 -05:00
Joseph Doherty 85d479e23e fix(opcua-acl): #972 revalidation no longer stands down subscriptions while Security:Acl:Enabled=false
IsSubscriptionStillPermitted now asks Permits(identity, CreateMonitoredItems, node) — the creation
gate's own seam and the one place the flag-off bypass lives — instead of the bypass-less
IsAllowedCached. Since 8ad03e9c5 the pass ran with the flag off (SecurityFilteringActive's
'|| NamespaceIndexes.Count >= 4' term was always true: five namespaces are always registered) and
stood every ungranted/Anonymous subscription down within 60 s or on the next deploy (review U-1).

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

Tests: unit flag-off (keyed + Anonymous, empty authority, no authorizer) x5 passes with a flag-on
positive control; wire flag-off data + folder-event subscriptions survive 5 ticks + a no-grant deploy,
with flag-on controls on the same items.
2026-12-03 10:00:02 -05:00
Joseph Doherty e6ca58148b fix(abcip): #983 packed structure reads, non-blocking lease release, allocation trims, docs (P-24)
Structure reads of a known size pack into one MSP; browse/template lease release no longer
blocks a thread-pool thread up to 2 s; scheduler packs with running totals; CipReply empty
extended-status array shared. AbCip.md documents P-2/P-13/P-16/P-22/P-23/P-24.
2026-12-03 10:00:00 -05:00
Joseph Doherty 7d6cf97fdd fix(abcip): #983 RMW lock keying + whole-word lock, bit selector 0-63, interval floors, cycle guard on struct type, browse surfaces transport faults (P-23 a-e) 2026-12-03 09:55:25 -05:00
Joseph Doherty 7e3dbbb122 Merge #973: fleet diagnostics only dials known cluster members (SSRF closed) 2026-12-03 09:50:38 -05:00
Joseph Doherty c5c31a1671 fix(abcip): #983 whole BOOL-array read counts DWORDs (P-13); probe leases with the driver timeout (P-22) 2026-12-03 09:50:16 -05:00
Joseph Doherty b7d413366d Merge #984: AbLegacy unsupported types fail per-tag, bit arrays sized in words, Bit-without-/n RMWs bit 0 2026-12-03 09:47:29 -05:00
Joseph Doherty a9bc103eea fix(ablegacy): #984 per-tag family-type rejection + gate, bit arrays sized in words, Bit write RMWs bit 0, T/C/R read coalescing, answered-refusal/gate-race/null-write fixes
P-5 Long on MicroLogix/PLC-5 is BadConfigurationError per tag (init no longer throws), deploy gate warns via family-aware Inspect.
P-14 Bit array wire read sized in 16-bit words. P-15 Bit without /n RMWs bit 0; Bit on non-bit file refused.
P-18 native T/C/R sub-elements coalesce into one whole-element block read.
P-23f local OutOfBounds/TooLarge no longer count as answers, element/file >65535 is malformed; g block read re-resolves under the gate with identity-checked eviction; h null scalar write BadTypeMismatch.
2026-12-03 09:47:13 -05:00
Joseph Doherty 56fcc6e939 fix(adminui): #973 /fleet/diagnostics only dials Up driver members or enabled ClusterNodes; client refuses non-host:port targets
Closes the A-1 SSRF: ?node= / the typed box resolved straight into an Akka ActorSelection, so any
signed-in user could make the admin node open a remoting association to an arbitrary host:port.
Page policy stays AuthenticatedRead (same tier as /fleet and /hosts). Akka untrusted-mode audit
recorded in docs/security.md as an open follow-up.
2026-12-03 09:46:37 -05:00
Joseph Doherty eff7775bca fix(abcip): #983 a dead device no longer stalls the multi-device read batch and logs once per outage (P-2, P-16)
Scheduler faults everything queued behind a failed channel exchange; per-device read
windows plus a per-call fault latch fail a dead device's remaining items fast; throttled
creates no longer throw+log per tag (one Warning per device per outage, Info on recovery).
2026-12-03 09:45:29 -05:00
Joseph Doherty 462dadc911 Merge #980: unexpected cluster exit exits non-zero for SCM, audit buffer survives DB outage, HTTPS listener misconfig fails boot 2026-12-03 09:43:27 -05:00
Joseph Doherty ccba570840 fix(host): #980 node exits non-zero when its ActorSystem terminates, audit flush keeps+retries on transient DB failure, HTTPS + dedicated listener fails host start
H-1: ActorSystemTerminationWatchdog flushes logs and exits the process with code 1 instead of StopApplication (clean SCM stop never triggers sc failure recovery).
H-2: AuditWriterActor re-buffers a batch when the DB did not answer; bounded 10k drop-oldest with counter; threshold flush suppressed while failing.
H-5: DedicatedListenerGuard throws instead of log-and-zero when an HTTPS binding blocks a requested dedicated h2c listener.
2026-12-03 09:43:11 -05:00
Joseph Doherty 388291d18a fix(modbus): #981 RTU-over-TCP discards the socket on caller cancel, re-subscribe republishes inside the deadband, DL205 non-octal C address is an error
S-1: ModbusRtuOverTcpTransport.SendOnceAsync tears the socket down on any exit after the write
without a validated reply (caller cancellation included), so a late reply can no longer answer
the next request at Good. S-2: SubscribeAsync/SubscribeAcquisitionAsync drop the deadband
baselines of their refs before polling starts. S-8: a family-recognised prefix whose body the
family parser rejects no longer falls through to the generic mnemonic table.
2026-12-03 09:42:30 -05:00
Joseph Doherty e4740df2c9 fix(opcua): #970 a projected lookup racing back-to-back renewals never gives up and reports a live node missing
#968 made OtOpcUaNodeManager.TryResolve/TryResolveForRenewal re-evaluate a
definition replaced mid-check, but at most 16 times. A reader preempted while a
renewer swapped the definition back to back exhausted the bound and answered
'no such node' for a live node, which tears a physical stream down
(A_definition_replaced_by_a_renewal_never_resolves_as_missing failed 22/280
under load, on master too).

The bound is removed; the double read stays (it is what stops a removed node
being answered). The loop provably ends: the committed map compares values by
reference, so a retry happens only when a replacement of THIS node was
committed during that pass. Iterations are at most 1 + the replacements
committed during the call (lock-free progress; commits are serialized under
Lock and each needs a renewal or page apply); a removed node or a disposing
manager ends it at once.

Regression: A_lookup_outlasting_many_back_to_back_replacements_never_resolves_as_missing
(deterministic: the definition's authority check commits a replacement each time
it is evaluated, 64 times in a row; red on master, green now). Stress at the
same load: 280/280 runs of the 5 renewal tests pass (master: 22/280 failed).
2026-12-02 15:36:52 -05:00
Joseph Doherty a571a0fc99 fix(grpc-data): #969 concurrent cadence renewals of one predecessor share one metadata call and one commit
Two Subscribe cadences of one node reach the renewal window on the same tick
and each ran its own overlap renewal of the same predecessor: two origin
metadata calls, and the second commit adopted the first's successor yet
replaced the node's committed definition again (harmless since #968, wasted).

ProjectedDataAccess now keeps in-flight cadence renewals per predecessor proof
(reference identity, same node). A cadence that finds one waits for it; a
committed shared renewal is its success too (it adopts the committed successor
exactly as the existing already-committed shortcut does, its own caller
re-authorized by TryPrepareBinding). A shared renewal that did not commit is no
verdict: the joiner renews for itself, so one cadence stopping or being refused
only delays the other. No sink interface change.

Tests: Concurrent_cadence_renewals_of_one_predecessor_share_one_metadata_call_and_one_commit
(red: 2 metadata calls; green: 1 call, 1 definition replacement, both streams
kept) plus a variant where the shared renewal fails and the joiner renews
itself. The #968 adoption wire test keeps exercising the unshared path via a
test switch.
2026-12-02 15:10:02 -05:00
Joseph Doherty 464f8d4852 fix(grpc-data): #968 a projected node replaced by a metadata renewal mid-lookup no longer resolves as missing
OtOpcUaNodeManager.TryResolve/TryResolveForRenewal read the committed
definition map twice and answered false when a renewal replaced the
definition between the reads. Every subscription demand check racing a
renewal could then see its live node as gone and tear its physical stream
down (freshness check breaking the attempt, 'Source unavailable' on the
rebind baseline). Two cadences of one node made it likely: both renew on
the same tick and the second, redundant renewal replaces the definition
again while the first cadence rebinds - the residual ~1% hang of
Two_sdk_cadences_renew_before_expiry (the barrier timeout was a victim).

A lookup now re-evaluates a definition replaced mid-check (bounded).
Regression: A_definition_replaced_by_a_renewal_never_resolves_as_missing
(red: ~19% of lookups racing renewals answered missing), plus a wire test
for two cadences committing the same successor.
2026-12-02 14:46:34 -05:00
Joseph Doherty c38f78d1f4 Merge #965: metadata-renewal wire tests pace the fake clock deterministically (tick-quiescence counters, AdvanceInOneStep); residual ~1% heavy-load hang tracked #968
v2-ci / unit-tests (push) Has been cancelled
2026-12-02 13:55:05 -05:00
Joseph Doherty 34014190a7 test(runtime): #965 pace metadata-renewal wire tests by observed progress, not wall-clock delays
- ProjectedDataAccess: internal queued/handled renewal-tick counters (RenewalTicksQuiescentForTests) so a test can wait until every tick a clock advance fired has been handled.
- ManualTimeProvider.AdvanceInOneStep: all timers see the final instant (successor lease is stamped from request start).
- Live_predecessor_cadence...: Task.Delay(20/100) pacing replaced by advance-and-settle; 10 s waits widened.
- Two_sdk_cadences...: 9 s jump in one step (deterministic successor issue time, fixes the 7.45 s margin flake); read each item's notifications until its expected value (8 vs 9 flake); barrier timeout widened.
Residual ~1% hang tracked in #968.
2026-12-02 13:54:50 -05:00
Joseph Doherty 8e03995300 Merge #967: an invoker failing before dispatch on an externally-rejected claim releases the late-write slot/target and answers RejectedBeforeDispatch 2026-12-02 13:19:59 -05:00
Joseph Doherty 8d6b64393e fix(grpc-data): #967 a rich write whose invoker fails before dispatch on an externally-rejected claim releases its slot
When the invoker threw without running the dispatch delegate (open breaker /
bulkhead) after the claim had already been completed RejectedBeforeDispatch
by someone else, Complete(RichRejected) returned false, the path answered
OutcomeUnknown and never completed the physical task. The late-write slot,
the (driver, reference) target and the ticket's byte lease stayed reserved
for the process lifetime, so every later write to that tag was refused as
'Outstanding driver write capacity exhausted'.

Both catch paths now go through FailRichAttempt: an undispatched terminal
claim can never dispatch (dispatch is a CAS from pending), so the physical
task completes with the claim's pre-dispatch outcome and the caller hears
RejectedBeforeDispatch. Only a dispatched claim stays Unknown and is left
to the driver's own completion.
2026-12-02 13:19:44 -05:00
Joseph Doherty e96d81ba06 Merge #966: a Modify's replacement item no longer emits a live delta before its snapshot (real ordering defect, 60/40k -> 0/40k) 2026-12-02 13:12:38 -05:00
Joseph Doherty efd749da0f fix(grpc-data): #966 a modify's replacement no longer emits a live delta before its snapshot
The suspected ordering gap was real. A modify that replaces an item commits on the delivery side (the ack's
commit): the replacement enters _items (it was already registered with the delivery scheduler at staging) and its
snapshot job goes to _committedSnapshots, which only the NEXT tick moves to the pump. A tick already past that
dequeue that then reads a source change (e.g. from a sibling item on the same source, whose interest group survives
the modify) marks the source dirty. The scheduler hands it the replacement's handle, and ConsiderAsync sent the
newer value as a live delta before SnapshotBegin. The snapshot that followed carried the older captured value.

ConsiderAsync now defers an item whose interest group is not snapshot-complete. LastConsidered is left unchanged,
and the group's own lease (its cursor starts at the snapshot capture) yields the change once SnapshotEnd commits.
The same guard covers added and recovered items. Nothing starves: an undelivered SnapshotEnd stops the stream.

Deterministic test (BeforeDirtyTickForTests hold + gated modify ack + publish under the hold): red 3/3 before
(value:R:20 | begin | snapshot:R:10), green after, with a positive control that 20 is delivered after the end.
Parallel in-process stress of the unhooked scenario (2 items on one source, modify one under continuous publish):
60/40000 violations before (10000 x widths 2/4/6/8), 0/40000 after.
2026-12-02 13:12:27 -05:00
Joseph Doherty bcd4a9aa29 fix(grpc-data): #964 rich write releases its late-write slot before replying / freeing the tag
The late-write observer released the physical slot on its own continuation of
the driver task, while RunRichWriteAsync replied and told WriteCompleted on
another. A next write to the same target (queued, or sent right after the
reply) could reach TryReserve before the release and be rejected with
'Outstanding driver write capacity exhausted' although nothing was
outstanding. LateWriteReservation.Observe now returns a task that completes
after the slot is released; the actor awaits it (when the physical write has
finished) before replying and freeing the tag. The flaky unit test waited on
the lifetime counter, which is disposed just before the release - it now
awaits the settled task.

Repro: 200 sequential same-target actor writes failed 3/3 runs (no load);
0 failures in 15 runs at load avg ~468. Unit signal: lifetime-wait 22-39 /
2M false 'slot busy', settled-wait 0/2M.
2026-12-02 13:10:20 -05:00