* feat!: collapse pipeline — Resolver emits a flat prompt, drop categories (v1.1) BREAKING CHANGE: the Category Splitter and Prompt Builder stages and nodes are removed. The Resolver is now the translator from Scene JSON to prompt: it resolves concepts to Knowledge Base tags and joins them into one flat comma-separated prompt string, in resolution order (which naturally leads with character concepts). Resolver node outputs are now (prompt, warnings, errors, json) — the json being the traceable resolved tags so a translation problem is inspectable. Node count drops from 8 to 6. The CategoryMap/PromptOutput models and their schemas are removed; the `category` field remains on entries and resolved tags for traceability only. Debug Viewer simplified to scene/warnings/errors. Goldens, example scenes/workflow, integration/performance/repo-layout/release tests, benchmark script, and the docs (README + wiki) are updated to the flat prompt. Version bumped to 1.1.0. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * build: drop removed splitter/builder packages from pyproject Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> --------- Co-authored-by: kunail0804 <kunail0804@gmail.com> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
58 lines
2.0 KiB
Python
58 lines
2.0 KiB
Python
"""Tests that the shipped example scenes compile to their documented outputs (#30)."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
from tests.regression.golden_scenes import (
|
|
compile_prompt,
|
|
load_reference_knowledge_base,
|
|
)
|
|
|
|
EXAMPLES_DIR = Path(__file__).resolve().parent.parent / "examples"
|
|
SCENES_DIR = EXAMPLES_DIR / "scenes"
|
|
WORKFLOW_FILE = EXAMPLES_DIR / "workflows" / "scene_compiler_pipeline.json"
|
|
|
|
SCENE_FILES = sorted(SCENES_DIR.glob("*.scene.json"))
|
|
|
|
|
|
@pytest.fixture(scope="module")
|
|
def knowledge_base():
|
|
return load_reference_knowledge_base()
|
|
|
|
|
|
def test_example_scenes_exist() -> None:
|
|
assert SCENE_FILES, "no example scenes found"
|
|
for scene_file in SCENE_FILES:
|
|
expected = scene_file.with_name(scene_file.name.replace(".scene.json", ".prompts.json"))
|
|
assert expected.is_file(), f"missing expected outputs for {scene_file.name}"
|
|
|
|
|
|
@pytest.mark.parametrize("scene_file", SCENE_FILES, ids=lambda p: p.stem)
|
|
def test_example_scene_compiles_to_documented_outputs(scene_file: Path, knowledge_base) -> None:
|
|
scene = json.loads(scene_file.read_text(encoding="utf-8"))
|
|
expected_file = scene_file.with_name(scene_file.name.replace(".scene.json", ".prompts.json"))
|
|
expected = json.loads(expected_file.read_text(encoding="utf-8"))
|
|
assert compile_prompt(scene, knowledge_base) == expected
|
|
|
|
|
|
def test_workflow_is_valid_json_referencing_registered_nodes() -> None:
|
|
import nodes
|
|
|
|
workflow = json.loads(WORKFLOW_FILE.read_text(encoding="utf-8"))
|
|
node_types = {node["type"] for node in workflow["nodes"]}
|
|
# Every node type in the example workflow is a registered Scene Compiler node.
|
|
assert node_types <= set(nodes.NODE_CLASS_MAPPINGS)
|
|
# The full pipeline is present.
|
|
for required in (
|
|
"SceneCompilerConfiguration",
|
|
"SceneCompilerKnowledgeBaseLoader",
|
|
"SceneCompilerAnalyzer",
|
|
"SceneCompilerValidator",
|
|
"SceneCompilerResolver",
|
|
):
|
|
assert required in node_types
|