@typeonce/oxlint-plugin-ritmo 0.13.0 → 0.15.0

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
@@ -1,5 +1,99 @@
1
1
  # @typeonce/oxlint-plugin-ritmo
2
2
 
3
+ ## 0.15.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 3a195b7: **Cooldowns and timers are deadlines: the step they end on, exact through saves and rollback.** A timer counted down by `dt` drifts by a rounded float every tick, and the float it saves means nothing once the fixed step changes. `Clock.Deadline<Hz>` is the absolute step a duration ends on, a plain number branded with the clock's rate:
8
+
9
+ ```ts
10
+ // ready: Clock.Deadline<60> | null, its schema narrowing with Clock.isDeadline(step)
11
+ const Weapon = Descriptor.ConstructedComponent(
12
+ z.object({ ready: z.unknown().refine(Clock.isDeadline(step)).nullable() })
13
+ )("Game/Weapon");
14
+
15
+ const time = resources.time.get();
16
+ const { ready } = data.weapon.get();
17
+ if (ready === null || Clock.reached(time, ready)) {
18
+ fire();
19
+ data.weapon.set({ ready: Clock.deadline(time, Clock.duration(step, 0.5)) });
20
+ }
21
+ ```
22
+
23
+ - `Clock.deadline(time, duration)`, `Clock.reached(time, deadline)`, and `Clock.remaining(time, deadline)` (whole steps left, for a readout). A deadline of a 60 Hz clock does not compile against a 30 Hz `Time`, and a raw number is not a deadline.
24
+ - `Clock.isDeadline(step)` is the guard for a game's schema, like `Entity.isHandle`: any whole number of steps, 0 or more.
25
+ - New lint rule `ritmo/no-float-timers` for simulation files: reports `timer -= dt`, `cooldown - time.dt`, and the like, and names `Clock.deadline` / `Clock.reached`. `position.x += velocity.x * dt` is integration and is not reported. Turn it on in the simulation override of `.oxlintrc.json`: `"ritmo/no-float-timers": "error"`.
26
+
27
+ - c75daff: **`oxlint --fix` does the whole job for `ritmo/use-ops-for-math`.** The rule points at `Ops` from `@typeonce/ritmo` (it moved from `@typeonce/ritmo-math`), and its fix now adds `import { Ops } from "@typeonce/ritmo"` when the file has none, once per file, after the last import (a `const { Ops } = require("@typeonce/ritmo")` in CommonJS, for vendored code). `x **= y` is fixed to `x = Ops.pow(x, y)` when `x` is a variable. `ritmo/use-random-for-randomness` names `Random` from `@typeonce/ritmo` the same way.
28
+
29
+ **Aliasing `Math` is reported.** `const { sin } = Math`, `const M = Math`, passing `Math` to a function, `globalThis.Math.sin`, and `Math[name]` with a computed key hid a non-exact call from the rule; each is now reported (without a fix). Exact members (`Math.PI`, `Math.abs`, `const { floor } = Math`) stay valid.
30
+
31
+ **New rule `ritmo/no-brand-cast`.** A cast to a branded type (`raw as ItemId` where `ItemId` comes from `.brand()`, `Schema.brand`, `Brand.Branded`, or a Ritmo brand such as `Random.State` or `Clock.Deadline`) skips the check the brand stands for. The rule reports it in simulation code and names the fix: decode through the schema, or the Ritmo constructor (`Random.seed`, `Clock.deadline`, `Game.Entity.handle`). Turn it on in the simulation override:
32
+
33
+ ```json
34
+ {
35
+ "files": ["src/simulation/**"],
36
+ "rules": { "ritmo/no-brand-cast": "error" }
37
+ }
38
+ ```
39
+
40
+ ## 0.14.0
41
+
42
+ ### Minor Changes
43
+
44
+ - 70d054e: **Rewind a runtime in memory, for rollback netcode and client prediction.** `runtime.checkpoint(simulate)` marks the world between ticks, and `runtime.rewind(checkpoint)` puts it back exactly: ticking `simulate` again gives the same results, bit for bit, as a runtime that never rewound (entity ids, values and their change ticks, relations, scopes, resources, machines, queued commands, unread events, and the read positions of `simulate`'s systems). See the `Checkpoint` module, and the skill's new `playbooks/netcode.md`.
45
+
46
+ ```ts
47
+ const history = new Map<number, Checkpoint.Checkpoint<typeof Root>>();
48
+ history.set(tick, runtime.checkpoint(simulate));
49
+ runtime.tick(simulate);
50
+
51
+ // Real input for an earlier tick differs from the guess: go back and run again.
52
+ const rewound = runtime.rewind(history.get(wrongTick)!);
53
+ if (!rewound.ok) resync(rewound.error); // Released: older than the window
54
+ ```
55
+
56
+ - Taking a checkpoint copies only resources, machines, and queues; the first change to a page of values, an entity, a relation, or a scope after it keeps what it replaced. The runtime keeps the last `checkpoints` (a new option of `Game.Runtime.make`, `Checkpoint.defaultWindow` = 16 by default); an older one, one newer than a checkpoint rewound to, and every one taken before a `restore` fail with `Released`. A checkpoint of another runtime fails with `OtherRuntime`.
57
+ - A schedule that would not rewind does not compile, and the error (`__fixCheckpoint__`) names the fix: a service that is neither an input source (`snapshot()`) nor plain data, a system with `local` state (in its state transitions too), or a schedule widened to a schedule type.
58
+ - Systems and inspectors outside the rewound schedule, like renderers, see a rewind as ordinary changes. An entity the rewind took away and the ticks after it brought back under the same id is seen as changed, never as despawned and spawned again, so `RenderSync` keeps its node.
59
+ - **`runtime.checksum()`**: a fingerprint of what `snapshot()` saves, as 16 hex digits, that does not depend on how the world was built (component order, object key order). Peers compare it to catch a desync; gated like `snapshot`, and returns a `Result`.
60
+ - `Schedule.Source<Data>` and `Schedule.IsPlain<T>`: the input-source shape and the plain-data check that replays and checkpoints share. `Schedule.SystemsIn` is exported.
61
+
62
+ **Devtools:**
63
+
64
+ - **Breaking: `Replay.Source` and `Replay.IsPlain` moved to core**, as `Schedule.Source` and `Schedule.IsPlain`.
65
+
66
+ ```diff
67
+ -const Controls = Descriptor.Service<Replay.Source<Input>>()("Game/Controls")
68
+ +import type * as Schedule from "@typeonce/ritmo/Schedule"
69
+ +const Controls = Descriptor.Service<Schedule.Source<Input>>()("Game/Controls")
70
+ ```
71
+
72
+ - **Breaking: replay checkpoint hashes are `runtime.checksum()`.** Replays recorded with an earlier version report every checkpoint as diverged; record them again. A runtime passed to `Replay.recorder` or `Replay.session` needs `checksum`, which every runtime with `snapshot` has.
73
+
74
+ **Lint:** `handle-tick-result` also reports a dropped `runtime.rewind(...)` result: a released checkpoint changes nothing, and the ticks meant to run again would run on top of the present.
75
+
76
+ - dbfbd9d: **New package: `@typeonce/ritmo-netcode`, online multiplayer.** A session per peer exchanges inputs over a `NetworkLink` and ticks the simulation with every seat's input: `Netcode.rollback` runs at once on guesses and rolls back with the runtime's checkpoints when real input contradicts one; `Netcode.lockstep` waits for every seat. Seat 0 starts the match and every resync from one save that every peer restores at the same tick; `session.rate` slows the peer that runs ahead; peers compare checksums of confirmed ticks, and a mismatch stops the session with `Desynced` until `resync()`.
77
+
78
+ ```ts
79
+ const seats = Netcode.seats(PlayerInput, { count: 2, idle }) // the simulation's input source
80
+ const session = Netcode.rollback(runtime, { simulate, seats: seats.value, seat, links: [WebSocketNetworkLink.make(socket)], hostClock, step })
81
+ FixedLoop.start({ ..., rate: session.value.rate, update: session.value.update({ input: readInput, onHalted: report }) })
82
+ ```
83
+
84
+ - Transports: `WebSocketNetworkLink.make(socket)` (a relay; the browser's, Node's, Deno's, or Bun's WebSocket), `WebRtcNetworkLink.make(channel)` (between peers), `MemoryNetworkLink.make(...)` (seeded latency, jitter, and loss, for headless tests), or any `{ send, receive, status }`.
85
+ - What does not compile: a rollback simulation that cannot be rewound, one whose requirements the runtime does not provide, and a runtime that cannot save. What fails at construction, as a typed `Result`: a seat out of range, seats another session took or the runtime does not provide, and a `maxRollback` beyond the checkpoints the runtime keeps.
86
+ - The skill's `playbooks/netcode.md` now drives the package instead of a hand-written loop.
87
+
88
+ **Core:**
89
+
90
+ - `FixedLoop.start` takes `rate`, read once per frame, within `FixedLoop.rateRange` (0.9 to 1.1): how fast host time runs into the accumulator, for a networked session's pacing. A value outside the range stops the loop with an `InvalidRate` failure, a new member of `FixedLoop.Failure`.
91
+ - **`runtime.restore` sets the next entity id to the save's**, where it used to keep the higher of the save's and the runtime's own. The same save restored in two runtimes now allocates the same ids afterwards, whatever each held before; peers of a networked game need it. A handle kept from before a restore may now name an entity spawned after it: drop handles across a restore, as their ids could already name restored entities.
92
+
93
+ **Lint:** `keep-simulation-headless` reports `WebSocket`, `RTCPeerConnection`, and `RTCDataChannel` with their own message: online play runs the simulation under a netcode session, and remote input goes through `Netcode.seats`, never `runtime.send(...)`.
94
+
95
+ **Devtools:** `Desync.compare(mine, theirs)` lists every difference between two saves of a tick, entities by id and values by path: the report for a `Desynced` session made with `keepSnapshots: true`.
96
+
3
97
  ## 0.13.0
4
98
 
5
99
  ### Minor Changes
package/README.md CHANGED
@@ -5,7 +5,9 @@
5
5
  Ritmo's types reject wrong calls, and its devtools lints reject wrong runs. These rules catch the source patterns neither can see:
6
6
 
7
7
  - simulation code that reads the wall clock, `Math.random`, engine-dependent math, or the page;
8
+ - timers counted in floats;
8
9
  - data that cannot be saved;
10
+ - casts that claim a brand's check without running it;
9
11
  - state values that keep a previous state's fields;
10
12
  - runtime results that are dropped.
11
13
 
@@ -39,14 +41,16 @@ Register the plugin and turn the rules on in `.oxlintrc.json`. The simulation ru
39
41
  "ritmo/use-random-for-randomness": "error",
40
42
  "ritmo/use-ops-for-math": "error",
41
43
  "ritmo/keep-simulation-headless": "error",
42
- "ritmo/no-infinity-in-simulation-data": "error"
44
+ "ritmo/no-infinity-in-simulation-data": "error",
45
+ "ritmo/no-float-timers": "error",
46
+ "ritmo/no-brand-cast": "error"
43
47
  }
44
48
  }
45
49
  ]
46
50
  }
47
51
  ```
48
52
 
49
- Rules are named `ritmo/<rule>`. `ritmo/use-ops-for-math` and `ritmo/use-cell-value` fix themselves with `oxlint --fix` (`use-ops-for-math` once `Ops` is imported in the file).
53
+ Rules are named `ritmo/<rule>`. `ritmo/use-ops-for-math` and `ritmo/use-cell-value` fix themselves with `oxlint --fix`.
50
54
 
51
55
  A deliberate exception, such as a host-time module inside a simulation folder, takes a disable comment with the reason:
52
56
 
@@ -59,10 +63,12 @@ const started = performance.now()
59
63
  |---|---|---|---|
60
64
  | [`use-clock-for-time`](#ritmouse-clock-for-time) | simulation | `Date.now()`, `performance.now()`, `new Date()`, timers | `Clock` |
61
65
  | [`use-random-for-randomness`](#ritmouse-random-for-randomness) | simulation | `Math.random()`, `crypto` randomness | `Random.draw(resources.rng)` |
62
- | [`use-ops-for-math`](#ritmouse-ops-for-math) | simulation | `Math.sin`, `Math.hypot`, `a ** b`, ... | `Ops` |
66
+ | [`use-ops-for-math`](#ritmouse-ops-for-math) | simulation | `Math.sin`, `Math.hypot`, `a ** b`, `const { sin } = Math`, ... | `Ops` |
63
67
  | [`keep-simulation-headless`](#ritmokeep-simulation-headless) | simulation | page globals, host I/O, renderer imports | input and data from the host, drawing in a render schedule |
64
68
  | [`no-infinity-in-simulation-data`](#ritmono-infinity-in-simulation-data) | simulation | `Infinity` / `NaN` in object literals | `null` |
65
- | [`handle-tick-result`](#ritmohandle-tick-result) | everywhere | a dropped `runtime.tick(...)` / `restore(...)` result | check `.ok` |
69
+ | [`no-float-timers`](#ritmono-float-timers) | simulation | `timer -= dt`, `cooldown - time.dt` | `Clock.deadline` / `Clock.reached` |
70
+ | [`no-brand-cast`](#ritmono-brand-cast) | simulation | `raw as UserId`, `1 as Random.State` | the schema or constructor that brands it |
71
+ | [`handle-tick-result`](#ritmohandle-tick-result) | everywhere | a dropped `runtime.tick(...)` / `restore(...)` / `rewind(...)` result | check `.ok` |
66
72
  | [`prefix-descriptor-and-system-names`](#ritmoprefix-descriptor-and-system-names) | everywhere | `"Position"`, `Game.System("Move", ...)` | `"Game/Position"` |
67
73
  | [`use-cell-value`](#ritmouse-cell-value) | everywhere | `cell.present ? cell.get() : undefined` | `cell.value()` |
68
74
  | [`no-state-spread`](#ritmono-state-spread) | everywhere | `{ ...ground, _tag: "air", vy }` | `cell.transition({ from, to, data })`, `nextMachines.x.set({ _tag, ...fields })`, or the new state's fields written out |
@@ -80,7 +86,7 @@ setTimeout(() => spawnWave(), 500) // reported
80
86
  // instead
81
87
  const time = resources.time.get()
82
88
  if (Clock.elapsed(time) > 3) open() // seconds since the start
83
- const due = time.step + Clock.steps(Clock.duration(step, 0.5)) // store it, compare each tick
89
+ const due = Clock.deadline(time, Clock.duration(step, 0.5)) // store it, Clock.reached(time, due) each tick
84
90
  if (Clock.every(time, waveEvery)) spawnWave() // repeats
85
91
  ```
86
92
 
@@ -103,19 +109,23 @@ Catches `Math.random()`, `crypto.getRandomValues()`, and `crypto.randomUUID()`.
103
109
 
104
110
  ### `ritmo/use-ops-for-math`
105
111
 
106
- The spec lets engines approximate `Math.sin`, `cos`, `tan`, `asin`, `acos`, `atan`, `atan2`, `exp`, `expm1`, `log`, `log2`, `log10`, `log1p`, `cbrt`, `pow`, `hypot`, `sinh`, `cosh`, `tanh`, `asinh`, `acosh`, `atanh`, and `a ** b`, and they do: Chrome, Safari, macOS, and Linux disagree in the last bit, and a simulation grows that bit into a different run. [`Ops`](https://github.com/typeonce-dev/ritmo/blob/main/packages/math/README.md#determinism-across-devices) from `@typeonce/ritmo-math` has each of them as a port that returns the same bits everywhere.
112
+ The spec lets engines approximate `Math.sin`, `cos`, `tan`, `asin`, `acos`, `atan`, `atan2`, `exp`, `expm1`, `log`, `log2`, `log10`, `log1p`, `cbrt`, `pow`, `hypot`, `sinh`, `cosh`, `tanh`, `asinh`, `acosh`, `atanh`, and `a ** b`, and they do: Chrome, Safari, macOS, and Linux disagree in the last bit, and a simulation grows that bit into a different run. [`Ops`](https://github.com/typeonce-dev/ritmo/blob/main/packages/core/README.md) from `@typeonce/ritmo` has each of them as a port that returns the same bits everywhere.
107
113
 
108
114
  ```ts
109
115
  const turn = Math.atan2(Math.sin(b - a), Math.cos(b - a)) // reported
110
116
  const beauty = base * repeat ** n // reported
111
117
 
112
118
  // instead
113
- import { Ops } from "@typeonce/ritmo-math"
119
+ import { Ops } from "@typeonce/ritmo"
114
120
  const turn = Ops.atan2(Ops.sin(b - a), Ops.cos(b - a))
115
121
  const beauty = base * Ops.pow(repeat, n)
116
122
  ```
117
123
 
118
- `Math.sqrt`, `abs`, `min`, `max`, `floor`, `ceil`, `round`, `trunc`, `sign`, `+ - * /`, and `x ** 2` are exact everywhere and are not reported. With `Ops` imported in the file, `oxlint --fix` rewrites the calls.
124
+ `Math.sqrt`, `abs`, `min`, `max`, `floor`, `ceil`, `round`, `trunc`, `sign`, `+ - * /`, and `x ** 2` are exact everywhere and are not reported (`Math.PI`, `Math["floor"]`, and `const { abs, PI } = Math` neither).
125
+
126
+ `oxlint --fix` does the whole change in one run: it rewrites `Math.sin(x)` to `Ops.sin(x)`, `a ** b` to `Ops.pow(a, b)`, and `x **= y` to `x = Ops.pow(x, y)`, and adds `import { Ops } from "@typeonce/ritmo"` once, after the last import (`const { Ops } = require("@typeonce/ritmo")` in a CommonJS file). It uses `Ops` where the file already imports it, under any name (`import { Ops as M }`, `import * as Ops from "@typeonce/ritmo/Ops"`). It leaves the report unfixed where a rewrite could change the code: `body.speed **= y` (the rewrite would evaluate `body` twice), and a file or function where the name `Ops` already means something else (a type-only import included).
127
+
128
+ The global Math handed on as a value hides the calls made through it from the rule, so it is reported too (without a fix): an alias (`const M = Math`), a destructured function or rest element (`const { sin } = Math`), an argument (`apply(Math, "sin", x)`), a computed key (`Math[name]`), and `globalThis.Math` used the same ways. Call `Ops.sin` directly, and read exact members by name. A local named `Math` is not the global and is not reported.
119
129
 
120
130
  ### `ritmo/keep-simulation-headless`
121
131
 
@@ -124,7 +134,8 @@ The simulation runs in tests, bots, replays, and on servers, where there is no p
124
134
  | Reported | Setup instead |
125
135
  |---|---|
126
136
  | Page globals: `window`, `document`, `navigator`, `matchMedia`, ... | Capture input in the host with `Keyboard`, `Gamepad`, `Pointer`, or `Touch` (merged with `Controls`) from `@typeonce/ritmo-browser` and `InputCapture` into a resource that systems read. Pass page state (size, settings) in with `runtime.send(...)` or a resource. |
127
- | Host I/O: `localStorage`, `fetch`, `WebSocket`, `location`, ... | Do the I/O in host code and pass the result in with `runtime.send(...)` or a resource. Save and load the world in the host with `runtime.snapshot()` and `runtime.restore(...)`. |
137
+ | Host I/O: `localStorage`, `fetch`, `location`, ... | Do the I/O in host code and pass the result in with `runtime.send(...)` or a resource. Save and load the world in the host with `runtime.snapshot()` and `runtime.restore(...)`. |
138
+ | Connections to other peers: `WebSocket`, `RTCPeerConnection`, `RTCDataChannel` | For online play, run the simulation under a [`@typeonce/ritmo-netcode`](https://github.com/typeonce-dev/ritmo/blob/main/packages/netcode/README.md) session: host code opens the connection and wraps it in a link, and remote input reaches the simulation through `Netcode.seats`, never `runtime.send(...)`. |
128
139
  | Renderer and UI imports, types included: `pixi.js`, `three`, `@typeonce/ritmo-render`, `react`, `preact`, ... | Draw from a render schedule in render code: mirror entities into nodes with `RenderSync` and a `NodeRegistry` from `@typeonce/ritmo-render`, and declare renderer services (a node registry) and their types there; renderer nodes stay in the registry, never in components. The schema and simulation systems name no renderer type, so another renderer can replace this one. |
129
140
 
130
141
  Locals and fields with these names (`term.window`, a `location` parameter) are not globals and are not reported.
@@ -146,25 +157,72 @@ dash: { remaining: 0, since: null } // since: numbe
146
157
 
147
158
  Catches `Infinity`, `-Infinity`, `NaN`, and `Number.POSITIVE_INFINITY` / `NEGATIVE_INFINITY` / `NaN` as a property value in any object literal in simulation files, including values built in helpers before they are spawned. Search seeds in locals (`let best = Infinity`) are not reported.
148
159
 
160
+ ### `ritmo/no-float-timers`
161
+
162
+ A timer counted down by `dt` adds a rounded float every tick, so it ends a step early or late, and the float it saves means nothing once the fixed step changes. A deadline is the step the timer ends on: written once, exact, and valid after a restore or a rollback, since the clock it is measured against is saved and rewound with it.
163
+
164
+ ```ts
165
+ cooldown.remaining -= dt // reported
166
+ data.buff.set({ ...buff, left: buff.left - time.dt }) // reported
167
+
168
+ // instead: ready: Clock.Deadline<60> | null, its schema narrowing with Clock.isDeadline(step)
169
+ const cooldown = Clock.duration(step, 0.5)
170
+ const time = resources.time.get()
171
+ const { ready } = data.weapon.get()
172
+ if (ready === null || Clock.reached(time, ready)) {
173
+ fire()
174
+ data.weapon.set({ ready: Clock.deadline(time, cooldown) })
175
+ }
176
+ const bar = ready === null ? 0 : Clock.remaining(time, ready) / Clock.steps(cooldown) // a readout
177
+ ```
178
+
179
+ Catches a stored value (a local or a field) plus or minus a tick's seconds on their own: `dt`, `deltaTime`, or `deltaSeconds`, as a local, a field (`time.dt`), or a resource read (`resources.deltaTime.get()`), in `x -= dt`, `x += dt`, and `x - dt` / `x + dt` anywhere (`Math.max(0, x - dt)`, an object literal). A rate scaled by `dt` (`position.x += velocity.x * dt`) is integration and is not reported, nor is a count of whole steps (`cooldown - 1`), nor a `delta` that is not time (a pointer's).
180
+
181
+ ### `ritmo/no-brand-cast`
182
+
183
+ A branded type (`UserId`, `Random.State`, `Clock.Deadline<60>`) stands for a check the value passed. A cast claims the brand without running the check, so an invalid value travels as a valid one: a save holding it fails to load, or the simulation computes with it.
184
+
185
+ ```ts
186
+ const UserId = z.string().uuid().brand("UserId")
187
+ type UserId = z.infer<typeof UserId>
188
+ const id = raw as UserId // reported
189
+ const rng = Random.resource("Game/Rng", 1 as Random.State) // reported
190
+
191
+ // instead
192
+ const id = UserId.parse(raw) // Effect: Schema.decodeUnknownSync(UserId)(raw)
193
+ const rng = Random.resource("Game/Rng", Random.seed(1))
194
+ ```
195
+
196
+ Oxlint has no type information, so the rule reads the brand from the code: a cast (`x as T` or `<T>x`) to
197
+ - a brand helper: `Brand.Branded<...>`, Effect's `Brand.Brand<...>`, Zod's `z.BRAND<...>` / `z.$brand<...>`, or a `Brand<...>` / `Branded<...>` of any library;
198
+ - an object type with a brand key: `T & { readonly __brand: "UserId" }` (also `_brand`, `__type`), or a key declared as `declare const brand: unique symbol`;
199
+ - a type alias or interface in the same file that is one of these, or the type of a schema in the same file built with `.brand(...)` / `Schema.brand(...)` (`z.infer<typeof UserId>`, `typeof Gold.Type`, `Schema.Schema.Type<typeof Gold>`);
200
+ - a branded Ritmo export imported from `@typeonce/ritmo` (or a subpath such as `@typeonce/ritmo/Clock`): `Clock.Deadline`, `Clock.Step`, `Clock.Duration`, `Clock.ClockResource`, `Entity.Handle`, `Entity.EntityId`, `Random.State`, `Checkpoint.Checkpoint`, `Checkpoint.Rewindable`.
201
+
202
+ Make the value through its check: decode at the boundary with the game's schema, or with Ritmo's constructor or guard (`Random.seed` / `Random.result`, `Clock.deadline` / `Clock.isDeadline`, `Game.Entity.handle` / `Entity.isHandle`). `as const`, `satisfies`, and casts to types without a brand are not reported, nor are brands imported from another file of the game (the rule cannot see them).
203
+
149
204
  ## Rules for every file
150
205
 
151
206
  ### `ritmo/handle-tick-result`
152
207
 
153
- `runtime.tick(...)` returns a `Result`: a system that fails stops the tick, and the failure comes back here. `runtime.restore(...)` returns one too: an invalid save leaves the previous world in place. Dropping either hides the failure.
208
+ `runtime.tick(...)` returns a `Result`: a system that fails stops the tick, and the failure comes back here. `runtime.restore(...)` returns one too: an invalid save leaves the previous world in place. So does `runtime.rewind(...)`: a checkpoint the runtime let go of changes nothing, and the ticks meant to run again run on top of the present. Dropping any of them hides the failure.
154
209
 
155
210
  ```ts
156
211
  runtime.tick(update) // reported
157
212
  runtime.restore(save) // reported
213
+ runtime.rewind(checkpoint) // reported
158
214
 
159
215
  // instead
160
216
  const ran = runtime.tick(update)
161
217
  if (!ran.ok) console.error(ran.error) // names the system and why
162
218
  const restored = runtime.restore(save)
163
219
  if (!restored.ok) showLoadError(restored.error)
220
+ const rewound = runtime.rewind(checkpoint)
221
+ if (!rewound.ok) resync(rewound.error) // Released or OtherRuntime
164
222
  void runtime.tick(render) // ignored on purpose
165
223
  ```
166
224
 
167
- Catches `tick(...)`, `tryTick(...)`, and `restore(...)` used as a statement on a receiver named like a runtime (`runtime`, `game.runtime`, `worldRuntime`). Game wrappers with other names (`town.restore(...)`) are not reported. Option: `{ "runtimePattern": "^(runtime|world)$" }` (a case-insensitive regular expression for the receiver's name; default `runtime$`).
225
+ Catches `tick(...)`, `tryTick(...)`, `restore(...)`, and `rewind(...)` used as a statement on a receiver named like a runtime (`runtime`, `game.runtime`, `worldRuntime`). Game wrappers with other names (`town.restore(...)`) are not reported. Option: `{ "runtimePattern": "^(runtime|world)$" }` (a case-insensitive regular expression for the receiver's name; default `runtime$`).
168
226
 
169
227
  ### `ritmo/prefix-descriptor-and-system-names`
170
228
 
package/dist/index.js CHANGED
@@ -3,10 +3,10 @@
3
3
  *
4
4
  * Types catch wrong calls and devtools catch wrong runs; these rules catch
5
5
  * the source patterns neither can see: simulation code that reads the wall
6
- * clock, `Math.random`, engine-dependent math, or the page, data that cannot
7
- * be saved, state values that keep a previous state's fields, and runtime
8
- * results that are dropped. Every report names the
9
- * Ritmo API to use instead.
6
+ * clock, `Math.random`, engine-dependent math, or the page, timers counted
7
+ * in floats, data that cannot be saved, casts that skip a brand's check,
8
+ * state values that keep a previous state's fields, and runtime results that
9
+ * are dropped. Every report names the Ritmo API to use instead.
10
10
  *
11
11
  * Register the plugin in `.oxlintrc.json` with `"jsPlugins":
12
12
  * ["@typeonce/oxlint-plugin-ritmo"]`. Its rules are named `ritmo/<rule>`.
@@ -16,7 +16,8 @@
16
16
  *
17
17
  * - Simulation files: `ritmo/use-clock-for-time`,
18
18
  * `ritmo/use-random-for-randomness`, `ritmo/use-ops-for-math`,
19
- * `ritmo/keep-simulation-headless`, `ritmo/no-infinity-in-simulation-data`.
19
+ * `ritmo/keep-simulation-headless`, `ritmo/no-infinity-in-simulation-data`,
20
+ * `ritmo/no-float-timers`, `ritmo/no-brand-cast`.
20
21
  * - Every file: `ritmo/handle-tick-result`,
21
22
  * `ritmo/prefix-descriptor-and-system-names`, `ritmo/use-cell-value`,
22
23
  * `ritmo/no-state-spread`.
@@ -26,6 +27,8 @@
26
27
  import { definePlugin } from "@oxlint/plugins";
27
28
  import handleTickResult from "./rules/handle-tick-result.js";
28
29
  import keepSimulationHeadless from "./rules/keep-simulation-headless.js";
30
+ import noBrandCast from "./rules/no-brand-cast.js";
31
+ import noFloatTimers from "./rules/no-float-timers.js";
29
32
  import noInfinityInSimulationData from "./rules/no-infinity-in-simulation-data.js";
30
33
  import noStateSpread from "./rules/no-state-spread.js";
31
34
  import prefixDescriptorAndSystemNames from "./rules/prefix-descriptor-and-system-names.js";
@@ -41,6 +44,8 @@ export default definePlugin({
41
44
  "use-ops-for-math": useOpsForMath,
42
45
  "keep-simulation-headless": keepSimulationHeadless,
43
46
  "no-infinity-in-simulation-data": noInfinityInSimulationData,
47
+ "no-float-timers": noFloatTimers,
48
+ "no-brand-cast": noBrandCast,
44
49
  "handle-tick-result": handleTickResult,
45
50
  "prefix-descriptor-and-system-names": prefixDescriptorAndSystemNames,
46
51
  "use-cell-value": useCellValue,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAE9C,OAAO,gBAAgB,MAAM,+BAA+B,CAAA;AAC5D,OAAO,sBAAsB,MAAM,qCAAqC,CAAA;AACxE,OAAO,0BAA0B,MAAM,2CAA2C,CAAA;AAClF,OAAO,aAAa,MAAM,4BAA4B,CAAA;AACtD,OAAO,8BAA8B,MAAM,+CAA+C,CAAA;AAC1F,OAAO,YAAY,MAAM,2BAA2B,CAAA;AACpD,OAAO,eAAe,MAAM,+BAA+B,CAAA;AAC3D,OAAO,aAAa,MAAM,6BAA6B,CAAA;AACvD,OAAO,sBAAsB,MAAM,sCAAsC,CAAA;AAEzE,eAAe,YAAY,CAAC;IAC1B,IAAI,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE;IACvB,KAAK,EAAE;QACL,oBAAoB,EAAE,eAAe;QACrC,2BAA2B,EAAE,sBAAsB;QACnD,kBAAkB,EAAE,aAAa;QACjC,0BAA0B,EAAE,sBAAsB;QAClD,gCAAgC,EAAE,0BAA0B;QAC5D,oBAAoB,EAAE,gBAAgB;QACtC,oCAAoC,EAAE,8BAA8B;QACpE,gBAAgB,EAAE,YAAY;QAC9B,iBAAiB,EAAE,aAAa;KACjC;CACF,CAAC,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAE9C,OAAO,gBAAgB,MAAM,+BAA+B,CAAA;AAC5D,OAAO,sBAAsB,MAAM,qCAAqC,CAAA;AACxE,OAAO,WAAW,MAAM,0BAA0B,CAAA;AAClD,OAAO,aAAa,MAAM,4BAA4B,CAAA;AACtD,OAAO,0BAA0B,MAAM,2CAA2C,CAAA;AAClF,OAAO,aAAa,MAAM,4BAA4B,CAAA;AACtD,OAAO,8BAA8B,MAAM,+CAA+C,CAAA;AAC1F,OAAO,YAAY,MAAM,2BAA2B,CAAA;AACpD,OAAO,eAAe,MAAM,+BAA+B,CAAA;AAC3D,OAAO,aAAa,MAAM,6BAA6B,CAAA;AACvD,OAAO,sBAAsB,MAAM,sCAAsC,CAAA;AAEzE,eAAe,YAAY,CAAC;IAC1B,IAAI,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE;IACvB,KAAK,EAAE;QACL,oBAAoB,EAAE,eAAe;QACrC,2BAA2B,EAAE,sBAAsB;QACnD,kBAAkB,EAAE,aAAa;QACjC,0BAA0B,EAAE,sBAAsB;QAClD,gCAAgC,EAAE,0BAA0B;QAC5D,iBAAiB,EAAE,aAAa;QAChC,eAAe,EAAE,WAAW;QAC5B,oBAAoB,EAAE,gBAAgB;QACtC,oCAAoC,EAAE,8BAA8B;QACpE,gBAAgB,EAAE,YAAY;QAC9B,iBAAiB,EAAE,aAAa;KACjC;CACF,CAAC,CAAA"}
@@ -1,7 +1,7 @@
1
1
  /**
2
- * The result of `runtime.tick(...)`, `tryTick(...)`, and `restore(...)` is read: a
3
- * failed system or an invalid save comes back as data, and dropping it hides
4
- * the failure.
2
+ * The result of `runtime.tick(...)`, `tryTick(...)`, `restore(...)`, and
3
+ * `rewind(...)` is read: a failed system, an invalid save, or a released
4
+ * checkpoint comes back as data, and dropping it hides the failure.
5
5
  */
6
6
  declare const _default: import("@oxlint/plugins").Rule;
7
7
  export default _default;
@@ -1,20 +1,21 @@
1
1
  import { defineRule } from "@oxlint/plugins";
2
2
  import { calledMethod, docsUrl, receiverName } from "../internal/ast.js";
3
3
  /**
4
- * The result of `runtime.tick(...)`, `tryTick(...)`, and `restore(...)` is read: a
5
- * failed system or an invalid save comes back as data, and dropping it hides
6
- * the failure.
4
+ * The result of `runtime.tick(...)`, `tryTick(...)`, `restore(...)`, and
5
+ * `rewind(...)` is read: a failed system, an invalid save, or a released
6
+ * checkpoint comes back as data, and dropping it hides the failure.
7
7
  */
8
8
  export default defineRule({
9
9
  meta: {
10
10
  type: "problem",
11
11
  docs: {
12
- description: "Check the Result of runtime.tick(...), tryTick(...), and restore(...) instead of dropping it.",
12
+ description: "Check the Result of runtime.tick(...), tryTick(...), restore(...), and rewind(...) instead of dropping it.",
13
13
  url: docsUrl("handle-tick-result")
14
14
  },
15
15
  messages: {
16
16
  tick: "The result of `{{call}}(...)` is dropped. A system that fails stops the tick and returns the failure here, so it goes unnoticed and the world is left half-updated. Check it: `const ran = {{call}}(...); if (!ran.ok) ...` (`ran.error` names the system and why). Write `void {{call}}(...)` to ignore it on purpose.",
17
- restore: "The result of `{{call}}(...)` is dropped. A save that fails to load leaves the previous world in place, unnoticed. Check it: `const restored = {{call}}(data); if (!restored.ok) ...` (`restored.error` says what was invalid). Write `void {{call}}(...)` to ignore it on purpose."
17
+ restore: "The result of `{{call}}(...)` is dropped. A save that fails to load leaves the previous world in place, unnoticed. Check it: `const restored = {{call}}(data); if (!restored.ok) ...` (`restored.error` says what was invalid). Write `void {{call}}(...)` to ignore it on purpose.",
18
+ rewind: "The result of `{{call}}(...)` is dropped. A checkpoint the runtime let go of (older than its window, or taken before a rewind to an older one or a restore) changes nothing, so the ticks run next are run on top of the present instead of again, unnoticed. Check it: `const rewound = {{call}}(checkpoint); if (!rewound.ok) ...` (`rewound.error` says why), and resynchronize, for example by loading a peer's save. Write `void {{call}}(...)` to ignore it on purpose."
18
19
  },
19
20
  schema: [
20
21
  {
@@ -38,14 +39,14 @@ export default defineRule({
38
39
  if (call.type !== "CallExpression" || call.callee.type !== "MemberExpression" || call.arguments.length === 0)
39
40
  return;
40
41
  const method = calledMethod(call);
41
- if (method !== "tick" && method !== "tryTick" && method !== "restore")
42
+ if (method !== "tick" && method !== "tryTick" && method !== "restore" && method !== "rewind")
42
43
  return;
43
44
  const receiver = receiverName(call.callee.object);
44
45
  if (receiver === undefined || !runtime.test(receiver))
45
46
  return;
46
47
  context.report({
47
48
  node,
48
- messageId: method === "restore" ? "restore" : "tick",
49
+ messageId: method === "restore" || method === "rewind" ? method : "tick",
49
50
  data: { call: context.sourceCode.getText(call.callee) }
50
51
  });
51
52
  }
@@ -1 +1 @@
1
- {"version":3,"file":"handle-tick-result.js","sourceRoot":"","sources":["../../src/rules/handle-tick-result.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAE5C,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAMxE;;;;GAIG;AACH,eAAe,UAAU,CAAC;IACxB,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,IAAI,EAAE;YACJ,WAAW,EAAE,+FAA+F;YAC5G,GAAG,EAAE,OAAO,CAAC,oBAAoB,CAAC;SACnC;QACD,QAAQ,EAAE;YACR,IAAI,EACF,yTAAyT;YAC3T,OAAO,EACL,qRAAqR;SACxR;QACD,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACV,cAAc,EAAE;wBACd,IAAI,EAAE,QAAQ;wBACd,WAAW,EAAE,kIAAkI;qBAChJ;iBACF;gBACD,oBAAoB,EAAE,KAAK;aAC5B;SACF;KACF;IACD,MAAM,CAAC,OAAO;QACZ,MAAM,OAAO,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE,CAAY,CAAA;QACrD,MAAM,OAAO,GAAG,IAAI,MAAM,CAAC,OAAO,CAAC,cAAc,IAAI,UAAU,EAAE,GAAG,CAAC,CAAA;QACrE,OAAO;YACL,mBAAmB,CAAC,IAAI;gBACtB,MAAM,IAAI,GAAG,IAAI,CAAC,U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,EAAE,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE;iBACxD,CAAC,CAAA;YACJ,CAAC;SACF,CAAA;IACH,CAAC;CACF,CAAC,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"keep-simulation-headless.d.ts","sourceRoot":"","sources":["../../src/rules/keep-simulation-headless.ts"],"names":[],"mappings":"AA6BA;;;;;GAKG"}
1
+ {"version":3,"file":"keep-simulation-headless.d.ts","sourceRoot":"","sources":["../../src/rules/keep-simulation-headless.ts"],"names":[],"mappings":"AAgCA;;;;;GAKG"}
@@ -5,10 +5,12 @@ const page = new Set([
5
5
  "window", "document", "navigator", "screen", "matchMedia", "getComputedStyle", "devicePixelRatio",
6
6
  "innerWidth", "innerHeight", "addEventListener", "removeEventListener", "alert", "confirm", "prompt"
7
7
  ]);
8
- /** Globals that do host I/O: storage, network, navigation. */
8
+ /** Globals that do host I/O: storage, requests, navigation. */
9
9
  const io = new Set([
10
- "localStorage", "sessionStorage", "indexedDB", "caches", "fetch", "XMLHttpRequest", "WebSocket", "EventSource", "location", "history"
10
+ "localStorage", "sessionStorage", "indexedDB", "caches", "fetch", "XMLHttpRequest", "EventSource", "location", "history"
11
11
  ]);
12
+ /** Globals that connect to other peers: what online play goes through a netcode session for. */
13
+ const network = new Set(["WebSocket", "RTCPeerConnection", "RTCDataChannel"]);
12
14
  /** Renderer and UI packages, by exact name. */
13
15
  const renderers = new Set([
14
16
  "@typeonce/ritmo-render", "@typeonce/ritmo-pixi", "pixi.js", "three", "react", "react-dom", "preact",
@@ -32,6 +34,7 @@ export default defineRule({
32
34
  messages: {
33
35
  page: "`{{name}}` is the page, which tests, bots, and replays do not have. Capture input in the host with `Keyboard`, `Pointer`, or `Touch` from `@typeonce/ritmo-browser` and `InputCapture` into a resource, and read that resource in systems. Pass other page state (size, settings) in from host code with `runtime.send(...)` or a resource.",
34
36
  io: "`{{name}}` is host I/O, which tests, bots, and replays do not have and cannot reproduce. Do the I/O in host code and pass the result in with `runtime.send(...)` or a resource; save and load the world in host code with `runtime.snapshot()` and `runtime.restore(...)`.",
37
+ network: "`{{name}}` is a connection to other peers, which tests, bots, and replays do not have. For other players' input, run the simulation under a session of `@typeonce/ritmo-netcode` (`Netcode.rollback` or `Netcode.lockstep`): host code opens the connection and wraps it in a link (`WebSocketNetworkLink`, `WebRtcNetworkLink`), and remote input reaches the simulation through `Netcode.seats`, never `runtime.send(...)`, which a rollback would read on the wrong tick.",
35
38
  renderer: "The simulation imports `{{source}}`, a renderer or UI package, so it no longer runs headless. Draw from a render schedule in render code: mirror entities into nodes with `RenderSync` and a `NodeRegistry` from `@typeonce/ritmo-render`, and declare its services (a node registry) there. Renderer nodes stay in the registry, never in components.",
36
39
  rendererType: "The simulation names a type from `{{source}}`, a renderer or UI package, so it is tied to that renderer and another one cannot replace it. Declare renderer services (a node registry) and their types in render code; services are not registered in the schema. Renderer nodes stay in the registry, never in components."
37
40
  },
@@ -74,7 +77,7 @@ export default defineRule({
74
77
  checkSource(node, stringValue(node.source));
75
78
  },
76
79
  Identifier(node) {
77
- const kind = page.has(node.name) ? "page" : io.has(node.name) ? "io" : undefined;
80
+ const kind = page.has(node.name) ? "page" : io.has(node.name) ? "io" : network.has(node.name) ? "network" : undefined;
78
81
  if (kind === undefined)
79
82
  return;
80
83
  // `typeof window` in a type runs nothing.
@@ -1 +1 @@
1
- {"version":3,"file":"keep-simulation-headless.js","sourceRoot":"","sources":["../../src/rules/keep-simulation-headless.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAG5C,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAE9F,mDAAmD;AACnD,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC;IACnB,QAAQ,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY,EAAE,kBAAkB,EAAE,k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gBAC1C,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,aAAa,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,iBAAiB;oBAAE,OAAM;gBACxF,IAAI,CAAC,iBAAiB,CAAC,OAAO,EAAE,IAAI,CAAC;oBAAE,OAAM;gBAC7C,OAAO,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC,CAAA;YACtE,CAAC;SACF,CAAA;IACH,CAAC;CACF,CAAC,CAAA"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Simulation code never casts a value to a branded type: a brand stands for a
3
+ * check, and the cast claims it without running it.
4
+ */
5
+ declare const _default: import("@oxlint/plugins").Rule;
6
+ export default _default;
7
+ //# sourceMappingURL=no-brand-cast.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-brand-cast.d.ts","sourceRoot":"","sources":["../../src/rules/no-brand-cast.ts"],"names":[],"mappings":"AAmDA;;;GAGG"}