Skip to main content

Module templates

Module templates 

Source
Expand description

Subagent templates: compile the subagents.templates section at boot, resolving each template to its tier (flat worker vs instance-tier child) and validating everything that can be judged before params exist.

Directive extraction runs exactly ONCE, here, on operator-authored text. Params fold in later at spawn as data (fold_params) and are never re-parsed for directives, so a caller-supplied param value can never turn into machinery (an :::mcp block smuggled through a param stays inert prose). params_introduced_machinery is the spawn-time guard that makes that ordering enforceable rather than merely intended.

Structs§

CompiledTemplate
A boot-compiled template: frozen machinery + cleaned prose with {{params.*}} holes.

Enums§

Tier
The two tiers a template can resolve to. The tier is not declared: it follows from whether the instruction carries machinery, so one rule decides it and an operator cannot ask for a tier the text does not justify.

Functions§

compile_templates
Compile every declared template. Errors are aggregated (all problems, not the first) and refuse the PARENT’s startup, naming the template.
fold_params
Fold {{params.X}} (and {{ params.X }}) into text as data. ONLY the params. root is touched — every other {{…}} placeholder is a runtime template that must survive verbatim. A referenced-but-absent param is left in place (boot validation already guaranteed declarations; an optional param without a value keeps its hole visible rather than becoming “”).
fold_params_value
fold_params over every string in a JSON document (workflow bodies, config fragments).
params_introduced_machinery
The spawn guard that keeps params data: after folding, the prose must still contain no directives — the template’s own were replaced by one-line notes at boot, so any fence found now can only have come from a param value. Returns true when the spawn must be refused.
validate_params
Validate spawn-time params against the declared schema: unknown keys, missing required keys and type/enum mismatches are refused naming the field; declared defaults fill in. Returns the effective map.