Commit Graph

88 Commits

Author SHA1 Message Date
josh f3e6a2e692 Fix background music: bright lo-fi pad instead of horror ambient
CI / build-and-push (push) Successful in 46s
Moved chords up an octave (C4-E5 range), switched to triangle waves,
faster LFO rates, all major voicings, and higher filter cutoff. The
previous version with sub-bass sine drones and ultra-slow modulation
was genuinely terrifying.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-28 20:20:43 -04:00
josh d609934b73 Add working sound effects and background music via Web Audio API
CI / build-and-push (push) Successful in 1m17s
Synthesized audio system with 9 distinct SFX (click, success, warning,
danger, purchase, achievement, era transition, info) mapped to all game
notifications, plus generative ambient background music with chord
progressions. Adds SFX volume slider to settings alongside existing
music volume control. No audio files or npm dependencies needed.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-28 20:12:05 -04:00
josh 1e3d50719e Merge pull request 'Revitalize backend: working cloud saves, logout, and account UX' (#13) from feature/auth-invites into main
CI / build-and-push (push) Successful in 59s
Reviewed-on: #13
2026-04-28 19:34:37 -04:00
josh 2a6629af79 Revitalize backend: working cloud saves, logout, and account UX
Cloud saves were fully built but never wired up — useCloudSave() hook was
never called, no load-from-cloud flow existed, and there was no way to
continue a saved game. Logout was completely missing (no endpoint, no UI).
Accounts felt like a gate behind the invite wall rather than real accounts.

Backend: add tokenVersion to users for server-side token invalidation,
POST /auth/logout bumps it to revoke all JWTs, GET /auth/me returns
profile, GET /saves/latest returns most recent save with full gameData.
All createToken calls now include tokenVersion. Auth middleware rejects
tokens with stale tokenVersion.

Frontend: wire up useCloudSave() in App (auto-saves every 60 ticks with
error handling), fetch cloud save on startup for registered users, show
"Continue Your Game" card on NewGameScreen, add Log Out button with
confirmation in Settings, show username in sidebar, 401 interceptor
clears auth and reloads.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-28 19:32:03 -04:00
josh 5d30d1f4a1 Make dev menu (Ctrl+D) always available without localStorage gate
CI / build-and-push (push) Successful in 36s
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-28 12:29:46 -04:00
josh ce2cab3404 Merge pull request 'Fix admin seed, open username/email changes, invite refresh & revocation' (#11) from feature/auth-invites into main
CI / build-and-push (push) Successful in 51s
Reviewed-on: #11
2026-04-27 22:28:23 -04:00
josh 2912d760cb Fix admin seed, open username/email changes, invite refresh & revocation
- Seed checks for any admin role instead of username='admin'
- Username change open to all registered users (was admin-only)
- New change-email endpoint requiring password confirmation
- Settings page: inline editing for username and email
- Invitations: await refresh after generate so list updates visibly
- Invitations: revoke button to delete unused invites (admin only)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-27 22:22:42 -04:00
josh 035d4f0385 Merge pull request 'Rename AI Tycoon to Token Empire across entire codebase' (#10) from feature/auth-invites into main
Balance Check / balance-simulation (push) Successful in 41s
Balance Check / multi-run-balance (push) Successful in 14m22s
CI / build-and-push (push) Successful in 1m23s
Reviewed-on: #10
2026-04-27 21:08:36 -04:00
josh c1cc70eeb9 Rename AI Tycoon to Token Empire across entire codebase
Balance Check / balance-simulation (pull_request) Successful in 38s
Balance Check / multi-run-balance (pull_request) Successful in 13m44s
Full rebrand: UI display text, package scope (@ai-tycoon/* -> @token-empire/*),
localStorage keys, Docker/CI image paths, database names, and documentation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-27 21:04:07 -04:00
josh 5e4007160c Merge pull request 'Fix empty VITE_API_URL falling back to localhost in production' (#9) from feature/auth-invites into main
CI / build-and-push (push) Successful in 36s
Reviewed-on: #9
2026-04-27 20:51:19 -04:00
josh be93e57853 Fix empty VITE_API_URL falling back to localhost in production
Use ?? instead of || so empty string (same-origin) is preserved
while undefined still falls back to localhost:3001 for dev.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-27 20:50:34 -04:00
josh eca244f9d4 Merge pull request 'Fix double /api prefix causing invite gate bypass and broken API calls' (#8) from feature/auth-invites into main
CI / build-and-push (push) Successful in 37s
Reviewed-on: #8
2026-04-27 20:47:40 -04:00
josh fbedcec4f2 Fix double /api prefix causing invite gate bypass and broken API calls
VITE_API_URL was /api but all API paths already included /api/,
resulting in /api/api/config etc. Config call failed silently and
defaulted to requireInvite:false. Set VITE_API_URL to empty string
so paths like /api/auth/anonymous go through nginx as-is.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-27 20:45:13 -04:00
josh 95b43dceec Merge pull request 'Fix health check 404: add /api/health route, remove nginx /health proxy' (#7) from feature/auth-invites into main
CI / build-and-push (push) Successful in 1m13s
Reviewed-on: #7
2026-04-27 20:29:51 -04:00
josh 65afa886af Fix health check 404: add /api/health route, remove nginx /health proxy
Frontend API_BASE is /api in production, so health check was hitting
/api/health which didn't exist. Added /api/health on the server and
removed the now-unnecessary separate nginx /health proxy rule.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-27 20:22:00 -04:00
josh 01d9703aec Merge pull request 'Improve API error messages: show HTTP status, catch network errors' (#6) from feature/auth-invites into main
CI / build-and-push (push) Successful in 37s
Reviewed-on: #6
2026-04-27 20:14:13 -04:00
josh 7348b35475 Improve API error messages: show HTTP status, catch network errors
"Unknown error" was hiding the actual HTTP status (likely 502 from
nginx). Now shows "HTTP 502 Bad Gateway" etc. Network TypeErrors
(connection refused) also get a clear message.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-27 20:03:34 -04:00
josh 8e5dca471e Merge pull request 'Add nginx reverse proxy for /api and /health to backend server' (#5) from feature/auth-invites into main
CI / build-and-push (push) Successful in 1m4s
Reviewed-on: #5
2026-04-27 20:00:16 -04:00
josh 6cf5bf76b3 Add nginx reverse proxy for /api and /health to backend server
The frontend builds with VITE_API_URL=/api so all API calls target
the same origin. Without a proxy rule, nginx was serving index.html
for API paths, causing JSON parse errors.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-27 19:59:32 -04:00
josh cc27c00991 Merge pull request 'Add backend health check, fetch timeouts, stale token cleanup, and error screen' (#4) from feature/auth-invites into main
CI / build-and-push (push) Successful in 39s
Reviewed-on: #4
2026-04-27 19:56:53 -04:00
josh 2ab097ec8a Add backend health check, fetch timeouts, stale token cleanup, and error screen
Frontend now checks /health before starting auth flow. Shows a clear
"Cannot Connect to Server" screen with retry button when backend is
unreachable. Stale non-JWT tokens in localStorage are detected and
cleared automatically. All API calls have a 10s timeout via AbortController.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-27 19:55:50 -04:00
josh c0965cb7d7 Merge pull request 'Add auto-migration on server startup' (#3) from feature/auth-invites into main
CI / build-and-push (push) Successful in 45s
Reviewed-on: #3
2026-04-27 19:43:38 -04:00
josh 066c3310ff Add auto-migration on server startup
Run Drizzle migrations before seeding admin user so tables exist
on fresh database. Migration files generated from current schema.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-27 19:41:10 -04:00
josh 5f7b728463 Merge pull request 'Fix Docker production build: move tsx to dependencies, reinstall in production stage' (#2) from feature/auth-invites into main
CI / build-and-push (push) Successful in 1m19s
Reviewed-on: #2
2026-04-27 19:34:39 -04:00
josh a061337d6f Fix Docker production build: move tsx to dependencies, reinstall in production stage
The production Docker stage was copying pnpm symlinks between stages
which broke module resolution. Now does a fresh pnpm install --prod
in the production stage and runs from the server working directory.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-27 19:33:16 -04:00
josh b0c552562a Merge pull request 'Add auth system with invite-only registration and admin roles' (#1) from feature/auth-invites into main
CI / build-and-push (push) Successful in 1m21s
Reviewed-on: #1
2026-04-27 19:26:15 -04:00
josh 4881907c28 Add auth system with invite-only registration and admin roles
JWT-based auth (hono/jwt + bcrypt), anonymous-first flow preserved.
Registration requires invite code when REQUIRE_INVITE=true. Admin
user seeded on startup (admin/admin, forced password reset). Login
accepts email or username. Admin invitations management page in
sidebar. Regular users get invite-a-friend button when USER_INVITATIONS > 0.
Frontend gate screen blocks game access for unregistered users with
invite code entry, registration, login, and password reset flows.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-27 19:25:16 -04:00
josh df01ac8e35 Move revenue after churn and raise price churn cap to prevent exploit
Balance Check / balance-simulation (push) Successful in 2m1s
CI / build-and-push (push) Successful in 2m6s
Balance Check / multi-run-balance (push) Successful in 13m10s
Churned subscribers no longer generate revenue the tick they leave,
and the price churn multiplier cap is raised from 10 to 1000 so
astronomical prices empty the subscriber pool in a single tick.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-26 22:17:30 -04:00
josh 63e56dc229 Fix consumer subscription pricing exploit with perceived-value-based elasticity
Balance Check / balance-simulation (push) Successful in 51s
Balance Check / multi-run-balance (push) Successful in 13m19s
CI / build-and-push (push) Successful in 45s
Players could set astronomical prices and still retain subscribers because
price elasticity floored at 10% for any price above $100, satisfaction
ignored pricing entirely, and churn had no price component.

Introduces perceived value per tier (model quality × reputation), replaces
the broken linear formula with sigmoid decay, adds price-aware satisfaction
blending, and applies per-tier price-based churn multipliers.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-26 21:51:03 -04:00
josh 5aa9436368 Expand multirun reporting: health summary, era durations, serving diagnostics, cash-flow detail
Balance Check / balance-simulation (push) Successful in 46s
Balance Check / multi-run-balance (push) Successful in 14m6s
CI / build-and-push (push) Successful in 46s
Propagate per-era duration/bottleneck, serving utilization, cash-flow nadir/peak,
and late-game revenue growth through the worker→CSV→interpret pipeline. Add
simulation health archetype classification, per-era bottleneck frequency,
unused-feature frequency table, failed-run AGI gate analysis, and log-scale
variance for exponential metrics. All new CSV columns parse defensively for
backward compatibility with older summary files.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-26 20:55:49 -04:00
josh 62998d6cb2 Remove duplicate per-run completion line from worker stderr
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-26 20:21:38 -04:00
josh a240ba2e44 Scale CI multi-simulation to 100 runs, remove per-run progress ticker
Balance Check / balance-simulation (push) Successful in 42s
Balance Check / multi-run-balance (push) Successful in 13m37s
CI / build-and-push (push) Successful in 43s
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-26 20:11:49 -04:00
josh 19f652b43a Replace per-switch network simulation with aggregate per-DC statistical model
Balance Check / balance-simulation (push) Successful in 48s
Balance Check / multi-run-balance (push) Successful in 1m24s
CI / build-and-push (push) Successful in 43s
Eliminates the 22K-object switchRegistry that caused O(n×m) scans 4x per tick.
Network health is now tracked as aggregate counts per tier (totalByTier/healthyByTier)
with RepairBatch timers, cutting late-game tick cost from ~50ms to ~0.3ms.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-26 20:06:40 -04:00
josh 57a81be769 Cache serving pipeline fleet to eliminate per-tick rebuilds and reduce GC pressure
Fleet template is now rebuilt only when deploymentVersion changes (~68 times per
28,800-tick run instead of every tick). Reuses module-level Maps, arrays, and
utilization objects instead of allocating new ones each tick. Replaces 4x
Object.values().reduce() with single-pass aggregation and sorts fleet in-place.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-26 19:51:13 -04:00
josh bbb69a315c Remove benchmark evaluation system, use training capabilities directly
Model quality for market segments and product lines now derives from deployed
model capabilities (coding, reasoning, agents, etc.) instead of requiring a
separate manual benchmark evaluation step. This eliminates an unbounded
benchmarkResults[] array that was scanned 5x per tick and removes ~480 lines
of dead-weight UI, types, and engine code.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-26 19:28:59 -04:00
josh db034687d6 Add real-time progress feedback to multi-run simulations
Balance Check / balance-simulation (push) Successful in 11m24s
Balance Check / multi-run-balance (push) Successful in 26m35s
CI / build-and-push (push) Successful in 34s
Switch from exec() to spawn() for streaming stderr, add onProgress
callback to runner, and emit per-run progress lines from workers.
CI now shows live percentage, tick count, and era during long runs.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-26 17:42:45 -04:00
josh 04d8a4e883 Update .gitea/workflows/balance-check.yml
CI / build-and-push (push) Successful in 17s
2026-04-26 17:08:45 -04:00
josh 416b6bfe8d Add research money costs, longer research times, era-scaled talent costs, and persona strategy
Balance Check / balance-simulation (push) Successful in 11m19s
Balance Check / multi-run-balance (push) Has been cancelled
CI / build-and-push (push) Successful in 40s
Research now costs money (drained per-tick) with ~2.5-3.5x longer durations by category.
Early-game talent budget costs reduced via era multiplier (startup 0.2x → bigtech 1.0x).
New seed-driven PersonaStrategy with 8 axes of variation for meaningful multi-run testing.
CI multi-run switched from greedy to persona strategy.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-26 16:14:27 -04:00
josh b906592af4 Redesign system interconnections display: group by health, inline diagnoses
Balance Check / balance-simulation (push) Successful in 6m53s
Balance Check / multi-run-balance (push) Successful in 20m40s
CI / build-and-push (push) Successful in 27s
Remove misleading Reputation -> Era Gates connection (score 0 meant
"already sufficient," not broken). Add diagnosis and eventLabel fields
to each connection. Group output: broken links first with [!!] and
plain-language explanation, then healthy links as compact one-liners.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-26 13:00:41 -04:00
josh d47afd8542 Fix CI interpret step using wrong relative path for summary CSV
CI / build-and-push (push) Successful in 14s
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-26 12:25:10 -04:00
josh 6105c28887 Fix research complete notification using raw ID instead of display name
Balance Check / balance-simulation (push) Successful in 6m37s
Balance Check / multi-run-balance (push) Failing after 20m20s
CI / build-and-push (push) Successful in 33s
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-26 12:22:17 -04:00
josh a8746246f8 Add Vitest test suite with 184 tests covering all game engine systems
Balance Check / balance-simulation (push) Successful in 7m0s
Balance Check / multi-run-balance (push) Failing after 20m5s
CI / build-and-push (push) Successful in 1m18s
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-26 09:41:56 -04:00
josh 1f50f6c86c Fix crash on existing saves missing researchQueue by merging persisted state with defaults
CI / build-and-push (push) Successful in 27s
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-26 08:41:54 -04:00
josh cc606ae523 Fix balance-check CI: remove node cache, random sim, and unsupported artifact uploads
CI / build-and-push (push) Successful in 12s
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-26 08:19:40 -04:00
josh 5885e33531 Add research queue: queue multiple projects, auto-promote on completion, RP refund on dequeue
Balance Check / multi-run-balance (push) Has been cancelled
Balance Check / balance-simulation (push) Has been cancelled
CI / build-and-push (push) Successful in 28s
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-26 08:16:16 -04:00
josh 626ca51041 Fix community size ballooning to infinity with logistic growth damping
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-26 08:16:02 -04:00
josh 102e05c8ba Add game-simulation package with multi-run balance testing, fix stalled-pipeline trap
Balance Check / balance-simulation (push) Failing after 11m32s
Balance Check / multi-run-balance (push) Failing after 23m46s
CI / build-and-push (push) Successful in 1m20s
Adds a full simulation harness (game-simulation package) with greedy/random strategies,
36-metric diagnostics, multi-run orchestration via child processes, and a statistical
interpreter. Includes 2.3x engine performance optimizations (research bonus caching,
per-DC dirty tracking, reduced allocations in tick pipeline, single-pass loops).

Fixes a critical balance bug where training pipelines stalled on insufficient VRAM would
permanently block training slots — the engine never re-checked stalled pipelines, and the
greedy strategy didn't pre-check VRAM requirements. This caused 20-25% of seeds to get
stuck in Scale-up era. All three fixes (engine un-stalling, strategy VRAM pre-check,
stalled pipeline cancellation) bring pass rate from 75% to 100% across 20 random seeds.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-26 06:11:26 -04:00
josh 283c7c7932 Overhaul dashboard into command center with compute tracking, era-gated sections
CI / build-and-push (push) Successful in 37s
Add compute history time-series (capacity vs demand chart), revenue vs expenses
dual-line chart, enhanced system status (training allocation, network uptime,
model freshness), active operations panel, market position bars, and competitor
snapshot. Stat cards expand from 3 to 6 as player progresses through eras.
Graceful v9→v10 save migration preserves existing games.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-25 13:45:16 -04:00
josh 901db02a6b Replace decorative overload policy with real serving pipeline and dedicated Serving page
CI / build-and-push (push) Successful in 28s
The old overload policy had dead controls (maxQueueDepth, rateLimitPerCustomer never read)
and trivial flat penalties. This replaces it with a full serving pipeline where deployed
models form a fleet, requests route through priority/degradation logic, and policy choices
create meaningful strategic tradeoffs.

New serving pipeline: fleet building from deployed models (size/quant/MoE multipliers),
demand categorization by 5 priority tiers, enterprise capacity reservation, priority-ordered
serving with overflow behaviors (queue/reject/degrade), auto-degradation to faster models
under load, and Batch API to fill idle capacity at discounted rates.

4 new research nodes gate features progressively: Intelligent Request Routing, Priority
Queue System, Request Batching, and Auto-Scaling. New dedicated Serving page with pipeline
metrics, model fleet utilization, and research-gated policy controls.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-25 12:42:09 -04:00
josh d7d77238b9 Redesign model lifecycle: upfront SFT/alignment, multi-size families, point releases, quantization-only variants
CI / build-and-push (push) Successful in 45s
Training pipeline now requires SFT specializations and alignment method configured at start — no more
mid-training configuration step. Model families support multiple size tiers (Nano/Small/Medium/Large/Flagship)
trained independently, mimicking real AI company model families. Point releases iterate on deployed models
with 40% training time and 8% capability gain. Distillation and fine-tuning variants removed — players
train smaller size tiers or configure SFT during initial training instead. Only quantization remains as
a variant type.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-25 11:00:38 -04:00