Skip to main content

Module validate

Module validate 

Source
Expand description

Structural validation of tool-call arguments against declared schemas.

Every tool advertises a JSON Schema for its parameters (built-ins in defs.rs, Rhai script tools via their compiled @param annotations, MCP tools via the server’s inputSchema). Until issue #155 nothing checked a model’s arguments against that schema: handlers did ad-hoc presence checks that could not tell {"path": 42} from a missing path, and extra or misspelled properties passed through silently. This module is the one validator dispatch consults before a call is executed.

Two properties are load-bearing:

  • A schema that does not compile skips validation instead of refusing calls. Garbage schemas are reachable in normal operation - a typo’d Rhai @param n strng required compiles to {"type": "strng"}, and MCP servers may send fragments this crate cannot interpret. Refusing those calls would break working tools; ArgValidation::SchemaUnusable lets the caller log and dispatch anyway.
  • External $refs never resolve. The jsonschema dependency is built with default-features = false, so a server-supplied schema referencing an external URI fails to compile (and is skipped, per the point above) rather than fetching over the network or filesystem at validation time.

Modules§

format
Built-in well-formedness checks for common output formats.

Enums§

ArgValidation
The outcome of checking one tool call’s arguments against its schema.

Functions§

validate_output
Validate a submitted final output against the schema its blueprint declared.
validate_tool_args
Validate args against schema, the exact parameter schema advertised to the model for tool_name.