# 01. Project Foundation — Root Config & Directory Cleanup

meta:
  id: shieldai-unified-restructure-01
  feature: shieldai-unified-restructure
  priority: P0
  depends_on: []
  tags: [infrastructure, cleanup, foundation]

objective:
- Establish a clean project root with unified tooling, removing the fragmented packages/ + services/ split and preparing the workspace for a single monolithic web app plus native mobile projects.

deliverables:
- Updated root `package.json` with single workspace entry `web/`
- Updated `pnpm-workspace.yaml` to include `web/`, `iOS/ShieldAI`, `android/`, `browser-ext/`
- Updated `turbo.json` with tasks for web, browser-ext
- Remove or archive legacy `packages/`, `services/`, `server/` directories
- Ensure `web/` is the primary application workspace
- Root-level shared config files (`.nvmrc`, `.editorconfig`, `tsconfig.base.json` cleanup)

steps:
1. Backup `packages/`, `services/`, `server/` to a dated archive branch or tar.gz before removal.
2. Update root `package.json`:
   - Remove `workspaces` field referencing `packages/*` and `services/*`
   - Add `workspaces: ["web", "browser-ext"]` or use pnpm workspace syntax
   - Update scripts to reference `web/` directly (e.g., `"dev": "pnpm --filter web dev"`)
3. Update `pnpm-workspace.yaml`:
   ```yaml
   packages:
     - "web"
     - "browser-ext"
   ```
4. Update `turbo.json`:
   - Remove package-specific build outputs that no longer apply
   - Ensure `web#build`, `web#dev`, `web#test` are defined
   - Add `browser-ext#build` if needed
5. Clean root of obsolete files:
   - `check-identity.js`, `test-classifier.ts`, `test-maxpayload.ts`, `test-ws-maxpayload*.js` (move to web/ if still needed)
   - `docker-compose*.yml`, `Dockerfile` (will be recreated in task 42)
   - `infra/`, `load-tests/`, `docs/` (evaluate if content should move to web/docs or archive)
6. Verify `web/` has its own `package.json`, `vite.config.ts`, `tsconfig.json`, and can run independently.
7. Run `pnpm install` from root to regenerate lockfile and verify workspace resolves correctly.
8. Run `pnpm dev` from root and confirm web app starts on expected port.

tests:
- Unit: N/A (infrastructure task)
- Integration: `pnpm install` completes without workspace errors; `pnpm dev` starts web app; `pnpm build` in web/ succeeds
- E2E: N/A

acceptance_criteria:
- [ ] `pnpm-workspace.yaml` only references `web` and `browser-ext`
- [ ] `pnpm install` from root resolves dependencies cleanly
- [ ] `pnpm dev` starts the web app without errors
- [ ] `packages/`, `services/`, and `server/` are no longer in the working tree (archived or deleted)
- [ ] No broken references to removed directories in root config files

validation:
- Run `ls packages/ services/ server/` and confirm "No such file or directory" or they are empty placeholders
- Run `pnpm dev` and verify `http://localhost:3000` responds
- Run `pnpm build` inside `web/` and verify output in `web/.output/` or `web/dist/`

notes:
- Do NOT delete git history. Use `git mv` where possible, or archive via `git branch archive/legacy-$(date +%Y%m%d)` before deleting.
- The `web/` directory already exists (was `redux/`) and contains a SolidStart scaffold. We build from there.
- `iOS/ShieldAI` and `android/` are native projects and do not participate in the pnpm workspace; they are tracked as sibling directories.
