feat(context): add offline shadow profile and local dev gate
Memind CI / Test, build, and release guards (push) Has been cancelled
Memind CI / Test, build, and release guards (push) Has been cancelled
Provide context-runtime-profile simulation for gateway shadow events, run-context-runtime-offline.mjs for zero-LLM verification, and a local dev guide for user-led shadow self-tests later. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
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);
|
||||
});
|
||||
Reference in New Issue
Block a user