Repository navigation
0.1.37
Cuts the database query load of an idle vault by roughly thirty times.
The problem
Query usage was approaching the free-tier ceiling without the vault being especially busy, because the cost scaled with devices × uptime rather than with anything you actually did.
Every authenticated request spent two queries before doing any work — one to load the device, one to check vault membership. The idle sync loop made two such requests every interval, a change-feed read and an ack. So a device sitting there doing nothing cost six queries every 30 seconds, about 17,000 a day, each.
What changed
The device and membership checks are now one query. They were two round trips asking about the same request. Kept as a separate helper rather than folded into the shared membership check, because the recovery endpoints deliberately run without an active device and would have broken.
Acks are only sent when the cursor actually moved. An idle vault was re-sending the same sequence number every interval, forever, and each one is an authenticated write.
Polling backs off when idle. After a couple of quiet minutes the interval eases from 30 seconds out to 5, and snaps straight back on any local edit. Explicit triggers — startup, attaching a vault, resuming a paused file — bypass the backoff entirely, so nothing you do ever waits on it.
| before | after | |
|---|---|---|
| idle queries per device per day | ~17,000 | under 600 |
Active use is unchanged: edits still push on the next cycle, and a vault being worked in never slows down. The only thing that gets slower is noticing a remote change to a vault that has been untouched for several minutes.
Requires the matching backend deploy, which is already live.
Also adds docs/architecture.md — why the system is built the way it is, the tradeoffs, and the production failures that shaped it.