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.
This commit is contained in:
Joseph Doherty
2026-12-03 09:47:13 -05:00
parent 65fd71de7a
commit a9bc103eea
10 changed files with 601 additions and 75 deletions
+31 -3
View File
@@ -28,9 +28,15 @@ Per family the `AbLegacyPlcFamilyProfile` supplies the libplctag `plc` attribute
default CIP path, max-payload bytes, and the `SupportsStringFile` /
`SupportsLongFile` capability flags. MicroLogix uses direct EIP (empty default
path); MicroLogix and PLC-5 don't ship L-files; PLC-5 predates them entirely.
Tag types are validated against the device's profile at init time — declaring a
`Long` or `String` tag on a family that can't support it fails fast with a clear
message.
Tag types are validated against the device's profile — declaring a `Long` or
`String` tag on a family that can't support it is **that tag's** configuration
error (review 2026-12-02 P-5): init still succeeds, the tag reads and writes
`BadConfigurationError` without touching the wire, one Warning is logged, and the tag
appears in the skipped-tag report. The deploy gate (`AbLegacyTagDefinitionFactory.Inspect`
with the device's `PlcFamily`, same `AbLegacyPlcFamilyProfile.UnsupportedDataTypeReason`
authority) warns earlier. Note the MicroLogix profile says `SupportsLongFile: false`;
MicroLogix 1100/1400 may in fact ship L files (product knowledge, unverified on
hardware here) — flipping the flag is a one-line change once a real controller confirms.
## Capability Surface
@@ -81,6 +87,28 @@ PCCC structural rules — bit-addressing only on 16/32-bit element files,
sub-elements only on T/C/R files, no file number on I/O/S — rejecting malformed
addresses before they reach libplctag.
**A `Bit` tag authored without `/n`** reads as bit 0 of its word, so it **writes as bit 0**
through the same read-modify-write (decision, P-15: reading and writing the same bit is the
least surprising and preserves the other 15; refusing would have broken existing tags). It used to
write the whole word as 0x0001 / 0x0000. A `Bit` tag with no `/n` and no status sub-element on a
file with no bit layout (F, ST, a bare T/C/R element) has no sound write and is `BadNotSupported`.
**Bit arrays** — `arrayLength` counts BITS; the wire read is sized in 16-bit words
(`(bits + 15) / 16`, `AbLegacyDriver.WireElementCount`), so 256 bits on a 16-word `B3` file is one
16-word read, not a 256-word read past the end of the file (P-14).
**Read coalescing of Timer / Counter / Control sub-elements (P-18)** — on the **Native** transport, `T4:n.ACC` /
`.PRE` / `.DN`… (and C/R) of nearby elements of one file ride ONE whole-element read (6 bytes per element)
and each tag is sliced out of its element; N/B/F/L word coalescing is unchanged. libplctag keeps the
per-sub-element reads (its multi-element T/C/R layout is not verified here), and `S:`/`I:`/`O:` words
(implicit file number, octal PLC-5 I/O) are still not coalesced. Hardware gate: native block read on a real
controller with timers.
**Answered refusals (P-23f)** — only a refusal the DEVICE sent (`AbDeviceReplyException`, or a libplctag
status) counts as proof the device is alive; a locally raised `OutOfBounds`/`TooLarge` does not. A file or
element number above 65535 (cannot be encoded) is a malformed address (`BadNodeIdUnknown`), never a wire
read. A **null** scalar write value is `BadTypeMismatch` before any runtime is created (P-23h).
**Bit-within-word writes** — B-file (`B3:0/0`), I/O image (`I:0/0`, `O:1/2`),
N-file (`N7:0/3`), and L-file bit addresses all use the same parent-word
read-modify-write (RMW) path: the driver reads the parent word, flips the target