feat: harden orchestrator execution runtime
This commit is contained in:
@@ -41,7 +41,7 @@ test('LangGraph runtime checkpoints a deterministic observe-only code workflow',
|
||||
id: 'run-shadow-1:executor-preview',
|
||||
executor: 'goosed',
|
||||
status: 'blocked',
|
||||
reason: 'executor_dispatch_not_implemented',
|
||||
reason: 'executor_execution_disabled',
|
||||
durable: false,
|
||||
});
|
||||
assert.equal(
|
||||
@@ -153,3 +153,60 @@ test('LangGraph runtime derives a bounded opaque Executor Job id for long run id
|
||||
assert.ok(state.plan.executorJob.id.length <= 128);
|
||||
assert.equal((await runtime.getExecutorJob(state.plan.executorJob.id)).status, 'blocked');
|
||||
});
|
||||
|
||||
test('LangGraph active workflow waits on a leased Executor Job and converges terminal state', async () => {
|
||||
const runtime = createLangGraphOrchestratorRuntime({
|
||||
checkpointer: new MemorySaver(),
|
||||
executionEnabled: true,
|
||||
enabledExecutors: ['goosed'],
|
||||
});
|
||||
const state = await runtime.start({
|
||||
runId: 'run-active-1',
|
||||
requestId: 'request-active-1',
|
||||
workflow: { name: 'code-run-v1', version: 1 },
|
||||
subject: { tenantId: 'tenant-1', userId: 'user-1' },
|
||||
input: {
|
||||
instruction: 'Run a controlled canary',
|
||||
executor: 'goosed',
|
||||
workspaceRef: { kind: 'workspace-alias', id: 'canary' },
|
||||
},
|
||||
policy: {
|
||||
executionMode: 'active',
|
||||
sideEffectsAllowed: true,
|
||||
networkAllowed: false,
|
||||
},
|
||||
});
|
||||
assert.equal(state.status, 'waiting');
|
||||
assert.equal(state.phase, 'executor_queued');
|
||||
assert.equal(state.plan.executorJob.status, 'queued');
|
||||
|
||||
const claim = await runtime.claimExecutorJob({
|
||||
workerId: 'worker-1',
|
||||
executors: ['goosed'],
|
||||
});
|
||||
await runtime.startExecutorJob(claim.job.jobId, { leaseToken: claim.leaseToken });
|
||||
await runtime.completeExecutorJob(claim.job.jobId, {
|
||||
leaseToken: claim.leaseToken,
|
||||
result: {
|
||||
summary: 'canary complete',
|
||||
artifactRefs: [{ kind: 'canary-result', id: 'result-1' }],
|
||||
},
|
||||
});
|
||||
|
||||
const completed = await runtime.getState('run-active-1');
|
||||
assert.equal(completed.status, 'succeeded');
|
||||
assert.equal(completed.result.executed, true);
|
||||
assert.deepEqual(
|
||||
completed.result.executorJob.result.artifactRefs,
|
||||
[{ kind: 'canary-result', id: 'result-1' }],
|
||||
);
|
||||
assert.deepEqual(
|
||||
(await runtime.listEvents('run-active-1')).events.map((event) => event.type),
|
||||
[
|
||||
'workflow_validated',
|
||||
'workflow_planned',
|
||||
'workflow_executor_queued',
|
||||
'workflow_completed',
|
||||
],
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user