Skip to content

Multi-cohort support with per-member initial balance#358

Open
crthpl wants to merge 18 commits intomainfrom
multi-cohort
Open

Multi-cohort support with per-member initial balance#358
crthpl wants to merge 18 commits intomainfrom
multi-cohort

Conversation

@crthpl
Copy link
Copy Markdown
Contributor

@crthpl crthpl commented Mar 5, 2026

Summary

  • Multi-cohort architecture: Routes are now per-cohort (/[cohort_name]/market, etc.), each cohort has its own SQLite database, and a global database tracks users/membership across cohorts
  • Per-member initial balance: Admins can configure an initial clip balance when adding members to a cohort. Falls back to legacy defaults (admin=100M, non-admin=0) when not set
  • Admin cohort detail page: Member management moved from inline on /admin to a dedicated /admin/cohorts/[name] page with user combobox, email batch add, and initial balance inputs
  • Python client update: metagame package updated for multi-cohort WebSocket endpoints (/api/ws/{cohort_name}) and cohort discovery via REST API
  • Default cohort config: New default_cohort_id setting for python client/scenarios server targeting

fixes: ARB-357 ARB-382

Test plan

  • Start dev.sh, login as admin, verify /admin shows cohort list with chevron links
  • Click a cohort to navigate to detail page, verify members load
  • Add a user with an initial balance, verify it's stored and displayed
  • Login as that user in the cohort, verify account is created with the configured balance
  • Add members by email with initial balance, verify persistence
  • NULL initial_balance preserves legacy defaults (admin=100M, non-admin=0)
  • Python client connects via cohort-specific WebSocket endpoint
  • Read-only toggle still works from both admin list and detail page

crthpl added 3 commits March 2, 2026 22:26
- Add global SQLite DB for users, cohorts, membership, and config
- Per-cohort WebSocket routes at /api/ws/:cohort_name
- REST endpoints for cohort listing and admin management
- Restructure frontend routes under /[cohort_name]/
- Cohort selection page with auto-redirect for single cohort
- Admin page for cohort/member/config management
- Public auction access with auction-only mode
- Cohort-scoped localStorage keys
- Legacy DB auto-migration support
Resolve conflicts:
- websocket_sudo.rs: drop removed market positions test
- api.svelte.ts: keep both auctionOnly and sudoEnabled
- +layout.svelte: keep stripped auth-only root layout
- market/+page.svelte: keep getCurrentCohort, drop scenariosApi
- Move performance page under [cohort_name]/
- Update scroll handler with hysteresis from main
… multi-cohort support

- Add initial_balance column to cohort_member table with migration
- Look up configured initial balance on account creation, falling back to legacy defaults (admin=100M, non-admin=0) when NULL
- Split member management into dedicated /admin/cohorts/[name] detail page
- Simplify admin page cohort list with navigation links
- Add default_cohort_id config option
- Update python client for multi-cohort WebSocket endpoints
@crthpl crthpl requested a review from a team as a code owner March 5, 2026 18:36
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 5, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
platform Ready Ready Preview, Comment Apr 8, 2026 8:51pm

Request Review

- Add create_if_missing param to DB::init_with_path
- Clean up global DB row if cohort DB init fails (prevents UNIQUE constraint on retry)
- Add existing_db checkbox to admin UI (fails if DB file doesn't exist)
- Add GlobalDB::delete_cohort for rollback
- Add apiBase.ts, CORS and cross-origin fixes
sqlite:///data/foo.sqlite should resolve to /data/, not data/
- Backend endpoint lists .sqlite files not yet used by cohorts
- Frontend shows them as buttons that fill the slug and check "use existing DB"
- CohortState.is_read_only is now AtomicBool, loaded per-message
- Admin toggle updates the atomic, no restart needed
- New migration adds email column to global_user
- ensure_global_user stores email from Kinde auth
- Cohort members query falls back to global_user email
- Admin "All Users" list shows emails and searches by email
- Display name editing for all users on accounts page (cross-cohort)
- Admin user management: edit names, toggle admin, delete users with confirm modals
- Account color coding: color field in proto/DB, color picker for admins, colored dots in act-as dropdown, colored header when acting as colored account
- Switch cohort button only shown with multiple cohorts, moved to sidebar footer
- Editable initial balance for non-instantiated cohort members
- Fix 404 on admin page reload (disable prerender/SSR for admin routes)
- Hide read-only toggle from main admin page (keep on cohort detail page)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant