# view

## Intent

A semantic user-facing view composed from named context values, independently meaningful parts, and one or more surface presentations.

Exact selection subject:

```yaml
subject: view
```

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`                | `view: ViewContext`                  |
| `all`                 | `views: ViewContext[]`               |
| 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                               |
| ------------------------------ | --------------------------- | ---------------------------------------------------- |
| `view.id`                      | `string`                    | Opaque stable semantic identity.                     |
| `view.name`                    | `NameContext`               | Stable semantic identity and finite naming variants. |
| `view.description`             | `string\|null`              | Human semantic description.                          |
| `view.tags`                    | `string[]`                  | Semantic classifiers; empty when none.               |
| `view.explanations`            | `ExplanationContext[]`      | Advisory usage/security/implementation notes.        |
| `view.group`                   | `SemanticLinkContext\|null` | Owning semantic group.                               |
| `view.feature`                 | `SemanticLinkContext\|null` | Canonical owning feature, when present.              |
| `view.context`                 | `NamedValueContext[]`       | Named semantic values available to the view.         |
| `view.parts`                   | `ViewPartContext[]`         | Same item contract as the `view.part` subject.       |
| `view.presentations`           | `ViewPresentationContext[]` | Named surface presentations.                         |
| `view.presentations[].name`    | `NameContext`               | Presentation identity.                               |
| `view.presentations[].surface` | `SemanticLinkContext`       | Target surface.                                      |

## Usage rules

- `view.parts[]` must reuse the exact `ViewPartContext`.
- Making parts selectable does not flatten them out of the view hierarchy.
- Context/presentation map keys become explicit names.

## Runtime IR implications to audit

- Current `View` should gain universal metadata.
- View parts need stable canonical identities for selection/indexing.

## Template example — Handlebars / React composition

```hbs
export function {{file.symbol}}() {
  return (
    <main>
    {{#each view.parts}}
      <{{name.pascal}} />
    {{/each}}
    </main>
  );
}
```

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 view 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?
