# property.composite

## Intent

A reusable structured value object made of named fields plus invariants.

Exact selection subject:

```yaml
subject: property.composite
```

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.composite: CompositePropertyContext`      |
| `all`                 | `properties.composites: CompositePropertyContext[]` |
| 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

This file defines the unique composite-property context. Its nested fields reuse the shared field-value contract.

| Context path                      | Type                        | Meaning / template use                                                                  |
| --------------------------------- | --------------------------- | --------------------------------------------------------------------------------------- |
| `property.composite.id`           | `string`                    | Opaque stable semantic identity.                                                        |
| `property.composite.name`         | `NameContext`               | Shared naming context from [README.md](/pack-builders/context/overview).                |
| `property.composite.description`  | `string\|null`              | Semantic description.                                                                   |
| `property.composite.tags`         | `string[]`                  | Semantic tags.                                                                          |
| `property.composite.explanations` | `ExplanationContext[]`      | Shared explanation context.                                                             |
| `property.composite.group`        | `SemanticLinkContext\|null` | Owning group link.                                                                      |
| `property.composite.feature`      | `SemanticLinkContext\|null` | Canonical owning feature.                                                               |     |
| `property.composite.lifecycle`    | `LifecycleContext`          | Shared lifecycle context.                                                               |
| `property.composite.examples`     | `CanonicalValue[]`          | Examples.                                                                               |
| `property.composite.fields`       | `CompositeFieldContext[]`   | Deterministic named fields.                                                             |
| `property.composite.invariants`   | `ExpressionContext[]`       | Full contexts from [expression.md](/pack-builders/context/expression), demand-resolved. |

### CompositeFieldContext

| Context path                           | Type                       | Meaning / template use                                                           |
| -------------------------------------- | -------------------------- | -------------------------------------------------------------------------------- |
| `property.composite.fields[].name`     | `NameContext`              | Field identity.                                                                  |
| `property.composite.fields[].value`    | `SemanticValueContext`     | Reuses [shared/semantic-value.md](/pack-builders/context/shared-semantic-value). |
| `property.composite.fields[].optional` | `boolean`                  | Field-local optional presence.                                                   |
| `property.composite.fields[].nullable` | `boolean`                  | Field-local nullable value.                                                      |
| `property.composite.fields[].array`    | `ArrayBoundsContext\|null` | Field-local array cardinality.                                                   |
| `property.composite.fields[].tags`     | `string[]`                 | Field-level tags.                                                                |

## Usage rules

- Composite fields reuse `SemanticValueContext`; templates never inspect pointer prefixes and nested reusable properties/schemas keep their authoritative context contract.
- Field maps become arrays with explicit names.

## Runtime IR implications to audit

- Properties should gain universal metadata.
- Provide a consistent type projection for property/schema-backed fields.

## Template example — Jinja / Python value object

```jinja
@dataclass(frozen=True)
class {{ file.symbol }}:
{% for field in property.composite.fields %}
    {{ field.name.snake }}: {{ render_field_value(field.value) }}
{% 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.composite 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?
