Repository navigation
test: package boundary contracts for the campus-core carve - #977
Merged
Merged
Conversation
Encodes the layering agreed on #970 as executable rules: - AST: shared layers (common, config, model, storage, webauth, services) may depend only on SHARED_ALLOWED campus layers, must never import a service layer (even lazily), and must keep flask/werkzeug out of module level; campus.common's only allowed module-level third-party import is bcrypt (utils/secret). - Runtime: importing campus.storage must not load psycopg2, pymongo, or boto3 (drivers stay per-backend lazy). Relative imports resolve to absolute campus-rooted targets: the resolver anchors at the file's containing package, so rule violations written as 'from ..audit import ...' are caught too (both sides mutation-verified: a module-level 'import flask' and a relative service-layer import in campus/model/base.py each fail with the exact file/line/rule). If these stay green, phase 3 packaging is mechanical.
nycomp
force-pushed
the
test/package-boundaries
branch
from
October 27, 2026 15:52
2741f43 to
efc38a5
Compare
3 tasks
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.
Closes the contract-tests line of #970 (phase 1). Stack: 3/3 on #976 (which needs #975) — CI runs per link.
Change
tests/unit/test_package_boundaries.pyencodes the layering agreed on #970 as executable rules, so the phase-3 distribution split stays mechanical:AST rules (shared layers: common, config, model, storage, webauth, services):
SHARED_ALLOWED(e.g. storage → common+model; common → nothing);auth,api,audit,yapper,flask_campus,deploy) — module level or lazy;campus.common's only allowed module-level third-party import is bcrypt (utils/secret.py) — keepsrequestsfrom ever riding back in.Runtime rule:
campus.storagemust not loadpsycopg2/pymongo/boto3(drivers stay per-backend lazy; subprocess-based, since the test process may have them loaded).These rules are green on today's tree — the phase-0 work (#972/#973) and the #976 move are exactly what made that true. Mutation-verified: a module-level
import flaskadded tocampus/model/base.pyfails with the exact file/line/rule, then the tree reverts clean.Verification
Full unit (842), contract, integration, and
ruff check .green at this tip.