@homie-rocks/studio 0.45.3 → 0.46.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -17,6 +17,108 @@ To bring a studio up to date, tell Claude: "Upgrade my studio to the newest Homi
17
17
  `npx -y @homie-rocks/studio@latest upgrade`, which shows what's new since the version your studio pins (from this
18
18
  file) and what the upgrade would change, and changes nothing until you agree.
19
19
 
20
+ ## [0.46.2] - 2026-10-11
21
+
22
+ **Plugin 0.46.2** · Big rooms: the room runs the rules, its Gates do the rest.
23
+
24
+ A room of hundreds has a new shape, a deploy the owner asked for is approved by the asking, and Homie paces no input of a server-hosted game.
25
+
26
+ Measured on Cloudflare with a game where every player sees about 180 others: 300 players at 20 frames a second from a home connection; 600 at 20 frames a second measured from inside Cloudflare, marginal from one home connection carrying all 600; 1,000 are admitted and the room keeps its ticks, but delivery is not there yet. On the same game 0.45.0 delivered 13 frames a second at 300 and lost every player at 1,000.
27
+
28
+ ### Added
29
+
30
+ - `room.rates` in game.json: a studio's own pace on what one player may send, in messages a second by kind (`{ "in": 60 }`). Leave it out and there is none.
31
+ - `lib/crowd-probe/`: a Worker of its own that plays simulated players against a studio from inside Cloudflare, five a request, and `lib/crowd-cloud.mjs`, which adds the requests up into the report the home driver writes. A trial's tool: no studio's Worker imports it.
32
+ - Each Gate measures the room's clock against its own, the room's ticks a second by its own clock, and the longest it went without a world. The room's own count of its ticks cannot see the room run late.
33
+ - A big room's diagnostics come from an object that is neither the room nor a Gate with players. The room and each Gate post a second's facts to it (ticks a second, how long a player's input took to reach the rules, frames written to each player, how old the world was when a Gate sent it, how far behind players say they are), and `/_studio/api/room` answers from that copy with its age. Measuring a room costs it nothing, and a room too busy to answer still has its last word read.
34
+ - A player's client says which tick it holds (`g` on its inputs and pings). A Gate that finds a player more than a second behind sends that player fewer, fresher frames, down to one a second, and restores the rate when they have caught up. Each frame is a change from the last one sent and carries the player's own body. A client that says nothing is sent every tick, as before.
35
+
36
+ ### Changed
37
+
38
+ - In a room behind Gates the room object runs the rules and hands each Gate one world a tick. The Gate chooses what each of its players can see, encodes it and writes it. The room no longer selects, encodes or queues anything per player on its tick.
39
+ - A Gate holds fifty players and Gates fill in order: the room tells the door which Gate has room, so fifty players in a 1,000-seat game are one Gate and a full room is twenty. A studio sets its room's size and nothing else. A room of 64 or fewer is still its Table alone.
40
+ - The world crosses from the room to a Gate as one block of numbers, the same block for every Gate, plus whatever else about a body changed since that Gate last heard: about 33 KB a tick for 1,000 players where the JSON was 150 KB, and almost nothing for the Gate to parse.
41
+ - A body that keeps its course is not sent again. A client built with 0.46.2 moves it along its last velocity, and a Gate sends it only when that has drifted past the game's `view.precisionM` (near bodies) or half the distance it covers between `view.farHz` refreshes (far ones). On the crowd-circuit game at 1,000 players a frame falls from 71 rows to 20, a player from 14.8 KB a second on the wire to 6.3, and a far body is drawn 3 cm from the truth on average where it was 35 cm. A game page built before 0.46.2 is sent every moving body, as before.
42
+ - A Gate works out once for each world what does not depend on the player. Encoding a player's frame takes under a third of the time.
43
+ - Each Gate has its own channel to the room. The relay between them (the Concentrator) is gone: it re-read and re-sent every world for eight Gates and was the first object to fall behind. A studio's `CONCENTRATOR` binding stays declared and unused, so an upgrade needs no migration.
44
+ - A Gate sends the room what its players sent at once when the channel is quiet and never more than one frame in 50 ms, however many players it holds. Receipts ride that frame.
45
+ - Far-view refreshes are spread across players, so a room's largest updates do not all leave on the same tick.
46
+ - A deploy requested in the owner's prompt is approved for that task, including retries. Unrequested deployments remain held; explicit refusals revoke the task approval.
47
+ - The crowd probe offers WebSocket compression, as every browser does, coasts, names the tick it holds, follows the room's word on how early its inputs arrive (as the toolkit's client does), and reports whether the server agreed to compress, what that saved, and the kilobytes a second a player cost.
48
+
49
+ ### Fixed
50
+
51
+ - Homie no longer paces what a player sends a game whose rules run on the server. 0.45.3 dropped honest input at 60 a second when a slow network delivered a batch late. What players say to each other keeps its pace, and so does every room a player's own browser hosts.
52
+ - A game with fields only their owner may see keeps each player's view in the room when the room is behind Gates. A Gate was handed the whole state.
53
+ - Late callbacks that catch up at the requested tick rate no longer end a healthy room as an overrun; sustained slow ticks still stop.
54
+ - Relay failures log their layer, close cause and queue counters. A link's receipt latency measures the link, not the cadence a receipt waited for. Frozen Cloudflare clocks are not reported as zero execution time.
55
+ - Deployment summaries no longer assume Workers Free. A big room's estimate counts its Gates and its diagnostics object and says which request traffic it leaves out.
56
+
57
+ ### Upgrade notes
58
+
59
+ - Rebuild and deploy a studio to get the new room shape; a game needs no change. A game page built before 0.46.2 still plays in a big room: it is sent every tick and every moving body, because it says neither which tick it holds nor that it coasts.
60
+ - A room of 64 seats or fewer, and every room a player's browser hosts, is as it was: none of this is on its path. The one change that reaches a small server-hosted room is that Homie no longer paces what a player sends it.
61
+ - To measure your own game on your own Cloudflare account: `lib/crowd-load.mjs` plays a crowd from your computer and `lib/crowd-probe/` from inside Cloudflare. `lib/crowd-probe/README.md` has the commands and how to delete the probe afterwards.
62
+ - What four trials on Cloudflare measured, what is proven and what is not, is in `docs/crowd-transport-0462.md`.
63
+
64
+ ## [0.46.0] - 2026-10-10
65
+
66
+ **Plugin 0.46.0**
67
+
68
+ Keep a world and its account characters across restarts.
69
+
70
+ ### Added
71
+
72
+ - Opt-in lasting single-area worlds: `room.lifetime: "persistent"` retains a room
73
+ across empty periods, restarts and compatible builds. State fields declared
74
+ `{ durable: true }` are written the moment they change, as one small journal
75
+ record committed before that tick is published, exactly once across a crash.
76
+ The rest of the room is checkpointed every `room.durability.movementSeconds`
77
+ (30 by default for a lasting world) and on pause or an orderly stop; a restore
78
+ is the last checkpoint plus the journal, so value is never lost or repeated
79
+ though positions may rewind a moment. A room where nothing changes writes
80
+ nothing. Storage failures stop play and retain committed state.
81
+ - Optional `room.characters: true` keeps one character per game on the existing
82
+ signed-in player account. Rules read `player.character` on join and write its
83
+ inventory through declared entity fields. A durable lease and return outbox
84
+ prevent two rooms holding the character at once. Explicit `world.finish()`
85
+ resets retain the latest account character instead of replaying its old inventory.
86
+ No manual provisioning.
87
+
88
+ ### Changed
89
+
90
+ - Only opted-in worlds use a stable public room instead of allocating fresh match
91
+ copies. Full worlds wait for seats; named room links select other worlds.
92
+ - Lasting worlds default to `offline: false` so practice cannot look like a
93
+ durable session. An explicit `offline: true` still allows unsaved local practice.
94
+ - Only character games require studio account sign-in before playing and return
95
+ the character on disconnect/recall instead of leaving it as a bot.
96
+ - `room.durability.movementSeconds` defaults to 30 when `lifetime` is
97
+ `"persistent"`; it is still 1 for every other room. In a lasting world an
98
+ undeclared field, a position or an undeclared non-player entity can come back
99
+ up to that many seconds old after a crash: declare what must not.
100
+ - Only lasting worlds retain incompatible saves instead of
101
+ resetting and stop on write failure. Their save envelopes do
102
+ not use the match path's 16 MB cap. Existing simulation and Cloudflare constraints
103
+ still apply. Ordinary rules games and browser-hosted games keep their APIs,
104
+ save costs and lifecycle.
105
+
106
+ ### Fixed
107
+
108
+ - Refund-event SQL triggers no longer try to parse plain-text settings as JSON,
109
+ which could prevent account room tickets being signed. The automatic
110
+ `0020_function_meta.sql` migration preserves refund IDs and delivery behavior.
111
+
112
+ ### Upgrade notes
113
+
114
+ - First milestone-3 slice. Compatible deployments still restart the Worker and
115
+ reload old views; uninterrupted rule swaps, migrations, durable command retries,
116
+ atomic trades and restore points remain later slices. Commands should be
117
+ idempotent; a command lost before commitment has not happened. Queued events are
118
+ not atomic transfers when a recipient leaves. Existing cloud saves, shop orders
119
+ and grants, and app records retain their existing behavior.
120
+ - Version 0.46.0 is provisional. No deploy or merge is part of this PR.
121
+
20
122
  ## [0.45.3] - 2026-10-10
21
123
 
22
124
  **Plugin 0.45.3**
package/README.md CHANGED
@@ -206,8 +206,9 @@ game its studio chooses to share, each with its own licence ("Game parts", below
206
206
 
207
207
  `players.max` in game.json is the room's chosen positive integer capacity; omitted means 8.
208
208
  There is no 32-player ceiling or default per-address admission limit. Public games use
209
- rules plus view with `room.host: "server"`. Gates carry the browser connections and
210
- concentrators combine Gate links for larger rooms. Server rules survive browser departures.
209
+ rules plus view with `room.host: "server"`. Gates carry the browser connections, each on
210
+ its own channel to the room: the room runs the rules and hands every Gate one world a tick;
211
+ the Gate selects, encodes and paces each player's view. Server rules survive browser departures.
211
212
  New browser/offline games use the same rules contract. Existing netplay games and their
212
213
  port host helpers remain supported for upgrades, with their original 32-seat limit.
213
214
  For larger rooms, follow `guides/game/REWRITE.md`.
@@ -0,0 +1,345 @@
1
+ # Rooms milestone 2: releasable slices
2
+
3
+ The opening sections preserve the released slice-1 record. The 0.45.0 slice-2
4
+ implementation, local measurements and remaining work follow below.
5
+
6
+ 0.44.0 is slice 1, **spatial state delivery**. It is useful independently in an
7
+ existing server-hosted room: the studio chooses `room.view.radiusM` in game.json,
8
+ and a player's view receives nearby entities and its own body. Unchanged state
9
+ is compressed as deltas. No change to rules or movement is needed. `room.each`,
10
+ `enter` and `leave` describe the visible set, so a view must dispose of departed
11
+ meshes and recreate returning ones. Leaving view does not mean despawning.
12
+
13
+ This first PR does not claim that the public join/build path admits hundreds.
14
+ That path retains milestone 1's 32-seat restriction until slice 2 supplies Gates
15
+ and removes it. The simulation and relay now handle a 300-seat test directly,
16
+ without a simulation seat clamp or truncated rosters/control rows. This is the
17
+ foundation for the next slice, not a substitute for its admission and transport
18
+ proof. No deployment or merge was made.
19
+
20
+ ## What ships first
21
+
22
+ - `room.view.radiusM`: a studio-selected radius in metres, including z in 3D.
23
+ Omitted or null means the whole room, with the existing small-room path and
24
+ no extra per-client encoding. Zero means only colocated entities. No default
25
+ radius, downstream budget, spend limit, or crowd admission policy is imposed.
26
+ - The real relay filters both ongoing snapshots and join/rejoin welcome state.
27
+ A player with no body yet sees no entities. Watchers retain the whole-room
28
+ overview in this slice; following a camera does not restrict their feed.
29
+ - Each connection retains one keyframe. Deltas carry changed entity components,
30
+ new entities and explicit removals, against that keyframe. They carry the
31
+ current round and only the receiving player's input acknowledgment/control row.
32
+ - A keyframe at least once per simulation second, and a fresh one at every
33
+ connection or epoch change. Backpressure skips snapshots without advancing the
34
+ encoder. A missing intermediate delta cannot corrupt later updates. A lost
35
+ keyframe causes deltas to be ignored until the next keyframe, at most one
36
+ simulation second later. WebSocket itself is ordered and reliable.
37
+ - Saving and host recovery still use complete authoritative state. Filtering
38
+ never changes simulation, collision, queries, scoreboards or shared state.
39
+ - Seeded, virtual-time correctness in `npm test`; the long 300-client run is in
40
+ `test:rules:extended`. The pre-existing 12-scenario real-time traffic matrix and
41
+ 27 handover repetitions move there too, with all assertions retained. The gate
42
+ keeps two actual-browser cases (tab hiding and socket closing); virtual time
43
+ covers the rate/seed/handover matrix. No wall-clock throughput threshold is a
44
+ release gate.
45
+
46
+ Interest is a bandwidth feature, **not hidden information**. Shared state,
47
+ effects, roster and watcher overview are still public. Private fields and tells
48
+ arrive together in slice 3. Browser hosting continues to send complete state;
49
+ requesting a radius there produces a build diagnostic. The existing starters
50
+ need no contract rewrite for slice 1 and keep their whole-room views.
51
+
52
+ ## Design decisions and departures
53
+
54
+ The roadmap's sections 5, 6, 7, 10 and 23 are the starting point. Milestone 1
55
+ already separates the host, core, transport-free relay and view. We reuse those
56
+ roles instead of first splitting Table into new abstractions or declaring empty
57
+ Durable Object classes. Gate and concentrator classes arrive together in slice 2,
58
+ when they can actually carry connections and their deploy can be tested.
59
+
60
+ Interest/deltas precede Gates: doing this work in the existing relay gives a
61
+ shippable feature and a measurable role to move. The codec is independent of
62
+ Cloudflare and does not introduce a second runtime or contract profile. A small
63
+ game continues to see the match contract without `uses` or `profile` boilerplate.
64
+
65
+ Deltas name periodic keyframes rather than retaining an acknowledged history
66
+ per player. One baseline bounds memory, intermediates may be skipped safely, and
67
+ reconnect always starts fresh. This trades retransmitted changes and up to one
68
+ simulation second of recovery after a lost keyframe for a much smaller protocol.
69
+ It is not the roadmap's final bandwidth scheduler; near/far tiers, priorities,
70
+ short IDs, watcher follow feeds and shared far encodings remain slice 3 work.
71
+
72
+ The roadmap's default 96-metre visibility radius, default crowd cap from S6,
73
+ per-client bandwidth budget and guest-address cap are not defaults we will
74
+ adopt. They contradict the owner's no-imposed-limits rule. Studios may choose
75
+ limits explicitly. Cloudflare limits and measured capacity are reported as
76
+ information, never turned into a Homie admission ceiling.
77
+
78
+ ## Local proof
79
+
80
+ The workload uses the checked and guarded rules loader, real host runtime and
81
+ NetRoom relay, with 300 simulated WebSocket clients, one actual player body per
82
+ seat, 20 Hz seeded inputs, a 20-by-15 grid at four-metre spacing and a chosen
83
+ 12-metre radius. Each player moves at up to 2 m/s and increments a field each
84
+ tick. All 300 input acknowledgments, own bodies and roster entries are checked;
85
+ there are no rules errors or cut ticks. The fixture explicitly chooses a
86
+ 5,000,000-unit tick budget; this is not a new default or a general game capacity
87
+ claim. Warmup is 20 ticks. Clients keep one baseline and latest state, not a log
88
+ of every received frame.
89
+
90
+ Measurement includes input dispatch, rules, encoding, serialization and all 300
91
+ clients parsing and decoding in the same Node process. Memory is peak sampled
92
+ whole-process heap/RSS, including the harness and rules loader, not isolated
93
+ server memory. Bytes count all downstream frames during the measurement window,
94
+ including snapshot JSON and pings; WebSocket/TLS framing is not included. These
95
+ are **local numbers, not Cloudflare measurements**, not Internet latency, and
96
+ not a rendering or physical-phone capacity result.
97
+
98
+ Measurement command:
99
+
100
+ ```sh
101
+ node --input-type=module -e 'import {interestWorkload} from "./packages/studio/test/rules-interest-workload.mjs"; console.log(JSON.stringify(await interestWorkload({ticks:1200,measure:true}),null,2))'
102
+ ```
103
+
104
+ Observed on macOS arm64, Node 22.23.3, 1,200 measured ticks (60 seconds of
105
+ virtual play), plus 20 warmup ticks. Other local verification was running; CPU
106
+ timings are observations, not a throughput guarantee.
107
+
108
+ | Measurement | Local result |
109
+ | --- | ---: |
110
+ | Clients / tick rate | 300 / 20 Hz |
111
+ | Peak visible bodies for one client | 33 |
112
+ | Tick including relay and all client decoding, p50 / p95 / p99 | 14.88 / 21.04 / 25.41 ms |
113
+ | Largest measured tick | 31.98 ms |
114
+ | Downstream per player, mean / highest | 23,171 / 29,117 bytes/s |
115
+ | Peak sampled whole-process heap / RSS | 133,426,952 / 238,764,032 bytes |
116
+
117
+ This does **not** meet the roadmap's eventual 16 KB/s target. Tiers, priority and
118
+ shared encodings in slice 3 have work to do; no target was weakened or represented
119
+ as passed. All 300 clients are simulated, not 300 browser tabs or Cloudflare
120
+ connections.
121
+
122
+ ## Release verification
123
+
124
+ - Focused codec, relay and rules tests: 20 passed, no skips.
125
+ - Real view client on virtual time: 189 passed, including the new spatial
126
+ delivery/lost-keyframe/reconnect case. Existing Chrome rendering smoke tests
127
+ run in the root gate; this slice adds no rendering-specific browser case.
128
+ - Plugin: 123 passed, one optional live-URL fixture skipped.
129
+ - Plugin validation, packed Desktop server and release preflight passed;
130
+ preflight lists studio 0.44.0 as the sole new npm version.
131
+ - Template and history generation, changelog sync/check completed.
132
+ - Root `npm test` runs with `CHROME_PATH` pointing to local Chrome. Final root
133
+ results and all six CI checks are tracked on [PR #83](https://github.com/homie-rocks/homie/pull/83).
134
+ - A same-role reconnect now delivers its welcome snapshot to the rules view,
135
+ even though no role-change event fires. The regression blocks later periodic
136
+ keyframes and verifies that welcome-based deltas advance the view immediately.
137
+
138
+ ## Remaining slices, in order
139
+
140
+ Each is a separate releasable commit series/PR after its predecessor is released.
141
+ Slices 1 and 2 are implemented. Slice 1 shipped in 0.44.0; this PR prepares
142
+ slice 2 as 0.45.0 on the released 0.44.1 base.
143
+
144
+ 1. **0.44.0 — spatial state delivery**, above. Proof: codec oracle, real views
145
+ on virtual time, loss/reconnect, and 300-client host/relay workload.
146
+ 2. **0.45.0 — Gates and bigger public rooms (implemented below).** Gate/concentrator classes together,
147
+ reuse the delivery role, batch input and preserve commands, authenticated binding-only admission,
148
+ resume/revocation, and automatic layout from `players.max`. Remove public seat
149
+ caps, make guest policy studio-selected, report tested size in build/deploy
150
+ plans. Prove 300 clients through the actual join path, Gate restart/resend,
151
+ 20 Gates through concentrators, and small rooms without extra objects. Preserve
152
+ existing netplay builds, checks, deploys and host/port helpers at their original
153
+ 32-seat limit. New games, starters and authoring guides use rules plus view,
154
+ including browser/offline mode.
155
+ 3. **Private and scheduled delivery.** Field `see`, reliable one-player `tell`,
156
+ optional studio-chosen downstream budget and priorities (near/far visual
157
+ scheduling shipped in slice 2),
158
+ watcher follow/region and overview feeds, crowd rendering guidance/helpers.
159
+ Update starters where these capabilities apply. Prove no owner/server field
160
+ reaches another player's bytes, tells survive reconnect once, boundary
161
+ enter/leave and fairness under a chosen budget; measure a dense crowd and
162
+ rendering in real browsers. A view leaving interest is not evidence of privacy.
163
+ 4. **Crowd policies and vehicles.** Studio-selected `crowd.cap` with queue/hold,
164
+ soft event work scheduling without dropping work, `uses`, solid bodies,
165
+ attach/control/detach and driver prediction. Prove cap absent means no imposed
166
+ cap; explicit queues/holds release correctly; four-person vehicle prediction,
167
+ seat contention, disconnect and restore. Ship one vehicle example and update
168
+ the skill in the same slice.
169
+ 5. **Large worlds' files.** Extend existing studio-owned R2 asset serving to game
170
+ files over 25 MiB and multipart upload; streamed map chunks, zones, compiled
171
+ triangle meshes and navigation. Reuse the existing upload/build machinery.
172
+ Prove large asset integrity, interrupted/resumed multipart upload and map
173
+ streaming with the same collision data on server and client.
174
+ 6. **Milestone proofs and authoring tools.** Single-machine swarm CLI, match kit,
175
+ cross-browser-engine movement hashing, S6 at 20/60 Hz and multiple regions,
176
+ S11 transport assessment, dense crowd tuning and remaining authoring trials.
177
+ Local correctness stays seeded/virtual; long runs stay extended. The roadmap's
178
+ 300-bot, 30-minute Cloudflare exit test, Gate recovery latency, physical phone
179
+ rendering and actual billing need a separately authorized deployment/device
180
+ session. No local receipt here is represented as those results.
181
+
182
+ ## Slice 2 (0.45.0): public rooms in the hundreds
183
+
184
+ Implemented:
185
+
186
+ - `players.max` is the single build size, read by public admission, compilation
187
+ and deploy planning without the 32-seat clamp. Shared carrier addresses have
188
+ no automatic player ceiling.
189
+ - Gate and Concentrator classes carry ordered, batched logical connections over
190
+ binding-only links. Public authentication remains in the Worker. Small rooms
191
+ embed the delivery role in the Table; larger layouts use one logical Gate per
192
+ 64 seats and concentrators above eight Gates. These are routing partitions,
193
+ not admission limits. The template generates both bindings and migrations.
194
+ - Link loss closes downstream sockets for normal token-based seat resumption.
195
+ Gates do not persist simulation or become a second authority. Gate passes are
196
+ internal binding requests, not independently client-supplied authorizations.
197
+ - Ordered snapshot deltas, shared spatial indexing and cached wire rows reduce
198
+ repeated work. Optional `precisionM`, `nearM`, and `farHz` schedule remote
199
+ visual state; controlled bodies remain exact and independently recoverable in
200
+ every frame. A lost remote delta cannot stall the local body or collider
201
+ revisions. Snapshot exits remain immediate.
202
+ - Revision 12 carries roster patches after a full welcome roster. A reconnect
203
+ storm previously repeated full rosters to every player. The patch baseline is
204
+ the last transmitted roster, separately from policy relabelling.
205
+
206
+ A 300-player manifest (the game still needs appropriate arena,
207
+ spawning, rule cost and rendering):
208
+
209
+ ```json
210
+ {
211
+ "players": { "min": 1, "max": 300 },
212
+ "room": {
213
+ "host": "server",
214
+ "view": { "radiusM": 12, "precisionM": 0.01, "nearM": 4, "farHz": 5 }
215
+ }
216
+ }
217
+ ```
218
+
219
+ The visual settings are examples, not imposed defaults or information privacy.
220
+ The workload explicitly chooses a 5,000,000-unit tick budget as in slice 1.
221
+
222
+ ### Local measurements
223
+
224
+ All results below are **local**, not Cloudflare, billing, Internet latency or
225
+ physical-phone results. Bytes exclude WebSocket/TLS framing. Heap/RSS include
226
+ clients and the test harness in the same Node process. Other work on this
227
+ machine affects CPU timing; bytes are deterministic for the virtual workload.
228
+
229
+ | Workload | Players | Mean bytes/player/s | Tick p50 / p95 ms | Peak heap / RSS bytes |
230
+ | --- | ---: | ---: | ---: | ---: |
231
+ | Unmodified 0.44.0, 1,200 virtual ticks | 300 | 23,171 | 12.23 / 16.72 | 134,431,008 / 238,534,656 |
232
+ | Final scheduled/delta delivery, 1,200 virtual ticks | 300 | 9,937 | 10.57 / 15.59 | 129,070,360 / 232,275,968 |
233
+ | Final scheduled/delta delivery, 120 virtual ticks | 1,000 | 10,258 | 33.88 / 52.12 | 190,297,048 / 328,974,336 |
234
+ | Gate links, 4 Chrome pages, reconnect churn and host restore, before roster patches | 300 | 88,444 | 15.79 / 73.47 | 142,211,400 / 375,734,272 |
235
+ | Same mixed transport workload, with roster patches | 300 | 13,623 | 13.52 / 25.33 | 154,397,384 / 274,808,832 |
236
+
237
+ Steady-state downstream falls about **57%** at 300. The two preliminary mixed
238
+ runs include recovery traffic and measured a host wake (potentially several
239
+ ticks); they are not directly comparable to the steady-state pair or the final
240
+ single-tick measurements below. They did not declare rounds. The final harness
241
+ declares a ten-minute round and verifies that failures preserve it.
242
+
243
+ The mixed harness uses the real Gate/Concentrator classes, rules loader,
244
+ host and NetRoom, external local WebSockets and four Chrome pages rendering
245
+ received bodies, with in-memory links standing in for Durable Object bindings.
246
+ Actual public Worker routing and workerd eviction are checked separately below.
247
+
248
+ Commands:
249
+
250
+ ```sh
251
+ node packages/studio/test/rules-crowd-local.mjs 300 60
252
+ node packages/studio/test/rules-crowd-local.mjs 1000 60
253
+ node --test packages/studio/test/rules-gates.test.mjs packages/studio/test/rules-interest.test.mjs
254
+ ```
255
+
256
+ The sustained, real-time 300/1,000 mixed runs live in `test:rules:extended`,
257
+ which runs files sequentially so load experiments do not compete with each other.
258
+ Virtual-time tests cover batching/order, 1,000 logical admissions, link cleanup,
259
+ spatial boundaries, quantisation, far scheduling and keyframe recovery.
260
+
261
+ ### Admission, compatibility and recovery proofs
262
+
263
+ Existing browser-hosted netplay games retain the build and runtime path from
264
+ 0.44.1, including host helpers, HUD and port import. Their manifest precedence
265
+ and 32-seat limit remain; larger requests print the limit and rewrite guide.
266
+ The generated Worker supplies Gate/Concentrator exports for pre-Gate studio
267
+ entries without rewriting custom Worker source. The release gate uses unchanged Ember Vale files from released 0.32.1, packs and
268
+ installs the current package, builds it and runs the real two-browser check
269
+ through a completed round. Starters/docs teach rules plus view only.
270
+ Migrating the rules fixtures exposed missing TypeScript resolution for shared parts;
271
+ the guarded checker now resolves those same declared parts as the bundler.
272
+
273
+ The public Worker test verifies its actual authorization and capacity selection
274
+ for 300 and 1,000 against Gate bindings, including a private-door refusal and
275
+ ignoring caller-supplied capacity/hosting. Real local workerd tests additionally
276
+ prove 20 Gate binding links through concentrators and a Gate abort, and the full
277
+ public Worker → Gate → Table/SQLite route: 40 seats in a declared 300-player room,
278
+ then Gate death and Table death, with every token resuming its original seat.
279
+ The extended Workerd case also passed all **1,000 actual public admissions**
280
+ across 16 Gates/two concentrators, then a Gate abort (59 returning clients) and
281
+ a Table abort (all 1,000 returning clients), retaining every seat. That fixture
282
+ runs at 1 Hz and is a storage/admission proof, not a 20 Hz capacity benchmark.
283
+ These are functional proofs; the measured full crowds below use in-memory
284
+ internal binding links as described above, not a Cloudflare deployment.
285
+
286
+ Both declared-round mixed receipts now pass:
287
+
288
+ | Local mixed run | Bytes/player/s, all measured traffic | Tick p50 / p95 / max ms | Peak Node heap / RSS bytes | Churn |
289
+ | --- | ---: | ---: | ---: | ---: |
290
+ | 300 players, 4 Chrome pages, 62.93 s | 10,463 | 10.21 / 31.54 / 142.32 | 206,609,760 / 313,114,624 | 15 |
291
+ | 1,000 players, 4 Chrome pages, 101.02 s | 9,203 | 32.97 / 59.29 / 188.74 | 314,542,056 / 573,784,064 | 50 |
292
+
293
+ Each run recovered all players after both failures within the same live round;
294
+ simulated clients retained their seats, and all four real pages delivered live
295
+ snapshot receipts after recovery. The final runs also verify each simulated and
296
+ real client's own body after recovery. The 300 run's initial steady 20-second window
297
+ was 9,274 bytes/player/s; the 1,000 run measured 7,931 over its first 20.19 seconds.
298
+ Recovery-window averages include disconnected intervals,
299
+ so the seeded virtual comparison above is the fair before/after bandwidth pair.
300
+ Mixed tick timing is now one host tick through snapshot enqueue; earlier mixed
301
+ numbers measured a host wake, potentially several ticks. Browser process memory
302
+ is excluded from Node heap/RSS. The 300 run averaged 19.05 simulation ticks/s
303
+ including failures; the 1,000 run averaged 16.27. CPU timings vary with other
304
+ machine activity; 1,000 p95 exceeds a
305
+ 50-ms tick period, so this is not a claim of guaranteed 20 Hz on Cloudflare.
306
+
307
+ The earlier failed 1,000 run is superseded. Fixes isolated a single failed
308
+ client send from its entire Gate, compacted identical fanout rows on internal
309
+ links, and made the restart harness reconstruct both saved relay seats and the
310
+ host (as a Table restart does) instead of rejoining every old connection just
311
+ before disconnecting it. Final root and six-check CI results are tracked in
312
+ [PR #85](https://github.com/homie-rocks/homie/pull/85). No deployment or merge
313
+ was performed.
314
+
315
+ Competing full-suite and load runs triggered the real Workerd overrun guard
316
+ and a mixed-run recovery timeout. They are failed stress attempts, not capacity
317
+ receipts. The successful full Workerd rerun kept that guard enabled and ran
318
+ without our other load runs. No Cloudflare CPU, memory or network guarantee is
319
+ inferred from these local results.
320
+
321
+ The scripted recovery checks include deliberate observation waits. All clients
322
+ were back when checked at 20.08 s (Gate) / 20.74 s (rules) at 300, and
323
+ 20.10 s / 60.00 s at 1,000. These are upper bounds, not minimum recovery latency.
324
+ The 1,000-client full restart is visibly expensive; faster crowd reconnection
325
+ and deployed latency measurements remain work for the milestone proof slice.
326
+
327
+ ## Later step: retire browser-hosted netplay
328
+
329
+ Retirement is not part of 0.45.0. Its preconditions are that every game in
330
+ Homie's own three live studios has moved to server rules, and a release has
331
+ already shipped a one-command assisted rewrite for other studios. Until both
332
+ are met, existing games must continue to build, pass check, run and deploy,
333
+ with the legacy release gate protecting that promise. New games remain rules
334
+ games only.
335
+
336
+ ### Upgrade proof on the real studio copy
337
+
338
+ Copied `/Users/ryan/Studios/homie-arcade` to
339
+ `/tmp/homie-arcade-045-0Vaqlp/studio`, packed and installed 0.45.0 there.
340
+ `npm run build` passed for all five existing netplay games.
341
+ `npm run check -- --url http://127.0.0.1:8898` passed for its default game,
342
+ 2048 Race: desktop and phone finished round 1 in 123 seconds, with both
343
+ connections uninterrupted. The original studio was not changed; nothing was
344
+ deployed. The released 0.32.1 Ember Vale gate also passed with an older Worker
345
+ entry: one host and one replica finished round 1 in 92 seconds.
@@ -137,6 +137,58 @@ for an app. A wall/TV watches without taking a seat. Each interactive phone
137
137
  takes one of the room's declared seats; shared state is replicated, public and transient. An app's
138
138
  lasting, authorized business data belongs in `createAppRecords`, not in room fields.
139
139
 
140
+ ## Lasting worlds and account characters
141
+
142
+ For a world that should still exist tomorrow, set game.json:
143
+
144
+ ```json
145
+ {"room":{"host":"server","lifetime":"persistent","characters":true}}
146
+ ```
147
+
148
+ Lasting worlds default to `offline: false`: wait for the durable server. A studio
149
+ may explicitly set `offline: true` for separate local practice, whose progress
150
+ is not saved to the world or account. Never count that as proof of persistence.
151
+
152
+ `characters` is optional: `lifetime` alone keeps the world. Account characters
153
+ require the existing studio sign-in/passkey. Play redirects to the account page
154
+ when needed. In `room.join(ctx, player)`, return
155
+ `player.character ?? { kind: 'runner', at: spawn }`. Keep inventory in that player
156
+ kind's declared fields and change it only in rules. Mark inventory/currency and
157
+ collectible-ID sets with `{durable: true, visibility: 'owner'}`; use `durable: true`
158
+ for world changes and public progress too, omitting visibility only when public.
159
+ Durability and recipient visibility are separate declarations. The runtime returns its kind,
160
+ position, heading, fields and motion to the account when it leaves. Use
161
+ `player: true` or `leave: 'despawn'`; a returned character cannot also become a bot.
162
+ Do not reset inventory in `arrive`, round-start handlers or `world.finish`.
163
+
164
+ The public world has a stable room name; `?room=<name>` chooses another world.
165
+ Every durable change commits before publishing its results. An empty world sleeps and
166
+ retains state. A failed write stops play with the last good save intact. Another
167
+ room waits for the current holder to return the character; no timeout grants a
168
+ stale copy. No database or IDs are set up by hand. Ordinary games keep their
169
+ existing save frequency and behavior.
170
+
171
+ Write idempotent pickups using a saved collectible ID/set; duplicate commands
172
+ must not mint again. Events arrive later and can become `undeliverable` when a
173
+ recipient leaves; do not treat sending one as an atomic inventory transfer.
174
+ Trading and shop-grant consumption need the later economy slice. Browser saves
175
+ remain player-owned and are not an authoritative inventory.
176
+
177
+ Durable fields, entity lifecycle, pending events and character leases use an
178
+ atomic incremental journal. The rest is checkpointed every 30 seconds by default
179
+ (`room.durability.movementSeconds`, 1–60), and on pause/shutdown. Unchanged rooms
180
+ write nothing. A crash can rewind movement, but committed value and consumed
181
+ inputs replay together exactly once. Declare every fact needed to prevent a
182
+ repeat reward durable, including pickup IDs and cooldowns that protect value.
183
+ Compatible deploys still restart/reload and then restore the world.
184
+ A state-schema change is refused on restore with data retained; keep the previous
185
+ compatible build until migrations ship. Offline play has no account authority.
186
+
187
+ For proof, build normally, then sign two players in and test movement, pickup,
188
+ restart mid-pickup, a compatible rebuild, and a fresh profile signing in as the
189
+ same player. Verify actual inventory and world state. A lasting world need not
190
+ finish a round: its browser proof replaces the match check's round requirement.
191
+
140
192
  ## State and field types
141
193
 
142
194
  `f` declares state, event/command/effect payloads, ask state and guide views.
@@ -683,7 +735,8 @@ for a minute with delay. Movement should respond before the authoritative respon
683
735
  score and other shared outcomes still arrive with the network. The studio chooses `players.max`; neither frame rate nor feel is guaranteed by a passing build.
684
736
 
685
737
  Room state is saved automatically (default movementSeconds: 1, plus round end,
686
- pause and finish). After 60 seconds with no person the room ends even if screens or
738
+ pause and finish; a lasting world instead journals its durable fields at once and
739
+ checkpoints the rest every 30 seconds). After 60 seconds with no person the room ends even if screens or
687
740
  AI remain. Use browser createSaves for player-owned character progress; it is not
688
741
  server-verified money. Entity fields default to public. Declare visibility explicitly for private information (below); shared state and motion remain public. Use declared server round records for verified match history.
689
742
 
@@ -727,8 +780,17 @@ Rules, collision, saves and shared state stay authoritative and unchanged.
727
780
  Views must interpolate distant motion and dispose/recreate entities on view exit
728
781
  and entry. Omit the settings for full precision and the room's normal tick rate.
729
782
 
730
- A small room embeds delivery in its Table. Larger rooms open Gate connections;
731
- more than eight Gates use concentrators. The studio template supplies their exports, bindings and
783
+ A small room embeds delivery in its Table. Larger rooms open Gate connections, one channel
784
+ from each Gate to the room: the room runs the rules and hands each Gate one world a tick, and
785
+ the Gate selects, encodes and paces each player's view. A player on a slow connection is sent
786
+ fewer, fresher frames, never a growing backlog; draw from the newest snapshot and interpolate.
787
+ A body that keeps its course is not sent every tick: the view library moves it along its last
788
+ velocity, and it is sent again when that has drifted past `view.precisionM` (near bodies) or half
789
+ the distance it covers between `view.farHz` refreshes (far ones). `precisionM` is what a crowd
790
+ costs a player's connection: 0.01 is a centimetre; 0.05 sends about a sixth fewer bytes.
791
+ Homie sets no pace on what a player sends a server-hosted game. To set your own, add
792
+ `"rates": { "in": 60 }` to `room` in game.json: messages a second per player, by frame kind.
793
+ The studio template supplies the Gate exports, bindings and
732
794
  migration; upgrade the template before deploying an existing studio. No infrastructure naming or studio admission ceiling is required.
733
795
  Read the local measurements and their limitations in
734
796
  `docs/rooms-milestone-2-notes.md` before making a capacity claim.
@@ -179,11 +179,55 @@ edits, build, act on the diagnostics and test the actual play before declaring i
179
179
  Never turn typing off to make room: place the strip instead (`chat/CHAT.md` has every field).
180
180
  - Update `game.json` `name` and `blurb`, and the `<title>`.
181
181
 
182
+ ## Lasting worlds and account characters
183
+
184
+ For a world that should still exist tomorrow, set game.json:
185
+
186
+ ```json
187
+ {"room":{"host":"server","lifetime":"persistent","characters":true}}
188
+ ```
189
+
190
+ Lasting worlds default to `offline: false`: wait for the durable server. A studio
191
+ may explicitly set `offline: true` for separate local practice, whose progress
192
+ is not saved to the world or account. Never count that as proof of persistence.
193
+
194
+ `characters` is optional: `lifetime` alone keeps the world. Account characters
195
+ require the existing studio sign-in/passkey. Play redirects to the account page
196
+ when needed. In `room.join(ctx, player)`, return
197
+ `player.character ?? { kind: 'runner', at: spawn }`. Keep inventory in that player
198
+ kind's declared fields and change it only in rules. The runtime returns its kind,
199
+ position, heading, fields and motion to the account when it leaves. Use
200
+ `player: true` or `leave: 'despawn'`; a returned character cannot also become a bot.
201
+ Do not reset inventory in `arrive`, round-start handlers or `world.finish`.
202
+
203
+ The public world has a stable room name; `?room=<name>` chooses another world.
204
+ Every tick commits before publishing its results. An empty world sleeps and
205
+ retains state. A failed write stops play with the last good save intact. Another
206
+ room waits for the current holder to return the character; no timeout grants a
207
+ stale copy. No database or IDs are set up by hand. Ordinary games keep their
208
+ existing save frequency and behavior.
209
+
210
+ Write idempotent pickups using a saved collectible ID/set; duplicate commands
211
+ must not mint again. Events arrive later and can become `undeliverable` when a
212
+ recipient leaves; do not treat sending one as an atomic inventory transfer.
213
+ Trading and shop-grant consumption need the later economy slice. Browser saves
214
+ remain player-owned and are not an authoritative inventory.
215
+
216
+ This first slice saves the whole world every tick, so opted-in games pay for
217
+ more writes. Compatible deploys still restart/reload and then restore the world.
218
+ A state-schema change is refused on restore with data retained; keep the previous
219
+ compatible build until migrations ship. Offline play has no account authority.
220
+
221
+ For proof, build normally, then sign two players in and test movement, pickup,
222
+ restart mid-pickup, a compatible rebuild, and a fresh profile signing in as the
223
+ same player. Verify actual inventory and world state. A lasting world need not
224
+ finish a round: its browser proof replaces the match check's round requirement.
225
+
182
226
  ## Progress that lasts: cloud saves
183
227
 
184
228
  When the plan says progress persists across sessions or devices (the codex's "Progress that lasts", or the person
185
- asks for a character, levels, unlocks, a collection, hardcore), wire in saves. Never keep it in the room: a room
186
- forgets everything 60 s after its last player leaves.
229
+ asks for a character, levels, unlocks, a collection, hardcore), wire in saves. For player-owned browser progress use the existing saves API below. For a server-authoritative
230
+ world or inventory, use Lasting worlds above. Ordinary match rooms expire after their last player leaves.
187
231
 
188
232
  - `game.json`: `"saves": true`. A new game of that kind can start from the starter:
189
233
  `npx --no-install homie-studio game new <id> --from ember-vale --name "<Name>"` (a hero that lasts, lifetime