import test from 'node:test'; import assert from 'node:assert/strict'; import { readFileSync } from 'node:fs'; import { loadConfig } from '../src/lib/config.mjs'; const ENV_KEYS = [ 'HISTORY_WRITER_DERIVED_REFRESH_MAX_EVENT_AGE_MS', 'INTENT_REQUEST_INVENTORY_MAX_AGE_MS', ]; function withCleanEnv(fn) { const previous = Object.fromEntries(ENV_KEYS.map((key) => [key, process.env[key]])); for (const key of ENV_KEYS) delete process.env[key]; try { return fn(); } finally { for (const [key, value] of Object.entries(previous)) { if (value == null) delete process.env[key]; else process.env[key] = value; } } } test('history writer derived refresh replay cutoff keeps the approved default', () => withCleanEnv(() => { const config = loadConfig({ envPath: '/tmp/unrip-no-such-env-file' }); assert.equal(config.historyWriterDerivedRefreshMaxEventAgeMs, 30000); assert.equal(config.historyWriterDerivedRefreshMaxEventAgeMs, config.intentRequestInventoryMaxAgeMs); })); test('legacy request freshness env no longer ships in kubernetes config', () => { const manifest = readFileSync(new URL('../deploy/k8s/base/unrip.yaml', import.meta.url), 'utf8'); assert.match(manifest, /HISTORY_WRITER_DERIVED_REFRESH_MAX_EVENT_AGE_MS: "30000"/); assert.doesNotMatch(manifest, /INTENT_REQUEST_INVENTORY_MAX_AGE_MS/); });