Skip to main content

Module validation

Module validation 

Source
Expand description

Producer-side construction invariants for the tool metadata model.

The WIT shape alone does not enforce the construction invariants listed in the golem:tool/common@0.1.0 doc-comment; they are checked here by validate_tool. These checks are intended to run when a tool component’s metadata is produced or first ingested, so that every downstream consumer (signature projection, help rendering, the runtime) can assume a well-formed Tool.

Type and value well-formedness (recursion, named-definition resolution, value-against-type validity) is delegated to the shared golem:core/types model in golem_schema: typed positions embed a recursive SchemaType resolving against the tool’s SchemaGraph, and validate_value checks value-is literals against the declared type.

The CLI-structural checks implemented here are:

  • The command tree is non-empty (the root command is at index 0).
  • Every command-index subcommand reference is in bounds.
  • All identifier-like strings match is_valid_identifier.
  • Subcommand names and aliases are pairwise unique among siblings.
  • Within a command-body, option/flag long names, their aliases, positional names, and short forms are pairwise unique, and unique against globals inherited from the command itself and any ancestor.
  • Every constraint ref name resolves to a body-declared or inherited option/flag/positional.
  • Each value-is literal is a valid value for the declared type of the referenced name (with the “any element/occurrence” relaxation for list-typed and repeatable names).
  • A body’s default-formatter resolves to one of its formatters.
  • A tail-positional with verbatim = true declares a separator.
  • variant types never appear in (or are reachable from) an input position; input-side discrimination uses union instead.
  • The command tree is an acyclic tree: every node is reachable from the root and has exactly one parent (no cycles, no shared subcommands).

One WIT-listed invariant is deliberately not checked here: the root command-node’s name equals the tool’s metadata name. A tool is identified by its root command name, so there is no second value to compare against at this layer; the check belongs to whatever registers a tool under an externally supplied name.

Enums§

ToolMiddlewareValidationError
A producer-side construction-invariant violation in tool middleware metadata.
ToolValidationError
A single producer-side construction-invariant violation.

Functions§

is_valid_identifier
Returns true if s is a valid tool identifier (^[a-z][a-z0-9]*(-[a-z0-9]+)*$).
validate_tool
Validate a Tool against the producer-side construction invariants.
validate_tool_middleware
Validate middleware identity metadata and every embedded tool descriptor.