OpenCode 2: keep the serving account's scoped windows and credits fresh

Merged
AN
17h ago
+632-82

Refs #864. Vault sweeps apply Insula's cached reading every tick (no extra Insula refresh or /usage call); local sweeps are due on the poll-only clock; header merges keep the poll's top-level checkedAt. Routing freshness still reads per-window clocks (regression: zero /usage on a header-fed serving account). Packed 2.16.4 and 2.2.7 accept the stored shapes.


Summary by cubic

Fixes #864: the serving account's model-scoped weekly windows and credits now refresh from Insula (vault) or the regular poll (local) while response headers keep arriving, so the sidebar no longer shows a growing "checked … ago" for it.

Key changes

  • Header merges retain the poll's clock instead of letting response headers advance the top-level checkedAt.
  • Vault sweeps apply a cached Insula reading each tick without an extra Insula refresh or /usage call.
  • The newest poll owns the complete scoped windows and credits list; older polls and late headers can't restore removed fields.
  • Routing freshness still reads per-window clocks, so a header-fed account doesn't trigger a usage GET.
  • Compatibility guards verify packed 2.16.4 and 2.2.7 accept the stored shapes.