fix(correlations): date the earlier-engine note from the instance's first new run

The note for records whose findings predate the seasonally adjusted
engine compared against a fixed calendar date, so findings an instance
kept writing under the earlier engine until its deploy did not count.
The first discovery sync of the new engine now stamps
AppSettings.correlationSeasonalEngineSince before it writes; without a
stamp every stored discovery pattern counts as an earlier finding.

A restore from a portable export reset each pattern's createdAt to the
restore day and dropped the note for good. createdAt now rides every
export, and a file without it falls back to lastComputedAt.
This commit is contained in:
Marc-André Bombeck committed 2026-10-09 10:44:17 +02:00
1 parent 587ea35d34
commit 0ea8d929d2
5 files changed
+250 -31

No files matched your search

+11 -4
View File
@@ -506,10 +506,15 @@ export async function buildProfileBackupSection(
...(disasterRecovery
? {
id: pattern.id,
createdAt: pattern.createdAt.toISOString(),
updatedAt: pattern.updatedAt.toISOString(),
}
: {}),
// Carried in every export, not only DR: when a finding was first made
// is part of what it means. The correlation surface reads it to tell a
// finding of the earlier engine from one of the seasonally adjusted
// engine, and a restore that reset it to the restore day would drop
// that note for good.
createdAt: pattern.createdAt.toISOString(),
canonicalKey: pattern.canonicalKey,
family: pattern.family,
factorKey: pattern.factorKey,
@@ -945,9 +950,11 @@ export async function restoreProfileData(
dismissedEvidenceHash: pattern.dismissedEvidenceHash,
dismissedEffectSize: pattern.dismissedEffectSize,
dismissedSampleSize: pattern.dismissedSampleSize,
...(pattern.createdAt
? { createdAt: new Date(pattern.createdAt) }
: {}),
// A file from before portable exports carried `createdAt` falls back
// to the last computation, the latest instant the finding certainly
// existed: still earlier than this restore, which is what keeps a
// finding of the earlier engine counted as one.
createdAt: new Date(pattern.createdAt ?? pattern.lastComputedAt),
...(pattern.updatedAt
? { updatedAt: new Date(pattern.updatedAt) }
: {}),