GuardedJsonList

Source:

Local role: Guarded list wrapper used in mutable fields of ModelObject.

Big-picture role: Extends authority-safe mutation behavior to list operations in objects managed by World.

Inheritance:

  • list[Any]

Parameters and fields:

  • initial: List[Any] | None
  • mutation_guard: MutationGuard

Methods:

  • set_mutation_guard(...)
  • guarded mutators: append, extend, insert, pop, remove, reverse, sort, __setitem__, __delitem__, __iadd__
  • __deepcopy__(...)

Example:

from ometeotl_core.model.base import GuardedJsonList

lst = GuardedJsonList(["tag-a", "tag-b"])
lst.append("tag-c")        # allowed — no guard active
lst.remove("tag-a")

# When a World enables authority mode, the mutation guard fires
# and lst.append(value) raises RuntimeError until authority mode is disabled.

See also:

Ometeotl

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