Template analysis protocol
For the derived vocabulary templates can request (classifications, presence facts, JSON literals, HTTP views, storage, generated representations) and the CLI discovery commands, see context/derived.md.
Template Servers tell the Engine which context paths a template reads. The Engine validates those paths, projects only them, and asks for a strict render of the same snapshot.
Engine ─ POST /analysis (TemplateAnalysisRequest) ─▶ Template Server
◀─ requirements: exact + subtree paths, dependencies, diagnostics
Engine validates paths: vocabulary + invocation envelope
Engine projects context (see context-resolution)
Engine ─ POST /render (TemplateRenderRequest, same snapshot identity) ─▶ rendered bytes
The protocol is dryv.templates/v1alpha1, the requirements document is dryv.context-requirements/v1alpha1, and the vocabulary is dryv.context/v1alpha1. The server never receives Runtime IR, and the Engine never parses template syntax.
Snapshot
A snapshot contains sorted, digest-checked resources, the root resource, the vocabulary version, the provider version, the built-in helper-set version and the renderer configuration. Changing any of these changes its identity. Rendering always refers to an analysed identity. Static dependencies must be supplied resources, and cycles or missing dependencies are errors.
Requirements
version: dryv.context-requirements/v1alpha1
template: { key: entity, source: src/{entity}/entity.ts.hbs, digest: sha256:… }
vocabulary: dryv.context/v1alpha1
requirements:
exact:
- file.symbol
- file.dependencies[].path.relative
- schema.fields[].name.camel
subtree: []
dependencies: [{ source: src/shared/type.hbs, digest: sha256:… }]
diagnostics: []
Requirements are sorted and deduplicated.
Path grammar
| Form | Example | Meaning |
|---|---|---|
| member | schema.name.pascal | exact value |
| collection | schema.fields[].name.camel | only that member of each element |
| named map | file.symbols.model, pack.inputs.package_name | lower snake-case literal key, checked against the plan or pack |
Raw IR paths (#/schemas/…, $ref, ir.*) are never valid. Renderer-local aliases (with, set, sections, macro parameters, loop variables) must resolve back to canonical paths.
Analysis rules
- Conditions are conservative. Every branch's reads are requested. Presence is decided at render time, and a missing value becomes
nullor[]. - Dynamic lookups request a bounded subtree and emit a warning. A subtree includes only the node's local fields and stops at context-reference boundaries (for example,
value → SchemaContext). The Engine rejects unbounded named-map requests. Dynamic keys onpack.inputsare rejected. - Includes and partials are analysed as part of the dependency closure.
- Opaque helpers, ambient filters, dynamic dependencies and unsupported constructs fail analysis. Only the built-in, versioned, pure helper set exists.
Engine validation
Before resolving anything, the Engine rejects unknown roots or members, invalid [] traversal, traversal through scalars, invalid map keys, roots unavailable for this invocation (for example, feature under scope: each), unbounded subtrees, leftover aliases, and version or digest mismatches. Diagnostics point to the template, the span, the offending path and the expected vocabulary.
Root availability: file is always available. application is always available and resolved on demand. pack is always available. The subject root follows subject + scope. group is available for collects.group and collects.feature. feature is available for collects.feature.
Renderer conformance
- Strict. Accessing anything that wasn't analysed or wasn't supplied fails deterministically.
- Hermetic. No network, undeclared files, environment reads, clock or randomness, and no IR or artifact queries.
- Analysis caches are capped at 128 snapshots and don't depend on the semantic subject.
| Renderer | Analysis | Strict snapshot render |
|---|---|---|
| Handlebars, Jinja, Liquid | yes | yes |
| Mustache | explicitly unsupported | can't be used for analysed generation |