@atolis-hq/wake 0.3.69 → 0.3.70
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/bootstrap/composition-root.js +1 -0
- package/dist/src/bootstrap/version.js +1 -1
- package/dist/src/control-plane/application/advance-once-ports.js +1 -0
- package/dist/src/control-plane/application/advance-once.js +13 -2
- package/dist/src/control-plane/contracts/config.js +1 -0
- package/package.json +1 -1
|
@@ -112,6 +112,7 @@ export async function createCompositionRoot(wakeRoot, options = {}) {
|
|
|
112
112
|
}, resources, clock, {
|
|
113
113
|
ids,
|
|
114
114
|
dispatchPolicy: new DispatchPolicy({ maxDispatches: config.controlPlane.maxDispatches }),
|
|
115
|
+
maxConcurrentRuns: config.controlPlane.maxConcurrentRuns,
|
|
115
116
|
isDispatchPaused: isRuntimePaused,
|
|
116
117
|
workspaceRecovery: workspaces,
|
|
117
118
|
work,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ActivationClaimConflictError, RunStatus, WorkspaceMode } from '../../execution/index.js';
|
|
2
|
-
import { correlationId, EventActorKind
|
|
2
|
+
import { correlationId, EventActorKind } from '../../kernel/index.js';
|
|
3
3
|
import { isAmbiguityResolutionBlock, WorkflowStatus } from '../../orchestration/index.js';
|
|
4
4
|
import { WorkStatus } from '../../work/index.js';
|
|
5
5
|
import { ControlStreamKind } from '../contracts/streams.js';
|
|
@@ -11,13 +11,14 @@ export function createAdvanceOnce(orchestration, execution, resources, clock, de
|
|
|
11
11
|
const workspaceRecovery = dependencies.workspaceRecovery;
|
|
12
12
|
const transcriptRetention = dependencies.transcriptRetention;
|
|
13
13
|
const dispatchPolicy = dependencies.dispatchPolicy ?? new DispatchPolicy({ maxDispatches: 1 });
|
|
14
|
+
const maxConcurrentRuns = dependencies.maxConcurrentRuns ?? 1;
|
|
14
15
|
const context = (cause) => ({
|
|
15
16
|
commandId: dependencies.ids.next('command'),
|
|
16
17
|
correlationId: correlationId(cause),
|
|
17
18
|
occurredAt: clock.now().toISOString(),
|
|
18
19
|
actor: { kind: EventActorKind.System, id: ControlStreamKind.Global },
|
|
19
20
|
});
|
|
20
|
-
|
|
21
|
+
const advance = async (options) => {
|
|
21
22
|
if (options.maxProgress < 1)
|
|
22
23
|
return { kind: 'exhausted', progressCount: 0 };
|
|
23
24
|
if (await isDispatchPaused())
|
|
@@ -115,6 +116,8 @@ export function createAdvanceOnce(orchestration, execution, resources, clock, de
|
|
|
115
116
|
};
|
|
116
117
|
}
|
|
117
118
|
const allRuns = await execution.list();
|
|
119
|
+
if (allRuns.filter((run) => run.status === RunStatus.Started).length >= maxConcurrentRuns)
|
|
120
|
+
return { kind: 'no-work' };
|
|
118
121
|
const selectedCandidate = dispatchPolicy.select(await Promise.all(pending.map(async (item, requestedPosition) => ({
|
|
119
122
|
workItemId: item.workflow.workItemId,
|
|
120
123
|
activationId: item.activation.activationId,
|
|
@@ -183,4 +186,12 @@ export function createAdvanceOnce(orchestration, execution, resources, clock, de
|
|
|
183
186
|
reason: run.failure?.message ?? 'execution failed',
|
|
184
187
|
};
|
|
185
188
|
};
|
|
189
|
+
// Tick, resident, and API callers share this advancement instance. Serialize the
|
|
190
|
+
// capacity check through Run creation so concurrent callers cannot over-dispatch.
|
|
191
|
+
let prior = Promise.resolve();
|
|
192
|
+
return async (options) => {
|
|
193
|
+
const current = prior.then(() => advance(options));
|
|
194
|
+
prior = current.then(() => undefined, () => undefined);
|
|
195
|
+
return current;
|
|
196
|
+
};
|
|
186
197
|
}
|
|
@@ -10,6 +10,7 @@ const scheduleSchema = z
|
|
|
10
10
|
export const controlPlaneConfigSchema = z
|
|
11
11
|
.object({
|
|
12
12
|
maxDispatches: z.number().int().positive().default(1),
|
|
13
|
+
maxConcurrentRuns: z.number().int().positive().default(1),
|
|
13
14
|
schedules: z.array(scheduleSchema).default([]),
|
|
14
15
|
resident: z
|
|
15
16
|
.object({
|