Skip to content

refactor(gateway): extract interrupt helpers from run.py (slice 19 of #54962) - #77722

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

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

Conversation

@andrexibiza

@andrexibiza andrexibiza commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Related #54962 #55138 #77433

What / Why

Slice 19 of the god-file extraction campaign (#54962): pulls the interrupt-marker helpers out of the 26,823-line gateway/run.py god file into a focused gateway/interrupt_helpers.py module.

Moved (pure move, byte-verbatim, zero behavior change):

  • _stamp_hygiene_compression_provenance — best-effort activity provenance stamp for hygiene compression transitions (timeout / cooldown).

Kept in gateway/run.py (documented, not moved):

gateway/run.py re-exports the moved function via a module-attribute import, so gateway.run._stamp_hygiene_compression_provenance keeps resolving with identical object identity (log records also keep the gateway.run logger name).

How to test

python -c "import gateway.run"
python -m pytest tests/gateway/test_restart_resume_pending.py -q --no-header -p no:cacheprovider

Verified in this PR:

  • import gateway.run succeeds from the worktree; gateway.run._stamp_hygiene_compression_provenance is gateway.interrupt_helpers._stamp_hygiene_compression_provenance (identity asserted).
  • tests/gateway/test_restart_resume_pending.py: 31 passed (the only test file referencing the interrupt cluster).
  • git diff --check: clean. scripts/check-windows-footguns.py: no footguns found.
  • Moved function is byte-verbatim identical to HEAD:gateway/run.py (diff-checked).

Shrink

gateway/run.py: 26,823 → 26,811 lines (−12). New module: gateway/interrupt_helpers.py (+27). Net line movement is the smallest clean extraction: one function + its private imports; the dependent member stays with its claimed dependency rather than forcing the cluster.

Platforms tested

  • Windows 11 (git-bash), CPython via project venv — import + targeted pytest run.
  • Pure Python module move; no platform-specific code touched.

Part of #54962

Part of #55138

Part of #78647

@alt-glitch alt-glitch added type/refactor Code restructuring, no behavior change 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 sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state labels Aug 3, 2026
…ousResearch#54962)

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

Copy link
Copy Markdown
Contributor Author

At exact head b20be81408a66d9b7b23ad5d78fd39bc118cd43b, commit b20be81408a6 records the interrupt-helper extraction. _stamp_hygiene_compression_provenance now lives in the focused interrupt helper module and is re-exposed from gateway.run, preserving the original object identity and logger namespace. The freshness predicate and its default remain in gateway.run because they depend on the timestamp coercion helper owned by another slice; leaving that dependency in place keeps this a narrow, byte-verbatim move rather than forcing an incomplete cluster transfer.

For refactor(gateway): extract interrupt helpers from run.py (slice 19 of #54962), GitHub reports check rollup SUCCESS on exact head b20be81408a66d9b7b23ad5d78fd39bc118cd43b.

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 sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state type/refactor Code restructuring, no behavior change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants