The Zero That Means Forever: Stale Sensor Holds in Autonomous Upkeep Agents
A maintenance agent that keeps actuating on a frozen sensor reading is more dangerous than one that stops. The usual cause is not a code bug. It is a staleness setting of zero that a reviewer reads as no tolerance and the runtime reads as never stale. Your dashboards stay green the whole time, because the gateway keeps republishing the cached value with a fresh timestamp.
Why review never catches it
The diff looks harmless: `stale_after: 0` in a sensor binding, often copied from a template where someone wanted strict freshness. Many field gateways and polling libraries treat zero as the sentinel for disabling the check, so when a BACnet or Modbus device stops answering, the driver holds the last good value forever and keeps exporting it. Upstream, the time series database sees a regular sample arriving at a healthy interval, so its own staleness markers never fire and no gap shows up on any panel. The agent's planner gets a temperature, pressure or vibration figure that looks plausible, checks it against its policy, and keeps issuing setpoint changes or work orders against a plant state that stopped existing an hour ago. Nothing in the YAML is invalid, the schema accepts an integer, and the reviewer has no way to see the semantics of zero without reading driver source. That is why the same incident comes back with a new sensor name every quarter.
Detect it today
Run `changes(facility_sensor_value{kind="analog"}[15m]) == 0 and on (zone) rate(agent_actuation_total[15m]) > 0` against your Prometheus or compatible store. It returns every analog channel whose value has not moved in fifteen minutes while the agent responsible for that zone is still actuating. Real analog signals from thermistors, flow meters or accelerometers carry noise in the last digit, so a perfectly flat line for that long almost always means a cached hold, not a stable plant. Leave discrete channels like door contacts and breaker states out of the selector, since they are legitimately constant. On a first run across a mixed estate, expect a handful of hits per few hundred channels (an estimate from typical retrofit sites), and expect most of them to trace back to a zero or missing staleness bound.
What keeps the loop safe when a sensor dies
Authority to actuate has to expire with input freshness, so set `stale_after` in seconds, for example 90 s for a chilled water loop, make the schema reject zero and absent values outright, and have the agent drop to a conservative, locally enforced setpoint the moment any input it depends on crosses that bound. This is the same principle that functional safety standards in the IEC 61508 family apply to control systems: losing a signal must move the system toward a known safe state, not leave the last decision running. The trade-off is nuisance degradation, because a flaky gateway will now push zones into fallback more often, and operators will push back once comfort or throughput takes a hit. Treat that friction as data. A zone that keeps falling back is telling you where the sensor network needs redundancy, a second probe or a watchdog on the gateway itself.
The decision rule: set every staleness bound shorter than the time the controlled equipment takes to drift out of its safe band unattended, and when you cannot name that drift time, you are not ready to let the agent actuate that equipment.
Technical FAQ: Why not rely on the time series database's own staleness handling instead of a per binding setting?
Because the database only knows whether samples arrive, not whether they are new. If the gateway republishes a held value, every ingestion layer check passes, so freshness has to be enforced at the source binding and verified downstream with a flatline query like the one above.