Skip to content

refactor(auth): extract SSH/browser helpers into auth_browser_helpers (s2) - #80428

Open
andrexibiza wants to merge 5 commits into
NousResearch:mainfrom
andrexibiza:gfg/auth-s2-browser
Open

refactor(auth): extract SSH/browser helpers into auth_browser_helpers (s2)#80428
andrexibiza wants to merge 5 commits into
NousResearch:mainfrom
andrexibiza:gfg/auth-s2-browser

Conversation

@andrexibiza

@andrexibiza andrexibiza commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Summary

Extract the SSH/browser helper family from hermes_cli/auth.py into hermes_cli/auth_browser_helpers.py with a PEP 562 seam so every moved name still resolves is-identical through the monolith namespace.

Part of #78637 (auth kill target) · Part of #78647 (Large-file decomposition epic)

Why this matters to users

auth.py is a god-file under active conquest. This slice moves remote-session / graphical-browser / SSH-hint helpers out without behavior change, so future auth work doesn't keep colliding inside an 8k+ line monolith and so the kill board can advance.

What moved

  • _is_remote_session
  • _can_open_graphical_browser
  • _ssh_user_at_host
  • _print_loopback_ssh_hint
  • _CONSOLE_BROWSER_NAMES (+ related constants in window)

Window (parent 863e3131855): 3396–3557 (def-aligned) / 3392–3557 (banner-inclusive).

Golden receipts

Variant sha256 (with-NL)
def-aligned 3396–3557 91e0fd158ce44af1b2f32ce24363e1254587825df4cf9bda8c16c480a2544bc6
banner 3392–3557 6fb799dafb81ab602bb86f11dba294f3d94ffafe4a8f3cded76f4f502f4651a4

difflib 0 after sanctioned seams (lazy round-trip + bottom OAUTH_OVER_SSH_DOCS_URL import).

Double-blind review

Pass Model Verdict
A grok-composer-2.5-fast APPROVED (1 MINOR: trailing blank at EOF)
B grok-build-0.1 (adversarial) APPROVED (MINOR: EOF blank + one weakened docstring assert)

No CRITICAL/IMPORTANT. Spec compliance PASS.

Collision gate

Live census over full open-PR population (~19k). Nominal #17246 / #17647 = base-drift pre-window, CONFLICTING, fail git apply --check — not live collisions on this window. s3/s4/s5 windows remain gated on their own colliders (FILE-LIST on #78637).

Stat

 hermes_cli/auth.py                                 | 184 +++---------------
 hermes_cli/auth_browser_helpers.py                 | 214 +++++++++++++++++++++
 tests/hermes_cli/test_auth_browser_helpers_seam.py | 161 ++++++++++++++++
 3 files changed, 402 insertions(+), 157 deletions(-)

How to test

scripts/run_tests.sh tests/hermes_cli/test_auth_browser_helpers_seam.py
# plus affected: loopback / graphical-browser / related auth suites

Reviewer receipts: seam identity is, both import orders, ruff clean, LF-only, DCO present.

Platforms

Windows native + git-bash runner.

Interlock

…elpers.py

Slice s2 of the auth.py god-file kill (epic NousResearch#78647, target NousResearch#78637):
the SSH / remote-session detection and graphical-browser helpers
(_is_remote_session, _CONSOLE_BROWSER_NAMES, _can_open_graphical_browser,
_ssh_user_at_host, _print_loopback_ssh_hint) move byte-verbatim into
hermes_cli/auth_browser_helpers.py.

Seam: hermes_cli.auth re-exports every moved name (eager import at the
vacated site + PEP 562 module __getattr__ fallback), so bare-name call
sites inside the monolith, downstream from-hermes_cli.auth import
importers, and test monkeypatches all keep resolving unchanged. The ONE
non-verbatim body adjustment is the function-local round-trip seam
inside _print_loopback_ssh_hint that imports _is_remote_session through
the monolith re-export at call time, so monkeypatch.setattr(auth, ...)
keeps steering the moved code; OAUTH_OVER_SSH_DOCS_URL is imported at
the bottom of the new module to break the import cycle.

Regression coverage: tests/test_auth_browser_helpers_seam.py asserts
real identity (auth.<name> is helpers.<name>) for every re-exported
name, the PEP 562 fallback, and behavior smokes. Existing affected
suites (test_auth_loopback_ssh_hint, test_graphical_browser_detection,
test_setup_tts_xai_oauth, test_subscription_cli,
test_anthropic_oauth_pkce, test_spotify_auth) pass unchanged.

Golden receipts (recomputed at pin 863e313):
- def-aligned 3396-3557 with-NL sha 91e0fd158ce44af1b2f32ce24363e1254587825df4cf9bda8c16c480a2544bc6
- banner-inclusive 3392-3557 with-NL sha 6fb799dafb81ab602bb86f11dba294f3d94ffafe4a8f3cded76f4f502f4651a4

Collision census: all 38 open PRs touching hermes_cli/auth.py
hunk-checked; window 3396-3557 clean (nearest live hunk 3969; the two
nominal overlaps 17246/17647 are base-drift artifacts created before the
window existed and fail git apply --check at HEAD).

Signed-off-by: Andrex Ibiza, MBA <84248988+andrexibiza@users.noreply.github.com>
@andrexibiza

Copy link
Copy Markdown
Contributor Author

Interlock receipt

@alt-glitch alt-glitch added type/refactor Code restructuring, no behavior change comp/cli CLI entry point, hermes_cli/, setup wizard area/auth Authentication, OAuth, credential pools P3 Low — cosmetic, nice to have labels Aug 6, 2026
Signed-off-by: Andrex Ibiza <andrexibiza@users.noreply.github.com>
Signed-off-by: Andrex Ibiza <andrexibiza@users.noreply.github.com>
…trigger run)

Signed-off-by: andrexibiza <84248988+andrexibiza@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/auth Authentication, OAuth, credential pools comp/cli CLI entry point, hermes_cli/, setup wizard P3 Low — cosmetic, nice to have type/refactor Code restructuring, no behavior change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants