Hard-Remove Workflow
sharedModule packaging and permanent removal conventions.
Use this workflow only when scope is stable and soft-disable has already shipped successfully.
Objective
Permanently remove a module (commerce, rbac, notifications, wallet, observability)
without breaking:
- contract-first boundaries
- audience projection policy
- frontend feature-slice structure
- backend module wiring
Implementation conventions
1) Freeze profile decision
- Resolve profile flags first:
bun run profiles:resolve --profiles core,rbac --format env- Persist the selected profile set in project docs/runbook before removal PRs.
2) Remove composition entry points
- Backend:
- update module wiring and guards
- remove interface adapters/routes for the module
- Frontend:
- remove route adapters and feature entry exports
- remove sidebar/module flag references that are no longer valid
3) Remove contract surface
- Remove the module namespace from
libs/contracts/src/orpc/athas-orpc.contract.ts. - Remove backend oRPC implementation bindings for that namespace.
- Keep audience projections explicit for remaining endpoints.
4) Remove infrastructure internals
- Remove provider/repository/use-case files under module boundaries.
- Remove module-specific env schema entries if no longer needed.
- Remove package references/import paths that become orphaned.
5) Data layer cleanup
- Remove DB tables/migrations only with an explicit migration plan.
- Never delete production data paths without rollback strategy.
Verification gate
bun run typecheck
bun run depcruise:backend
bun run depcruise:frontend
bun run check:contract-first
bun run check:projection-policy
bun run check:module-profilesAutomation (observability pass 1)
For starter variants that exclude observability, use the hard-remove helper in a dedicated variant branch:
bun run profiles:hard-remove --profiles core,commerce --writeNotes:
- The command applies only when
observabilityresolves to disabled for backend/admin/client. - Run without
--writefirst for a dry-run preview. - After applying, run
bun installand the verification gate commands before creating the variant PR.
PR requirements
- Update roadmap task status in same PR.
- Update canonical docs in
apps/docs/content/docs. - Include explicit removed paths list in PR description.
Profile scaffolding support
Generate profile env bundles when preparing a scoped starter variant:
bun run scaffold:profile --profiles core,commerce --name commerce-starterGenerated files:
profiles/<name>/backend.envprofiles/<name>/admin.envprofiles/<name>/client.env