Skip to main content

Module startup

Module startup 

Source
Expand description

Fast-start gate that amortises first-command checks across the CLI.

Every difflore invocation used to pay the cost of:

  • opening the SQLite pool + 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§

StartupStatus
Serialized as ~/.difflore/startup-cache.json. Every field except version and migrations_applied_at is 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 force is 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.