mons-web 0.1.133 → 0.2.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/README.md CHANGED
@@ -1,46 +1,88 @@
1
- # mons-rust
2
-
3
- `cargo add mons-rust`
4
-
5
- or
6
-
7
- `npm install mons-rust`
8
-
9
- ## Automove
10
-
11
- Docs:
12
-
13
- - runbook: `HOW_TO_ITERATE_ON_AUTOMOVE.md`
14
- - next mechanism: `AUTOMOVE_IDEAS.md`
15
- - durable evidence and lessons: `docs/automove-knowledge.md`
16
-
17
- Shipping surface:
18
-
19
- - Fast and Normal retain shipping search; Pro uses the promoted bounded tactical policy
20
- - complete independently cold selector calls must remain below `700ms`
21
-
22
- Experiments use a small candidate-specific `#[cfg(test)]` harness:
23
-
24
- - `cargo test --release --lib <test_name> -- --ignored --nocapture --test-threads=1`
25
- - `./scripts/check-automove-hygiene.sh`
26
-
27
- ## Rules Tests
28
-
29
- Runner:
30
-
31
- - `./scripts/run-rules-tests.sh`
32
- - `./scripts/run-rules-tests.sh --limit 100`
33
- - `./scripts/run-rules-tests.sh --log /tmp/rules-tests.log`
34
-
35
- The checked-in corpus is `test-data/rules-regressions.jsonl.gz`. Its manifest records
36
- the deterministic 10,000-case selection policy, source archive hashes, coverage, and
37
- artifact hashes. The runner verifies the complete stream even when `--limit` executes
38
- only a prefix.
39
-
40
- ## Publishing
41
-
42
- - Set the release version in `Cargo.toml` and regenerate `Cargo.lock`, then commit the
43
- complete release change set. Publishing requires a clean worktree.
44
- - Run `./publish.sh --check-only` for the complete rules, Rust, release-gate, Wasm,
45
- public-surface, cold-route, and npm-size validation without publishing.
46
- - Run `./publish.sh` only after the check-only path passes and the release commit is clean.
1
+ # Mons TypeScript engine
2
+
3
+ The Mons rules engine is implemented in strict TypeScript and distributed as two
4
+ dependency-free npm packages:
5
+
6
+ - `mons-web` is an ES module for browsers and bundlers.
7
+ - `mons-rust` is the existing CommonJS package for Node.js. Its historical package
8
+ name is unchanged for compatibility.
9
+
10
+ Both packages expose the same 23 named game APIs and the same TypeScript declarations.
11
+
12
+ ```ts
13
+ import { GameVariant, MonsGameModel } from "mons-web";
14
+
15
+ const game = MonsGameModel.new(GameVariant.Classic);
16
+ const output = game.process_input_fen("l10,5;l9,4");
17
+ ```
18
+
19
+ ```js
20
+ const { GameVariant, MonsGameModel } = require("mons-rust");
21
+
22
+ const game = MonsGameModel.new(GameVariant.Classic);
23
+ ```
24
+
25
+ ## Migrating `mons-web` initialization
26
+
27
+ `mons-web` no longer has a default initializer or an `initSync` export. Remove the
28
+ default import and initialization call; named imports are ready to use immediately.
29
+ The generated `InitInput`, `SyncInitInput`, and `InitOutput` TypeScript types are
30
+ removed with those loaders.
31
+
32
+ ```diff
33
+ -import initMonsWeb, { MonsGameModel } from "mons-web";
34
+ -await initMonsWeb();
35
+ +import { MonsGameModel } from "mons-web";
36
+ ```
37
+
38
+ The named API is otherwise preserved, including enum values, FEN formats, model
39
+ classes, event ordering, random automoves, and smart-automove preferences.
40
+
41
+ Incoming strings retain the previous runtime normalization: unpaired UTF-16
42
+ surrogates become U+FFFD before parsing or echoing. One intentional error-policy
43
+ change applies to malformed data: native `RuntimeError("unreachable")` traps from
44
+ invalid UTF-8 slice boundaries or genuine board/location bounds failures are
45
+ deterministic TypeScript `RangeError`s. Wrapped location indices that resolve inside
46
+ the board remain compatible aliases.
47
+
48
+ Published JavaScript targets ES2020. The Node package uses Node's built-in performance
49
+ and cryptographic-random services directly; the browser package uses the corresponding
50
+ `globalThis` APIs. Node.js 22.13 through 22.x, or Node.js 24 or newer, is required
51
+ only for repository development and release tooling.
52
+
53
+ ## Validation
54
+
55
+ Install the workspace with Node.js 22.13 through 22.x, or Node.js 24 or newer, and
56
+ run the standard checks:
57
+
58
+ ```sh
59
+ npm ci --engine-strict
60
+ npm run format:check
61
+ npm run lint
62
+ npm run typecheck
63
+ npm run build
64
+ npm test
65
+ npm run test:automove-parity
66
+ ```
67
+
68
+ Run `./scripts/run-rules-tests.sh` with no options to replay the deterministic
69
+ compressed stream of 699,994 canonical unique rules transitions recovered from
70
+ 699,999 historical raw fixtures. The command validates and streams the corpus without
71
+ unpacking or rewriting it.
72
+
73
+ Run `node ./scripts/check-complete-games.cjs` to validate the immutable public corpus
74
+ of 1,527 complete real-player games. Run `npm run test:complete-games` to replay all
75
+ 25,185 turns and 169,480 inputs through the TypeScript engine across all 12 variants.
76
+
77
+ ## Release
78
+
79
+ Run `./publish.sh --check-only` to execute the complete Node-only validation, build
80
+ both package tarballs, and perform npm dry runs without publishing. Publishing is an
81
+ explicit release operation: run `./publish.sh` from a clean worktree only when both
82
+ packages should be released to the `latest` tag.
83
+
84
+ A real publish acquires the transient `mons-npm-publish-lock` tag on `origin`, or on
85
+ the shared remote named by `MONS_PUBLISH_LOCK_REMOTE`. All publishers must use this
86
+ script and the same remote for the lock to serialize releases across hosts. If a
87
+ process terminates without releasing the tag, the script prints inspection and
88
+ lease-protected stale-lock recovery commands.
package/mons-web.d.ts CHANGED
@@ -10,58 +10,6 @@
10
10
  export function winner(fen_w: string, fen_b: string, flat_moves_string_w: string, flat_moves_string_b: string): string;
11
11
  /**
12
12
  */
13
- export enum Consumable {
14
- Potion = 0,
15
- Bomb = 1,
16
- BombOrPotion = 2,
17
- }
18
- /**
19
- */
20
- export enum ItemModelKind {
21
- Mon = 0,
22
- Mana = 1,
23
- MonWithMana = 2,
24
- MonWithConsumable = 3,
25
- Consumable = 4,
26
- }
27
- /**
28
- */
29
- export enum AvailableMoveKind {
30
- MonMove = 0,
31
- ManaMove = 1,
32
- Action = 2,
33
- Potion = 3,
34
- }
35
- /**
36
- */
37
- export enum MonKind {
38
- Demon = 0,
39
- Drainer = 1,
40
- Angel = 2,
41
- Spirit = 3,
42
- Mystic = 4,
43
- }
44
- /**
45
- */
46
- export enum Color {
47
- White = 0,
48
- Black = 1,
49
- }
50
- /**
51
- */
52
- export enum Modifier {
53
- SelectPotion = 0,
54
- SelectBomb = 1,
55
- Cancel = 2,
56
- }
57
- /**
58
- */
59
- export enum ManaKind {
60
- Regular = 0,
61
- Supermana = 1,
62
- }
63
- /**
64
- */
65
13
  export enum EventModelKind {
66
14
  MonMove = 0,
67
15
  ManaMove = 1,
@@ -86,11 +34,20 @@ export enum EventModelKind {
86
34
  }
87
35
  /**
88
36
  */
89
- export enum OutputModelKind {
90
- InvalidInput = 0,
91
- LocationsToStartFrom = 1,
92
- NextInputOptions = 2,
93
- Events = 3,
37
+ export enum Consumable {
38
+ Potion = 0,
39
+ Bomb = 1,
40
+ BombOrPotion = 2,
41
+ }
42
+ /**
43
+ */
44
+ export enum SquareModelKind {
45
+ Regular = 0,
46
+ ConsumableBase = 1,
47
+ SupermanaBase = 2,
48
+ ManaBase = 3,
49
+ ManaPool = 4,
50
+ MonBase = 5,
94
51
  }
95
52
  /**
96
53
  */
@@ -107,13 +64,34 @@ export enum NextInputKind {
107
64
  }
108
65
  /**
109
66
  */
110
- export enum SquareModelKind {
67
+ export enum OutputModelKind {
68
+ InvalidInput = 0,
69
+ LocationsToStartFrom = 1,
70
+ NextInputOptions = 2,
71
+ Events = 3,
72
+ }
73
+ /**
74
+ */
75
+ export enum ManaKind {
111
76
  Regular = 0,
112
- ConsumableBase = 1,
113
- SupermanaBase = 2,
114
- ManaBase = 3,
115
- ManaPool = 4,
116
- MonBase = 5,
77
+ Supermana = 1,
78
+ }
79
+ /**
80
+ */
81
+ export enum AvailableMoveKind {
82
+ MonMove = 0,
83
+ ManaMove = 1,
84
+ Action = 2,
85
+ Potion = 3,
86
+ }
87
+ /**
88
+ */
89
+ export enum MonKind {
90
+ Demon = 0,
91
+ Drainer = 1,
92
+ Angel = 2,
93
+ Spirit = 3,
94
+ Mystic = 4,
117
95
  }
118
96
  /**
119
97
  */
@@ -133,6 +111,28 @@ export enum GameVariant {
133
111
  }
134
112
  /**
135
113
  */
114
+ export enum ItemModelKind {
115
+ Mon = 0,
116
+ Mana = 1,
117
+ MonWithMana = 2,
118
+ MonWithConsumable = 3,
119
+ Consumable = 4,
120
+ }
121
+ /**
122
+ */
123
+ export enum Modifier {
124
+ SelectPotion = 0,
125
+ SelectBomb = 1,
126
+ Cancel = 2,
127
+ }
128
+ /**
129
+ */
130
+ export enum Color {
131
+ White = 0,
132
+ Black = 1,
133
+ }
134
+ /**
135
+ */
136
136
  export class EventModel {
137
137
  free(): void;
138
138
  /**
@@ -447,141 +447,3 @@ export class VerboseTrackingEntityModel {
447
447
  */
448
448
  events(): (EventModel)[];
449
449
  }
450
-
451
- export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
452
-
453
- export interface InitOutput {
454
- readonly memory: WebAssembly.Memory;
455
- readonly __wbg_eventmodel_free: (a: number) => void;
456
- readonly __wbg_get_eventmodel_color: (a: number) => number;
457
- readonly __wbg_get_eventmodel_item: (a: number) => number;
458
- readonly __wbg_get_eventmodel_kind: (a: number) => number;
459
- readonly __wbg_get_eventmodel_loc1: (a: number) => number;
460
- readonly __wbg_get_eventmodel_loc2: (a: number) => number;
461
- readonly __wbg_get_eventmodel_mana: (a: number) => number;
462
- readonly __wbg_get_eventmodel_mon: (a: number) => number;
463
- readonly __wbg_get_itemmodel_consumable: (a: number) => number;
464
- readonly __wbg_get_itemmodel_kind: (a: number) => number;
465
- readonly __wbg_get_itemmodel_mana: (a: number) => number;
466
- readonly __wbg_get_itemmodel_mon: (a: number) => number;
467
- readonly __wbg_get_location_i: (a: number) => number;
468
- readonly __wbg_get_location_j: (a: number) => number;
469
- readonly __wbg_get_manamodel_color: (a: number) => number;
470
- readonly __wbg_get_manamodel_kind: (a: number) => number;
471
- readonly __wbg_get_mon_color: (a: number) => number;
472
- readonly __wbg_get_mon_kind: (a: number) => number;
473
- readonly __wbg_get_nextinputmodel_actor_mon_item: (a: number) => number;
474
- readonly __wbg_get_nextinputmodel_kind: (a: number) => number;
475
- readonly __wbg_get_nextinputmodel_modifier: (a: number) => number;
476
- readonly __wbg_get_outputmodel_kind: (a: number) => number;
477
- readonly __wbg_get_squaremodel_color: (a: number) => number;
478
- readonly __wbg_get_squaremodel_kind: (a: number) => number;
479
- readonly __wbg_get_squaremodel_mon_kind: (a: number) => number;
480
- readonly __wbg_itemmodel_free: (a: number) => void;
481
- readonly __wbg_location_free: (a: number) => void;
482
- readonly __wbg_manamodel_free: (a: number) => void;
483
- readonly __wbg_mon_free: (a: number) => void;
484
- readonly __wbg_monsgamemodel_free: (a: number) => void;
485
- readonly __wbg_nextinputmodel_free: (a: number) => void;
486
- readonly __wbg_outputmodel_free: (a: number) => void;
487
- readonly __wbg_set_eventmodel_color: (a: number, b: number) => void;
488
- readonly __wbg_set_eventmodel_item: (a: number, b: number) => void;
489
- readonly __wbg_set_eventmodel_kind: (a: number, b: number) => void;
490
- readonly __wbg_set_eventmodel_loc1: (a: number, b: number) => void;
491
- readonly __wbg_set_eventmodel_loc2: (a: number, b: number) => void;
492
- readonly __wbg_set_eventmodel_mana: (a: number, b: number) => void;
493
- readonly __wbg_set_eventmodel_mon: (a: number, b: number) => void;
494
- readonly __wbg_set_itemmodel_consumable: (a: number, b: number) => void;
495
- readonly __wbg_set_itemmodel_kind: (a: number, b: number) => void;
496
- readonly __wbg_set_itemmodel_mana: (a: number, b: number) => void;
497
- readonly __wbg_set_itemmodel_mon: (a: number, b: number) => void;
498
- readonly __wbg_set_location_i: (a: number, b: number) => void;
499
- readonly __wbg_set_location_j: (a: number, b: number) => void;
500
- readonly __wbg_set_manamodel_color: (a: number, b: number) => void;
501
- readonly __wbg_set_manamodel_kind: (a: number, b: number) => void;
502
- readonly __wbg_set_mon_color: (a: number, b: number) => void;
503
- readonly __wbg_set_mon_kind: (a: number, b: number) => void;
504
- readonly __wbg_set_nextinputmodel_actor_mon_item: (a: number, b: number) => void;
505
- readonly __wbg_set_nextinputmodel_kind: (a: number, b: number) => void;
506
- readonly __wbg_set_nextinputmodel_modifier: (a: number, b: number) => void;
507
- readonly __wbg_set_outputmodel_kind: (a: number, b: number) => void;
508
- readonly __wbg_set_squaremodel_color: (a: number, b: number) => void;
509
- readonly __wbg_set_squaremodel_kind: (a: number, b: number) => void;
510
- readonly __wbg_set_squaremodel_mon_kind: (a: number, b: number) => void;
511
- readonly __wbg_squaremodel_free: (a: number) => void;
512
- readonly __wbg_verbosetrackingentitymodel_free: (a: number) => void;
513
- readonly location_new: (a: number, b: number) => number;
514
- readonly mon_decrease_cooldown: (a: number) => void;
515
- readonly mon_faint: (a: number) => void;
516
- readonly mon_is_fainted: (a: number) => number;
517
- readonly mon_new: (a: number, b: number, c: number) => number;
518
- readonly monsgamemodel_active_color: (a: number) => number;
519
- readonly monsgamemodel_automove: (a: number) => number;
520
- readonly monsgamemodel_available_move_kinds: (a: number, b: number) => void;
521
- readonly monsgamemodel_black_score: (a: number) => number;
522
- readonly monsgamemodel_can_takeback: (a: number, b: number) => number;
523
- readonly monsgamemodel_clearTracking: (a: number) => void;
524
- readonly monsgamemodel_fen: (a: number, b: number) => void;
525
- readonly monsgamemodel_fromFenForSimulation: (a: number, b: number) => number;
526
- readonly monsgamemodel_from_fen: (a: number, b: number) => number;
527
- readonly monsgamemodel_inactive_player_items_counters: (a: number, b: number) => void;
528
- readonly monsgamemodel_is_later_than: (a: number, b: number, c: number) => number;
529
- readonly monsgamemodel_is_moves_verified: (a: number) => number;
530
- readonly monsgamemodel_item: (a: number, b: number) => number;
531
- readonly monsgamemodel_locations_with_content: (a: number, b: number) => void;
532
- readonly monsgamemodel_new: (a: number) => number;
533
- readonly monsgamemodel_newForSimulation: (a: number) => number;
534
- readonly monsgamemodel_process_input: (a: number, b: number, c: number, d: number) => number;
535
- readonly monsgamemodel_process_input_fen: (a: number, b: number, c: number) => number;
536
- readonly monsgamemodel_remove_item: (a: number, b: number) => void;
537
- readonly monsgamemodel_setVerboseTracking: (a: number, b: number) => void;
538
- readonly monsgamemodel_smartAutomove: (a: number, b: number, c: number, d: number) => void;
539
- readonly monsgamemodel_square: (a: number, b: number) => number;
540
- readonly monsgamemodel_takeback: (a: number) => number;
541
- readonly monsgamemodel_takeback_fens: (a: number, b: number) => void;
542
- readonly monsgamemodel_turn_number: (a: number) => number;
543
- readonly monsgamemodel_verbose_tracking_entities: (a: number, b: number) => void;
544
- readonly monsgamemodel_verify_moves: (a: number, b: number, c: number, d: number, e: number) => number;
545
- readonly monsgamemodel_white_score: (a: number) => number;
546
- readonly monsgamemodel_winner_color: (a: number) => number;
547
- readonly monsgamemodel_without_last_turn: (a: number, b: number, c: number) => number;
548
- readonly outputmodel_events: (a: number, b: number) => void;
549
- readonly outputmodel_input_fen: (a: number, b: number) => void;
550
- readonly outputmodel_locations: (a: number, b: number) => void;
551
- readonly outputmodel_next_inputs: (a: number, b: number) => void;
552
- readonly verbosetrackingentitymodel_color: (a: number) => number;
553
- readonly verbosetrackingentitymodel_events: (a: number, b: number) => void;
554
- readonly verbosetrackingentitymodel_events_fen: (a: number, b: number) => void;
555
- readonly verbosetrackingentitymodel_fen: (a: number, b: number) => void;
556
- readonly winner: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
557
- readonly __wbg_set_nextinputmodel_location: (a: number, b: number) => void;
558
- readonly __wbg_get_mon_cooldown: (a: number) => number;
559
- readonly __wbg_get_nextinputmodel_location: (a: number) => number;
560
- readonly __wbg_set_mon_cooldown: (a: number, b: number) => void;
561
- readonly __wbindgen_malloc: (a: number, b: number) => number;
562
- readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
563
- readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
564
- readonly __wbindgen_free: (a: number, b: number, c: number) => void;
565
- readonly __wbindgen_exn_store: (a: number) => void;
566
- }
567
-
568
- export type SyncInitInput = BufferSource | WebAssembly.Module;
569
- /**
570
- * Instantiates the given `module`, which can either be bytes or
571
- * a precompiled `WebAssembly.Module`.
572
- *
573
- * @param {SyncInitInput} module
574
- *
575
- * @returns {InitOutput}
576
- */
577
- export function initSync(module: SyncInitInput): InitOutput;
578
-
579
- /**
580
- * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
581
- * for everything else, calls `WebAssembly.instantiate` directly.
582
- *
583
- * @param {InitInput | Promise<InitInput>} module_or_path
584
- *
585
- * @returns {Promise<InitOutput>}
586
- */
587
- export default function __wbg_init (module_or_path?: InitInput | Promise<InitInput>): Promise<InitOutput>;