# surface

## Intent

A delivery/presentation surface such as web, mobile, desktop, CLI, or embedded.

Exact selection subject:

```yaml
subject: surface
```

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`                | `surface: SurfaceContext`    |
| `all`                 | `surfaces: SurfaceContext[]` |
| collection candidates | `collects.group`             |

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                               |
| ---------------------- | ------------------------------------- | ---------------------------------------------------- |
| `surface.id`           | `string`                              | Opaque stable semantic identity.                     |
| `surface.name`         | `NameContext`                         | Stable semantic identity and finite naming variants. |
| `surface.description`  | `string\|null`                        | Human semantic description.                          |
| `surface.tags`         | `string[]`                            | Semantic classifiers; empty when none.               |
| `surface.explanations` | `ExplanationContext[]`                | Advisory usage/security/implementation notes.        |
| `surface.group`        | `SemanticLinkContext\|null`           | Owning semantic group.                               |
| `surface.kind`         | `web\|mobile\|desktop\|cli\|embedded` | Structural kind.                                     |
| `surface.views`        | `SemanticLinkContext[]`               | Derived views presented on the surface.              |
| `surface.applications` | `SemanticLinkContext[]`               | Derived applications including the surface.          |

## Usage rules

- `views` is a reverse index from view presentations; templates should not scan all views.
- Do not add kind-specific fields until real packs prove them.

## Runtime IR implications to audit

- Current surface variants should gain universal metadata.
- Provide efficient reverse indexes for views/application membership.

## Template example — Handlebars / view registry

```hbs
export const
{{file.symbol}}
= [
{{#each surface.views}}
  "{{name.pascal}}",
{{/each}}
] as const;
```

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