INNER CODE UNIT · TypeScript
healthSentinel
lidge-jun/opencodex · src/cli/index.ts:631
let healthSentinel: ReturnType<typeof startServiceHealthSentinel> = null; // opt-in #6671, started once ready
// No pre-emptive snapshot here. `injectCodexConfig` journals the exact bytes it
// is about to transform; snapshotting earlier only captured a baseline that could
// already be stale by the time injection ran (#477).
// Background proactive token refresh. No-op unless config.tokenGuardian.enabled; timer is unref'd
// so it never keeps the process alive on its own. Stopped in syncCleanup so no refresh fires mid-drain.
const guardian = startTokenGuardian();
// Design B upgrade path: keep retrying the one-time opencodex→openai history migration in the
// background — the first `ocx start` after an update usually races the Codex app's DB lock.
// Loopback-only (legacy mode still forward-tags) and respects syncResumeHistory opt-out.
let historyGuardian: ReturnType<typeof startHistoryMigrationGuardian> | undefined;
let routingHealer: { stop(): void } | undefined; // routing-healer.ts; stopped first in syncCleanup
let catalogHealer: { stop(): void } | undefined;
let cleaned = false;
let cleanupSucceeded = true;
const syncCleanup = () => {