feat(resource): add resource type model + schema loader #261

Closed
opened 2026-02-22 23:40:39 +00:00 by freemo · 0 comments
Owner

Metadata

  • Commit: feat(resource): add resource type model + schema loader
  • Branch: feature/m1-resource-type-schema

Subtasks

  • Create src/cleveragents/domain/models/core/resource_type.py with ResourceTypeName, ResourceTypeArgument, ResourceTypeSpec, ResourceKind enum (physical/virtual), and SandboxStrategy enum (git_worktree/copy_on_write/transaction_rollback/snapshot/none). Done: Day 7, February 15, 2026
  • Define ResourceTypeArgument fields per spec (name, type, required, description, default, validation_pattern) and validate name to map to CLI --<name>. Done: Day 7, February 15, 2026
  • Add ResourceTypeSpec fields per spec: user_addable, cli_args, child_types, parent_types, auto_discovery, equivalence (virtual only), handler, sandbox_strategy, and capabilities (read/write/sandbox/checkpoint). Done: Day 7, February 15, 2026
  • Enforce namespaced name rules for custom types; allow unnamespaced built-ins (e.g., git-checkout, fs-directory) via a dedicated built_in flag. Done: Day 7, February 15, 2026
  • Add docs/schema/resource_type.schema.yaml mirroring the spec JSON schema (fields, enums, required list, cliArg/childType defs, and conditional equivalence requirement for virtual types). Done: Day 7, February 15, 2026
  • Add resource type YAML loader in src/cleveragents/resource/schema.py with ${ENV_VAR} interpolation, schema version guardrails, and explicit error messages for invalid names, constraints, and cli_args definitions. Done: Day 7, February 15, 2026
  • Add docs/reference/resource_type_model.md with minimal examples and validation rules (include git-checkout + fs-directory and physical/virtual notes). Done: Day 7, February 15, 2026
  • Tests (Behave): Add scenarios for resource type name validation, cli_args parsing, child_types/parent_types constraint validation, and unnamespaced built-in allowance. Done: Day 7, February 15, 2026
  • Tests (Behave): Add schema loader scenarios for env var interpolation, version mismatch, and handler metadata validation. Done: Day 7, February 15, 2026
  • Tests (Robot): Add Robot test that loads a ResourceType YAML fixture and asserts required fields are present. Done: Day 7, February 15, 2026
  • Tests (ASV): Add benchmarks/resource_type_schema_bench.py for YAML validation throughput. Done: Day 7, February 15, 2026
  • Tests (ASV): Add benchmarks/resource_type_model_bench.py for resource type validation and constraint checks. Done: Day 7, February 15, 2026
  • Run nox (all default sessions, including benchmark), fix any errors if needed ensuring nox passes. Done: Day 7, February 15, 2026
  • 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

Section: ### Section 4: Projects & Resources [WORKSTREAM B - Hamza Lead]
Status: Completed

## Metadata - **Commit**: `feat(resource): add resource type model + schema loader` - **Branch**: `feature/m1-resource-type-schema` ## Subtasks - [x] Create `src/cleveragents/domain/models/core/resource_type.py` with `ResourceTypeName`, `ResourceTypeArgument`, `ResourceTypeSpec`, `ResourceKind` enum (physical/virtual), and `SandboxStrategy` enum (git_worktree/copy_on_write/transaction_rollback/snapshot/none). Done: Day 7, February 15, 2026 - [x] Define `ResourceTypeArgument` fields per spec (`name`, `type`, `required`, `description`, `default`, `validation_pattern`) and validate `name` to map to CLI `--<name>`. Done: Day 7, February 15, 2026 - [x] Add `ResourceTypeSpec` fields per spec: `user_addable`, `cli_args`, `child_types`, `parent_types`, `auto_discovery`, `equivalence` (virtual only), `handler`, `sandbox_strategy`, and `capabilities` (read/write/sandbox/checkpoint). Done: Day 7, February 15, 2026 - [x] Enforce namespaced name rules for custom types; allow unnamespaced built-ins (e.g., `git-checkout`, `fs-directory`) via a dedicated `built_in` flag. Done: Day 7, February 15, 2026 - [x] Add `docs/schema/resource_type.schema.yaml` mirroring the spec JSON schema (fields, enums, required list, `cliArg`/`childType` defs, and conditional `equivalence` requirement for virtual types). Done: Day 7, February 15, 2026 - [x] Add resource type YAML loader in `src/cleveragents/resource/schema.py` with `${ENV_VAR}` interpolation, schema version guardrails, and explicit error messages for invalid names, constraints, and `cli_args` definitions. Done: Day 7, February 15, 2026 - [x] Add `docs/reference/resource_type_model.md` with minimal examples and validation rules (include git-checkout + fs-directory and physical/virtual notes). Done: Day 7, February 15, 2026 - [x] Tests (Behave): Add scenarios for resource type name validation, `cli_args` parsing, `child_types`/`parent_types` constraint validation, and unnamespaced built-in allowance. Done: Day 7, February 15, 2026 - [x] Tests (Behave): Add schema loader scenarios for env var interpolation, version mismatch, and handler metadata validation. Done: Day 7, February 15, 2026 - [x] Tests (Robot): Add Robot test that loads a ResourceType YAML fixture and asserts required fields are present. Done: Day 7, February 15, 2026 - [x] Tests (ASV): Add `benchmarks/resource_type_schema_bench.py` for YAML validation throughput. Done: Day 7, February 15, 2026 - [x] Tests (ASV): Add `benchmarks/resource_type_model_bench.py` for resource type validation and constraint checks. Done: Day 7, February 15, 2026 - [x] Run `nox` (all default sessions, including benchmark), fix any errors if needed ensuring nox passes. Done: Day 7, February 15, 2026 - [x] 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 **Section**: ### Section 4: Projects & Resources [WORKSTREAM B - Hamza Lead] **Status**: Completed
freemo added this to the v3.0.0 milestone 2026-02-22 23:40:39 +00:00
freemo self-assigned this 2026-02-22 23:40:39 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Blocks
#353 Epic: Projects & Resources B0-B2
cleveragents/cleveragents-core
Depends on
#68 feature/m1-resource-type-schema
cleveragents/cleveragents-core
Reference
cleveragents/cleveragents-core#261
No description provided.