RuntimeContext

Source:

Local role: Context manager that bundles one World with optional AuthorityCommandHandler.

Big-picture role: Runtime switch between local mode and server-authoritative mode.

Inheritance:

  • dataclass

Parameters and fields:

Methods:

  • enter() -> RuntimeContext
  • __exit__(...) -> None
  • authoritative -> bool
  • close() -> None

Related function:

Runtime policy options passed through build_runtime(...):

  • validation_soft_gate
  • validation_policy_profile (observe_only, enforce_structure, enforce_domain)
  • validation_stage_mode_overrides
  • validation_block_on_error
  • validation_completeness_level

Example:

from ometeotl_core.generic.runtime import build_runtime

# Local mode: direct mutations allowed
with build_runtime(world=world) as ctx:
    print(ctx.authoritative)   # False — no AuthorityCommandHandler attached
    world.add_space(space)

# Authoritative mode: all mutations go through the handler
with build_runtime(
    world=world,
    validation_policy_profile="enforce_structure",
    validation_soft_gate=True,
) as ctx:
    result = ctx.authority_handler.submit(envelope)
    print(result.accepted)

See also:

Ometeotl

A Python library to build complex multi-agent simulations, wargames, and AI-driven strategies