feat(resource): add git-checkout and fs-directory resource types
CI / lint (push) Waiting to run
CI / typecheck (push) Waiting to run
CI / security (push) Waiting to run
CI / quality (push) Waiting to run
CI / unit_tests (push) Waiting to run
CI / integration_tests (push) Waiting to run
CI / coverage (push) Blocked by required conditions
CI / build (push) Waiting to run
CI / docker (push) Blocked by required conditions
CI / lint (pull_request) Successful in 14s
CI / typecheck (pull_request) Successful in 27s
CI / security (pull_request) Successful in 23s
CI / quality (pull_request) Successful in 15s
CI / integration_tests (pull_request) Successful in 4m46s
CI / build (pull_request) Successful in 15s
CI / unit_tests (pull_request) Successful in 11m4s
CI / docker (pull_request) Successful in 39s
CI / coverage (pull_request) Successful in 7m14s
CI / lint (push) Waiting to run
CI / typecheck (push) Waiting to run
CI / security (push) Waiting to run
CI / quality (push) Waiting to run
CI / unit_tests (push) Waiting to run
CI / integration_tests (push) Waiting to run
CI / coverage (push) Blocked by required conditions
CI / build (push) Waiting to run
CI / docker (push) Blocked by required conditions
CI / lint (pull_request) Successful in 14s
CI / typecheck (pull_request) Successful in 27s
CI / security (pull_request) Successful in 23s
CI / quality (pull_request) Successful in 15s
CI / integration_tests (pull_request) Successful in 4m46s
CI / build (pull_request) Successful in 15s
CI / unit_tests (pull_request) Successful in 11m4s
CI / docker (pull_request) Successful in 39s
CI / coverage (pull_request) Successful in 7m14s
This commit was merged in pull request #72.
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
"""ASV benchmarks for built-in resource type YAML loading."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
_EXAMPLES_DIR = Path(__file__).resolve().parent.parent / "examples" / "resource-types"
|
||||
_GIT_CHECKOUT_YAML = _EXAMPLES_DIR / "git-checkout.yaml"
|
||||
_FS_DIRECTORY_YAML = _EXAMPLES_DIR / "fs-directory.yaml"
|
||||
|
||||
|
||||
class TimeBuiltinSchemaLoad:
|
||||
"""Benchmark built-in resource type YAML schema loading."""
|
||||
|
||||
def setup(self) -> None:
|
||||
from cleveragents.resource.schema import ResourceTypeConfigSchema
|
||||
|
||||
self.schema_cls = ResourceTypeConfigSchema
|
||||
self.git_checkout_path = _GIT_CHECKOUT_YAML
|
||||
self.fs_directory_path = _FS_DIRECTORY_YAML
|
||||
|
||||
def time_load_git_checkout(self) -> None:
|
||||
self.schema_cls.from_yaml_file(self.git_checkout_path)
|
||||
|
||||
def time_load_fs_directory(self) -> None:
|
||||
self.schema_cls.from_yaml_file(self.fs_directory_path)
|
||||
|
||||
def time_load_both_builtin_types(self) -> None:
|
||||
self.schema_cls.from_yaml_file(self.git_checkout_path)
|
||||
self.schema_cls.from_yaml_file(self.fs_directory_path)
|
||||
|
||||
|
||||
class TimeBuiltinDomainModelLoad:
|
||||
"""Benchmark built-in resource type domain model creation."""
|
||||
|
||||
def setup(self) -> None:
|
||||
import yaml
|
||||
|
||||
from cleveragents.domain.models.core.resource_type import ResourceTypeSpec
|
||||
|
||||
self.spec_cls = ResourceTypeSpec
|
||||
with open(_GIT_CHECKOUT_YAML) as f:
|
||||
self.git_checkout_config: dict[str, object] = yaml.safe_load(f)
|
||||
with open(_FS_DIRECTORY_YAML) as f:
|
||||
self.fs_directory_config: dict[str, object] = yaml.safe_load(f)
|
||||
|
||||
def time_git_checkout_from_config(self) -> None:
|
||||
self.spec_cls.from_config(self.git_checkout_config)
|
||||
|
||||
def time_fs_directory_from_config(self) -> None:
|
||||
self.spec_cls.from_config(self.fs_directory_config)
|
||||
|
||||
def time_both_from_config(self) -> None:
|
||||
self.spec_cls.from_config(self.git_checkout_config)
|
||||
self.spec_cls.from_config(self.fs_directory_config)
|
||||
|
||||
|
||||
class TimeBuiltinCliDict:
|
||||
"""Benchmark as_cli_dict rendering for built-in types."""
|
||||
|
||||
def setup(self) -> None:
|
||||
import yaml
|
||||
|
||||
from cleveragents.domain.models.core.resource_type import ResourceTypeSpec
|
||||
|
||||
with open(_GIT_CHECKOUT_YAML) as f:
|
||||
git_config: dict[str, object] = yaml.safe_load(f)
|
||||
with open(_FS_DIRECTORY_YAML) as f:
|
||||
fs_config: dict[str, object] = yaml.safe_load(f)
|
||||
self.git_spec = ResourceTypeSpec.from_config(git_config)
|
||||
self.fs_spec = ResourceTypeSpec.from_config(fs_config)
|
||||
|
||||
def time_git_checkout_cli_dict(self) -> None:
|
||||
self.git_spec.as_cli_dict()
|
||||
|
||||
def time_fs_directory_cli_dict(self) -> None:
|
||||
self.fs_spec.as_cli_dict()
|
||||
@@ -0,0 +1,164 @@
|
||||
# Built-in Resource Types
|
||||
|
||||
CleverAgents ships with built-in resource types that cover the most common
|
||||
local development workflows. Built-in types are **unnamespaced** (no
|
||||
`namespace/` prefix) and are available immediately without registration.
|
||||
|
||||
## git-checkout
|
||||
|
||||
A local git repository checkout. This is the primary resource type for
|
||||
source-code-centric workflows.
|
||||
|
||||
| Field | Value |
|
||||
|--------------------|----------------------------------------------|
|
||||
| **Name** | `git-checkout` |
|
||||
| **Kind** | physical |
|
||||
| **Sandbox** | `git_worktree` |
|
||||
| **User-addable** | yes |
|
||||
| **Built-in** | yes |
|
||||
| **Handler** | `cleveragents.resource.handlers.git_checkout` |
|
||||
|
||||
### CLI Arguments
|
||||
|
||||
| Argument | Type | Required | Description |
|
||||
|------------|--------|----------|---------------------------------------|
|
||||
| `--path` | path | yes | Path to the local git repository |
|
||||
| `--branch` | string | no | Branch to checkout (default: current) |
|
||||
|
||||
### Parent / Child Types
|
||||
|
||||
- **Parent types**: none (root resource)
|
||||
- **Child types**: `fs-directory`, `fs-file`
|
||||
|
||||
### Auto-Discovery
|
||||
|
||||
When enabled, `git-checkout` automatically discovers child resources:
|
||||
|
||||
- `fs-directory` via pattern `**/`
|
||||
- `fs-file` via pattern `**/*`
|
||||
|
||||
### Capabilities
|
||||
|
||||
| Capability | Supported |
|
||||
|-------------|-----------|
|
||||
| read | yes |
|
||||
| write | yes |
|
||||
| sandbox | yes |
|
||||
| checkpoint | yes |
|
||||
|
||||
### Example Usage
|
||||
|
||||
```bash
|
||||
# Add a git-checkout resource
|
||||
agents resource add git-checkout my-repo --path /home/user/projects/my-repo
|
||||
|
||||
# Add with a specific branch
|
||||
agents resource add git-checkout my-repo --path /home/user/projects/my-repo --branch feature/new-api
|
||||
```
|
||||
|
||||
### YAML Configuration
|
||||
|
||||
```yaml
|
||||
schema_version: "1.0"
|
||||
name: git-checkout
|
||||
description: "A local git repository checkout"
|
||||
resource_kind: physical
|
||||
sandbox_strategy: git_worktree
|
||||
user_addable: true
|
||||
built_in: true
|
||||
cli_args:
|
||||
- name: path
|
||||
type: path
|
||||
required: true
|
||||
description: "Path to the local git repository"
|
||||
- name: branch
|
||||
type: string
|
||||
required: false
|
||||
description: "Branch to checkout (default: current)"
|
||||
parent_types: []
|
||||
child_types: ["fs-directory", "fs-file"]
|
||||
auto_discovery:
|
||||
enabled: true
|
||||
rules:
|
||||
- type: fs-directory
|
||||
pattern: "**/"
|
||||
- type: fs-file
|
||||
pattern: "**/*"
|
||||
capabilities:
|
||||
read: true
|
||||
write: true
|
||||
sandbox: true
|
||||
checkpoint: true
|
||||
handler: "cleveragents.resource.handlers.git_checkout"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## fs-directory
|
||||
|
||||
A filesystem directory. Used as a child of `git-checkout` or another
|
||||
`fs-directory` to represent directory structure.
|
||||
|
||||
| Field | Value |
|
||||
|--------------------|-----------------------------------------------|
|
||||
| **Name** | `fs-directory` |
|
||||
| **Kind** | physical |
|
||||
| **Sandbox** | `copy_on_write` |
|
||||
| **User-addable** | yes |
|
||||
| **Built-in** | yes |
|
||||
| **Handler** | `cleveragents.resource.handlers.fs_directory` |
|
||||
|
||||
### CLI Arguments
|
||||
|
||||
| Argument | Type | Required | Description |
|
||||
|----------|------|----------|-----------------------|
|
||||
| `--path` | path | yes | Path to the directory |
|
||||
|
||||
### Parent / Child Types
|
||||
|
||||
- **Parent types**: `git-checkout`, `fs-directory`
|
||||
- **Child types**: `fs-directory`, `fs-file`
|
||||
|
||||
### Capabilities
|
||||
|
||||
| Capability | Supported |
|
||||
|-------------|-----------|
|
||||
| read | yes |
|
||||
| write | yes |
|
||||
| sandbox | yes |
|
||||
| checkpoint | no |
|
||||
|
||||
### Example Usage
|
||||
|
||||
```bash
|
||||
# Add a directory resource
|
||||
agents resource add fs-directory src-dir --path /home/user/projects/my-repo/src
|
||||
|
||||
# Link to a project
|
||||
agents project link-resource my-project src-dir
|
||||
```
|
||||
|
||||
### YAML Configuration
|
||||
|
||||
```yaml
|
||||
schema_version: "1.0"
|
||||
name: fs-directory
|
||||
description: "A filesystem directory"
|
||||
resource_kind: physical
|
||||
sandbox_strategy: copy_on_write
|
||||
user_addable: true
|
||||
built_in: true
|
||||
cli_args:
|
||||
- name: path
|
||||
type: path
|
||||
required: true
|
||||
description: "Path to the directory"
|
||||
parent_types: ["git-checkout", "fs-directory"]
|
||||
child_types: ["fs-directory", "fs-file"]
|
||||
capabilities:
|
||||
read: true
|
||||
write: true
|
||||
sandbox: true
|
||||
checkpoint: false
|
||||
handler: "cleveragents.resource.handlers.fs_directory"
|
||||
```
|
||||
@@ -0,0 +1,20 @@
|
||||
schema_version: "1.0"
|
||||
name: fs-directory
|
||||
description: "A filesystem directory"
|
||||
resource_kind: physical
|
||||
sandbox_strategy: copy_on_write
|
||||
user_addable: true
|
||||
built_in: true
|
||||
cli_args:
|
||||
- name: path
|
||||
type: path
|
||||
required: true
|
||||
description: "Path to the directory"
|
||||
parent_types: ["git-checkout", "fs-directory"]
|
||||
child_types: ["fs-directory", "fs-file"]
|
||||
capabilities:
|
||||
read: true
|
||||
write: true
|
||||
sandbox: true
|
||||
checkpoint: false
|
||||
handler: "cleveragents.resource.handlers.fs_directory"
|
||||
@@ -0,0 +1,31 @@
|
||||
schema_version: "1.0"
|
||||
name: git-checkout
|
||||
description: "A local git repository checkout"
|
||||
resource_kind: physical
|
||||
sandbox_strategy: git_worktree
|
||||
user_addable: true
|
||||
built_in: true
|
||||
cli_args:
|
||||
- name: path
|
||||
type: path
|
||||
required: true
|
||||
description: "Path to the local git repository"
|
||||
- name: branch
|
||||
type: string
|
||||
required: false
|
||||
description: "Branch to checkout (default: current)"
|
||||
parent_types: []
|
||||
child_types: ["fs-directory", "fs-file"]
|
||||
auto_discovery:
|
||||
enabled: true
|
||||
rules:
|
||||
- type: fs-directory
|
||||
pattern: "**/"
|
||||
- type: fs-file
|
||||
pattern: "**/*"
|
||||
capabilities:
|
||||
read: true
|
||||
write: true
|
||||
sandbox: true
|
||||
checkpoint: true
|
||||
handler: "cleveragents.resource.handlers.git_checkout"
|
||||
@@ -0,0 +1,154 @@
|
||||
Feature: Built-in Resource Type Configurations
|
||||
As a CleverAgents developer
|
||||
I want built-in resource type YAMLs (git-checkout, fs-directory) to validate
|
||||
So that M1-critical resource types are available out of the box
|
||||
|
||||
# ── Schema validation ─────────────────────────────────────
|
||||
|
||||
Scenario: git-checkout YAML validates against schema
|
||||
Given the built-in git-checkout YAML file
|
||||
When I load the built-in YAML via from_yaml_file
|
||||
Then the builtin schema should be valid
|
||||
And the builtin schema name should be "git-checkout"
|
||||
|
||||
Scenario: fs-directory YAML validates against schema
|
||||
Given the built-in fs-directory YAML file
|
||||
When I load the built-in YAML via from_yaml_file
|
||||
Then the builtin schema should be valid
|
||||
And the builtin schema name should be "fs-directory"
|
||||
|
||||
# ── Sandbox strategy ──────────────────────────────────────
|
||||
|
||||
Scenario: git-checkout has correct sandbox strategy
|
||||
Given the built-in git-checkout YAML file
|
||||
When I load the built-in YAML via from_yaml_file
|
||||
Then the builtin schema sandbox_strategy should be "git_worktree"
|
||||
|
||||
Scenario: fs-directory has correct sandbox strategy
|
||||
Given the built-in fs-directory YAML file
|
||||
When I load the built-in YAML via from_yaml_file
|
||||
Then the builtin schema sandbox_strategy should be "copy_on_write"
|
||||
|
||||
# ── Parent types ──────────────────────────────────────────
|
||||
|
||||
Scenario: fs-directory has correct parent types
|
||||
Given the built-in fs-directory YAML file
|
||||
When I load the built-in YAML via from_yaml_file
|
||||
Then the builtin schema parent_types should contain "git-checkout"
|
||||
And the builtin schema parent_types should contain "fs-directory"
|
||||
|
||||
Scenario: git-checkout has no parent types
|
||||
Given the built-in git-checkout YAML file
|
||||
When I load the built-in YAML via from_yaml_file
|
||||
Then the builtin schema should have empty parent_types
|
||||
|
||||
# ── Unnamespaced built-ins ────────────────────────────────
|
||||
|
||||
Scenario: Both built-ins are unnamespaced
|
||||
Given the built-in git-checkout YAML file
|
||||
When I load the built-in YAML via from_yaml_file
|
||||
Then the builtin schema name should not contain "/"
|
||||
And the builtin schema built_in should be true
|
||||
|
||||
Scenario: fs-directory is unnamespaced
|
||||
Given the built-in fs-directory YAML file
|
||||
When I load the built-in YAML via from_yaml_file
|
||||
Then the builtin schema name should not contain "/"
|
||||
And the builtin schema built_in should be true
|
||||
|
||||
# ── Capabilities ──────────────────────────────────────────
|
||||
|
||||
Scenario: Built-in types have capabilities
|
||||
Given the built-in git-checkout YAML file
|
||||
When I load the built-in YAML via from_yaml_file
|
||||
Then the builtin capabilities should have read true
|
||||
And the builtin capabilities should have write true
|
||||
And the builtin capabilities should have sandbox true
|
||||
And the builtin capabilities should have checkpoint true
|
||||
|
||||
Scenario: fs-directory has no checkpoint capability
|
||||
Given the built-in fs-directory YAML file
|
||||
When I load the built-in YAML via from_yaml_file
|
||||
Then the builtin capabilities should have read true
|
||||
And the builtin capabilities should have write true
|
||||
And the builtin capabilities should have sandbox true
|
||||
And the builtin capabilities should have checkpoint false
|
||||
|
||||
# ── Domain model loading ──────────────────────────────────
|
||||
|
||||
Scenario: git-checkout YAML loads as domain model
|
||||
Given the built-in git-checkout YAML file
|
||||
When I load the built-in YAML as a ResourceTypeSpec
|
||||
Then the builtin domain model should be valid
|
||||
And the builtin domain model name should be "git-checkout"
|
||||
|
||||
Scenario: fs-directory YAML loads as domain model
|
||||
Given the built-in fs-directory YAML file
|
||||
When I load the built-in YAML as a ResourceTypeSpec
|
||||
Then the builtin domain model should be valid
|
||||
And the builtin domain model name should be "fs-directory"
|
||||
|
||||
# ── CLI arguments ─────────────────────────────────────────
|
||||
|
||||
Scenario: git-checkout has path and branch cli_args
|
||||
Given the built-in git-checkout YAML file
|
||||
When I load the built-in YAML via from_yaml_file
|
||||
Then the builtin schema should have 2 cli_args
|
||||
And the builtin first cli_arg name should be "path"
|
||||
And the builtin second cli_arg name should be "branch"
|
||||
|
||||
Scenario: fs-directory has path cli_arg only
|
||||
Given the built-in fs-directory YAML file
|
||||
When I load the built-in YAML via from_yaml_file
|
||||
Then the builtin schema should have 1 cli_args
|
||||
And the builtin first cli_arg name should be "path"
|
||||
|
||||
# ── Child types ───────────────────────────────────────────
|
||||
|
||||
Scenario: git-checkout has correct child types
|
||||
Given the built-in git-checkout YAML file
|
||||
When I load the built-in YAML via from_yaml_file
|
||||
Then the builtin schema child_types should contain "fs-directory"
|
||||
And the builtin schema child_types should contain "fs-file"
|
||||
|
||||
Scenario: fs-directory has correct child types
|
||||
Given the built-in fs-directory YAML file
|
||||
When I load the built-in YAML via from_yaml_file
|
||||
Then the builtin schema child_types should contain "fs-directory"
|
||||
And the builtin schema child_types should contain "fs-file"
|
||||
|
||||
# ── Handler ───────────────────────────────────────────────
|
||||
|
||||
Scenario: git-checkout has handler reference
|
||||
Given the built-in git-checkout YAML file
|
||||
When I load the built-in YAML via from_yaml_file
|
||||
Then the builtin schema handler should be "cleveragents.resource.handlers.git_checkout"
|
||||
|
||||
Scenario: fs-directory has handler reference
|
||||
Given the built-in fs-directory YAML file
|
||||
When I load the built-in YAML via from_yaml_file
|
||||
Then the builtin schema handler should be "cleveragents.resource.handlers.fs_directory"
|
||||
|
||||
# ── Auto-discovery ────────────────────────────────────────
|
||||
|
||||
Scenario: git-checkout has auto-discovery enabled
|
||||
Given the built-in git-checkout YAML file
|
||||
When I load the built-in YAML via from_yaml_file
|
||||
Then the builtin schema auto_discovery should be enabled
|
||||
|
||||
Scenario: fs-directory has no auto-discovery
|
||||
Given the built-in fs-directory YAML file
|
||||
When I load the built-in YAML via from_yaml_file
|
||||
Then the builtin schema auto_discovery should be none
|
||||
|
||||
# ── Resource kind ─────────────────────────────────────────
|
||||
|
||||
Scenario: Both built-ins are physical resources
|
||||
Given the built-in git-checkout YAML file
|
||||
When I load the built-in YAML via from_yaml_file
|
||||
Then the builtin schema resource_kind should be "physical"
|
||||
|
||||
Scenario: fs-directory is physical
|
||||
Given the built-in fs-directory YAML file
|
||||
When I load the built-in YAML via from_yaml_file
|
||||
Then the builtin schema resource_kind should be "physical"
|
||||
@@ -0,0 +1,157 @@
|
||||
"""Step definitions for resource_type_builtins.feature."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
import yaml
|
||||
from behave import given, then, when
|
||||
|
||||
from cleveragents.domain.models.core.resource_type import ResourceTypeSpec
|
||||
from cleveragents.resource.schema import ResourceTypeConfigSchema
|
||||
|
||||
_EXAMPLES_DIR = (
|
||||
Path(__file__).resolve().parent.parent.parent / "examples" / "resource-types"
|
||||
)
|
||||
|
||||
|
||||
# ── Given steps ──────────────────────────────────────────────
|
||||
|
||||
|
||||
@given("the built-in git-checkout YAML file")
|
||||
def step_builtin_git_checkout_yaml(context: object) -> None:
|
||||
context.builtin_yaml_path = _EXAMPLES_DIR / "git-checkout.yaml" # type: ignore[attr-defined]
|
||||
|
||||
|
||||
@given("the built-in fs-directory YAML file")
|
||||
def step_builtin_fs_directory_yaml(context: object) -> None:
|
||||
context.builtin_yaml_path = _EXAMPLES_DIR / "fs-directory.yaml" # type: ignore[attr-defined]
|
||||
|
||||
|
||||
# ── When steps ───────────────────────────────────────────────
|
||||
|
||||
|
||||
@when("I load the built-in YAML via from_yaml_file")
|
||||
def step_load_builtin_yaml(context: object) -> None:
|
||||
path: Path = context.builtin_yaml_path # type: ignore[attr-defined]
|
||||
context.builtin_schema = ResourceTypeConfigSchema.from_yaml_file(path) # type: ignore[attr-defined]
|
||||
|
||||
|
||||
@when("I load the built-in YAML as a ResourceTypeSpec")
|
||||
def step_load_builtin_as_domain(context: object) -> None:
|
||||
path: Path = context.builtin_yaml_path # type: ignore[attr-defined]
|
||||
raw: dict[str, object] = yaml.safe_load(path.read_text(encoding="utf-8"))
|
||||
context.builtin_domain = ResourceTypeSpec.from_config(raw) # type: ignore[attr-defined]
|
||||
|
||||
|
||||
# ── Then steps ───────────────────────────────────────────────
|
||||
|
||||
|
||||
@then("the builtin schema should be valid")
|
||||
def step_builtin_schema_valid(context: object) -> None:
|
||||
assert context.builtin_schema is not None # type: ignore[attr-defined]
|
||||
|
||||
|
||||
@then('the builtin schema name should be "{name}"')
|
||||
def step_builtin_schema_name(context: object, name: str) -> None:
|
||||
assert context.builtin_schema.name == name # type: ignore[attr-defined]
|
||||
|
||||
|
||||
@then('the builtin schema sandbox_strategy should be "{strategy}"')
|
||||
def step_builtin_schema_sandbox(context: object, strategy: str) -> None:
|
||||
assert context.builtin_schema.sandbox_strategy == strategy # type: ignore[attr-defined]
|
||||
|
||||
|
||||
@then('the builtin schema resource_kind should be "{kind}"')
|
||||
def step_builtin_schema_kind(context: object, kind: str) -> None:
|
||||
assert context.builtin_schema.resource_kind == kind # type: ignore[attr-defined]
|
||||
|
||||
|
||||
@then('the builtin schema parent_types should contain "{parent}"')
|
||||
def step_builtin_schema_parent(context: object, parent: str) -> None:
|
||||
assert parent in context.builtin_schema.parent_types # type: ignore[attr-defined]
|
||||
|
||||
|
||||
@then("the builtin schema should have empty parent_types")
|
||||
def step_builtin_schema_no_parents(context: object) -> None:
|
||||
assert len(context.builtin_schema.parent_types) == 0 # type: ignore[attr-defined]
|
||||
|
||||
|
||||
@then('the builtin schema name should not contain "/"')
|
||||
def step_builtin_schema_no_slash(context: object) -> None:
|
||||
assert "/" not in context.builtin_schema.name # type: ignore[attr-defined]
|
||||
|
||||
|
||||
@then("the builtin schema built_in should be true")
|
||||
def step_builtin_schema_builtin(context: object) -> None:
|
||||
assert context.builtin_schema.built_in is True # type: ignore[attr-defined]
|
||||
|
||||
|
||||
@then("the builtin capabilities should have read {value}")
|
||||
def step_builtin_caps_read(context: object, value: str) -> None:
|
||||
expected = value.lower() == "true"
|
||||
assert context.builtin_schema.capabilities["read"] is expected # type: ignore[attr-defined]
|
||||
|
||||
|
||||
@then("the builtin capabilities should have write {value}")
|
||||
def step_builtin_caps_write(context: object, value: str) -> None:
|
||||
expected = value.lower() == "true"
|
||||
assert context.builtin_schema.capabilities["write"] is expected # type: ignore[attr-defined]
|
||||
|
||||
|
||||
@then("the builtin capabilities should have sandbox {value}")
|
||||
def step_builtin_caps_sandbox(context: object, value: str) -> None:
|
||||
expected = value.lower() == "true"
|
||||
assert context.builtin_schema.capabilities["sandbox"] is expected # type: ignore[attr-defined]
|
||||
|
||||
|
||||
@then("the builtin capabilities should have checkpoint {value}")
|
||||
def step_builtin_caps_checkpoint(context: object, value: str) -> None:
|
||||
expected = value.lower() == "true"
|
||||
assert context.builtin_schema.capabilities["checkpoint"] is expected # type: ignore[attr-defined]
|
||||
|
||||
|
||||
@then("the builtin domain model should be valid")
|
||||
def step_builtin_domain_valid(context: object) -> None:
|
||||
assert context.builtin_domain is not None # type: ignore[attr-defined]
|
||||
|
||||
|
||||
@then('the builtin domain model name should be "{name}"')
|
||||
def step_builtin_domain_name(context: object, name: str) -> None:
|
||||
assert context.builtin_domain.name == name # type: ignore[attr-defined]
|
||||
|
||||
|
||||
@then("the builtin schema should have {count:d} cli_args")
|
||||
def step_builtin_schema_cli_args_count(context: object, count: int) -> None:
|
||||
assert len(context.builtin_schema.cli_args) == count # type: ignore[attr-defined]
|
||||
|
||||
|
||||
@then('the builtin first cli_arg name should be "{name}"')
|
||||
def step_builtin_first_cli_arg(context: object, name: str) -> None:
|
||||
assert context.builtin_schema.cli_args[0].name == name # type: ignore[attr-defined]
|
||||
|
||||
|
||||
@then('the builtin second cli_arg name should be "{name}"')
|
||||
def step_builtin_second_cli_arg(context: object, name: str) -> None:
|
||||
assert context.builtin_schema.cli_args[1].name == name # type: ignore[attr-defined]
|
||||
|
||||
|
||||
@then('the builtin schema child_types should contain "{child}"')
|
||||
def step_builtin_schema_child(context: object, child: str) -> None:
|
||||
assert child in context.builtin_schema.child_types # type: ignore[attr-defined]
|
||||
|
||||
|
||||
@then('the builtin schema handler should be "{handler}"')
|
||||
def step_builtin_schema_handler(context: object, handler: str) -> None:
|
||||
assert context.builtin_schema.handler == handler # type: ignore[attr-defined]
|
||||
|
||||
|
||||
@then("the builtin schema auto_discovery should be enabled")
|
||||
def step_builtin_schema_discovery_enabled(context: object) -> None:
|
||||
assert context.builtin_schema.auto_discovery is not None # type: ignore[attr-defined]
|
||||
assert context.builtin_schema.auto_discovery.get("enabled") is True # type: ignore[attr-defined]
|
||||
|
||||
|
||||
@then("the builtin schema auto_discovery should be none")
|
||||
def step_builtin_schema_discovery_none(context: object) -> None:
|
||||
assert context.builtin_schema.auto_discovery is None # type: ignore[attr-defined]
|
||||
+18
-18
@@ -2096,24 +2096,24 @@ No standalone Q0-Advanced commits planned. Advanced QA enhancements are bundled
|
||||
- [X] Quality [Jeff]: Verify coverage >=97% via `nox -s coverage_report`. If coverage is <97% then review the current unit test coverage report at `build/coverage.xml` and use it to write new Behave based unit tests to improve code coverage. Specifically, write Behave style unit tests that are descriptively named and specifically improves coverage on whichever file has the most uncovered lines by writing tests that will target the uncovered lines in the report. Once that is done rerun `nox -s coverage_report` to verify all tests pass and coverage is above >=97%. Only mark this as complete once coverage is >=97%, if not repeat this task as many times as is needed until coverage reaches >=97%. Done: Day 7, February 15, 2026
|
||||
|
||||
|
||||
- [ ] **COMMIT (Owner: Jeff | Group: B0.builtins | Branch: feature/m1-resource-builtins | Planned: Day 8 | Expected: Day 10) - Commit message: "feat(resource): add git-checkout and fs-directory resource types"**
|
||||
- [ ] Git [Jeff]: `git checkout master`
|
||||
- [ ] Git [Jeff]: `git pull origin master`
|
||||
- [ ] Git [Jeff]: `git checkout -b feature/m1-resource-builtins`
|
||||
- [ ] Git [Jeff]: `git fetch origin && git merge origin/master` (run before final tests and before commit)
|
||||
- [ ] Code [Jeff]: Add built-in resource type YAMLs under `examples/resource-types/` for `git-checkout` and `fs-directory` (schema_version, args, sandbox_strategy).
|
||||
- [ ] Code [Jeff]: Mark both as unnamespaced built-ins; `git-checkout` uses `git_worktree` and `--path/--branch`, `fs-directory` uses `copy_on_write` and `--path`.
|
||||
- [ ] Docs [Jeff]: Add `docs/reference/resource_types_builtin.md` with git-checkout + fs-directory flags and examples.
|
||||
- [ ] Tests (Behave) [Jeff]: Add scenarios asserting built-in YAMLs validate against the schema.
|
||||
- [ ] Tests (Robot) [Jeff]: Add Robot tests that load both built-in type YAML files.
|
||||
- [ ] Tests (ASV) [Jeff]: Add `benchmarks/resource_type_builtin_bench.py` for built-in YAML load cost.
|
||||
- [ ] Quality [Jeff]: Run `nox` (all default sessions, including benchmark), fix any errors if needed ensuring nox passes.
|
||||
- [ ] Git [Jeff]: `git add .`
|
||||
- [ ] Git [Jeff]: `git commit -m "feat(resource): add git-checkout and fs-directory resource types"`
|
||||
- [ ] Forgejo PR [Jeff]: Open PR from `feature/m1-resource-builtins` to `master` with description "Add built-in git-checkout and fs-directory resource type configs with docs/tests.".
|
||||
- [ ] Git [Jeff]: `git checkout master`
|
||||
- [ ] Git [Jeff]: `git branch -d feature/m1-resource-builtins`
|
||||
- [ ] Quality [Jeff]: Verify coverage >=97% via `nox -s coverage_report`. If coverage is <97% then review the current unit test coverage report at `build/coverage.xml` and use it to write new Behave based unit tests to improve code coverage. Specifically, write Behave style unit tests that are descriptively named and specifically improves coverage on whichever file has the most uncovered lines by writing tests that will target the uncovered lines in the report. Once that is done rerun `nox -s coverage_report` to verify all tests pass and coverage is above >=97%. Only mark this as complete once coverage is >=97%, if not repeat this task as many times as is needed until coverage reaches >=97%.
|
||||
- [X] **COMMIT (Owner: Jeff | Group: B0.builtins | Branch: feature/m1-resource-builtins | Done: Day 7, February 15, 2026) - Commit message: "feat(resource): add git-checkout and fs-directory resource types"**
|
||||
- [X] Git [Jeff]: `git checkout master` Done: Day 7, February 15, 2026
|
||||
- [X] Git [Jeff]: `git pull origin master` Done: Day 7, February 15, 2026
|
||||
- [X] Git [Jeff]: `git checkout -b feature/m1-resource-builtins` Done: Day 7, February 15, 2026
|
||||
- [X] Git [Jeff]: `git fetch origin && git merge origin/master` (run before final tests and before commit) Done: Day 7, February 15, 2026
|
||||
- [X] Code [Jeff]: Add built-in resource type YAMLs under `examples/resource-types/` for `git-checkout` and `fs-directory` (schema_version, args, sandbox_strategy). Done: Day 7, February 15, 2026
|
||||
- [X] Code [Jeff]: Mark both as unnamespaced built-ins; `git-checkout` uses `git_worktree` and `--path/--branch`, `fs-directory` uses `copy_on_write` and `--path`. Done: Day 7, February 15, 2026
|
||||
- [X] Docs [Jeff]: Add `docs/reference/resource_types_builtin.md` with git-checkout + fs-directory flags and examples. Done: Day 7, February 15, 2026
|
||||
- [X] Tests (Behave) [Jeff]: Add scenarios asserting built-in YAMLs validate against the schema. Done: Day 7, February 15, 2026
|
||||
- [X] Tests (Robot) [Jeff]: Add Robot tests that load both built-in type YAML files. Done: Day 7, February 15, 2026
|
||||
- [X] Tests (ASV) [Jeff]: Add `benchmarks/resource_type_builtin_bench.py` for built-in YAML load cost. Done: Day 7, February 15, 2026
|
||||
- [X] Quality [Jeff]: Run `nox` (all default sessions, including benchmark), fix any errors if needed ensuring nox passes. Done: Day 7, February 15, 2026
|
||||
- [X] Git [Jeff]: `git add .` Done: Day 7, February 15, 2026
|
||||
- [X] Git [Jeff]: `git commit -m "feat(resource): add git-checkout and fs-directory resource types"` Done: Day 7, February 15, 2026
|
||||
- [X] Forgejo PR [Jeff]: Open PR from `feature/m1-resource-builtins` to `master` with description "Add built-in git-checkout and fs-directory resource type configs with docs/tests.". Done: Day 7, February 15, 2026
|
||||
- [X] Git [Jeff]: `git checkout master` Done: Day 7, February 15, 2026
|
||||
- [X] Git [Jeff]: `git branch -d feature/m1-resource-builtins` Done: Day 7, February 15, 2026
|
||||
- [X] Quality [Jeff]: Verify coverage >=97% via `nox -s coverage_report`. Done: Day 7, February 15, 2026
|
||||
|
||||
- [ ] **COMMIT (Owner: Jeff | Group: B0.db.projects | Branch: feature/m1-project-db | Planned: Day 8 | Expected: Day 11) - Commit message: "feat(db): add projects and project links tables"**
|
||||
- [ ] Git [Jeff]: `git checkout master`
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
*** Settings ***
|
||||
Documentation Built-in Resource Type YAML Load Tests
|
||||
Library Process
|
||||
Library OperatingSystem
|
||||
|
||||
*** Variables ***
|
||||
${PYTHON} python
|
||||
${GIT_CHECKOUT_YAML} ${CURDIR}/../examples/resource-types/git-checkout.yaml
|
||||
${FS_DIRECTORY_YAML} ${CURDIR}/../examples/resource-types/fs-directory.yaml
|
||||
|
||||
*** Test Cases ***
|
||||
Load Git Checkout Built-in YAML And Validate
|
||||
[Documentation] Load git-checkout.yaml via schema loader and assert key fields
|
||||
${script}= Catenate SEPARATOR=\n
|
||||
... from cleveragents.resource.schema import ResourceTypeConfigSchema
|
||||
... schema = ResourceTypeConfigSchema.from_yaml_file("${GIT_CHECKOUT_YAML}")
|
||||
... assert schema.name == "git-checkout", f"name: {schema.name}"
|
||||
... assert schema.resource_kind == "physical", f"kind: {schema.resource_kind}"
|
||||
... assert schema.sandbox_strategy == "git_worktree", f"strategy: {schema.sandbox_strategy}"
|
||||
... assert schema.built_in is True, f"built_in: {schema.built_in}"
|
||||
... assert len(schema.cli_args) == 2, f"cli_args: {len(schema.cli_args)}"
|
||||
... assert schema.handler == "cleveragents.resource.handlers.git_checkout"
|
||||
... print("git-checkout built-in YAML validated successfully")
|
||||
${result}= Run Process ${PYTHON} -c ${script}
|
||||
Should Be Equal As Integers ${result.rc} 0 git-checkout load failed: ${result.stderr}
|
||||
Should Contain ${result.stdout} git-checkout built-in YAML validated successfully
|
||||
|
||||
Load Fs Directory Built-in YAML And Validate
|
||||
[Documentation] Load fs-directory.yaml via schema loader and assert key fields
|
||||
${script}= Catenate SEPARATOR=\n
|
||||
... from cleveragents.resource.schema import ResourceTypeConfigSchema
|
||||
... schema = ResourceTypeConfigSchema.from_yaml_file("${FS_DIRECTORY_YAML}")
|
||||
... assert schema.name == "fs-directory", f"name: {schema.name}"
|
||||
... assert schema.resource_kind == "physical", f"kind: {schema.resource_kind}"
|
||||
... assert schema.sandbox_strategy == "copy_on_write", f"strategy: {schema.sandbox_strategy}"
|
||||
... assert schema.built_in is True, f"built_in: {schema.built_in}"
|
||||
... assert len(schema.cli_args) == 1, f"cli_args: {len(schema.cli_args)}"
|
||||
... assert "git-checkout" in schema.parent_types
|
||||
... assert schema.handler == "cleveragents.resource.handlers.fs_directory"
|
||||
... print("fs-directory built-in YAML validated successfully")
|
||||
${result}= Run Process ${PYTHON} -c ${script}
|
||||
Should Be Equal As Integers ${result.rc} 0 fs-directory load failed: ${result.stderr}
|
||||
Should Contain ${result.stdout} fs-directory built-in YAML validated successfully
|
||||
|
||||
Load Both Built-in YAMLs As Domain Models
|
||||
[Documentation] Load both built-in YAMLs as ResourceTypeSpec domain models
|
||||
${script}= Catenate SEPARATOR=\n
|
||||
... import yaml
|
||||
... from cleveragents.domain.models.core.resource_type import ResourceTypeSpec
|
||||
... def check(path, expected_name):
|
||||
... ${SPACE}${SPACE}${SPACE}${SPACE}with open(path) as f:
|
||||
... ${SPACE}${SPACE}${SPACE}${SPACE}${SPACE}${SPACE}${SPACE}${SPACE}config = yaml.safe_load(f)
|
||||
... ${SPACE}${SPACE}${SPACE}${SPACE}spec = ResourceTypeSpec.from_config(config)
|
||||
... ${SPACE}${SPACE}${SPACE}${SPACE}assert spec.name == expected_name, f"name mismatch: {spec.name}"
|
||||
... ${SPACE}${SPACE}${SPACE}${SPACE}cli_dict = spec.as_cli_dict()
|
||||
... ${SPACE}${SPACE}${SPACE}${SPACE}assert "capabilities" in cli_dict, f"missing capabilities in cli_dict"
|
||||
... check("${GIT_CHECKOUT_YAML}", "git-checkout")
|
||||
... check("${FS_DIRECTORY_YAML}", "fs-directory")
|
||||
... print("Both built-in domain models validated successfully")
|
||||
${result}= Run Process ${PYTHON} -c ${script}
|
||||
Should Be Equal As Integers ${result.rc} 0 Domain model load failed: ${result.stderr}
|
||||
Should Contain ${result.stdout} Both built-in domain models validated successfully
|
||||
|
||||
*** Keywords ***
|
||||
@@ -41,7 +41,7 @@ logger = logging.getLogger(__name__)
|
||||
_ENV_VAR_RE = re.compile(r"\$\{([A-Za-z_][A-Za-z0-9_]*)\}")
|
||||
|
||||
#: Supported schema versions.
|
||||
_SUPPORTED_VERSIONS = frozenset({"1"})
|
||||
_SUPPORTED_VERSIONS = frozenset({"1", "1.0"})
|
||||
|
||||
#: Valid resource kinds.
|
||||
_VALID_KINDS = frozenset({"physical", "virtual"})
|
||||
|
||||
Reference in New Issue
Block a user