Build AI methods with your coding agent, then run them anywhere: as an MCP for chatbots, as a webapp for people, or via API for your software.
Add concept_ref/pipe_ref aliases, fix concept_cmd alias bug, and reorganize spec tests
Louis Choquelf25fba3b6a51
diff --git a/pipelex/builder/operations/concept_ops.py b/pipelex/builder/operations/concept_ops.pyindex b66575e63..9be3ea6b5 100644--- a/pipelex/builder/operations/concept_ops.py+++ b/pipelex/builder/operations/concept_ops.py@@ -27,7 +27,7 @@ def parse_concept_spec(spec_data: dict[str, Any]) -> ConceptSpec:spec_data = dict(spec_data)# Accept common aliases for "concept_code"- for alias in ("the_concept_code", "code", "name", "concept_name"):+ for alias in ("the_concept_code", "code", "name", "concept_name", "concept_ref"):if alias in spec_data:if "concept_code" not in spec_data:spec_data["concept_code"] = spec_data.pop(alias)diff --git a/pipelex/builder/operations/pipe_ops.py b/pipelex/builder/operations/pipe_ops.pyindex df03ad0be..4be863635 100644--- a/pipelex/builder/operations/pipe_ops.py+++ b/pipelex/builder/operations/pipe_ops.py@@ -52,7 +52,7 @@ def parse_pipe_spec(pipe_type: str, spec_data: dict[str, Any]) -> PipeSpec:spec_data["type"] = pipe_type# Accept common aliases for "pipe_code"- for alias in ("the_pipe_code", "code", "name", "pipe_name"):+ for alias in ("the_pipe_code", "code", "name", "pipe_name", "pipe_ref"):if alias in spec_data:if "pipe_code" not in spec_data:spec_data["pipe_code"] = spec_data.pop(alias)diff --git a/pipelex/cli/agent_cli/commands/concept_cmd.py b/pipelex/cli/agent_cli/commands/concept_cmd.pyindex de0307716..613293e02 100644--- a/pipelex/cli/agent_cli/commands/concept_cmd.py+++ b/pipelex/cli/agent_cli/commands/concept_cmd.py@@ -103,7 +103,7 @@ def _parse_concept_spec_from_json(spec_data: dict[str, Any]) -> ConceptSpec:ValidationError: If validation fails."""# Accept common aliases for "concept_code"- for alias in ("concept_code", "code", "name", "concept_name"):+ for alias in ("the_concept_code", "code", "name", "concept_name"):if alias in spec_data:if "concept_code" not in spec_data:spec_data["concept_code"] = spec_data.pop(alias)diff --git a/tests/unit/pipelex/cli/test_concept_cmd.py b/tests/unit/pipelex/builder/operations/test_concept_spec_to_toml.pysimilarity index 50%rename from tests/unit/pipelex/cli/test_concept_cmd.pyrename to tests/unit/pipelex/builder/operations/test_concept_spec_to_toml.pyindex df2303177..6d29ef882 100644--- a/tests/unit/pipelex/cli/test_concept_cmd.py+++ b/tests/unit/pipelex/builder/operations/test_concept_spec_to_toml.py@@ -1,9 +1,9 @@-"""Unit tests for the agent CLI concept command."""+"""Unit tests for concept_spec_to_toml and structure_field_to_dict from concept_ops."""from __future__ import annotationsimport json-from typing import Any, ClassVar+from typing import Anyfrom pipelex.builder.concept.concept_spec import ConceptStructureSpec, ConceptStructureSpecFieldTypefrom pipelex.builder.operations.concept_ops import (@@ -13,10 +13,12 @@ from pipelex.builder.operations.concept_ops import ()-class TestStructureFieldToDict:- """Tests for structure_field_to_dict function."""+class TestConceptSpecToToml:+ """Tests for structure_field_to_dict and concept_spec_to_toml covering all field types and modes."""++ # -- structure_field_to_dict ------------------------------------------- def test_text_field_with_description_only(self) -> None:+ def test_text_field_description_only(self) -> None:"""Text field with only description should produce minimal dict."""field_spec = ConceptStructureSpec(the_field_name="name",@@ -24,12 +26,10 @@ class TestStructureFieldToDict:type=ConceptStructureSpecFieldType.TEXT,)result = structure_field_to_dict(field_spec)-assert result == {"description": "The person's name"}assert "type" not in resultdef test_text_field_with_required(self) -> None:- """Text field with required=True should include type."""field_spec = ConceptStructureSpec(the_field_name="name",description="The person's name",@@ -37,25 +37,20 @@ class TestStructureFieldToDict:required=True,)result = structure_field_to_dict(field_spec)-- assert result["description"] == "The person's name"assert result["type"] == ConceptStructureSpecFieldType.TEXTassert result["required"] is Truedef test_integer_field(self) -> None:- """Integer field should include type."""field_spec = ConceptStructureSpec(the_field_name="age",description="Age in years",type=ConceptStructureSpecFieldType.INTEGER,)result = structure_field_to_dict(field_spec)-assert result["type"] == ConceptStructureSpecFieldType.INTEGERassert result["description"] == "Age in years"def test_field_with_default_value(self) -> None:- """Field with default value should include default."""field_spec = ConceptStructureSpec(the_field_name="count",description="Number of items",@@ -63,12 +58,9 @@ class TestStructureFieldToDict:default_value=0,)result = structure_field_to_dict(field_spec)-assert result["default"] == 0- assert result["type"] == ConceptStructureSpecFieldType.INTEGERdef test_concept_field_with_concept_ref(self) -> None:- """Concept field should include concept_ref."""field_spec = ConceptStructureSpec(the_field_name="customer",description="The customer",@@ -76,15 +68,9 @@ class TestStructureFieldToDict:concept_ref="myapp.Customer",)result = structure_field_to_dict(field_spec)-assert result["concept_ref"] == "myapp.Customer"- assert result["type"] == ConceptStructureSpecFieldType.CONCEPTdef test_field_with_choices(self) -> None:- """Field with choices should include choices in output.-- This test would have caught the bug where choices were silently dropped.- """field_spec = ConceptStructureSpec(the_field_name="status",description="Current status",@@ -92,12 +78,9 @@ class TestStructureFieldToDict:choices=["pending", "in_progress", "complete"],)result = structure_field_to_dict(field_spec)-assert result["choices"] == ["pending", "in_progress", "complete"]- assert result["description"] == "Current status"def test_field_with_choices_and_required(self) -> None:- """Field with choices and required should include both."""field_spec = ConceptStructureSpec(the_field_name="priority",description="Task priority",@@ -106,13 +89,10 @@ class TestStructureFieldToDict:required=True,)result = structure_field_to_dict(field_spec)-assert result["choices"] == ["low", "medium", "high"]assert result["required"] is True- assert result["type"] == ConceptStructureSpecFieldType.TEXTdef test_field_with_choices_and_default(self) -> None:- """Field with choices and default value should include both."""field_spec = ConceptStructureSpec(the_field_name="status",description="Current status",@@ -121,173 +101,12 @@ class TestStructureFieldToDict:default_value="pending",)result = structure_field_to_dict(field_spec)-assert result["choices"] == ["active", "inactive", "pending"]assert result["default"] == "pending"+ # -- concept_spec_to_toml ----------------------------------------------class TestConceptCodeAliases:- """Tests for concept_code alias handling in parse_concept_spec."""-- _BASE: ClassVar[dict[str, Any]] = {- "description": "A test concept",- "refines": "Text",- }-- def test_canonical_concept_code(self) -> None:- spec = {**self._BASE, "concept_code": "Invoice"}- result = parse_concept_spec(spec)- assert result.concept_code == "Invoice"-- def test_alias_concept_code(self) -> None:- spec = {**self._BASE, "concept_code": "Invoice"}- result = parse_concept_spec(spec)- assert result.concept_code == "Invoice"-- def test_alias_code(self) -> None:- spec = {**self._BASE, "code": "Invoice"}- result = parse_concept_spec(spec)- assert result.concept_code == "Invoice"-- def test_alias_name(self) -> None:- spec = {**self._BASE, "name": "Invoice"}- result = parse_concept_spec(spec)- assert result.concept_code == "Invoice"-- def test_alias_concept_name(self) -> None:- spec = {**self._BASE, "concept_name": "Invoice"}- result = parse_concept_spec(spec)- assert result.concept_code == "Invoice"-- def test_canonical_ignores_alias(self) -> None:- """When concept_code is present, alias keys are removed so Pydantic doesn't reject them."""- spec = {**self._BASE, "concept_code": "Canonical", "name": "Alias"}- result = parse_concept_spec(spec)- assert result.concept_code == "Canonical"-- def test_multiple_aliases_all_cleaned_up(self) -> None:- """When concept_code and multiple aliases are present, all aliases are removed."""- spec = {**self._BASE, "concept_code": "Invoice", "name": "Alt", "code": "Alt2"}- result = parse_concept_spec(spec)- assert result.concept_code == "Invoice"---class TestStructureFieldStringShorthand:- """A bare string in structure should be treated as a text field with that description."""-- def test_string_field_becomes_text(self) -> None:- spec: dict[str, Any] = {- "concept_code": "Simple",- "description": "A simple concept",- "structure": {- "title": "The title of the item",- },- }- result = parse_concept_spec(spec)- assert result.structure is not None- assert result.structure["title"].type == ConceptStructureSpecFieldType.TEXT- assert result.structure["title"].description == "The title of the item"-- def test_mixed_string_and_dict_fields(self) -> None:- spec: dict[str, Any] = {- "concept_code": "Mixed",- "description": "A mixed concept",- "structure": {- "name": "The person's name",- "age": {"type": "integer", "description": "Age in years"},- },- }- result = parse_concept_spec(spec)- assert result.structure is not None- assert result.structure["name"].type == ConceptStructureSpecFieldType.TEXT- assert result.structure["age"].type == ConceptStructureSpecFieldType.INTEGER---class TestParseConceptSpecFromJson:- """Tests for parse_concept_spec function."""-- def test_parse_simple_concept_with_refines(self) -> None:- """Parse a simple concept that refines Text."""- spec_data: dict[str, Any] = {- "concept_code": "Invoice",- "description": "A commercial invoice",- "refines": "Text",- }- result = parse_concept_spec(spec_data)-- assert result.concept_code == "Invoice"- assert result.description == "A commercial invoice"- assert result.refines == "Text"-- def test_parse_structured_concept(self) -> None:- """Parse a concept with structure."""- spec_data: dict[str, Any] = {- "concept_code": "Person",- "description": "A person record",- "structure": {- "name": "The person's name",- "age": {"type": "integer", "description": "Age in years"},- },- }- result = parse_concept_spec(spec_data)-- assert result.concept_code == "Person"- assert result.structure is not None- assert "name" in result.structure- assert "age" in result.structure- assert result.structure["name"].type == ConceptStructureSpecFieldType.TEXT- assert result.structure["age"].type == ConceptStructureSpecFieldType.INTEGER-- def test_parse_concept_with_choices_in_structure(self) -> None:- """Parse a concept with choices field in structure.-- This test would have caught the bug where choices were silently ignored- during JSON parsing (if Pydantic had extra='ignore').- """- spec_data: dict[str, Any] = {- "concept_code": "Task",- "description": "A task with status",- "structure": {- "status": {- "type": "text",- "description": "Current status",- "choices": ["pending", "in_progress", "complete"],- }- },- }- result = parse_concept_spec(spec_data)-- assert result.structure is not None- assert result.structure["status"].choices == ["pending", "in_progress", "complete"]---class TestConceptSpecToToml:- """Tests for concept_spec_to_toml function."""-- def test_toml_output_includes_choices(self) -> None:- """TOML output should include choices when present.-- This is the main regression test for the bug where choices- were not included in the TOML output.- """- spec_data: dict[str, Any] = {- "concept_code": "TaskStatus",- "description": "A task with status tracking",- "structure": {- "status": {- "type": "text",- "description": "Current status",- "choices": ["pending", "in_progress", "complete"],- }- },- }- concept_spec = parse_concept_spec(spec_data)- toml_output = concept_spec_to_toml(concept_spec)-- assert 'choices = ["pending", "in_progress", "complete"]' in toml_output-- def test_toml_output_simple_refines_concept(self) -> None:- """TOML output for a simple refines concept."""+ def test_simple_refines_concept(self) -> None:spec_data: dict[str, Any] = {"concept_code": "Invoice","description": "A commercial invoice",@@ -295,13 +114,11 @@ class TestConceptSpecToToml:}concept_spec = parse_concept_spec(spec_data)toml_output = concept_spec_to_toml(concept_spec)-assert "[concept.Invoice]" in toml_outputassert 'description = "A commercial invoice"' in toml_outputassert 'refines = "Text"' in toml_output- def test_toml_output_structured_concept_with_multiple_fields(self) -> None:- """TOML output for a structured concept with multiple field types."""+ def test_structured_concept_with_multiple_fields(self) -> None:spec_data: dict[str, Any] = {"concept_code": "Order","description": "A customer order",@@ -317,31 +134,30 @@ class TestConceptSpecToToml:}concept_spec = parse_concept_spec(spec_data)toml_output = concept_spec_to_toml(concept_spec)-assert "[concept.Order]" in toml_outputassert "order_id" in toml_outputassert "required = true" in toml_outputassert "quantity" in toml_output- assert "status" in toml_outputassert "choices" in toml_output--class TestConceptStructureSpecChoices:- """Tests specifically for the choices field on ConceptStructureSpec."""-- def test_choices_field_exists_on_model(self) -> None:- """Verify that choices field exists on ConceptStructureSpec."""- field_spec = ConceptStructureSpec(- the_field_name="status",- description="Current status",- type=ConceptStructureSpecFieldType.TEXT,- choices=["a", "b", "c"],- )- assert hasattr(field_spec, "choices")- assert field_spec.choices == ["a", "b", "c"]+ def test_toml_includes_choices(self) -> None:+ """Regression: choices must appear in TOML output."""+ spec_data: dict[str, Any] = {+ "concept_code": "TaskStatus",+ "description": "A task with status tracking",+ "structure": {+ "status": {+ "type": "text",+ "description": "Current status",+ "choices": ["pending", "in_progress", "complete"],+ }+ },+ }+ concept_spec = parse_concept_spec(spec_data)+ toml_output = concept_spec_to_toml(concept_spec)+ assert 'choices = ["pending", "in_progress", "complete"]' in toml_outputdef test_choices_none_by_default(self) -> None:- """Choices should be None by default."""field_spec = ConceptStructureSpec(the_field_name="name",description="A name",@@ -350,7 +166,6 @@ class TestConceptStructureSpecChoices:assert field_spec.choices is Nonedef test_choices_passed_to_blueprint(self) -> None:- """Choices should be passed through to the blueprint."""field_spec = ConceptStructureSpec(the_field_name="status",description="Current status",@@ -358,7 +173,6 @@ class TestConceptStructureSpecChoices:choices=["pending", "complete"],)blueprint = field_spec.to_blueprint()-assert blueprint.choices == ["pending", "complete"]def test_roundtrip_json_to_toml_preserves_choices(self) -> None:@@ -380,6 +194,36 @@ class TestConceptStructureSpecChoices:spec_data = json.loads(input_json)concept_spec = parse_concept_spec(spec_data)toml_output = concept_spec_to_toml(concept_spec)-assert 'choices = ["low", "medium", "high", "critical"]' in toml_outputassert "required = true" in toml_output++ def test_description_only_field_uses_string_format(self) -> None:+ """A field with only a description should serialize as a simple string in TOML."""+ spec_data: dict[str, Any] = {+ "concept_code": "Simple",+ "description": "A concept with simple fields",+ "structure": {"title": "The title"},+ }+ concept_spec = parse_concept_spec(spec_data)+ toml_output = concept_spec_to_toml(concept_spec)+ assert 'title = "The title"' in toml_output++ def test_no_structure_omits_structure_section(self) -> None:+ spec_data: dict[str, Any] = {+ "concept_code": "Plain",+ "description": "A plain concept",+ "refines": "Text",+ }+ concept_spec = parse_concept_spec(spec_data)+ toml_output = concept_spec_to_toml(concept_spec)+ assert "structure" not in toml_output++ def test_no_refines_omits_refines(self) -> None:+ spec_data: dict[str, Any] = {+ "concept_code": "Standalone",+ "description": "A standalone concept",+ "structure": {"name": "The name"},+ }+ concept_spec = parse_concept_spec(spec_data)+ toml_output = concept_spec_to_toml(concept_spec)+ assert "refines" not in toml_outputdiff --git a/tests/unit/pipelex/builder/operations/test_data.py b/tests/unit/pipelex/builder/operations/test_data.pynew file mode 100644index 000000000..1d19bbb01--- /dev/null+++ b/tests/unit/pipelex/builder/operations/test_data.py@@ -0,0 +1,14 @@+"""Shared test data for pipelex.builder.operations tests."""++from typing import Any, ClassVar+++class PipeOpsTestData:+ BASE_LLM_SPEC: ClassVar[dict[str, Any]] = {+ "pipe_code": "test_pipe",+ "description": "Test LLM pipe",+ "model": "$writing-creative",+ "inputs": {"text": "Text"},+ "output": "Text",+ "prompt": "Write about @text",+ }diff --git a/tests/unit/pipelex/builder/operations/test_parse_concept_spec.py b/tests/unit/pipelex/builder/operations/test_parse_concept_spec.pynew file mode 100644index 000000000..95970259f--- /dev/null+++ b/tests/unit/pipelex/builder/operations/test_parse_concept_spec.py@@ -0,0 +1,123 @@+"""Unit tests for parse_concept_spec from pipelex.builder.operations.concept_ops."""++from __future__ import annotations++from typing import Any, ClassVar++import pytest++from pipelex.builder.concept.concept_spec import ConceptStructureSpecFieldType+from pipelex.builder.operations.concept_ops import parse_concept_spec+++class TestParseConceptSpec:+ """Comprehensive tests for parse_concept_spec: validation, aliases, structure conversion."""++ _BASE: ClassVar[dict[str, Any]] = {+ "description": "A test concept",+ "refines": "Text",+ }++ # -- concept_code aliases ---------------------------------------------++ def test_canonical_concept_code(self) -> None:+ spec = {**self._BASE, "concept_code": "Invoice"}+ result = parse_concept_spec(spec)+ assert result.concept_code == "Invoice"++ @pytest.mark.parametrize("alias", ["the_concept_code", "code", "name", "concept_name", "concept_ref"])+ def test_concept_code_alias_accepted(self, alias: str) -> None:+ spec = {**self._BASE, alias: "Invoice"}+ result = parse_concept_spec(spec)+ assert result.concept_code == "Invoice"++ def test_canonical_ignores_alias(self) -> None:+ """When concept_code is present, alias keys are removed."""+ spec = {**self._BASE, "concept_code": "Canonical", "name": "Alias"}+ result = parse_concept_spec(spec)+ assert result.concept_code == "Canonical"++ def test_multiple_aliases_all_cleaned_up(self) -> None:+ spec = {**self._BASE, "concept_code": "Invoice", "name": "Alt", "code": "Alt2"}+ result = parse_concept_spec(spec)+ assert result.concept_code == "Invoice"++ # -- does not mutate caller's dict ------------------------------------++ def test_original_dict_unchanged(self) -> None:+ original: dict[str, Any] = {**self._BASE, "code": "Invoice"}+ snapshot = dict(original)+ parse_concept_spec(original)+ assert original == snapshot++ # -- structure field conversion ---------------------------------------++ def test_string_field_becomes_text(self) -> None:+ """A bare string in structure should be treated as a text field."""+ spec: dict[str, Any] = {+ "concept_code": "Simple",+ "description": "A simple concept",+ "structure": {"title": "The title of the item"},+ }+ result = parse_concept_spec(spec)+ assert result.structure is not None+ assert result.structure["title"].type == ConceptStructureSpecFieldType.TEXT+ assert result.structure["title"].description == "The title of the item"++ def test_mixed_string_and_dict_fields(self) -> None:+ spec: dict[str, Any] = {+ "concept_code": "Mixed",+ "description": "A mixed concept",+ "structure": {+ "name": "The person's name",+ "age": {"type": "integer", "description": "Age in years"},+ },+ }+ result = parse_concept_spec(spec)+ assert result.structure is not None+ assert result.structure["name"].type == ConceptStructureSpecFieldType.TEXT+ assert result.structure["age"].type == ConceptStructureSpecFieldType.INTEGER++ # -- full parsing scenarios -------------------------------------------++ def test_simple_concept_with_refines(self) -> None:+ spec_data: dict[str, Any] = {+ "concept_code": "Invoice",+ "description": "A commercial invoice",+ "refines": "Text",+ }+ result = parse_concept_spec(spec_data)+ assert result.concept_code == "Invoice"+ assert result.description == "A commercial invoice"+ assert result.refines == "Text"++ def test_structured_concept(self) -> None:+ spec_data: dict[str, Any] = {+ "concept_code": "Person",+ "description": "A person record",+ "structure": {+ "name": "The person's name",+ "age": {"type": "integer", "description": "Age in years"},+ },+ }+ result = parse_concept_spec(spec_data)+ assert result.concept_code == "Person"+ assert result.structure is not None+ assert "name" in result.structure+ assert "age" in result.structure++ def test_concept_with_choices_in_structure(self) -> None:+ spec_data: dict[str, Any] = {+ "concept_code": "Task",+ "description": "A task with status",+ "structure": {+ "status": {+ "type": "text",+ "description": "Current status",+ "choices": ["pending", "in_progress", "complete"],+ }+ },+ }+ result = parse_concept_spec(spec_data)+ assert result.structure is not None+ assert result.structure["status"].choices == ["pending", "in_progress", "complete"]diff --git a/tests/unit/pipelex/builder/operations/test_parse_pipe_spec.py b/tests/unit/pipelex/builder/operations/test_parse_pipe_spec.pyindex 8a1b51153..716aa170d 100644--- a/tests/unit/pipelex/builder/operations/test_parse_pipe_spec.py+++ b/tests/unit/pipelex/builder/operations/test_parse_pipe_spec.py@@ -17,17 +17,9 @@ from pipelex.builder.pipe.pipe_llm_spec import PipeLLMSpecfrom pipelex.builder.pipe.pipe_parallel_spec import PipeParallelSpecfrom pipelex.builder.pipe.pipe_search_spec import PipeSearchSpecfrom pipelex.builder.pipe.pipe_sequence_spec import PipeSequenceSpec+from tests.unit.pipelex.builder.operations.test_data import PipeOpsTestData--class _BaseLLM:- SPEC: ClassVar[dict[str, Any]] = {- "pipe_code": "test_pipe",- "description": "Test LLM pipe",- "model": "$writing-creative",- "inputs": {"text": "Text"},- "output": "Text",- "prompt": "Write about @text",- }+_BASE_LLM = PipeOpsTestData.BASE_LLM_SPECclass TestParsePipeSpec:@@ -46,33 +38,25 @@ class TestParsePipeSpec:# -- pipe_code aliases ------------------------------------------------def test_canonical_pipe_code(self) -> None:- result = parse_pipe_spec("PipeLLM", {**_BaseLLM.SPEC})+ result = parse_pipe_spec("PipeLLM", {**_BASE_LLM})assert result.pipe_code == "test_pipe"- @pytest.mark.parametrize(- ("alias", "value"),- [- ("the_pipe_code", "via_the_pipe_code"),- ("code", "via_code"),- ("name", "via_name"),- ("pipe_name", "via_pipe_name"),- ],- )- def test_pipe_code_alias_accepted(self, alias: str, value: str) -> None:- spec = {key: val for key, val in _BaseLLM.SPEC.items() if key != "pipe_code"}- spec[alias] = value+ @pytest.mark.parametrize("alias", ["the_pipe_code", "code", "name", "pipe_name", "pipe_ref"])+ def test_pipe_code_alias_accepted(self, alias: str) -> None:+ spec = {key: val for key, val in _BASE_LLM.items() if key != "pipe_code"}+ spec[alias] = "via_alias"result = parse_pipe_spec("PipeLLM", spec)- assert result.pipe_code == value+ assert result.pipe_code == "via_alias"def test_canonical_pipe_code_takes_precedence_over_alias(self) -> None:"""When pipe_code is present, aliases are ignored and cleaned up."""- spec = {**_BaseLLM.SPEC, "code": "alias_value", "name": "another_alias"}+ spec = {**_BASE_LLM, "code": "alias_value", "name": "another_alias"}result = parse_pipe_spec("PipeLLM", spec)assert result.pipe_code == "test_pipe"def test_first_alias_wins_when_no_canonical(self) -> None:"""When multiple aliases are present without pipe_code, iteration order wins (the_pipe_code first)."""- spec = {key: val for key, val in _BaseLLM.SPEC.items() if key != "pipe_code"}+ spec = {key: val for key, val in _BASE_LLM.items() if key != "pipe_code"}spec["code"] = "second"spec["the_pipe_code"] = "first"spec["name"] = "third"@@ -82,26 +66,26 @@ class TestParsePipeSpec:# -- output dict tolerance --------------------------------------------def test_output_as_string(self) -> None:- result = parse_pipe_spec("PipeLLM", {**_BaseLLM.SPEC, "output": "Article"})+ result = parse_pipe_spec("PipeLLM", {**_BASE_LLM, "output": "Article"})assert result.output == "Article"def test_output_dict_with_type_key(self) -> None:- result = parse_pipe_spec("PipeLLM", {**_BaseLLM.SPEC, "output": {"type": "Article"}})+ result = parse_pipe_spec("PipeLLM", {**_BASE_LLM, "output": {"type": "Article"}})assert result.output == "Article"def test_output_single_item_dict(self) -> None:"""A single-item dict is unambiguous — extract the value."""- result = parse_pipe_spec("PipeLLM", {**_BaseLLM.SPEC, "output": {"result": "Article"}})+ result = parse_pipe_spec("PipeLLM", {**_BASE_LLM, "output": {"result": "Article"}})assert result.output == "Article"def test_output_multi_item_dict_raises(self) -> None:"""A multi-item dict is ambiguous — validation fails."""with pytest.raises(ValidationError):- parse_pipe_spec("PipeLLM", {**_BaseLLM.SPEC, "output": {"a": "Text", "b": "Image"}})+ parse_pipe_spec("PipeLLM", {**_BASE_LLM, "output": {"a": "Text", "b": "Image"}})def test_output_type_key_takes_precedence_in_dict(self) -> None:"""When 'type' key is present in output dict, it wins even if other keys exist."""- result = parse_pipe_spec("PipeLLM", {**_BaseLLM.SPEC, "output": {"type": "Article", "extra": "ignored"}})+ result = parse_pipe_spec("PipeLLM", {**_BASE_LLM, "output": {"type": "Article", "extra": "ignored"}})assert result.output == "Article"# -- steps/branches 'pipe' → 'pipe_code' alias -----------------------@@ -215,7 +199,7 @@ class TestParsePipeSpec:[("PipeLLM",- {**_BaseLLM.SPEC},+ {**_BASE_LLM},PipeLLMSpec,),(diff --git a/tests/unit/pipelex/builder/operations/test_pipe_spec_to_toml.py b/tests/unit/pipelex/builder/operations/test_pipe_spec_to_toml.pyindex a23d656b6..a934fcc4c 100644--- a/tests/unit/pipelex/builder/operations/test_pipe_spec_to_toml.py+++ b/tests/unit/pipelex/builder/operations/test_pipe_spec_to_toml.py@@ -2,20 +2,10 @@from __future__ import annotations-from typing import Any, ClassVar-from pipelex.builder.operations.pipe_ops import parse_pipe_spec, pipe_spec_to_toml+from tests.unit.pipelex.builder.operations.test_data import PipeOpsTestData--class _BaseLLM:- SPEC: ClassVar[dict[str, Any]] = {- "pipe_code": "test_pipe",- "description": "Test LLM pipe",- "model": "$writing-creative",- "inputs": {"text": "Text"},- "output": "Text",- "prompt": "Write about @text",- }+_BASE_LLM = PipeOpsTestData.BASE_LLM_SPECclass TestPipeSpecToToml:@@ -24,7 +14,7 @@ class TestPipeSpecToToml:# -- PipeLLM ----------------------------------------------------------def test_llm_basic_structure(self) -> None:- spec = parse_pipe_spec("PipeLLM", {**_BaseLLM.SPEC})+ spec = parse_pipe_spec("PipeLLM", {**_BASE_LLM})toml = pipe_spec_to_toml(spec)assert "[pipe.test_pipe]" in tomlassert 'type = "PipeLLM"' in toml@@ -32,42 +22,42 @@ class TestPipeSpecToToml:assert 'output = "Text"' in tomldef test_llm_inputs_as_inline_table(self) -> None:- spec = parse_pipe_spec("PipeLLM", {**_BaseLLM.SPEC})+ spec = parse_pipe_spec("PipeLLM", {**_BASE_LLM})toml = pipe_spec_to_toml(spec)assert 'inputs = {text = "Text"}' in tomldef test_llm_model_in_toml(self) -> None:- spec = parse_pipe_spec("PipeLLM", {**_BaseLLM.SPEC})+ spec = parse_pipe_spec("PipeLLM", {**_BASE_LLM})toml = pipe_spec_to_toml(spec)assert 'model = "$writing-creative"' in tomldef test_llm_no_model_omits_field(self) -> None:- data = {key: val for key, val in _BaseLLM.SPEC.items() if key != "model"}+ data = {key: val for key, val in _BASE_LLM.items() if key != "model"}spec = parse_pipe_spec("PipeLLM", data)toml = pipe_spec_to_toml(spec)assert "model" not in tomldef test_llm_system_prompt_in_toml(self) -> None:- spec = parse_pipe_spec("PipeLLM", {**_BaseLLM.SPEC, "system_prompt": "You are a helpful writer."})+ spec = parse_pipe_spec("PipeLLM", {**_BASE_LLM, "system_prompt": "You are a helpful writer."})toml = pipe_spec_to_toml(spec)assert "system_prompt" in tomlassert "You are a helpful writer." in tomldef test_llm_prompt_in_toml(self) -> None:- spec = parse_pipe_spec("PipeLLM", {**_BaseLLM.SPEC})+ spec = parse_pipe_spec("PipeLLM", {**_BASE_LLM})toml = pipe_spec_to_toml(spec)assert "prompt" in tomlassert "Write about @text" in tomldef test_llm_no_inputs_omits_inputs(self) -> None:empty_inputs: dict[str, str] = {}- data = {**_BaseLLM.SPEC, "inputs": empty_inputs}+ data = {**_BASE_LLM, "inputs": empty_inputs}spec = parse_pipe_spec("PipeLLM", data)toml = pipe_spec_to_toml(spec)assert "inputs" not in tomldef test_llm_multiple_inputs(self) -> None:- data = {**_BaseLLM.SPEC, "inputs": {"text": "Text", "context": "Document"}}+ data = {**_BASE_LLM, "inputs": {"text": "Text", "context": "Document"}}spec = parse_pipe_spec("PipeLLM", data)toml = pipe_spec_to_toml(spec)assert 'text = "Text"' in toml