Skip to content

fix: prod robustness#68

Merged
sqhell merged 1 commit into
mainfrom
feat/auto-rdmiztion
Apr 23, 2026
Merged

fix: prod robustness#68
sqhell merged 1 commit into
mainfrom
feat/auto-rdmiztion

Conversation

@sqhell
Copy link
Copy Markdown
Contributor

@sqhell sqhell commented Apr 23, 2026

No description provided.

@sqhell sqhell merged commit 01628e8 into main Apr 23, 2026
1 check passed
@sqhell sqhell deleted the feat/auto-rdmiztion branch April 23, 2026 16:13
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request implements a graceful shutdown mechanism for the orchestrator and virtual bots using promise tracking and timeouts. It also introduces a dormancy threshold for bots with consecutive task errors, adds validation for the demo time scale, and optimizes pool exhaustion logging. Feedback suggests explicitly cloning the bot list during shutdown to ensure iteration safety and removing a redundant error check in the bot's top-up logic.

Comment thread autobots/orchestrator.js
Comment on lines +143 to +146
const loops = this.#bots.map((b) => {
b.stop();
return b.loopPromise;
});
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The comment mentions taking a "snapshot" of the bot list, but the code iterates over this.#bots directly. While safe in this specific implementation because b.stop() is synchronous and doesn't trigger immediate removal, it is better practice to actually snapshot the array (e.g., using the spread operator) to ensure the set of bots being signaled is isolated from any concurrent mutations to the collection during iteration.

Suggested change
const loops = this.#bots.map((b) => {
b.stop();
return b.loopPromise;
});
const loops = [...this.#bots].map((b) => {
b.stop();
return b.loopPromise;
});

Comment thread autobots/virtual-bot.js
Comment on lines +215 to 219
if (this.#consecutiveTaskErrors >= MAX_CONSECUTIVE_TASK_ERRORS) {
this.#goDormant("task_error_threshold");
break;
}
this.#scheduleNextTopUp(Date.now());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This error threshold check is redundant in the top-up block. The MAX_CONSECUTIVE_TASK_ERRORS counter is only incremented within #runTask(), and it is already checked immediately after that call (lines 208-211). Since #runTopUp() does not modify the error counter, the condition cannot become true during this block if it wasn't already true (and caught) previously.

          this.#scheduleNextTopUp(Date.now());

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant