feat: harden orchestrator execution runtime

This commit is contained in:
john
2026-07-24 23:53:32 +08:00
parent 396bb78200
commit f6f2cd0933
55 changed files with 5122 additions and 194 deletions
+31 -5
View File
@@ -41,9 +41,10 @@ test('orchestrator config defaults to a disabled native-safe runtime', async ()
);
assert.equal(state.executors.every((executor) => executor.enabled === false), true);
assert.equal(
state.executors.every((executor) => executor.dispatchImplemented === false),
state.executors.every((executor) => executor.dispatchImplemented === true),
true,
);
assert.equal(state.config.executionEnabled, false);
});
test('orchestrator config normalizes unsafe values and keeps a workflow allowlist', () => {
@@ -94,7 +95,7 @@ test('orchestrator config persists versioned admin updates and selects canary us
assert.equal(native.reason, 'canary_not_selected');
});
test('orchestrator execution handoff remains hard-disabled when Active is requested', async () => {
test('orchestrator execution handoff remains disabled without both admin and environment gates', async () => {
const service = createOrchestratorAdminConfigService(createPool(), { env: {} });
await service.updateAdminConfig({
mode: 'active',
@@ -105,10 +106,11 @@ test('orchestrator execution handoff remains hard-disabled when Active is reques
assert.equal(runtime.runtime.plansLangGraph, true);
assert.equal(runtime.runtime.executesLangGraph, false);
assert.deepEqual(runtime.runtime.executionHandoff, {
implemented: false,
requested: true,
implemented: true,
requested: false,
enabled: false,
reason: 'phase3_dry_run_only',
reason: 'environment_execution_gate_disabled',
environmentGate: false,
});
const selected = await service.selectEngine({
@@ -121,6 +123,30 @@ test('orchestrator execution handoff remains hard-disabled when Active is reques
assert.equal(selected.dryRun, true);
});
test('orchestrator selects LangGraph only when admin and environment execution gates agree', async () => {
const service = createOrchestratorAdminConfigService(createPool(), {
env: { MEMIND_ORCHESTRATOR_EXECUTION_HANDOFF_ENABLED: '1' },
});
await service.updateAdminConfig({
mode: 'canary',
serviceUrl: 'http://127.0.0.1:8093',
executionEnabled: true,
userAllowlist: ['user-1'],
});
const runtime = await service.getRuntimeState();
assert.equal(runtime.runtime.executesLangGraph, true);
assert.equal(runtime.runtime.executionHandoff.environmentGate, true);
const selected = await service.selectEngine({
runId: 'run-1',
userId: 'user-1',
workflowName: 'code-run-v1',
});
assert.equal(selected.engine, 'langgraph');
assert.equal(selected.candidateEngine, 'langgraph');
assert.equal(selected.reason, 'user_allowlist');
assert.equal(selected.dryRun, false);
});
test('orchestrator keeps a Native primary as a non-dry-run Native selection', async () => {
const service = createOrchestratorAdminConfigService(createPool(), { env: {} });
await service.updateAdminConfig({