app.engine.strategy_registry module

Explicit strategy registry.

Replaces the legacy filesystem-scan in app.engine.all_engine_strategies. Strategy classes opt-in by decorating themselves with register_strategy(). External packages can contribute strategies via the game.strategies entry-point group declared in their packaging metadata.

app.engine.strategy_registry.register_strategy(id, *, version=None)[source]

Register a strategy class under a stable, public id.

The id is the value persisted on games and returned by the API, so it must remain stable across class renames or file moves.

Parameters:
  • id (str) – Public identifier for the strategy (e.g. "default").

  • version (str | None) – Optional version string. When provided, it is also exposed as the __strategy_version__ class attribute.

Raises:

ValueError – If id is empty or another class is already registered under the same id.

Return type:

Callable[[T], T]

app.engine.strategy_registry.registered_strategies()[source]

Return a snapshot of the registry as {id: class}.

Return type:

dict[str, type]

app.engine.strategy_registry.get_registered_class(strategy_id)[source]

Lookup a registered strategy class by id, or None if missing.

Parameters:

strategy_id (str)

Return type:

type | None

app.engine.strategy_registry.clear_registry()[source]

Reset the registry. Intended for tests only.

Return type:

None