Skip to content

Constant-time test: thin separation margin when the control lands near its floor #353

Description

@bordumb

Summary

The constant-time test rework in df6cc250 ("fix: constant time test flakiness",
crates/auths-crypto/tests/cases/constant_time.rs) is a good robustness improvement — it replaced a fixed
|t| threshold with a same-run relative check that cancels per-runner absolute noise. This issue is a
minor follow-up: the separation margin is thin in one corner.

The rule

const CONTROL_FLOOR: f64 = 1000.0;
const MIN_SEPARATION: f64 = 8.0;
// ...
assert!(control > CONTROL_FLOOR, ...);
assert!(ct * MIN_SEPARATION < control, ...);

The observation

When the naive control lands near its 1000 floor, the ct * 8 < control rule requires
ct_eq |t| < 125. The file's own comment notes ct_eq has been observed up to ~100 on busy CI cores.
That leaves only ~1.25× headroom in that corner — so a simultaneously noisy run (control compressed toward
1000 and ct_eq spiking toward 100) could false-fail.

Why it's minor

The control is structurally in the thousands (a 32-iteration vs 1-iteration loop), so landing near 1000 is
unlikely, and the joint event (control-near-floor and ct-near-100 on the same run) is improbable. It
likely won't flake in practice.

Possible tightening (optional)

  • Raise CONTROL_FLOOR toward ~1500–2000: a genuine control is normally 3000+, so it still always clears
    the floor, while widening ct_eq's headroom in the worst corner; or
  • key the separation off the control's measured value (already done) but require a larger MIN_SEPARATION
    only validated against the floor; or
  • just leave it and watch CI for flakes — this is a watch-item, not a known failure.

Severity

Minor / watch-item. No observed flake; filing so the thin corner is on record.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions