Skip to content

refactor(audit): move campus.common.http to campus.audit.http - #976

Merged
ngjunsiang merged 1 commit into
fix/harness-sdk-authorizationfrom
refactor/audit-http-move
Oct 27, 2026
Merged

ngjunsiang merged 1 commit into
fix/harness-sdk-authorizationfrom
refactor/audit-http-move

Conversation

@nycomp

@nycomp nycomp commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

Closes the http-move line of #970 (phase 1). Stack: 2/3 — needs #975 (harness sdk-#119 fix) below it; followed by the boundary-contract tests.

Change

campus/common/http → campus/audit/http (git mv, tracked as renames). The client's only production consumers were the audit service (audit.client, audit.web.auth) plus the cross-service test harness seam — audit domain, not shared infrastructure. The harness's monkeypatch target moves with the seam (tests/flask_test/json_client.py patches campus.audit.http.DefaultClient), and the TESTING-GUIDE / audit-tracing docs are updated.

campus.common.__init__ drops http from __all__ and the PEP 562 __getattr__ shim — no consumer used from campus.common import http; everyone imports the submodule path directly, so nothing breaks.

Effect

requests leaves campus.common's dependency list entirely — the only remaining third-party import at module level in the whole namespace is bcrypt (utils/secret.py, kept per #969). Measured at the tip of the stack (fresh interpreter):

Import Heavy modules loaded
import campus.common none (requests, bcrypt both gone from the eager chain)
import campus.storage bcrypt only (drivers still lazy)
import campus.audit.http (on demand) requests (+ the audit service's own init)

Test updates

  • tests/unit/common/test_import_weight.py: keeps the lean-import guard; replaces the getattr test with an attribute-access assertion (campus.common.http must raise AttributeError). Import-based assertions are fragile here: an import succeeds as an empty namespace package whenever a leftover campus/common/http directory exists on the path (untracked __pycache__ does this after branch switches) — learned the hard way, documented in the test.
  • Import-order fixes in the three files the path change unsorted (ruff I001; autofixes disabled repo-wide).

Verification

Unit (842), contract, integration, and ruff check . all green at the tip of the stacked series; contract exercises the moved harness seam end-to-end.

The HTTP client's only production consumers were the audit service
(audit.client, audit.web.auth) plus the cross-service test harness
seam, making it audit domain rather than shared infrastructure. With
the move, requests leaves campus.common's dependency list entirely:
campus-common's only third-party dep is now bcrypt (via utils.secret).

Mechanical move (git mv), import-path updates in audit client/web,
the flask_test harness (monkeypatch target moves with the seam), unit
tests, and the TESTING-GUIDE / audit-tracing docs. campus.common drops
the http shim and __getattr__.
@nycomp
nycomp force-pushed the refactor/audit-http-move branch from 2881b74 to bea1f4e Compare October 27, 2026 15:52
@ngjunsiang
ngjunsiang merged commit 5909847 into weekly Oct 27, 2026
22 checks passed
@nycomp
nycomp deleted the refactor/audit-http-move branch October 27, 2026 16:00
nycomp pushed a commit that referenced this pull request Oct 27, 2026
Repo-wide check of all 172 campus modules: every module docstring's
first line must be the module's dotted path. Fixes 18 stale ones
(legacy pre-reorg paths like campus.apps.api.routes.* and
campus.auth.routes.* that survived the oauth_proxy/resources moves,
singular/plural drift like routes.booking -> routes.bookings and
routes.api_keys -> routes.apikeys, a missing campus. prefix, and a
stray .py suffix), normalizes two descriptive-first docstrings
(audit.helpers.audit_events, logging_config), and adds the two missing
module docstrings (flask_campus.utils, model.booking).

Docs module-reference sweep found no stale module paths: the
campus.common.http mentions are deliberate history notes on the #976
move, and campus.test / campus.with_user_session in the guides are a
test URL and the Campus-client instance method respectively, not
modules.
nycomp pushed a commit that referenced this pull request Oct 27, 2026
Repo-wide check of all 172 campus modules: every module docstring's
first line must be the module's dotted path. Fixes 18 stale ones
(legacy pre-reorg paths like campus.apps.api.routes.* and
campus.auth.routes.* that survived the oauth_proxy/resources moves,
singular/plural drift like routes.booking -> routes.bookings and
routes.api_keys -> routes.apikeys, a missing campus. prefix, and a
stray .py suffix), normalizes two descriptive-first docstrings
(audit.helpers.audit_events, logging_config), and adds the two missing
module docstrings (flask_campus.utils, model.booking).

Docs module-reference sweep found no stale module paths: the
campus.common.http mentions are deliberate history notes on the #976
move, and campus.test / campus.with_user_session in the guides are a
test URL and the Campus-client instance method respectively, not
modules.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants