On this page

schema

Derived additions: has_* presence facts, *_json literals, fields[].storage.primary_key and field-link generated. See derived.md.

Intent

A named structured semantic object used for entities, DTOs, requests/responses, persistence models, and reusable domain structures.

Exact selection subject:

yaml
subject: schema

The current Runtime IR is evidence, not authority. Target improvements needed for a usable template contract are called out explicitly.

Scope envelope

ScopeContext
eachschema: SchemaContext
allschemas: SchemaContext[]
collection candidatescollects.group, collects.feature

For collects.<dimension>, the singular collector is added beside the plural selected-subject array. A collector is valid only when ownership is semantically provable.

Context tree

This file defines only schema-local context. Shared/nested contexts are referenced, not duplicated.

Context pathTypeMeaning / template use
schema.idstringOpaque stable semantic identity.
schema.nameNameContextSee shared NameContext in README.md.
schema.descriptionstring|nullHuman semantic description.
schema.tagsstring[]Semantic classifiers.
schema.explanationsExplanationContext[]See README.md.
schema.groupSemanticLinkContext|nullOwning group link; see README.md.
schema.featureSemanticLinkContext|nullCanonical owning feature, when present.
schema.roleSchemaRole|nullOne of entity, value, request, response, command, query, filter, event, view-model, config.
schema.abstractbooleanWhether the schema contributes meaning without direct concrete identity.
schema.extendsSchemaContext|nullFull context of the base schema from this file, demand-resolved.
schema.sourceSchemaSourceContext|nullThe projection this schema derives from: schema link, purpose (read|create|edit|query|custom), fields[] as {name, source}, and policies. null for original schemas.
schema.fieldsSchemaFieldContext[]Effective fields ordered by name: local fields, projected fields (with their optional/nullable/array overrides) and fields inherited through extends.
schema.facets.storageSchemaStorageContext|nullStorage semantics unique to schema.
schema.facets.storage.namespacestring|nullEffective storage namespace: the schema's own, else the nearest group default.
schema.invariantsSchemaInvariantContext[]Effective invariants: inherited, carried over from a projection source, then local.
schema.invariants[].nameNameContextStable invariant name, for constraint names such as chk_cart_item_quantity_positive.
schema.invariants[].messagestring|nullOptional error message.
schema.invariants[].ruleExpressionContextThe rule's full expression, demand-resolved.
schema.invariants[].form.kindcomparison|all|any|opaqueThe rule's simplest fixed-depth shape, computed by the Engine. opaque means the rule has no simple form.
schema.invariants[].form.comparisons[]InvariantComparisonContext[]One entry for comparison, several for all/any, none for opaque.
…comparisons[].operatorequal|not-equal|less-than|less-than-or-equal|greater-than|greater-than-or-equalComparison operator.
…comparisons[].left / .rightInvariantOperandContextkind is field, literal or arithmetic. field is a NameContext for a top-level field; value is the literal; operator and terms[] describe arithmetic over fields and literals.
schema.examplesCanonicalValue[]Whole-schema examples.

SchemaFieldContext

Context pathTypeMeaning / template use
schema.fields[].nameNameContextField identity; shared context from README.md.
schema.fields[].valueSemanticValueContextExact field-value contract from shared/semantic-value.md.
schema.fields[].optionalbooleanField-local optional presence.
schema.fields[].nullablebooleanField-local nullable value.
schema.fields[].arrayArrayBoundsContext|nullField-local array cardinality.
schema.fields[].defaultDefaultValueContext|nullCanonical value or expression default.
schema.fields[].mutationcreate-only|system|nullMutation rule.
schema.fields[].queryFieldQueryContext|nullFilter/sort/search/nesting capabilities.
schema.fields[].sensitivebooleanSensitive-data marker.
schema.fields[].policy.readPolicyContext|nullFull policy context from policy.md, demand-resolved.
schema.fields[].policy.writePolicyContext|nullFull policy context from policy.md, demand-resolved.
schema.fields[].relationRelationContext|nullField-local relation semantics.
schema.fields[].relatedRelatedContext|nullDerived/inverse relation semantics.
schema.fields[].sourcesFieldSourceContext[]Field-local value/resolve/options source bindings.

A reusable property's constraints are therefore reached naturally through the field value, for example:

text
schema.fields[].value.property.primitive.constraints.length
schema.fields[].value.property.primitive.constraints.range
schema.fields[].value.property.primitive.constraints.precision
schema.fields[].value.property.primitive.constraints.scale

schema.fields[].value.property.enum.values

schema.fields[].value.property.temporal.constraints

schema.fields[].value.property.composite.fields

Those subtrees are not redefined here; they are the full matching property contexts from their subject files.

Usage rules

  • fields is the effective generation view; templates should not rebuild inheritance/derivation semantics.
  • role says what the schema does; source says where its shape came from.
  • Storage stays under facets.storage.

Runtime IR implications to audit

  • Resolve each field through SemanticValueContext; property/schema references must expose their authoritative full context contract without templates parsing pointer prefixes.

Template example — Handlebars / TypeScript DTO

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

export interface {{file.symbol}} {
{{#each schema.fields}}
  {{name.camel}}{{#if optional}}?{{/if}}:
  {{renderFieldValue value ../file.dependencies}}{{#if nullable}} | null{{/if}};
{{/each}}
}

The example uses semantic context for field meaning and file metadata for exact generated representation identity. renderFieldValue is a pack-owned macro that resolves generated schema/property types through file.dependencies instead of guessing their symbols from semantic casing. Any renderType/render_type helper shown is a pack-owned macro/partial consuming the documented TypeContext, not hidden Dryv context.

Audit questions

  • Is schema.source clearer than the current projection concept?
  • Do proof packs need roles beyond request/response?
  • Do templates need declared-vs-effective fields, or is effective meaning enough?

Facet cardinality

Initial storage cardinality is singular:

text
schema.facets.storage  0..1

One schema has at most one canonical storage mapping in the initial contract. Multiple target-specific physical representations belong to pack generation, not multiple semantic storage facets.

Search in