import assert from 'node:assert/strict'; import test from 'node:test'; import { CONTEXT_RUNTIME_SHADOW_ENV, describeContextRuntimeProfile, isContextRuntimeShadowProfile, simulateContextRuntimeShadowEvents, validateContextRuntimeShadowEvents, } from './context-runtime-profile.mjs'; test('describeContextRuntimeProfile defaults to off', () => { const profile = describeContextRuntimeProfile({}); assert.equal(profile.headroom, 'off'); assert.equal(profile.contextBudget, 'off'); assert.equal(profile.recallFusion, 'off'); }); test('isContextRuntimeShadowProfile accepts all-shadow bundle', () => { assert.equal(isContextRuntimeShadowProfile(CONTEXT_RUNTIME_SHADOW_ENV), true); assert.equal(isContextRuntimeShadowProfile({ ...CONTEXT_RUNTIME_SHADOW_ENV, MEMIND_HEADROOM_MODE: 'active', }), false); }); test('simulateContextRuntimeShadowEvents emits gateway-shaped payloads', () => { const simulation = simulateContextRuntimeShadowEvents(); assert.ok(simulation.events.headroom_context_observed); assert.ok(simulation.events.context_budget_resolved); assert.ok(simulation.events.recall_fusion_resolved); assert.equal(simulation.events.headroom_context_observed.mode, 'shadow'); assert.equal(simulation.events.context_budget_resolved.mode, 'shadow'); const validation = validateContextRuntimeShadowEvents(simulation); assert.equal(validation.ok, true, validation.issues?.join('; ')); }); test('simulateContextRuntimeShadowEvents respects off modes', () => { const simulation = simulateContextRuntimeShadowEvents({ env: { MEMIND_HEADROOM_MODE: 'off', MEMIND_CONTEXT_BUDGET_MODE: 'off', MEMIND_RECALL_FUSION_MODE: 'off' }, }); assert.equal(simulation.events.headroom_context_observed, undefined); assert.equal(simulation.events.context_budget_resolved, undefined); assert.equal(simulation.events.recall_fusion_resolved, undefined); });