#976 made StatusCode.Unknown (the gateway's handler threw) and non-RPC non-transport exceptions
RetryPlease. On the SendEvents path a RetryPlease marked the whole chunk and every later chunk
RetryPlease; with no Ack the sink treats the drain as an outage and counts nothing, so ONE such
event at the queue head stalled all Gateway alarm history until the 1,000,000-row capacity evicted
it silently. The SQL writers already isolate unrecognised failures (AlarmBatchWrite); the Gateway
writer had no equivalent.
Gateway: a RetryPlease failure that is not a known outage (IsSystemicFailure: Unavailable,
DeadlineExceeded, Cancelled, ResourceExhausted, Aborted, auth codes, typed Unavailable/auth client
exceptions, or a socket/IO/HTTP/disposed/timeout/cancellation cause) re-sends the chunk singly at
once: siblings Ack, the culprit keeps RetryPlease and dead-letters via MaxAttempts. If no single
Acks it is treated as systemic (later chunks not sent) — bounded to one chunk of singles per drain.
SQL (LOW): AlarmBatchWrite stops isolating at the first single that fails with a known outage
error; the SQL Server alarm writer passes the wider SqlHistorianConnection.IsOutage (login failed
18456/18452, unreachable/refused 2/40/53/64/121/10061/10065/-1, severity >= 20, pool timeout) —
IsTransient is unchanged for its retry callers. Fixes the false claim in docs/AlarmHistorian.md.
Tests: GatewayAlarmPoisonDrainTests (real LocalDb sink + real writer: poison at the queue head ⇒
siblings Ack on the first drain, poison dead-letters via MaxAttempts; positive control: Unavailable
outage ⇒ no single sends, nothing dead-lettered), writer-level isolation + bounded fan-out tests,
AlarmBatchWrite early-stop + no-stop-on-adjacent-poison control, SqlOutageClassificationTests.
At most one evaluation is pending per calc tag; a re-trigger only moves its
timestamp forward and the dependency snapshot is taken when the pump dequeues
it. Previously every dependency arrival enqueued a separate evaluation per
dependent with a trigger-time snapshot: k inputs of one cycle ran k times
(publishing intermediates computed from mixed old/new inputs) and the queue had
no bound when triggers outpaced the pump. The out-of-process batch pump now
dequeues every pending tag once per batch.
- 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>
#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.
G-9: a gateway-answered InvalidArgument/OutOfRange/NotFound/Unimplemented read is a connectivity observation (open, streak ends), not a failure; outages still degrade.
G-17: capped reverse/end-only QuestDB events reads find the n+1-th latest ts with an early-exit backward scan, then read ts >= cut ordered (ts DESC, event_id DESC).
G-18: Distribute takes a bridged/nonGood flag instead of per-sample delegates (O(buckets) allocation).
QuestDB integration fixture waits up to 60 s for WAL visibility (shared host is CPU-saturated; the 5 s production default made alarm-writer tests read back fewer rows).
Co-Authored-By: Claude <noreply@anthropic.com>
- 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.
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.
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.
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.
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.
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).
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.
#944: a snapshot/QueryActiveAlarms lists active alarms only, so a Clear dropped while the
host's OnAlarmEvent handler was detached (or the stream was down) was never recovered. The
driver records which alarms it delivered as active; on a COMPLETE read (sentinel or re-read,
new IGalaxyAlarmFeed.ActiveSetDelivered, raised under the dispatch lock) it synthesises a
restatement Clear for told-active alarms of the live subscription the read does not name,
before the known-state signal. A re-read counts alarms the live stream restated meanwhile as present.
#945: provider_status / snapshot_status no longer fall to the decode-failure default (logged +
counters). A snapshot flagged truncated (snapshot_status or per-record flag) is not complete: no
sweep, no known-state signal; when the gateway clears the verdict the driver re-reads.
Co-Authored-By: Claude <noreply@anthropic.com>
#946: AlarmRefreshRequiredMinInterval (default 10 s, 0 disables) spaces RefreshRequired-triggered ConditionRefresh sweeps per session; a request inside the window is deferred to its end and coalesced, never dropped.
#947: AcknowledgeAsync throws the breaker-exempt DriverOperationRefusedException for Bad per-ack statuses and unresolvable condition ids (BadConditionBranchAlreadyAcked is success) so the #760 revert fires. Docs reverse the O-8 decision.
- a sequence gap outside a bracket is a loss (re-refresh, same budget); older/repeated
sequence numbers are ignored and not recorded
- AlarmInitialStateEventArgs.Withdrawn (additive): the driver withdraws 'known' once per
signalled episode on its first loss; DriverHostActor sends MarkConditionsKnown(Known:false)
for those conditions, drops them from the backstop and re-arms F5
- a RefreshStart while a bracket is open is a loss (never erases the open bracket's)
- a failed ConditionRefresh call is retried through the same bounded retry
- retry generation token (a finished retry never clears a newer retry's pending flag)
- spent budget renews after a 5-min cool-down; RefreshRequired sweeps coalesced
Red/green per fix (7 mutations) + live opc-plc gate re-run.
Track RefreshStart..RefreshEnd per alarm subscription. EventQueueOverflow (matched by
EventType before the source filter - it comes from the Server object), RefreshRequired,
a publish-sequence gap the SDK skipped (EventFieldList.Message.SequenceNumber; SDK 2.0.1's
Republish publish-state never fires for a gap that blocks delivery) or a missing
RefreshStart suppress the A1 signal and re-run ConditionRefresh, bounded (3, 2/4/8 s);
exhausted = conditions stay unknown (Uncertain), never Unsignalable. Alarm event queue
1000 -> 10000; new counters alarm_event_queue_overflow / alarm_refresh_lossy.
Unit + real-SDK gap tests, live overflow gate on opc-plc --alm; plan G2 text corrected.
- Only full-state live messages (snapshot entry, Raise, Retrigger, Clear) supersede a
QueryActiveAlarms entry; an Acknowledge merges (Active => ActiveAcked) instead of
skipping it and then signalling a cold condition known.
- Stream epoch bumped before StreamOpened; a changed epoch at replay drops the replay
and the signal (an alarm cleared in the gap is absent, never touched); no re-read
before the current stream's sentinel.
- Lows: dispose race returns false; teardown token on the RPC and the retry wait;
an unexpected failure keeps a queued follow-up.
A sentinel comes only when StreamAlarms opens, so a subscription that became live
after the current stream's sentinel (or changed during its snapshot phase, F4)
stayed unknown until a reopen. The feed now re-reads the active set via the
gateway's existing QueryActiveAlarms (same monitor cache), replays entries as
restatements except where the live stream already delivered a newer message for
that alarm, and the driver then signals the still-live subscription. Coalesced
(one in flight + one follow-up), 3 bounded retries, Unimplemented not retried,
a failed re-read never signals.
A list cut off at the per-read cap may hide the alarm a selector matches; a condition that matched nothing on such a
read stays unknown instead of being signalled known-inactive.
The feed raises a new IGalaxyAlarmFeed.StreamOpened (default no-op accessors) before each stream's first message;
GalaxyDriver records the live subscription then, and its sentinel signals only if that is still the live one —
so refs whose snapshot entries arrived before (or without) the subscription are never signalled. The handle is
now added before the feed starts, so the first stream opens under it.
A condition Unavailable at baseline never became known: its later Normal is a quality-only emission and only full
emissions signalled. A delta emission now signals its touched conditions whose level is not Unavailable, after the
events and under the same lock (tracker baseline required). Sample_delta_does_not_signal… (which pinned the old
behaviour) is now Sample_delta_signals_its_touched_conditions_and_a_rebaseline_signals_all.