Arborwake Wiki

Developers

Architecture

How the Arborwake alpha is put together, the save and reward boundaries, and the older engine of the original opening.

Content checked 2 November 2026

The Arborwake alpha#

Layers#

LayerWhereWhat it does
Integrated game statesrc/main-game/game/ β€” state.js, controller.js, campaign.js, home.js, encounters.jsPure state for session.game version 1: roster, side quests, observations, journal, home duties, pending rewards and the shared Threadway position.
World and travelsrc/main-game/game/world.js, maps.js, residents.js; shared src/main-game/navigation.jsThe six 2D places, polygon floors (CR-NAV-01), resident routes and physical gates.
Threadwaysrc/main-game/threadway3d/, src/main-game/game/threadway-host.js, threadway-assets.mjs, transport-package.mjsThe 3D street. It borrows the host ledger and checkpoint, streams nearby sections, and saves its position.
Encounterssrc/main-game/alpha/ (host, rules, pinned presenter in public/encounter/)Opens a turn room in a child presenter with host-owned setup, then verifies the result.
Services and shopssrc/main-game/services.js, src/main-game/game/shops.js, vendored kit in src/main-game/vendor/ and game/vendor/Claude B’s pinned services v3, kit and roster rules behind lead adapters.
Presentationsrc/main-game/game/presentation.js, ui.js, effects.js, world.css, src/hud/Drawing, menus, the HUD and transaction-driven effects.
Savessrc/main-game/game/migration.js, src/main-game/progress-store.jsKey arborwake.game.progress.v1. Earlier alpha saves keep their resources; their records are archived, not accepted as story evidence.

Provenance files sit beside the code: game/INTEGRATION.json, game/UPDATED-PINS.json, game/art/SOURCES.json and game/RELEASE-FILES.json (1,149 inspected inputs with hashes).

Trust boundaries#

Commands and tests#

Command (in the Placeholder checkout)What it doesLast lead result (2 Nov)
npm run buildRelease build; dist/index.html opens the gamepassed
npm run test:systemsNode tests for tests/main-game/*.test.js135 passed
npm testThe original Placeholder world rules11 passed
npm run build:prototypeKeeps the older preview filespassed (49 files)
npm run test:browserEdge through local Wrangler: podium, observation, building, lesson, Workshop purchase, return, reload, touch, the full journey7 passed
npm run deploy:checkWrangler dry run onlypassed; nothing uploaded

These results are the lead’s own. On 3 November the wiki reran npm run test:systems (135/135) and npm test (11/11) on a clean extract of b89f778; it did not rerun the builds or browser suites.

The original opening on main (history)#

This is the engine of the three-minute Circuit Ranger opening. It still builds and runs on main, and parts of it (navigation, saves) were reused.

Stack#

JavaScript, HTML and CSS; Phaser 4.2.1 for drawing; Vite 8.3.5 for building; Playwright 1.64.1 with installed Edge for browser tests; Prettier 3.6.2; Node β‰₯ 22.12. Logical viewport 512Γ—288, pixel-art scaling.

Principles#

Modules#

FileResponsibilityKey exports
src/app.jsOwns the state reference, the fixed-step accumulator, input and bootβ€”
src/core/state.jsWorld factory and constants; bounded event ring (100)createWorld, STEP, REACH, emit
src/core/runtime.jsOpening setup, command dispatcher, step order, opening directornewGame, targets, dispatch, step
src/world/maps.js / src/world/navigation.jsRegion records; walking, path-finding (16 px grid) and doorwaysREGIONS, movePlayer, setDestination, transition, isWalkable, findPath
src/simulation/cells.jsTend, Call, care, material, response, neuron strain, residentstend, call, cancelWork, updateCells, addMaterial, getCellTargets
src/home/progression.jsBuilding, banking on return, recruiting Mote, assignmentstartBuild, updateHome, onReturn, assignResident
src/persistence/save.jsSnapshot validation and IndexedDB savesvalidateSnapshot, createSnapshot, saveWorld, loadWorld
src/render/scene.jsThe single Phaser scenecreateScene
src/render/manifest.js, art-format.js, art-layer.jsOptional approved sprite/layer loading (catalogue empty)ART_CATALOG
src/ui/panel.jsDOM interface, drawers and ending dialogmountUI

One step#

step(state, dt) advances in this order:

time += dt β†’ movePlayer β†’ updateCells β†’ updateHome β†’ updateDiscovery β†’ updateDirector

step throws if dt is not in (0, 0.05]. The director runs the opening phases: welcome β†’ forecast β†’ defence β†’ recovery β†’ ending β†’ commons (after Continue), or practice in Gate A mode.

Commands#

pause, continue, move {x,y}, destination {x,y}, select {id}, cycle, cancel, call, build, assign {residentId, sectorId}, ready, tend. There are no skill or expedition commands; their future shapes are agreed in Integration.

Trace one action: select β†’ tend β†’ dispatcher checks pause, target, region and range β†’ cells latch the action β†’ each step advances material progress β†’ completion writes cleared = true before one event β†’ the renderer simply stops drawing it.

Saves#

IndexedDB database arborwake-save-v1, keys current and previous. A save writes both in one transaction (the old current becomes previous) with a revision check that rejects stale tabs. Schema version 1 validates the fixed regions, six sectors, 1–3 residents and Supply limits. Snapshots drop input, path and action, and load paused. Extra unknown data is not a supported extension mechanism.

Since the 31 October rename, the first run at a browser origin copies saves from the database used under the project's former name into the new one, keeping their revisions. It never overwrites an existing Arborwake record and never deletes the old database, which stays as a recovery source. Close tabs running an older build first: the old database is not kept in sync. Old identifiers are recognised only by src/persistence/legacy-brand.js.

Tests#

CommandWhat it coversLast lead result (27 Oct)
npm testNode unit/integration rules (world, cells, home, saves, runtime review, art)60/60
npm run buildStatic production buildpassed (bundle-size advisory)
npm run test:browser7 Edge smoke routes: Gate A, both branches, saves, restart, pointer/keyboard, W/A7/7
npm run test:artArt loader on Canvas and WebGL with synthetic sheets4/4
npm run test:realtimeOne unaccelerated three-minute run1/1, 180,878 ms, held 37/45

Browser suites refuse to reuse an existing server; set ARBORWAKE_TEST_PORT (or ARBORWAKE_SYSTEMS_TEST_PORT for the systems preview) for an isolated port. ?qa=1 exposes disclosed fixed-step acceleration for tests only; the browser QA hooks are window.arborwake and window.arborwakeSystems.

After the rename (main 54cc7cc), the lead reported on 31 October: npm test 101/101, npm run build and npm run build:systems passed, npm run test:browser 10/10 (including save migration), and npm run test:systems:browser 3/3. test:art and test:realtime were not rerun; the table above shows their last results.

Run it#

npm ci
npm run dev        # http://127.0.0.1:5173
npm test
npm run build
npm run test:browser

Or play the built snapshot without any setup.

Built 3 Nov 2026, 12:17 am (Sydney) from wiki/source/pages/architecture.md. The wiki checkout was at 7df3a62ea; accepted main was 1ded4c01c; the Placeholder alpha was bf472ae0a. Rebuild: node wiki/tools/build-wiki.mjs.