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 checkpoint evaluate

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

Overview

Concrete pure function that evaluates checkpoint cadence policies — event count, time interval, tick delta, and event type triggers — and returns an optional checkpoint signal with deterministic metadata.

Description

The evaluate function in `engine/director/checkpoint.py` is a pure function on inputs: policy, state, recent events, and timing. It never summarizes semantically — the payload is deterministic metadata (event type counts, recent refs, pending DM count).

Four cadence triggers:

  • every_events: Meaningful new event count crosses threshold
  • every_minutes: Elapsed wall-clock time crosses interval
  • every_ticks: Tick delta crosses threshold
  • on_event_types: Any new event has a matching type (forced fire)

The state cursor uses `appended_now` (total events ever appended) rather than list indices, surviving TTL cleanup.

Usage

Import this function for checkpoint cadence evaluation. In production, called by `DirectorRuntime._observe_checkpoint()`.

Code Reference

Source Location

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

Signature

def evaluate(
    *,
    tick: int,
    monotonic_now: float,
    new_events: list[Event],
    policy: CheckpointPolicy,
    state: CheckpointState,
    new_id: str,
    pending_dm_count: int,
    appended_now: int,
) -> tuple[DirectorSignal | None, CheckpointState]:
    """Return (maybe-signal, advanced state)."""

Import

from worldseed.engine.director.checkpoint import evaluate

Usage Examples

from worldseed.engine.director.checkpoint import evaluate
from worldseed.engine.director.models import CheckpointPolicy, CheckpointState
import uuid

policy = CheckpointPolicy(every_events=10, every_ticks=5)
state = CheckpointState()

signal, state = evaluate(
    tick=10,
    monotonic_now=time.monotonic(),
    new_events=recent_events,
    policy=policy,
    state=state,
    new_id=uuid.uuid4().hex[:16],
    pending_dm_count=2,
    appended_now=event_log.total_appended,
)

if signal is not None:
    print(f"Checkpoint: {signal.reason}")
    print(f"Payload: {signal.payload}")

Related Pages

Implements Principle

Requires Environment

Page Connections

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