feat(resource): add virtual core resource types
CI / benchmark-publish (pull_request) Has been skipped
CI / lint (pull_request) Successful in 18s
CI / build (pull_request) Successful in 18s
CI / quality (pull_request) Successful in 29s
CI / typecheck (pull_request) Successful in 42s
CI / security (pull_request) Successful in 52s
CI / unit_tests (pull_request) Successful in 2m51s
CI / integration_tests (pull_request) Successful in 3m27s
CI / docker (pull_request) Successful in 56s
CI / e2e_tests (pull_request) Successful in 3m51s
CI / coverage (pull_request) Successful in 6m12s
CI / benchmark-regression (pull_request) Successful in 37m29s

Add 6 built-in virtual resource types (file, directory, commit, branch, tag,
tree) with equivalence metadata for content-hash and git-object identity
matching.

- YAML configs under examples/resource-types/
- Bootstrap registration with virtual types hidden from resource add scaffolding
- Equivalence criteria per spec (content_hash, merkle_hash, git SHA identity)
- Behave tests (83 scenarios), Robot tests, ASV benchmarks
- Documentation in docs/reference/resource_types_builtin.md

ISSUES CLOSED: #329
This commit is contained in:
2026-03-10 00:20:59 +00:00
parent 758dafd8fa
commit c14ce65d61
20 changed files with 1723 additions and 18 deletions
@@ -0,0 +1,81 @@
"""ASV benchmarks for virtual core resource type YAML loading."""
from __future__ import annotations
from pathlib import Path
from typing import Any
import yaml
from cleveragents.domain.models.core.resource_type import ResourceTypeSpec
from cleveragents.resource.schema import ResourceTypeConfigSchema
_EXAMPLES_DIR = Path(__file__).resolve().parent.parent / "examples" / "resource-types"
_VIRTUAL_CORE_NAMES = ("file", "directory", "commit", "branch", "tag", "tree")
_VIRTUAL_YAML_PATHS = {
name: _EXAMPLES_DIR / f"{name}.yaml" for name in _VIRTUAL_CORE_NAMES
}
class TimeVirtualCoreSchemaLoad:
"""Benchmark virtual core resource type YAML schema loading."""
timeout = 60
def setup(self) -> None:
self.schema_cls = ResourceTypeConfigSchema
self.paths = dict(_VIRTUAL_YAML_PATHS)
def time_load_file_yaml(self) -> None:
self.schema_cls.from_yaml_file(self.paths["file"])
def time_load_directory_yaml(self) -> None:
self.schema_cls.from_yaml_file(self.paths["directory"])
def time_load_all_virtual_core(self) -> None:
for path in self.paths.values():
self.schema_cls.from_yaml_file(path)
class TimeVirtualCoreDomainModelLoad:
"""Benchmark virtual core resource type domain model creation."""
timeout = 60
def setup(self) -> None:
self.spec_cls = ResourceTypeSpec
self.configs: dict[str, dict[str, Any]] = {}
for name, path in _VIRTUAL_YAML_PATHS.items():
with open(path, encoding="utf-8") as f:
self.configs[name] = yaml.safe_load(f)
def time_file_from_config(self) -> None:
self.spec_cls.from_config(self.configs["file"])
def time_commit_from_config(self) -> None:
self.spec_cls.from_config(self.configs["commit"])
def time_all_virtual_core_from_config(self) -> None:
for config in self.configs.values():
self.spec_cls.from_config(config)
class TimeVirtualCoreCliDict:
"""Benchmark as_cli_dict rendering for virtual core types."""
timeout = 60
def setup(self) -> None:
self.specs: dict[str, ResourceTypeSpec] = {}
for name, path in _VIRTUAL_YAML_PATHS.items():
with open(path, encoding="utf-8") as f:
config: dict[str, Any] = yaml.safe_load(f)
self.specs[name] = ResourceTypeSpec.from_config(config)
def time_file_cli_dict(self) -> None:
self.specs["file"].as_cli_dict()
def time_all_virtual_core_cli_dict(self) -> None:
for spec in self.specs.values():
spec.as_cli_dict()