feat(tool): add tool and validation domain models #277

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

Metadata

  • Commit: feat(tool): add tool and validation domain models
  • Branch: feature/m3-tool-domain

Subtasks

  • Add Tool model in src/cleveragents/domain/models/core/tool.py with namespaced name, description, source type, input/output JSON schema, and capability metadata (read_only, writes, checkpointable, side_effects).
  • Enforce capability consistency (read_only implies writes=false; validation of conflicting flags).
  • Add ResourceBinding model with slot definitions, binding modes (context, static, parameter), and required access level (read_only/read_write).
  • Add Validation model as Tool subtype with mode, wraps, and transform fields; enforce read-only constraints.
  • Enforce Validation output schema includes passed: bool plus optional data/message, and force writes=false, checkpointable=false, read_only=true for validations.
  • Enforce namespace collision rules (a Validation and Tool cannot share the same namespaced name).
  • Require transform when wraps is set and validate that wraps references an existing Tool name.
  • Add enums for ToolSource, ToolType (tool/validation), and ValidationMode.
  • Add docs/schema/tool.schema.yaml and docs/schema/validation.schema.yaml with required fields, wraps/transform rules, and resource binding definitions.
  • Add YAML loader via Tool.from_config() and Validation.from_config() class methods that validate fields, normalize keys, and return Tool/Validation domain models. (Implemented on models directly rather than separate schema.py to match action.py pattern.)
  • Add example configs under examples/tools/ and examples/validations/ (plain tool, validation, wrapped validation) for tests.
  • Add docs/reference/tool_model.md and docs/reference/validation_model.md with examples.
  • Tests (Behave): Add features/tool_model.feature for schema validation, resource binding rules, validation constraints, and YAML loader errors. (60 scenarios, 163 steps)
  • Tests (ASV): Add benchmarks/tool_model_bench.py for schema validation throughput (model + YAML loader). (3 benchmark suites)
  • Run nox (all default sessions, including benchmark). NOTE: lint 0 findings, typecheck 0 errors, unit_tests 2293 scenarios passed (0 failures), integration_tests 208 passed (0 failures).
  • Verify coverage >=97% via nox -s coverage_report. Coverage is 97% overall (tool.py 99% coverage).

Section: ### Section 5: Actors, Skills & Tool Execution [WORKSTREAM C - Aditya Lead]
Status: Completed

## Metadata - **Commit**: `feat(tool): add tool and validation domain models` - **Branch**: `feature/m3-tool-domain` ## Subtasks - [x] Add `Tool` model in `src/cleveragents/domain/models/core/tool.py` with namespaced name, description, source type, input/output JSON schema, and capability metadata (`read_only`, `writes`, `checkpointable`, `side_effects`). - [x] Enforce capability consistency (`read_only` implies `writes=false`; validation of conflicting flags). - [x] Add `ResourceBinding` model with slot definitions, binding modes (context, static, parameter), and required `access` level (`read_only`/`read_write`). - [x] Add `Validation` model as Tool subtype with `mode`, `wraps`, and `transform` fields; enforce read-only constraints. - [x] Enforce Validation output schema includes `passed: bool` plus optional `data`/`message`, and force `writes=false`, `checkpointable=false`, `read_only=true` for validations. - [x] Enforce namespace collision rules (a Validation and Tool cannot share the same namespaced name). - [x] Require `transform` when `wraps` is set and validate that `wraps` references an existing Tool name. - [x] Add enums for ToolSource, ToolType (tool/validation), and ValidationMode. - [x] Add `docs/schema/tool.schema.yaml` and `docs/schema/validation.schema.yaml` with required fields, `wraps`/`transform` rules, and resource binding definitions. - [x] Add YAML loader via `Tool.from_config()` and `Validation.from_config()` class methods that validate fields, normalize keys, and return Tool/Validation domain models. (Implemented on models directly rather than separate schema.py to match action.py pattern.) - [x] Add example configs under `examples/tools/` and `examples/validations/` (plain tool, validation, wrapped validation) for tests. - [x] Add `docs/reference/tool_model.md` and `docs/reference/validation_model.md` with examples. - [x] Tests (Behave): Add `features/tool_model.feature` for schema validation, resource binding rules, validation constraints, and YAML loader errors. (60 scenarios, 163 steps) - [x] Tests (ASV): Add `benchmarks/tool_model_bench.py` for schema validation throughput (model + YAML loader). (3 benchmark suites) - [x] Run `nox` (all default sessions, including benchmark). NOTE: lint 0 findings, typecheck 0 errors, unit_tests 2293 scenarios passed (0 failures), integration_tests 208 passed (0 failures). - [x] Verify coverage >=97% via `nox -s coverage_report`. Coverage is 97% overall (tool.py 99% coverage). **Section**: ### Section 5: Actors, Skills & Tool Execution [WORKSTREAM C - Aditya Lead] **Status**: Completed
freemo added this to the v3.1.0 milestone 2026-02-22 23:40:49 +00:00
freemo self-assigned this 2026-02-22 23:40:49 +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
#354 Epic: Actor & Skill Schema + CLI (C0)
cleveragents/cleveragents-core
Depends on
Reference
cleveragents/cleveragents-core#277
No description provided.