fix(daily): judge the briefing's day by when its text was written

The check that keeps an earlier day's briefing off the Today surfaces
read the cache row's insightsCachedAt. Every warm moves that column,
including the unchanged-hash short-circuit that keeps yesterday's text
and only refreshes the stamp, so text written the day before passed as
today's after the nightly warm.

The cached payload now carries briefingGeneratedAt, written only where
new text is written: a full generation in the warm and in the
on-demand route, and the daily paragraph re-roll. The stamp refresh
leaves it untouched. briefingForToday reads that moment, and a payload
without it counts as not from today, so the hero falls back to its own
lead until the next generation.
This commit is contained in:
Marc-André Bombeck committed 2026-10-05 21:57:49 +02:00
1 parent 14a2931a99
commit 491d542f58
10 files changed
+193 -14

No files matched your search

+4 -1
View File
@@ -11,6 +11,7 @@
* write breaks that convergence — the settling seam tests pin the client
* half, this comment is the server half of the contract.
*/
import { withBriefingGeneratedAt } from "@/lib/insights/briefing-generated-at";
import { prisma } from "@/lib/db";
import { auditLog } from "@/lib/auth/audit";
import {
@@ -1051,7 +1052,9 @@ export const POST = apiHandler((request: NextRequest) =>
},
data: {
insightsCachedAt: new Date(),
insightsCachedText: JSON.stringify(insights),
insightsCachedText: JSON.stringify(
withBriefingGeneratedAt(insights, new Date()),
),
insightsCachedLocale: locale,
insightsSnapshotHash: hashInsightSnapshot({
features: compactFeatures,