Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:AIScientists Dev WorldSeed ConsequenceScanner scan

From Leeroopedia
Knowledge Sources
Domains Simulation, Reactive_Systems
Last Updated 2026-10-26 18:00 GMT

Overview

Concrete reactive rule scanner that evaluates consequence triggers each tick, fires effects on state transitions or persistent conditions, and cascades via re-scanning until a stable fixed point is reached.

Description

The ConsequenceScanner.scan() method evaluates all consequence triggers and fires effects when conditions are met. It supports two firing modes (`on_change` and `every_tick`), two scoping modes (global and per-entity with `$entity`), and cascading with up to 10 re-scan passes.

Consequences are pre-classified at construction time: those referencing `$entity` are evaluated per-entity per-tick; others are evaluated once per tick.

The scanner also handles consequence-triggered DM calls — if a consequence has a `dm` config, the DM intent is returned for async resolution.

Usage

Import this class to scan consequences. In production, it's created by `TickEngine.__init__()` and called during `_post_actions()` each tick.

Code Reference

Source Location

  • Repository: WorldSeed
  • File: src/worldseed/engine/consequence_scanner.py

Signature

class ConsequenceScanner:
    def __init__(
        self,
        config: SceneConfig,
        store: StateStore,
        event_log: EventLog,
        recorder: Any = None,
    ) -> None: ...

    def scan(self, tick: int) -> tuple[list[str], list[dict[str, Any]]]:
        """Scan all consequences, re-scanning until stable.

        Returns:
            (triggered_names, dm_pending_list)
        """

Import

from worldseed.engine.consequence_scanner import ConsequenceScanner

I/O Contract

Inputs

Name Type Required Description
tick int Yes Current tick number
(internal) SceneConfig Consequence definitions from config
(internal) StateStore Current world state

Outputs

Name Type Description
return[0] list[str] Names of triggered consequences
return[1] list[dict] DM pending calls for consequence DM resolution
(mutation) StateStore Effects applied for triggered consequences

Usage Examples

from worldseed.engine.consequence_scanner import ConsequenceScanner

scanner = ConsequenceScanner(config, store, event_log, recorder=recorder)

# Scan each tick
triggered, dm_pending = scanner.scan(tick=5)
print(f"Triggered: {triggered}")
if dm_pending:
    print(f"{len(dm_pending)} consequence DM calls pending")

Related Pages

Implements Principle

Requires Environment

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment