towerdef/docs/NEXT.md
Claude 72c49eee1f Wrap up: review findings, balance baseline, bot tool and next-session notes
- docs/NEXT.md: where to pick up, prioritised, with the known wall-selling bug
  and its two-line fix
- docs/review-2026-10-09/: 85 reviewer findings (touch, co-op, client code,
  visual, reverse proxy) with verification status, repro scripts archive and
  the review workflow script; nothing fixed yet by design
- docs/BALANCE.md + tools/bot.js: headless balance bot and the untuned baseline
  (IDS Sniper dominates, maze is a near-guaranteed win, credits snowball)
- test/sim.test.js derives tunable numbers from the tables, plus a shape test
- README status note

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tb8pW2KAN4oFkh1aK1BfD8
2026-10-09 21:38:59 +00:00

79 lines
6.7 KiB
Markdown

# Where to pick up (written 2026-10-09)
Netwall is playable and pushed: solo (desktop + phone), two-player co-op through the Node server, music, PWA, deploy docs.
Development was paused on purpose before the fix stage. This file is the entry point for the next session.
## State of the repo
| Area | State |
|---|---|
| `public/js/sim.js` | Shared rules. 20 unit tests. **Balance not tuned yet** (see `docs/BALANCE.md`). |
| `server/` | Done and reviewed by an independent adversarial pass (5 real issues found and fixed: pid leak/slot hijack, room-flood lockout, spoofable X-Forwarded-For, startup crash in restricted sandboxes, clock-step in rate limiter). 59 tests. |
| `public/` client | Works, but a second review pass found many issues. **None fixed yet.** See `docs/review-2026-10-09/findings.md`. |
| `e2e/` | `npm run e2e`: smoke, touch, end flow, co-op (two browsers incl. reconnect), 14-size layout matrix. All passed at the last run. |
| `tools/bot.js` | Headless balance bot (dev tool). Complete; its results are summarised in `docs/BALANCE.md`. |
| Deploy | `docs/DEPLOY.md`, `deploy/netwall.service`, README setup guide. Never run against a real nginx Proxy Manager or on a phone yet (an NPM-style review found doc inaccuracies, listed in the findings). |
`npm test` = 80 passing (20 sim + 59 server + 1 balance-table shape test). Verified from a fresh `git clone`.
## KNOWN BUG in the pushed build (fix first, it is two lines)
**Selecting a placed Firewall throws a TypeError, so walls cannot be sold** (finding `visual-1`, confirmed).
Cause: `renderInfo()` in `public/js/main.js` assumes every tower has 3 levels (`tower.level < 3`), but a wall has one
level, so `statsFor(type, i + 1)` and `def.levels[tower.level].cost` read `levels[1]`, which is `undefined`. Use
`tower.level < def.levels.length` in both places (and for the `up` button / `updateInfoDynamic`). Add an e2e assertion:
build a wall, tap it, tap Sell, check the credits.
## Suggested order of work
1. **The wall bug above**, then the other confirmed high/medium client bugs:
* `code-2`: the info panel is rebuilt with `innerHTML` on every `view.rev` change, so an Upgrade/Sell/Target tap that
lands during a rebuild is lost (worse in co-op, where the partner's actions bump `rev`). Update in place or rebuild
only when this tower's signature changes.
* `coop-1` / `code-1`: `RemoteController` keeps only the last 10 snapshots; a render stall of ~0.5 to 1 s drops snapshots
that carry `tw` (tower list) before they are displayed, so the partner's new towers are lost until a resync. Never
discard an entry whose `tw` has not been applied (or apply `tw` to the mirror on arrival and only delay the drawn list).
* `touch-1`, `touch-2`: with a wall armed, the first finger of a pinch builds a wall immediately; with a turret armed
it moves the pending placement. Defer the first placement to pointerup/first real move and cancel on a second pointer.
* Phone layout: after tapping a tower the Upgrade/Sell/Target buttons are below the fold (`visual-2`, `touch-3`); on small
phones the first-run Help has no visible "Got it" (`visual-3`) and the co-op room code and Invite button are not
visible while waiting for a partner (`visual-4`, `touch-8`). Likely fix: show the selected-tower panel as a bottom
sheet over the palette, put room code/invite in the top bar or a toast, make overlays scroll with a sticky button row.
* `coop-2`: after a half-open connection (Wi-Fi/cell switch) the UI looks alive but frozen for 47 to 65 s; show the
reconnect overlay as soon as the watchdog fires and open a new socket without waiting for the old one to close.
2. **Co-op correctness**: simultaneous Upgrade / Next Wave from both players are applied twice (`coop-5`: make upgrade
idempotent, e.g. send the expected level; ignore a wave command within ~1 s of another), host-leaves-while-end-screen
(`coop-3`, `code-11`), failed join from the menu kills the live game (`coop-4`), controller races (`code-3`, `code-4`).
3. **Smaller UX/a11y**: reduced-motion hides every toast (`touch-5`, `visual-6`), Space held launches ~20 waves
(`code-6`: ignore `e.repeat`), co-op music/stinger after Play again (`code-5`, `code-7`, `code-12`), touch target sizes,
safe-area double padding, contrast, colour-only enemy legend, pause not obvious.
4. **Proxy docs/behaviour** (`proxy-*` in the findings): 403 when the public URL has a non-default port (Origin vs Host
port handling), DEPLOY.md claims NPM can send `X-Forwarded-Host` from the Advanced tab (it cannot), NPM's default read
timeout is 90 s not 60 s, service worker serves nginx's 502 page instead of the cached app, path-prefix instructions for NPM.
5. **Balance** (`docs/BALANCE.md`): the baseline shows the game is currently too easy and IDS Sniper dominates.
6. Real-world checks that were never possible in the sandbox: a real phone (iOS Safari audio unlock, safe areas, wake
lock), real nginx Proxy Manager with Let's Encrypt, a Proxmox LXC with the systemd unit.
Findings marked UNVERIFIED were reported with a reproduction but not yet independently re-checked (the verification
stage was stopped); re-run the repro from `docs/review-2026-10-09/repro-scripts.tgz` before fixing.
## Decisions waiting for the user
* **Maze exploit.** A long serpentine of cheap walls (5 credits) makes routes about 5 to 6 times longer than the direct path.
Options: escalating wall price, a wall cap, or faster/tougher waves. See `docs/BALANCE.md`.
* **Room codes** are 4 characters (about 1M); a stranger could guess an open room. Options: 6 characters, an optional
room password, per-IP rate limit on failed joins.
* **Music size.** battle/boss/menu are 3 to 8 MB each and downloaded whole on first use; fine on Wi-Fi, heavy on mobile
data. Could re-encode to mono ~48 kbps.
## Dev environment (what the session used, none of it is in the repo)
* The sandbox had no Node and no root. The user's machine can install anything: `apt install nodejs npm`, `npm install`,
`npx playwright-core install chromium-headless-shell` (plus `npx playwright-core install-deps` as root) and `npm run e2e` is all that is needed.
* The review pipeline (5 reviewers, a verifier per finding, one fixer, a final QA) was a Workflow script; a copy is in
`docs/review-2026-10-09/phase2-workflow.js` and can be re-run (re-point its scratch paths) to verify the UNVERIFIED
findings and to run the fix stage.
* Conventions: `public/js/sim.js` must stay pure and DOM-free (it runs in the browser for solo and in Node for co-op); `ws` is the only
runtime dependency; the client uses only relative URLs (works under a proxy path prefix); `test/` may only hold real test files
(plain `node --test` runs everything there).
* Git: commit and push at milestones is pre-authorised for this project.