refactor(server): extract the diagnostics routes into routers/diagnostics.py (R3) - #857
Merged
Merged
Conversation
Contributor
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
✅ Files skipped from review due to trivial changes (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughDiagnostics endpoints are extracted into a dedicated router with input normalization and payload caps. The application publishes its running version through appstate, mounts the router, preserves compatibility exports, and updates extraction documentation and size-exemption metrics. ChangesDiagnostics router extraction
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant Client
participant diagnostics_router
participant appstate
participant LoadedPlugins
participant diagnostics_bundle
Client->>diagnostics_router: POST /api/diagnostics/export
diagnostics_router->>appstate: Read runtime configuration and version
diagnostics_router->>LoadedPlugins: Snapshot loaded plugins under lock
diagnostics_router->>diagnostics_bundle: Build bundle with capped sections
diagnostics_bundle-->>diagnostics_router: Return ZIP bytes
diagnostics_router-->>Client: Return attachment response
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
byrongamatos
force-pushed
the
refactor/r3-router-diagnostics
branch
from
July 10, 2026 23:18
13dc6ad to
02044e5
Compare
…tics.py (R3) The three /api/diagnostics/* routes (export, preview, hardware) plus their exclusive payload-cap helpers and the `_diag_*` normalisers. Bodies verbatim except @app->@router, CONFIG_DIR->appstate.config_dir, _running_version()-> appstate.running_version() (a new seam slot; the impl stays in server.py where the settings region also calls it), and the builtin-plugins lookup in _diag_plugins_roots: Path(__file__).parent -> Path(__file__).resolve().parents[2] (routers -> lib -> app root; plugins/ ships at the app root in every packaging path). The pure caps/normalisers (_diag_cap_console/_dict/_contributions, _diag_coerce_bool, _diag_normalize_include, _DIAG_MAX_*) are re-exported from server.py so the existing `server._diag_*` / `server._DIAG_*` tests keep resolving — none of them monkeypatch these, so no test retargets. server.py: 7,216 -> 6,960. Verified: pyflakes clean (bar the intentional re-export lines); route table IDENTICAL (143); full pytest 2399 passed (77 diag/packaging + 122 diagnostic- matched cases incl the cap/coerce/normalize suites); eslint 0; Codex pending. Boot smoke: /hardware, /preview, and POST /export (200 application/zip) all serve from the new router location. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
byrongamatos
force-pushed
the
refactor/r3-router-diagnostics
branch
from
July 10, 2026 23:20
02044e5 to
358d5a9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The three
/api/diagnostics/*routes (export,preview,hardware) plus their exclusive payload-cap helpers and_diag_*normalisers →lib/routers/diagnostics.py.Bodies verbatim except
@app→@router,CONFIG_DIR→appstate.config_dir,_running_version()→appstate.running_version()(new seam slot; impl stays inserver.py, still called by the settings region), and the builtin-plugins lookup in_diag_plugins_roots:Path(__file__).parent→Path(__file__).resolve().parents[2](routers → lib → app root;plugins/ships at the app root in every packaging path).The pure caps/normalisers (
_diag_cap_console/_dict/_contributions,_diag_coerce_bool,_diag_normalize_include,_DIAG_MAX_*) are re-exported fromserver.pyso the existingserver._diag_*/server._DIAG_*tests keep resolving — none monkeypatch these, so no test retargets.server.py: 7,216 → 6,960.Verification
pyflakesclean bar the intentional re-export lines.pytest2399 passed (77 diag/packaging + 122diagnostic-matched cases incl the cap/coerce/normalize suites).npm run lint0; Codex 0 findings./hardware,/preview, andPOST /export(200application/zip) all serve from the new router location.🤖 Generated with Claude Code
Summary by CodeRabbit