Skip to content

fix(gateway): harden scale-to-zero dormancy guards - #52359

Merged
benbarclay merged 1 commit into
mainfrom
fix/scale-to-zero-review-warnings
Jun 25, 2026
Merged

fix(gateway): harden scale-to-zero dormancy guards#52359
benbarclay merged 1 commit into
mainfrom
fix/scale-to-zero-review-warnings

Conversation

@benbarclay

Copy link
Copy Markdown
Collaborator

Summary

Test Plan

  • uv run --extra dev python -m pytest tests/gateway/test_scale_to_zero.py tests/gateway/test_scale_to_zero_watcher.py tests/gateway/relay/test_relay_going_idle.py -q -o 'addopts='
  • python -m compileall -q gateway/run.py tests/gateway/test_scale_to_zero_watcher.py
  • git diff --check origin/main -- gateway/run.py tests/gateway/test_scale_to_zero_watcher.py

Block scale-to-zero suspend while background async delegations are active, and restore runtime status to running on real inbound after a dormant wake.\n\nAdd regression coverage for both review findings.
@github-actions

Copy link
Copy Markdown
Contributor

🔎 Lint report: fix/scale-to-zero-review-warnings vs origin/main

ruff

Total: 0 on HEAD, 0 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 0 pre-existing issues carried over.

ty (type checker)

Total: 11268 on HEAD, 11268 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 5942 pre-existing issues carried over.

Diagnostics are surfaced as warnings — this check never fails the build.

@tonydwb tonydwb left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review Summary

Verdict: Approved

This PR hardens the scale-to-zero dormancy guards in the gateway. Two key changes:

  1. active_count() from tools.async_delegation is checked to prevent suspending while background delegations are active
  2. _scale_to_zero_note_real_inbound() stamps real inbound traffic and restores lifecycle status after a dormant wake

Key observations

  • Async delegation check prevents suspend while background tasks run
  • Real inbound note prevents status from being stuck in draining after wake
  • Internal completion/replay events intentionally do NOT call the helper
  • Good test coverage for both changes

Looks Good

  • Fail-closed design with defensive exception handling
  • Proper separation between real traffic and internal events
  • Tests verify the status restoration behavior

Reviewed by Hermes Agent (cron)

@alt-glitch alt-glitch added type/bug Something isn't working comp/gateway Gateway runner, session dispatch, delivery P3 Low — cosmetic, nice to have sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages labels Jun 25, 2026
@benbarclay
benbarclay merged commit d6269da into main Jun 25, 2026
27 checks passed
@benbarclay
benbarclay deleted the fix/scale-to-zero-review-warnings branch June 25, 2026 10:41
pai-scaffolde pushed a commit to pai-scaffolde/hermes-agent that referenced this pull request Jun 28, 2026
Block scale-to-zero suspend while background async delegations are active, and restore runtime status to running on real inbound after a dormant wake.\n\nAdd regression coverage for both review findings.
waefrebeorn pushed a commit to waefrebeorn/slermes that referenced this pull request Jul 2, 2026
Block scale-to-zero suspend while background async delegations are active, and restore runtime status to running on real inbound after a dormant wake.\n\nAdd regression coverage for both review findings.
habarmc1223-sudo pushed a commit to habarmc1223-sudo/hermes-agent-fluxmem that referenced this pull request Jul 8, 2026
Block scale-to-zero suspend while background async delegations are active, and restore runtime status to running on real inbound after a dormant wake.\n\nAdd regression coverage for both review findings.
santhreal pushed a commit to santhreal/hermes-agent that referenced this pull request Jul 13, 2026
Block scale-to-zero suspend while background async delegations are active, and restore runtime status to running on real inbound after a dormant wake.\n\nAdd regression coverage for both review findings.
Gravezzz pushed a commit to Gravezzz/hermes-agent that referenced this pull request Jul 21, 2026
Block scale-to-zero suspend while background async delegations are active, and restore runtime status to running on real inbound after a dormant wake.\n\nAdd regression coverage for both review findings.
leewenjie pushed a commit to leewenjie/hermes-agent that referenced this pull request Aug 7, 2026
Block scale-to-zero suspend while background async delegations are active, and restore runtime status to running on real inbound after a dormant wake.\n\nAdd regression coverage for both review findings.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P3 Low — cosmetic, nice to have sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants