aorecomp

Anarchy Online classic in the browser

git clone https://aorecomp.ubeagle.com/code/aorecomp.git


commit a5180e7e4b8ca5f9858c4727530f81e9c3b47688
parent 57d25ec1ef90537b629481b70b40bfd3a0f88d8f
Author: anon <anon@example.com>
Date:   Fri,  6 Nov 2026 06:27:53 +0000

Document server ownership and synchronization boundaries

Diffstat:
MDEVELOPERS.md | 22++++++++++++++++++++++
MTODO.md | 8+++++++-
2 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/DEVELOPERS.md b/DEVELOPERS.md @@ -58,6 +58,28 @@ Saving it validates and writes the database; there are no per-player YAML storage files. HTTPS key/certificate files are separate and use atomic file replacement. +### Server ownership boundaries + +| Responsibility | Owner and boundary | +| --- | --- | +| Protocol and sessions | `main.go` dispatches native messages; `browser_socket.go` and `browser_account.go` authorize browser streams and credentials. Connection state belongs to `worldClient`, `chatClient` and their output/stream adapters. Decode and authorize before invoking a game action. | +| World simulation | `state.go` owns characters and live sessions. `simulation.go` starts the movement, roaming/action, zoning and checkpoint loops used by both executable entry points. Browser scenarios must not supply their own tick loops. | +| Rules and content | Action implementations such as `inventory.go`, combat and nano handlers decide admission and outcomes using `gamedata`. UI and transport code report those outcomes rather than reproducing the rules. | +| Durable transactions | `database.go`, `item_store.go` and `world_store.go` own database records, item ownership and checkpoints. Significant actions commit their related changes before updating shared ownership or publishing success. Keep frequent movement in memory until its checkpoint. | + +`server.mutex` protects shared world state. Helpers suffixed `_locked` require +that lock. Operations needing ordered simulation/session changes acquire +`updateMutex` before `mutex`; retain that order in new code. Build outbound +updates under the world lock and use the existing output queues after releasing +it. Do not hold the world lock across a blocking network write. + +The test-only API follows these boundaries: it serializes setup with the same +locks, refuses setup while the player has a game connection, invokes the +existing persistence methods and returns explicit snapshots. Its build tag +keeps those capabilities out of production. Production and test shutdown share +the final checkpoint/database-close path. Keep these ownership rules as affected +code changes; a package split is not required to enforce them. + The matching browser build is checked in under `server/assets/client/`: `index.html`, `game.js`, `game.wasm.br`, `profile-worker.js`, `audio-worklet.js`, and `build.json`. A fresh clone can run `(cd server && go run .)` immediately. diff --git a/TODO.md b/TODO.md @@ -432,11 +432,17 @@ rewriting this document does not close them. vet checks. The three superseded Go runners are removed; the remaining earned progression runner shares the cold-client assertions. See [browser testing](DEVELOPERS.md#browser-game-testing). -- [ ] Document/enforce server ownership boundaries as affected code changes: +- [x] Document/enforce server ownership boundaries as affected code changes: protocol/session handling, world simulation, game rules/content, and durable transactions. Keep low-significance simulation state in memory between checkpoints and significant inventory/reward mutations atomic. Avoid a broad package reorganization as an alpha prerequisite. + November 5: [the ownership map](DEVELOPERS.md#server-ownership-boundaries) + records the current owners, lock order, output boundary and persistence + cadence. Production and test executables share simulation/shutdown ownership; + the test API uses those locks and persistence methods and refuses live-player + setup. The migrated browser, cold-recovery and failure-cleanup checks verify + these affected paths. Continue enforcing the documented rules on later edits. ## Deferred historical completeness