Principle:AIScientists Dev WorldSeed Effect Execution
| Knowledge Sources | |
|---|---|
| Domains | DSL, State_Management |
| Last Updated | 2026-10-26 18:00 GMT |
Overview
A registry-based DSL effect executor that applies state mutations — setting, incrementing, decrementing properties, creating/removing entities, manipulating lists, managing relationships, emitting events, and iterating over collections — all dispatched by operator name without hardcoding any scene-specific logic.
Description
Effects are the mutation layer of the WorldSeed DSL. Each effect is an `EffectConfig` with an `operator` field that selects a handler from a module-level registry. The `execute()` function looks up the handler and calls it with a uniform signature: `(effect, store, event_log, ctx, tick)`.
Available operators:
- state_ops: `set`, `increment`, `decrement` — modify entity properties with min/max bounds
- entity_ops: `create_entity`, `remove_entity` — lifecycle management
- event_ops: `emit_event` — append to EventLog with scope, TTL, push, highlight flags
- list_ops: `list_append`, `list_remove`, `list_pop_random` — collection manipulation
- relationship_ops: `add_relationship`, `remove_relationship` — entity graph edges
- rotate_ops: `rotate` — cyclic sequence advancement
- for_each_ops: `for_each` — iterate over entities and apply nested effects
- autoresearch_exec: Scene-specific operator for the autoresearch community
Effects support a conditional `when` clause: if present, the effect is skipped when the condition evaluates false. This enables conditional logic within effect lists without separate action definitions.
Usage
Use this principle to understand how actions and DM judgments mutate world state. Effects are executed by `RulesEngine` during action processing, by `ConsequenceScanner` during reactive triggers, and by `apply_dm_response` during DM judgment application.
Theoretical Basis
The executor follows the same registry-dispatch pattern as preconditions:
# Abstract dispatch (NOT real implementation)
def execute(effect, store, event_log, ctx, tick):
if effect.when is not None:
if not evaluate_precondition(effect.when, store, ctx):
return # conditional skip
handler = registry.get(effect.operator)
if handler is None:
raise ValueError(f"Unknown effect operator: {effect.operator}")
handler(effect, store, event_log, ctx, tick)
All handlers share the same signature, so new operators can be added by registering a function — no changes to the dispatch logic. Scene-specific operators (like `autoresearch_exec`) are registered at import time and coexist with generic ones.