On this page

file

Planning-derived additions: file.dependency_groups and file.dependencies[].is_self. See derived.md.

Selectable subject: no
Context root: file

file is the authoritative renderer-facing metadata for one concrete PlannedFileArtifact from artifact planning.

It is generation metadata, not Runtime IR semantics.

A rendered template must use this context for facts already decided by pack planning—especially exported symbols, final paths, resolved generated representation dependencies, and barrel/export members—instead of reconstructing those facts from semantic names.

Availability

text
one rendered PlannedFileArtifact
→ file: FileContext

A template invocation may expand to several files. Each rendered file receives its own FileContext while reusing the invocation's semantic context.

Raw/static files are copied and do not need renderer context.

Identity and source

Context pathTypeMeaning / template use
file.templatestring|nullOwning template registry key; null for a global resource outside a template boundary.
file.moderenderedThis context is supplied to a rendered concrete file.
file.source.pathstringPack-relative source resource path before rendering/output composition.

Planned output path

Context pathTypeMeaning / template use
file.path.packstringFinal pack-relative generated path after static/dynamic path composition and renderer-suffix removal.
file.path.workspacestringFinal workspace/project-relative generated path after the usage output root is applied.
file.path.directorystringDerived directory of file.path.workspace; empty for a workspace-root file.
file.path.namestringFinal generated filename including its target extension.
file.path.import_basestring|nullImport alias address of this file's destination root, ending in the separator (for example #/modules/), for addressing the pack's own static files. Null when no import alias applies.

Paths use Dryv portable / separators.

The file context does not invent language-specific module specifiers. A TypeScript, Python, Dart, Rust, or other pack may transform a planned file path according to that ecosystem's import rules.

Declared output symbols

Context pathTypeMeaning / template use
file.symbolstring|nullExact resolved value of this template invocation's output.symbol.
file.symbolsmap<string,string>Exact resolved named values from output.symbols; empty when none.

These values are planner authority.

Dryv must never derive them again from:

text
schema.name
operation.name
property.enum.name
filename
target-language parsing

If a pack declares:

yaml
templates:
  entity:
    output:
      symbol: $(subject.name.pascal)Entity

and the selected schema is User, rendering receives:

text
schema.name.pascal = User
file.symbol        = UserEntity

The template therefore writes:

hbs
export class {{file.symbol}} { ... }

not:

hbs
export class {{schema.name.pascal}}Entity { ... }

This keeps the emitted declaration exactly synchronized with pack planning.

Multiple named symbols

If the pack declares:

yaml
output:
  symbols:
    model: $(subject.name.pascal)
    identifier: $(subject.name.pascal)Id

the template accesses:

hbs
export interface
{{file.symbols.model}}
{} export type
{{file.symbols.identifier}}
= string;

file.symbol remains null in this case. Dryv must not silently choose one named symbol as "primary."

Artifact planning's initial carrier rule still applies: a symbol-bearing invocation must resolve to one unambiguous concrete symbol-carrying file.

GeneratedArtifactReferenceContext

Imports and exports reuse one generated-artifact reference contract.

Context pathTypeMeaning / template use
templatestring|nullProducer template key.
path.packstringProducer's planned pack-relative output path.
path.workspacestringProducer's planned workspace path.
path.relativestringPortable relative filesystem path from the current file's directory to the producer file, including the producer filename.
path.import_rootstring|nullProducer path relative to its import root: the pack activation's imports, else its destination's, rooted at imports.root (destination-relative) or imports.path (project-relative). Null when no import alias applies.
path.prefixedstring|nullpath.import_root shaped by imports.separator and imports.extension and prefixed with imports.prefix (for example #/modules/users/user.dto.ts, app.users.models, crate::users::models). Null when no import alias applies.
symbolstring|nullProducer's exact declared output.symbol.
symbolsmap<string,string>Producer's exact named output.symbols.
subjectsSemanticLinkContext[]Canonical semantic subjects represented by the producer artifact.

path.relative, path.import_root and path.prefixed are facts derived from already-planned workspace paths. They are not target-language module specifiers until a pack renders them as one.

Resolved generated dependencies

Context pathTypeMeaning / template use
file.dependenciesGeneratedDependencyContext[]Resolved generated dependencies for this concrete file.
file.dependencies[].targetSemanticLinkContextSpecific semantic reference in the consumer that caused this dependency.
file.dependencies[].packstringKey of the pack that generated the dependency, such as examples.zod. Lets a template adapt to the bound provider without guessing from names.
file.dependencies[].slotstring|nullThe bound slot for a dependency on another pack's file (schema.validation, …); null within one pack.
file.dependencies[]GeneratedArtifactReferenceContext + target, pack, slotAll other fields reuse the generated-artifact reference contract above. path.relative works across destinations.

These are resolved generated representation dependencies, not source-language import statements and not the pack's raw imports: eligibility list.

The pack key imports: is retained because it declares which producer templates are eligible to satisfy generated references. Artifact planning resolves those declarations, including #/needs/<slot> imports through the project's bind, into file.dependencies[].

A dependency may later render as an ES import, Python import, Rust use, Dart import, fully-qualified reference, inline reference, or no emitted import syntax at all.

artifact planning has already performed:

text
consumer semantic reference
→ allowed producer template
→ generated representation index
→ concrete producer file
→ declared producer symbol(s)

So a target pack may choose to render some dependencies as source-language imports, for example:

hbs
{{#each file.dependencies}}
  {{#if symbol}}
    import {
    {{symbol}}
    } from "{{path.relative}}";
  {{/if}}
{{/each}}

A real TypeScript pack may apply a small pack-owned path macro to remove/adjust the target extension. It must not recalculate the producer symbol.

The same rule applies when semantic context later needs to mention a generated representation.

For example, if:

text
schema field
    → semantic schema Customer

resolved generated dependency
    → target = Customer
    → symbol = CustomerDto

the generated field type must use the resolved import symbol CustomerDto, not reconstruct Customer from field.value.schema.name.

A pack may centralize this lookup in a macro/partial such as:

text
renderFieldValue(field.value, file.dependencies)

where semantic meaning comes from field.value and generated representation identity comes from the dependency entry whose target matches that semantic value. This lookup is pack template logic over explicit context; Dryv does not inject generated symbols into semantic subjects.

Barrel/export members

Context pathTypeMeaning / template use
file.exportsGeneratedArtifactReferenceContext[]Deterministic producer stream already resolved by artifact planning for an export/barrel artifact.

The order is the artifact planning deterministic export order:

  1. declared exports template-ref order;
  2. stable artifact order within each producer;
  3. deduplication only by identical artifact identity.

Example:

hbs
{{#each file.exports}}
  {{#if symbol}}
    export {
    {{symbol}}
    } from "{{path.relative}}";
  {{else}}
    export * from "{{path.relative}}";
  {{/if}}
{{/each}}

Again, symbol and path identity come from planning.

Boundary with semantic context

Use semantic context for software meaning:

text
schema.name
schema.fields
operation.inputs
property.enum.values

Use file for generated-artifact facts:

text
file.symbol
file.symbols
file.path
file.dependencies
file.exports

Never add generated facts back onto semantic subjects:

text
schema.symbol       # wrong
schema.path         # wrong
operation.imports   # wrong
property.enum.file  # wrong

Demand-driven materialization

This file defines the complete available contract.

A template using only:

text
file.symbol
schema.fields

does not require Dryv to materialize file.dependencies, file.exports, trace metadata, or unused path variants.

Runtime/planner implications

artifact planning already requires the planner to know all underlying facts before rendering.

The context vocabulary therefore does not create new semantic authority. It only exposes a renderer-facing projection of:

  • concrete planned file identity;
  • source/output paths;
  • exact declared output symbols;
  • resolved generated representation dependency edges;
  • resolved export stream;
  • represented subjects;
  • trace provenance.

No rendered source parsing is allowed.

Import aliases

A code destination, or a single pack activation, declares how generated code addresses planned files:

yaml
destinations:
  modules:
    path: src/modules
    imports: { path: src, prefix: "#/" } # project-relative root: #/modules/..., #/types/...
packs:
  generated-client:
    imports: { path: src/gen, prefix: "@gen" } # this pack's own alias overrides the destination's
  python-models:
    imports: { path: app, prefix: app, separator: ".", extension: strip } # app.users.models

root (destination-relative) and path (project-relative) are alternatives. Packs render path.prefixed for dependencies and file.path.import_base for their own static files, falling back to relative paths when no alias applies. The project maps each alias in its toolchain (for TypeScript, tsconfig.json paths and package.json imports).

Search in