mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-16 23:33:29 +00:00
perf(insights): regenerate texts only when the underlying data changed
A sha256 fingerprint of the compacted feature snapshot is stored beside every generated text; nightly, forced and ingest-triggered regeneration all skip the model call when the fingerprint matches and refresh the timestamp instead. Warms cover only the user's resolved locale and the blanket per-status eviction after a comprehensive generation is gone — a lazily-read second locale regenerates on its own miss path. The ingest debounce widens from thirty minutes to six hours and no longer deletes cache rows, the visit-triggered warm re-checks freshness at job start, backs off for an hour after a failure and is capped at two forced runs per user per day, and its dedup window now outlives the client poll horizon. An active day drops from hundreds of model calls to a handful tied to actual data change.
This commit is contained in:
1 parent
9fa4962314
commit
23f7c74c04
24 files changed
+1596
-411
No files matched your search
@@ -0,0 +1,15 @@
|
||||
-- v1.16.8 — content-hash gate for insight regeneration.
|
||||
--
|
||||
-- `insights_snapshot_hash` stores the SHA-256 fingerprint of the
|
||||
-- compacted feature snapshot the cached comprehensive insight was
|
||||
-- generated from. Nightly, forced, and lazy regenerations compare the
|
||||
-- fresh snapshot's hash against it and skip the provider call
|
||||
-- (refreshing only `insights_cached_at`) when nothing the prompt sees
|
||||
-- has changed.
|
||||
--
|
||||
-- `insights_warm_failed_at` records the last failed/timed-out forced
|
||||
-- warm of the comprehensive insight, so the forced path can back off
|
||||
-- for an hour instead of re-attempting a broken provider chain on
|
||||
-- every page-open. Additive + non-destructive.
|
||||
ALTER TABLE "users" ADD COLUMN "insights_snapshot_hash" TEXT;
|
||||
ALTER TABLE "users" ADD COLUMN "insights_warm_failed_at" TIMESTAMP(3);
|
||||
@@ -60,6 +60,17 @@ model User {
|
||||
insightsPrivacyMode String @default("aggregated") @map("insights_privacy_mode") // "aggregated" | "raw"
|
||||
insightsCachedAt DateTime? @map("insights_cached_at")
|
||||
insightsCachedText String? @map("insights_cached_text") // cached JSON output
|
||||
// v1.16.8 — SHA-256 fingerprint of the compacted feature snapshot the
|
||||
// cached comprehensive text was generated from. Nightly / forced / lazy
|
||||
// regenerations compare the fresh snapshot's hash against this and skip
|
||||
// the provider call (refreshing only `insightsCachedAt`) when nothing
|
||||
// the prompt sees has changed.
|
||||
insightsSnapshotHash String? @map("insights_snapshot_hash")
|
||||
// v1.16.8 — last time a forced full warm's comprehensive step failed or
|
||||
// timed out. The forced warm path backs off for an hour after a failure
|
||||
// so a persistently broken provider chain cannot be re-driven into a
|
||||
// full generation attempt by every page-open.
|
||||
insightsWarmFailedAt DateTime? @map("insights_warm_failed_at")
|
||||
// v1.4.36 W3 T3 — per-user AI Insights exclude-metrics list, mirrors
|
||||
// `coachPrefsJson.excludeMetrics`. The /api/insights/generate route
|
||||
// filters matching keys off `features` before JSON.stringify so the
|
||||
|
||||
Reference in new issue
Block a user