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 DirectorQueue

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

Overview

Concrete in-memory durable queue for director signals and DM requests with deduplication rules and FIFO ordering, serving as the persistable container the engine writes to and the API serves from.

Description

The DirectorQueue class stores signals and DM requests with specific dedup contracts:

  • urgent: At most one pending signal per (target_agent_id, event_ref). Re-queueing while a previous urgent for the same agent + event ref is pending is a no-op.
  • checkpoint: At most one pending checkpoint at a time. A new checkpoint while one is pending is dropped.
  • dm_request: Never deduped. Every action/consequence DM intent is distinct.

The queue is non-draining: `peek_pending()` returns signals without removing them. Callers must explicitly `ack_signal()` (for urgent/checkpoint) or `resolve_dm_request()` (for DM requests).

Persistence via `to_dict()` / `restore()` enables pause/resume.

Usage

Import this class to access the director queue. In production, owned by `DirectorRuntime` and accessed via the runtime's facade methods.

Code Reference

Source Location

  • Repository: WorldSeed
  • File: src/worldseed/engine/director/queue.py

Signature

class DirectorQueue:
    def enqueue_signal(self, signal: DirectorSignal) -> bool: ...
    def peek_pending(self, limit=None, types=None) -> list[DirectorSignal]: ...
    def ack_signal(self, signal_id: str) -> bool: ...
    def enqueue_dm_request(self, request: PendingDMRequest) -> None: ...
    def get_dm_request(self, request_id: str) -> PendingDMRequest | None: ...
    def resolve_dm_request(self, request_id: str, result: dict) -> bool: ...
    def fail_dm_request(self, request_id: str, reason: str) -> bool: ...
    def pending_dm_count(self) -> int: ...
    def to_dict(self) -> dict: ...
    def restore(self, data: dict) -> None: ...

Import

from worldseed.engine.director.queue import DirectorQueue

Usage Examples

from worldseed.engine.director.queue import DirectorQueue

queue = DirectorQueue()

# Enqueue signals (returns False if deduped)
accepted = queue.enqueue_signal(signal)

# Peek pending (does not drain)
pending = queue.peek_pending(limit=10, types=["urgent", "checkpoint"])

# Acknowledge
queue.ack_signal("signal_id_123")

# Resolve DM request
queue.resolve_dm_request("request_id_456", {"narrative": "...", "effects": [...]})

Related Pages

Implements Principle

Requires Environment

Page Connections

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