Files
cleveragents-core/features/project_show_resource_name.feature
freemo 0a8e5cb388 fix(cli): display resource name in project show linked resources list
- What was implemented
  - Added _resolve_resource_names() helper in src/cleveragents/cli/commands/project.py that queries the Resource Registry to map resource ULIDs to their namespaced names, with graceful fallback to None when the registry is unavailable or a resource has no name
  - Updated _project_spec_dict() to accept an optional resource_names dict parameter and include resource_name alongside resource_id in JSON/YAML output formats
  - Updated show command to resolve resource names before display, showing human-readable names (e.g. local/my-git-repo) instead of raw ULIDs, falling back to ULID when name is unavailable
  - Added BDD feature file features/project_show_resource_name.feature with 6 regression scenarios
  - Added step definitions features/steps/project_show_resource_name_steps.py

- Key design decisions
  - Graceful degradation: if the Resource Registry is unavailable, the show command still works and falls back to displaying the raw ULID
  - Resources without names (auto-discovered) also fall back to ULID display
  - JSON/YAML output includes both resource_id and resource_name for completeness
  - The fix is minimal and non-breaking: _project_spec_dict() only includes resource_name when resource_names dict is explicitly passed

- Rationale and implementation notes
  - _resolve_resource_names() provides a bounded, resilient means to enrich output with human-readable names without breaking on registry failures
  - The show command uses resolved names for display while preserving IDs as the underlying data source
  - Outputs (JSON/YAML) expose both IDs and names when available, ensuring downstream consumers have full context

- Modules/Components Affected
  - src/cleveragents/cli/commands/project.py
  - tests/BDD: features/project_show_resource_name.feature
  - tests/BDD steps: features/steps/project_show_resource_name_steps.py

- Backwards compatibility
  - Non-breaking: if resource_names is not provided or the registry is unavailable, behavior remains compatible by falling back to ULIDs

- Testing
  - Added regression scenarios via the new feature file and step definitions to validate name resolution and fallback behavior

ISSUES CLOSED: #2943
2026-06-06 03:29:32 -04:00

72 lines
4.1 KiB
Gherkin

# Regression tests for bug #2943: agents project show must display resource
# names instead of raw ULIDs for linked resources.
Feature: Project show displays resource names for linked resources
As a developer using the agents CLI
I want "agents project show" to display human-readable resource names
So that I can identify linked resources without looking up ULIDs manually
Background:
Given a fresh project-show-resource-name database is initialised
@tdd_issue @tdd_issue_2943
Scenario: Show displays resource name instead of ULID for a named resource
Given a project "local/my-app" exists in the resource-name DB
And a named resource "local/my-git-repo" is linked to project "local/my-app" in the resource-name DB
When I show project "local/my-app" via the resource-name CLI
Then the resource-name show output should contain "local/my-git-repo"
And the resource-name show exit code should be 0
@tdd_issue @tdd_issue_2943
Scenario: Show falls back to ULID when resource has no name
Given a project "local/unnamed-res-proj" exists in the resource-name DB
And an unnamed resource is linked to project "local/unnamed-res-proj" in the resource-name DB
When I show project "local/unnamed-res-proj" via the resource-name CLI
Then the resource-name show output should contain the resource ULID
And the resource-name show exit code should be 0
@tdd_issue @tdd_issue_2943
Scenario: Show displays resource name with read-only marker
Given a project "local/ro-proj" exists in the resource-name DB
And a named read-only resource "local/ro-resource" is linked to project "local/ro-proj" in the resource-name DB
When I show project "local/ro-proj" via the resource-name CLI
Then the resource-name show output should contain "local/ro-resource"
And the resource-name show output should contain "read-only"
And the resource-name show exit code should be 0
@tdd_issue @tdd_issue_2943
Scenario: Show displays resource name with alias when set
Given a project "local/alias-proj" exists in the resource-name DB
And resource "local/aliased-resource" with alias "my-alias" is linked to project "local/alias-proj" in the resource-name DB
When I show project "local/alias-proj" via the resource-name CLI
Then the resource-name show output should contain "local/aliased-resource"
And the resource-name show output should contain "my-alias"
And the resource-name show exit code should be 0
@tdd_issue @tdd_issue_2943
Scenario: JSON output includes both resource_id and resource_name
Given a project "local/json-proj" exists in the resource-name DB
And a named resource "local/json-resource" is linked to project "local/json-proj" in the resource-name DB
When I show project "local/json-proj" as JSON via the resource-name CLI
Then the resource-name show output should contain "resource_id"
And the resource-name show output should contain "resource_name"
And the resource-name show output should contain "local/json-resource"
And the resource-name show exit code should be 0
@tdd_issue @tdd_issue_2943
Scenario: YAML output includes both resource_id and resource_name
Given a project "local/yaml-proj" exists in the resource-name DB
And a named resource "local/yaml-resource" is linked to project "local/yaml-proj" in the resource-name DB
When I show project "local/yaml-proj" as YAML via the resource-name CLI
Then the resource-name show output should contain "resource_id"
And the resource-name show output should contain "resource_name"
And the resource-name show output should contain "local/yaml-resource"
And the resource-name show exit code should be 0
@tdd_issue @tdd_issue_2943
Scenario: Show gracefully handles registry unavailable by falling back to ULID
Given a project "local/fallback-proj" exists in the resource-name DB
And a resource is linked to project "local/fallback-proj" in the resource-name DB
When I show project "local/fallback-proj" with registry unavailable via the resource-name CLI
Then the resource-name show output should contain the resource ULID
And the resource-name show exit code should be 0