Skip to content

refactor(gateway): extract compression-status helpers from run.py (slice 4 of #54962) - #77450

Open
andrexibiza wants to merge 3 commits into
NousResearch:mainfrom
andrexibiza:fix/gateway-status-helpers
Open

refactor(gateway): extract compression-status helpers from run.py (slice 4 of #54962)#77450
andrexibiza wants to merge 3 commits into
NousResearch:mainfrom
andrexibiza:fix/gateway-status-helpers

Conversation

@andrexibiza

@andrexibiza andrexibiza commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Related #52995 #54962 #55138 #69550 #77433 #77438

What does this PR do?

Fourth slice of the Extract Gateway Platform Routing from
gateway/run.py
refactor (#54962, #55138) — follow-up to #77433 (slice 1:
display helpers) and #77438 (slices 2-3: message/config + resume/replay
helpers).

This slice pulls the compression-status matcher out of the god-file
into gateway/status_helpers.py:

No behavior change: byte-identical extraction (AST-verified against
origin/main). gateway/run.py shrinks by 47 lines; the 8 now-unused
template imports are removed from run.py and live only in the new module.
The matcher is imported at the extraction point so the line-628 call 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 4, using the same verified pattern as
slices 1-3 (module + import + shrink + AST-fidelity). Platform adapters
and the dispatch loop remain for follow-up slices.

How to test

pytest tests/gateway/test_compression_progress_notices.py -q
# plus regression: test_replay_entry_fields, test_restart_resume_pending
# 78 passed total

What platforms were tested?

  • Windows 11 native: both files parse, imports resolve, _status_template_to_regex
    AST-identical to origin/main, 78 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 ~360 lines across
slices 1-4, 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 (78 pass)
  • git diff --check clean
  • Attribution audit clean

Part of #78647

…ice 4 of NousResearch#54962)

Fourth slice of the gateway god-file unpacking: extract
_status_template_to_regex and the _COMPRESSION_PROGRESS_STATUS_RE matcher
into gateway/status_helpers.py.

- Byte-identical extraction (AST-verified): the regex is built from the
  SAME template constants the emit sites format
  (agent/conversation_compression.py), so wording drift cannot silently
  diverge
- gateway/run.py: -47 lines; the 8 now-unused template imports removed;
  helpers imported at the extraction point
- 78 tests pass (compression-progress notices + replay + resume suites)

Follow-up to NousResearch#77433 (slice 1) and NousResearch#77438 (slices 2-3). Progress on NousResearch#54962.

Signed-off-by: andrexibiza <84248988+andrexibiza@users.noreply.github.com>
… 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: -78 lines; helpers imported at the extraction point
- 46 tests pass (loop exception handler + compression notices)

Follow-up to NousResearch#77433 (slice 1), NousResearch#77438 (slices 2-3), NousResearch#77450 (slice 4).
Progress on NousResearch#54962.

Signed-off-by: andrexibiza <84248988+andrexibiza@users.noreply.github.com>
@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