Journal / Workbench
Built to keep running
- Author
- Published
- Reading
- 4 min
- Written in
- Finn, Mercedes Sprinter
How Weft keeps your van working through updates, power cuts and dead zones, and why it tells you when it doesn't know something.
A van is a hard place for a computer. The power can drop at any moment, the internet comes and goes, and the nearest help might be days away. So Weft has to keep working without anyone looking after it, and we've designed every part of it with that in mind.
Everything runs in the van
Weft Core runs your van by itself. Automations, history, camera recordings and the decision to send an alert all happen on the Core. At the campsite, your phone finds the Core on the van's Wi-Fi and talks to it directly.
When the signal drops, the van keeps doing everything it did before. The internet is only needed to reach you: remote access from somewhere else, alerts arriving on your phone, the weather forecast, updates and backups.
Two copies of the system
Weft Core has two complete copies of its software. While you use one, an update is written to the other, so the system you're running is never touched.
Switching between them is a single small write to the storage, made so that it either happens completely or not at all. If the power cuts out halfway through an update, the Core starts up on the copy that was working. We test this on a simulated van by cutting the power at around ninety different points of an update and of a rollback.
Every update has to prove itself
After an update, the Core starts the new version on trial. For the first few minutes it checks itself, three times, a minute apart:
- that it started the right copy, with the system files locked and your data in place;
- that Weft is running and answers with the same identity and setup as before;
- that every service your van uses has started and stays up;
- that every sensor that was reporting before the update is reporting again;
- that it can still install the next update.
Only when all of that passes does it keep the new version. If anything fails, or the checks don't finish in time, it restarts on the previous one. A missing internet connection doesn't count as a failure, because on the road that's normal.
One signed build for every van
Every version of Weft is built once, signed, and sent to every van as the same file. The build is reproducible: building the same version again gives exactly the same bytes. The van checks the signature before it installs anything and refuses what we didn't sign.
Before a version is signed, our build system takes the previous release, updates it the way a van would, and starts it up. New versions go to a small group of vans first and only reach everyone after a day without problems.
Updates wait until you're parked
The Core downloads updates whenever it can, while you drive too. It only restarts when the van is parked and nothing is moving, by default between three and five in the morning. You can also have it ask you first.
An update that gets interrupted, by a power cut or a dead battery, carries on where it stopped the next time the Core starts.
The same system after every restart
The system files are read-only. Your settings, history and recordings live in a separate place, and anything temporary is cleared at every restart. So the Core you start tomorrow is exactly the one we built and tested, plus your data.
A hardware watchdog restarts the Core if it ever stops responding, and each part of Weft restarts on its own if it stops.
Your history is written by one part of Weft only, in small steps, so a sudden power cut leaves a short gap and the rest intact. Raw readings are kept for 30 days, five-minute summaries for a year and daily summaries for good.
Unknown means unknown
Reliability is also about what Weft shows you. When the Core can't read a sensor, the app says it doesn't know. It never fills in a zero or an "off". If a device goes quiet, Weft keeps its last value for a few minutes, marked as old, then shows it as unavailable. A door sensor that hasn't reported in three hours shows as unknown, because a wrong "closed" is worse than an honest "don't know".
Some devices can't report back at all, like a roof fan that only takes commands. Weft shows what it last told them to do, and marks it as unconfirmed.
Nightly backups
Every night the Core encrypts a backup of itself and sends it off the van, so your setup can be restored onto a new Core if it ever needs replacing. How that backup is protected is in What stays in the van.