Expand description
Fast-start gate that amortises first-command checks across the CLI.
Every difflore invocation used to pay the cost of:
- opening the
SQLitepool + running migrations - reading provider config (auth check probe)
- (if logged in) pinging the cloud for reachability
On an interactive shell this is ~200–600 ms wasted per command when
nothing has actually changed. ensure_ready keeps a tiny JSON file
(~/.difflore/startup-cache.json) with the last-known-good timestamp
for each check and short-circuits when all timestamps are fresh.
TTL is deliberately short (5 min) so genuine outages surface within a few invocations rather than being masked for the whole session.
Structs§
- Startup
Status - Serialized as
~/.difflore/startup-cache.json. Every field exceptversionandmigrations_applied_atis optional so the struct can round-trip cleanly across future schema additions.
Constants§
- STARTUP_
TTL_ MINUTES - Five minutes — balances “skip the probe on the next N commands after a fresh one” (common case) with “surface real drift within seconds” (when the user just logged out of the cloud, swapped provider keys, etc.).
Functions§
- ensure_
ready - Gate every CLI command goes through on entry. When the cache is
fresh and
forceis false, returns the cached status without touching the filesystem beyond the single read. When any probe is stale, runs the full check battery and updates the cache.