#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.
- 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.
PerEndpointConnectTimeout (3 s) now bounds only TCP + discovery, so failover past a
dead endpoint stays fast. The new SessionCreateTimeout (10 s) bounds OpenSecureChannel
+ CreateSession on an endpoint that answered discovery, where the client-side cert and
crypto work lives (#910). 2 x (3 + 10) s stays inside the host's 30 s initialise bound.
Expiries name the budget that ran out; both budgets must be positive; AdminUI form
carries the new field so a save does not drop it; driver docs updated.
Closes#912
Cause: the client-side PerEndpointConnectTimeout (3 s), not opc-plc. The
validate:null case is the first test the assembly runs, so it pays the
cold-process cost of the first Basic256Sha256 connect: loading the fresh
throwaway certificate, validating the server's, and the asymmetric handshake.
In the G2 full-solution run that local work used up the budget. The opc-plc
log at 13:13:50-53Z shows the discovery channel closing at 50.709, then nothing
from the client for 3 s, then OpenSecureChannel answered at 53.775 and the
client closing the channel 48 ms later. The SDK reports a wait cancelled by
that budget as BadRequestInterrupted. opc-plc auto-accepted the certificate
(--aa, "Trusting certificate ... command line option") with no reject and no
store round-trip.
- Driver: a per-endpoint budget expiry now surfaces as TimeoutException naming
PerEndpointConnectTimeout instead of BadRequestInterrupted or a bare
TaskCanceledException. There is no behaviour change. Unit test added
against a silent TCP listener.
- Test: the ServerHostNameValidationTests secure options use a 15 s budget,
the same as the browser integration tests' 10 s. Connect latency is not
what these tests check.
- docs/drivers/OpcUaClient.md: documents what the budget covers.