|
| 1 | +# PR_26171_ALFA_009 Team-Aware Bootstrap Report |
| 2 | + |
| 3 | +## Purpose |
| 4 | + |
| 5 | +Implement team-aware local dev bootstrap commands with role-aware port assignment while preserving the legacy local API command. |
| 6 | + |
| 7 | +## Reset Note |
| 8 | + |
| 9 | +Before rebuilding from clean `main`, the failed dirty attempt included: |
| 10 | + |
| 11 | +- `dev/reports/codex_changed_files.txt` |
| 12 | +- `dev/reports/codex_review.diff` |
| 13 | +- `dev/scripts/start-local-api-server.mjs` |
| 14 | +- `package.json` |
| 15 | +- untracked bootstrap reports |
| 16 | +- untracked `dev/scripts/start-dev.mjs` |
| 17 | +- untracked `dev/scripts/team-port-config.mjs` |
| 18 | +- untracked `dev/tests/dev-runtime/TeamAwareBootstrap.test.mjs` |
| 19 | + |
| 20 | +Per OWNER instruction, those uncommitted changes were discarded with `git reset --hard` and `git clean -fd`, then this branch was recreated from clean `main`. |
| 21 | + |
| 22 | +## Implementation Summary |
| 23 | + |
| 24 | +- Added `npm run dev:bootstrap`. |
| 25 | +- Added `npm run dev:api`. |
| 26 | +- Added `npm run dev:web`. |
| 27 | +- Preserved `npm run dev:local-api` unchanged as the legacy alias. |
| 28 | +- Added `dev/scripts/team-port-config.mjs` for full team name and role-aware port resolution. |
| 29 | +- Added `dev/scripts/start-dev.mjs` as the bootstrap orchestrator. |
| 30 | +- Added focused node tests for team resolution, role offsets, invalid team/role validation, script wiring, `.env` loading behavior, and bootstrap diagnostics. |
| 31 | +- Added automatic browser launch for owner-role `dev:bootstrap` after the API and web servers are both ready. |
| 32 | +- Skipped automatic browser launch for the `codex` role. |
| 33 | +- Fixed npm argument forwarding/parsing so both `--team charlie` and positional `charlie` select the same team after the package script's `--mode bootstrap` argument. |
| 34 | +- Treats `.env` `GAMEFOUNDRY_SITE_URL` and `GAMEFOUNDRY_API_URL` as legacy/default local values for bootstrap mode, then overwrites runtime URLs from the resolved team/role ports. |
| 35 | + |
| 36 | +## Supported Teams |
| 37 | + |
| 38 | +`owner`, `alfa`, `bravo`, `charlie`, `delta`, `echo`, `foxtrot`, `golf`, `hotel` |
| 39 | + |
| 40 | +## Supported Roles |
| 41 | + |
| 42 | +`owner`, `codex` |
| 43 | + |
| 44 | +## Port Mapping |
| 45 | + |
| 46 | +`owner` role uses base ports. `codex` role uses base ports plus 2. |
| 47 | + |
| 48 | +| Team | Owner Web | Owner API | Codex Web | Codex API | |
| 49 | +| --- | ---: | ---: | ---: | ---: | |
| 50 | +| owner | 5500 | 5501 | 5502 | 5503 | |
| 51 | +| alfa | 5510 | 5511 | 5512 | 5513 | |
| 52 | +| bravo | 5520 | 5521 | 5522 | 5523 | |
| 53 | +| charlie | 5530 | 5531 | 5532 | 5533 | |
| 54 | +| delta | 5540 | 5541 | 5542 | 5543 | |
| 55 | +| echo | 5550 | 5551 | 5552 | 5553 | |
| 56 | +| foxtrot | 5560 | 5561 | 5562 | 5563 | |
| 57 | +| golf | 5570 | 5571 | 5572 | 5573 | |
| 58 | +| hotel | 5580 | 5581 | 5582 | 5583 | |
| 59 | + |
| 60 | +## Commands Added |
| 61 | + |
| 62 | +```powershell |
| 63 | +npm run dev:bootstrap |
| 64 | +npm run dev:api |
| 65 | +npm run dev:web |
| 66 | +``` |
| 67 | + |
| 68 | +## Legacy Command Preserved |
| 69 | + |
| 70 | +```powershell |
| 71 | +npm run dev:local-api |
| 72 | +``` |
| 73 | + |
| 74 | +## Exact Startup Commands |
| 75 | + |
| 76 | +```powershell |
| 77 | +npm run dev:bootstrap -- --team owner |
| 78 | +npm run dev:bootstrap -- --team alfa |
| 79 | +npm run dev:bootstrap -- --team bravo |
| 80 | +npm run dev:bootstrap -- --team charlie |
| 81 | +npm run dev:bootstrap -- --team delta |
| 82 | +npm run dev:bootstrap -- --team echo |
| 83 | +npm run dev:bootstrap -- --team foxtrot |
| 84 | +npm run dev:bootstrap -- --team golf |
| 85 | +npm run dev:bootstrap -- --team hotel |
| 86 | +``` |
| 87 | + |
| 88 | +Codex role example: |
| 89 | + |
| 90 | +```powershell |
| 91 | +npm run dev:bootstrap -- --team alfa --role codex |
| 92 | +``` |
| 93 | + |
| 94 | +## Browser Launch Behavior |
| 95 | + |
| 96 | +- `owner` role launches the browser automatically to the selected team's `index.html`. |
| 97 | +- `codex` role skips browser launch. |
| 98 | +- Browser launch happens only after both API and web servers are ready. |
| 99 | +- The Alfa owner launch target is `http://127.0.0.1:5510/index.html`. |
| 100 | +- The Alfa codex browser launch is skipped while using web `5512` and API `5513`. |
| 101 | +- The Charlie launch target is `http://127.0.0.1:5530/index.html` for both `npm run dev:bootstrap -- --team charlie` and `npm run dev:bootstrap -- charlie`. |
| 102 | +- Computed team/role ports override any `.env` or inherited process `GAMEFOUNDRY_SITE_URL` / `GAMEFOUNDRY_API_URL` values loaded before bootstrap startup. |
| 103 | +- Bootstrap runtime sets `GAMEFOUNDRY_SITE_URL=http://127.0.0.1:<webPort>` and `GAMEFOUNDRY_API_URL=http://127.0.0.1:<apiPort>/api` after team/role resolution. |
| 104 | + |
| 105 | +## Files Changed |
| 106 | + |
| 107 | +- `package.json` - updated |
| 108 | +- `dev/scripts/start-dev.mjs` - added |
| 109 | +- `dev/scripts/team-port-config.mjs` - added |
| 110 | +- `dev/tests/dev-runtime/TeamAwareBootstrap.test.mjs` - added |
| 111 | + |
| 112 | +## Validation Summary |
| 113 | + |
| 114 | +All requested targeted validation passed. |
0 commit comments