Skip to content

refactor(web): extract messaging-platform catalog into web_routers/messaging - #79128

Open
andrexibiza wants to merge 1 commit into
NousResearch:mainfrom
andrexibiza:fix/web-messaging-router-extract
Open

refactor(web): extract messaging-platform catalog into web_routers/messaging#79128
andrexibiza wants to merge 1 commit into
NousResearch:mainfrom
andrexibiza:fix/web-messaging-router-extract

Conversation

@andrexibiza

@andrexibiza andrexibiza commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Current disposition

Exact head: f64b41b46e17cd0bd253998ae23c490f6b62571b.

Contributor-side verification is complete on this exact head. GitHub reports the PR mergeable; the fresh current-base CI, Docker, and Nix runs are all green; there are no unresolved inline review threads.

Fresh receipts triggered from the unchanged exact head after the prior cancelled run:

  • CI 32284415567: success;
  • Docker 32284414599: success;
  • Nix 32284414641: success.

The complete legacy symbol/profile-startup contract is preserved:

  • hermes_cli.web_server re-exports the legacy messaging symbols used by existing callers and tests;
  • the extracted module late-binds historical web_server helpers, preserving monkeypatch ownership;
  • profile-scoped reads use the requested profile’s runtime-status path and pass its profile home to the shared liveness resolver;
  • startup_failed is projected from that requested profile’s runtime state rather than ambient/default state;
  • all three route bodies retain their asyncio.to_thread offloads;
  • the PR uses Part of #78647 / Part of #78628, never an epic-closing keyword.

The earlier cancelled CI run 32142622233 is superseded by the successful fresh matrix above. Maintainer review/merge is the remaining repository action; no implementation or CI residue remains on the contributor side.

Summary

Web-server god-file slice R4-C2C5: extract the messaging-platform catalog and Channels management from hermes_cli/web_server.py into hermes_cli/web_routers/messaging.py using an APIRouter, while preserving the legacy import/patch surface.

What changed

  • moved the messaging catalog, environment metadata, status projection, and get/update/test routes into the focused router;
  • mounted the router and re-exported the legacy public/private seam names from web_server.py;
  • resolved cross-cluster helpers through web_deps.late() / late_attr() so the original module remains the monkeypatch authority;
  • preserved named-profile credential/runtime isolation and the complete platform catalog;
  • added seam identity, route registration, response-contract, unknown-platform, env metadata, and catalog-shape regressions.

Structural verification

  • deterministic packet/tree reconstruction matched the repair commit tree;
  • AST comparison found the extracted functions structurally equivalent except for the declared router decorators and late-bound health URL access;
  • previously failing legacy symbol imports and profile startup behavior pass in the repaired candidate;
  • Ruff, compilation, attribution, git diff --check, OS-specific tests, e2e, and all repository-required fresh checks pass;
  • contributor identity remains Axl Ibiza, MBA <andrexibiza@gmail.com> in the actual repair commit.

Coordination

@spfcraze

spfcraze commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

This was generated by AI during triage.

CI slices 5/8 and 8/8 fail on this branch: _build_catalog_entry can no longer be imported from hermes_cli.web_server, and a profile-scoped messaging read reports a different platform state.

Problems:

  • tests/hermes_cli/test_web_server.py:1033 and tests/hermes_cli/test_setup_hidden_env.py:45 import _build_catalog_entry from hermes_cli.web_server; the diff moves the definition out of hermes_cli/web_server.py into the new messaging router, and both files fail collection in CI with ImportError: cannot import name '_build_catalog_entry' from 'hermes_cli.web_server'.
  • tests/hermes_cli/test_web_server_messaging_profiles.py:131 asserts telegram["state"] == "startup_failed" for a profile with a configured token and no running gateway; slice 5/8 receives 'gateway_stopped' — the extracted route reports a different state for the same setup.
  • The body closes with Fixes #78647, so merging this PR auto-closes the god-file epic; [COMPLETE] Large-file decomposition: 20/20 done #78647's method section says refactor slices link Part of (no auto-close) and only a completed file shard closes its issue.

Suggested changes:

  • Restore the seam: keep _build_catalog_entry importable from hermes_cli.web_server (re-export or import it there), and run the pre-existing messaging tests — tests/hermes_cli/test_web_server.py, tests/hermes_cli/test_setup_hidden_env.py, tests/hermes_cli/test_web_server_messaging_profiles.py — in CI alongside the new seam test.
  • Change the closing keyword to Part of #78647 so a slice merge does not close the epic.

Checked against c0d75d6 — the PR head when this was written — and 1be70d6, main at the same moment.

@andrexibiza

Copy link
Copy Markdown
Contributor Author

🔒 This shard is part of the web_server.py KILL LOCK — the permanent record of the 17,700-line whole, the mess it caused (#58576 event-loop stalls, #60800 cold-start stalls, #53972 token persistence, #71778 analytics), every shard in the wave, and every open fixer PR still fighting the surface (#50188 #71802 #54034 #76764 #71150 #67365 #65434 #65424 #78411 #75845 #68022 #62654 #76757 #68251 #51070 #73605 #73849 #73393 #71752 #77808 #46956 #74297 #77853).

Lock: posted on #78628 · Indexed by the Kill All Gods meta-issue #78647.

@alt-glitch alt-glitch added type/refactor Code restructuring, no behavior change comp/cli CLI entry point, hermes_cli/, setup wizard comp/dashboard Web dashboard / control panel UI (dashboard/, landing) sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades P3 Low — cosmetic, nice to have labels Aug 5, 2026
…in (NousResearch#79128)

Restores the seams the original NousResearch#79128 slice broke and re-extracts the messaging-platform catalog/routes from current main:

- Re-export the legacy _build_catalog_entry symbol from hermes_cli.web_server so existing test/consumer imports keep resolving.
- Late-bind read_runtime_status, resolve_gateway_liveness, get_running_pid_cached and get_runtime_status_running_pid through hermes_cli.web_deps.late(), preserving web_server monkeypatch authority after the router extraction.
- Read _GATEWAY_HEALTH_URL via late_attr() instead of freezing server state at import time.
- Retain all three current-main asyncio.to_thread offloads in the extracted routes.

Catalog and route bodies match current main except the intended late-bound health-state edit and APIRouter decorator ownership.
@andrexibiza

Copy link
Copy Markdown
Contributor Author

Implementation verification for the repair on #79128 (web_server.py god-file slice R4-C2C5).

Verified the repair packet against a live checkout at the pinned base e02d1e41fc6104187e20af9eac8b2820566e3508 in an isolated worktree.

Apply / identity

  • Patch SHA-256 verified: 15c066b34255ff3f98d67c5bef1d626ce38fb933df9212184b428af6afd554b8.
  • git am applies cleanly; the resulting tree c40c2a97a1ad395ffb9f319f3be30ecdec33f7a0 is byte-identical to the repair commit's tree (f64b41b46e1). All three packaged tree/ files match the applied result byte-for-byte.
  • Diff shape as claimed: 3 files changed, +1172/−1020 — new hermes_cli/web_routers/messaging.py (1068 L), hermes_cli/web_server.py −1037 L, new tests/test_web_server_messaging_seam.py.

Extraction equivalence

  • AST comparison of all 15 extracted functions against the messaging cluster in web_server.py at base and at current main: 11 are structurally identical to both. The 4 remaining differ only in the two declared ways — _messaging_platform_payload reads _GATEWAY_HEALTH_URL via late_attr() instead of the module global, and the three route handlers (get_messaging_platforms, test_messaging_platform, update_messaging_platform) carry @router.* instead of @app.* decorators. All three asyncio.to_thread offloads from current main are retained inside those bodies.

Seam identity / monkeypatch authority

  • read_runtime_status, resolve_gateway_liveness, get_running_pid_cached, get_runtime_status_running_pid (plus six private helpers) late-bound through the repo's existing hermes_cli.web_deps.late() seam, resolving web_server.<name> at call time; _GATEWAY_HEALTH_URL read via late_attr() at call time, not frozen at import.
  • Legacy _build_catalog_entry re-export restored in web_server.py; seam test asserts ws.<name> is m.<name> identity for all nine moved names.
  • Contract harness: 4/4 PASS, including post-import monkeypatching of web_server.read_runtime_status remaining authoritative.

Canonical suites (the ones the authoring container could not run)

  • test_web_server_messaging_seam.py, test_web_server.py, test_web_server_messaging_profiles.py, test_env_custom_keys.py, test_setup_hidden_env.py190 passed, 4 skipped, 0 failed (all 4 skips are POSIX-only PTY-bridge platform skips). The profile-scoped suite monkeypatches web_server.get_running_pid_cached/read_runtime_status after import and exercises the extracted routes end-to-end — the strongest evidence monkeypatch authority survives the extraction.

Static checks

  • py_compile clean on all three files; git diff --check HEAD^ clean; ruff (0.15.10) clean on all three — the packet receipt marked ruff NOT RUN; that gap is now closed.

Two documentation-level notes (no code impact)

  1. The verification receipt's "Local repaired tree: 27b0082676…" does not match the deterministically reproduced tree (c40c2a97a1ad…, identical to the repair commit's tree); 27b00826… is absent from the local object DB. The receipt's patch SHA-256 and base tree (a165d227…) do check out.
  2. The shipped patch regenerates the commit with a shorter message ("refactor(web): preserve messaging seams after router extraction") and a DCO trailer under the noreply identity, whereas the actual repair commit f64b41b46e1 carries the full "refactor(web): extract messaging-platform catalog into web_routers/messaging #79128"-referencing message under the canonical author identity (Axl Ibiza, MBA <andrexibiza@gmail.com>). Recommend pushing from the actual repair commit so the PR linkage and attribution are preserved — the PR head is currently the older c0d75d6b1169.

Behavior-preserving modulo the two declared seam edits; offloads retained; previously-unrunnable suites all green. Part of #78647 / #78628.

@andrexibiza
andrexibiza force-pushed the fix/web-messaging-router-extract branch from c0d75d6 to f64b41b Compare August 18, 2026 13:27

andrexibiza commented Aug 19, 2026

Copy link
Copy Markdown
Contributor Author

Exact-head completion receipt for f64b41b46e17cd0bd253998ae23c490f6b62571b:

  • CI 32284415567: success.
  • Docker 32284414599: success.
  • Nix 32284414641: success.
  • GitHub: mergeable.
  • Unresolved inline review threads: 0.

The fresh close→reopen dispatch supersedes the earlier cancelled CI run. The legacy web_server symbol seam, profile-local startup/status projection, startup_failed behavior, late-bound monkeypatch ownership, and asyncio.to_thread boundaries are verified on the exact successful head.

Contributor-side implementation and CI residue are closed. Maintainer review/merge remains.

@andrexibiza andrexibiza changed the title refactor(web): extract messaging-platform catalog into web_routers/messaging (web_server.py god-file slice R4-C2C5) refactor(web): extract messaging-platform catalog into web_routers/messaging Aug 19, 2026
@andrexibiza andrexibiza reopened this Aug 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard comp/dashboard Web dashboard / control panel UI (dashboard/, landing) P3 Low — cosmetic, nice to have sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data type/refactor Code restructuring, no behavior change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants