@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.
@@ -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,
@@ -108,4 +108,4 @@ export function resolveWakeVersion(options = {}) {
108
108
  return `g${headHash.slice(0, 7)}`;
109
109
  return '0.1.0-dev';
110
110
  }
111
- export const wakeVersion = "g2f2caef";
111
+ export const wakeVersion = "g342239b";
@@ -1,5 +1,5 @@
1
1
  import { ActivationClaimConflictError, RunStatus, WorkspaceMode } from '../../execution/index.js';
2
- import { correlationId, EventActorKind, } from '../../kernel/index.js';
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
- return async (options) => {
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({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atolis-hq/wake",
3
- "version": "0.3.69",
3
+ "version": "0.3.70",
4
4
  "description": "Local autonomous agent control plane for software development",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {