babylon.kernel.system_base

SystemBase — abstract base class for simulation Systems (ADR-003).

Lifts the shared scaffolding that the 22 System implementations duplicate: - name declaration (ClassVar) - the GraphProtocol narrowing guard (raw nx graphs rejected per Amendment L) - the read-node-attribute pattern with required=True diagnostics - the publish-via-event-bus shorthand

The companion System Protocol in babylon.kernel.system_protocol is preserved for structural typing (tests, mocks). PEP 544 explicitly supports this dual-export pattern.

Per ADR-003 (Bundle 2 / Spec 059) and research.md D1 (22 Systems, not 23).

Functions

resolve_rng(services, tick)

Seed-deterministic RNG for stochastic System rolls (III.7).

Classes

SystemBase()

Abstract base for all simulation Systems.

babylon.kernel.system_base.resolve_rng(services, tick)[source]

Seed-deterministic RNG for stochastic System rolls (III.7).

Prefers services.rng when a harness injects one; otherwise a fresh random.Random(0xBA1AC1A + tick) — the spec-070 fallback previously duplicated by faction_influence and reactionary.

Parameters:
  • services (ServicesProtocol) – Service container (checked for an injected rng).

  • tick (int) – Current simulation tick, mixed into the fallback seed.

Return type:

Random

Returns:

A random.Random whose stream is a pure function of tick (fallback path) or the injected harness RNG.

class babylon.kernel.system_base.SystemBase[source]

Bases: ABC

Abstract base for all simulation Systems.

Subclasses MUST set the name ClassVar and implement step().

Helpers:

_wrap_graph() — assert the graph satisfies GraphProtocol. _read() — read a node attribute, raising KeyError when

required=True and the attribute is absent (surfaces schema bugs at the read site, per CLAUDE.md “Common Gotchas”).

_publish() — publish an event via the service container’s bus.

name: ClassVar[str]
creates_value: ClassVar[bool] = False
abstractmethod step(graph, services, context)[source]

Apply system logic to the world graph (in-place mutation).

The signature matches babylon.kernel.system_protocol.System exactly. The engine (and all test fixtures) pass a BabylonGraph, which satisfies GraphProtocol.

Return type:

None

Parameters: