mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-19 08:12:52 +00:00
The status tier funnels every generation through runStatusCompletion, which reserves against the day's ledger before egress and reconciles after. The comprehensive briefing did not: the shared generator and the on-demand POST /api/insights/generate route both called the provider chain directly, so none of that spend reached coach_usage and no daily ceiling applied to it. Route every briefing provider call — first pass, JSON-shape retry, grounding-correction retry, and the daily paragraph re-roll — through one chokepoint that reuses reserveBudget / reconcileSpend and resolveDailyCap. The reservation lands after the consent gate, so a consent-blocked user is never charged, and a failed or timed-out call is refunded in full. Over-cap is a typed skipped outcome for the off-request generator (no upstream fault to retry against, so no failure marker and no retry enqueue) and a 429 for the on-demand route.