Skip to content

refactor(routes): move compare domain into routes/compare/ subpackage#5660

Merged
RaresKeY merged 1 commit into
odysseus-dev:devfrom
ydonghao:refactor/routes-compare-to-subdir
Jul 21, 2026
Merged

refactor(routes): move compare domain into routes/compare/ subpackage#5660
RaresKeY merged 1 commit into
odysseus-dev:devfrom
ydonghao:refactor/routes-compare-to-subdir

Conversation

@ydonghao

Copy link
Copy Markdown
Contributor

Summary

Slice 2i of the route-domain reorganization (Refs #4082 / #4071; inventory baseline in #4148). Moves the compare domain into routes/compare/, keeping a backward-compat sys.modules shim at the old path. Pure file reorganization, no behavior change.

Follows the same pattern as the merged gallery (#4903), research (#4975), memory (#5007), history (#5090), contacts (#5227), and note (#5236) slices.

What moves

From To
routes/compare_routes.py (365 lines) routes/compare/compare_routes.py

New routes/compare/__init__.py marks the subpackage. Compare is a single-file, LOW-complexity domain.

Backward compatibility

A backward-compat shim remains at routes/compare_routes.py, using sys.modules replacement so the import ... as cr + monkeypatch.setattr(cr, "SessionLocal", ...) / "_owned_endpoint_by_url" / "_owned_endpoint_by_id" pattern in test_endpoint_owner_scope_followup.py reaches the canonical module.

The canonical module imports only from core/, src/, and routes.session_routes — no dependency on the legacy shim.

Test repoints (1 site)

One source-introspection test reads the compare source by file path. Repointed from routes/compare_routes.pyroutes/compare/compare_routes.py:

  • test_endpoint_owner_scope_followup.py (shared with other domains; only the compare entry repointed here)

Shim regression test

Adds tests/test_compare_routes_shim.py to pin the sys.modules shim contract (same-object).

How to test

python -m compileall routes/compare/ routes/compare_routes.py app.py
python -m pytest tests/ -q

Full suite: 4676 passed, 3 skipped, 0 failed.

Target branch

  • This PR targets dev, not main.

Linked Issue

Follows the Phase 0 architecture refactor (#4082 / #4071) and the merged runtime inventory (#4148). One domain per PR per maintainer guidance.

Type of Change

  • Refactor / cleanup

Checklist

  • I searched open issues and open PRs — this is not a duplicate
  • This PR targets dev
  • My changes are limited to the scope described above — no unrelated refactors
  • No runtime behavior changes (pure file move + import shim)
  • Backward-compatible: old from routes.compare_routes import ... paths keep working via shim

Slice 2i of the route-domain reorganization (odysseus-dev#4082/odysseus-dev#4071). Moves
compare_routes.py into routes/compare/, leaving a backward-compat
sys.modules shim at the old path. Pure file reorganization, no behavior
change.

The shim uses sys.modules replacement so the `import ... as cr` +
`monkeypatch.setattr(cr, "SessionLocal", ...)` / `"_owned_endpoint_by_url"`
/ `"_owned_endpoint_by_id"` pattern in test_endpoint_owner_scope_followup.py
reaches the canonical module.

Canonical module imports only from core/, src/, and routes.session_routes
(zero dependency on the legacy shim). One source-introspection test site
repointed: test_endpoint_owner_scope_followup.py (shared with other domains;
only the compare entry repointed here).

Adds tests/test_compare_routes_shim.py to pin the sys.modules shim
contract. Verified: compileall clean; targeted tests pass.
@ydonghao

Copy link
Copy Markdown
Contributor Author

Friendly ping for review 👋

This is slice 2i of the route-domain reorg, one of three parallel low-risk slices (the others: #5658 cleanup, #5659 admin_wipe). Only the compare domain moves — a single-file, 365-line domain — into routes/compare/ behind the same sys.modules shim as all previous slices.

Both points from your #4903 review are baked in (canonical doesn't depend on shim; shim regression test included). One source-introspection test site repointed (test_endpoint_owner_scope_followup.py). CI fully green (pytest 4676 passed).

@RaresKeY @alteixeira20 — would you mind taking a look when you have a moment?

@RaresKeY RaresKeY left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I reviewed the latest head against the prior route-domain move pattern. The compare implementation is preserved byte-for-byte under the new canonical package path, app registration uses that path, and the legacy shim keeps old imports resolving to the same module object. I did not find any author-actionable issues.

Validation

  • Visible CI checks on this head passed.
  • Focused isolated tests passed (17 tests), the canonical-first legacy import probe passed, and the changed Python files compiled successfully.
  • I did not run a live application smoke test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready for review Description complete — ready for maintainer review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants