managym 0.2.2__tar.gz
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.
- managym-0.2.2/PKG-INFO +375 -0
- managym-0.2.2/README.md +363 -0
- managym-0.2.2/content/semantic/current/learning_schema.json +41 -0
- managym-0.2.2/content/semantic/current/setups.json +3145 -0
- managym-0.2.2/managym/Cargo.lock +578 -0
- managym-0.2.2/managym/Cargo.toml +47 -0
- managym-0.2.2/managym/PRINCIPLES.md +139 -0
- managym-0.2.2/managym/README.md +363 -0
- managym-0.2.2/managym/__init__.py +7 -0
- managym-0.2.2/managym/__init__.pyi +909 -0
- managym-0.2.2/managym/cards/Cargo.toml +13 -0
- managym-0.2.2/managym/cards/src/afr.rs +67 -0
- managym-0.2.2/managym/cards/src/blb.rs +32 -0
- managym-0.2.2/managym/cards/src/bro.rs +28 -0
- managym-0.2.2/managym/cards/src/dft.rs +65 -0
- managym-0.2.2/managym/cards/src/eld.rs +77 -0
- managym-0.2.2/managym/cards/src/fdn.rs +90 -0
- managym-0.2.2/managym/cards/src/fin.rs +44 -0
- managym-0.2.2/managym/cards/src/grn.rs +28 -0
- managym-0.2.2/managym/cards/src/hob.rs +74 -0
- managym-0.2.2/managym/cards/src/ice.rs +29 -0
- managym-0.2.2/managym/cards/src/iko.rs +78 -0
- managym-0.2.2/managym/cards/src/isd.rs +28 -0
- managym-0.2.2/managym/cards/src/ktk.rs +43 -0
- managym-0.2.2/managym/cards/src/lea.rs +362 -0
- managym-0.2.2/managym/cards/src/lib.rs +100 -0
- managym-0.2.2/managym/cards/src/m20.rs +35 -0
- managym-0.2.2/managym/cards/src/mh1.rs +69 -0
- managym-0.2.2/managym/cards/src/mh2.rs +42 -0
- managym-0.2.2/managym/cards/src/mkm.rs +50 -0
- managym-0.2.2/managym/cards/src/ons.rs +26 -0
- managym-0.2.2/managym/cards/src/ori.rs +27 -0
- managym-0.2.2/managym/cards/src/por.rs +46 -0
- managym-0.2.2/managym/cards/src/ptk.rs +36 -0
- managym-0.2.2/managym/cards/src/rav.rs +33 -0
- managym-0.2.2/managym/cards/src/roe.rs +40 -0
- managym-0.2.2/managym/cards/src/rtr.rs +28 -0
- managym-0.2.2/managym/cards/src/soi.rs +57 -0
- managym-0.2.2/managym/cards/src/sth.rs +27 -0
- managym-0.2.2/managym/cards/src/stx.rs +235 -0
- managym-0.2.2/managym/cards/src/ths.rs +27 -0
- managym-0.2.2/managym/cards/src/tla.rs +10937 -0
- managym-0.2.2/managym/cards/src/tokens.rs +282 -0
- managym-0.2.2/managym/cards/src/vis.rs +36 -0
- managym-0.2.2/managym/cards/src/war.rs +41 -0
- managym-0.2.2/managym/cards/src/zen.rs +40 -0
- managym-0.2.2/managym/cards/tests/cards/README.md +35 -0
- managym-0.2.2/managym/cards/tests/cards/afr.rs +166 -0
- managym-0.2.2/managym/cards/tests/cards/blb.rs +44 -0
- managym-0.2.2/managym/cards/tests/cards/check_scryfall.py +64 -0
- managym-0.2.2/managym/cards/tests/cards/coverage.py +101 -0
- managym-0.2.2/managym/cards/tests/cards/definitions.rs +307 -0
- managym-0.2.2/managym/cards/tests/cards/dft.rs +61 -0
- managym-0.2.2/managym/cards/tests/cards/eld.rs +29 -0
- managym-0.2.2/managym/cards/tests/cards/fdn.rs +51 -0
- managym-0.2.2/managym/cards/tests/cards/hob.rs +116 -0
- managym-0.2.2/managym/cards/tests/cards/ice.rs +45 -0
- managym-0.2.2/managym/cards/tests/cards/iko.rs +90 -0
- managym-0.2.2/managym/cards/tests/cards/ktk.rs +20 -0
- managym-0.2.2/managym/cards/tests/cards/lea.rs +175 -0
- managym-0.2.2/managym/cards/tests/cards/m20.rs +29 -0
- managym-0.2.2/managym/cards/tests/cards/mkm.rs +128 -0
- managym-0.2.2/managym/cards/tests/cards/observability.rs +4345 -0
- managym-0.2.2/managym/cards/tests/cards/rav.rs +52 -0
- managym-0.2.2/managym/cards/tests/cards/roe.rs +514 -0
- managym-0.2.2/managym/cards/tests/cards/scryfall.rs +50 -0
- managym-0.2.2/managym/cards/tests/cards/soi.rs +31 -0
- managym-0.2.2/managym/cards/tests/cards/stx.rs +688 -0
- managym-0.2.2/managym/cards/tests/cards/ths.rs +138 -0
- managym-0.2.2/managym/cards/tests/cards/tla.rs +15718 -0
- managym-0.2.2/managym/cards/tests/cards/war.rs +34 -0
- managym-0.2.2/managym/cards/tests/cards/zen.rs +54 -0
- managym-0.2.2/managym/cards/tests/cards.rs +56 -0
- managym-0.2.2/managym/cards/tests/fixtures/tla-allocation.jsonl +305 -0
- managym-0.2.2/managym/decision.py +289 -0
- managym-0.2.2/managym/decision_capture.py +184 -0
- managym-0.2.2/managym/enums.py +106 -0
- managym-0.2.2/managym/examples/bench_execution.rs +117 -0
- managym-0.2.2/managym/examples/bench_layers.rs +312 -0
- managym-0.2.2/managym/examples/bench_observation.rs +216 -0
- managym-0.2.2/managym/examples/bench_search.rs +164 -0
- managym-0.2.2/managym/examples/bench_steps.rs +76 -0
- managym-0.2.2/managym/examples/curated/mod.rs +71 -0
- managym-0.2.2/managym/examples/curated/search.rs +32 -0
- managym-0.2.2/managym/examples/export_canonical_replay.rs +16 -0
- managym-0.2.2/managym/examples/export_experience_protocol.rs +16 -0
- managym-0.2.2/managym/examples/export_study_index.rs +10 -0
- managym-0.2.2/managym/examples/export_study_protocol.rs +16 -0
- managym-0.2.2/managym/examples/export_study_recorded_decisions.rs +10 -0
- managym-0.2.2/managym/experience.py +770 -0
- managym-0.2.2/managym/experience_projection.py +646 -0
- managym-0.2.2/managym/perf/baseline.json +37 -0
- managym-0.2.2/managym/possible_worlds.py +587 -0
- managym-0.2.2/managym/src/agent/ability_description.rs +1042 -0
- managym-0.2.2/managym/src/agent/action.rs +238 -0
- managym-0.2.2/managym/src/agent/behavior_tracker.rs +44 -0
- managym-0.2.2/managym/src/agent/continuation.rs +1451 -0
- managym-0.2.2/managym/src/agent/effect_execution.rs +1077 -0
- managym-0.2.2/managym/src/agent/env.rs +1757 -0
- managym-0.2.2/managym/src/agent/mod.rs +16 -0
- managym-0.2.2/managym/src/agent/observation.rs +2120 -0
- managym-0.2.2/managym/src/agent/observation_encoder.rs +2046 -0
- managym-0.2.2/managym/src/agent/observation_json.rs +458 -0
- managym-0.2.2/managym/src/agent/opponent.rs +16 -0
- managym-0.2.2/managym/src/agent/policy_history.rs +498 -0
- managym-0.2.2/managym/src/agent/record_vocabulary.rs +383 -0
- managym-0.2.2/managym/src/agent/rollout_pool.rs +368 -0
- managym-0.2.2/managym/src/agent/shared_effects.rs +246 -0
- managym-0.2.2/managym/src/agent/structured_offer.rs +1996 -0
- managym-0.2.2/managym/src/agent/vector_env.rs +1803 -0
- managym-0.2.2/managym/src/benchmark_allocations.rs +59 -0
- managym-0.2.2/managym/src/benchmark_layers.rs +78 -0
- managym-0.2.2/managym/src/benchmark_search.rs +44 -0
- managym-0.2.2/managym/src/bin/semantic_conformance.rs +100 -0
- managym-0.2.2/managym/src/canonical_replay.rs +426 -0
- managym-0.2.2/managym/src/cards/content_pack.rs +257 -0
- managym-0.2.2/managym/src/cards/deck_admission.rs +224 -0
- managym-0.2.2/managym/src/cards/decklist.rs +592 -0
- managym-0.2.2/managym/src/cards/fixtures.rs +30 -0
- managym-0.2.2/managym/src/cards/mod.rs +39 -0
- managym-0.2.2/managym/src/cards/names.rs +146 -0
- managym-0.2.2/managym/src/cards/pool.rs +130 -0
- managym-0.2.2/managym/src/cards/setups.rs +193 -0
- managym-0.2.2/managym/src/cards/tokens.rs +744 -0
- managym-0.2.2/managym/src/conformance.rs +1073 -0
- managym-0.2.2/managym/src/decision.rs +857 -0
- managym-0.2.2/managym/src/decision_capture.rs +279 -0
- managym-0.2.2/managym/src/decision_context.rs +418 -0
- managym-0.2.2/managym/src/experience.rs +875 -0
- managym-0.2.2/managym/src/flow/action.rs +944 -0
- managym-0.2.2/managym/src/flow/card_capture.rs +438 -0
- managym-0.2.2/managym/src/flow/cast_permission.rs +455 -0
- managym-0.2.2/managym/src/flow/combat.rs +11 -0
- managym-0.2.2/managym/src/flow/combat_actions.rs +411 -0
- managym-0.2.2/managym/src/flow/damage.rs +245 -0
- managym-0.2.2/managym/src/flow/decision.rs +3796 -0
- managym-0.2.2/managym/src/flow/effects.rs +257 -0
- managym-0.2.2/managym/src/flow/event.rs +426 -0
- managym-0.2.2/managym/src/flow/game.rs +588 -0
- managym-0.2.2/managym/src/flow/identity.rs +247 -0
- managym-0.2.2/managym/src/flow/layers.rs +1203 -0
- managym-0.2.2/managym/src/flow/mana.rs +1288 -0
- managym-0.2.2/managym/src/flow/mod.rs +33 -0
- managym-0.2.2/managym/src/flow/naming_tests.rs +366 -0
- managym-0.2.2/managym/src/flow/play.rs +2034 -0
- managym-0.2.2/managym/src/flow/priority.rs +45 -0
- managym-0.2.2/managym/src/flow/proposed_event.rs +1444 -0
- managym-0.2.2/managym/src/flow/resolution.rs +2243 -0
- managym-0.2.2/managym/src/flow/resolution_tests.rs +3793 -0
- managym-0.2.2/managym/src/flow/retarget.rs +203 -0
- managym-0.2.2/managym/src/flow/sba.rs +309 -0
- managym-0.2.2/managym/src/flow/scenario.rs +224 -0
- managym-0.2.2/managym/src/flow/search.rs +318 -0
- managym-0.2.2/managym/src/flow/selection_sampling.rs +862 -0
- managym-0.2.2/managym/src/flow/setup.rs +169 -0
- managym-0.2.2/managym/src/flow/stabilization.rs +71 -0
- managym-0.2.2/managym/src/flow/statics.rs +1088 -0
- managym-0.2.2/managym/src/flow/target_authority_tests.rs +867 -0
- managym-0.2.2/managym/src/flow/tick.rs +485 -0
- managym-0.2.2/managym/src/flow/trigger.rs +148 -0
- managym-0.2.2/managym/src/flow/triggers.rs +1975 -0
- managym-0.2.2/managym/src/flow/turn.rs +383 -0
- managym-0.2.2/managym/src/flow/zones.rs +925 -0
- managym-0.2.2/managym/src/infra/mod.rs +1 -0
- managym-0.2.2/managym/src/infra/profiler.rs +284 -0
- managym-0.2.2/managym/src/lib.rs +29 -0
- managym-0.2.2/managym/src/match_fixtures.rs +123 -0
- managym-0.2.2/managym/src/possible_worlds.rs +1483 -0
- managym-0.2.2/managym/src/python/bindings.rs +4702 -0
- managym-0.2.2/managym/src/python/convert.rs +86 -0
- managym-0.2.2/managym/src/python/deck_bindings.rs +334 -0
- managym-0.2.2/managym/src/python/mod.rs +8 -0
- managym-0.2.2/managym/src/python/vector_env_bindings.rs +1484 -0
- managym-0.2.2/managym/src/search_state.rs +261 -0
- managym-0.2.2/managym/src/state/deck.rs +104 -0
- managym-0.2.2/managym/src/state/hash.rs +297 -0
- managym-0.2.2/managym/src/state/mod.rs +10 -0
- managym-0.2.2/managym/src/state/player.rs +130 -0
- managym-0.2.2/managym/src/study.rs +690 -0
- managym-0.2.2/managym/src/world.rs +137 -0
- managym-0.2.2/managym/state/Cargo.toml +11 -0
- managym-0.2.2/managym/state/src/ability.rs +1810 -0
- managym-0.2.2/managym/state/src/binding.rs +26 -0
- managym-0.2.2/managym/state/src/card.rs +1230 -0
- managym-0.2.2/managym/state/src/effect.rs +351 -0
- managym-0.2.2/managym/state/src/game_object.rs +279 -0
- managym-0.2.2/managym/state/src/lib.rs +24 -0
- managym-0.2.2/managym/state/src/mana.rs +787 -0
- managym-0.2.2/managym/state/src/permanent.rs +270 -0
- managym-0.2.2/managym/state/src/predicate.rs +201 -0
- managym-0.2.2/managym/state/src/stack_object.rs +176 -0
- managym-0.2.2/managym/state/src/subtype.rs +217 -0
- managym-0.2.2/managym/state/src/target.rs +2 -0
- managym-0.2.2/managym/state/src/zone.rs +219 -0
- managym-0.2.2/managym/tests/authored_match_tests.rs +63 -0
- managym-0.2.2/managym/tests/canonical_replay_tests.rs +187 -0
- managym-0.2.2/managym/tests/conformance_tests.rs +347 -0
- managym-0.2.2/managym/tests/content_pack_clone_allocations.rs +178 -0
- managym-0.2.2/managym/tests/content_pack_tests.rs +213 -0
- managym-0.2.2/managym/tests/elemental_world_tests.rs +59 -0
- managym-0.2.2/managym/tests/engine_tests.rs +444 -0
- managym-0.2.2/managym/tests/experience_protocol_tests.rs +151 -0
- managym-0.2.2/managym/tests/fixtures/naming_vocabulary.json +3006 -0
- managym-0.2.2/managym/tests/fixtures/observation_json/acting.json +1 -0
- managym-0.2.2/managym/tests/fixtures/observation_json/empty.json +1 -0
- managym-0.2.2/managym/tests/fixtures/observation_json/pending-0-0.json +1 -0
- managym-0.2.2/managym/tests/fixtures/observation_json/pending-0-1.json +1 -0
- managym-0.2.2/managym/tests/fixtures/observation_json/pending-1-0.json +1 -0
- managym-0.2.2/managym/tests/fixtures/observation_json/pending-1-1.json +1 -0
- managym-0.2.2/managym/tests/fixtures/observation_json/populated.json +1 -0
- managym-0.2.2/managym/tests/fixtures/observation_json/provenance.json +65 -0
- managym-0.2.2/managym/tests/fixtures/observation_json/sparse-optionals.json +1 -0
- managym-0.2.2/managym/tests/fixtures/observation_json/terminal.json +1 -0
- managym-0.2.2/managym/tests/fixtures/observation_json/viewer-0.json +1 -0
- managym-0.2.2/managym/tests/fixtures/observation_json/viewer-1.json +1 -0
- managym-0.2.2/managym/tests/fixtures/scryfall_cards.json +4624 -0
- managym-0.2.2/managym/tests/fixtures/structured_declare_attackers_offer.json +110 -0
- managym-0.2.2/managym/tests/fixtures/structured_priority_bolt_offer.json +90 -0
- managym-0.2.2/managym/tests/learn_setup_tests.rs +110 -0
- managym-0.2.2/managym/tests/match_state_hash_tests.rs +296 -0
- managym-0.2.2/managym/tests/possible_worlds_tests.rs +434 -0
- managym-0.2.2/managym/tests/prepared_possible_worlds_tests.rs +238 -0
- managym-0.2.2/managym/tests/rules/cr_103_game_start.rs +31 -0
- managym-0.2.2/managym/tests/rules/cr_106_mana.rs +145 -0
- managym-0.2.2/managym/tests/rules/cr_117_priority.rs +44 -0
- managym-0.2.2/managym/tests/rules/cr_305_lands.rs +60 -0
- managym-0.2.2/managym/tests/rules/cr_400_identity.rs +191 -0
- managym-0.2.2/managym/tests/rules/cr_405_stack.rs +110 -0
- managym-0.2.2/managym/tests/rules/cr_508_attackers.rs +72 -0
- managym-0.2.2/managym/tests/rules/cr_509_blockers.rs +60 -0
- managym-0.2.2/managym/tests/rules/cr_510_combat_damage.rs +60 -0
- managym-0.2.2/managym/tests/rules/cr_514_cleanup.rs +81 -0
- managym-0.2.2/managym/tests/rules/cr_601_casting.rs +99 -0
- managym-0.2.2/managym/tests/rules/cr_602_activated_abilities.rs +229 -0
- managym-0.2.2/managym/tests/rules/cr_603_triggers.rs +296 -0
- managym-0.2.2/managym/tests/rules/cr_608_resolution.rs +424 -0
- managym-0.2.2/managym/tests/rules/cr_613_continuous_effects.rs +1391 -0
- managym-0.2.2/managym/tests/rules/cr_614_replacement.rs +227 -0
- managym-0.2.2/managym/tests/rules/cr_702_keywords.rs +747 -0
- managym-0.2.2/managym/tests/rules/cr_704_sba.rs +441 -0
- managym-0.2.2/managym/tests/rules/decklist_disclosure.rs +198 -0
- managym-0.2.2/managym/tests/rules/engine_events.rs +571 -0
- managym-0.2.2/managym/tests/rules/event_log.rs +126 -0
- managym-0.2.2/managym/tests/rules/event_observations.rs +185 -0
- managym-0.2.2/managym/tests/rules/mod.rs +24 -0
- managym-0.2.2/managym/tests/rules/presentation_events.rs +105 -0
- managym-0.2.2/managym/tests/rules/structured_attacker_offers.rs +640 -0
- managym-0.2.2/managym/tests/rules/structured_offers.rs +708 -0
- managym-0.2.2/managym/tests/rules_tests.rs +2 -0
- managym-0.2.2/managym/tests/scenario_tests.rs +316 -0
- managym-0.2.2/managym/tests/search_state_contract.rs +252 -0
- managym-0.2.2/managym/tests/search_tests.rs +490 -0
- managym-0.2.2/managym/tests/semantic_conformance_tests.rs +88 -0
- managym-0.2.2/managym/tests/study_index_protocol_tests.rs +163 -0
- managym-0.2.2/managym/tests/study_protocol_tests.rs +122 -0
- managym-0.2.2/managym/tests/support/game.rs +462 -0
- managym-0.2.2/managym/tests/support/inspect.rs +376 -0
- managym-0.2.2/managym/tests/support/mod.rs +11 -0
- managym-0.2.2/managym/tests/support/play.rs +553 -0
- managym-0.2.2/managym/uv.lock +206 -0
- managym-0.2.2/pyproject.toml +39 -0
managym-0.2.2/PKG-INFO
ADDED
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: managym
|
|
3
|
+
Version: 0.2.2
|
|
4
|
+
Requires-Dist: numpy>=1.24.0
|
|
5
|
+
Requires-Dist: pydantic>=2.12.0
|
|
6
|
+
Summary: The Magic: The Gathering rules environment for Manabot
|
|
7
|
+
Requires-Python: >=3.12, <3.14
|
|
8
|
+
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
9
|
+
Project-URL: Homepage, https://manabot.gg
|
|
10
|
+
Project-URL: Repository, https://github.com/loopflowstudio/manabot
|
|
11
|
+
|
|
12
|
+
# managym
|
|
13
|
+
|
|
14
|
+
The deterministic Magic: The Gathering rules engine and training environment
|
|
15
|
+
behind Manabot. Rust, with PyO3 bindings consumed by `manabot` (the agent)
|
|
16
|
+
and `academy` (the optional play UI). Install the `managym` distribution for
|
|
17
|
+
`import managym` without the training stack. `manabot` depends on the exact
|
|
18
|
+
same version and keeps `manabot.managym` as a compatibility alias. Rust sources
|
|
19
|
+
stay in this directory. Start with the
|
|
20
|
+
[Python installation example](../docs/engine-python.md).
|
|
21
|
+
|
|
22
|
+
[Engine development principles](PRINCIPLES.md) records the lessons from
|
|
23
|
+
Allies–Lessons, Elemental and TLA: shared rule ownership, preserved choices and
|
|
24
|
+
timing, trustworthy learning evidence, and measured runtime/search performance.
|
|
25
|
+
|
|
26
|
+
## Architecture
|
|
27
|
+
|
|
28
|
+
managym is Manabot's authoritative world: match execution, semantic
|
|
29
|
+
Commands, viewer Observations, deterministic replay, exact forks, and the
|
|
30
|
+
meaning and materialization of possible worlds. The cross-package contracts
|
|
31
|
+
are in the [README](../README.md#contracts-the-code-enforces).
|
|
32
|
+
|
|
33
|
+
1. **`src/agent/`**: RL-facing API (`Env`, action spaces, observations)
|
|
34
|
+
2. **`src/flow/`**: Game progression (turns, priority, combat)
|
|
35
|
+
3. **`state/`**: the `managym-state` crate — rules vocabulary and game-state
|
|
36
|
+
types (cards, zones, mana, effects), re-exported here as `managym::state`;
|
|
37
|
+
**`src/state/`** adds players, decks and the canonical match-state hash
|
|
38
|
+
4. **`cards/`**: the `managym-cards` crate — card set modules (one per printed set)
|
|
39
|
+
and their tests, reached by the engine only through `managym_cards::catalog()`;
|
|
40
|
+
**`src/cards/`**: `ContentPack`, rules fixtures, authored setups, pool support and learning tokens
|
|
41
|
+
5. **`src/infra/`**: Logging and profiler infrastructure
|
|
42
|
+
6. **`src/python/`**: PyO3 bindings and Rust→Python conversions
|
|
43
|
+
|
|
44
|
+
Each card is a function in the file of its first printing's set under
|
|
45
|
+
`cards/src/`, returning the engine's own `CardDefinition` in its rules types
|
|
46
|
+
(`Effect`, `Ability`, `TargetSpec`, …). The engine runs that value directly, and
|
|
47
|
+
the learning catalog (`src/cards/tokens.rs`, `managym.learning_catalog`)
|
|
48
|
+
derives policy tokens from it. `src/world.rs` owns `WORLD_VERSION`, the card/deck
|
|
49
|
+
support check (defined non-token cards, excluding rules fixtures) and the set
|
|
50
|
+
filter. Known rules bugs are tracked as Tasks without revoking playability. Keep
|
|
51
|
+
decklist data separate from card behavior; see
|
|
52
|
+
[the content contract](../content/semantic/README.md).
|
|
53
|
+
|
|
54
|
+
Dependencies flow: python → agent → flow → state/infra, and across crates
|
|
55
|
+
`managym` → `managym-cards` → `managym-state`. `cargo test` in this directory
|
|
56
|
+
runs all three (the workspace's default members).
|
|
57
|
+
|
|
58
|
+
Authored setups come from `AuthoredSetup::player_config` (Python:
|
|
59
|
+
`managym.authored_deck_setup(setup, deck_key)`, naming the setup by preset or
|
|
60
|
+
by the `pack_key` frozen evidence records). Carry that complete config
|
|
61
|
+
when swapping seats or rebuilding roots: deck and sideboard together identify
|
|
62
|
+
an authored setup. `PlayerConfig::new` intentionally gives custom setups an
|
|
63
|
+
empty sideboard; it does not infer one from card names or a matching main deck.
|
|
64
|
+
Sideboard rosters are fixed at setup, and remaining copies are derived from
|
|
65
|
+
absence from game zones. They are not part of the library or a new game zone.
|
|
66
|
+
|
|
67
|
+
Viewer observations carry remaining owner copies in `agent_sideboard`, using
|
|
68
|
+
private `candidate_id` values that join Learn action focus. These are outside-game
|
|
69
|
+
descriptors, not `CardData` with a fabricated zone or in-game `ObjectRef`.
|
|
70
|
+
Both players expose definition-only initial and remaining sideboard counts;
|
|
71
|
+
only the owner gets copy candidates. Python observation JSON and validation
|
|
72
|
+
use the native Rust implementations so new visibility fields cannot drift.
|
|
73
|
+
|
|
74
|
+
The policy input factors resolved `EffectRecords` through `agent/shared_effects.rs`
|
|
75
|
+
before admission: complete equal payloads share one header and typed detail
|
|
76
|
+
slice, with one explicit membership per original record. Controller, exact
|
|
77
|
+
source incarnation, timestamps, fixed affected sets and duplicate edges survive.
|
|
78
|
+
Public object IDs are joins; private card storage IDs do not enter this view.
|
|
79
|
+
Native scalar/vector and Python encoders mirror bounded arrays of 128 × 18,
|
|
80
|
+
4096 × 3 and 2048 × 2; every capacity fails explicitly. Local facts exclude
|
|
81
|
+
active effects.
|
|
82
|
+
Projection never mutates or semantically coalesces the engine’s records.
|
|
83
|
+
|
|
84
|
+
Catalog naming uses `Decision::NameCard` over a shared immutable `NameVocabulary`.
|
|
85
|
+
The catalog builds sorted real names once, including back faces and excluding
|
|
86
|
+
tokens and rules fixtures. Decisions/forks share that allocation; canonical state
|
|
87
|
+
records its digest. A decision holds a `NameScope`; a scope over
|
|
88
|
+
`NAME_BRANCHING` (64) names offers a deterministic balanced partition into
|
|
89
|
+
contiguous groups, and choosing one only narrows the scope. Selecting a name
|
|
90
|
+
constructs one `ExileNamed` effect, then enters the existing private search
|
|
91
|
+
continuation. Public names and optional learning definition references are not
|
|
92
|
+
in-game card objects or deck admission. The policy input carries name joins and
|
|
93
|
+
group spans in `name_candidates[A,4]` at ordinary action capacity.
|
|
94
|
+
See [policy inputs](../docs/observation-and-model.md#catalog-naming-input).
|
|
95
|
+
|
|
96
|
+
Spell-level modes are announced before targets and payment. Independent target
|
|
97
|
+
clauses use `Effect::TargetClause`; effects within a clause share its targets.
|
|
98
|
+
Repeated specs in separate clauses may choose the same object. A resolving
|
|
99
|
+
frame retains its active clause and each chosen slot's resolution-start eligibility
|
|
100
|
+
across suspended decisions (CR 608.2b). Effects use those retained results; live
|
|
101
|
+
presence checks separately prevent following departed objects (CR 400.7).
|
|
102
|
+
Illegal slots remain positional, and zero optional targets still resolve.
|
|
103
|
+
`ObjectSelector::Targets` applies one verb to all eligible slots of that clause
|
|
104
|
+
in one event batch. `ForEachTarget` instead runs a separate child program per
|
|
105
|
+
slot, retaining its position across choices. Leaves from the Vine's simultaneous
|
|
106
|
+
counter placement uses the former.
|
|
107
|
+
Graveyard targets
|
|
108
|
+
carry an exact `ObjectRef`, so continuations cannot follow a physical card into
|
|
109
|
+
a later incarnation. Mutate permanents at their event authority;
|
|
110
|
+
source-relative effects require the original battlefield object.
|
|
111
|
+
|
|
112
|
+
Delayed abilities compose event matching, frequency, expiry, captured subjects
|
|
113
|
+
and effects. `CreateDelayedTrigger.event` only matches the event;
|
|
114
|
+
`DelayedFrequency::Once` consumes its watcher on the first match, even if the
|
|
115
|
+
occurrence is countered or later does nothing. `EachMatch` keeps waiting until
|
|
116
|
+
`DelayedExpiry::ThisTurn` removes the watcher at cleanup, or `Never` supplies no
|
|
117
|
+
stated expiry. Exact-object death watchers retire when the watched incarnation
|
|
118
|
+
leaves, regardless of frequency. Expiry removes waiting watchers, never queued
|
|
119
|
+
or stacked occurrences. No printed trigger vocabulary is migrated.
|
|
120
|
+
`CreateDelayedTrigger.remember` resolves an ordinary `ObjectSelector` when the
|
|
121
|
+
ability is created. Its exact incarnations travel through placement, stack and
|
|
122
|
+
suspended resolution; `ObjectSelector::Remembered` never follows a departed
|
|
123
|
+
object into a new incarnation. Event context (such as the spell just cast) stays
|
|
124
|
+
separate. End-step timing can wait for either player's step or the controller's,
|
|
125
|
+
independently of what was captured. Viewer-safe relations and text expose
|
|
126
|
+
the remembered references, expiry and frequency. Relation row kind 9 carries
|
|
127
|
+
frequency (column 28: 1 once, 2 each match); column 48 keeps its expiry meaning.
|
|
128
|
+
Missing historical frequency is unknown.
|
|
129
|
+
|
|
130
|
+
Public hand knowledge is a minimum multiset of `CardDefId` counts on `Player`,
|
|
131
|
+
not a set of revealed physical cards. Search forks by full clone: clone the
|
|
132
|
+
`Game` before a normal Command `apply` and compare `search_state::witness` to
|
|
133
|
+
check that the source is unchanged. Exercise nested choices through Commands,
|
|
134
|
+
not by direct calls to resolution helpers.
|
|
135
|
+
|
|
136
|
+
## Build and test
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
cargo fmt --check
|
|
140
|
+
cargo clippy --all-targets --all-features -- -D warnings
|
|
141
|
+
cargo test
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
**CI runs `cargo test` in debug — validate in debug before landing.** The
|
|
145
|
+
engine guards its invariants with `debug_assert!`, which compiles out of
|
|
146
|
+
release entirely, so a test can pass green in `--release` and still fail CI.
|
|
147
|
+
|
|
148
|
+
New registered real cards also need their Scryfall shell and Oracle text in
|
|
149
|
+
`tests/fixtures/scryfall_cards.json`; `cargo test --test conformance_tests`
|
|
150
|
+
checks every registration against that snapshot. For an accepted rules-world
|
|
151
|
+
change, record a new versioned conformance corpus and update the CI/test root
|
|
152
|
+
without rewriting earlier receipts. The current corpus is
|
|
153
|
+
[semantic-kernel-w17-v2](../conformance/semantic-kernel-w17-v2/).
|
|
154
|
+
|
|
155
|
+
After changing Rust, rebuild the Python extension into the uv-managed venv:
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
uv run --extra play maturin develop --release \
|
|
159
|
+
--manifest-path managym/Cargo.toml --features python
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
Run this from the repository root with its CPython 3.13 development environment.
|
|
163
|
+
For a 3.12 compatibility check, use a separate environment and rebuild for that
|
|
164
|
+
interpreter; a `cp313` extension cannot be reused by `cp312`. Follow
|
|
165
|
+
[AGENTS.md](../AGENTS.md#commands) when replacing an already loaded extension.
|
|
166
|
+
|
|
167
|
+
The [pinned Comprehensive Rules audit](https://github.com/loopflowstudio/manabot/blob/cac6fa27d/docs/rules/audit-2026-10/README.md)
|
|
168
|
+
inventories every numbered entry, with explicit unknowns and scoped evidence.
|
|
169
|
+
Card-shell checks and replay agreement do not independently prove rules
|
|
170
|
+
correctness. Prefer directed tests with independently specified outcomes and
|
|
171
|
+
small bounded combinations before adding longer random-game cohorts.
|
|
172
|
+
|
|
173
|
+
Check the committed inventory offline from the repository root with
|
|
174
|
+
`uv run python scripts/audit_rules.py`. Supplying `--source <downloaded-txt>`
|
|
175
|
+
also checks the pinned byte digest and exact source inventory. Do not upgrade
|
|
176
|
+
child rules merely because their family has a test or a matching citation.
|
|
177
|
+
The Prism/Treasure audit probe now follows explicit nested payment decisions
|
|
178
|
+
and passes its final mana, sacrifice and empty-stack assertions. Its original
|
|
179
|
+
failure remains historical evidence; this bounded pass does not certify all
|
|
180
|
+
payment rules. See the audit's
|
|
181
|
+
[ownership review](https://github.com/loopflowstudio/manabot/blob/cac6fa27d/docs/rules/audit-2026-10/unification.md)
|
|
182
|
+
before using its historical Task attribution.
|
|
183
|
+
|
|
184
|
+
## Style
|
|
185
|
+
|
|
186
|
+
```rust
|
|
187
|
+
// filename.rs
|
|
188
|
+
// One-line purpose of file
|
|
189
|
+
|
|
190
|
+
use crate::flow::game::Game;
|
|
191
|
+
use crate::state::player::PlayerId;
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
Prefer explicit types and focused modules. Keep game behavior in enums +
|
|
195
|
+
`match` expressions instead of inheritance-like abstractions.
|
|
196
|
+
|
|
197
|
+
Bounded observation encoders reserve card rows after the owner's visible cards
|
|
198
|
+
for outside candidates. Their seven zone bits stay zero and the explicit outside
|
|
199
|
+
bit is set; action focus uses the same padded object table as the model. The
|
|
200
|
+
current default has 512 action rows. Card, permanent, action and focus capacity
|
|
201
|
+
excesses raise encoding errors by default; they must not be treated as a random-policy
|
|
202
|
+
fallback. An explicit `action_overflow="first-legal"` policy retains the first
|
|
203
|
+
`max_actions` legal actions with their original indices and Commands. The TLA
|
|
204
|
+
pilot selects 64 slots and records replay-linked cutoff counts; the native and
|
|
205
|
+
Academy legal action sets remain complete. Other capacity excesses still fail.
|
|
206
|
+
Complete outside program bindings and public known-hand definition
|
|
207
|
+
counts still require the semantic input path during the Learn migration.
|
|
208
|
+
|
|
209
|
+
The optional [policy-history v1 projection](../docs/observation-and-model.md#policy-inputs) is a bounded
|
|
210
|
+
derived suffix updated at the native event append. Observation reads share it;
|
|
211
|
+
clone and diagnostic injection must preserve its documented lifecycle.
|
|
212
|
+
|
|
213
|
+
Every match, authored or not, runs on the world's one catalog
|
|
214
|
+
(`cards::content_pack::default_content_pack`): every set-file definition in name
|
|
215
|
+
order, so authored setups are decklists over the world pool, not packs.
|
|
216
|
+
`PlayerConfig.submitted` (Python: `world="world"`, `managym.WORLD_SETUP`, set by
|
|
217
|
+
`Deck.player()`) submits a deck to the installed world: it must pass
|
|
218
|
+
`development-v1` admission against the world's supported cards (see [decklist
|
|
219
|
+
import](../docs/engine.md#decks)) or reset fails. Fixed setups and tests leave
|
|
220
|
+
it unset and run as given without submitted-deck construction checks.
|
|
221
|
+
Any other `world` value is rejected: authored content packs are retired.
|
|
222
|
+
|
|
223
|
+
Mana feasibility and production share typed costs and pools. `Mana.lesson`
|
|
224
|
+
retains Herbalist's restriction; `effective_spell_cost` supplies the Lesson
|
|
225
|
+
casting context, while resolving costs and activations remain unrestricted
|
|
226
|
+
contexts. Chosen-color mana abilities pay their activation costs before their
|
|
227
|
+
immediate output decision. `Game::characteristics` derives battlefield grants;
|
|
228
|
+
those granted mana abilities never become activated stack objects. Waterbend
|
|
229
|
+
taps are cost payment, not tapping for mana. The view is the one reader of a
|
|
230
|
+
battlefield permanent's characteristics, legendary and ward included: the
|
|
231
|
+
legend rule reads its `is_legendary`, and every `CardData` field that states a
|
|
232
|
+
characteristic reads it there (`tests/cards/observability.rs` classifies each
|
|
233
|
+
field as layered or printed by definition).
|
|
234
|
+
|
|
235
|
+
The cached raw layer board tracks discovered reads of mana pools and tapped
|
|
236
|
+
state, including nested predicates and granted statics. Independent pool/tap
|
|
237
|
+
writes retain the board and fixed activations; dynamic activation outputs and
|
|
238
|
+
costs refresh separately. Trigger kinds follow raw layer dependencies. Immutable
|
|
239
|
+
scans use `layer_views` (or `characteristics_many` when activation finalization
|
|
240
|
+
is needed), preserving caller order and validating the shared board once in
|
|
241
|
+
debug. Singular reads retain their cache checks. Opt-in `benchmark`
|
|
242
|
+
instrumentation attributes board, clone and dependency work without adding
|
|
243
|
+
counters to ordinary wheels.
|
|
244
|
+
|
|
245
|
+
A resolving spell remains on the stack until the zone-move authority commits
|
|
246
|
+
its departure. That authority applies flashback exile replacement and captures
|
|
247
|
+
cast provenance before removing the stack object. Do not remove spells early in
|
|
248
|
+
countering or finalization. Copied tokens detach immutable characteristics from
|
|
249
|
+
the source definition, retain its semantic identity, and expose their actual
|
|
250
|
+
legendary status in observations; canonical hashing includes their copied data.
|
|
251
|
+
|
|
252
|
+
Resolving optional costs use `Effect::OptionalPayment` and `PaymentProgress`.
|
|
253
|
+
Their [ownership and authoring contract](../docs/engine.md#resolution-contracts)
|
|
254
|
+
covers both ordinary mana and waterbend without a card-specific decision.
|
|
255
|
+
`OptionalManaPaymentX` first chooses an affordable X, then uses the same payment
|
|
256
|
+
progress. Its `WhenYouDo` branch creates a distinct occurrence retaining X;
|
|
257
|
+
`TargetRequirement.total_mana_value_x` bounds the whole chosen clause, including
|
|
258
|
+
retargeting. Named searches retain native permission to inspect the searched
|
|
259
|
+
zones only during the instruction; semantic capture uses that permission too.
|
|
260
|
+
|
|
261
|
+
Mana offers, waterbend affordability and automatic production use executable
|
|
262
|
+
witnesses from `flow/mana.rs`. A mana source is reserved while its printed
|
|
263
|
+
upfront cost is pending; `Decision::ManaUpfront` retains the parent decision
|
|
264
|
+
and frame. Only after that obligation finishes do its tap/life/sacrifice costs
|
|
265
|
+
commit and its output become a visible color decision. Mana abilities do not
|
|
266
|
+
create stack objects. Fixed production keeps source order; a nested automatic
|
|
267
|
+
prefix considers concrete pool remainders and the parent's completion.
|
|
268
|
+
|
|
269
|
+
Every registered chosen-output mana mode consumes a tap (sometimes also a
|
|
270
|
+
sacrifice), so each source has one use during a payment. The registry contract
|
|
271
|
+
requires a model extension before introducing separate tap/sacrifice mana uses,
|
|
272
|
+
repeatable free sources, or additional mana-ability cost methods.
|
|
273
|
+
Search retains identities rather than grouping equal outputs. Its total and
|
|
274
|
+
spend-purpose bounds only reject impossible branches; every accepted payment
|
|
275
|
+
still requires a complete witness. This is finite search, without a general
|
|
276
|
+
large-board performance guarantee.
|
|
277
|
+
|
|
278
|
+
`Env.capture_decision(viewer, history_capacity=0)` supplies atomic decision capture
|
|
279
|
+
v5: the schema-8 semantic Observation, shared native continuation frames, bound public card
|
|
280
|
+
characteristics, visible object joins, world/content identity and optional public
|
|
281
|
+
history v1 (0 disables it; 1..32 admits a chronological suffix). Its SHA-256 covers
|
|
282
|
+
all fields except the digest itself using recursively key-sorted compact JSON.
|
|
283
|
+
`DECISION_CAPTURE_VERSION` owns this aggregate's inclusion/order/digest contract;
|
|
284
|
+
`SEMANTIC_DECISION_VERSION` owns embedded schema 8. Historical captures retain
|
|
285
|
+
their original schema; w14 deliberately changes the current action contract.
|
|
286
|
+
|
|
287
|
+
The opaque native capture binds an Env and reset generation. Use
|
|
288
|
+
`execute_captured_command_json(capture, command_json)` for atomic origin and
|
|
289
|
+
current-digest validation plus ordinary semantic execution. Portable capture JSON
|
|
290
|
+
is evidence, not execution authority; clones need their own live capture.
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
The policy input has configurable fact capacity (512 by default). It keeps
|
|
294
|
+
trigger-placement action joins and retained
|
|
295
|
+
resolution-start eligibility in native current stack/continuation relations, and
|
|
296
|
+
widens player and card rows for cast permissions, the hand-only lock, restricted
|
|
297
|
+
mana by spending subtype and announced X. Its
|
|
298
|
+
layout, checkpoint admission and measurement commands are documented in
|
|
299
|
+
[the observation input contract](../docs/observation-and-model.md#policy-inputs).
|
|
300
|
+
The presentation context and text capture derive from the same typed frames;
|
|
301
|
+
portable schema-8 viewer JSON is validated by the native observation types.
|
|
302
|
+
|
|
303
|
+
`Game::card_power` reads contextual power in every zone: the layered view on
|
|
304
|
+
the battlefield, and characteristic-defining abilities with the spell's
|
|
305
|
+
controller or card's owner elsewhere (including outside the game). Zone
|
|
306
|
+
filters use `card_matches_predicate`; printed-only matching belongs to
|
|
307
|
+
structural definition checks and private layer stages. `LookAndSelect` names
|
|
308
|
+
whether the remainder is random; chosen order suspends on native
|
|
309
|
+
`OrderLibrary`, placing cards first-to-draw first through ordinary SelectCard
|
|
310
|
+
Commands. Bottom ordering exposes the remaining inspected cards; Surveil uses
|
|
311
|
+
the same owner to order kept cards on top, retaining the chosen prefix privately
|
|
312
|
+
until ordering finishes. Top ordering has obligation code 27 (mode is the
|
|
313
|
+
committed prefix length); code 23 retains its bottom-order meaning.
|
|
314
|
+
|
|
315
|
+
`EffectFrame::completion` owns the return destination: the interrupted scope,
|
|
316
|
+
a retained caller decision, a completed-operation event, root spell cleanup,
|
|
317
|
+
or root priority. Completion events fire before the caller's suffix; Scry and
|
|
318
|
+
Surveil wait for every partition and ordering choice. `continue_resolution` runs
|
|
319
|
+
any pending batch before exposing the next decision. An `EventBatch` on the active
|
|
320
|
+
frame retains every proposal, applied replacement identity, pre-departure facts
|
|
321
|
+
and result until replacement choices and consequent linked returns finish. The
|
|
322
|
+
affected player chooses each replacement; applicability is recomputed after every
|
|
323
|
+
transformation. No member
|
|
324
|
+
commits until the complete batch is ready. Native obligation code 29 names this
|
|
325
|
+
choice, with source-specific labels and focus.
|
|
326
|
+
|
|
327
|
+
Mana activation sacrifice effects retain their output and parent payment there
|
|
328
|
+
after upfront mana, tap and life costs commit. Returning from a linked-entry
|
|
329
|
+
replacement restores the saved decision without paying costs again or opening
|
|
330
|
+
priority. Combat, SBA departures, spell finalization, activated costs, token
|
|
331
|
+
entry and Surveil movement use this owner. SBA progress distinguishes stable,
|
|
332
|
+
changed and pending; a pending turn action cannot enter priority stabilization.
|
|
333
|
+
Immediate fixture/arithmetic helpers require completion without a question and
|
|
334
|
+
fail explicitly if used for a choice-bearing event. Sacrifice facts match their
|
|
335
|
+
pre-move subjects after replacement choices and before any batch member leaves;
|
|
336
|
+
trigger placement still waits for resolution. The policy input projects the
|
|
337
|
+
retained program, results, completion and proposals through fact-kind 14 as bare
|
|
338
|
+
name/value facts, with viewer-safe reference slots in relation kind 10; a frame
|
|
339
|
+
that retains nothing emits no occurrence. Academy's pending-resolution summary
|
|
340
|
+
and LLM text are rendered by the same walk only through `describe_effect_execution`
|
|
341
|
+
(decision context and capture), never by a policy observation.
|
|
342
|
+
|
|
343
|
+
`SelectCards` snapshots eligible exact objects from its selector, retains min/max
|
|
344
|
+
cardinality across choices, and runs the chosen effects in a child scope with
|
|
345
|
+
`ObjectSelector::Selected`. `CardsThisWay` names the scope's latest mill/discard
|
|
346
|
+
result independently of a later `Move`; the caller keeps those results while
|
|
347
|
+
selection effects run. Mill, optional discard/draw and basic/tutor searches use
|
|
348
|
+
ordinary `MillCards`, `If`, `SelectCards`, `Move` and `ShuffleLibrary` composition.
|
|
349
|
+
`ObjectSelector::Zone` records source-zone/predicate provenance; both hidden-world
|
|
350
|
+
materializers refresh unknown selected subsets throughout saved callers and child
|
|
351
|
+
scopes, preserving cardinality and exact viewer-known choices. Restricted partial
|
|
352
|
+
selections exclude incompatible count worlds. Foretold assignments use the same
|
|
353
|
+
subset constraints: exact weights count only compatible ordered fills, and the
|
|
354
|
+
materializer samples that conditional measure. Commitments are captured before
|
|
355
|
+
zone reassignment, so a sampled face-down slot cannot erase an earlier selection.
|
|
356
|
+
Frozen count-only belief samplers reject these additional constraints before
|
|
357
|
+
inference. `ObjectBinding` carries exact incarnation, captured zone/predicate and
|
|
358
|
+
per-seat exact knowledge through waiting, queued, placing, stack and resolving
|
|
359
|
+
trigger lifetimes. Both samplers use one assignment across those captures and
|
|
360
|
+
active selections; known exact captures remain fixed, and departed incarnations
|
|
361
|
+
never follow a later object. Capturing `Moved` uses its new zone. This binding
|
|
362
|
+
provenance is canonical state, independent of viewer-safe reference projection. Library inspection exposes membership in stable definition/object order,
|
|
363
|
+
never draw order. Prospective battlefield entrants are public during replacement
|
|
364
|
+
choices and remain pinned in both samplers.
|
|
365
|
+
|
|
366
|
+
`Effect::Move.library_end` states top/bottom placement without a shuffle; its
|
|
367
|
+
placement commits before linked returns can pause. `put_in_library` authors that
|
|
368
|
+
operation, and `ShuffleLibrary` can follow after all child work. Ordinary `move_to`
|
|
369
|
+
retains shuffle-into-library behavior. Shared selection has obligation code 28;
|
|
370
|
+
retired codes 5, 6 and 7 keep their historical meanings.
|
|
371
|
+
|
|
372
|
+
`SuspendedResolution::continuation` walks retained frames and decisions root first;
|
|
373
|
+
observation projection and hidden-world sampling share that chain for caller
|
|
374
|
+
ancestry and inspection permissions.
|
|
375
|
+
|