# property.union

## Intent

A named semantic union suitable for sealed types, discriminated unions, serializers, and schema alternatives.

Exact selection subject:

```yaml
subject: property.union
```

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

## Scope envelope

| Scope                 | Context                                     |
| --------------------- | ------------------------------------------- |
| `each`                | `property.union: UnionPropertyContext`      |
| `all`                 | `properties.unions: UnionPropertyContext[]` |
| collection candidates | `collects.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

| Context path                    | Type                        | Meaning / template use                               |
| ------------------------------- | --------------------------- | ---------------------------------------------------- |
| `property.union.id`             | `string`                    | Opaque stable semantic identity.                     |
| `property.union.name`           | `NameContext`               | Stable semantic identity and finite naming variants. |
| `property.union.description`    | `string\|null`              | Human semantic description.                          |
| `property.union.tags`           | `string[]`                  | Semantic classifiers; empty when none.               |
| `property.union.explanations`   | `ExplanationContext[]`      | Advisory usage/security/implementation notes.        |
| `property.union.group`          | `SemanticLinkContext\|null` | Owning semantic group.                               |
| `property.union.feature`        | `SemanticLinkContext\|null` | Canonical owning feature, when present.              |
| `property.union.lifecycle`      | `LifecycleContext`          | Deprecation/removal semantics.                       |
| `property.union.discriminant`   | `NameContext`               | Discriminator field name.                            |
| `property.union.members`        | `UnionMemberContext[]`      | Named alternatives.                                  |
| `property.union.members[].name` | `NameContext`               | Alternative name.                                    |
| `property.union.members[].type` | `TypeContext`               | Alternative type.                                    |

## Usage rules

- Current member map becomes explicit named entries.
- The discriminant is semantic; target annotation syntax is not.

## Runtime IR implications to audit

- Properties should gain universal metadata.
- Audit how each member's discriminant value is canonically represented so packs never infer it.

## Template example — Jinja / TypeScript union

```jinja
export type {{ file.symbol }} =
{% for member in property.union.members -%}
  | {{ render_type(member.type) }}{{ ";" if loop.last else "" }}
{% endfor %}
```

The example uses semantic context only. Any `renderType`/`render_type` helper shown is a pack-owned macro/partial consuming the documented `TypeContext`, not hidden Dryv context.

## Audit questions

- Can a real property.union pack generate code without parsing raw IR storage conventions?
- Is any field here present only because the current IR happens to store it?
- Does any nested item need first-class selection of its own?
