fix(gateway): bound final shutdown cleanup - #62272
Conversation
|
Thanks for the focused shutdown hardening. The underlying premise is present on current main: Problems
Suggested changes
The config.yaml surface is aligned with |
af76a13 to
747e56c
Compare
|
Addressed in 747e56c2c. The regression is now scoped to the invariant it actually proves: a generic wedged final-cleanup step cannot hold service-manager shutdown. Removed the unrelated |
747e56c to
fe6ee9c
Compare
fe6ee9c to
8ed2993
Compare
|
Refreshed onto current |
|
Refreshed onto current main (a4973c3) in 4fb9f839d. The conflict resolution preserves upstream's DEFAULT_CONFIG extraction and places gateway.shutdown_cleanup_timeout in hermes_cli/config_defaults.py, while retaining the bounded final-cleanup behavior and duck-typed runner compatibility. Local verification: 184 shutdown/config/cache-cleanup tests passed; Ruff, git diff --check, publish gate, and gitleaks passed. GitHub reports MERGEABLE, and all required CI passed, including all eight Python slices and Desktop E2E. The non-required arm64 Docker build passed; the non-required amd64 Docker build was still running at final read-back. |
7d1818b to
de24b1f
Compare
|
Rebased onto current The resolution preserves upstream's extracted Local verification: 90 focused and adjacent tests passed across shutdown, config, cache cleanup, restart drain, bounded adapter teardown, channel overrides, and async session storage. Ruff, byte compilation, |
de24b1f to
e91b0b0
Compare
|
Rebased onto current The resolution preserves upstream's selective multiplex profile serving, explicit unserved-route rejection, user-boundary completion routing, and current adjacent config tests while retaining the bounded post-adapter Local verification:
Fresh CI passed 11/12 Python slices, e2e, Ruff/ty, Windows and macOS lanes, OSV, supply-chain, attribution, lockfile, history, and both Docker builds. Slice 5 failed only I reproduced that failure identically in an untouched worktree at exact base |
e91b0b0 to
5079f9c
Compare
|
Refreshed onto exact current
The bounded post-adapter final-cleanup behavior and timeout=0 compatibility remain intact. GitHub reports the PR mergeable. |
5079f9c to
71ecc16
Compare
|
Rebased onto current The resolution preserves upstream’s completion-batch cancellation-before-adapter-disconnect regression and this PR’s wedged post-adapter Local verification:
GitHub now reports |
71ecc16 to
d4eeee7
Compare
|
CI failure resolved on head |
d4eeee7 to
2b3874e
Compare
|
Resolved the latest base conflict on current main in The resolution preserves both the bounded final-shutdown cleanup from this PR and current main shutdown/cache teardown behavior, including fake-runner and async-session-store contracts. Local proof: 95 relevant tests passed with 2 expected Windows skips; Ruff, diff/security gates, and the existing-PR publish gate passed. Replacement GitHub CI is fully green, and GitHub reports the PR mergeable. |
fix(gateway): bound final shutdown cleanup
|
2b3874e to
5fb82eb
Compare
|
Resolved the renewed current-main conflict and addressed the cleanup-status review at
|
|
Replacement CI is fully green on |
Summary
Fixes #58666.
When
/restartis requested under a service manager, the gateway sets_shutdown_eventafter adapter teardown but then runs final tool/environment cleanup inline on the event loop. If that best-effort cleanup wedges, the loop never returns to the main gateway task, so housekeeping never stops and launchd/systemd never observes process exit.This adds a bounded late-shutdown helper for the post-adapter
final-cleanupphase:gateway.shutdown_cleanup_timeoutinconfig.yaml(default 5s)done,timed out, andfaileddistinctly instead of logging exceptions as successful cleanupSystemExit/KeyboardInterruptraised by the cleanup worker while preserving cancellation of the shutdown task itself0The regression injects a generic post-disconnect final-cleanup wedge. It proves
stop(restart=True, service_restart=True)still completes and preserves the service-restart exit code without claiming an unprovenchannel_overridestrigger. Additional coverage proves inline exceptions and workerSystemExitare reported as failed cleanup.This supersedes closed #61011. That version used a new non-secret
HERMES_*environment variable; this rescope follows the maintainer review by making the timeout a typedgateway.*configuration value with YAML loading and serialization coverage.Duplicate / overlap check
channel_overridesmatches concern model/routing behavior, launchd matches concern service management, and MCP shutdown matches bound an earlier subsystemVerification
main8b09a9df8476010a78e86d6c32254b4ac14a8c4fgit diff --check, public identity/privacy checks, gitleaks, and the existing-PR review-follow-up gate passedCurrent head:
5fb82eb188439957f7e04842c45a6424ad5c8046