On this page
- Meaning
- Canonical field shape
- Field defaults
- Mutation, query, sensitivity, and policies
- Effective Schema field references
- Inheritance
- Relations
- Reverse related fields
- Field-local sources
- Storage facets
- Storage inheritance
- Projection
- Projection safety
- Effective Schema resolution
- Invariants
- Metadata
- Boundaries
- Canonical summary
Schemas
This document describes the canonical Runtime IR contract. Authoring implementations may expose richer helpers, but they must lower into these resolved forms. Runtime IR does not preserve authoring selectors, shorthand, or compatibility shapes.
Meaning
A Schema describes canonical structured software state.
Properties own reusable value meaning. Schemas compose those reusable values into structured state and add context-specific semantics such as usage, relationships, query capability, mutation rules, field-local sources, inheritance, projection, policies, and portable storage requirements.
Schema meaning is resolved and inspectable. Packs consume that meaning; they do not redefine it.
Canonical field shape
Schema and composite fields use a flat shape. There is no usage wrapper.
email:
kind: property
$ref: "#/properties/primitives/customers.Email"
optional: true
nullable: true
array:
min: 1
max: 5
Absence has canonical meaning:
- no
optionalmeans required; - no
nullablemeans non-nullable; - no
arraymeans scalar.
array: {} means an unbounded array. array.min and array.max constrain collection length.
Fields target one of:
- a Property;
- another Schema;
- intrinsic
unknown; - intrinsic
dynamic.
Properties and Schemas remain the reusable semantic authority. Field usage does not mutate the referenced definition.
Field defaults
A field may declare a literal canonical value or a named Expression reference as its default.
status:
kind: property
$ref: "#/properties/enums/orders.Status"
default: pending
Computed defaults use the canonical Expression registry rather than inline expression definitions.
Mutation, query, sensitivity, and policies
Field mutation currently supports:
create-only;system;context;transition.
Absence means normal mutable participation.
Query capability is explicit and resolved:
email:
kind: property
$ref: "#/properties/primitives/customers.Email"
query:
filter: [contains, equal]
sort: true
search: true
Only capabilities compatible with the effective field target and usage are valid. Optional, nullable, and array usage enable their corresponding operators. allow_nested: true is only valid for Schema/composite targets.
Sensitivity is expressed as sensitive: true; absence means no local sensitivity declaration.
Field policies reference reusable Policies:
policy:
read:
$ref: "#/policies/customers.CanReadEmail"
write:
$ref: "#/policies/customers.CanEditEmail"
Capabilities and policies remain distinct: capability says whether the behavior is semantically supported; policy says under which reusable rule it may be exercised.
Effective Schema field references
Schema relationships reference effective Schema meaning, not physical serialized field locations.
Canonical field reference:
$ref: "#/schemas/customers.Customer"
field: id
Do not use physical pointers such as:
#/schemas/customers.Customer/fields/id
The effective reference remains valid when the field is inherited or projected because it identifies the Schema and effective field name rather than one storage location in the document.
Inheritance
extends means specialization / IS-A.
schemas:
records.BaseRecord:
abstract: true
fields:
id:
kind: property
$ref: "#/properties/primitives/shared.Id"
customers.Customer:
extends:
$ref: "#/schemas/records.BaseRecord"
fields:
name:
kind: property
$ref: "#/properties/primitives/customers.Name"
Rules:
- one direct parent;
- deep inheritance is valid;
- inherited fields are implicit and must not be serialized again on a child;
- redefining an inherited field is invalid;
- inheritance cycles are invalid;
- effective Schema meaning includes the full ancestor chain.
abstract: true marks reusable non-final structured meaning. Absence means concrete.
Relations
A forward relation is declared on a Property field and points to an effective field on another Schema.
customerId:
kind: property
$ref: "#/properties/primitives/shared.Id"
relation:
target:
$ref: "#/schemas/customers.Customer"
field: id
cardinality: many-to-one
on_delete: restrict
Cardinality is one of:
one-to-one;one-to-many;many-to-one;many-to-many.
Lifecycle behavior is one of:
restrict;cascade;detach;reset.
Normal relation cycles and self-relations are valid. Cascade graphs are validated separately because delete/update cascade cycles can make lifecycle behavior unsafe or ambiguous.
Forward relation source and target fields must have compatible effective types.
Reverse related fields
Reverse navigation is explicit and belongs on a Schema-valued field.
orders:
kind: schema
$ref: "#/schemas/orders.Order"
array: {}
related:
via:
$ref: "#/schemas/orders.Order"
field: customerId
cardinality: one-to-many
related.via must resolve to a forward relation that targets the Schema represented by the reverse field. An optional inverse effective-field reference may make a paired relationship explicit.
relation and related are different semantic facts and cannot coexist on the same field.
Field-local sources
Sources are Schema-field semantics. There is no root sources registry.
A field may own named sources for distinct purposes. The source selects its producing Operation output through a typed OperationPortRef rather than a separate Operation reference plus output name:
countryId:
kind: property
$ref: "#/properties/primitives/shared.Id"
sources:
choices:
purpose: options
output:
$ref: "#/operations/countries.ListCountries"
direction: output
index: 0
Purpose is one of:
value;resolve;options.
Sources may bind Operation inputs either from the consuming field value or from another effective Schema field. Bindings are ordered objects with an explicit target Operation input port and typed source:
inputs:
- target:
$ref: "#/operations/countries.ResolveCountry"
direction: input
index: 0
source:
kind: field
value:
$ref: "#/schemas/customers.Customer"
field: tenantId
- target:
$ref: "#/operations/countries.ResolveCountry"
direction: input
index: 1
source:
kind: value
kind: value means the consuming field value. kind: field references another effective Schema field.
Runtime validation checks that the output targets an existing Operation output port, each input binding targets an input port of that same Operation, duplicate targets are rejected, and bound input types are compatible. A field source is not a global data loader, transport endpoint, cache contract, query language, or UI widget definition.
Storage facets
Portable storage requirements belong to Schema under facets.storage. There is no root storage registry and no Storage reference from Feature.
namespace is the logical storage namespace, such as a database schema. When a schema doesn't set one, it comes from the nearest group up the owning group chain that sets facets.storage.namespace. Physical details (column names, database types, transformers) are pack decisions, never IR.
Concrete stored Schema:
facets:
storage:
name: customers
kind: persistent
primary_key: [id]
indexes:
- fields: [email]
unique: true
- fields: [tenantId, externalId]
unique: true
- fields: [createdAt]
name: customer_created_at
kind defaults to persistent; volatile is also allowed.
Indexes have one canonical object shape:
fields: [fieldA, fieldB]
unique: true # optional; absence means false
name: index_name # optional
There is no scalar index shorthand and no separate uniqueness list.
Storage fields resolve against effective Schema fields, including inherited fields.
Storage inheritance
Abstract Schemas may contribute storage rules without concrete identity:
records.StoredRecord:
abstract: true
fields:
id:
kind: property
$ref: "#/properties/primitives/shared.Id"
facets:
storage:
primary_key: [id]
A concrete descendant that inherits or declares storage rules must complete the facet with its own local name:
customers.Customer:
extends:
$ref: "#/schemas/records.StoredRecord"
facets:
storage:
name: customers
Rules:
- abstract storage facets must not declare a concrete storage name;
- concrete storage names do not inherit;
- inherited primary keys remain implicit and cannot be redefined;
- local indexes may extend inherited indexes;
- inherited index name/signature conflicts fail;
- concrete stored Schemas are inheritance terminals and cannot have descendants.
Partitioning is declared in facets.storage.partitioning using the storage builder. LIST, composite RANGE/HASH, nested layouts and bounded calendar series share one canonical declaration. Provider-specific ORM decorators, repository code and SQL syntax remain pack concerns. See the partitioning reference.
Projection
Projection derives a new structured shape from exactly one original non-projected Schema while preserving explicit lineage.
Canonical Runtime IR is fully resolved:
projection:
source:
$ref: "#/schemas/customers.Customer"
purpose: read
policies:
- $ref: "#/policies/customers.CanReadCustomer"
fields:
displayName:
from: name
email:
from: email
optional: true
slug:
from: slug
Projection purposes are:
read;create;edit;query;custom.
The Runtime IR does not preserve authoring selectors such as pick/omit/capability selectors or wildcard heuristics. Authoring may offer such helpers, but the compiler must lower them into the explicit fields map above.
The TypeScript and Python Authors require an explicit purpose helper. An unqualified projection(source) is invalid, and custom additionally requires an explicit non-empty pick. Purpose helpers derive the eligible field set, while pick, omit, rename and usage amendments refine it. Both compilers sort and lower the result to the same explicit canonical map; the Engine never derives hidden fields.
Each projected output field records its source field through from. Projection may rename and alter usage only; it cannot redefine the underlying Property/Schema target.
Usage amendments are explicit. Omitted usage members inherit the source usage. Explicit optional/nullable booleans can tighten or loosen those dimensions; array: false makes the projected field scalar, while an array object sets projected array usage.
A projected Schema may add independent local fields through its normal fields map. Local fields and projected output fields must not collide.
Projection safety
Projection rules:
- source must resolve to an original non-projected Schema;
- projection-from-projection is invalid;
- projection inheritance is invalid;
- abstract projections are invalid;
- projection storage facets are invalid;
- projection must contain at least one explicit field mapping;
- source field names must resolve against effective source fields;
- required field policies must be present in
projection.policies.
Purpose-specific restrictions are validated:
read: readable normal/system/related fields may be projected, subject to read policies;create: system-, context- and transition-managed and reverse-related fields are excluded, and write policies apply;edit: has create restrictions and also excludes create-only fields;query: projected source fields must expose query capability and required read policies;custom: explicit mappings remain structurally and referentially validated without inventing an implicit purpose.
Effective Schema resolution
Consumers should reason about effective meaning, not raw declaration location.
Effective fields are resolved from:
- inherited ancestor fields;
- explicit projection mappings when the Schema is a projection;
- local fields.
Invalid collisions/redefinitions are rejected rather than resolved by hidden precedence.
Effective-field references, relations, related fields, storage rules, examples, validation, and inspection all operate on this same resolved meaning.
Inspection preserves provenance separately: projection lineage shows each projected output field and its source effective field; inheritance remains visible through extends; storage dependencies point to effective Schema fields.
Invariants
An invariant is a named rule that every valid value of the schema satisfies. The rule is a boolean expression declared in expressions. It reads the schema's fields through the value context, exactly as composite invariants do.
expressions:
commerce.QuantityPositive:
group: { $ref: "#/groups/commerce" }
value:
operator: greater-than
left: { context: value, path: [quantity] }
right: { value: 0 }
schemas:
commerce.CartItem:
invariants:
- name: quantityPositive
rule: { $ref: "#/expressions/commerce.QuantityPositive" }
message: Quantity must be at least 1
nameis alphanumeric, starts with a letter, and is unique within the schema.messageis optional plain text.- A rule may read only the
valuecontext, and every path must resolve to one of the schema's effective fields. Diagnostics:ir.schema.invariant_unknown_context,ir.schema.invariant_unresolved_field,ir.schema.invariant_type_mismatch. - Invariants are for rules across fields or computed rules. Single-field limits (range, length, pattern) stay field constraints.
- Effective invariants.
extendsinherits every parent invariant. A projection carries over a source invariant only when every field the rule reads is projected under the same name; otherwise it's dropped. A local invariant with the same name replaces an inherited one.
Metadata
Schemas and fields may use universal semantic metadata such as tags and structured explanations. Metadata does not create hidden behavior.
Boundaries
Schemas do not own:
- reusable Property value/type meaning;
- reusable Policy definitions;
- Operation execution/retry/transport behavior;
- Workflow orchestration;
- Event occurrence definitions;
- Part/View/Presentation experience behavior;
- framework ORM models;
- database-provider implementation details;
- generated file/folder structure.
Schemas may reference Properties, Policies, Operations, and other Schemas when structured-state meaning requires those relationships.
Canonical summary
The established Schema surface includes:
- structured state definitions;
- flat fields and contextual usage;
- literal/expression defaults;
- mutation, query, sensitivity, and field policy semantics;
- deep single-parent inheritance with implicit inherited fields;
- effective Schema-field references;
- forward relations and reverse related fields;
- field-local named sources;
- Schema-owned
facets.storage; - explicit resolved projections with purpose and lineage;
- Schema examples;
- universal semantic metadata.
There are no canonical root Source or Storage registries, no field usage wrapper, no physical Schema-field reference convention, and no weak projection selector representation in Runtime IR.