# view.part

## Intent

An independently selectable portion of a view that can generate a form, presenter, action component, or other UI fragment while retaining view ownership.

Exact selection subject:

```yaml
subject: view.part
```

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.part: ViewPartContext`         |
| `all`                 | `views.parts: ViewPartContext[]`     |
| 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.part.id`                     | `string`                         | Opaque stable semantic identity.                     |
| `view.part.name`                   | `NameContext`                    | Stable semantic identity and finite naming variants. |
| `view.part.description`            | `string\|null`                   | Human semantic description.                          |
| `view.part.tags`                   | `string[]`                       | Semantic classifiers; empty when none.               |
| `view.part.explanations`           | `ExplanationContext[]`           | Advisory usage/security/implementation notes.        |
| `view.part.group`                  | `SemanticLinkContext\|null`      | Owning semantic group.                               |
| `view.part.feature`                | `SemanticLinkContext\|null`      | Canonical owning feature, when present.              |
| `view.part.view`                   | `SemanticLinkContext`            | Owning view.                                         |
| `view.part.kind`                   | `present\|collect\|invoke`       | Structural variant.                                  |
| `view.part.present.source.port`    | `OperationPortLinkContext\|null` | Resolved output port being presented.                |
| `view.part.present.source.select`  | `SemanticPathContext[]`          | Selected subpaths.                                   |
| `view.part.present.context`        | `OperationInputBindingContext[]` | View-context→operation-input bindings of the source operation. |
| `view.part.collect.target.port`    | `OperationPortLinkContext\|null` | Resolved input port being collected.                 |
| `view.part.collect.target.collect` | `SemanticPathContext[]`          | Subpaths collected.                                  |
| `view.part.collect.target.context` | `ContextBindingContext[]`        | View-context values injected into target paths.      |
| `view.part.invoke.operation`       | `SemanticLinkContext\|null`      | Invoked operation.                                   |
| `view.part.invoke.context`         | `OperationInputBindingContext[]`         | View-context→operation-input bindings.               |

## Usage rules

- Variant-specific subtrees are null unless active.
- Resolved port links include index/name/value so UI templates can generate meaningful controls.
- First-class selection keeps the canonical root `view.part`.

## Runtime IR implications to audit

- Give view parts stable identity and universal metadata.
- Operation port naming is required for readable form/action context.
- Audit whether `kind` should become a selection filter after proof packs.

## Template example — Jinja / form component

```jinja
{% if view.part.kind == "collect" %}
export function {{ file.symbol }}() {
  return (
    <form>
      {/* collects {{ render_value(view.part.collect.target.port.value, file.dependencies) }} */}
      <button type="submit">Submit</button>
    </form>
  );
}
{% endif %}
```

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.part 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?
