# Naming

This document defines the serialization vocabulary shared by Runtime IR, the Authoring Protocol, compilers, loaders, serializers, packs, inspection, and tooling.

It is normative for Dryv-owned wire contracts.

## Core rule

Dryv separates four naming domains. They must not be conflated.

| Domain                            | Canonical form              | Example                                              |
| --------------------------------- | --------------------------- | ---------------------------------------------------- |
| Dryv-owned serialized object keys | `lower_snake_case`          | `primary_key`, `time_zone`, `max_attempts`           |
| Dryv-owned fixed symbolic values  | `lower-kebab-case`          | `starts-with`, `property-temporal`, `provider-hello` |
| User-authored identifiers         | preserve exactly            | `UserProfile`, `externalCustomerId`, `moneyAmount`   |
| Reserved/external-standard tokens | preserve governing spelling | `$ref`, `GET`, `application/json`, `Africa/Nairobi`  |

The compiler is the normalization boundary. Authoring APIs may use language-idiomatic spelling, but every compiler must emit the same canonical Runtime and Authoring Protocol vocabulary.

This contract defines the current unpublished format. Retired spellings are not canonical aliases and Runtime does not convert them.

## Dryv-owned keys

Serialized keys owned by Dryv use `lower_snake_case`.

Examples:

```text
timeZone          -> time_zone
primaryKey        -> primary_key
rateLimit         -> rate_limit
maxAttempts       -> max_attempts
mediaType         -> media_type
sessionId         -> session_id
runtimeIRVersion  -> runtime_ir_version
```

CamelCase Dryv keys are not canonical aliases.

`$ref` is intentionally exempt. It is a reserved structural key and remains `$ref` everywhere in canonical IR and protocol records.

Python implementations may require internal field aliases for reserved syntax such as `$ref` or language keywords such as `from`. Those implementation names do not change the canonical serialized spelling.

## Dryv-owned fixed values

Known Dryv discriminators, operators, protocol message types, and record kinds use `lower-kebab-case` when they contain multiple words.

Examples:

```text
startsWith             -> starts-with
notEqual               -> not-equal
greaterThanOrEqual     -> greater-than-or-equal
compile.request        -> compile-request
provider.hello         -> provider-hello
properties.primitive   -> property-primitive
properties.temporal    -> property-temporal
```

Single-word controlled values remain single words, for example `schema`, `operation`, `unknown`, `dynamic`, `required`, and `optional`.

## User-authored identifiers

Dryv never recursively normalizes arbitrary keys or names supplied by the author.

Authored identities include:

- property and schema names;
- schema/composite field names;
- enum member keys and authored enum values;
- union member names and discriminant field names;
- generic parameter names;
- operation input/output names;
- event, failure, policy, workflow, source, view, surface, feature, application, and presentation names;
- group names;
- storage names and authored index names;
- project-specific labels and binding names.

Example:

```text
schema: UserProfile
field: externalCustomerId
property: moneyAmount
union member: byExternalId
```

Canonical references preserve those exact path tokens, subject only to JSON Pointer escaping:

```yaml
$ref: "#/schemas/UserProfile"
$ref: "#/schemas/UserProfile/fields/externalCustomerId"
$ref: "#/properties/primitives/moneyAmount"
```

## External and standards-owned vocabulary

Dryv does not rename values whose spelling is governed by another standard or external system.

Examples include:

- HTTP methods such as `GET` and `POST`;
- media types such as `application/json`;
- IANA timezone IDs such as `Africa/Nairobi`;
- URI/path values;
- external provider identifiers where the contract declares them opaque;
- canonical version identifiers such as `dryv.ir/v1alpha1`.

A field containing an external value may still have a Dryv-owned snake_case key.

## Runtime IR examples

Canonical schema field:

```yaml
externalCustomerId:
  kind: property
  $ref: "#/properties/primitives/CustomerId"
  mutation: create-only
```

Canonical storage facet:

```yaml
facets:
  storage:
    primary_key:
      - externalCustomerId
```

Canonical query operators:

```yaml
query:
  filter:
    - starts-with
    - not-equal
    - greater-than-or-equal
```

The authored field name remains camelCase because it belongs to the author. The Dryv-owned keys and operators do not.

## Authoring Protocol examples

Client request:

```json
{
  "type": "compile-request",
  "session_id": "s1",
  "entrypoint": "authoring/app.ts",
  "protocol_versions": ["dryv.authoring/v1alpha1"],
  "runtime_ir_versions": ["dryv.ir/v1alpha1"],
  "batch_size": 64
}
```

Provider hello uses:

```text
type = provider-hello
compiler_id
compiler_version
author_version
author_compatibility
author_representation
protocol_versions
runtime_ir_versions
```

Canonical property records are:

```text
property-primitive
property-enum
property-composite
property-literal
property-union
property-record
property-tuple
property-generic
property-temporal
```

## Property registry naming

Canonical reusable property registries are exactly:

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

`unknown` and `dynamic` are direct field target kinds. They never create reusable registries and are not recursive type-expression variants.

## Compiler requirements

Every Author compiler must:

1. validate its own implementation-specific Author representation;
2. resolve authored declaration identities explicitly;
3. preserve user-authored identifiers exactly;
4. map Dryv-owned keys to canonical snake_case;
5. map Dryv-owned fixed values to canonical kebab-case;
6. emit reserved `$ref` rather than an implementation-specific `ref` key;
7. emit only current canonical Runtime registries and concepts;
8. reject authored constructs that cannot be represented canonically instead of emitting an older shape;
9. produce the same semantic IR for equivalent authoring in different languages.

A compiler must not apply a blind recursive case converter. Such a converter would corrupt authored identities and standards-owned values. Normalization belongs in explicit semantic mapping code.

## Enforcement

The naming contract must be reflected in:

- Runtime contract field names and controlled values;
- Runtime serialization and loading;
- Authoring Protocol contracts;
- every compiler implementation;
- protocol and mapping tests;
- canonical examples;
- pack-facing Runtime vocabulary;
- inspection and planning output where canonical IR fields are exposed.

Vocabulary that violates these rules is a contract defect, not a stylistic preference.
