Validation Rules
This page consolidates all validation rules from the Specification into an ordered checklist for implementers. Rules are grouped by the stage at which they should be enforced.
Stage 1: TOML Parsing
Before any MTHDS-specific validation, the file must be valid TOML.
- The file MUST be valid UTF-8-encoded TOML.
- A
.mthdsfile MUST have the.mthdsextension. METHODS.tomlMUST be named exactlyMETHODS.toml.methods.lockMUST be named exactlymethods.lock.
Stage 2: Bundle Structural Validation
After parsing TOML into a dictionary, validate the bundle structure:
domainMUST be present.domainMUST be a valid domain code: one or moresnake_casesegments ([a-z][a-z0-9_]*) separated by..main_pipe, if present, MUST besnake_caseand MUST reference a pipe defined in the same bundle.- Concept codes MUST be
PascalCase([A-Z][a-zA-Z0-9]*). - Concept codes MUST NOT match any native concept code (
Dynamic,Text,Image,Document,Html,TextAndImages,Number,ImgGenPrompt,Page,JSON,Anything). - Pipe codes MUST be
snake_case([a-z][a-z0-9_]*). refinesandstructureMUST NOT both be set on the same concept.
Stage 3: Concept Field Validation
For each field in a concept's structure:
descriptionMUST be present.- If
typeis omitted,choicesMUST be non-empty. type = "dict"requires bothkey_typeandvalue_type.type = "concept"requiresconcept_refand forbidsdefault_value.type = "list"withitem_type = "concept"requiresitem_concept_ref.concept_refMUST NOT be set unlesstype = "concept".item_concept_refMUST NOT be set unlessitem_type = "concept".default_valuetype MUST match the declaredtype.- If
choicesis set anddefault_valueis present,default_valueMUST be inchoices. - Field names MUST NOT start with
_.
Stage 4: Pipe Type-Specific Validation
Each pipe type has specific rules:
PipeLLM:
- All prompt and system_prompt variables MUST have matching inputs.
- All inputs MUST be referenced in prompt or system_prompt.
PipeFunc:
function_nameMUST be present and non-empty.
PipeImgGen:
promptMUST be present.- All prompt variables MUST have matching inputs.
PipeExtract:
inputsMUST contain exactly one entry.outputMUST be"Page[]".
PipeSearch:
promptMUST be present.- All prompt variables MUST have matching inputs.
outputMUST beSearchResultor a concept that refinesSearchResult.
PipeCompose:
- Exactly one of
templateorconstructMUST be present. outputMUST NOT use multiplicity brackets ([]or[N]).- All template/construct variables MUST have matching inputs.
PipeSequence:
stepsMUST have at least one entry.nb_outputandmultiple_outputMUST NOT both be set on the same step.batch_overandbatch_asMUST either both be present or both be absent.batch_overandbatch_asMUST NOT be the same value.
PipeParallel:
- At least one of
add_each_outputorcombined_outputMUST be set.
PipeCondition:
- Exactly one of
expression_templateorexpressionMUST be present. outcomesMUST have at least one entry.
PipeBatch:
input_list_nameMUST be ininputs.input_item_nameMUST NOT be empty.input_item_nameMUST NOT equalinput_list_name.input_item_nameMUST NOT equal any key ininputs.
Stage 5: Reference Validation (Bundle-Level)
Within a single bundle:
- Bare concept references MUST resolve to: a native concept, a concept in the current bundle, or a concept in the same domain (same package).
- Bare pipe references MUST resolve to: a pipe in the current bundle, or a pipe in the same domain (same package).
- Domain-qualified references MUST resolve within the current package.
- Cross-package references (
->syntax) are deferred to package-level validation.
Stage 6: Manifest Validation
For METHODS.toml:
[package]section MUST be present.addressMUST match the pattern^[a-zA-Z0-9._-]+\.[a-zA-Z0-9._-]+/[a-zA-Z0-9._/-]+$.versionMUST be valid semver.descriptionMUST NOT be empty.- All dependency aliases MUST be unique and
snake_case. - All dependency addresses MUST match the hostname/path pattern.
- All dependency version constraints MUST be valid.
- Domain paths in
[exports]MUST be valid domain codes. - Domain paths in
[exports]MUST NOT use reserved domains (native,mthds,pipelex). - All pipe codes in
[exports]MUST be validsnake_case.
Stage 7: Package-Level Validation
After loading all bundles and resolving dependencies:
- Bundles MUST NOT declare a domain starting with a reserved segment.
- Cross-package references MUST reference known dependency aliases.
- Cross-package pipe references MUST target exported pipes.
- Exported pipes MUST exist in the scanned bundles.
- Same-domain concept and pipe code collisions across bundles are errors.
Stage 8: Lock File Validation
For methods.lock:
- Each entry's
versionMUST be valid semver. - Each entry's
hashMUST matchsha256:[0-9a-f]{64}. - Each entry's
sourceMUST start withhttps://.