feat(validation): implement tool wrapping runtime (wraps + transform delegation) #555

Merged
freemo merged 1 commit from feature/m5-tool-wrapping-runtime into master 2026-03-04 18:42:41 +00:00
Owner

Summary

Implements the runtime execution engine for validation tool wrapping as specified in docs/specification.md § Core Concepts > Validation > Tool Wrapping. This adds the missing runtime layer that actually performs delegation when a validation has wraps set.

Changes

  • WrappedToolExecutor — Resolves wraps references and delegates execution to the wrapped tool. Supports composable wrapping chains (wrapper wraps another wrapper) with cycle detection and depth limiting (max 10 levels).
  • ArgumentMapper — Applies argument_mapping configuration to translate arguments between the wrapper's schema and the wrapped tool's schema. Supports forwarded parameter names and literal fixed values.
  • TransformExecutor — Runs the user-supplied transform function in a sandboxed Python environment with restricted builtins (no imports, no filesystem, no network). Validates that transforms return proper validation-format dicts with a passed boolean.
  • Error typesWrappedToolNotFoundError, WrappingCycleError, WrappingDepthExceededError, TransformExecutionError with clear diagnostic messages.
  • Package exports — All new types exported via cleveragents.tool.__init__.

Testing

  • 20 Behave scenarios (features/tool_wrapping_runtime.feature): argument mapping (identity, configured, literal values, error cases), transform execution (valid, sandbox, missing function, invalid return), wrapping delegation (simple, chained, missing tool, cycle detection, context inheritance, type validation).
  • 8 Robot Framework integration tests (robot/tool_wrapping_runtime.robot): end-to-end smoke tests for imports, mapping, transform, delegation, and error handling.
  • ASV benchmarks (benchmarks/tool_wrapping_bench.py): delegation overhead for identity mapping, configured mapping, transform execution, single and chained delegation.

Quality Gates

  • nox -s lint — passes
  • nox -s typecheck — 0 errors, 0 warnings (Pyright strict, no # type: ignore)
  • nox -s unit_tests — 8154 scenarios passed (including 20 new)

Closes #543

## Summary Implements the runtime execution engine for validation tool wrapping as specified in `docs/specification.md` § Core Concepts > Validation > Tool Wrapping. This adds the missing runtime layer that actually performs delegation when a validation has `wraps` set. ### Changes - **`WrappedToolExecutor`** — Resolves `wraps` references and delegates execution to the wrapped tool. Supports composable wrapping chains (wrapper wraps another wrapper) with cycle detection and depth limiting (max 10 levels). - **`ArgumentMapper`** — Applies `argument_mapping` configuration to translate arguments between the wrapper's schema and the wrapped tool's schema. Supports forwarded parameter names and literal fixed values. - **`TransformExecutor`** — Runs the user-supplied `transform` function in a sandboxed Python environment with restricted builtins (no imports, no filesystem, no network). Validates that transforms return proper validation-format dicts with a `passed` boolean. - **Error types** — `WrappedToolNotFoundError`, `WrappingCycleError`, `WrappingDepthExceededError`, `TransformExecutionError` with clear diagnostic messages. - **Package exports** — All new types exported via `cleveragents.tool.__init__`. ### Testing - **20 Behave scenarios** (`features/tool_wrapping_runtime.feature`): argument mapping (identity, configured, literal values, error cases), transform execution (valid, sandbox, missing function, invalid return), wrapping delegation (simple, chained, missing tool, cycle detection, context inheritance, type validation). - **8 Robot Framework integration tests** (`robot/tool_wrapping_runtime.robot`): end-to-end smoke tests for imports, mapping, transform, delegation, and error handling. - **ASV benchmarks** (`benchmarks/tool_wrapping_bench.py`): delegation overhead for identity mapping, configured mapping, transform execution, single and chained delegation. ### Quality Gates - `nox -s lint` — passes - `nox -s typecheck` — 0 errors, 0 warnings (Pyright strict, no `# type: ignore`) - `nox -s unit_tests` — 8154 scenarios passed (including 20 new) Closes #543
freemo added this to the v3.4.0 milestone 2026-03-04 03:37:05 +00:00
freemo force-pushed feature/m5-tool-wrapping-runtime from 85603ae5a9
Some checks failed
CI / lint (pull_request) Successful in 14s
CI / typecheck (pull_request) Successful in 32s
CI / security (pull_request) Successful in 29s
CI / quality (pull_request) Successful in 15s
CI / benchmark-publish (pull_request) Has been skipped
CI / build (pull_request) Successful in 17s
CI / unit_tests (pull_request) Successful in 2m5s
CI / integration_tests (pull_request) Successful in 2m57s
CI / coverage (pull_request) Failing after 4m25s
CI / docker (pull_request) Successful in 2m49s
CI / benchmark-regression (pull_request) Successful in 29m3s
to 9a7795a5e9
All checks were successful
CI / lint (pull_request) Successful in 19s
CI / typecheck (pull_request) Successful in 33s
CI / security (pull_request) Successful in 29s
CI / quality (pull_request) Successful in 15s
CI / benchmark-publish (pull_request) Has been skipped
CI / build (pull_request) Successful in 14s
CI / unit_tests (pull_request) Successful in 2m2s
CI / integration_tests (pull_request) Successful in 3m3s
CI / coverage (pull_request) Successful in 4m15s
CI / docker (pull_request) Successful in 1m47s
CI / benchmark-regression (pull_request) Successful in 25m12s
2026-03-04 16:55:09 +00:00
Compare
freemo scheduled this pull request to auto merge when all checks succeed 2026-03-04 17:28:36 +00:00
freemo force-pushed feature/m5-tool-wrapping-runtime from 9a7795a5e9
All checks were successful
CI / lint (pull_request) Successful in 19s
CI / typecheck (pull_request) Successful in 33s
CI / security (pull_request) Successful in 29s
CI / quality (pull_request) Successful in 15s
CI / benchmark-publish (pull_request) Has been skipped
CI / build (pull_request) Successful in 14s
CI / unit_tests (pull_request) Successful in 2m2s
CI / integration_tests (pull_request) Successful in 3m3s
CI / coverage (pull_request) Successful in 4m15s
CI / docker (pull_request) Successful in 1m47s
CI / benchmark-regression (pull_request) Successful in 25m12s
to 646f27218b
All checks were successful
CI / lint (pull_request) Successful in 15s
CI / typecheck (pull_request) Successful in 32s
CI / security (pull_request) Successful in 29s
CI / quality (pull_request) Successful in 15s
CI / benchmark-publish (pull_request) Has been skipped
CI / build (pull_request) Successful in 13s
CI / unit_tests (pull_request) Successful in 2m2s
CI / integration_tests (pull_request) Successful in 3m2s
CI / coverage (pull_request) Successful in 4m6s
CI / docker (pull_request) Successful in 39s
CI / benchmark-regression (pull_request) Successful in 28m52s
2026-03-04 17:28:45 +00:00
Compare
freemo force-pushed feature/m5-tool-wrapping-runtime from 646f27218b
All checks were successful
CI / lint (pull_request) Successful in 15s
CI / typecheck (pull_request) Successful in 32s
CI / security (pull_request) Successful in 29s
CI / quality (pull_request) Successful in 15s
CI / benchmark-publish (pull_request) Has been skipped
CI / build (pull_request) Successful in 13s
CI / unit_tests (pull_request) Successful in 2m2s
CI / integration_tests (pull_request) Successful in 3m2s
CI / coverage (pull_request) Successful in 4m6s
CI / docker (pull_request) Successful in 39s
CI / benchmark-regression (pull_request) Successful in 28m52s
to 93e3893d69
All checks were successful
CI / lint (pull_request) Successful in 14s
CI / typecheck (pull_request) Successful in 34s
CI / security (pull_request) Successful in 29s
CI / quality (pull_request) Successful in 15s
CI / benchmark-publish (pull_request) Has been skipped
CI / build (pull_request) Successful in 14s
CI / unit_tests (pull_request) Successful in 2m4s
CI / integration_tests (pull_request) Successful in 2m50s
CI / coverage (pull_request) Successful in 4m15s
CI / docker (pull_request) Successful in 42s
CI / lint (push) Successful in 12s
CI / typecheck (push) Successful in 31s
CI / quality (push) Successful in 16s
CI / security (push) Successful in 31s
CI / build (push) Successful in 16s
CI / unit_tests (push) Successful in 3m23s
CI / benchmark-regression (push) Has been skipped
CI / docker (push) Successful in 42s
CI / integration_tests (push) Successful in 4m11s
CI / coverage (push) Successful in 4m8s
CI / benchmark-publish (push) Successful in 16m5s
CI / benchmark-regression (pull_request) Successful in 29m59s
2026-03-04 18:21:22 +00:00
Compare
freemo merged commit 93e3893d69 into master 2026-03-04 18:42:41 +00:00
freemo deleted branch feature/m5-tool-wrapping-runtime 2026-03-04 18:42:41 +00:00
Sign in to join this conversation.
No reviewers
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.

Dependencies

No dependencies set.

Reference
cleveragents/cleveragents-core!555
No description provided.