fix(valid-detection-benchmark): floor scale runtimes at one millisecond

The 11.5 review noted that the scale validator accepted runtime_ms >= 0,
so a sub-millisecond or frozen-clock reading could be recorded as 0 ms.
Clamp every recorded runtime (per-arm, streaming, lane) to at least 1 ms
and tighten the validator to > 0. A frozen-clock test proves all three
floors; it fails against the previous source (0 ms receipts).
This commit is contained in:
Marius Ciepluch
2026-11-23 11:05:20 +01:00
parent f30a5d2cb2
commit f2093a5380
2 changed files with 31 additions and 5 deletions
+3 -3
View File
@@ -346,7 +346,7 @@ def run_streaming_validation(
reasons.append(WorkflowReasonCode.INTERRUPTED)
elif consumed != declared_total and not reasons:
reasons.append(WorkflowReasonCode.INSTRUMENT_FAILURE)
runtime_ms = int((time.perf_counter() - started) * 1000)
runtime_ms = max(1, int((time.perf_counter() - started) * 1000))
status = WorkflowStatus.IMPAIRED if reasons or consumed != declared_total else WorkflowStatus.COMPLETED
return StreamRunReceipt(
status,
@@ -397,7 +397,7 @@ class TimingAdapterProxy:
started = time.perf_counter()
result = self._inner.execute(bundle)
arm_id = getattr(getattr(bundle, "arm", None), "arm_id", "unknown-arm")
self.arm_runtimes.append((arm_id, max(0, int((time.perf_counter() - started) * 1000))))
self.arm_runtimes.append((arm_id, max(1, int((time.perf_counter() - started) * 1000))))
return result
@@ -500,7 +500,7 @@ def stream_with_lane(
consumed += len(batch)
total_bytes += sum(len(item.raw) for item in batch)
chain = _chain_step(chain, _lane_marker(batch)[2])
runtime_ms = int((time.perf_counter() - started) * 1000)
runtime_ms = max(1, int((time.perf_counter() - started) * 1000))
impaired = bool(refusals) or consumed < declared_total
receipt = StreamRunReceipt(
WorkflowStatus.IMPAIRED if impaired else WorkflowStatus.COMPLETED,