Browse the documentation
CAP-03: Typed tool input and output
- ID:
CAP-03 - Title: Typed tool input and output
- Lead:
seed - Touches:
drosera,bloom - Horizon:
now - Milestone:
M2 - CLI phase:
P2 - Status:
in-progress - Claim:
specified - Depends on: none
Why
src/tool-id.mjs checks that a registry entry carries an inputSchema object, and src/run-model.mjs admits tool IDs per objective, yet neither seed nor its consumers enforce a deterministic schema subset over tool inputs or outputs today. Without shared schema validation, malformed model arguments reach tool executors, outputs lack structural guarantees, and workspaces either import heavy external validators or duplicate ad-hoc checks.
What it does
seed defines and ships a small, zero-dependency, hand-written schema subset and validator for tool inputs and optional tool outputs:
- Closed schema subset:
type:"object","array","string","number","integer","boolean", or"null".- Object keywords:
properties(map of field name to nested schema),required(array of non-empty property names), andadditionalProperties(falseonly when present, refusing unlisted properties). - Array keywords:
items(single schema applied to every element) andmaxItems(non-negative safe integer). - Scalar and enumeration keywords:
enum(non-empty array of JSON primitive literals),minLengthandmaxLength(non-negative safe integers for strings),minimumandmaximum(finite numbers for numbers and integers). - Unknown keywords anywhere in a schema object are refused rather than silently ignored.
- Schema checker and value validator:
checkSchema(schema)validates thatschemauses only the closed subset and returns a frozen{ ok, errors }result where each error carries a JSON-pointer path (such as/properties/limit/minimum) and reason.validateValue(schema, value)first validatesschema(failing closed if malformed) and then checksvalue, returning a frozen{ ok, errors }result with JSON-pointer paths (such as/limitor/items/0).- Error messages never echo raw string values that could leak credentials or private content; they name the JSON-pointer path and violated constraint only.
- Optional
outputSchemaon registry entries:- Registry entries in
src/tool-id.mjsgain an optionaloutputSchemafield validated bycheckSchema. - Omitting
outputSchemastays valid (additive minor change keeping0.8.0entries valid); supplying an invalidoutputSchemafailsisWellFormedRegistryEntryandcheckRegistry.
- Registry entries in
- Consumer execution flow in
droseraandbloom:droseratool faces accept optionalinputSchemaandoutputSchemaconstrained by a dependency-free mirror of theseedsubset, verified by parity tests.- Before dispatching any tool call,
bloomvalidates arguments withvalidateValue(entry.inputSchema, args). On failure, the tool does not execute;bloomsends one structured repair turn naming the JSON-pointer errors. If the repaired arguments still fail validation, the call stops with failure classmalformed(aligned withschema-invalidinrun-model.md). - When a tool declares
outputSchema,bloomvalidates the tool’s output before handing it back to the model; an output validation failure counts against the same single-turn repair budget so invalid tool outputs never trigger unbounded retries.
Contract touchpoints
seed:docs/contracts/tool-id.md(adds closed schema subset contract,checkSchema/validateValuebehavior, and optionaloutputSchemaon registry entries as an additive minor update);docs/contracts/run-model.md(aligns pre-dispatch validation refusal withschema-invalid).drosera:docs/contracts/tools.md(optionalinputSchemaandoutputSchemaontoolFace, parity againstseedsubset).bloom:docs/architecture.md(pre-dispatch argument validation, single repair turn thenmalformed, output validation sharing repair budget).
Tool IDs and events
Tool IDs
None defined by this capability.
| Tool ID | Effect | Third-party egress | Owner gate | Summary |
|---|
Events
None defined by this capability. Validation and repair events in the team trace belong to CAP-10.
| Event | Emitter | Payload summary |
|---|
Acceptance tests
unknown-schema-keyword-refused:checkSchemarejects any schema containing an unsupported keyword (such as$ref,oneOf, orpattern) and returns frozen{ ok: false, errors }with the JSON-pointer path to the offending keyword.value-validation-json-pointer-no-secret-echo:validateValuecheckstype,properties,required,additionalProperties: false,items,enum,minLength,maxLength,minimum,maximum, andmaxItems, reports JSON-pointer error paths, and never echoes sensitive or arbitrary raw string values in error messages.optional-output-schema-additive: Existing0.8.0registry entries withoutoutputSchemaremain valid inisWellFormedRegistryEntryandcheckRegistry, while entries supplying a malformedoutputSchemaare rejected.drosera-face-schema-parity:droseratool faces accept optionalinputSchemaandoutputSchema, and a parity check confirmsdroseraaccepts and rejects the exact same schema shapes and values asseed.bloom-single-repair-turn-then-malformed: Inbloom, invalid tool arguments never invoke the tool executor, trigger at most one repair turn carrying JSON-pointer error paths, and stop asmalformedif the second attempt still failsinputSchema.output-validation-shares-repair-budget: Inbloom, a tool result failingoutputSchemaconsumes from the single-turn repair budget and stops cleanly rather than looping or passing unvalidated output into model context.
Slices
CAP-03.1(seed, milestoneM2, statuslanded): Implement the closed schema subset (checkSchema,validateValue) inseedand add optionaloutputSchemato registry entries (docs/contracts/tool-id.md, additive minor bump).CAP-03.2(drosera, milestoneM2, statusproposed): Add optionalinputSchemaandoutputSchemavalidation on tool faces with parity verification againstseed.CAP-03.3(bloom, milestoneM2, statusproposed): Wire pre-dispatchinputSchemachecking, one repair turn thenmalformed, andoutputSchemavalidation sharing the repair budget.
Non-goals
- Implementing full JSON Schema (
$ref,allOf,oneOf,anyOf,not,pattern,format, remote schema resolution). - Coercing argument types or silently stripping unknown keys when
additionalProperties: falseis set. - Adding any runtime dependency or external schema validation package.
Family rules and conflicts
- Zero runtime dependencies: Schema checking and validation are pure hand-written JavaScript in
seedwith zero dependencies. - Additive compatibility:
outputSchemais strictly optional so existingseed0.8.0callers remain unbroken; addingoutputSchemaand new exports is a minor version bump. - No secret echo: Validation errors identify JSON-pointer paths and expected types or bounds, never repeating raw string payloads that might hold credentials.
Open owner decisions
D4Decided 2026-11-24 in seed#3: Where should the schema subset and validator live? Owner’s answer, verbatim: “I need you to approve on recommendations and continue”.seedowns the subset and validator.droseramirrors the subset and verifies parity.
Evidence
CAP-03.1is exercised by six cases intest/schema.test.mjscovering nested schema refusal, redacted error paths, bounds, closed objects, and registry compatibility.
Changes
2026-11-24: RecordD4and ship the closed schema subset with optional registry output schemas (CAP-03, seed#3).2026-11-23: AddedM2slice milestones and alignedD4wording with the canonical decision record.2026-11-23: Initial capability specification created (CAP-01.2scaffold).