System Design Atlas

Sensor monitoring with late measurements

05 / 10Worked example

Data and states

What facts must be able to explain a final result?

M-17 records what D-17 sent with BOOT-4 and sequence 4711. W-17 aggregates measurements over time. AL-17 references a final window and TEMP-3. Each object retains its own lifecycle.

Starting point Step 4 separated acceptance, processing and acknowledgement in the contracts.

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.

Connect devices, raw events, windows and alerts

D-17 · Raw events, windows and alerts have separate lifecycles

Device D-171 device → 0..n boot sessions
BOOT-41 session → 0..n raw events; unique sequence numbers
M-17 Raw Eventaccepted · Measurement time · Receive time · Key
BOOT-4 → M-17: Origin of the measurement
Window W-17open → provisional → final
M-17 → W-17: exactly one time window; W-17 contains 0..n usable raw events
Alert AL-17open → acknowledged → resolved
AL-17 → W-17: a triggering final window; later windows complement the same open episode
W-17: [12:00, 12:01) UTC. provisional at 12:01, final no earlier than 12:03. Raw values projected at or after the cutoff are marked latent, including internal processing delays. Resolution after acknowledgement requires a newer final window with ≥ 4 distinct valid measurements and a mean ≤ 30 °C.
  • Domain relationship
  • Stored data
  • Device

W-17 belongs to a device and time range; it may contain values from multiple boot sessions. AL-17 references the triggering final window and TEMP-3.

Cardinalities and states make visible why a later raw value does not overwrite a final result.

Permitted state transitions

EntityTransitionsProtection rule
Window W-17open → provisional → finalopen until 12:01:00 UTC, then provisional; final from 12:03:00 UTC after atomic finalisation. Each value belongs to exactly one UTC minute window [start, end).
Alert AL-17open → acknowledged → resolvedAcknowledgement confirms awareness. resolved requires acknowledged and a newer final window containing ≥ 4 distinct valid values with a mean ≤ 30 °C.
Raw event M-17accepted; evaluation status usable or late. Conflicts are quarantined separately.A duplicate refers to M-17. late/quarantine does not change a final window.

Window W-17

Transitions
open → provisional → final
Protection rule
open until 12:01:00 UTC, then provisional; final from 12:03:00 UTC after atomic finalisation. Each value belongs to exactly one UTC minute window [start, end).

Alert AL-17

Transitions
open → acknowledged → resolved
Protection rule
Acknowledgement confirms awareness. resolved requires acknowledged and a newer final window containing ≥ 4 distinct valid values with a mean ≤ 30 °C.

Raw event M-17

Transitions
accepted; evaluation status usable or late. Conflicts are quarantined separately.
Protection rule
A duplicate refers to M-17. late/quarantine does not change a final window.

Consistency at the commit point

Input
Raw value, deduplication entry and acceptance status take effect together. Only then does the confirmation follow.
Projector
The window state, processed event key, alert and checkpoint in the result store update in one transaction. A failure before commit rolls everything back; after commit, a restart sees the existing effect. Finalisation is unique per (tenant, device, window, rule version). An open or acknowledged alert retains its identity; further hot windows add to it. A new episode can begin only after resolved.
Rule version
The final window records TEMP-3. A later rule change does not silently reinterpret past results.

Time rule and delayed processing

A common deadline
W-17 covers [12:00:00, 12:01:00) UTC. It becomes provisional at 12:01:00 and final no earlier than 12:03:00. Only valid raw values incorporated into the window before 12:03:00 count. Messages and timers are serialised per device; at the cutoff, finalisation takes precedence. Timer delay does not extend the acceptance period.
Keep backlogs visible
A value received at 12:02:59 but projected at 12:03:01 remains a raw measurement marked late with processing backlog as the reason. Reception time, projection time and the stored classification explain the difference. Replay preserves the final count, mean and late classification; it does not reassess historical windows using the current clock.
Compare watermarks
A watermark estimates event-time progress from the data stream. Slow or silent inputs can hold it back. Our timer follows the platform clock and finalises independently, so an internal backlog can reduce completeness. Both rules require explicit treatment of late values. Events have no global ordering.

Terms in this step

Event time
The time a device took a measurement, stored separately from reception and processing times.
Finalisation
An explicit completion point after a defined waiting period. This is a domain design decision, not a claim of perfect knowledge of real-world timing.

Try it yourself

Draw M-17, W-17 and AL-17 with one state each. Reason why late does not trigger a retroactive AL-17 change.

A hint for your attempt

In this timer model, late means the raw value was projected at or after the fixed cutoff. Reception time and internal backlog explain the cause; the final result is preserved.

Compare with a possible solution
Relationship
M-17 is accepted and usable, W-17 is final, and AL-17 is open. Distinct raw events form W-17; AL-17 references this triggering window and TEMP-3. Test: the four values [29, 30, 31, 32] °C give 122 ÷ 4 = 30.5 °C and create an alert.
Late
A late raw measurement is stored and marked, but excluded from the final calculation. Test: the mean and alert state remain unchanged.
Resolution
AL-17 passes through open → acknowledged → resolved. The newer final window must contain at least four distinct valid measurements with a mean ≤ 30 °C. Test: a data gap, an older window or acknowledgement alone keeps the alert open.

Apply to your project

Which data is authoritative in your system, which is derived and which merely records workflow status?

From the states, step 6 derives runtime processes and their module boundaries.