Warehouse Latency Percentile Rounds Rank Down and Hides Slow Samples
Level 2 · node · Correctness · Nearest-rank percentile floors the rank and omits high latency samples
Scenario
A fictional warehouse monitoring service records job processing latencies in milliseconds by site and reports percentiles. The dashboard uses the nearest-rank definition, but the current calculation rounds the rank downward, hiding occasional slow jobs. Inspect the repository, calculation service, and controller.
Requirements
Correct the nearest-rank index selection after sorting samples. Preserve per-site isolation, input validation, the 100th percentile, and unknown-site behavior.
Acceptance criteria
- The 95th percentile uses the ceiling of the nearest-rank position.
- The 50th percentile of an odd-sized sample is its median.
- The 100th percentile returns the largest sample.
- Sample sets from different sites remain independent.
- Invalid samples and out-of-range percentiles are rejected.
- An unknown site returns null for percentile queries.