test(grpc-data-rig): #1115 scale profile (seed --scale N) and the #1026 scale gate

- device: read-only scale block (holding registers 1000..5095) + scale_set control action
- seed: GRPC_DATA_SCALE=N adds SOURCE driver modscale/dev with N UInt16 tags in TagGroups
  small (first 160) / large (rest), one RawTagGroup export + CONSUMER mapping each
  (map-scale-small|large); fixture.json records the counts
- rig.py: seed --scale N; deploy trigger gets a 60 s socket timeout (the AdminUI's
  StartDeployment ask waits up to 45 s; a 2048-tag snapshot read took ~25 s, so the
  general 15 s cap aborted the POST)
- scale_gate.py: opens a >128 and a >1024-item mapping via Client CLI recursive
  subscribes on CONSUMER, requires all Good, churns the block, restarts the SOURCE pair,
  requires all Good with a post-restart value, checks the consumer ResetHistory counter
  and the container logs for 'history expired'; PASS/FAIL + evidence/S1026-results.json

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Joseph Doherty
2026-12-05 03:34:02 -05:00
parent 961ca2897c
commit 8ddae2f43d
7 changed files with 570 additions and 9 deletions
+20 -1
View File
@@ -1,7 +1,9 @@
"""Deterministic, fixture-only Modbus TCP source and bounded control ledger.
Register map (unit 1): 0 counter; 10..12 fixed array; 20..63 writable scalar/
array window. Control calls advance or set values explicitly; wall time never
array window; 1000..5095 read-only scale block (#1115), every register holding
the one value the `scale_set` control action last set (initially 1). Control
calls advance or set values explicitly; wall time never
changes samples. A one-shot fault can discard a write response *after* recording
its effect, which gives the integration gate a reproducible ambiguous outcome.
"""
@@ -20,6 +22,10 @@ CONTROL_PORT = 8080
MAX_PDU_BYTES = 253
MAX_CONTROL_BYTES = 4096
MAX_LEDGER_ITEMS = 1024
# #1115 scale profile: a read-only block the seeder's `--scale N` tags poll (N <= SCALE_COUNT). Contiguous, so the
# Modbus driver's read coalescing covers 2048 tags in ~17 FC03 reads. Values change only through `scale_set`.
SCALE_BASE = 1000
SCALE_COUNT = 4096
class DeviceState:
@@ -30,6 +36,9 @@ class DeviceState:
self._registers.update({24: 7, 25: 11, 26: 13})
text = b"grpc data source"
self._registers.update({40 + offset // 2: int.from_bytes(text[offset:offset + 2], "big") for offset in range(0, len(text), 2)})
self._scale_value = 1
self._scale_sets = 0
self._registers.update({address: 1 for address in range(SCALE_BASE, SCALE_BASE + SCALE_COUNT)})
self._effect_total = 0
self._read_total = 0
self._request_total = 0
@@ -54,6 +63,7 @@ class DeviceState:
"rejected_writes": list(self._rejected_writes),
"writable": {str(address): self._registers[address] for address in range(20, 64)},
"drop_next_write_response": self._drop_next_write_response,
"scale": {"base": SCALE_BASE, "count": SCALE_COUNT, "value": self._scale_value, "sets": self._scale_sets},
}
def read(self, address, quantity):
@@ -121,6 +131,15 @@ def apply_control(state, command):
raise ValueError("set requires writable address and uint16 value")
with state._lock:
state._registers[address] = value
elif action == "scale_set":
value = command.get("value")
if type(value) is not int or not 0 <= value <= 65535:
raise ValueError("scale_set requires a uint16 value")
with state._lock:
for address in range(SCALE_BASE, SCALE_BASE + SCALE_COUNT):
state._registers[address] = value
state._scale_value = value
state._scale_sets += 1
elif action == "drop_next_write_response":
with state._lock:
state._drop_next_write_response = True