# Canonical Dryv Runtime IR

Runtime IR is the semantic center of Dryv: one portable, language-neutral
contract shared by authoring implementations, the engine, packs, clients, and
tools.

There is one Dryv Runtime IR. There is not a Python IR, TypeScript IR, or
renderer-specific IR.

## One semantic authority

Runtime IR is the only authority for what described software means.

Authoring produces it. The runtime validates, resolves, indexes, inspects,
hashes, serializes, loads, and plans from it. Packs consume bounded context
derived from it.

Generated application code does not become a competing semantic authority after
generation.

## Canonical properties

Canonical Runtime IR should remain:

- language-agnostic;
- framework-agnostic;
- runtime-agnostic;
- portable;
- explicit;
- deterministic;
- inspectable;
- versioned;
- usable by both humans and automated agents.

Stable identity must not depend on host-language object identity.

## Typed relationships

Canonical concepts connect through explicit directional relationships.

Examples include:

```text
Schema extends Schema
StorageMapping maps Schema
Operation uses Policy
Operation may fail with Failure
Operation emits Event
Workflow waits for Event
View triggers Operation
Presentation places View
```

The authored direction is stored explicitly. Reverse relationships can be
derived by the runtime.

## Authored facts and derived facts

Dryv avoids forcing authors to maintain the same relationship twice.

If an Operation emits an Event, the Operation can author that forward
relationship. Runtime can derive an index of Event emitters for inspection or
template context.

This reduces contradictory state while preserving rich queries.

## One Schema concept

Typed structure reuses the same Schema concept across:

- operation inputs and outputs;
- event payloads;
- workflow data;
- nested fields;
- views and other typed interactions.

A request DTO, database entity, SDK model, or form model is normally a
pack-specific representation of canonical structure rather than a separate
canonical root.

## Serialization is transport

Runtime IR can be transported through formats such as JSON, JSONL, or YAML
without creating separate semantics.

A serialized Runtime IR document can be loaded without the original authoring
runtime. That is a core portability property.

## Provenance

Runtime IR should retain enough provenance to explain:

- which authored declaration produced a concept;
- where inherited or composed facts originated;
- which relationships were authored directly;
- which facts were derived later;
- how a generated result traces back to canonical meaning.

Provenance is part of explainability, not merely debugging metadata.

## The canonical-root test

Before introducing a new Runtime IR root, ask whether the concept has durable,
language-neutral meaning independent of how one target stack likes to generate
code.

If the idea exists only because a template or framework wants a role such as
controller, repository, DTO, page, or component, it normally belongs in the
pack rather than Runtime IR.
