Files
cleveragents-core/robot/tool_wrapping_runtime.robot
freemo 93e3893d69 feat(validation): implement tool wrapping runtime (wraps + transform delegation)
Implement the runtime execution engine for validation tool wrapping,
as specified in docs/specification.md § Tool Wrapping.

WrappedToolExecutor resolves wraps references and delegates execution
to wrapped tools, supporting composable wrapping chains with cycle
detection and depth limiting (max 10 levels).

ArgumentMapper translates arguments between wrapper and wrapped tool
schemas using the argument_mapping configuration. Supports both
forwarded parameter names and literal fixed values.

TransformExecutor runs user-supplied transform functions in a
sandboxed Python environment with restricted builtins (no imports,
no filesystem, no network access). Validates that transforms return
proper validation-format dicts with a passed boolean.

Wired into the tool package public API via tool/__init__.py exports.
All new error types (WrappedToolNotFoundError, WrappingCycleError,
WrappingDepthExceededError, TransformExecutionError) provide clear
diagnostic messages.

Tests: 20 Behave scenarios covering argument mapping, transform
execution, simple/chained delegation, error handling, and sandbox
restrictions. 8 Robot Framework integration smoke tests. ASV
benchmarks for delegation overhead measurement.

ISSUES CLOSED: #543
2026-03-04 18:21:19 +00:00

59 lines
2.8 KiB
Plaintext

*** Settings ***
Documentation Tool wrapping runtime smoke tests
Library Process
Library OperatingSystem
*** Variables ***
${PYTHON} python
*** Test Cases ***
Wrapping Package Is Importable
[Documentation] Verify tool wrapping module can be imported
${result}= Run Process ${PYTHON} -c
... from cleveragents.tool.wrapping import ArgumentMapper, TransformExecutor, WrappedToolExecutor, WrappedToolNotFoundError, WrappingCycleError, WrappingDepthExceededError, TransformExecutionError; print('OK')
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} OK
Wrapping Exports In Tool Init
[Documentation] Verify wrapping types are exported from tool package
${result}= Run Process ${PYTHON} -c
... from cleveragents.tool import ArgumentMapper, TransformExecutor, WrappedToolExecutor; print('OK')
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} OK
ArgumentMapper Identity Mapping
[Documentation] Verify ArgumentMapper with None mapping passes args through
${result}= Run Process ${PYTHON} robot/scripts/test_mapper_identity.py
Should Be Equal As Integers ${result.rc} 0 ${result.stderr}
Should Contain ${result.stdout} OK
ArgumentMapper With Mapping
[Documentation] Verify ArgumentMapper translates arguments
${result}= Run Process ${PYTHON} robot/scripts/test_mapper_configured.py
Should Be Equal As Integers ${result.rc} 0 ${result.stderr}
Should Contain ${result.stdout} OK
TransformExecutor Runs Transform
[Documentation] Verify TransformExecutor executes transform code
${result}= Run Process ${PYTHON} robot/scripts/test_transform_run.py
Should Be Equal As Integers ${result.rc} 0 ${result.stderr}
Should Contain ${result.stdout} OK
TransformExecutor Sandbox Blocks Import
[Documentation] Verify TransformExecutor blocks import in sandbox
${result}= Run Process ${PYTHON} robot/scripts/test_transform_sandbox.py
Should Be Equal As Integers ${result.rc} 0 ${result.stderr}
Should Contain ${result.stdout} blocked=True
WrappedToolExecutor Simple Delegation
[Documentation] Verify WrappedToolExecutor delegates to wrapped tool
${result}= Run Process ${PYTHON} robot/scripts/test_delegation.py
Should Be Equal As Integers ${result.rc} 0 ${result.stderr}
Should Contain ${result.stdout} OK
WrappedToolExecutor Missing Tool Error
[Documentation] Verify WrappedToolExecutor raises on missing wrapped tool
${result}= Run Process ${PYTHON} robot/scripts/test_missing_tool.py
Should Be Equal As Integers ${result.rc} 0 ${result.stderr}
Should Contain ${result.stdout} error_raised=True