System Design Atlas

Sensor monitoring with late measurements

02 / 10Worked example

Requirements

Which rule must every transport retry preserve?

Domain rules and operational targets protect different properties. W-17 becomes provisional when its window ends and final after the fixed processing wait. TEMP-3 identifies the temperature rule version used in this case. An alert requires at least four measurements and a final mean above 30 °C.

Starting point Step 1 separates acceptance, evaluation and human examination.

Assumptions for the example case

Example design with 10,000 temperature devices, one value every 10 seconds. An example of a time period ranges from 12:00 to immediately before 12:01. The evaluation will be completed at 12:03 at the earliest. The waiting time of 120 seconds after the end of the time period is an evaluation rule and not a permitted deviation of the instrument clock. Numbers and temperatures are illustrative design assumptions.

Check function, invariant and measurement target separately

W-17 · Separate function, domain rule and operational target

Function
Accepting raw value permanentlyD-17, BOOT-4 and sequence 4711 are readable.

Own testSend the same message again.

Invariant
Protecting the final windowOnly ≥ 4 measurements and mean > 30 °C open AL-17.

Own test3 values or exactly 30 °C must not open an alert.

Quality objective
Check acceptance under Replay5,000 values/s remain a separate replay test profile.

Own testMeasure ingestion latency, log backlog and quarantined values.

  • Performance
  • Protection rule
  • Measurement target

A transport acknowledgement establishes neither a final window nor a valid alert. Each property requires its own test.

An ingestion acknowledgement makes no promise about an alert. The rule and its timing require separate tests.

Business requirements and invariants (functional)

Further reading
RequirementRule in the exampleNegative test
Accept uniquelyKey is (tenant, device, bootId, sequence).Same key with different payload goes into quarantine.
Track times separatelyMeasurement time and reception time both remain readable.Future time does not flow in W-17.
Protect the final resultLate values do not change a final window silently.Later raw value does not change AL-17.
Open an alertFinal mean > 30 °C from at least 4 different valid measurements.Exactly 30 °C or 3 values do not open anything.

Accept uniquely

Rule in the example
Key is (tenant, device, bootId, sequence).
Negative test
Same key with different payload goes into quarantine.

Track times separately

Rule in the example
Measurement time and reception time both remain readable.
Negative test
Future time does not flow in W-17.

Protect the final result

Rule in the example
Late values do not change a final window silently.
Negative test
Later raw value does not change AL-17.

Open an alert

Rule in the example
Final mean > 30 °C from at least 4 different valid measurements.
Negative test
Exactly 30 °C or 3 values do not open anything.

Assumed quality goals (non-functional)

Further reading
Ingestion path
At 5,000 replayed values/s, measure ingestion latency, error rate and ingestion-log backlog.
Evaluation path
Observe finalisation and alert backlogs per window. Agree a target with the team and operational context before deployment.
Traceability
Each final result records the measurement count, mean, TEMP-3 and processing time.

Terms in this step

Invariant
A domain rule that retries, errors and parallel processing must preserve.
Data gap
A visible range of missing or discarded measurements. It is neither a normal result nor an automatic all-clear.

Try it yourself

State the alert invariant for W-17 and name two value sequences that must not create an alert.

A hint for your attempt

The threshold is strictly greater than 30 °C; minimum scope and finality belong to the same rule.

Compare with a possible solution
Rule
Only W-17 = final with at least four distinct valid measurements and a mean > 30 °C may open AL-17. Counterexample: [31, 31, 31] °C contains only three measurements and produces no alert.
Limit value
The four final measurements [29, 30, 30, 31] °C give (29 + 30 + 30 + 31) ÷ 4 = 30 °C and create no alert. The comparison is strictly >.
Retry behaviour
A duplicate changes neither the measurement count nor the mean. Test: send sequence 4711 twice; W-17 and AL-17 remain unchanged.

Apply to your project

Which rule in your system needs a minimum data count, timing and a threshold together?

This rule determines the data volume, retention needs and replay peak to calculate in step 3.