@scientific-method/standard-checker 0.4.0 → 0.4.1

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.
@@ -129,13 +129,20 @@ export function checkExperiment(ctx, id, e, isSup) {
129
129
  const fx = JSON.parse(readFileSync(fixture, "utf8"));
130
130
  if (fx.experiment !== id)
131
131
  problem(fixture, `experiment must be ${id}`);
132
- if (!["new-game", "emulated-call"].includes(meta.starting_state) &&
133
- !(fx.starting_state && fx.starting_state.xxh3))
134
- problem(fixture, "gives the hash of the save its runs started from");
135
- if (typeof meta.starting_state === "string" &&
136
- meta.starting_state.endsWith(".patch.json") &&
137
- !fx.starting_state?.base_xxh3)
132
+ // Only a new game and an emulated call start without a save. starting_state null still has
133
+ // one: a save that cannot be committed, kept with the captures and found by its hash.
134
+ const save = fx.starting_state;
135
+ if (!["new-game", "emulated-call"].includes(meta.starting_state) && !save?.xxh3) {
136
+ const where = "gives the hash of the save its runs started from in starting_state.xxh3";
137
+ problem(fixture, meta.starting_state === null
138
+ ? `${where}; starting_state null names a save kept with the captures, and an experiment that starts without a save has starting_state new-game or emulated-call`
139
+ : where);
140
+ }
141
+ if (typeof meta.starting_state === "string" && meta.starting_state.endsWith(".patch.json") && !save?.base_xxh3)
138
142
  problem(fixture, "a patch fixture gives the base save's hash as well");
143
+ for (const key of ["xxh3", "base_xxh3"])
144
+ if (save?.[key] && !/^[0-9a-f]{32}$/.test(String(save[key])))
145
+ problem(fixture, `starting_state.${key} must be 32 lower-case hex digits`);
139
146
  for (const run of asList(fx.runs)) {
140
147
  for (const ev of asList(run?.events))
141
148
  if (!glossary.has(ev?.event))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scientific-method/standard-checker",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "Checks a restoration's spec/, parity/ and deviations/ against version 1 of the dinorefurb documentation standard.",
5
5
  "type": "module",
6
6
  "license": "MIT",