Repository navigation
refactor(yapper): inject event DB URI provider; campus.yapper imports no campus packages - #981
Merged
Merged
Conversation
…imports (#970) Phase 2 of the campus-core carve: campus.yapper is now self-contained — it imports no campus package at all, so the lazy yapper<->auth cycle is gone at the source. create() resolves the event database URI in priority order: db_uri argument > db_uri_provider() callable > YAPPERDB_URI env var > remote campus vault via campus_python. The two branches that lazily imported campus.auth.resources to read the local vault (STORAGE_MODE=1 test mode and DEPLOY=campus.auth) are removed: the auth service now injects a provider backed by its own vault in get_yapper(), and test fixtures export the seeded URI as YAPPERDB_URI env for bare create() calls (the vault secret stays seeded for the vault-delivery contract). Test mode never contacts the remote vault: with no URI resolvable it raises instead of reaching the network (guards issue #319's class of bug). The boundary contract (test_package_boundaries) moves yapper out of SERVICE_LAYERS into SHARED_ALLOWED with zero allowed deps: emitters (auth, api) may import yapper; it must never grow campus dependencies back. New factory unit tests cover the resolution order and assert campus.auth stays unimported at runtime. Verified: import campus.yapper loads only campus.yapper; bare create() under test mode never loads campus.auth. Unit, contract, integration, ruff all green.
Adds docs/yapper.md: what the event bus is, the self-contained contract (no campus imports, boundary-enforced), the create() URI resolution order, per-caller recipes (api-style bare create, auth's injected provider, test fixtures), the removed DEPLOY=campus.auth special case, emit/handle usage, and the vault-delivery contract. Also corrects the three package-tree listings that still labelled yapper a 'Logging framework' (it is the event bus), adds yapper to campus/README's Services and Key Components, and records the 'yapper -> (nothing)' dependency rule in PACKAGING.md alongside the other constraints. The stale create() docstring TODO (issue #177, closed long ago) is resolved by the rewritten docstring in the previous commit.
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
force-pushed
the
refactor/yapper-creds-injection
branch
from
October 27, 2026 22:40
a5488bf to
fbd326e
Compare
This was referenced Oct 27, 2026
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.
Part of #970 — phase 2 (yapper↔auth cycle), single commit, base
weekly.Change
campus.yapperis now self-contained: it imports no campus package at all. The lazyfrom campus.auth import resourcescalls (the yapper↔auth cycle) are gone at the source, replaced by dependency injection at the DB-URI seam.create()resolves the event database URI in priority order:db_uriargumentdb_uri_provider()callable — the injection pointYAPPERDB_URIenvironment variable"campus.yapper"via campus_python (unchanged default for api's barecreate()in production)Client identity (CLIENT_ID/CLIENT_SECRET) stays env-driven, unchanged.
Callers
get_yapper()now injects a provider backed by its own in-process vault (vault["campus.yapper"]["YAPPERDB_URI"]), replacing theDEPLOY=campus.authenv special-case (branch deleted; yapper no longer consults DEPLOY). The ~40get_yapper().emit(...)call sites are untouched, and contract tests patchget_yapperby name — unaffected.campus.yapper.create()route calls are untouched: production still resolves via the remote vault; in test mode the fixture exports the seeded URI asYAPPERDB_URIenv.tests/fixtures/yapper.py) — still seed the vault secret (the vault-delivery contract and its integration test are unchanged) and additionally set the env var, with a comment explaining the split.Safety properties
STORAGE_MODE=1with no resolvable URI raisesValueErrorinstead of falling through to the remote vault (guards issue fix(integration): yapper backend tries to connect to external service in test mode #319's class of bug).test_package_boundaries.py): yapper moves out ofSERVICE_LAYERSintoSHARED_ALLOWEDwith zero allowed campus deps — emitters may import yapper; it must never grow campus dependencies back. Statically enforced.tests/unit/yapper/test_factory.pycovers the resolution order and asserts at runtime (subprocess) thatcreate()never loadscampus.auth.Verification
import campus.yapperloads onlycampus.yapper; barecreate()under test mode runs withcampus.authunimported. Unit, contract, integration, andruff check .all green.Note for reviewers: this is the injection fix from the phase-2 discussion on #970. The yapper-into-
campus.auditplacement idea was assessed and set aside (audit never imports yapper; the move would drag audit's init into every emitter and widen the cycle into auth⇄audit).