Implementation:AIScientists Dev WorldSeed validate scene
| Knowledge Sources | |
|---|---|
| Domains | Validation |
| Last Updated | 2026-10-26 18:00 GMT |
Overview
Concrete tool for running multi-level validation checks on a scene config beyond the Pydantic schema, covering static references, physics simulation, smoke tests, and sanity checks provided by the WorldSeed library.
Description
The validate function (in `scene/validator.py`) is the comprehensive validation entry point. It runs five levels of checks on a loaded `SceneConfig`:
- Level 2 — References: Duplicate IDs, relationship targets, effect targets, agent locations, event scopes, action params, enum sources, graph connectivity, auto_tick emit events, UI consistency.
- Level 3 — Physics: Simulates N ticks with no agents to verify resource trajectories and consequence triggers.
- Level 4 — Smoke: Attempts each action with each agent in the initial state.
- Level 5 — Sanity: Runs the config's own declared `sanity_checks` section.
Levels 3-5 only run if Level 2 passes (no hard errors). The `validate_cmd` CLI wrapper provides JSON output and pedantic hint display.
Usage
Import this function to validate a scene config programmatically. The `worldseed validate` CLI command wraps it for command-line use.
Code Reference
Source Location
- Repository: WorldSeed
- File: src/worldseed/scene/validator.py
Signature
def validate(
config: SceneConfig,
physics_ticks: int = 50,
run_sanity: bool = True,
) -> ValidationResult:
"""Run all validation levels."""
# CLI wrapper:
def validate_cmd(args: argparse.Namespace) -> None:
"""Validate a scene config (worldseed validate CLI)."""
Import
from worldseed.scene.validator import validate
from worldseed.cli.validate import validate_cmd # CLI entry
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| config | SceneConfig | Yes | Loaded scene config |
| physics_ticks | int | No | Physics simulation ticks (default 50) |
| run_sanity | bool | No | Run sanity_checks section (default True) |
Outputs
| Name | Type | Description |
|---|---|---|
| return | ValidationResult | Messages, physics report, smoke report, sanity results |
| ValidationResult.ok | bool | True if no error-level messages |
Usage Examples
Programmatic Validation
from worldseed.scene.config import load_config
from worldseed.scene.validator import validate
config = load_config("configs/teahouse.yaml")
result = validate(config, physics_ticks=50)
if result.ok:
print(f"Valid! {result.entity_count} entities, {result.action_count} actions")
else:
for error in result.errors:
print(f"[{error.code}] {error.summary}")
if error.suggestion:
print(f" Suggestion: {error.suggestion}")
CLI Usage
# Basic validation
worldseed validate --config configs/teahouse.yaml
# With JSON output
worldseed validate --config configs/teahouse.yaml --json-output
# With more physics ticks and pedantic hints
worldseed validate --config configs/teahouse.yaml --ticks 100 --pedantic