UAT: agents resource list --type does not support regex filtering as spec requires #3612

Open
opened 2026-04-05 20:28:07 +00:00 by freemo · 0 comments
Owner

Metadata

  • Branch: tdd/backlog-resource-list-type-regex (failing test), bugfix/backlog-resource-list-type-regex (fix)
  • Commit Message: fix(cli): add regex pattern matching to agents resource list --type filter
  • Milestone: (none — backlog, see note below)
  • Parent Epic: #398

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

Background and Context

Per docs/specification.md, the agents resource list command is defined as:

agents resource list [--all] [(-t|--type) <TYPE>]
--type/-t TYPE: Filter by resource type (accepts a regex).

The spec explicitly states the --type filter "accepts a regex." This is a first-class feature of the resource listing interface, enabling users to filter across families of resource types (e.g., all git-* resources, all container-* resources) without needing to know exact type names.

Current Behavior

The --type filter performs only exact type name matching (or polymorphic subtype matching via ADR-042), but does not support regex patterns.

In src/cleveragents/cli/commands/resource.py, the resource_list() function passes the raw --type string directly to the service:

resources = service.list_resources(
    type_name=type_filter,
    include_auto_discovered=show_all,
)

In src/cleveragents/application/services/_resource_registry_ops.py, the list_resources() method performs only exact or subtype matching:

if type_name is not None:
    if exact:
        query = query.filter_by(type_name=type_name)
    else:
        # ADR-042: polymorphic listing — include subtypes
        registry = self._load_type_registry()
        subtypes = find_subtypes(type_name, registry)
        all_types = [type_name, *subtypes]
        query = query.filter(ResourceModel.type_name.in_(all_types))

There is no regex compilation or pattern matching anywhere in this path. If a user runs:

agents resource list --type "git.*"

The system attempts to find a resource type literally named "git.*" (which doesn't exist) and returns no results, instead of matching git-checkout, git-remote, git-branch, etc.

Expected Behavior

Per the specification, --type must accept a Python regex pattern and filter resources whose type_name matches the pattern. For example:

  • --type "git.*" → returns all resources with type names matching git-checkout, git-remote, git-branch, etc.
  • --type "container.*" → returns all container resource types
  • --type "^git-checkout$" → exact match (anchored regex, equivalent to current exact behaviour)
  • --type "git-checkout" → unanchored match (current exact match is a subset of this)

The regex should be applied using Python's re.search() or re.fullmatch() semantics (to be determined by implementation, but must be documented in the CLI help text).

Affected Code Locations

  • src/cleveragents/cli/commands/resource.pyresource_list() function, --type option handling
  • src/cleveragents/application/services/_resource_registry_ops.pylist_resources() method, type filtering logic

Subtasks

  • Write a failing Behave scenario in features/ that reproduces the missing regex behaviour (TDD — must be merged to master before the fix)
  • Update list_resources() in _resource_registry_ops.py to compile the type_name argument as a regex and filter ResourceModel.type_name using re.search() (or re.fullmatch() — document the choice)
  • Handle invalid regex patterns gracefully: raise a typed InvalidFilterPatternError (or equivalent domain exception) that the CLI renders as a user-friendly error message
  • Update the --type CLI help text in resource.py to state "accepts a regex pattern"
  • Add type annotations for any new parameters or return types introduced
  • Update or add Robot Framework integration tests in robot/ covering regex filter scenarios
  • Verify that the existing ADR-042 polymorphic subtype behaviour is preserved (or explicitly superseded) when a regex is provided

Definition of Done

  • Failing Behave test merged to master before fix branch is created
  • agents resource list --type "git.*" returns all resources whose type name matches the pattern
  • Invalid regex input produces a clear, user-facing error (not a Python traceback)
  • CLI --help output for --type documents regex support
  • All existing resource list tests continue to pass
  • All nox stages pass (nox -e lint, nox -e typecheck, nox -e unit_tests, nox -e integration_tests)
  • Coverage >= 97%

Automated by CleverAgents Bot
Supervisor: Acting on behalf of: UAT Testing | Agent: ca-new-issue-creator

## Metadata - **Branch**: `tdd/backlog-resource-list-type-regex` (failing test), `bugfix/backlog-resource-list-type-regex` (fix) - **Commit Message**: `fix(cli): add regex pattern matching to agents resource list --type filter` - **Milestone**: *(none — backlog, see note below)* - **Parent Epic**: #398 > **Backlog note:** This issue was discovered during autonomous operation > on milestone v3.0.0. It does not block milestone completion and has been > placed in the backlog for human review and future milestone assignment. ## Background and Context Per `docs/specification.md`, the `agents resource list` command is defined as: ``` agents resource list [--all] [(-t|--type) <TYPE>] --type/-t TYPE: Filter by resource type (accepts a regex). ``` The spec explicitly states the `--type` filter **"accepts a regex."** This is a first-class feature of the resource listing interface, enabling users to filter across families of resource types (e.g., all `git-*` resources, all `container-*` resources) without needing to know exact type names. ## Current Behavior The `--type` filter performs only exact type name matching (or polymorphic subtype matching via ADR-042), but does **not** support regex patterns. In `src/cleveragents/cli/commands/resource.py`, the `resource_list()` function passes the raw `--type` string directly to the service: ```python resources = service.list_resources( type_name=type_filter, include_auto_discovered=show_all, ) ``` In `src/cleveragents/application/services/_resource_registry_ops.py`, the `list_resources()` method performs only exact or subtype matching: ```python if type_name is not None: if exact: query = query.filter_by(type_name=type_name) else: # ADR-042: polymorphic listing — include subtypes registry = self._load_type_registry() subtypes = find_subtypes(type_name, registry) all_types = [type_name, *subtypes] query = query.filter(ResourceModel.type_name.in_(all_types)) ``` There is no regex compilation or pattern matching anywhere in this path. If a user runs: ``` agents resource list --type "git.*" ``` The system attempts to find a resource type literally named `"git.*"` (which doesn't exist) and returns no results, instead of matching `git-checkout`, `git-remote`, `git-branch`, etc. ## Expected Behavior Per the specification, `--type` must accept a Python regex pattern and filter resources whose `type_name` matches the pattern. For example: - `--type "git.*"` → returns all resources with type names matching `git-checkout`, `git-remote`, `git-branch`, etc. - `--type "container.*"` → returns all container resource types - `--type "^git-checkout$"` → exact match (anchored regex, equivalent to current exact behaviour) - `--type "git-checkout"` → unanchored match (current exact match is a subset of this) The regex should be applied using Python's `re.search()` or `re.fullmatch()` semantics (to be determined by implementation, but must be documented in the CLI help text). ## Affected Code Locations - `src/cleveragents/cli/commands/resource.py` — `resource_list()` function, `--type` option handling - `src/cleveragents/application/services/_resource_registry_ops.py` — `list_resources()` method, type filtering logic ## Subtasks - [ ] Write a failing Behave scenario in `features/` that reproduces the missing regex behaviour (TDD — must be merged to `master` before the fix) - [ ] Update `list_resources()` in `_resource_registry_ops.py` to compile the `type_name` argument as a regex and filter `ResourceModel.type_name` using `re.search()` (or `re.fullmatch()` — document the choice) - [ ] Handle invalid regex patterns gracefully: raise a typed `InvalidFilterPatternError` (or equivalent domain exception) that the CLI renders as a user-friendly error message - [ ] Update the `--type` CLI help text in `resource.py` to state *"accepts a regex pattern"* - [ ] Add type annotations for any new parameters or return types introduced - [ ] Update or add Robot Framework integration tests in `robot/` covering regex filter scenarios - [ ] Verify that the existing ADR-042 polymorphic subtype behaviour is preserved (or explicitly superseded) when a regex is provided ## Definition of Done - [ ] Failing Behave test merged to `master` before fix branch is created - [ ] `agents resource list --type "git.*"` returns all resources whose type name matches the pattern - [ ] Invalid regex input produces a clear, user-facing error (not a Python traceback) - [ ] CLI `--help` output for `--type` documents regex support - [ ] All existing resource list tests continue to pass - [ ] All nox stages pass (`nox -e lint`, `nox -e typecheck`, `nox -e unit_tests`, `nox -e integration_tests`) - [ ] Coverage >= 97% --- **Automated by CleverAgents Bot** Supervisor: Acting on behalf of: UAT Testing | Agent: ca-new-issue-creator
freemo added this to the v3.7.0 milestone 2026-04-05 20:29:24 +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
#398 Epic: Post-MVP Resources
cleveragents/cleveragents-core
Reference
cleveragents/cleveragents-core#3612
No description provided.