Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
test(doctor): Postgres hot-check golden stores the fixture sync's soak-counter day as <sync-day>
garrytan12ba239873d2
diff --git a/test/doctor-hot-checks-sync-day.test.ts b/test/doctor-hot-checks-sync-day.test.tsindex 11fca77f39..04dba9c4c4 100644--- a/test/doctor-hot-checks-sync-day.test.ts+++ b/test/doctor-hot-checks-sync-day.test.ts@@ -40,6 +40,16 @@ describe('Postgres hot-check golden: the fence trend day', () => {expect(() => stampSyncDay(runOn('2026-11-19'), '2026-11-20', ['2026-11-20', '2026-11-20'])).toThrow('not the day the fixture sync stamped');});+ test('the soak counter day the fixture sync stamped is stored as the sync day, and only a day around the sync passes', () => {+ const soakDays = (report: Report) => report.checks.filter(c => c.name === 'sync_soak_counters').flatMap(c => (c.details as { by_day?: Array<{ day: string }> } | undefined)?.by_day ?? []).map(d => d.day);+ expect(soakDays(golden)).toEqual([SYNC_DAY]);+ expect(soakDays(stampSyncDay(runOn('2026-11-20'), '2026-11-20', ['2026-11-20', '2026-11-20']) as Report)).toEqual([SYNC_DAY]);+ const soakNextDay = JSON.parse(JSON.stringify(runOn('2026-11-20'))) as Report;+ for (const c of soakNextDay.checks) if (c.name === 'sync_soak_counters') for (const d of (c.details as { by_day: Array<{ day: string }> }).by_day) d.day = '2026-11-21';+ expect(stampSyncDay(soakNextDay, '2026-11-20', ['2026-11-20', '2026-11-21'])).toEqual(golden);+ expect(() => stampSyncDay(soakNextDay, '2026-11-20', ['2026-11-20', '2026-11-20'])).toThrow('sync_soak_counters day 2026-11-21');+ });+test('only the trend day is replaced: other date-like drift still differs', () => {const drifted = runOn('2026-11-20');const other = drifted.checks.find(c => c.name !== 'fence_integrity' && typeof c.message === 'string')!;diff --git a/test/fixtures/goldens/doctor/hot-checks-postgres-json.json b/test/fixtures/goldens/doctor/hot-checks-postgres-json.jsonindex d5ff254153..1e994c4ac5 100644--- a/test/fixtures/goldens/doctor/hot-checks-postgres-json.json+++ b/test/fixtures/goldens/doctor/hot-checks-postgres-json.json@@ -677,7 +677,7 @@"by_day": [{"content_decisions": 0,- "day": "2026-10-16",+ "day": "<sync-day>","interventions": 1}],@@ -4650,7 +4650,7 @@"by_day": [{"content_decisions": 0,- "day": "2026-10-16",+ "day": "<sync-day>","interventions": 1}],diff --git a/test/helpers/doctor-hot-checks-fixture.ts b/test/helpers/doctor-hot-checks-fixture.tsindex 3aab6be94d..786d58c400 100644--- a/test/helpers/doctor-hot-checks-fixture.ts+++ b/test/helpers/doctor-hot-checks-fixture.ts@@ -173,12 +173,15 @@ export const SYNC_DAY = '<sync-day>';* exactly that field, and only after checking it: `stamped` is the day read* back from the trend row, it must be one of the days read just before and* after the sync (two only when the sync crossed midnight UTC), and every- * `fence_integrity.details.trend[].by_day[].day` must equal it. Any other- * field, date-like or not, is left for the golden to compare.+ * `fence_integrity.details.trend[].by_day[].day` must equal it. The fixture+ * sync's soak counter row (`sync_soak_counters.details.by_day[].day`) is+ * stamped by the sync process's own clock, so it must be one of the two days+ * read around the sync and is stored as the same symbol. Any other field,+ * date-like or not, is left for the golden to compare.*/export function stampSyncDay(report: unknown, stamped: string, syncDays: readonly [string, string]): unknown {if (!syncDays.includes(stamped)) throw new Error(`fence trend day ${stamped} is neither the day before (${syncDays[0]}) nor after (${syncDays[1]}) the fixture sync`);- const copy = structuredClone(report) as { checks?: Array<{ name: string; details?: { trend?: Array<{ by_day?: Array<{ day: string }> }> } }> };+ const copy = structuredClone(report) as { checks?: Array<{ name: string; details?: { trend?: Array<{ by_day?: Array<{ day: string }> }>; by_day?: Array<{ day: string }> } }> };for (const check of copy.checks ?? []) {if (check.name !== 'fence_integrity') continue;for (const trend of check.details?.trend ?? []) for (const entry of trend.by_day ?? []) {@@ -186,6 +189,13 @@ export function stampSyncDay(report: unknown, stamped: string, syncDays: readonlentry.day = SYNC_DAY;}}+ for (const check of copy.checks ?? []) {+ if (check.name !== 'sync_soak_counters') continue;+ for (const entry of check.details?.by_day ?? []) {+ if (!syncDays.includes(entry.day)) throw new Error(`sync_soak_counters day ${entry.day} is neither the day before (${syncDays[0]}) nor after (${syncDays[1]}) the fixture sync`);+ entry.day = SYNC_DAY;+ }+ }return copy;}