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-indexsubcommand 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
refname resolves to a body-declared or inherited option/flag/positional. - Each
value-isliteral 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-formatterresolves to one of itsformatters. - A
tail-positionalwithverbatim = truedeclares aseparator. varianttypes never appear in (or are reachable from) an input position; input-side discrimination usesunioninstead.- 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§
- Tool
Middleware Validation Error - A producer-side construction-invariant violation in tool middleware metadata.
- Tool
Validation Error - A single producer-side construction-invariant violation.
Functions§
- is_
valid_ identifier - Returns
trueifsis a valid tool identifier (^[a-z][a-z0-9]*(-[a-z0-9]+)*$). - validate_
tool - Validate a
Toolagainst the producer-side construction invariants. - validate_
tool_ middleware - Validate middleware identity metadata and every embedded tool descriptor.