UAT: NamespacedName in plan.py does not validate reserved or provider namespaces — actions and plans can be created with system/, admin/, openai/, anthropic/ etc. #2143

Open
opened 2026-04-03 04:24:39 +00:00 by freemo · 1 comment
Owner

Metadata

  • Branch: fix/namespaced-name-reserved-namespace-validation
  • Commit Message: fix(domain): enforce reserved and provider namespace validation in NamespacedName
  • Milestone: v3.7.0
  • Parent Epic: #362

Summary

NamespacedName in src/cleveragents/domain/models/core/plan.py does not validate reserved or provider namespaces. Its validate_namespace() method only checks alphanumeric-with-hyphens format, allowing actions, plans, and other entities to be created with namespaces such as system/, admin/, openai/, anthropic/, google/, etc. — all of which are explicitly reserved by the specification (§Namespaces, ADR-002).

By contrast, parse_namespaced_name() in src/cleveragents/domain/models/core/project.py correctly enforces these rules using RESERVED_NAMESPACES and PROVIDER_NAMESPACES frozensets. The fix must bring NamespacedName.validate_namespace() into parity with the project-level enforcement.

Reproduction

from cleveragents.domain.models.core.plan import NamespacedName

# These should all raise ValueError but don't:
nn = NamespacedName.parse("openai/my-action")   # Should fail: provider namespace
nn2 = NamespacedName.parse("system/my-action")  # Should fail: reserved namespace
nn3 = NamespacedName.parse("anthropic/my-plan") # Should fail: provider namespace

Expected Behaviour (per spec §Namespaces and ADR-002)

  • local/ is reserved for local-only items and must not be used for custom entity registration.
  • Built-in provider namespaces (openai/, anthropic/, google/, gemini/, deepseek/, mistral/, perplexity/, qwen/, amazon/) are reserved for built-in LLM actors.
  • NamespacedName.parse("openai/my-action") must raise ValueError with a message identifying the namespace as reserved.

Actual Behaviour

NamespacedName.validate_namespace() accepts any alphanumeric-with-hyphens string, including all reserved and provider namespaces. Entity resolution ambiguity and namespace isolation violations are silently permitted.

Affected Files

  • src/cleveragents/domain/models/core/plan.pyNamespacedName.validate_namespace() (~line 221)
  • Reference (correct): src/cleveragents/domain/models/core/project.pyRESERVED_NAMESPACES, PROVIDER_NAMESPACES, parse_namespaced_name() (lines 41–160)

Subtasks

  • Extract RESERVED_NAMESPACES and PROVIDER_NAMESPACES frozensets into a shared constants module (e.g., src/cleveragents/domain/models/core/namespaces.py) to avoid duplication between plan.py and project.py
  • Update NamespacedName.validate_namespace() in plan.py to reject reserved namespaces (local, system, admin, etc.) with a descriptive ValueError
  • Update NamespacedName.validate_namespace() in plan.py to reject provider namespaces (openai, anthropic, google, gemini, deepseek, mistral, perplexity, qwen, amazon) with a descriptive ValueError
  • Update parse_namespaced_name() in project.py to import from the shared constants module
  • Write Behave unit tests (in features/) covering: reserved namespace rejection, provider namespace rejection, and valid custom namespace acceptance for NamespacedName
  • Verify all existing NamespacedName usages in the codebase are not broken by the new validation (audit call sites)
  • Run nox -e typecheck and confirm no Pyright errors introduced

Definition of Done

  • NamespacedName.parse("openai/x") raises ValueError identifying openai as a reserved provider namespace
  • NamespacedName.parse("system/x") raises ValueError identifying system as a reserved namespace
  • NamespacedName.parse("local/x") raises ValueError identifying local as a reserved namespace
  • NamespacedName.parse("myorg/my-action") succeeds as before
  • RESERVED_NAMESPACES and PROVIDER_NAMESPACES are defined in a single shared location, imported by both plan.py and project.py
  • Behave feature file added with scenarios for all reserved and provider namespace rejection cases
  • All nox stages pass
  • Coverage >= 97%

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

## Metadata - **Branch**: `fix/namespaced-name-reserved-namespace-validation` - **Commit Message**: `fix(domain): enforce reserved and provider namespace validation in NamespacedName` - **Milestone**: v3.7.0 - **Parent Epic**: #362 ## Summary `NamespacedName` in `src/cleveragents/domain/models/core/plan.py` does not validate reserved or provider namespaces. Its `validate_namespace()` method only checks alphanumeric-with-hyphens format, allowing actions, plans, and other entities to be created with namespaces such as `system/`, `admin/`, `openai/`, `anthropic/`, `google/`, etc. — all of which are explicitly reserved by the specification (§Namespaces, ADR-002). By contrast, `parse_namespaced_name()` in `src/cleveragents/domain/models/core/project.py` correctly enforces these rules using `RESERVED_NAMESPACES` and `PROVIDER_NAMESPACES` frozensets. The fix must bring `NamespacedName.validate_namespace()` into parity with the project-level enforcement. ## Reproduction ```python from cleveragents.domain.models.core.plan import NamespacedName # These should all raise ValueError but don't: nn = NamespacedName.parse("openai/my-action") # Should fail: provider namespace nn2 = NamespacedName.parse("system/my-action") # Should fail: reserved namespace nn3 = NamespacedName.parse("anthropic/my-plan") # Should fail: provider namespace ``` ## Expected Behaviour (per spec §Namespaces and ADR-002) - `local/` is reserved for local-only items and must not be used for custom entity registration. - Built-in provider namespaces (`openai/`, `anthropic/`, `google/`, `gemini/`, `deepseek/`, `mistral/`, `perplexity/`, `qwen/`, `amazon/`) are reserved for built-in LLM actors. - `NamespacedName.parse("openai/my-action")` must raise `ValueError` with a message identifying the namespace as reserved. ## Actual Behaviour `NamespacedName.validate_namespace()` accepts any alphanumeric-with-hyphens string, including all reserved and provider namespaces. Entity resolution ambiguity and namespace isolation violations are silently permitted. ## Affected Files - `src/cleveragents/domain/models/core/plan.py` — `NamespacedName.validate_namespace()` (~line 221) - Reference (correct): `src/cleveragents/domain/models/core/project.py` — `RESERVED_NAMESPACES`, `PROVIDER_NAMESPACES`, `parse_namespaced_name()` (lines 41–160) ## Subtasks - [ ] Extract `RESERVED_NAMESPACES` and `PROVIDER_NAMESPACES` frozensets into a shared constants module (e.g., `src/cleveragents/domain/models/core/namespaces.py`) to avoid duplication between `plan.py` and `project.py` - [ ] Update `NamespacedName.validate_namespace()` in `plan.py` to reject reserved namespaces (`local`, `system`, `admin`, etc.) with a descriptive `ValueError` - [ ] Update `NamespacedName.validate_namespace()` in `plan.py` to reject provider namespaces (`openai`, `anthropic`, `google`, `gemini`, `deepseek`, `mistral`, `perplexity`, `qwen`, `amazon`) with a descriptive `ValueError` - [ ] Update `parse_namespaced_name()` in `project.py` to import from the shared constants module - [ ] Write Behave unit tests (in `features/`) covering: reserved namespace rejection, provider namespace rejection, and valid custom namespace acceptance for `NamespacedName` - [ ] Verify all existing `NamespacedName` usages in the codebase are not broken by the new validation (audit call sites) - [ ] Run `nox -e typecheck` and confirm no Pyright errors introduced ## Definition of Done - [ ] `NamespacedName.parse("openai/x")` raises `ValueError` identifying `openai` as a reserved provider namespace - [ ] `NamespacedName.parse("system/x")` raises `ValueError` identifying `system` as a reserved namespace - [ ] `NamespacedName.parse("local/x")` raises `ValueError` identifying `local` as a reserved namespace - [ ] `NamespacedName.parse("myorg/my-action")` succeeds as before - [ ] `RESERVED_NAMESPACES` and `PROVIDER_NAMESPACES` are defined in a single shared location, imported by both `plan.py` and `project.py` - [ ] Behave feature file added with scenarios for all reserved and provider namespace rejection cases - [ ] All nox stages pass - [ ] Coverage >= 97% --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: ca-new-issue-creator
freemo added this to the v3.7.0 milestone 2026-04-03 04:24:43 +00:00
freemo self-assigned this 2026-04-03 16:58:02 +00:00
Author
Owner

MoSCoW classification: Must Have

Rationale: This issue addresses a core spec requirement or blocks critical functionality. The project cannot ship without this fix.


Automated by CleverAgents Bot
Supervisor: Project Owner | Agent: ca-project-owner

MoSCoW classification: **Must Have** Rationale: This issue addresses a core spec requirement or blocks critical functionality. The project cannot ship without this fix. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: ca-project-owner
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.

Depends on
#362 Epic: Security & Safety Hardening
cleveragents/cleveragents-core
Reference
cleveragents/cleveragents-core#2143
No description provided.