# Properties

Properties are reusable value definitions shared across Dryv Authoring, canonical Runtime IR, and template packs.

This page describes the current contract. Earlier unpublished Property shapes are not compatibility inputs.

## Reusable property families

Canonical Runtime IR has exactly nine property registries:

```text
primitives
enums
composites
literals
unions
records
tuples
generics
temporal
```

There is no catch-all `types` registry and there are no `unknowns` or `dynamics` registries.

## Primitive properties

Primitive properties are string, number, and boolean definitions.

String semantics are explicit:

```yaml
properties:
  primitives:
    DisplayName:
      type: string
      kind: text
      length:
        min: 1
        max: 120

    Email:
      type: string
      kind: format
      format: email
```

Number semantics use `type: number` with a numeric `kind`:

```yaml
properties:
  primitives:
    Count:
      type: number
      kind: integer
      format: non-negative-integer
      range:
        min: 0

    Price:
      type: number
      kind: decimal
      format: money
      precision: 12
      scale: 2
      currency: KES

    PriceCents:
      type: number
      kind: integer
      format: money
      minor_units: true
      currency: KES
```

`integer` is not a primitive `type`.

Money is a number with `format: money`. In major units it's a `decimal` with precision and scale. With `minor_units: true` it's an `integer` count of minor units (cents). `currency` is an optional ISO 4217 code. `currency` and `minor_units` are valid only on money.

## Temporal properties

Dates, times, instants, durations, intervals, year-month, and month-day are first-class reusable temporal properties:

```yaml
properties:
  temporal:
    CreatedAt:
      kind: instant
      precision: millisecond

    MaintenanceWindow:
      kind: interval
      point:
        $ref: "#/properties/temporal/CreatedAt"
      range:
        min: PT5M
        max: PT2H
```

Temporal meaning is not encoded through a string-format fallback.

## Enum properties

Enums define reusable closed scalar sets with authored member keys and values:

```yaml
properties:
  enums:
    Status:
      values:
        active:
          value: active
        disabled:
          value: disabled
```

`ordered: true` makes declaration order semantic and enables ordering operations.

## Composite properties

Composites define reusable structured values without making them source/schemas/entities:

```yaml
properties:
  composites:
    Money:
      fields:
        amount:
          kind: property
          $ref: "#/properties/primitives/Amount"
        currency:
          kind: property
          $ref: "#/properties/primitives/Currency"
```

Composite invariants reference named canonical Expressions. They are reusable value-level rules evaluated against the composite value rather than embedded anonymous rule objects:

```yaml
properties:
  composites:
    shared.Range:
      fields:
        min:
          kind: property
          $ref: "#/properties/primitives/shared.Number"
        max:
          kind: property
          $ref: "#/properties/primitives/shared.Number"
      invariants:
        - $ref: "#/expressions/shared.ValidRange"
```

The Expression owns the reusable rule; the Composite owns the fact that the invariant applies to its value.

## Literal, union, record, and tuple

These remain distinct reusable families:

```text
literal -> one exact scalar/null value
union   -> one explicitly named discriminated alternative
record  -> explicit key/value map meaning
tuple   -> fixed positional sequence meaning
```

Reusable unions are always discriminated:

```yaml
Identifier:
  discriminant: identifierKind
  members:
    byUuid:
      kind: reference
      $ref: "#/properties/primitives/Uuid"
    bySlug:
      kind: reference
      $ref: "#/properties/primitives/Slug"
```

A canonical value uses the union's discriminant plus `value`:

```yaml
identifierKind: byUuid
value: 018f6f0d-7e6b-7c4c-bca2-4cc840e9d8f5
```

## Generic properties

Generic definitions and reusable applications share `properties.generics`:

```yaml
Page:
  kind: definition
  parameters:
    - name: T
  value: {}
```

```yaml
UserPage:
  kind: application
  $ref: "#/properties/generics/Page"
  arguments:
    - kind: reference
      $ref: "#/schemas/User"
```

Applications use positional arguments and must match the target definition's parameter count exactly.

## Direct unknown and dynamic

`unknown` and `dynamic` are direct field targets only:

```yaml
fields:
  providerPayload:
    kind: unknown

  runtimeMetadata:
    kind: dynamic
```

They are not reusable properties and cannot occur recursively inside `TypeExpression`.

## Field target contract

Canonical field kinds are:

```text
property
schema
unknown
dynamic
```

```text
property -> $ref required
schema   -> $ref required
unknown  -> $ref forbidden
dynamic  -> $ref forbidden
```

Presence, nullability, and arrays remain use-site semantics.

## Naming and compiler normalization

```text
Dryv-owned keys          lower_snake_case
Dryv-owned fixed values  lower-kebab-case
Authored identifiers     preserve exactly
External/reserved tokens preserve exactly
```

An Authoring implementation may expose idiomatic host-language names, but its compiler must emit canonical Runtime names and values explicitly. It must not recursively rename authored identifiers such as `moneyAmount`, `UserProfile`, `externalCustomerId`, or union member names.

Canonical references use `$ref`.

See:

- `.tasks/docs/design/ir-properties.md`
- `.tasks/docs/design/canonical-naming.md`
- `.tasks/docs/design/ir.md`

## Authoring expectations

An Authoring SDK may provide ergonomic constructors and infer which canonical registry owns a declaration. The compiler remains responsible for producing the exact current Runtime contract and rejecting meaning that cannot be represented without hidden semantics.

## Pack expectations

Packs consume canonical property meaning directly. They may support, lower, bind, or explicitly reject a concept depending on target capability, but must not redefine it.
