mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-11 05:42:19 +00:00
The comprehensive briefing's bounded feature read (extractFeatures) was paid more than once where it should not be: the on-demand route and the shared generator each run a downgrade ladder that re-reads with identical arguments, and a nightly warm has no shared object across consumers in a single tick. Add a request/run-scoped feature cache: withFeatureCacheScope opens an AsyncLocalStorage store, getCachedFeatures memoises the first compute per (userId, day, includeRaw, sinceDays), gated on a cheap salient-input fingerprint so a mid-scope ingest recomputes and a probe failure fails safe. Outside a scope it is a pure passthrough. Wired into the comprehensive generator, the on-demand POST handler, and the nightly per-candidate loop + forceWarmUser. Coach keeps its own snapshot.