YmerNode.Mcp.Tools.References.Validate (Ymer Node v0.2.1)

Copy Markdown View Source

Value validation for the references tool's params.

The dispatch layer checks that a required param is PRESENT but is blind to what it holds, so these functions are the boundary's value checks: every extracted scalar is type-checked before use, and each failure is a distinct atom so YmerNode.Mcp.Tools.References.Errors can render specific recovery guidance rather than one shrug for everything.

Summary

Functions

Normalizes a limit.

find needs at least one criterion — an empty find is not a table dump; that is list.

Checks a source token against the vocabulary the caller's declarations imply.

Functions

id(id)

limit(n)

Normalizes a limit.

The declared integer type is advisory — the dispatch gate checks presence, not value type — so a positive numeric string is accepted, and an over-max value CLAMPS to the maximum rather than bouncing. A caller that asks for 500 wants as many as it can have, and refusing the call teaches it nothing it can act on.

optional_query(query)

some_criterion(arg1, tags, arg3)

find needs at least one criterion — an empty find is not a table dump; that is list.

source(source, declarations)

Checks a source token against the vocabulary the caller's declarations imply.

The declarations travel in rather than being fetched here: the action has read the seam already, and reading it again to validate one string would be a second query per call — for a token that is checked against the same answer the rest of the call is using.

The token stays a string all the way through. It cannot become an atom: a declared source is an accepted script's name, which is user data, so String.to_existing_atom/1 would fail on every newly accepted script and String.to_atom/1 would let a caller grow the atom table at will.

tags(tags)