fix(resource-type): require letter-start for namespace/name in _NAMESPACED_RE #3290
Labels
No labels
auto/needs-reevaluation
controller-managed
auto/blocked-by-deps
auto/ci-timeout
auto/claimed-implementer
auto/claimed-merge
auto/claimed-reviewer
auto/driver-down
auto/invariant-violation
auto/last-attempt-tier-0
auto/last-attempt-tier-1
auto/last-attempt-tier-2
auto/last-attempt-tier-min
Automation Tracking
auto/needs-conflict-resolution
auto/needs-implementer
auto/postmortem
auto/ready-to-merge
auto/restart-throttled
auto/revert
auto/sentinel
auto/stale-inactivity
auto/unstable
Blocked
Bounty
$100
Bounty
$1000
Bounty
$10000
Bounty
$20
Bounty
$2000
Bounty
$250
Bounty
$50
Bounty
$500
Bounty
$5000
Bounty
$750
MoSCoW
Could have
MoSCoW
Must have
MoSCoW
Should have
Needs Feedback
Points
1
Points
13
Points
2
Points
21
Points
3
Points
34
Points
5
Points
55
Points
8
Points
88
Priority
Backlog
Priority
CI Blocker
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Signed-off: Owner
Signed-off: Scrum Master
Signed-off: Tech Lead
Spike
State
Completed
State
Duplicate
State
In Progress
State
In Review
State
Paused
State
Unverified
State
Verified
State
Wont Do
Type
Automation
Type
Bug
Type
Discussion
Type
Documentation
Type
Epic
Type
Feature
Type
Legendary
Type
Refactor
Type
Support
Type
Task
Type
Testing
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Blocks
Reference
cleveragents/cleveragents-core!3290
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/resource-type-namespaced-re-digit-start"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Fixes
_NAMESPACED_REinresource_type.pyand_resource_type_validation.pyto require both namespace and name components to start with a letter, consistent with the spec requirement and_BUILTIN_NAME_RE.Problem
The
_NAMESPACED_REpattern used[a-zA-Z0-9]as the first character class, allowing digit-starting names like123abc/my-typeandlocal/456-type. This was inconsistent with:_BUILTIN_NAME_REwhich correctly uses[a-zA-Z]_SERVER_NS_NAME_REinproject.pyChanges
src/cleveragents/domain/models/core/resource_type.py_NAMESPACED_REfrom^[a-zA-Z0-9][a-zA-Z0-9_-]*/[a-zA-Z0-9][a-zA-Z0-9_-]*$to^[a-zA-Z][a-zA-Z0-9_-]*/[a-zA-Z][a-zA-Z0-9_-]*$src/cleveragents/domain/models/core/_resource_type_validation.py_NAMESPACED_REfrom^[a-zA-Z0-9_-]+/[a-zA-Z0-9_-]+$to^[a-zA-Z][a-zA-Z0-9_-]*/[a-zA-Z][a-zA-Z0-9_-]*$features/resource_type_digit_start_validation.feature(new)123abc/my-type)local/456-type)1ns/2name)local/my-type,myorg/custom-db,my_org/my_type)inheritsfield valuesfeatures/steps/resource_type_digit_start_validation_steps.py(new)Verification
ResourceTypeSpec(name="123abc/my-type", ...)now raisesValidationError✓ResourceTypeSpec(name="local/456-type", ...)now raisesValidationError✓ResourceTypeSpec(name="local/my-type", ...)still succeeds ✓ResourceTypeSpec(name="myorg/custom-db", ...)still succeeds ✓nox -e lintpasses ✓nox -e typecheckpasses (0 errors, 0 warnings) ✓Closes #2983
Automated by CleverAgents Bot
Supervisor: Implementation | Agent: ca-issue-worker
_NAMESPACED_REinresource_type.pyand_resource_type_validation.pyallows custom resource type names/namespaces starting with digits — spec requires names to start with a letter #2983Review Summary
Reviewed PR #3290 with focus on api-consistency, naming-conventions, and code-patterns.
This is a clean, well-scoped bug fix that corrects
_NAMESPACED_REregex patterns in two files to require letter-start for both namespace and name components, aligning with the spec requirement and the existing_BUILTIN_NAME_RE/_SERVER_NS_NAME_REpatterns.Verdict: This PR is ready for approval.
✅ Specification Compliance
[[server:]namespace/]nameand the glossary entry for "Namespace" confirms letter-start convention_SERVER_NS_NAME_REinproject.py(line 32-36) already uses[a-zA-Z]for first character — this PR brings_NAMESPACED_REinto alignment_BUILTIN_NAME_REalready uses[a-zA-Z]— consistency is now restored✅ API Consistency (Focus Area)
_NAMESPACED_REdefinitions (inresource_type.pyand_resource_type_validation.py) are now identical:^[a-zA-Z][a-zA-Z0-9_-]*/[a-zA-Z][a-zA-Z0-9_-]*$_SERVER_NS_NAME_REinproject.pyand_BUILTIN_NAME_REin both filesvalidate_name()andvalidate_inherits()validators correctly use the updated pattern through the module-level_NAMESPACED_RE✅ Naming Conventions (Focus Area)
_NAMESPACED_RE,_BUILTIN_NAME_RE)resource_type_digit_start_validation.featurefollows project naming patternsresource_type_digit_start_validation_steps.pyfollows the<feature>_steps.pyconvention_make_custom_physical_spec()follows the_prefix convention for internal helpers✅ Code Patterns (Focus Area)
ValidationErrorintocontext.rt_errorgivenstep fromresource_type_model_coverage_steps.pythenstep for "invalid inherits type name" is correctly reused fromresource_type_model_coverage_steps.py(noted in the step file docstring)✅ CONTRIBUTING.md Compliance
fix(resource-type): require letter-start for namespace/name in _NAMESPACED_RE— correct Conventional Changelog format ✓ISSUES CLOSED: #2983✓Closes #2983, milestone v3.7.0 (matches issue),Type/Buglabel ✓# type: ignore, imports at top of file ✓✅ Test Quality
inheritsfield rejection cases✅ Code Correctness
[a-zA-Z0-9]→[a-zA-Z]is correct for the stated requirement_resource_type_validation.py: The old pattern^[a-zA-Z0-9_-]+/[a-zA-Z0-9_-]+$was even more permissive — it allowed names starting with hyphens or underscores (e.g.,_ns/name,-ns/name). The new pattern correctly prevents this too.Minor Suggestions (Non-blocking)
DRY concern — duplicate
_NAMESPACED_REdefinitions: Bothresource_type.pyand_resource_type_validation.pydefine their own_NAMESPACED_RE(and_BUILTIN_NAME_RE). If someone changes one but not the other in the future, the inconsistency bug could recur. Consider a follow-up issue to consolidate these into a single shared location (e.g., the validation module exports them, andresource_type.pyimports). This is a pre-existing design issue, not introduced by this PR.Additional edge case tests: Since the
_resource_type_validation.pyfix also prevents names starting with hyphens or underscores (which the old[a-zA-Z0-9_-]+pattern allowed), consider adding scenarios for_ns/nameand-ns/namerejection in a follow-up. Again, not blocking for this PR since the issue scope was specifically digit-starting names.Decision: APPROVED ✅
Automated by CleverAgents Bot
Supervisor: PR Review | Agent: ca-pr-self-reviewer
_NAMESPACED_REinresource_type.pyand_resource_type_validation.pyallows custom resource type names/namespaces starting with digits — spec requires names to start with a letterPR Status Update — Awaiting Review
This PR is ready for review. Here is the current status:
✅ CI Checks
All critical CI checks are passing:
The
benchmark-regressionandbenchmark-publishchecks are pending (these are non-blocking performance checks that run asynchronously).✅ Merge Readiness
State/In Review✅Type/Bug✅❌ Blocking: Needs 2 Approving Reviews
Per CONTRIBUTING.md, this PR requires 2 approving reviews from non-author contributors. Currently there are 0 official approvals.
Review requests have been sent to @khird and @drew.
What This PR Does
Fixes
_NAMESPACED_REinresource_type.pyand_resource_type_validation.pyto require both namespace and name components to start with a letter (changing[a-zA-Z0-9]→[a-zA-Z]for the first character class). This aligns with the spec requirement,_BUILTIN_NAME_RE, and_SERVER_NS_NAME_REinproject.py.The fix is minimal, targeted, and includes 8 Behave scenarios covering rejection and acceptance cases.
Automated by CleverAgents Bot
Supervisor: Implementation | Agent: ca-issue-worker
Independent Code Review — PR #3290
Reviewed PR #3290 with focus on api-consistency, naming-conventions, and code-patterns.
This is a clean, well-scoped bug fix that corrects
_NAMESPACED_REregex patterns in two files to require letter-start for both namespace and name components, aligning with the spec requirement and the existing_BUILTIN_NAME_REpattern.Verdict: No issues found. This PR is ready for human reviewer approval.
✅ Specification Compliance
[[server:]namespace/]namewith letter-start requirement_BUILTIN_NAME_REalready uses[a-zA-Z]— consistency is now restored across both modules_SERVER_NS_NAME_REinproject.pyalready enforces letter-start — this PR brings_NAMESPACED_REinto alignment✅ API Consistency (Focus Area — Deep Dive)
_NAMESPACED_REdefinitions (inresource_type.pyand_resource_type_validation.py) are now identical:^[a-zA-Z][a-zA-Z0-9_-]*/[a-zA-Z][a-zA-Z0-9_-]*$_BUILTIN_NAME_REin both filesvalidate_name()andvalidate_inherits()validators correctly use the updated pattern through the module-level_NAMESPACED_RE_resource_type_validation.py: The old pattern^[a-zA-Z0-9_-]+/[a-zA-Z0-9_-]+$was even more permissive than the one inresource_type.py— it allowed names starting with hyphens or underscores (e.g.,_ns/name,-ns/name). The new pattern correctly prevents this too, bringing both files into perfect alignment.✅ Naming Conventions (Focus Area — Deep Dive)
_NAMESPACED_RE,_BUILTIN_NAME_RE)resource_type_digit_start_validation.featurefollows project naming patternsresource_type_digit_start_validation_steps.pyfollows the<feature>_steps.pyconvention_make_custom_physical_spec()follows the_prefix convention for internal helpersstep_<action>pattern✅ Code Patterns (Focus Area — Deep Dive)
ValidationErrorintocontext.rt_errorgivenstep fromresource_type_model_coverage_steps.pythenstep for "invalid inherits type name" is correctly reused fromresource_type_model_coverage_steps.py(noted in the step file docstring)✅ CONTRIBUTING.md Compliance
fix(resource-type): require letter-start for namespace/name in _NAMESPACED_RE— correct Conventional Changelog format ✓ISSUES CLOSED: #2983✓Closes #2983✓Type/Bug✓# type: ignore, imports at top of file ✓✅ Test Quality
inheritsfield rejection cases (digit-starting namespace and name)✅ Code Correctness
[a-zA-Z0-9]→[a-zA-Z]is correct for the stated requirement*quantifier after the first character class is correct (first char already matched by[a-zA-Z])local/my-type,myorg/custom-db,my_org/my_typestill passMinor Suggestions (Non-blocking)
DRY concern — duplicate
_NAMESPACED_REdefinitions: Bothresource_type.pyand_resource_type_validation.pydefine their own_NAMESPACED_RE(and_BUILTIN_NAME_RE). If someone changes one but not the other in the future, the inconsistency bug could recur. Consider a follow-up issue to consolidate these into a single shared location (e.g., the validation module exports them, andresource_type.pyimports). This is a pre-existing design issue, not introduced by this PR.Additional edge case tests: Since the
_resource_type_validation.pyfix also prevents names starting with hyphens or underscores (which the old[a-zA-Z0-9_-]+pattern allowed), consider adding scenarios for_ns/nameand-ns/namerejection in a follow-up. Not blocking since the issue scope was specifically digit-starting names.Decision: APPROVED ✅
(Note: Posted as COMMENT because the Forgejo API user matches the PR author. Human reviewers @khird and @drew — this PR is ready for your approval.)
Automated by CleverAgents Bot
Supervisor: PR Review | Agent: ca-pr-self-reviewer