Skip to content

fix(gateway): prefer systemd scope for timeout check - #54396

Open
ruizanthony wants to merge 1 commit into
NousResearch:mainfrom
ruizanthony:fix/systemd-timeout-scope
Open

fix(gateway): prefer systemd scope for timeout check#54396
ruizanthony wants to merge 1 commit into
NousResearch:mainfrom
ruizanthony:fix/systemd-timeout-scope

Conversation

@ruizanthony

Copy link
Copy Markdown
Contributor

Summary

  • Detect the running systemd manager from /proc/self/cgroup before checking TimeoutStopUSec.
  • Prefer the system manager for services under /system.slice and the user manager for /user.slice.
  • Add regression coverage for the false-positive case where a stale inactive user unit reports 90s while the active system unit is correctly configured at 210s.

Why

Gateway startup could warn that a systemd unit was stale even when the running service was a system unit with a correct TimeoutStopSec. The check queried systemctl --user first, so a same-named inactive user unit could produce a false TimeoutStopSec=90s mismatch.

Test plan

  • python -m py_compile gateway/shutdown_forensics.py tests/gateway/test_shutdown_forensics.py
  • python -m pytest tests/gateway/test_shutdown_forensics.py -q -o 'addopts=' --tb=short

@teknium1

Copy link
Copy Markdown
Contributor

Thanks for the focused regression fix. Current main still tries systemctl --user before the system manager and accepts the first parseable result (gateway/shutdown_forensics.py:363-389), which permits the false positive documented in linked issue #63158. This PR uses the running unit's cgroup scope to select the appropriate manager and adds a system-scope regression case.

The patch hunk context matches current main, is limited to the diagnostic path and its tests, and introduces no config, tool-schema, caching, or message-flow changes. This is an automated hermes-sweeper review.

@teknium1 teknium1 added sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform labels Jul 15, 2026
@ruizanthony
ruizanthony force-pushed the fix/systemd-timeout-scope branch from 0cd4c7b to 65e1745 Compare July 29, 2026 18:13
@ruizanthony

Copy link
Copy Markdown
Contributor Author

Rebased cleanly onto current main. Exact head: 65e1745148f20cfc585ed2460e9a666a1f5ab355; targeted shutdown-forensics gate: 31 passed; diff check clean. Please re-review.

@ruizanthony
ruizanthony force-pushed the fix/systemd-timeout-scope branch from 65e1745 to 07dcd68 Compare July 29, 2026 18:22
@ruizanthony

Copy link
Copy Markdown
Contributor Author

Attribution gate fixed by rewriting the unchanged commit with the repository-approved author identity. New exact head: 07dcd680f59bfc40b2269e9367e0cf711c671481; CI restarted.

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:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants