Skip to content

19. Compiler output

The Viv compiler processes one or more source files (after resolving includes), via a single entry file, and produces a single JSON file called the content bundle. This chapter describes the structure of that output.

The entry file is the Viv source file passed to the compiler as input. The compiler parses it, recursively resolves any include statements, and merges all resulting construct definitions into a single combined representation before proceeding with validation, postprocessing, and bundling. The entry file’s path is used as the base for resolving relative include paths.

A content bundle is the compiled artifact consumed by a Viv runtime. It is a JSON object with the following top-level keys:

KeyTypeContents
metadataobjectBundle metadata
actionsobjectAction definitions, keyed by name
actionSelectorsobjectAction-selector definitions, keyed by name
plansobjectPlan definitions, keyed by name
queriesobjectQuery definitions, keyed by name
siftingPatternsobjectSifting-pattern definitions, keyed by name
planSelectorsobjectPlan-selector definitions, keyed by name
tropesobjectTrope definitions, keyed by name

Template actions are excluded from the content bundle, as they exist solely for inheritance purposes.

The metadata object carries version information and validation data:

FieldTypePurpose
schemaVersionstringThe Viv content-bundle schema version. Runtimes enforce compatibility against this.
compilerVersionstringThe compiler version that produced this bundle, for provenance.
grammarVersionstringThe DSL grammar version at compile time, for provenance.
referencedEnumsstring[]Names of all enums referenced in the bundle, used for adapter validation.
referencedFunctionNamesstring[]Names of all adapter functions referenced in the bundle, used for adapter validation.
timeOfDayParameterizedReactionsobject[]Records of reactions constrained by time of day, used for adapter validation.
timeOfDayParameterizedQueriesstring[]Names of queries parameterized by time of day, used for adapter validation.
hasEntityDataAssignmentsbooleanWhether the bundle contains any assignment that modifies entity data. Some adapter configurations disallow this.

Expressions in the content bundle are represented as JSON objects with a type discriminator field identifying the expression kind. The shapes of these compiled expressions are defined by the DSL types (see dsl_types.py in the compiler source).

The schemaVersion field in the metadata ensures that a content bundle is compatible with the runtime consuming it. A runtime MUST check this version during initialization and reject bundles with incompatible schema versions.