UAT: ActionArgument.validate_name rejects hyphenated argument names but ActionConfigSchema allows them — inconsistency between YAML schema and domain model #4028

Open
opened 2026-04-06 08:46:14 +00:00 by freemo · 0 comments
Owner

Metadata

  • Branch: fix/action-argument-validate-name-hyphen-inconsistency
  • Commit Message: fix(action): align ActionArgument.validate_name to allow hyphens consistent with ActionConfigSchema
  • Milestone: None (backlog)
  • Parent Epic: #392

What Was Tested

Code-level analysis comparing src/cleveragents/domain/models/core/action.py (domain model) and src/cleveragents/action/schema.py (YAML schema validator).

Expected Behavior

Both the YAML schema validator (ActionConfigSchema) and the domain model (ActionArgument) should use consistent validation rules for argument names. If one allows hyphens, both should.

Actual Behavior

There is a validation inconsistency between the two layers:

ActionConfigSchema.ActionArgumentSchema.validate_name (in src/cleveragents/action/schema.py):

@field_validator("name")
@classmethod
def validate_name(cls, v: str) -> str:
    if not v.replace("-", "_").isidentifier():
        raise ValueError(...)
    return v

This allows hyphens (e.g., my-arg is valid).

ActionArgument.validate_name (in src/cleveragents/domain/models/core/action.py):

@field_validator("name")
@classmethod
def validate_name(cls: type[ActionArgument], v: str) -> str:
    if not v.isidentifier():
        raise ValueError(
            "Argument name must be a valid Python identifier "
            "(alphanumeric and underscores, not starting with a digit)"
        )
    return v

This rejects hyphens (e.g., my-arg raises ValueError).

Impact

A user can create a YAML action file with an argument named my-arg:

arguments:
  - name: my-arg
    type: string
    required: true

ActionConfigSchema.from_yaml() will accept this YAML (no validation error).

But when Action.from_config() calls ActionArgument.from_mapping({"name": "my-arg", "type": "string"}), it will raise a ValueError because ActionArgument.validate_name uses isidentifier() which rejects hyphens.

This creates a confusing user experience where YAML validation passes but domain model creation fails with a cryptic error.

Code Locations

  • src/cleveragents/action/schema.py, ActionArgumentSchema.validate_name (allows hyphens)
  • src/cleveragents/domain/models/core/action.py, ActionArgument.validate_name (rejects hyphens)

Steps to Reproduce

from cleveragents.action.schema import ActionConfigSchema

yaml_content = """
name: local/test-action
description: Test
strategy_actor: local/strategy
execution_actor: local/exec
definition_of_done: Done
arguments:
  - name: my-arg
    type: string
    required: true
"""

# Step 1: YAML schema validation passes
schema = ActionConfigSchema.from_yaml(yaml_content)
print("Schema valid:", schema.arguments[0].name)  # "my-arg" - passes!

# Step 2: Domain model creation fails
from cleveragents.domain.models.core.action import Action
config = {
    "name": "local/test-action",
    "description": "Test",
    "strategy_actor": "local/strategy",
    "execution_actor": "local/exec",
    "definition_of_done": "Done",
    "arguments": [{"name": "my-arg", "type": "string", "required": True}]
}
action = Action.from_config(config)  # Raises ValueError!

Subtasks

  • Decide on canonical validation rule: allow hyphens (option 1) or reject them (option 2)
  • Update ActionArgument.validate_name in src/cleveragents/domain/models/core/action.py to use v.replace("-", "_").isidentifier() (preferred — aligns with schema)
  • Update the ValueError message in ActionArgument.validate_name to reflect the new rule (mention hyphens are allowed)
  • Add or update Behave unit test scenario asserting ActionArgument accepts hyphenated names
  • Add or update Behave unit test scenario asserting both layers accept/reject the same set of names
  • Ensure nox -e lint, nox -e typecheck, and nox -e unit_tests all pass

Definition of Done

  • ActionArgument.validate_name and ActionConfigSchema.ActionArgumentSchema.validate_name use identical validation logic for argument names
  • Hyphenated argument names (e.g., my-arg) are accepted by both layers (or rejected by both, consistently)
  • Unit tests cover the consistent validation behaviour across both layers
  • No regression in existing argument name validation tests
  • All nox stages pass
  • Coverage >= 97%

Backlog note: This issue was discovered during autonomous operation
on milestone v3.2.0. It does not block milestone completion and has been
placed in the backlog for human review and future milestone assignment.


Automated by CleverAgents Bot
Supervisor: UAT Testing | Agent: ca-new-issue-creator

## Metadata - **Branch**: `fix/action-argument-validate-name-hyphen-inconsistency` - **Commit Message**: `fix(action): align ActionArgument.validate_name to allow hyphens consistent with ActionConfigSchema` - **Milestone**: None (backlog) - **Parent Epic**: #392 ## What Was Tested Code-level analysis comparing `src/cleveragents/domain/models/core/action.py` (domain model) and `src/cleveragents/action/schema.py` (YAML schema validator). ## Expected Behavior Both the YAML schema validator (`ActionConfigSchema`) and the domain model (`ActionArgument`) should use consistent validation rules for argument names. If one allows hyphens, both should. ## Actual Behavior There is a validation inconsistency between the two layers: **`ActionConfigSchema.ActionArgumentSchema.validate_name`** (in `src/cleveragents/action/schema.py`): ```python @field_validator("name") @classmethod def validate_name(cls, v: str) -> str: if not v.replace("-", "_").isidentifier(): raise ValueError(...) return v ``` This **allows** hyphens (e.g., `my-arg` is valid). **`ActionArgument.validate_name`** (in `src/cleveragents/domain/models/core/action.py`): ```python @field_validator("name") @classmethod def validate_name(cls: type[ActionArgument], v: str) -> str: if not v.isidentifier(): raise ValueError( "Argument name must be a valid Python identifier " "(alphanumeric and underscores, not starting with a digit)" ) return v ``` This **rejects** hyphens (e.g., `my-arg` raises `ValueError`). ## Impact A user can create a YAML action file with an argument named `my-arg`: ```yaml arguments: - name: my-arg type: string required: true ``` `ActionConfigSchema.from_yaml()` will **accept** this YAML (no validation error). But when `Action.from_config()` calls `ActionArgument.from_mapping({"name": "my-arg", "type": "string"})`, it will **raise a `ValueError`** because `ActionArgument.validate_name` uses `isidentifier()` which rejects hyphens. This creates a confusing user experience where YAML validation passes but domain model creation fails with a cryptic error. ## Code Locations - `src/cleveragents/action/schema.py`, `ActionArgumentSchema.validate_name` (allows hyphens) - `src/cleveragents/domain/models/core/action.py`, `ActionArgument.validate_name` (rejects hyphens) ## Steps to Reproduce ```python from cleveragents.action.schema import ActionConfigSchema yaml_content = """ name: local/test-action description: Test strategy_actor: local/strategy execution_actor: local/exec definition_of_done: Done arguments: - name: my-arg type: string required: true """ # Step 1: YAML schema validation passes schema = ActionConfigSchema.from_yaml(yaml_content) print("Schema valid:", schema.arguments[0].name) # "my-arg" - passes! # Step 2: Domain model creation fails from cleveragents.domain.models.core.action import Action config = { "name": "local/test-action", "description": "Test", "strategy_actor": "local/strategy", "execution_actor": "local/exec", "definition_of_done": "Done", "arguments": [{"name": "my-arg", "type": "string", "required": True}] } action = Action.from_config(config) # Raises ValueError! ``` ## Subtasks - [ ] Decide on canonical validation rule: allow hyphens (option 1) or reject them (option 2) - [ ] Update `ActionArgument.validate_name` in `src/cleveragents/domain/models/core/action.py` to use `v.replace("-", "_").isidentifier()` (preferred — aligns with schema) - [ ] Update the `ValueError` message in `ActionArgument.validate_name` to reflect the new rule (mention hyphens are allowed) - [ ] Add or update Behave unit test scenario asserting `ActionArgument` accepts hyphenated names - [ ] Add or update Behave unit test scenario asserting both layers accept/reject the same set of names - [ ] Ensure `nox -e lint`, `nox -e typecheck`, and `nox -e unit_tests` all pass ## Definition of Done - [ ] `ActionArgument.validate_name` and `ActionConfigSchema.ActionArgumentSchema.validate_name` use identical validation logic for argument names - [ ] Hyphenated argument names (e.g., `my-arg`) are accepted by both layers (or rejected by both, consistently) - [ ] Unit tests cover the consistent validation behaviour across both layers - [ ] No regression in existing argument name validation tests - All nox stages pass - Coverage >= 97% > **Backlog note:** This issue was discovered during autonomous operation > on milestone v3.2.0. It does not block milestone completion and has been > placed in the backlog for human review and future milestone assignment. --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: ca-new-issue-creator
HAL9000 added this to the v3.5.0 milestone 2026-04-09 03:11:48 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Blocks
#392 Epic: Actor YAML & Compiler
cleveragents/cleveragents-core
Reference
cleveragents/cleveragents-core#4028
No description provided.