Skip to content

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.

Refactor concept code references to use 'concept_code' instead of 'the_concept_code'

Louis Choquelbd4163300772
diff --git a/docs/under-the-hood/dry-run-mock-generation.md b/docs/under-the-hood/dry-run-mock-generation.md
index 06e45babb..d82a15691 100644
--- a/docs/under-the-hood/dry-run-mock-generation.md
+++ b/docs/under-the-hood/dry-run-mock-generation.md
@@ -19,7 +19,7 @@ class BundleHeaderSpec(StructuredContent):
main_pipe: str # Must be snake_case, must exist in pipe dict
class ConceptSpec(StructuredContent):
- the_concept_code: str # Must be PascalCase
+ concept_code: str # Must be PascalCase
```
Standard mock generators (like Polyfactory) produce random strings like `"uygNjiAuDMOtZEyibgHw"` which fail validation. The dry run system addresses this at two levels:
@@ -109,7 +109,7 @@ class DryRunFactory:
| Format | Generator | Example Output | Used For |
|--------|-----------|----------------|----------|
| `SNAKE_CASE` | `generate_snake_case_code()` | `mock_abcd` | `domain_code`, `pipe_code`, `the_field_name` |
-| `PASCAL_CASE` | `generate_pascal_case_code()` | `MockAbcd` | `the_concept_code` |
+| `PASCAL_CASE` | `generate_pascal_case_code()` | `MockAbcd` | `concept_code` |
| `CONCEPT_REF` | `generate_concept_ref()` | `mock_abcd.MockCdef` | `concept_ref` field (domain.ConceptCode format) |
| `IGNORE` | Sets field to `Ignore()` | None/default | `default_value`, `structure` fields |
| `DICT_SNAKE_KEY_PASCAL_VALUE` | `generate_dict_snake_key_pascal_value()` | `{mock_abcd: MockCdef}` | `inputs` dict in PipeSpec |
diff --git a/pipelex/builder/concept/concept_spec.py b/pipelex/builder/concept/concept_spec.py
index 1cd02f277..3ae765054 100644
--- a/pipelex/builder/concept/concept_spec.py
+++ b/pipelex/builder/concept/concept_spec.py
@@ -238,7 +238,7 @@ class ConceptSpec(StructuredContent):
model_config = ConfigDict(extra="forbid")
- the_concept_code: str = Field(description="Name of the concept. Must be PascalCase.", json_schema_extra={"mock_format": MockFormat.PASCAL_CASE})
+ concept_code: str = Field(description="Name of the concept. Must be PascalCase.", json_schema_extra={"mock_format": MockFormat.PASCAL_CASE})
description: str = Field(description="Description of the concept, in natural language.")
structure: dict[str, ConceptStructureSpec] | None = Field(
default=None,
@@ -257,7 +257,7 @@ class ConceptSpec(StructuredContent):
examples=["Text", "Html", "Image", "Document", "Number", "Page", "TextAndImages", "ImgGenPrompt", "JSON"],
)
- @field_validator("the_concept_code", mode="before")
+ @field_validator("concept_code", mode="before")
@classmethod
def validate_concept_code(cls, value: str) -> str:
# Split first to handle domain.ConceptCode format
@@ -358,7 +358,7 @@ class ConceptSpec(StructuredContent):
concept_group = Group()
if title:
concept_group.renderables.append(Text(title, style="bold"))
- concept_group.renderables.append(Text.from_markup(f"Concept: [green]{self.the_concept_code}[/green]", style="bold"))
+ concept_group.renderables.append(Text.from_markup(f"Concept: [green]{self.concept_code}[/green]", style="bold"))
if self.refines:
concept_group.renderables.append(Text.from_markup(f"Refines: [green]{self.refines}[/green]"))
concept_group.renderables.append(Text.from_markup(f"\nDescription: [yellow italic]{self.description}[/yellow italic]\n"))
diff --git a/pipelex/builder/operations/concept_ops.py b/pipelex/builder/operations/concept_ops.py
index a668caef2..b66575e63 100644
--- a/pipelex/builder/operations/concept_ops.py
+++ b/pipelex/builder/operations/concept_ops.py
@@ -12,7 +12,7 @@ from pipelex.builder.concept.concept_spec import ConceptSpec, ConceptStructureSp
def parse_concept_spec(spec_data: dict[str, Any]) -> ConceptSpec:
"""Parse and validate a ConceptSpec from JSON-like data.
- Accepts common aliases for "the_concept_code" and converts structure fields.
+ Accepts common aliases for "concept_code" and converts structure fields.
Args:
spec_data: Raw data for the concept spec.
@@ -26,11 +26,11 @@ def parse_concept_spec(spec_data: dict[str, Any]) -> ConceptSpec:
# Work on a copy to avoid mutating the caller's dict
spec_data = dict(spec_data)
- # Accept common aliases for "the_concept_code"
- for alias in ("concept_code", "code", "name", "concept_name"):
+ # Accept common aliases for "concept_code"
+ for alias in ("the_concept_code", "code", "name", "concept_name"):
if alias in spec_data:
- if "the_concept_code" not in spec_data:
- spec_data["the_concept_code"] = spec_data.pop(alias)
+ if "concept_code" not in spec_data:
+ spec_data["concept_code"] = spec_data.pop(alias)
else:
spec_data.pop(alias)
@@ -126,6 +126,6 @@ def concept_spec_to_toml(concept_spec: ConceptSpec) -> str:
concept_item_table.add("structure", structure_table)
# Build the nested structure: [concept.ConceptName]
- concept_section.add(concept_spec.the_concept_code, concept_item_table)
+ concept_section.add(concept_spec.concept_code, concept_item_table)
doc.add("concept", concept_section)
return tomlkit.dumps(doc)
diff --git a/pipelex/builder/operations/pipe_ops.py b/pipelex/builder/operations/pipe_ops.py
index 56fc476b1..efdc614b9 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 ("code", "the_pipe_code", "name"):
+ for alias in ("the_pipe_code", "code", "name", "pipe_name"):
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.py
index dd64700e0..de0307716 100644
--- a/pipelex/cli/agent_cli/commands/concept_cmd.py
+++ b/pipelex/cli/agent_cli/commands/concept_cmd.py
@@ -53,7 +53,7 @@ def _concept_spec_to_toml(concept_spec: ConceptSpec) -> str:
concept_item_table.add("structure", structure_table)
# Build the nested structure: [concept.ConceptName]
- concept_section.add(concept_spec.the_concept_code, concept_item_table)
+ concept_section.add(concept_spec.concept_code, concept_item_table)
doc.add("concept", concept_section)
return tomlkit.dumps(doc)
@@ -102,11 +102,11 @@ def _parse_concept_spec_from_json(spec_data: dict[str, Any]) -> ConceptSpec:
Raises:
ValidationError: If validation fails.
"""
- # Accept common aliases for "the_concept_code"
+ # Accept common aliases for "concept_code"
for alias in ("concept_code", "code", "name", "concept_name"):
if alias in spec_data:
- if "the_concept_code" not in spec_data:
- spec_data["the_concept_code"] = spec_data.pop(alias)
+ if "concept_code" not in spec_data:
+ spec_data["concept_code"] = spec_data.pop(alias)
else:
spec_data.pop(alias)
@@ -150,7 +150,7 @@ def concept_cmd(
JSON spec format:
{
- "the_concept_code": "MyConceptName",
+ "concept_code": "MyConceptName",
"description": "Description of the concept",
"refines": "Text", // Optional: native concept to refine
"structure": { // Optional: for structured concepts
@@ -164,7 +164,7 @@ def concept_cmd(
}
Examples:
- pipelex-agent concept --spec '{"the_concept_code": "Invoice", "description": "A commercial invoice", "refines": "Text"}'
+ pipelex-agent concept --spec '{"concept_code": "Invoice", "description": "A commercial invoice", "refines": "Text"}'
pipelex-agent concept --spec-file concept.json
"""
# Validate that exactly one of spec or spec_file is provided
diff --git a/pipelex/core/memory/working_memory_factory.py b/pipelex/core/memory/working_memory_factory.py
index 89859f590..04a1f24fa 100644
--- a/pipelex/core/memory/working_memory_factory.py
+++ b/pipelex/core/memory/working_memory_factory.py
@@ -19,7 +19,7 @@ from pipelex.core.stuffs.text_content import TextContent
SNAKE_CASE_FIELD_NAMES = {"domain", "domain_code", "pipe_code"}
# Field names that require PascalCase format for pipelex concept specs
-PASCAL_CASE_FIELD_NAMES = {"the_concept_code"}
+PASCAL_CASE_FIELD_NAMES = {"concept_code"}
class WorkingMemoryFactory(BaseModel):
diff --git a/tests/integration/pipelex/builder/concept/integration_test_data.py b/tests/integration/pipelex/builder/concept/integration_test_data.py
index 7bc8ee8f8..dc9b7c9b5 100644
--- a/tests/integration/pipelex/builder/concept/integration_test_data.py
+++ b/tests/integration/pipelex/builder/concept/integration_test_data.py
@@ -9,7 +9,7 @@ class ConceptSpecGenerationTestCases:
Generate a concept specification for a "BlogPost" concept.
Requirements:
-- the_concept_code: BlogPost
+- concept_code: BlogPost
- description: A blog post with title, content, and publication date
- structure: None (leave empty)
- refines: None (leave empty)
@@ -20,7 +20,7 @@ Requirements:
Generate a concept specification for a "ProductDescription" concept.
Requirements:
-- the_concept_code: ProductDescription
+- concept_code: ProductDescription
- description: A detailed description of a product for e-commerce
- refines: Text (this concept refines the native Text concept)
- structure: None (leave empty because we're using refines)
@@ -31,7 +31,7 @@ Requirements:
Generate a concept specification for a "Person" concept with a simple structure.
Requirements:
-- the_concept_code: Person
+- concept_code: Person
- description: A person with basic information
- structure: A dictionary with these fields:
- name: (type: text, description: "The person's full name", required: true)
@@ -44,7 +44,7 @@ Requirements:
Generate a concept specification for a "Product" concept with a detailed structure.
Requirements:
-- the_concept_code: Product
+- concept_code: Product
- description: A product in an e-commerce system
- structure: A dictionary with these fields:
- name: (type: text, description: "Product name", required: true)
@@ -60,7 +60,7 @@ Requirements:
Generate a concept specification for a "UserProfile" concept.
Requirements:
-- the_concept_code: UserProfile
+- concept_code: UserProfile
- description: A user profile with optional settings
- structure: A dictionary with these fields:
- username: (type: text, description: "User's username", required: true)
@@ -76,7 +76,7 @@ Requirements:
Generate a concept specification for a "customer_order" concept.
Requirements:
-- the_concept_code: customer_order
+- concept_code: customer_order
- description: An order placed by a customer
- structure: A dictionary with these fields:
- order_number: (type: text, description: "Unique order identifier", required: true)
@@ -90,7 +90,7 @@ Requirements:
Generate a concept specification for a "ProductPhoto" concept.
Requirements:
-- the_concept_code: ProductPhoto
+- concept_code: ProductPhoto
- description: A photograph of a product for display in catalog
- refines: Image (this concept refines the native Image concept)
- structure: None (leave empty because we're using refines)
@@ -101,7 +101,7 @@ Requirements:
Generate a concept specification for an "Event" concept with a date field.
Requirements:
-- the_concept_code: Event
+- concept_code: Event
- description: An event with scheduling information
- structure: A dictionary with these fields:
- title: (type: text, description: "Event title", required: true)
diff --git a/tests/integration/pipelex/builder/concept/test_concept_spec_generation.py b/tests/integration/pipelex/builder/concept/test_concept_spec_generation.py
index dd5ea169c..838871310 100644
--- a/tests/integration/pipelex/builder/concept/test_concept_spec_generation.py
+++ b/tests/integration/pipelex/builder/concept/test_concept_spec_generation.py
@@ -64,7 +64,7 @@ class TestConceptSpecGeneration:
# The Pydantic validation and field validators have already run
assert generated_concept_spec is not None
assert isinstance(generated_concept_spec, ConceptSpec)
- assert generated_concept_spec.the_concept_code
+ assert generated_concept_spec.concept_code
assert generated_concept_spec.description
- log.info(f"✓ Successfully generated ConceptSpec for '{topic}': {generated_concept_spec.the_concept_code}")
+ log.info(f"✓ Successfully generated ConceptSpec for '{topic}': {generated_concept_spec.concept_code}")
diff --git a/tests/unit/pipelex/builder/concept/test_concept_blueprint.py b/tests/unit/pipelex/builder/concept/test_concept_blueprint.py
index 4f3323bbd..2da86e01e 100644
--- a/tests/unit/pipelex/builder/concept/test_concept_blueprint.py
+++ b/tests/unit/pipelex/builder/concept/test_concept_blueprint.py
@@ -29,13 +29,11 @@ class TestConceptCodeValidation:
# Create a ConceptSpec with the input code
concept_spec = ConceptSpec(
- the_concept_code=input_code,
+ concept_code=input_code,
description="Test concept for code validation",
refines=None,
structure=None,
)
# Verify the concept code was converted correctly
- assert concept_spec.the_concept_code == expected_code, (
- f"Expected concept code to be '{expected_code}', but got '{concept_spec.the_concept_code}'"
- )
+ assert concept_spec.concept_code == expected_code, f"Expected concept code to be '{expected_code}', but got '{concept_spec.concept_code}'"
diff --git a/tests/unit/pipelex/builder/concept/test_data.py b/tests/unit/pipelex/builder/concept/test_data.py
index 4bef1bb8d..9aaf981d3 100644
--- a/tests/unit/pipelex/builder/concept/test_data.py
+++ b/tests/unit/pipelex/builder/concept/test_data.py
@@ -9,7 +9,7 @@ class ConceptBlueprintTestCases:
SIMPLE_CONCEPT = (
"simple_concept",
ConceptSpec(
- the_concept_code="ConceptCode",
+ concept_code="ConceptCode",
description="A simple test concept",
refines=None,
structure=None,
@@ -24,7 +24,7 @@ class ConceptBlueprintTestCases:
CONCEPT_WITH_REFINES = (
"concept_with_refines",
ConceptSpec(
- the_concept_code="ConceptCode",
+ concept_code="ConceptCode",
description="An enhanced text concept",
refines="Text",
structure=None,
@@ -39,7 +39,7 @@ class ConceptBlueprintTestCases:
CONCEPT_WITH_TEXT_FIELD = (
"concept_with_text_field",
ConceptSpec(
- the_concept_code="ConceptCode",
+ concept_code="ConceptCode",
description="Entity with text field",
structure={
"name": ConceptStructureSpec(
@@ -67,7 +67,7 @@ class ConceptBlueprintTestCases:
CONCEPT_WITH_INTEGER_FIELD = (
"concept_with_integer_field",
ConceptSpec(
- the_concept_code="ConceptCode",
+ concept_code="ConceptCode",
description="Entity with integer field",
structure={
"age": ConceptStructureSpec(
@@ -96,7 +96,7 @@ class ConceptBlueprintTestCases:
CONCEPT_WITH_MULTIPLE_FIELDS = (
"concept_with_multiple_fields",
ConceptSpec(
- the_concept_code="ConceptCode",
+ concept_code="ConceptCode",
description="Entity with multiple fields",
structure={
"name": ConceptStructureSpec(
@@ -150,7 +150,7 @@ class ConceptBlueprintTestCases:
CONCEPT_WITH_CONCEPT_REF = (
"concept_with_concept_ref",
ConceptSpec(
- the_concept_code="Invoice",
+ concept_code="Invoice",
description="An invoice with a customer reference",
structure={
"invoice_number": ConceptStructureSpec(
diff --git a/tests/unit/pipelex/cli/test_concept_cmd.py b/tests/unit/pipelex/cli/test_concept_cmd.py
index 8a3645313..df2303177 100644
--- a/tests/unit/pipelex/cli/test_concept_cmd.py
+++ b/tests/unit/pipelex/cli/test_concept_cmd.py
@@ -134,42 +134,42 @@ class TestConceptCodeAliases:
"refines": "Text",
}
- def test_canonical_the_concept_code(self) -> None:
- spec = {**self._BASE, "the_concept_code": "Invoice"}
+ def test_canonical_concept_code(self) -> None:
+ spec = {**self._BASE, "concept_code": "Invoice"}
result = parse_concept_spec(spec)
- assert result.the_concept_code == "Invoice"
+ 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.the_concept_code == "Invoice"
+ assert result.concept_code == "Invoice"
def test_alias_code(self) -> None:
spec = {**self._BASE, "code": "Invoice"}
result = parse_concept_spec(spec)
- assert result.the_concept_code == "Invoice"
+ assert result.concept_code == "Invoice"
def test_alias_name(self) -> None:
spec = {**self._BASE, "name": "Invoice"}
result = parse_concept_spec(spec)
- assert result.the_concept_code == "Invoice"
+ 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.the_concept_code == "Invoice"
+ assert result.concept_code == "Invoice"
def test_canonical_ignores_alias(self) -> None:
- """When the_concept_code is present, alias keys are removed so Pydantic doesn't reject them."""
- spec = {**self._BASE, "the_concept_code": "Canonical", "name": "Alias"}
+ """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.the_concept_code == "Canonical"
+ assert result.concept_code == "Canonical"
def test_multiple_aliases_all_cleaned_up(self) -> None:
- """When the_concept_code and multiple aliases are present, all aliases are removed."""
+ """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.the_concept_code == "Invoice"
+ assert result.concept_code == "Invoice"
class TestStructureFieldStringShorthand:
@@ -177,7 +177,7 @@ class TestStructureFieldStringShorthand:
def test_string_field_becomes_text(self) -> None:
spec: dict[str, Any] = {
- "the_concept_code": "Simple",
+ "concept_code": "Simple",
"description": "A simple concept",
"structure": {
"title": "The title of the item",
@@ -190,7 +190,7 @@ class TestStructureFieldStringShorthand:
def test_mixed_string_and_dict_fields(self) -> None:
spec: dict[str, Any] = {
- "the_concept_code": "Mixed",
+ "concept_code": "Mixed",
"description": "A mixed concept",
"structure": {
"name": "The person's name",
@@ -209,20 +209,20 @@ class TestParseConceptSpecFromJson:
def test_parse_simple_concept_with_refines(self) -> None:
"""Parse a simple concept that refines Text."""
spec_data: dict[str, Any] = {
- "the_concept_code": "Invoice",
+ "concept_code": "Invoice",
"description": "A commercial invoice",
"refines": "Text",
}
result = parse_concept_spec(spec_data)
- assert result.the_concept_code == "Invoice"
+ 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] = {
- "the_concept_code": "Person",
+ "concept_code": "Person",
"description": "A person record",
"structure": {
"name": "The person's name",
@@ -231,7 +231,7 @@ class TestParseConceptSpecFromJson:
}
result = parse_concept_spec(spec_data)
- assert result.the_concept_code == "Person"
+ assert result.concept_code == "Person"
assert result.structure is not None
assert "name" in result.structure
assert "age" in result.structure
@@ -245,7 +245,7 @@ class TestParseConceptSpecFromJson:
during JSON parsing (if Pydantic had extra='ignore').
"""
spec_data: dict[str, Any] = {
- "the_concept_code": "Task",
+ "concept_code": "Task",
"description": "A task with status",
"structure": {
"status": {
@@ -271,7 +271,7 @@ class TestConceptSpecToToml:
were not included in the TOML output.
"""
spec_data: dict[str, Any] = {
- "the_concept_code": "TaskStatus",
+ "concept_code": "TaskStatus",
"description": "A task with status tracking",
"structure": {
"status": {
@@ -289,7 +289,7 @@ class TestConceptSpecToToml:
def test_toml_output_simple_refines_concept(self) -> None:
"""TOML output for a simple refines concept."""
spec_data: dict[str, Any] = {
- "the_concept_code": "Invoice",
+ "concept_code": "Invoice",
"description": "A commercial invoice",
"refines": "Text",
}
@@ -303,7 +303,7 @@ class TestConceptSpecToToml:
def test_toml_output_structured_concept_with_multiple_fields(self) -> None:
"""TOML output for a structured concept with multiple field types."""
spec_data: dict[str, Any] = {
- "the_concept_code": "Order",
+ "concept_code": "Order",
"description": "A customer order",
"structure": {
"order_id": {"type": "text", "description": "Order identifier", "required": True},
@@ -365,7 +365,7 @@ class TestConceptStructureSpecChoices:
"""Full roundtrip from JSON input to TOML output should preserve choices."""
input_json = json.dumps(
{
- "the_concept_code": "WorkItem",
+ "concept_code": "WorkItem",
"description": "A work item",
"structure": {
"priority": {