Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
test(doctor): the Postgres hot-check golden stamps the soak counters' day; regenerate the flag registry (#6712 wave)
garrytan58788c7b8674
diff --git a/src/core/cli-flag-registry.generated.ts b/src/core/cli-flag-registry.generated.tsindex e876cf7de3..4c98956c26 100644--- a/src/core/cli-flag-registry.generated.ts+++ b/src/core/cli-flag-registry.generated.ts@@ -74,7 +74,7 @@ export const CLI_FLAG_REGISTRY: Record<string, readonly string[]> = {'graph-query': ['--brain', '--depth', '--direction', '--help', '--hop', '--include-foreign', '--json', '--mcp-only', '--source', '--type'],'hook': ['--allow-unverified-remote', '--auto', '--brain', '--branch', '--cached', '--count', '--diff-filter', '--enable', '--end-of-options', '--env', '--get', '--harness', '--help', '--jq', '--json', '--limit', '--name-only', '--others', '--pat-file', '--path', '--porcelain', '--pure', '--quiet', '--remove', '--seat', '--session', '--show-current', '--show-toplevel', '--since', '--source', '--yes'],'import': ['--accept-pending', '--admin-intent', '--allow-empty', '--allow-noncanonical-root', '--apply', '--background', '--brain', '--cached', '--confirm-relocated-root', '--diff-filter', '--dim', '--embedding-dimensions', '--embedding-model', '--empty', '--exclude', '--exclude-standard', '--expected-epoch', '--expected-state', '--explain', '--follow', '--force', '--force-rechunk', '--format', '--fresh', '--help', '--include-gitignored', '--is-shallow-repository', '--json', '--log-noop', '--manifest', '--name-only', '--no-accept-pending', '--no-embed', '--no-embedding', '--no-gpg-sign', '--no-pull', '--no-renames', '--no-verify', '--only', '--others', '--path', '--probe', '--progress-interval', '--progress-json', '--quiet', '--self-transfer', '--show-toplevel', '--skip-failed', '--slugs', '--source', '--source-id', '--stale', '--status', '--supabase', '--timeout', '--to', '--url', '--verify', '--wait', '--workers'],- 'init': ['--access', '--acknowledge-managed', '--adopt', '--all', '--all-drifted', '--allow-create-db', '--allow-docker', '--apply', '--assign-corpus', '--audit', '--auto', '--auto-additive', '--background', '--bound-slug-prefixes', '--brain', '--break-lock', '--budget-ms', '--budget-usd', '--chat-model', '--check', '--clear-never-installed', '--confirm-relocated-root', '--conflicts', '--content-root', '--db-only', '--dest', '--detach', '--detail', '--dim', '--disable', '--drain', '--embedding-dimensions', '--embedding-model', '--enable', '--expand', '--expansion-model', '--expect', '--expect-remote', '--facts', '--fast', '--fix', '--force', '--force-retry', '--from-meetings', '--full', '--git', '--grant-types', '--group-by', '--harness', '--held', '--help', '--http', '--id', '--images', '--include-frontmatter', '--include-gitignored', '--issuer-url', '--json', '--keep', '--key', '--lanes', '--limit', '--list', '--local-postgres', '--markdown', '--max-usd', '--mcp-only', '--mcp-url', '--migrate-only', '--migration', '--model', '--no-autopilot-install', '--no-autostash', '--no-delegate', '--no-embed', '--no-embedding', '--no-expand', '--no-extract', '--no-git', '--no-lanes', '--no-llm', '--no-probe', '--no-pull', '--no-repair', '--no-schema-pack', '--non-interactive', '--oauth-client-id', '--oauth-client-secret', '--once', '--only', '--oversized', '--page', '--params', '--pat-file', '--path', '--pglite', '--phase', '--plan', '--prefer', '--prefer-postgres', '--preview', '--probe', '--profile', '--provenance', '--providers', '--pull', '--purge', '--push-only', '--query', '--question', '--quiet', '--rebase', '--reference-date', '--remediate', '--remove', '--repair-unknown-markers', '--reset', '--resolve', '--resume', '--retry-failed', '--save', '--schema-pack', '--scope', '--scopes', '--search-mode', '--section', '--self-transfer', '--semantic', '--show-toplevel', '--since', '--skip', '--skip-embed-check', '--skip-failed', '--slug', '--slugs', '--source', '--source-id', '--stale', '--state', '--status', '--supabase', '--surface', '--tier', '--timeout', '--to', '--token', '--touchpoint', '--url', '--url-env', '--user', '--version', '--wait', '--warn-only', '--workspace', '--yes'],+ 'init': ['--access', '--acknowledge-managed', '--adopt', '--all', '--all-drifted', '--allow-create-db', '--allow-docker', '--apply', '--assign-corpus', '--audit', '--auto', '--auto-additive', '--background', '--bound-slug-prefixes', '--brain', '--break-lock', '--budget-ms', '--budget-usd', '--chat-model', '--check', '--clear-never-installed', '--confirm-relocated-root', '--conflicts', '--content-root', '--db-only', '--dest', '--detach', '--detail', '--dim', '--disable', '--drain', '--embedding-dimensions', '--embedding-model', '--enable', '--expand', '--expansion-model', '--expect', '--expect-remote', '--facts', '--fast', '--fix', '--force', '--force-retry', '--from-meetings', '--full', '--git', '--grant-types', '--group-by', '--harness', '--held', '--help', '--http', '--id', '--images', '--include-frontmatter', '--include-gitignored', '--issuer-url', '--json', '--keep', '--key', '--lanes', '--limit', '--list', '--local-postgres', '--markdown', '--max-usd', '--mcp-only', '--mcp-url', '--migrate-only', '--migration', '--model', '--no-autopilot-install', '--no-autostash', '--no-delegate', '--no-embed', '--no-embedding', '--no-expand', '--no-extract', '--no-git', '--no-lanes', '--no-llm', '--no-probe', '--no-pull', '--no-repair', '--no-schema-pack', '--non-interactive', '--oauth-client-id', '--oauth-client-secret', '--once', '--only', '--oversized', '--page', '--params', '--pat-file', '--path', '--pglite', '--phase', '--plan', '--prefer', '--prefer-postgres', '--preview', '--probe', '--profile', '--provenance', '--providers', '--pull', '--purge', '--push-only', '--query', '--question', '--quiet', '--rebase', '--reference-date', '--remediate', '--remove', '--repair-unknown-markers', '--request', '--reset', '--resolve', '--resume', '--retry-failed', '--save', '--schema-pack', '--scope', '--scopes', '--search-mode', '--section', '--self-transfer', '--semantic', '--show-toplevel', '--since', '--skip', '--skip-embed-check', '--skip-failed', '--slug', '--slugs', '--source', '--source-id', '--stale', '--state', '--status', '--supabase', '--surface', '--tier', '--timeout', '--to', '--token', '--touchpoint', '--url', '--url-env', '--user', '--version', '--wait', '--warn-only', '--workspace', '--yes'],'integrations': ['--auto', '--brain', '--dry-run', '--help', '--json', '--overwrite', '--refresh', '--source', '--target'],'integrity': ['--accept-pending', '--auto', '--backend', '--background', '--brain', '--confidence', '--cost', '--dry-run', '--explain', '--follow', '--fresh', '--help', '--json', '--limit', '--no-accept-pending', '--probe', '--progress-interval', '--progress-json', '--quiet', '--review-lower', '--skip-bare-tweet', '--skip-urls', '--source', '--supabase', '--timeout', '--type', '--url', '--wait'],'jobs': ['--abbrev-ref', '--access', '--acknowledge-managed', '--add', '--aliases', '--all', '--allow-empty', '--allow-shell-jobs', '--allowed-operations', '--apply', '--asof', '--auto', '--background', '--backoff-delay', '--backoff-jitter', '--backoff-type', '--batch-size', '--bound-slug-prefixes', '--brain', '--break-lock', '--by-mention', '--cached', '--catch-up', '--check', '--cli-path', '--client', '--cluster-errors', '--concurrency', '--confidence', '--confirm-destructive', '--cost-estimate', '--date', '--dated-since', '--days', '--delay', '--detach', '--detail', '--diff-filter', '--dir', '--drain', '--dry-run', '--embedding-dimensions', '--embedding-model', '--empty', '--entities', '--exclude', '--exclude-standard', '--expect', '--explain', '--facts', '--federated-read', '--filters', '--fix', '--follow', '--force', '--force-break-lock', '--format', '--fresh', '--from-index', '--from-meetings', '--full', '--full-history', '--fuzzy', '--grammar-diagnostics', '--group', '--hard-deadline', '--health-interval', '--held', '--help', '--http', '--id', '--idempotency-key', '--ids', '--images', '--include-deleted', '--include-frontmatter', '--include-gitignored', '--include-hidden', '--include-null-signature', '--infer-dates', '--inject-bootstrap', '--inline', '--input', '--install', '--interval', '--is-ancestor', '--is-shallow-repository', '--job-id', '--job-isolation', '--json', '--kind', '--lanes', '--limit', '--lock-duration-ms', '--log-noop', '--markdown', '--max-age', '--max-attempts', '--max-cost', '--max-cost-usd', '--max-crashes', '--max-rss', '--max-sources', '--max-stalled', '--max-usd', '--max-waiting', '--mcp-only', '--min-context', '--missing-path', '--model', '--multimodal', '--name-only', '--ner', '--nice', '--no-auto-embed', '--no-autopilot-install', '--no-bulk', '--no-confirm', '--no-delegate', '--no-embed', '--no-extract', '--no-gpg-sign', '--no-hard-deadline', '--no-inject', '--no-lanes', '--no-llm', '--no-pull', '--no-renames', '--no-repair', '--no-schema-pack', '--no-verify', '--no-worker', '--non-interactive', '--now', '--older-than', '--once', '--only', '--order', '--others', '--output', '--override-disabled', '--oversized', '--pace', '--pace-max-concurrency', '--pack', '--page', '--parallel', '--params', '--path', '--pause', '--phase', '--pid-file', '--prefer', '--priority', '--probe', '--prune-orphans', '--purge', '--queue', '--queue-only', '--quiet', '--reason', '--rebuild', '--recent', '--redact-secrets', '--reenrich-after', '--refresh-ms', '--refresh-operations', '--repo', '--reset-checkpoint', '--resume', '--retry-failed', '--retry-held', '--review-lower', '--row', '--scopes', '--segment-limit', '--select', '--serial', '--session', '--show-toplevel', '--sigkill-rescue', '--since', '--skip-bare-tweet', '--skip-failed', '--skip-urls', '--sleep', '--slug', '--slugs', '--source', '--source-id', '--sources', '--src-subpath', '--stale', '--status', '--strategy', '--surface', '--swap-only', '--target', '--thin', '--thin-threshold', '--timeout', '--timeout-ms', '--to', '--trust', '--type', '--types', '--uninstall', '--updated-after', '--url', '--user', '--vectors', '--verbose', '--verify', '--version', '--watch', '--wedge-rescue', '--workers', '--working-tree', '--yes'],diff --git a/test/doctor-hot-checks-sync-day.test.ts b/test/doctor-hot-checks-sync-day.test.tsindex 11fca77f39..332b1b6454 100644--- a/test/doctor-hot-checks-sync-day.test.ts+++ b/test/doctor-hot-checks-sync-day.test.ts@@ -40,6 +40,15 @@ 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 counters day is stamped too, inside the run and nowhere else', () => {+ 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]);+ const acrossMidnight = runOn('2026-11-20');+ for (const c of acrossMidnight.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(acrossMidnight, '2026-11-20', ['2026-11-20', '2026-11-20'], '2026-11-21')).toEqual(golden);+ expect(() => stampSyncDay(acrossMidnight, '2026-11-20', ['2026-11-20', '2026-11-20'])).toThrow('outside the fixture run');+ });+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/e2e/doctor-hot-checks-golden.test.ts b/test/e2e/doctor-hot-checks-golden.test.tsindex 9986bd84e3..b56732803c 100644--- a/test/e2e/doctor-hot-checks-golden.test.ts+++ b/test/e2e/doctor-hot-checks-golden.test.ts@@ -80,7 +80,8 @@ async function capture(adminUrl: string): Promise<PgCaptures> {const stamped = await db.unsafe(`SELECT DISTINCT completed_keys->0->>'day' AS day FROM op_checkpoints WHERE op = $1`, [FENCE_TREND_OP]).finally(() => db.end());expect(stamped.length).toBe(1);const day = stamped[0]!.day as string;- for (const run of [first, second]) run.json = stampSyncDay(run.json, day, syncDays);+ const runEnd = new Date().toISOString().slice(0, 10);+ for (const run of [first, second]) run.json = stampSyncDay(run.json, day, syncDays, runEnd);return { first, second, url, name };}diff --git a/test/fixtures/goldens/README.md b/test/fixtures/goldens/README.mdindex 8b9aea529e..de8e713afa 100644--- a/test/fixtures/goldens/README.md+++ b/test/fixtures/goldens/README.md@@ -121,7 +121,9 @@ reproduce byte for byte. Each file is written by `test/helpers/golden.ts` as`test/helpers/fixed-clock-preload.ts`); Postgres, whose server stamps its own times,stores `fence_integrity.details.trend[].by_day[].day` as `<sync-day>` only after`stampSyncDay` checks it equals the day the fixture's sync stamped (one of the days- read around the sync). Regenerating writes the marker again.+ read around the sync). The soak counters' `sync_soak_counters.details.by_day[].day`+ is stored the same way, after checking it falls between the day before the sync and+ the day read after the last doctor run. Regenerating writes the marker again.## Setup migration ledgerdiff --git a/test/fixtures/goldens/doctor/hot-checks-postgres-json.json b/test/fixtures/goldens/doctor/hot-checks-postgres-json.jsonindex 8565982aaf..a4981991cd 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}],@@ -4602,7 +4602,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..eaf474ea50 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 soak+ * counters (`sync_soak_counters.details.by_day[].day`) are stamped by the+ * gbrain process's own clock while doctor runs, so each must fall between the+ * day before the sync and `runEnd`, the day read after the last doctor run.+ * 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 {+export function stampSyncDay(report: unknown, stamped: string, syncDays: readonly [string, string], runEnd = syncDays[1]): 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 (entry.day < syncDays[0] || entry.day > runEnd) throw new Error(`sync_soak_counters day ${entry.day} is outside the fixture run (${syncDays[0]} to ${runEnd})`);+ entry.day = SYNC_DAY;+ }+ }return copy;}