feat(resources): implement virtual resource type base class for abstract/computed resources #10605
Merged
HAL9000
merged 5 commits from 2026-06-04 08:42:50 +00:00
feat/v3.6.0-virtual-resource-types into master
Labels
Clear labels
auto/needs-reevaluation
controller-managed
overdue
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
Needs Feedback
Signed-off: Owner
Signed-off: Scrum Master
Signed-off: Tech Lead
Spike
Controller deferred this PR; awaiting Phase 6+ scope-evaluator or operator re-enablement.
Auto-agents controller manages this PR/issue (see tools/controller/deploy/RUNBOOK.md). Remove this label to abandon controller management.
PR blocked by an open issue dependency. Operator must close the dep (or remove the dependency link) before the merge driver can act. Auto-cleared by merge_drive when no open deps remain.
Most recent merge cycle hit CI timeout. Driver excludes this PR while last merge_cycle row is < 30 min old; label persists thereafter as visible history.
Currently being processed by an implementer worker.
Currently being processed by the merge driver.
Currently being processed by a reviewer worker.
Merge driver heartbeat stale; pipeline halted. Closed automatically on next clean tick.
Detected master commit violating the strict merge invariant. Tracked as an issue (not a PR label); kept here for label completeness.
In-cycle escalation: most recent attempt ran at the Tier 0 slot (`tier-0`). Slot's model defined in .opencode/models/tiers.yaml.
In-cycle escalation: most recent attempt ran at the Tier 1 slot (`tier-1`). Slot's model defined in .opencode/models/tiers.yaml.
In-cycle escalation: most recent attempt ran at the Tier 2 slot (`tier-2`). Slot's model defined in .opencode/models/tiers.yaml. Gated behind IMPLEMENTER_ESCALATION_TIER2_ENABLED.
In-cycle escalation: most recent attempt ran at the Tier -1 slot (`tier-min`). Slot's model defined in .opencode/models/tiers.yaml. Suffix is ``-min`` (not ``--1``) so the Forgejo UI reads naturally.
Tracking issues used by the AI Automation system for agents to communicate and report.
Rebase conflict needs LLM conflict-resolver.
Failing CI needs implementer attention.
Documenting a driver incident or rollback.
Reviewer has APPROVED this PR and no later REQUEST_CHANGES is outstanding. The merge driver requires this label to even consider a PR for merging. Set by the reviewer worker on APPROVE; cleared on REQUEST_CHANGES.
Train repeatedly lost master-tempo races. Driver excludes via merge_cycle until cooldown elapses; label persists as visible history.
Revert PR backing out an invariant violation. Fast-tracked through the merge driver.
Sentinel PR duplicated from upstream into a personal fork by tools/duplicate_prs_to_fork.py for pipeline testing. Lives only in the fork; the canonical pipeline never sees it.
No implementer activity for N days. Flagged for human review. Auto-cleared on next push to head branch.
Repeatedly fails on current master (>= 3 ci-fail-on-rebased-sha releases in 12 h). Excluded from driver until human triage.
A ticket in a blocked state and unable to complete until some other task is completed first.
Bounty
$100
A bounty of $100 for any open-source contributor who provides a MR that solves this issue
Bounty
$1000
A bounty of $1000 for any open-source contributor who provides a MR that solves this issue
Bounty
$10000
A bounty of $10000 for any open-source contributor who provides a MR that solves this issue
Bounty
$20
A bounty of $20 for any open-source contributor who provides a MR that solves this issue
Bounty
$2000
A bounty of $2000 for any open-source contributor who provides a MR that solves this issue
Bounty
$250
A bounty of $250 for any open-source contributor who provides a MR that solves this issue
Bounty
$50
A bounty of $50 for any open-source contributor who provides a MR that solves this issue
Bounty
$500
A bounty of $500 for any open-source contributor who provides a MR that solves this issue
Bounty
$5000
A bounty of $5000 for any open-source contributor who provides a MR that solves this issue
Bounty
$750
A bounty of $750 for any open-source contributor who provides a MR that solves this issue
MoSCoW
Could have
Could have feature in order to satisfy the epic/legendary.
MoSCoW
Must have
Must have feature in order to satisfy the epic/legendary.
MoSCoW
Should have
Should have feature in order to satisfy the epic/legendary.
There are questions in the ticket that can not be completed until the project owner provides clarity.
Points
1
1 man-hours worth of work for an expert with no learning curve.
Points
13
13 man-hours worth of work for an expert with no learning curve.
Points
2
2 man-hours worth of work for an expert with no learning curve.
Points
21
21 man-hours worth of work for an expert with no learning curve.
Points
3
3 man-hours worth of work for an expert with no learning curve.
Points
34
34 man-hours worth of work for an expert with no learning curve.
Points
5
5 man-hours worth of work for an expert with no learning curve.
Points
55
55 man-hours worth of work for an expert with no learning curve.
Points
8
8 man-hours worth of work for an expert with no learning curve.
Points
88
88 man-hours worth of work for an expert with no learning curve.
Priority
Backlog
This ticket has backlogged priority and is not to be worked on yet
Priority
CI Blocker
Critical priority issue that blocks CI/CD pipeline and prevents PR merges
Priority
Critical
The priority is critical
Priority
High
The priority is high
Priority
Low
The priority is low
Priority
Medium
The priority is medium
When an epic or legendary is in review it must be signed off by owner, tech lead, and scrum master before being marked as completed.
When an epic or legendary is in review it must be signed off by owner, tech lead, and scrum master before being marked as completed.
When an epic or legendary is in review it must be signed off by owner, tech lead, and scrum master before being marked as completed.
A ticket for learning a tool or technology that is needed to be able to do future planning and design.
State
Completed
The ticket has been fully implemented, completed, and merged with the source code. This label should only be applied once a ticket is closed.
State
Duplicate
A ticket that represents the same content as an existing ticket.
State
In Progress
A ticket that is actively being developed.
State
In Review
A ticket that has had some code completed to implement but is waiting to pass peer review and is not yet merged in.
State
Paused
This ticket's work started but wasn't finished. It's on hold (likely in a feature branch) and will be resumed later, either due to a blocker or a delay.
State
Unverified
All new tickets start in this state. A developer may set it to show the ticket is unverified. This means we haven't agreed to work on it. It will either move to a verified state or be closed as wontdo.
State
Verified
The issue has been verified by a developer as legitimate. It will be worked on and verified tickets are now considered part of the backlog.
State
Wont Do
This ticket has been decided it wont be done. This may mean the bug has been determined to not be real (cant verify) or the feature is one we have decided we dont want to adopt.
Type
Automation
Any edits or discussion about the AI automated coding system.
Type
Bug
Something that doesnt work as intended.
Type
Discussion
Anytime a ticket represents a discussion about a subject and doesnt fall into one of the other categories.
Type
Documentation
An error or improvement needed in the documentation.
Type
Epic
Any first tier epic. That is, an epic which contains only issues as children and will not have sub-epics.
Type
Feature
Some new functionality not present.
Type
Legendary
A type of Epic which will contain other Epics.
Type
Refactor
A code change that restructures existing code without changing its external behavior.
Type
Support
Someone needs help using the project.
Type
Task
A generic task that doesnt fit into the other type categories.
Type
Testing
Work exclusively focusing on fixing or expanding testing.
Projects
Clear projects
No project
Assignees
aditya (Aditya Chhabra)
aleenaumair (Aleena Umair)
brent.edwards (Brent Edwards)
CoreRasurae (Luis Mendes)
drew (Drew Morris)
eugen.thaci (Eugen Thaci)
freemo (Jeffrey Phillips Freeman)
HAL9000 (HAL 9000)
HAL9001 (HAL9001)
hamza.khyari (Hamza Khyari)
hurui200320 (Rui Hu)
justin.morris
khird (Kyle Hird)
org.cleveragents
Clear assignees
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: cleveragents/cleveragents-core#10605
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Delete Branch "feat/v3.6.0-virtual-resource-types"
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
This PR implements a new
VirtualResourcebase class to support abstract and computed resources in the CleverAgents framework. Virtual resources enable the definition of resources that don't directly correspond to physical infrastructure but are derived from or computed based on other resources. The implementation includes concrete examples (MetricResourceandAPIEndpointResource) and comprehensive BDD test coverage.Changes
VirtualResource Base Class: Introduced a new abstract base class that provides the foundation for defining computed and abstract resources with support for:
MetricResource Implementation: A concrete implementation of
VirtualResourcefor representing computed metrics:APIEndpointResource Implementation: A concrete implementation of
VirtualResourcefor API endpoint abstractions:BDD Test Suite: Comprehensive behavior-driven development tests covering:
Testing
The implementation includes extensive BDD tests that verify:
All tests follow the Gherkin syntax for clear, readable behavior specifications.
Issue Reference
Closes #8610
Automated by CleverAgents Bot
Agent: pr-creator
This PR implements the VirtualResource base class and two concrete implementations for abstract/computed resources.
BLOCKING ISSUES:
type: ignore VIOLATION — features/steps/resource_virtual_types_steps.py contains a # type: ignore comment. ZERO tolerance for # type: ignore per CONTRIBUTING.md Type Safety rule.
eval() USAGE — features/steps/resource_virtual_types_steps.py uses eval() in 4 locations to parse Gherkin values. This is a security anti-pattern and triggers S307 bandit warnings. Replace with ast.literal_eval() or explicit parsing.
CI LINT FAILING — lint check is red. Must fix before review can complete.
CI COVERAGE SKIPPED — Coverage did not run for this PR despite 1595 new lines of code. Per company policy, coverage must pass before merge.
PR MILESTONE NULL — Issue #8610 is in milestone v3.6.0 but PR milestone is null. Assign correctly.
NON-BLOCKING SUGGESTIONS:
CI Status:
@@ -0,0 +114,4 @@@then("the computed value should be {expected}")def step_check_computed_value(context: object, expected: str) -> None:eval() used here for parsing Gherkin values. This is a security anti-pattern (S307). Replace with ast.literal_eval() or explicit parsing. Multiple occurrences across both step files.
@@ -0,0 +215,4 @@compute_fn = eval(compute_fn_str) # noqa: S307resource = MetricResource(name=name,FAIL: # type: ignore comment on this line. Zero tolerance for # type: ignore per CONTRIBUTING.md Type Safety rule. Remove this suppression by adding proper type annotations.
Review posted as REQUEST_CHANGES. Blocking issues:
# type: ignoreviolation in features/steps/resource_virtual_types_steps.py (zero tolerance per CONTRIBUTING.md)eval()usage in test step definitions (security anti-pattern)Plus non-blocking suggestions for trailing newlines, code organization, and interface consistency.
Automated by CleverAgents Bot
Supervisor: PR Review | Agent: pr-review-worker
Implementation Attempt — Tier 1: kimi — Success
Addressed all blocking issues raised in the REQUEST_CHANGES review:
Blocking issues resolved:
# type: ignoreremoved —resource_virtual_types_steps.pyline 177: replacedcompute_fn=fn # type: ignorewithnon_callable: Any = fnto satisfy Pyright without suppression.eval()replaced — All 5eval()calls replaced with safe alternatives:lambda: <literal>) → new_parse_lambda_body()helper usingast.literal_eval()on the body expressionast.literal_eval()directly# noqa: S307directives removed (they were unused since S307 is not enabled)assert False→raise AssertionError()__all__sorting inresource/__init__.pyvirtual_resource_types_steps.py"the complex computed value should be correct"but step definition had"the computed value should be correct"— this was causing unit_tests to fail.Quality gates run locally:
Files changed:
features/steps/resource_virtual_types_steps.py— removed# type: ignore, replaced alleval()with safe alternatives, fixed all lint issues, fixed step mismatchfeatures/steps/virtual_resource_types_steps.py— removed unusedCallableimportsrc/cleveragents/domain/models/core/virtual_resource.py— modernised imports (UP035/UP045), fixed long linessrc/cleveragents/resource/__init__.py— sorted__all__(RUF022)src/cleveragents/resource/virtual.py— modernised to PEP 695 type params (UP046), removed ABC (B024)pyproject.toml— added per-file-ignore for E501 in virtual_resource.py docstringAutomated by CleverAgents Bot
Supervisor: Implementation | Agent: implementation-worker
Re-Review: Still Blocking Issues Remain
Thank you for addressing the previous review feedback. This re-review covers both verification of prior items and a full fresh evaluation of the current state.
✅ Prior Feedback: Addressed Items
# type: ignoreremoved — Confirmed. Zero occurrences in any file in the diff. Well done.eval()replaced — Confirmed. Alleval()calls replaced withast.literal_eval()via the safe_parse_lambda_body()helper. The remaining# noqa: E731comments are for lambda variable assignments (not security issues) and are acceptable.CI / lint (pull_request)is now SUCCESS. ✓v3.6.0. ✓❌ Blocking Issues That Must Be Fixed
1. CI
unit_testsSTILL FAILING (Introduced by this PR)CI / unit_tests (pull_request): FAILURE. Based on code analysis, a logic bug insrc/cleveragents/resource/virtual.pyname validation is causing test failures.In
resource/virtual.py, the validation strips hyphens and underscores before checkingisalnum(). This means"123-invalid"becomes"123invalid"which passes the check—so no error is raised. The BDD testReject invalid resource namespasses"123-invalid"and expectsValueError("invalid characters"), but validation silently passes. Test fails.Fix: Use a regex that validates the full name pattern, e.g.:
2. CI
coverageSTILL FAILING (Introduced by this PR)CI / coverage (pull_request): FAILURE. Coverage depends on unit tests passing. Since unit tests are failing, coverage cannot complete. Fix the unit test failures first, then verify coverage meets the ≥97% threshold.3. CI
e2e_testsFAILINGCI / e2e_tests (pull_request): FAILURE. This is a required CI gate. The previous CI run showede2e_tests: SUCCESS, meaning this has regressed with the current HEAD commit. Investigate and resolve.4. CHANGELOG entry missing
This PR adds 1,660 lines of new production code. Per CONTRIBUTING.md, every PR must include a CHANGELOG entry. There is no entry in
CHANGELOG.mdfor issue #8610 or the virtual resource feature.Add under
[Unreleased] > Added:5. Commit footers missing
ISSUES CLOSED: #NOf the 4 commits in this PR, only commit
8e9068efhasCloses #8610. The other 3 commits (e562bab6,92c7a866,9559b7d5) have noISSUES CLOSED: #NorRefs: #Nfooter. Per CONTRIBUTING.md, every commit footer must include this reference. AddRefs: #8610to all fix commits.⚠️ Non-Blocking Suggestions
6. Dual VirtualResource Implementations with Inconsistent Interfaces
The PR introduces two separate
VirtualResourceimplementations with different interfaces:src/cleveragents/resource/virtual.py: generic Python class,APIEndpointResource(endpoint_url=""),MetricResource(unit="")src/cleveragents/domain/models/core/virtual_resource.py: Pydantic BaseModel,APIEndpointResource(method="GET"),MetricResource(unit=None), pluswith_metadata()These have different base classes, attribute names, default values, validation behavior, exception wrapping, and metadata support. Consider documenting the intentional split or unifying where possible.
7. Branch naming convention not followed
Branch
feat/v3.6.0-virtual-resource-typesshould befeature/m6-virtual-resource-typesper CONTRIBUTING.md (feature/mN-<name>with milestone number N, not semver string). Non-blocking for this PR but please follow conventions in future.CI Status Summary
Please fix the 5 blocking issues and push a new commit. Once CI is green, this PR will be ready for re-review.
Automated by CleverAgents Bot
Supervisor: PR Review | Agent: pr-review-worker
@@ -0,0 +53,4 @@ValueError: If name is empty or invalid.TypeError: If compute_fn is not callable."""if not name or not isinstance(name, str):BLOCKING: Name validation logic has a bug causing unit test failures.
The current validation:
Stripping hyphens and underscores before calling
.isalnum()means"123-invalid"becomes"123invalid"which passes the check. The BDD testScenario: Reject invalid resource namespasses"123-invalid"and expectsValueErrorwith"invalid characters", but no error is raised. This is causing theunit_testsCI failure.How to fix: Use a regex that validates the full name pattern without stripping special characters:
This correctly rejects
"123-invalid"(starts with a digit), aligning with the test expectation.Automated by CleverAgents Bot
Supervisor: PR Review | Agent: pr-review-worker
Review posted as REQUEST_CHANGES. Blocking issues remaining:
unit_testsfailing — name validation bug inresource/virtual.py:"123-invalid".replace("-","").replace("_","")="123invalid"passes.isalnum()so theReject invalid resource namesBDD test never gets the expectedValueError.coveragefailing — depends on unit tests; fix unit tests first.e2e_testsfailing — regressed since prior run (was SUCCESS before); investigate.ISSUES CLOSED: #N— 3 of 4 commits (e562bab6,92c7a866,9559b7d5) lackRefs: #8610footer.Addressed from prior review:
# type: ignoreremoved ✅,eval()replaced withast.literal_eval()✅, lint CI fixed ✅, PR milestone set to v3.6.0 ✅.Automated by CleverAgents Bot
Supervisor: PR Review | Agent: pr-review-worker
🌱 Grooming: proceed — PR cleared for processing.
(check
no_duplicates, categoryno_duplicates)PR #10605 implements a novel VirtualResource base class for abstract/computed resources (with MetricResource and APIEndpointResource examples). Scanned all 415 open PRs for topical overlap: closest candidates (#10592, #10647, #10784) address resource types, cloud infrastructure, and extension interfaces, but none target the virtual/computed resource abstraction. No duplicate found.
📋 Estimate: tier 1.
Primary CI failure is a clear AmbiguousStep crash in the newly added features/steps/virtual_resource_types_steps.py: the step at line 66 uses {description} as a catch-all parameter that Behave's regex engine matches against the longer "without metadata" variant at line 152, causing a step registry collision at import time. Fix requires understanding Behave step-matching semantics and restructuring the conflicting step texts within the 1660-line newly introduced feature. Scope is single-file but non-mechanical — BDD pattern knowledge needed. The e2e WF14 failure is infrastructure/pre-existing and unrelated to this PR's virtual resource changes; implementer should triage but it is unlikely to require code changes in this PR.
9559b7d533toe761c82f5a(attempt #3, tier 1)
🔧 Implementer attempt —
rebased.Pushed 1 commit:
e761c82.e761c82f5atoe73de648ae(attempt #4, tier 1)
🔧 Implementer attempt —
rebased.Pushed 1 commit:
e73de64.e73de648aeto63f89bbe56(attempt #7, tier 1)
🔧 Implementer attempt —
rebased.Pushed 1 commit:
63f89bb.63f89bbe56to1ff7b4d061(attempt #8, tier 1)
🔧 Implementer attempt —
rebased.Pushed 1 commit:
1ff7b4d.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✅ Approved
Reviewed at commit
883c7a4.Confidence: high.
Claimed by
merge_drive.py(pid 3317687) until2026-06-04T09:53:35.725916+00:00.This claim is advisory and will be released when the cycle ends, or after the TTL by a sibling driver's expired-claim sweep.
883c7a4f3eto36a6bd6011Approved by the controller reviewer stage (workflow 245).