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 director resolver resolve

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

Overview

Concrete external DM resolve handler that applies a watcher-supplied judgment to a queued pending DM request, reusing the same validation, sanitization, and atomic application pipeline as in-process DM.

Description

The resolve function in `director_resolver.py` reads a `PendingDMRequest` from the director queue, validates and sanitizes the supplied effects through the same pipeline as in-process DM, applies them atomically via `apply_dm_response`, and marks the request resolved or failed in the queue.

The resolve flow:

  1. Fetch the pending DM request by ID
  2. Validate status is "pending"
  3. Parse effects from raw dicts into `EffectConfig` objects
  4. Validate effects via `validate_dm_effects`
  5. Sanitize effects via `sanitize_dm_effects`
  6. Apply atomically via `apply_dm_response` (with rollback on failure)
  7. Mark request resolved or failed in the queue
  8. Call `engine.refresh_perception_and_observe()` so observers see the new state

Usage

Import this function for external DM resolution. In production, called by `WorldEngine.resolve_director_dm_request()` which is invoked by the `POST /api/director/dm/{id}/resolve` endpoint.

Code Reference

Source Location

  • Repository: WorldSeed
  • File: src/worldseed/director_resolver.py

Signature

def resolve(
    engine: WorldEngine,
    request_id: str,
    narrative: str,
    effects_raw: list[dict[str, Any]],
) -> tuple[bool, str]:
    """Apply an external DM judgment. Returns (ok, reason)."""

Import

from worldseed import director_resolver
# Or via WorldEngine.resolve_director_dm_request()

Usage Examples

# Via WorldEngine facade
ok, reason = engine.resolve_director_dm_request(
    request_id="abc123",
    narrative="The tea was perfectly brewed.",
    effects_raw=[
        {"operator": "set", "target": "teapot.temperature", "value": 80},
        {"operator": "increment", "target": "agent_1.satisfaction", "value": 5},
    ],
)

if ok:
    print("DM request resolved successfully")
else:
    print(f"Failed: {reason}")

Related Pages

Implements Principle

Requires Environment

Page Connections

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