pub struct ParamDecl {Show 15 fields
pub name: String,
pub param_type: Option<String>,
pub description: Option<String>,
pub required: bool,
pub default: Option<Value>,
pub max_length: Option<u64>,
pub minimum: Option<f64>,
pub maximum: Option<f64>,
pub enum_values: Option<Vec<Value>>,
pub pattern: Option<String>,
pub min_length: Option<u64>,
pub format: Option<String>,
pub items: Option<ItemsDecl>,
pub max_items: Option<u64>,
pub allow_slash: bool,
}Expand description
Single [[tools.parameters]] entry.
The default and enum fields use toml::Value because they are
heterogeneous in the reference configs (a default may be an integer,
a string, or a boolean depending on the parameter type).
§Forward incompatibility (Phase 128, D-15)
This struct carries #[serde(deny_unknown_fields)], so a config declaring any
of the Phase 128 D2 keys — pattern, min_length, format, max_items,
allow_slash, or an [tools.parameters.items] table — fails to PARSE on
toolkit 0.1.3 rather than degrading to “the key was ignored”. That is
deliberate (a silently-ignored validation rule is the class this phase closes)
but it means a config written for this release cannot be loaded by an older
toolkit. The same applies to the [server.validation] section. Named in the
CHANGELOG.
Fields§
§name: StringParameter name (the :param token used in the tool’s sql).
param_type: Option<String>JSON-schema type ("string", "integer", "number", "boolean").
description: Option<String>Human-readable parameter description.
required: boolWhether the parameter is required.
default: Option<Value>Optional default value (any TOML type).
max_length: Option<u64>Maximum string length (string parameters only).
minimum: Option<f64>Inclusive minimum (integer / number parameters only).
Stored as f64. See Self::maximum for the precision limit that applies
to both bounds.
maximum: Option<f64>Inclusive maximum (integer / number parameters only).
§Not a safe way to bound a 64-bit integer ID
Both bounds are stored as f64, so an integer magnitude above 2^53
(9007199254740992) cannot be represented exactly. 9007199254740993
written in TOML has ALREADY become 9007199254740992 by the time any code
in this crate sees it, and no post-parse check can recover the fact that it
was rounded. ServerConfig::validate therefore refuses a bound that is
non-finite or whose magnitude EXCEEDS 2^53
(ConfigValidationError::NonFiniteParamBound) — which catches the wildly
out-of-range case, and deliberately does not claim to catch a value sitting
one unit past the boundary.
If you need to bound a u64 identifier, express the rule as a
Self::pattern over its string form instead. This limitation is a
documented one, not an oversight: adding an i64-typed bound vocabulary is
out of scope for D2.
enum_values: Option<Vec<Value>>Closed set of allowed values (any TOML scalar).
pattern: Option<String>Regular expression the value must match, emitted as JSON Schema pattern
(string parameters only).
§It is UNANCHORED
JSON Schema pattern is a SUBSTRING search, exactly as ECMA-262
RegExp.prototype.test is. A rule written as a bare character class such as
[A-Z]{3} matches "../../etc/passwd-ABC" and therefore buys no
enforcement whatsoever. Anchor every rule you mean as a whole-value rule:
^[A-Z]{3}$.
§\s and \S do not mean one thing here
Two regex engines are live inside one jsonschema 0.49.2 process, and which
one evaluates your pattern depends on the pattern’s own syntax:
- A plain pattern takes the linear-time engine, whose
\sis a PARTIAL ECMA-262 set — measured as{U+0009, U+000A, U+000B, U+000C, U+000D, U+0020, U+00A0, U+2029, U+FEFF}. It does NOT include U+3000 IDEOGRAPHIC SPACE, U+0085 NEL, U+1680, U+2000, U+2007, U+2028 or U+202F, and it DOES include the byte-order mark. - A pattern containing a lookaround or a backreference takes the
backtracking engine, where
\sis exactly\p{White_Space}— so it DOES match U+3000, and does NOT match U+FEFF.
Adding a lookahead to a pattern therefore silently changes what \s means
in it. For anything security-relevant, spell out an explicit character class
(e.g. [^\p{White_Space}]) rather than using the shorthand.
min_length: Option<u64>Minimum string length in Unicode code points, emitted as JSON Schema
minLength (string parameters only).
Counted in code points — not bytes and not grapheme clusters — matching
maxLength’s unit so a min_length == max_length pair names exactly one
length.
format: Option<String>JSON Schema format assertion, e.g. "uuid", "email", "date-time".
§It IS enforced on inputs in this SDK
format is ANNOTATIVE by default in jsonschema 0.49 — a bare
draft202012 validator accepts "!!!not-a-uuid!!!" against
format = "uuid". Declared inputs do not take that path: core pmcp
compiles a tool’s inputSchema through a format-ASSERTING builder
(Phase 128, Q1), so a declared format refuses a non-conforming value at
tools/call time.
Measured under this workspace’s pinned jsonschema configuration
(0.49, default-features = false), all NINETEEN standard Draft 2020-12
format names assert: date-time, date, time, duration, email,
idn-email, hostname, idn-hostname, ipv4, ipv6, uri,
uri-reference, iri, iri-reference, uuid, uri-template,
json-pointer, relative-json-pointer, regex. A format name OUTSIDE
that list is accepted-and-ignored, per JSON Schema’s own rule that an
unknown format is an annotation — so a typo such as "uid" for "uuid"
silently enforces nothing.
format is NOT enforced on OUTPUTS: structuredContent validation is
deliberately annotative there, and only warns.
items: Option<ItemsDecl>[tools.parameters.items] — the element schema for an array parameter,
emitted as JSON Schema items.
Emitted in OBJECT form only. Array-form items (the draft-07 tuple
construct) does not compile under the Draft 2020-12 pin and would take the
whole tool’s validator down with it.
max_items: Option<u64>Maximum number of array elements, emitted as JSON Schema maxItems
(array parameters only).
allow_slash: boolPermit / inside this parameter’s value when it is interpolated into a
single-call tool’s path template (Phase 128, D-11).
Path-placeholder values are refused for path separators by default, because
a / in a {segment} lets a caller reshape the request target. This
per-parameter opt-in is the ONLY legitimate source of that permission — it
exists for the genuine case of a parameter that names a multi-segment
resource path.
An OpenAPI spec’s allowReserved must NEVER be wired to this field. That
keyword describes URL percent-encoding latitude in the spec author’s
serialization rules; it is not a statement that the value may restructure
the path, and treating it as one would turn a routine spec detail into a
silent path-traversal opening.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for ParamDecl
impl<'de> Deserialize<'de> for ParamDecl
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl StructuralPartialEq for ParamDecl
Auto Trait Implementations§
impl Freeze for ParamDecl
impl RefUnwindSafe for ParamDecl
impl Send for ParamDecl
impl Sync for ParamDecl
impl Unpin for ParamDecl
impl UnsafeUnpin for ParamDecl
impl UnwindSafe for ParamDecl
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more