Skip to content

Commit 5acd0ce

Browse files
authored
refactor(routes): move contacts domain into routes/contacts/ subpackage (#5227)
Slice 2e of the route-domain reorganization (#4082/#4071, per specs/architecture-runtime-inventory.md §6.3). Moves contacts_routes.py into routes/contacts/, leaving a backward-compat sys.modules shim at the old path. Pure file reorganization, no behavior change. The shim uses sys.modules replacement (same pattern as the merged gallery #4903, research #4975, memory #5007, and history #5090 slices) so that `import routes.contacts_routes`, `from routes.contacts_routes import X`, `importlib.import_module(...)`, the string-targeted `monkeypatch.setattr("routes.contacts_routes.SETTINGS_FILE", ...)` used by test_carddav_password_encryption.py, and the `import ... as cr` + `setattr(cr, ...)` pattern in test_contacts_add_null_name.py all operate on the same module object the application uses. This also keeps the mutable module state `_contact_cache` identical across import paths. The canonical module does NOT depend on the shim — routes/contacts/ contacts_routes.py imports only from core/, src/, and stdlib (zero internal routes/ coupling). The inbound edge from routes/email_helpers.py (imports _fetch_contacts) keeps working through the shim. Zero source-introspection landmines — no test reads this file by path. Adds tests/test_contacts_routes_shim.py to pin the sys.modules shim contract (same-object + string-targeted monkeypatch reach-through). Verified: compileall clean; full suite 4485 passed, 3 skipped.
1 parent 9dc0d66 commit 5acd0ce

5 files changed

Lines changed: 968 additions & 897 deletions

File tree

app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -813,7 +813,7 @@ async def activity_heartbeat():
813813
app.include_router(setup_vault_routes())
814814

815815
# Contacts (CardDAV)
816-
from routes.contacts_routes import setup_contacts_routes
816+
from routes.contacts.contacts_routes import setup_contacts_routes
817817
app.include_router(setup_contacts_routes())
818818

819819
from companion import setup_companion_routes

routes/contacts/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
"""Contacts route domain package (slice 2e, #4082/#4071).
2+
3+
Contains contacts_routes.py, migrated from the flat routes/ directory.
4+
Backward-compat shim at routes/contacts_routes.py re-exports from here.
5+
"""

0 commit comments

Comments
 (0)