feat: expose global execution concurrency limit in settings
- Add PUT /api/global-concurrency endpoint to update globalMaxConcurrent via CentralCore (validated 1-50 range) - Make InProcessRuntime semaphore react to live concurrency changes via CentralCore "concurrency:changed" event — no restart needed - Add Global Max Concurrent input to Settings modal Scheduling section with fetch-on-mount and save-alongside-project-settings behavior - Add updateGlobalConcurrency API client function Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -91,6 +91,7 @@ export class InProcessRuntime
|
||||
private missionExecutionLoop?: MissionExecutionLoop;
|
||||
private missionAutopilot?: MissionAutopilot;
|
||||
private triageProcessor?: TriageProcessor;
|
||||
private concurrencyChangedListener?: (state: { globalMaxConcurrent: number }) => void;
|
||||
|
||||
/**
|
||||
* @param config - Runtime configuration
|
||||
@@ -175,8 +176,19 @@ export class InProcessRuntime
|
||||
if (this.config.globalSemaphore) {
|
||||
this.globalSemaphore = this.config.globalSemaphore;
|
||||
} else {
|
||||
const globalLimit = await this.getGlobalConcurrencyLimit();
|
||||
this.globalSemaphore = new AgentSemaphore(() => globalLimit);
|
||||
// Dynamic getter that re-reads from CentralCore on each semaphore acquire.
|
||||
// This ensures changes via PUT /api/global-concurrency take effect immediately.
|
||||
let cachedLimit = await this.getGlobalConcurrencyLimit();
|
||||
this.globalSemaphore = new AgentSemaphore(() => cachedLimit);
|
||||
|
||||
// Listen for concurrency changes from CentralCore (if it supports events)
|
||||
if (typeof this.centralCore.on === "function") {
|
||||
this.concurrencyChangedListener = (state: { globalMaxConcurrent: number }) => {
|
||||
cachedLimit = state.globalMaxConcurrent;
|
||||
runtimeLog.log(`Global concurrency limit updated to ${cachedLimit}`);
|
||||
};
|
||||
this.centralCore.on("concurrency:changed", this.concurrencyChangedListener);
|
||||
}
|
||||
}
|
||||
|
||||
// 5. Initialize Scheduler
|
||||
@@ -549,7 +561,13 @@ export class InProcessRuntime
|
||||
runtimeLog.log(`Stopping InProcessRuntime for project ${this.config.projectId}`);
|
||||
|
||||
try {
|
||||
// 1. Stop self-healing manager
|
||||
// 1. Remove concurrency change listener (if we registered one)
|
||||
if (this.concurrencyChangedListener && typeof this.centralCore.off === "function") {
|
||||
this.centralCore.off("concurrency:changed", this.concurrencyChangedListener);
|
||||
this.concurrencyChangedListener = undefined;
|
||||
}
|
||||
|
||||
// 2. Stop self-healing manager
|
||||
if (this.selfHealingManager) {
|
||||
this.selfHealingManager.stop();
|
||||
runtimeLog.log("SelfHealingManager stopped");
|
||||
|
||||
Reference in New Issue
Block a user