Restores green unit_tests by removing the duplicate Pydantic virtual-resource
implementation that had no production consumers and was causing behave step
collisions, fixing parse-library step patterns that never matched, and giving
the failing-test scenarios concrete step definitions.
Changes:
- Remove unused parallel implementation `src/cleveragents/domain/models/core/
virtual_resource.py`, its feature file `features/virtual_resource_types.feature`,
and its step file `features/steps/virtual_resource_types_steps.py`. The
canonical `src/cleveragents/resource/virtual.py` (re-exported by
`src/cleveragents/resource/__init__.py`) is the only public API; the
Pydantic copy had zero non-test consumers and its step file duplicated
step text patterns (e.g., `the computed value should be ...`), triggering
`behave.step_registry.AmbiguousStep` errors at module load.
- Fix `VirtualResource.__init__` name validation in
`src/cleveragents/resource/virtual.py`: replace the
`name.replace("-", "").replace("_", "").isalnum()` check with a single
regex `^[a-zA-Z][a-zA-Z0-9_-]*$`. The old check accepted leading digits
(e.g., `"123-invalid"` would strip the hyphen and pass `isalnum()`), so
the "Reject invalid resource names" scenario was silently failing.
- Fix step patterns in `features/steps/resource_virtual_types_steps.py`:
replace unsupported `{name!r}` parse-library syntax with literal-quoted
`"{name}"` (confirmed via `parse.parse(...)` REPL that `!r` returns
`None`); rename the over-broad `it should contain "{text}"` /
`it should raise {error_type} with message containing "{message}"`
patterns to specific forms that don't collide with steps in
`execution_environment_steps.py` and `structural_validation_steps.py`;
add try/except in the `When I compute the virtual resource` step so the
exception-handling scenario can reach its `Then` step.
- Fix table headers in `features/resource_virtual_types.feature` so behave's
table parser sees a proper `| name | value |` header row instead of
treating the first data row as headers.
- Drop the now-unused E501 override for the deleted file from `pyproject.toml`.
- Add CHANGELOG.md entry under `[Unreleased]`.
Verified locally: unit_tests gate against `features/resource_virtual_types.feature`
passes 18/18 scenarios; lint and typecheck both green.
Refs: #8610
- Remove # type: ignore from resource_virtual_types_steps.py (zero tolerance)
- Replace all eval() calls with ast.literal_eval() and _parse_lambda_body() helper
- Fix step mismatch: 'the complex computed value should be correct'
- Fix trailing whitespace and import ordering (W293, I001, RUF100)
- Fix B011 assert False -> raise AssertionError()
- Fix UP035/UP045/UP046 modernisation in domain model and resource virtual module
- Fix RUF022 __all__ sorting in resource/__init__.py
- Fix E501 long lines in virtual_resource.py via per-file-ignores
- Assign PR milestone to v3.6.0
- Implement VirtualResource base class for abstract/computed resources
- Add MetricResource example for computed metrics
- Add APIEndpointResource example for API endpoints
- Implement comprehensive BDD tests for virtual resource types
- Full type annotations with Generic support
- Support for on-demand computation via compute_fn
- Support for kwargs passing to compute functions
Closes#8610
- Implement VirtualResource base class with name, description, compute_fn, and metadata
- Implement MetricResource example for computed metrics with unit support
- Implement APIEndpointResource example for API endpoints with HTTP method support
- Add comprehensive BDD tests with 20+ scenarios covering all functionality
- Support on-demand computation via compute_fn callable
- Support metadata management with with_metadata() method
- Full type annotations and Pydantic validation