feat(m7.2-D): drop transitional agent.db, add admin helpers #89
Reference in New Issue
Block a user
Delete Branch "feat/m7.2d-drop-legacy-db"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Final slice of M7.2. Removes the transitional single-database handle that M7.2-A introduced alongside the pool, so
compliance-agentnow has a single source of truth for storage: every code path obtains a tenant-scopedDatabasefromagent.db_pool.for_tenant_id(...)orfor_tenant(&ctx). There is no shared "default" database anywhere.Stacked on PR-C (#88) — diff shown is only D's changes.
Changes
ComplianceAgent.db: Databasefield removed.ComplianceAgent::newnow takes only(config, db_pool). Verified by a grep during M7.2-C that no remaining call site readsagent.db.main.rsstops constructing the legacyDatabase. Only the pool is built at startup.TestServersame — dropsDatabase::connect/ensure_indexes, builds only the pool.cleanup()now drops every<db_name>_*per-tenant database (no longer touches a bare<db_name>).DatabasePool::list_tenant_db_names()— lists Mongo databases matching the pool's prefix. For admin endpoints + scheduler tenant enumeration in a future M7.3 (this PR keepsSCHEDULER_TENANT_IDSenv config — registry integration is a separate concern).DatabasePool::drop_tenant(&str)— idempotent tenant offboarding. Drops the per-tenant database and evicts the in-memoryensuredmarker so a later re-provision re-runsensure_indexes. GDPR delete in one call.Test plan
cargo fmt --all -- --checkcleancargo clippy --workspace --exclude compliance-dashboard -- -D warningscleancargo test -p compliance-core --lib— 7 passcargo test -p compliance-agent --lib— 228 passcargo test -p compliance-agent --test tenant_isolation— 6 pass including the newadmin_helpers_list_and_drop_tenant_dbswhich:list_tenant_db_namesreturns bothdrop_tenantcargo test -p compliance-agent --test tenant_status_middleware— 6 passM7.2 closeout state after this lands
Future M7.3 (not in this PR)
SCHEDULER_TENANT_IDSenv.list_tenant_db_names/drop_tenant(likely behind a separate auth path — service account, not customer JWT).🤖 Generated with Claude Code
Superseded — the M7.2 stack was inadvertently included in PR #90 squash-merge (
5648291) on main. The dashboard PR was branched off this PR's descendant and its full diff swept into main as one squash commit. M7.2-A through M7.2-D are all live on main and in production. Closing without merging.Pull request closed