Skip to content

refactor(gateway): extract transient-error helpers from run.py (slice 5 of #54962) - #77455

Open
andrexibiza wants to merge 1 commit into
NousResearch:mainfrom
andrexibiza:fix/gateway-error-helpers
Open

refactor(gateway): extract transient-error helpers from run.py (slice 5 of #54962)#77455
andrexibiza wants to merge 1 commit into
NousResearch:mainfrom
andrexibiza:fix/gateway-error-helpers

Conversation

@andrexibiza

@andrexibiza andrexibiza commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Related #31066 #31110 #54962 #55138 #77433 #77438 #77450 #77452

What does this PR do?

Fifth slice of the Extract Gateway Platform Routing from
gateway/run.py
refactor (#54962, #55138) — standalone PR for the
transient-error helper cluster (follow-up to #77433 slice 1, #77438
slice 2, #77452 slice 3, #77450 slice 4).

This slice pulls the transient-error safety-net helpers out of the
god-file into gateway/error_helpers.py:

No behavior change: byte-identical extraction (AST-verified against
origin/main). gateway/run.py shrinks by 76 lines; the helpers are
imported at the extraction point so the loop-install site and existing
tests stay green.

Scope honesty

The full platform-routing extraction from a 26.7K-line file is a
multi-PR effort. This is slice 5, standalone, same verified pattern as
slices 1-4 (module + import + shrink + AST-fidelity). Platform adapters
and the dispatch loop remain for follow-up slices.

How to test

pytest tests/gateway/test_loop_exception_handler.py -q
# 8 passed

What platforms were tested?

  • Windows 11 native: both files parse, imports resolve, both functions
    AST-identical to origin/main, 8 tests pass, git diff --check clean,
    attribution audit clean.

Why this matters

Every slice shrinks the largest file in the codebase and gives extracted
helpers direct coverage. gateway/run.py is down ~450 lines across
slices 1-5, with more to come.

Part of #54962
Part of #55138 (Extract Gateway Platform Routing)

  • Refactor (no behavior change)
  • Bug fix
  • Breaking change

Checklist

  • Code follows repo style (extraction, no new deps)
  • Self-review complete
  • Existing tests cover the extracted helpers (8 pass)
  • git diff --check clean
  • Attribution audit clean

Part of #78647

… 5 of NousResearch#54962)

Fifth slice of the gateway god-file unpacking: extract
_is_transient_network_error and _gateway_loop_exception_handler into
gateway/error_helpers.py.

- Byte-identical extraction (AST-verified against origin/main): the
  classifier walks the exception cause chain (NousResearch#31066/NousResearch#31110); the loop
  handler wires it into the event-loop safety net
- gateway/run.py: -76 lines; helpers imported at the extraction point
- 8 tests pass (loop exception handler)

Follow-up to NousResearch#77433 (slice 1), NousResearch#77438 (slice 2), NousResearch#77452 (slice 3),

Signed-off-by: andrexibiza <84248988+andrexibiza@users.noreply.github.com>
NousResearch#77450 (slice 4). Progress on NousResearch#54962.
@alt-glitch alt-glitch added type/refactor Code restructuring, no behavior change P3 Low — cosmetic, nice to have comp/gateway Gateway runner, session dispatch, delivery sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages labels Aug 3, 2026
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/refactor Code restructuring, no behavior change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants