@typeonce/ritmo-devtools 0.22.0 → 0.24.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.
Files changed (54) hide show
  1. package/CHANGELOG.md +83 -0
  2. package/README.md +61 -10
  3. package/dist/Desync.d.ts +2 -2
  4. package/dist/Desync.d.ts.map +1 -1
  5. package/dist/Desync.js +2 -1
  6. package/dist/Desync.js.map +1 -1
  7. package/dist/Format.d.ts +8 -1
  8. package/dist/Format.d.ts.map +1 -1
  9. package/dist/Format.js +13 -2
  10. package/dist/Format.js.map +1 -1
  11. package/dist/Fuzz.d.ts +12 -5
  12. package/dist/Fuzz.d.ts.map +1 -1
  13. package/dist/Fuzz.js +8 -1
  14. package/dist/Fuzz.js.map +1 -1
  15. package/dist/Replay.d.ts +50 -13
  16. package/dist/Replay.d.ts.map +1 -1
  17. package/dist/Replay.js +59 -8
  18. package/dist/Replay.js.map +1 -1
  19. package/dist/Session.d.ts +7 -15
  20. package/dist/Session.d.ts.map +1 -1
  21. package/dist/Session.js +41 -3
  22. package/dist/Session.js.map +1 -1
  23. package/dist/Verify.d.ts +11 -2
  24. package/dist/Verify.d.ts.map +1 -1
  25. package/dist/Verify.js +12 -7
  26. package/dist/Verify.js.map +1 -1
  27. package/dist/cli.js +19 -6
  28. package/dist/cli.js.map +1 -1
  29. package/dist/internal/packageVersions.d.ts +28 -0
  30. package/dist/internal/packageVersions.d.ts.map +1 -0
  31. package/dist/internal/packageVersions.js +144 -0
  32. package/dist/internal/packageVersions.js.map +1 -0
  33. package/dist/internal/replayStart.d.ts +18 -0
  34. package/dist/internal/replayStart.d.ts.map +1 -0
  35. package/dist/internal/replayStart.js +16 -0
  36. package/dist/internal/replayStart.js.map +1 -0
  37. package/dist/internal/skillLink.d.ts +1 -9
  38. package/dist/internal/skillLink.d.ts.map +1 -1
  39. package/dist/internal/skillLink.js +29 -6
  40. package/dist/internal/skillLink.js.map +1 -1
  41. package/dist/internal/version.d.ts +1 -1
  42. package/dist/internal/version.js +1 -1
  43. package/package.json +3 -3
  44. package/src/Desync.ts +3 -2
  45. package/src/Format.ts +15 -2
  46. package/src/Fuzz.ts +17 -5
  47. package/src/Replay.ts +104 -17
  48. package/src/Session.ts +41 -34
  49. package/src/Verify.ts +21 -9
  50. package/src/cli.ts +18 -6
  51. package/src/internal/packageVersions.ts +150 -0
  52. package/src/internal/replayStart.ts +16 -0
  53. package/src/internal/skillLink.ts +31 -8
  54. package/src/internal/version.ts +1 -1
@@ -0,0 +1,144 @@
1
+ /**
2
+ * The version check for the `ritmo-devtools lint` CLI (Node only): whether
3
+ * every Ritmo package the game installs is the same version. Each package
4
+ * depends on `@typeonce/ritmo` at its own minor, so `@typeonce/ritmo-browser`
5
+ * 0.22 beside `@typeonce/ritmo` 0.23 installs a second, hidden copy of core
6
+ * 0.22 under browser, and the game then gets type errors between the two
7
+ * copies that name neither.
8
+ *
9
+ * It resolves packages as Node does, by walking up from a folder through
10
+ * each `node_modules`, so it reads npm and yarn trees (hoisted or nested,
11
+ * workspaces included) and pnpm's (symlinks into `node_modules/.pnpm`) the
12
+ * same way. Yarn Plug'n'Play installs no `node_modules`: nothing is found
13
+ * and nothing is said.
14
+ */
15
+ import { readdirSync, readFileSync, realpathSync } from "node:fs";
16
+ import { basename, dirname, join, relative, sep } from "node:path";
17
+ const scope = "@typeonce";
18
+ /** The Ritmo packages, all released at one version: `@typeonce/ritmo*` and `@typeonce/oxlint-plugin-ritmo`. */
19
+ const isRitmo = (name) => name.startsWith(`${scope}/`) && name.includes("ritmo");
20
+ const isRecord = (value) => typeof value === "object" && value !== null;
21
+ const readManifest = (folder) => {
22
+ let manifest;
23
+ try {
24
+ manifest = JSON.parse(readFileSync(join(folder, "package.json"), "utf8"));
25
+ }
26
+ catch {
27
+ return undefined;
28
+ }
29
+ if (!isRecord(manifest) || typeof manifest["name"] !== "string" || typeof manifest["version"] !== "string")
30
+ return undefined;
31
+ const needs = new Set();
32
+ for (const field of ["dependencies", "peerDependencies", "optionalDependencies"]) {
33
+ const entries = manifest[field];
34
+ if (isRecord(entries))
35
+ for (const name of Object.keys(entries))
36
+ if (isRitmo(name))
37
+ needs.add(name);
38
+ }
39
+ return { name: manifest["name"], version: manifest["version"], needs: [...needs] };
40
+ };
41
+ /** The `node_modules` folders Node looks in from `folder`, nearest first. */
42
+ const lookups = (folder) => {
43
+ const found = [];
44
+ for (let at = folder;; at = dirname(at)) {
45
+ if (basename(at) !== "node_modules")
46
+ found.push(join(at, "node_modules"));
47
+ if (dirname(at) === at)
48
+ return found;
49
+ }
50
+ };
51
+ const realpath = (path) => {
52
+ try {
53
+ return realpathSync(path);
54
+ }
55
+ catch {
56
+ return undefined;
57
+ }
58
+ };
59
+ /** Where `name` resolves from `folder`, as Node finds it: the entry it resolves through, and its real path. */
60
+ const resolveFrom = (folder, name) => {
61
+ for (const modules of lookups(folder)) {
62
+ const entry = join(modules, ...name.split("/"));
63
+ const real = realpath(entry);
64
+ if (real !== undefined && readManifest(real) !== undefined)
65
+ return { entry, real };
66
+ }
67
+ return undefined;
68
+ };
69
+ /** Every Ritmo package name in a `node_modules/@typeonce` the game's folder can see. */
70
+ const visibleNames = (cwd) => {
71
+ const names = new Set();
72
+ for (const modules of lookups(cwd)) {
73
+ let entries;
74
+ try {
75
+ entries = readdirSync(join(modules, scope));
76
+ }
77
+ catch {
78
+ continue;
79
+ }
80
+ for (const entry of entries)
81
+ if (isRitmo(`${scope}/${entry}`))
82
+ names.add(`${scope}/${entry}`);
83
+ }
84
+ return [...names].sort();
85
+ };
86
+ /**
87
+ * Every copy of a Ritmo package installed for the game in `cwd`: the ones the
88
+ * game resolves, then, through each one's dependencies, every other copy one
89
+ * of them resolves (an npm copy nested under it, or pnpm's store folder).
90
+ */
91
+ export const check = (cwd) => {
92
+ const root = realpath(cwd) ?? cwd;
93
+ const installed = [];
94
+ const seen = new Set();
95
+ const queue = [];
96
+ const add = (found, under) => {
97
+ if (found === undefined || seen.has(found.real))
98
+ return;
99
+ const manifest = readManifest(found.real);
100
+ if (manifest === undefined)
101
+ return;
102
+ seen.add(found.real);
103
+ installed.push({ name: manifest.name, version: manifest.version, path: relative(root, found.entry).split(sep).join("/"), under });
104
+ queue.push({ folder: found.real, under: manifest.name });
105
+ };
106
+ for (const name of visibleNames(root))
107
+ add(resolveFrom(root, name), undefined);
108
+ // Each package resolves its own dependencies from where it really is (pnpm: its store folder).
109
+ for (let next = queue.shift(); next !== undefined; next = queue.shift()) {
110
+ for (const name of readManifest(next.folder)?.needs ?? [])
111
+ add(resolveFrom(next.folder, name), next.under);
112
+ }
113
+ const versions = new Set(installed.map(({ version }) => version));
114
+ return { _tag: versions.size > 1 ? "Mismatched" : "Same", installed };
115
+ };
116
+ const named = ({ name, version }) => `${name} ${version}`;
117
+ /**
118
+ * The CLI text for the version check: nothing when every copy is one
119
+ * version, one warning otherwise, naming each package and version and the fix.
120
+ */
121
+ export const format = (versions) => {
122
+ if (versions._tag === "Same")
123
+ return "";
124
+ const top = versions.installed.filter(({ under }) => under === undefined);
125
+ const nested = versions.installed.filter(({ under }) => under !== undefined);
126
+ // The version the others are measured against: core's, or the most common one.
127
+ const core = top.find(({ name }) => name === `${scope}/ritmo`);
128
+ const counts = new Map();
129
+ for (const { version } of top)
130
+ counts.set(version, (counts.get(version) ?? 0) + 1);
131
+ const reference = core?.version ?? [...counts].sort(([, left], [, right]) => right - left)[0]?.[0] ?? versions.installed[0].version;
132
+ const off = top.filter(({ version }) => version !== reference);
133
+ const beside = core !== undefined ? named(core) : `the other ${scope} packages at ${reference}`;
134
+ const seconds = nested.map((copy) => `a second ${named(copy)} under ${copy.under}`);
135
+ const head = off.length > 0
136
+ ? `${off.map(named).join(", ")} ${off.length === 1 ? "is" : "are"} installed with ${beside}${seconds.length > 0 ? ` (and ${seconds.join(", ")})` : ""}`
137
+ : `${seconds.join(", ")} ${seconds.length === 1 ? "is" : "are"} installed beside ${beside}`;
138
+ return [
139
+ `warning mismatched-versions ${scope} packages: ${head}: each copy has its own types, so values from one do not type-check against the other`,
140
+ ` fix: install the same version of every ${scope} package`,
141
+ ...versions.installed.map((copy) => ` ${copy.path} ${named(copy)}`)
142
+ ].join("\n");
143
+ };
144
+ //# sourceMappingURL=packageVersions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"packageVersions.js","sourceRoot":"","sources":["../../src/internal/packageVersions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACjE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,WAAW,CAAA;AAElE,MAAM,KAAK,GAAG,WAAW,CAAA;AAEzB,+GAA+G;AAC/G,MAAM,OAAO,GAAG,CAAC,IAAY,EAAW,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,KAAK,GAAG,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAA;AAgBjG,MAAM,QAAQ,GAAG,CAAC,KAAc,EAA8C,EAAE,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAA;AAE5H,MAAM,YAAY,GAAG,CAAC,MAAc,EAA0G,EAAE;IAC9I,IAAI,QAAiB,CAAA;IACrB,IAAI,CAAC;QACH,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM,CAAC,CAAC,CAAA;IAC3E,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAA;IAClB,CAAC;IACD,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,OAAO,QAAQ,CAAC,MAAM,CAAC,KAAK,QAAQ,IAAI,OAAO,QAAQ,CAAC,SAAS,CAAC,KAAK,QAAQ;QAAE,OAAO,SAAS,CAAA;IAC5H,MAAM,KAAK,GA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,EAAE,CAAA;IAC7F,OAAO;QACL,+BAA+B,KAAK,cAAc,IAAI,uFAAuF;QAC7I,4CAA4C,KAAK,UAAU;QAC3D,GAAG,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,IAAI,CAAC,IAAI,KAAK,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;KACtE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACd,CAAC,CAAA"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Why a replay's checksums cannot be compared with its recording's, or
3
+ * `undefined` when they can.
4
+ *
5
+ * Tick 0 is the world when the recorder started: the replay starts where the
6
+ * recorded run did. A later start is a save the rolling window moved to, and
7
+ * a save does not hold what the live game still had in flight there (events
8
+ * published and not yet read, each reader's position in `added()`,
9
+ * `changed()`, and the other streams, transient values), so an ordinary game
10
+ * replays to a different checksum from it. Comparing would report a
11
+ * nondeterminism that is not there.
12
+ */
13
+ export declare const savedStart: (file: {
14
+ readonly start: {
15
+ readonly tick: number;
16
+ };
17
+ }) => string | undefined;
18
+ //# sourceMappingURL=replayStart.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"replayStart.d.ts","sourceRoot":"","sources":["../../src/internal/replayStart.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,UAAU,SAAU;IAAE,QAAQ,CAAC,KAAK,EAAE;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,KAAG,MAAM,GAAG,SAGwK,CAAA"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Why a replay's checksums cannot be compared with its recording's, or
3
+ * `undefined` when they can.
4
+ *
5
+ * Tick 0 is the world when the recorder started: the replay starts where the
6
+ * recorded run did. A later start is a save the rolling window moved to, and
7
+ * a save does not hold what the live game still had in flight there (events
8
+ * published and not yet read, each reader's position in `added()`,
9
+ * `changed()`, and the other streams, transient values), so an ordinary game
10
+ * replays to a different checksum from it. Comparing would report a
11
+ * nondeterminism that is not there.
12
+ */
13
+ export const savedStart = (file) => file.start.tick === 0
14
+ ? undefined
15
+ : `starts from a save at tick ${file.start.tick}: checksums are not compared (a save does not hold events in flight or what each reader had already seen); check determinism with Determinism.check, or with a replay recorded from the recorder's first tick`;
16
+ //# sourceMappingURL=replayStart.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"replayStart.js","sourceRoot":"","sources":["../../src/internal/replayStart.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,IAAmD,EAAsB,EAAE,CACpG,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC;IACnB,CAAC,CAAC,SAAS;IACX,CAAC,CAAC,8BAA8B,IAAI,CAAC,KAAK,CAAC,IAAI,+MAA+M,CAAA"}
@@ -1,11 +1,4 @@
1
- /** The skills `@typeonce/ritmo` ships, with what an agent misses without each. */
2
- declare const skills: {
3
- readonly ritmo: "reads the playbooks for this Ritmo version";
4
- readonly "ritmo-prototype": "can prototype a mechanic with this Ritmo version";
5
- readonly "ritmo-onboarding": "can teach the game to strangers with this Ritmo version";
6
- readonly "ritmo-polish": "can polish the game's feel, feedback, and UI with this Ritmo version";
7
- };
8
- export type Skill = keyof typeof skills;
1
+ export type Skill = string;
9
2
  export type SkillLink = {
10
3
  readonly _tag: "Linked";
11
4
  readonly skill: Skill;
@@ -22,5 +15,4 @@ export type SkillLink = {
22
15
  export declare const check: (cwd: string) => ReadonlyArray<SkillLink>;
23
16
  /** The CLI text for the skill checks: nothing when every skill is linked, a note per skill otherwise. */
24
17
  export declare const format: (links: ReadonlyArray<SkillLink>) => string;
25
- export {};
26
18
  //# sourceMappingURL=skillLink.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"skillLink.d.ts","sourceRoot":"","sources":["../../src/internal/skillLink.ts"],"names":[],"mappings":"AAUA,kFAAkF;AAClF,QAAA,MAAM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Q,CAAC,IAAI,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAA;CAAE,CAAA;AA4BvD,8FAA8F;AAC9F,eAAO,MAAM,KAAK,QAAS,MAAM,KAAG,aAAa,CAAC,SAAS,CACL,CAAA;AAkBtD,yGAAyG;AACzG,eAAO,MAAM,MAAM,UAAW,aAAa,CAAC,SAAS,CAAC,KAAG,MACM,CAAA"}
@@ -5,14 +5,37 @@
5
5
  * version. It is a note: it never fails the lint, since where an agent reads
6
6
  * skills from is the project's choice.
7
7
  */
8
- import { lstatSync, realpathSync } from "node:fs";
8
+ import { existsSync, lstatSync, readdirSync, realpathSync } from "node:fs";
9
9
  import { join, sep } from "node:path";
10
- /** The skills `@typeonce/ritmo` ships, with what an agent misses without each. */
11
- const skills = {
10
+ /** What an agent misses without each skill `@typeonce/ritmo` ships. A skill not listed here gets {@link missing}. */
11
+ const misses = {
12
12
  ritmo: "reads the playbooks for this Ritmo version",
13
13
  "ritmo-prototype": "can prototype a mechanic with this Ritmo version",
14
14
  "ritmo-onboarding": "can teach the game to strangers with this Ritmo version",
15
- "ritmo-polish": "can polish the game's feel, feedback, and UI with this Ritmo version"
15
+ "ritmo-polish": "can polish the game's feel, feedback, and UI with this Ritmo version",
16
+ "ritmo-pixel-art": "makes and checks the game's pixel art with `ritmo-tools pixel` and this Ritmo version's principles",
17
+ "ritmo-fx": "makes and reviews the game's pixel art effects with `ritmo-tools fx` for this Ritmo version",
18
+ "ritmo-sounds": "makes and reviews the game's sound effects with `ritmo-tools sound` for this Ritmo version",
19
+ "ritmo-music": "makes and reviews the game's music with `ritmo-tools music` for this Ritmo version"
20
+ };
21
+ const missing = (skill) => misses[skill] ?? `reads the ${skill} skill of this Ritmo version`;
22
+ /**
23
+ * The skills to check: every folder with a `SKILL.md` in the installed
24
+ * `@typeonce/ritmo/skills`, so a skill a later version ships is checked
25
+ * with no change here. Without an installed package to read, the skills
26
+ * listed in {@link misses}.
27
+ */
28
+ const skillsIn = (cwd) => {
29
+ const installed = join(cwd, "node_modules", "@typeonce", "ritmo", "skills");
30
+ try {
31
+ const found = readdirSync(installed).filter((name) => existsSync(join(installed, name, "SKILL.md"))).sort();
32
+ if (found.length > 0)
33
+ return found;
34
+ }
35
+ catch {
36
+ // Not installed here: check the skills this version knows.
37
+ }
38
+ return Object.keys(misses).sort();
16
39
  };
17
40
  /** The folders agents read skills from, relative to the working directory. */
18
41
  const folders = (skill) => [`.agents/skills/${skill}`, `.claude/skills/${skill}`];
@@ -45,7 +68,7 @@ const checkSkill = (cwd, skill) => {
45
68
  return copied === undefined ? { _tag: "Missing", skill } : { _tag: "Copied", skill, path: copied };
46
69
  };
47
70
  /** Where each skill is in `cwd`: linked from the installed package, copied in, or missing. */
48
- export const check = (cwd) => Object.keys(skills).map((skill) => checkSkill(cwd, skill));
71
+ export const check = (cwd) => skillsIn(cwd).map((skill) => checkSkill(cwd, skill));
49
72
  const formatOne = (link) => {
50
73
  const installed = `node_modules/@typeonce/ritmo/skills/${link.skill}`;
51
74
  switch (link._tag) {
@@ -54,7 +77,7 @@ const formatOne = (link) => {
54
77
  case "Missing":
55
78
  return `note skill-not-linked ${link.skill}\n`
56
79
  + ` No ${folders(link.skill).join(" or ")} links to ${installed}.\n`
57
- + ` Link it (SETUP.md step 2) so your agent ${skills[link.skill]}.`;
80
+ + ` Link it (SETUP.md step 2) so your agent ${missing(link.skill)}.`;
58
81
  case "Copied":
59
82
  return `note skill-copied ${link.path}\n`
60
83
  + ` This is a copy of the ${link.skill} skill, or a link to somewhere else: it goes stale on the next upgrade.\n`
@@ -1 +1 @@
1
- {"version":3,"file":"skillLink.js","sourceRoot":"","sources":["../../src/internal/skillLink.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACjD,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,WAAW,CAAA;AAErC,kFAAkF;AAClF,MAA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EAAU,EAAE,CAChE,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA"}
@@ -3,5 +3,5 @@
3
3
  * `package.json` by `scripts/sync-version.ts` (run by \`pnpm version-packages\`)
4
4
  * and checked by a test.
5
5
  */
6
- export declare const libraryVersion = "0.22.0";
6
+ export declare const libraryVersion = "0.24.0";
7
7
  //# sourceMappingURL=version.d.ts.map
@@ -3,5 +3,5 @@
3
3
  * `package.json` by `scripts/sync-version.ts` (run by \`pnpm version-packages\`)
4
4
  * and checked by a test.
5
5
  */
6
- export const libraryVersion = "0.22.0";
6
+ export const libraryVersion = "0.24.0";
7
7
  //# sourceMappingURL=version.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typeonce/ritmo-devtools",
3
- "version": "0.22.0",
3
+ "version": "0.24.0",
4
4
  "description": "Headless debug sessions, trace history, text reports, replays, and fuzzing for Ritmo runtimes",
5
5
  "author": "Sandro Maglione",
6
6
  "license": "MIT",
@@ -51,8 +51,8 @@
51
51
  "provenance": true
52
52
  },
53
53
  "dependencies": {
54
- "@typeonce/ritmo": "^0.22.0",
55
- "@typeonce/ritmo-netcode": "^0.22.0"
54
+ "@typeonce/ritmo": "^0.24.0",
55
+ "@typeonce/ritmo-netcode": "^0.24.0"
56
56
  },
57
57
  "peerDependencies": {
58
58
  "oxlint": ">=1.86.0",
package/src/Desync.ts CHANGED
@@ -36,7 +36,7 @@ import * as Rendered from "./Rendered.ts"
36
36
 
37
37
  /** One value that differs: where, and each side's (`undefined`: absent on that side). */
38
38
  export interface Difference {
39
- /** `nextEntity`, `entity 12`, `entity 12 Game/Position.x`, `resource Game/Score`, `machine Game/Round`, `relation Game/ChildOf`, or `scope Game/Wave`. */
39
+ /** `nextEntity`, `entity 12`, `entity 12 Game/Position.x`, `resource Game/Score`, `machine Game/Round`, `next state Game/Round`, `relation Game/ChildOf`, or `scope Game/Wave`. */
40
40
  readonly path: string
41
41
  /** The entity the difference is in, when it is in one. */
42
42
  readonly entity: number | undefined
@@ -80,7 +80,7 @@ export interface CompareOptions {
80
80
  readonly labels?: Format.Labels
81
81
  }
82
82
 
83
- /** Every difference between two saves, in a stable order: the next id, entities by id, then resources, machines, relations, and scopes by name. */
83
+ /** Every difference between two saves, in a stable order: the next id, entities by id, then resources, machines, queued next states, relations, and scopes by name. */
84
84
  export const compare = (mine: Snapshot.WorldSnapshot, theirs: Snapshot.WorldSnapshot, options: CompareOptions = {}): Rendered.Rendered<ReadonlyArray<Difference>> => {
85
85
  const found: Array<Difference> = []
86
86
  differences("nextEntity", undefined, mine.nextEntity, theirs.nextEntity, found)
@@ -94,6 +94,7 @@ export const compare = (mine: Snapshot.WorldSnapshot, theirs: Snapshot.WorldSnap
94
94
  }
95
95
  byName("resource", undefined, mine.resources, theirs.resources, found)
96
96
  byName("machine", undefined, mine.machines, theirs.machines, found)
97
+ byName("next state", undefined, mine.nextStates, theirs.nextStates, found)
97
98
  byName("relation", undefined, mine.relations, theirs.relations, found)
98
99
  byName("scope", undefined, mine.scopes, theirs.scopes, found)
99
100
  // `entity 12 ...` prints as `player e12 ...`, like every entity in devtools text.
package/src/Format.ts CHANGED
@@ -177,7 +177,7 @@ export const system = (input: Debug.SystemDescription): string => {
177
177
  add("may relate", input.commands.relates)
178
178
  if (input.thisTick.length > 0) add("needs this tick", input.thisTick)
179
179
  add("when", input.when)
180
- add("pauses when", input.pauseWhen)
180
+ add("pauses while", input.pauseWhile)
181
181
  if (input.local) lines.push(" local state")
182
182
  return lines.join("\n")
183
183
  }
@@ -365,6 +365,8 @@ export type LineKind =
365
365
  | "skip"
366
366
  | "transition"
367
367
  | "restore"
368
+ /** A `rewind` to a checkpoint: what the frames it undid changed is gone. Shown under every filter, between the lines it separates. */
369
+ | "rewind"
368
370
  | "ignored"
369
371
  /** A read the writing system declared, under a `why` line; only `why` and `whyResource` with `depth` above 1 print them. */
370
372
  | "read"
@@ -384,6 +386,15 @@ export const ignoredFailure = (event: Debug.FailureIgnoredEvent, options: ValueO
384
386
  return `tick failure ignored: ${who} with ${value(error, options)}; ${later} (${found})`
385
387
  }
386
388
 
389
+ /**
390
+ * The text for a rewind: the checkpoint's tick and, when known, the frames
391
+ * it undid (those that started at or after that tick).
392
+ */
393
+ export const rewind = (event: Debug.RewindEvent, undid?: readonly [from: number, to: number]): string => {
394
+ if (!event.ok) return `rewind to tick ${event.toTick} rejected`
395
+ return undid === undefined ? `rewind to tick ${event.toTick}` : `rewind to tick ${event.toTick}, undoing f${undid[0]}-f${undid[1]}`
396
+ }
397
+
387
398
  /**
388
399
  * Structural equality for plain data: primitives by `Object.is`, arrays and
389
400
  * plain objects by their entries. Other objects compare by reference.
@@ -484,6 +495,8 @@ const rawLines = (event: Debug.TraceEvent, options: ValueOptions, labels: Labels
484
495
  return []
485
496
  case "restore":
486
497
  return [{ kind: "restore", frame: event.frame, schedule: "", system: undefined, entity: undefined, subject: undefined, noop: false, text: `restore ${event.ok ? "applied" : "rejected"}` }]
498
+ case "rewind":
499
+ return [{ kind: "rewind", frame: event.frame, schedule: "", system: undefined, entity: undefined, subject: undefined, noop: !event.ok, text: rewind(event) }]
487
500
  case "failure.ignored":
488
501
  return [{ kind: "ignored", frame: event.frame, schedule: event.schedule, system: event.system, entity: undefined, subject: undefined, noop: false, text: ignoredFailure(event, options) }]
489
502
  case "transition":
@@ -508,7 +521,7 @@ const rawLines = (event: Debug.TraceEvent, options: ValueOptions, labels: Labels
508
521
  subject: undefined,
509
522
  noop: discarded.length === 0,
510
523
  text: event.held
511
- ? `paused: ${event.condition} is false (holding its stream entries)`
524
+ ? `paused: ${event.condition} is true (holding its stream entries)`
512
525
  : `skipped: ${event.condition} is false${discarded.length > 0 ? `; discarded ${discarded.join(", ")}` : ""}`
513
526
  }]
514
527
  }
package/src/Fuzz.ts CHANGED
@@ -170,7 +170,11 @@ export interface Options<
170
170
  > {
171
171
  /** The schedule to fuzz: the one ticked once per simulation step. Its name in the replay. */
172
172
  readonly schedule: Name
173
- /** Ticked once before the fuzzed frames, with every input neutral: the replay starts after it. */
173
+ /**
174
+ * Ticked once before the fuzzed frames, with every input neutral. Each run
175
+ * then loads its own save of that world, as its replay does, so what setup
176
+ * left in flight (an event no system read yet) is not there in either.
177
+ */
174
178
  readonly setup?: Names
175
179
  /** The fuzzed sources, each from `input`. */
176
180
  readonly inputs: readonly [Input, ...Array<Input>]
@@ -216,8 +220,10 @@ export interface Found {
216
220
  readonly replay: Replay.ReplayFile
217
221
  /**
218
222
  * Whether the replay, opened with `Replay.session`, hits the violation
219
- * again. `false` means restoring the start lost state the bug needs
220
- * (transient components): reproduce it with `seed` instead.
223
+ * again. The run started from the replay's start, so `false` means the
224
+ * simulation read something besides its input and the world (run
225
+ * `Determinism.check`), or over a `network`, a failure that needs two
226
+ * peers: reproduce it with `seed` instead.
221
227
  */
222
228
  readonly reproduces: boolean
223
229
  /**
@@ -241,7 +247,7 @@ export interface InvalidOptions {
241
247
  readonly message: string
242
248
  }
243
249
 
244
- /** The world after setup cannot be saved (a `"~encode"` rejected it), so no replay could start there. */
250
+ /** The world after setup cannot be saved (a `"~encode"` rejected it, or setup left commands queued: end it with `applyDeferred()`), so no replay could start there. */
245
251
  export interface Unreplayable {
246
252
  readonly _tag: "Unreplayable"
247
253
  readonly error: Snapshot.SnapshotError
@@ -341,7 +347,8 @@ type NetworkChecks<Net, S extends Schema.Any, Fuzzed> =
341
347
  /**
342
348
  * Fuzzes `options.schedule` of the simulation `make` builds. Each run makes
343
349
  * a fresh runtime with `make(playback)` (the `Replay.session` factory),
344
- * ticks `setup` once, then ticks the schedule up to `frames` times with
350
+ * ticks `setup` once and loads its save of the world (where the replay
351
+ * starts), then ticks the schedule up to `frames` times with
345
352
  * every input's `generate`d value, checking `invariants` after each frame.
346
353
  * The first run that fails is shrunk and returned as a `Found` with a
347
354
  * replay; a schedule name that `make` does not return, an invariant that
@@ -439,6 +446,11 @@ export const run = <
439
446
  }
440
447
  const start = runtime.snapshot()
441
448
  if (!start.ok) return { kind: "invalid", error: { _tag: "Unreplayable", error: start.error } }
449
+ // The run starts from what its replay starts from: the save, loaded. What
450
+ // setup left in flight (an event no system read yet) is in neither, so a
451
+ // bug the run finds is a bug the replay plays to.
452
+ const restored = target.runtime.restore(start.value)
453
+ if (!restored.ok) return { kind: "invalid", error: { _tag: "InvalidOptions", message: `the world after setup does not load again: ${JSON.stringify(restored.error)}` } }
442
454
 
443
455
  const sink = Replay.memorySink()
444
456
  // One window over the whole timeline, with its only snapshot at the start.