# event

## Intent

A reusable semantic event with optional payload and explicit operation/workflow listeners.

Exact selection subject:

```yaml
subject: event
```

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`                | `event: EventContext`                |
| `all`                 | `events: EventContext[]`             |
| 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                                            |
| -------------------------- | ---------------------------- | ----------------------------------------------------------------- |
| `event.id`                 | `string`                     | Opaque stable semantic identity.                                  |
| `event.name`               | `NameContext`                | Stable semantic identity and finite naming variants.              |
| `event.description`        | `string\|null`               | Human semantic description.                                       |
| `event.tags`               | `string[]`                   | Semantic classifiers; empty when none.                            |
| `event.explanations`       | `ExplanationContext[]`       | Advisory usage/security/implementation notes.                     |
| `event.group`              | `SemanticLinkContext\|null`  | Owning semantic group.                                            |
| `event.feature`            | `SemanticLinkContext\|null`  | Canonical owning feature.                                         |     |
| `event.payload`            | `SemanticValueContext\|null` | Property/schema payload using the shared semantic-value contract. |
| `event.listeners`          | `EventListenerContext[]`     | Known listeners.                                                  |
| `event.listeners[].kind`   | `operation\|workflow`        | Listener kind.                                                    |
| `event.listeners[].target` | `SemanticLinkContext`        | Resolved listener.                                                |

## Usage rules

- Target kind is explicit; templates never infer operation/workflow from pointer prefixes.
- Do not invent broker/transport facets until proven.

## Runtime IR implications to audit

- Current event model is broadly useful; reverse emitter links can be derived if packs prove the need.

## Template example — Handlebars / TypeScript event

```hbs
export class
{{file.symbol}}
{ static readonly name = "{{event.name.qualified}}"; // payload type is rendered
by a pack-owned semantic-value macro constructor(public readonly payload:
{{renderValue event.payload file.dependencies}}) {} }
```

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