Files
Kordant/tasks/kordant-unified-restructure/41-cleanup-legacy.md
2026-05-25 22:49:37 -04:00

6.1 KiB

41. Cleanup — Remove Legacy packages/, services/, and server/ Directories

meta: id: kordant-unified-restructure-41 feature: kordant-unified-restructure priority: P0 depends_on: [kordant-unified-restructure-26, kordant-unified-restructure-27] tags: [cleanup, infrastructure, migration]

objective:

  • Safely remove all legacy directories that are no longer needed after the unified restructure. Ensure no functionality is lost and all important code has been migrated to the new monolithic architecture.

deliverables:

  • Archived legacy code (optional but recommended):
    • Git branch archive/legacy-pre-restructure containing full state before cleanup
    • Or tar.gz archive in archives/ directory
  • Removed directories:
    • packages/ — all subdirectories (api, core, correlation, db, extension, integration-tests, jobs, mobile, mobile-api-client, monitoring, report, shared-analytics, shared-auth, shared-billing, shared-db, shared-notifications, shared-ui, shared-utils, types, web)
    • services/ — all subdirectories (darkwatch, hometitle, removebrokers, spamshield, voiceprint)
    • server/ — alerts and webrtc subdirectories
    • infra/ — infrastructure configs (if not moved to web/ or docs/)
    • load-tests/ — load testing scripts (if not moved)
    • docs/ — evaluate and either move to web/docs/ or archive
  • Updated root configuration:
    • package.json with clean scripts referencing only web/ and browser-ext/
    • pnpm-workspace.yaml with only web and browser-ext
    • turbo.json with only relevant tasks
    • .gitignore cleaned of legacy entries
    • README.md updated to reflect new architecture
  • Verification checklist confirming:
    • All Fastify routes migrated to tRPC routers
    • All service logic migrated to web/src/server/services/
    • All Prisma schema migrated to Drizzle
    • All web pages migrated to new web/ app
    • All extension code migrated to browser-ext/
    • No broken imports or references to removed directories

steps:

  1. Create archive:
    • git branch archive/legacy-pre-restructure (from current HEAD)
    • Or tar -czf archives/legacy-$(date +%Y%m%d).tar.gz packages/ services/ server/ infra/ load-tests/
  2. Verify migration completeness:
    • Checklist: go through each legacy directory and confirm its contents have been migrated
    • packages/api/src/routes/web/src/server/api/routers/
    • packages/db/prisma/schema.prismaweb/src/server/db/schema.ts
    • packages/web/src/web/src/ (pages, components, hooks)
    • packages/extension/src/browser-ext/src/
    • services/*/src/web/src/server/services/*/
    • packages/jobs/src/web/src/server/jobs/
    • packages/shared-*/src/ → merged into web/src/server/services/ or web/src/lib/
  3. Remove directories:
    • rm -rf packages/
    • rm -rf services/
    • rm -rf server/
    • rm -rf infra/ (or move relevant files)
    • rm -rf load-tests/ (or move relevant files)
    • rm -rf docs/ (or move to web/docs/)
  4. Clean root files:
    • Remove check-identity.js, test-classifier.ts, test-maxpayload.ts, test-ws-maxpayload*.js (if not moved)
    • Remove docker-compose.yml, docker-compose.prod.yml, Dockerfile (will be recreated in task 42)
    • Remove vite.config.ts at root (only needed in web/)
    • Remove vitest.config.ts at root (only needed in web/)
    • Remove tsconfig.base.json, tsconfig.json at root (only needed in web/)
  5. Update root configs:
    • package.json: update scripts, remove legacy dependencies
    • pnpm-workspace.yaml: confirm only web and browser-ext
    • turbo.json: update tasks for new structure
    • .gitignore: remove entries for deleted directories
  6. Update README.md:
    • New architecture diagram (unified monolith)
    • Updated directory structure
    • Updated setup instructions
    • Migration notes
  7. Run full verification:
    • pnpm install from root
    • pnpm dev starts web app
    • pnpm build in web/ succeeds
    • pnpm test in web/ passes
    • cd browser-ext && pnpm build succeeds
    • No references to packages/, services/, or server/ in any file
  8. Commit cleanup with clear message.

steps:

  • Integration: pnpm install completes without errors
  • Integration: pnpm dev starts unified web app
  • Integration: pnpm build produces valid output
  • Integration: pnpm test passes all tests
  • Search: grep -r "packages/\|services/\|server/" --include="*.ts" --include="*.tsx" --include="*.json" --include="*.md" . returns only expected references (e.g., in README migration notes)

acceptance_criteria:

  • Legacy directories are removed from working tree
  • Archive branch or tar.gz exists with full legacy state
  • Root package.json only references web/ and browser-ext/
  • pnpm-workspace.yaml only includes web and browser-ext
  • pnpm install resolves dependencies cleanly
  • pnpm dev starts the unified app without errors
  • pnpm build succeeds for web app
  • pnpm test passes for web app
  • No broken imports or references to removed directories
  • README is updated with new architecture and setup instructions

validation:

  • ls packages/ services/ server/ → "No such file or directory"
  • git branch -a | grep archive → shows archive branch
  • pnpm install && pnpm dev → web app starts on localhost:3000
  • cd web && pnpm build → completes successfully
  • cd web && pnpm test → all tests pass
  • grep -r "@kordant/" --include="*.ts" --include="*.tsx" . → no references to old workspace packages

notes:

  • Do NOT delete git history. The archive branch preserves everything.
  • If any legacy file is discovered to be needed after cleanup, it can be retrieved from the archive branch.
  • The docs/ directory may contain valuable documentation. Review contents before deleting — move relevant docs to web/docs/ or root README.
  • examples/ and assets/ at root should also be reviewed and either moved or deleted.
  • This is a destructive operation. Double-check the migration checklist before executing.
  • Consider keeping plans/ directory if it contains active project plans. Move to docs/plans/ if needed.