# View renderer contract

This is what a renderer owes AFUI. It is written for anyone who draws an AFUI
declarative session: the built-in web renderer, and renderers that a host
implements natively. The view protocol does not say these things, and AFUI
depends on them, so they are written down here and checked by a shared set of
fixtures instead of being rediscovered one renderer at a time.

The words MUST, MUST NOT and SHOULD carry their usual meaning. Every MUST has an
id of the form `R-AREA-n`. Ids are stable: they are never renumbered or reused,
and a rule that goes away leaves its id retired. A fixture names the ids it
verifies in `covers`, and every id is covered by at least one fixture.

## What the contract covers

A session has one runtime channel and one declaration. Which panels it has and
what they are called is the session's business. A renderer is a parameter of the
session, and it only draws what the session sends. This contract covers what a
renderer does with the content of one session: the messages it receives, the
person's input it holds, the actions it sends, and the faults it reports.
Delivery, credentials, expiry and the session's outcome are not the renderer's
concern.

**A connection draws one view.** Each panel of a session has a view of its own,
with its own components and its own data model, and a viewer mounts one panel:
the one it names in the `panel` of the hello it opens its connection with, or the
declaration's default panel when it names none. The session sends a viewer only
the messages of that panel's view, so a renderer holds exactly one view, and no
message names a panel or a view. A host that shows several panels opens one
connection for each.

Terms used below:

- A **view** is one tree of components with its own data model. It starts
  empty: no components, and an empty object for a data model.
- A **message** is one operation on the view: update its components, update its
  data model, update its own toolbar slots.
- An **incremental message** is one operation, applied on its own to what the
  renderer is showing.
- A **replacement** is the messages that build the whole view from an empty one,
  in one message or in parts. The session sends one when a viewer starts or has
  to start over, and when it replaces the whole view, which is also how a view
  is emptied: a replacement with no messages leaves it empty.
- An **edit** is a change a person makes to a value that is bound to the data
  model.
- **Local UI state** is state that belongs to the view and not to the data.
- A **fault** is a condition the renderer reports to the session.

## Connection and replay

**R-REPLAY-1** A replacement is delimited, and a renderer MUST read it so. It is
one or more parts, numbered from zero, and every part says how many parts the
replacement has. The part numbered zero begins it and the part numbered one less
than the count ends it, so a replacement of one part is the whole of it in a
single message. A part carries the messages that build the display, or none. A replacement whose messages are none leaves the view empty, and nothing is displayed. A renderer MUST
read the parts in order, and MUST treat a part that does not follow the one
before it, or a message that is not a part arriving between two parts, as a fatal
fault.

**R-REPLAY-2** While a replacement is incomplete, the renderer MUST keep showing,
unchanged and responsive, the view it showed before it began. When the
replacement is complete, the renderer MUST swap the display in one step to the
view its messages built. Nothing of the old view is left afterwards.

**R-REPLAY-3** A renderer starts out waiting for a replacement, and goes back to
waiting when the runtime reports that this viewer must start over (a restart).
While it waits, the renderer MUST ignore every message that is not the part
numbered zero of a replacement, and MUST discard any replacement it had only
partly received. It MUST keep showing what it showed, and it applies nothing
until a replacement begins.

**R-REPLAY-4** When a dropped connection resumes and the runtime does not report
a restart, the renderer MUST NOT rebuild, clear or reset anything. The view, its data
model, local UI state and the person's edits stay as they were. A replacement
that was partly received stays partly received, and its next part carries on
from it.

A message the renderer receives from the runtime is an object with one key that
names it. It is an operation on the view (`updateComponents`, `updateDataModel`,
`updateView`), applied on its own to what the renderer is showing, or one part of a replacement:

```json
{"replace": {"part": 0, "parts": 2, "messages": [
  {"updateDataModel": {"path": "/", "value": {"name": ""}}},
  {"updateComponents": {"components": [{"id": "root", "component": "Text", "text": "Hello"}]}}
]}}
```

The messages of a replacement are operations on the view; they build it from an
empty one. A view is not created or deleted: it is built by operations, replaced
whole, and emptied by a replacement with no messages. There is no version and no
catalog on a message: a session has one catalog, and no message names a view
or a panel. The renderer reads the restart as the runtime's `onRestart` signal.

## Panels

**R-PANEL-1** A connection that mounts a panel the session does not declare is
declined before it is listed: the session ends it with a refusal, under the code
`view_panel_undeclared`, whose structured detail names the panel and the panels the
session declares. The refusal is not a message of the view; the renderer reads it
from the end of its connection, as the runtime's closed state with its reason and
detail. A renderer MUST then draw no view, MUST show the person one sentence that
says the panel is not offered, built from the code and the detail and never from
the words the session sent with it, and MUST ignore every message after it. It MUST
NOT connect again, MUST NOT fall back to another panel, and MUST NOT report the
refusal to the session; the session is the one that refused.

The panel a renderer mounts is the `panel` of its hello. The web renderer takes
it from the `?panel=` of the page address, as page code does, and sends none when
the address names none.

## Versions

A session is built with one version of the catalog, `major.minor`, and the
extensions it uses, if any; that set is what a renderer has to implement to draw it,
and it is written once, in the session's metadata, where a host can read it before it
connects. A renderer that draws says what it implements in the `viewer` payload of its
hello, which the runtime hands on unread: `implements`, the same set, with the version
it draws and the extensions it has, each with its own. A connection that does not draw,
one that only answers focus requests, says neither `implements` nor `panel` and is not
judged; a payload that draws MUST carry `implements`, and one that mounts a `panel`
without it is declined under `view_implements_invalid`. Minor versions
only add entries to a major version, so a renderer that implements `1.3` draws every
session built with `1.0` to `1.3`; any other major version shares nothing.

**R-VERSION-1** A connection whose `implements` does not satisfy the session's set, or
that mounts a panel and carries no `implements` at all (`view_implements_invalid`), is
declined before it is listed, under a code of its own: `view_major_unsupported` when the
major versions differ, `view_minor_unsupported` when the major version agrees and the
renderer's minor is lower, `view_extension_unsupported` when an extension the session
uses is missing or too old, the first that applies in that order. The structured detail
carries the session's set, the renderer's, and every item that is lacking as an object,
a `view` item with what it requires and what was offered or an `extension` item with its
name. A renderer MUST then draw no view, MUST show the person one sentence built from the
code and the detail and never from the words the session sent with it, one that says
which side has to be updated, and MUST ignore every message after it. It MUST NOT connect
again and MUST NOT report the refusal to the session. A native renderer that cannot
draw a session may instead hand it to a renderer that can; what it MUST NOT do is draw
part of it.

## The view and its data

**R-DATA-1** A data model update MUST write its value at its path. An update with
no path addresses the model root and replaces the whole model. A null value
removes what is at the path. The data a replacement sets MUST be in place before
its components read anything.

**R-DATA-2** Whatever a component shows from the data model MUST follow the
model: when the value at a path it reads changes, or the value at a path above or
below it does, the component shows the new value. A list whose children come from
a template over an array has one row for each element of the array. A
row follows its element, and when the array is replaced as a whole every row
shows the new element at its position. Rows beyond the end of a shorter array are
removed.

## Human edits

A person's input reaches the provider by one road. The renderer reports each
edit to the session as it is made, on the ordered road it sends actions on, so
an action always arrives behind every edit that came before it; the session
keeps each viewer's edits apart from the view the provider wrote, and the
provider that receives an action is handed the data model with that viewer's
edits laid over it. That is a guarantee of the protocol, not an option, and an
action carries only its name and the explicit parameters its component defines.

What the renderer reports and hears, as messages:

- `{"edit": {"path", "value", "revision", "number"}}` goes up, one for each
  place the person changed. `revision` is the revision of the last write of the
  provider that the renderer had applied when the person made the edit, and
  `number` counts up by one for each edit message the renderer sends.
- `revision` rides on each `updateDataModel` message and on the parts of a
  `replace` the session sends: the number of the provider's writes the view is
  as of. A replacement carries `edits` too, the number of the last edit of this
  viewer's that the view in it already holds.
- `{"editsRefused": {"refused": [{"path", "code", "message"}]}}` comes down when
  the session could not keep edits of this viewer, and says all of them each
  time; an empty list says there are none.

**R-INPUT-1** While an input method editor is composing text in a field, the
renderer MUST NOT write the intermediate text to the data model and MUST NOT
report it as an edit. The committed text is the edit, and it is reported once.
Echoing a value into a field, whether the person's own or the provider's, MUST
NOT reset the caret or the selection when the field already shows that text.

**R-EDIT-7** The renderer MUST report each edit a person makes, as one message
with the data model path, the value, the `revision` it had applied and the next
`number`. A change a person makes to the bound state of a control counts: a
text, a toggle, a selection, an expansion or a sort that is bound to a path. A
value the provider wrote is never reported as an edit.

**R-EDIT-8** The renderer MUST report edits by path: a later edit replaces the
edits it has not yet sent at its own path and beneath it, so one value goes out
for each place. It MUST send an edit no later than 300 ms after the
last change at its path and no later than 1000 ms after the first change it has
not yet sent, MUST send everything it holds at once when focus leaves a control,
and MUST send in the order the edits were made.

**R-EDIT-9** A write of the provider to the data model changes the edits the
renderer holds, and the session changes the edits it holds by the same rule,
which is the only one. A write at the path of an edit, or above it, takes the
edit whole. A write below the path of an edit takes that part of the edit's
value and leaves the rest, which the renderer MUST treat as one edit for each
piece the write did not reach; an array is not taken apart, so a write inside
an array the edit carries takes the whole array, and a value that is not an
object has no part to take and is kept whole. A write anywhere else leaves the
edit as it is, and a path that merely begins with the same characters is
elsewhere. A write at the root, with no path, is above every path. A write
takes edits the renderer holds whether or not it has sent them, and an edit
that survives is from then on made after that write.

**R-EDIT-10** Before the renderer sends an action it MUST send every edit it
has not yet sent, and MUST send the action after them. If the road to the
provider has no room for them yet, the renderer MUST NOT send the action: the
action ends in a failure the person can try again, the component is not left
waiting, and the action goes once there is room. If an edit can never be sent,
it is refused as R-EDIT-13 says, and the renderer MUST NOT send actions until the
person has made the edit again or a write of the provider has reached its path.

**R-EDIT-11** When the session starts this viewer over with a replacement that
says how many of the viewer's edits it holds (`edits`), the renderer MUST lay
over the view that replacement builds every edit it holds that has a higher
number than that, and the ones it has not yet sent, oldest first, and MUST NOT
lay over the ones the session says the view holds. An edit the new data model
cannot hold, because a value on its path is not an object where the path needs
one, is left out of the display; that is not a fault. The renderer holds, for
this, no more than it has not yet sent and the edits it sent last.

**R-EDIT-12** A replacement the provider sends, as against one that starts the
viewer over, is a write at the root: the renderer MUST discard every edit it
holds, sent or not, and report none of them.

**R-EDIT-13** While the session reports edits of this viewer as refused, the
renderer MUST show the person, near the interface, that a change was not kept,
and MUST stop showing it when the session reports none. An edit the renderer
could not send is shown the same way until it is made again, or until a write
of the provider reaches its path. The session turns the viewer's actions away
while it holds a refused edit, because the provider would otherwise be handed a
view without it; the renderer shows an action turned away for that reason with
its own notice, not the session's text.

The ids R-EDIT-1 to R-EDIT-6 are retired: they had the renderer hold the person's
edits and give them back itself.

## Actions

An action has one road, the session runtime's request: the renderer opens a
request, the provider may answer it with progress any number of times, and it
ends with a result, an error, or a cancellation. There is no other message an
action travels in and no other message that answers it, and a request carries nothing
but an action: no function is called across the road in either direction; what the person sees is
what R-REPLY-1 to R-REPLY-3 say of those answers.

**R-ACTION-1** An action the person triggers MUST be sent as one request whose
body is the action itself: one object that holds `name`, `sourceComponentId` (the component), `timestamp` (an ISO 8601 instant),
`userMessage` when the action defines one, and `context`. `context` holds one value for each key the action
defines, each evaluated at the moment of the trigger. The keys keep their names,
whatever they are. It carries nothing else: what the person entered reaches the
provider as edits (R-EDIT-10), not in the action.

**R-ACTION-3** While an action of a component awaits its reply, the renderer
MUST NOT send another action from that component. The component shows that it is
waiting, and takes triggers again when the reply has come.

When the provider answers an action, the renderer shows the answer to the person
in a status notice near the interface, and marks the component with a state:
waiting, progress, succeeded or failed. The notice always belongs to the latest
action.

**R-ACTION-4** A request that is cancelled before the provider answers, which the
runtime reports as the code `ui_request_cancelled`, ends the action as failed.
The notice is the renderer's own text for a cancelled action, and the code MUST
NOT appear in it.

**R-ACTION-5** An action that ends in failure, whatever the reason and whether
or not the failure says it can be tried again, leaves the component ready for
the next trigger, and the renderer MUST send that trigger as a new action. It
MUST NOT send an action again by itself.

**R-REPLY-1** A progress answer sets the component's state to progress. When it
carries a message, the renderer MUST show that message in the notice. A code
that comes with it is a hook for customisation, not text for the person.

**R-REPLY-2** A successful answer sets the state to succeeded. When it carries a
message, the renderer MUST show it. Otherwise the notice is cleared.

**R-REPLY-3** A refusal sets the state to failed and the renderer MUST show the
person the message that came with it. A refusal without a message shows a generic
notice from the renderer's own labels. The error code is machine-readable and
MUST NOT appear in text the person reads. It stays available to hosts through an
attribute or property for customisation.

## Local UI state

A renderer keeps two kinds of state apart. State that is bound to a path in the
data model is business state: the data model holds it and the provider can read
and write it. State that nothing in the data model names is local UI state. The
renderer keeps it for as long as the component exists.

**R-UISTATE-1** The local UI state the renderer MUST keep is this.

| State | Local when |
| --- | --- |
| expanded or collapsed state of a `Disclosure` | its `open` is not bound to a path |
| open confirmation on a `Button` | while that button has `confirm` |
| selected tab of `Tabs` | always |
| sort column and direction of a `Table` | its `sort` is not bound to a path |
| scroll position of a list or table | always |
| input focus, and the selection inside a focused text field | always |

It is kept for each component and each instance of it. A component that a
template repeats once for each element of an array has an independent state for
each element. A kept value that no longer fits, such as a tab index beyond the
tabs that exist or a sort key that names no column, is ignored and the default
applies.

**R-UISTATE-2** Local UI state MUST survive every incremental message, including
a component update that makes the renderer draw the view's tree again.

**R-UISTATE-3** Local UI state MUST survive a replacement. The view the
renderer builds from it shows the same expansion, tab, sort, scroll position and
focus, for every component that is still there.

**R-UISTATE-4** State that is bound to a path is business state and nothing else.
The renderer MUST show what the data model says, and a change the person makes
MUST write the model and be held only there. A bound `Disclosure` writes `true` or `false`
at its `open` path, and a bound `Table` writes `{"key", "direction"}` at its
`sort` path.

**R-UISTATE-5** The scroll position of the area a list or table is scrolled in,
the input focus and the selection inside the focused text field MUST survive every
incremental message and every replacement, for as long as the component is still
there. A renderer that draws the view again puts them back. A list has no
scrolling of its own in the web renderer: the page scrolls, and that scroll
position is the list's, and so is a table's (R-PANEL-3). The
fixtures name the position as the item at the start of the area.

## Media resources

This section has no rules yet. `Image` takes its address from `url`. The page
renderer loads that address as it is, and a session serves the images it was
given as assets from addresses of its own. `Video` and `AudioPlayer` have no
private-resource path at all today. How a renderer fetches the bytes of a
resource that belongs to the provider or to the session, so that web and native
renderers, remote access included, behave the same, is not decided. When it is,
it will be written here with rules and fixtures.

## The AFUI catalog

These are the rules on which AFUI's own components and properties need a renderer
to agree. The rest of a component's behaviour follows the catalog definition.

**R-CATALOG-1** A renderer MUST accept and draw everything the catalog defines:
every component, every property of a component, every enumerated value and every
function. A conformance case exercises each component, each property and each
function, and a check fails when one is missing.

**R-BUTTON-1** A `Button` MUST show its `label` as its text when `iconOnly` is false or omitted, and the label MUST be
the accessible name of the button unless overridden by R-ACCESS-1. An `icon`, when there is one, is shown beside the
label as decoration: it MUST be hidden from assistive technology and MUST NOT add to
the name.

**R-BUTTON-2** When `iconOnly` is true, a `Button` MUST require `icon` and show
only that icon. It MUST use `label` for the accessible name unless overridden by
R-ACCESS-1. The web renderer MUST set the button's `title` to `label` and keep
the target at least 2.75 rem wide and high. An omitted `icon` MUST cause a fatal
validation fault at the `icon` property. This presentation adds no local UI state.

**R-CONFIRM-1** A `Button` with `confirm` MUST present its message in a modal
confirmation. It MUST close before sending an action on confirmation and MUST
send no action on cancellation. It MUST keep an open confirmation across
redraws of the same instance. The `danger` variant highlights a potentially
destructive action, independently of whether the button requests confirmation.

**R-BADGE-1** A Badge MUST show its text in an inline capsule with a distinct glyph and colour for each level. Its accessible name MUST include its text and level unless overridden by R-ACCESS-1. The level defaults to neutral when omitted. A resolved level outside the catalog enumeration MUST cause a fatal validation fault at the level property. A Badge has no local UI state.

**R-CALLOUT-1** A Callout MUST show its optional title and required text with the glyph of its current level. A neutral, info or success callout MUST be a status region, and a warning or danger callout MUST be an alert. Its accessible name MUST be the title when present and the localised level otherwise, subject to R-ACCESS-1. The defaults and faults for level follow R-BADGE-1. A Callout has no local UI state.

**R-CHECKS-1** Each failed `@checks` rule with a message MUST display one separate line below the control that declares the check, in declaration order. The control MUST reference its active messages through `aria-describedby` alongside its helper text. A grouped picker is described as a group. Each enabled part of a date and time field is described. Passing a check MUST remove its message and association. A failed button check MUST continue to block the action. The messages are derived from current values and have no local UI state.

**R-TEXT-1** A `Text` MUST show its text exactly as given: no marker in it, such as a
leading `#`, changes how it is shown. A `Text` with `heading` 1, 2 or 3 MUST be a
heading of that level in the document outline, and a `Text` without `heading` MUST NOT be
one.

**R-LINK-1** A `Link` MUST show its `text` as a link to its `url`, a link that opens
outside the view without handing the page it came from to the one it opens: `rel` is
`noopener noreferrer`. The text MUST be the accessible name of the link unless overridden by R-ACCESS-1. Only an address
with the scheme `http`, `https` or `mailto` is followed, and the renderer MUST decide that
on the address as it stands after reading it, whether it is written in the component or
comes from the data model; no other scheme is followed, `javascript` and `data` and
`file` among them, and an address without a scheme is not one.

**R-LINK-2** A `Link` whose `url` is not an address that R-LINK-1 follows MUST show its `text`
as plain text with nothing to follow, and the renderer MUST report it, once for each
component and address, as a non-fatal fault with the code `LINK_URL_REFUSED`. A `url` that is
missing or empty is shown the same way and is not a fault.

**R-ACCESS-1** When a component with a semantic control has `@accessibility.label`, the
renderer MUST use it as the accessible name of the control itself. Composite
controls with individually named parts, such as a chooser, MUST retain those names
and name the group. A combined date and time control MUST distinguish the two
inputs in their names.

**R-ROW-1** A `Row` MUST wrap in a narrow pane and align its children on the cross
axis. With no `align` property it MUST center leaves and start-align all children
when any child is a container. When given, `align` MUST take precedence and align
children at the start, center or end.

**R-FACT-1** A `FactList` MUST present its labels and values in order as a
definition list. Their columns align in a wide pane and each label sits above
its value in a narrow pane. Numbers follow the viewer's locale and structured
values use JSON. An absent bound list is empty. A supplied list or fact with
the wrong shape MUST cause a fatal validation fault. This component has no
local UI state.

**R-IMAGE-1** An `Image` MUST show the entire image for `figure`, the default.
An `avatar` MUST use a small circular frame that may crop the image. A `banner`
MUST fill a wide frame and may crop the image. The supplied description MUST
name the image unless overridden by R-ACCESS-1. These variants have no local
UI state.

**R-CHOICE-1** A choice option's `description`, when it resolves to text, MUST
appear below the label and be associated with the option for assistive
technology. The option's label remains its accessible name. An empty
description takes no space. A description changes no selection or other UI state.

**R-LIST-1** A `List` that has `emptyText` MUST show it while the list has no item,
including when the path of its template is missing from the data model, and MUST NOT
show it while the list has an item.

**R-VISIBLE-1** The `visible` property MUST change presentation only. A component
whose `visible` is false, and everything inside it, is not displayed, and nothing
in it can be reached. Its bindings keep tracking the data model, and the data it
holds stays in the model.

**R-VISIBLE-2** A renderer MUST read `visible` as true when the value is `true`, a number other than
zero, the string `true` in any case, or a validation result whose `valid` is true.
Any other value, including a value that is null or missing, is false. When the
`visible` expression fails to evaluate, the component is displayed.

**R-PROGRESS-1** A `Progress` MUST be determinate when its `value` is a finite
number. Then its ratio is `value` held between 0 and `max`, divided by `max`.

**R-PROGRESS-2** A renderer MUST take `max` to be 1 unless it is a finite number
greater than zero. A missing, null, zero, negative or non-numeric `max` means 1.

**R-PROGRESS-3** A `Progress` whose `value` is missing, null or not a finite
number MUST be shown as having an unknown extent, the indeterminate state. It
MUST NOT be shown as empty. A number written as a string is not a number here.

**R-PROGRESS-4** When `label` is set, it MUST be the accessible name of the progress unless overridden by R-ACCESS-1,
and the renderer MUST also show it near the progress.

**R-TABLE-1** A `Table` MUST sort by the raw value of the sort key in each row's data unless R-TABLE-3 applies. Among the values that are not null the kinds
come in this order: numbers by magnitude, timestamps with an offset by the
instant they denote, other strings in natural order (runs of digits compare as
numbers), booleans with false first, and anything else together. Descending is the
reverse of that order.

**R-TABLE-2** Null values and rows without the key MUST sort after all the others,
whatever the direction. Rows that compare equal MUST keep their original order,
in both directions.

**R-TABLE-3** A column with `level` MUST evaluate it in each row and render its
existing text as a Badge. A resolved level outside the catalog enumeration MUST
cause a fatal fault at the column's level property. This column sorts by the
displayed value as text and keeps null or missing values last. It adds no local
UI state.

**R-CODE-1** A `CodeBlock` MUST show `code` as literal text. Line breaks and
indentation are kept, and markup in the text is not interpreted.

## Panels, actions and entries

A view has a toolbar of its own, and `root` says what kind of panel it is. An action is a `Button`, and every object that
owns actions (the view, a `Section`, an `Item`, a table row, a `Form`) names one primary action and an ordered list of
others. The rules below say what a renderer draws and does for them.

**R-PANEL-2** The toolbar MUST draw the primary action of the view first, if it is shown, and then the actions in the order
they are declared; that is its order for the keyboard and for assistive technology. When the room is short it MUST fold
actions into a menu from the end, in order. The part that stays and the part that is folded MUST each lose the dividers
that are left at their start or end, or next to another divider, by the one same rule; a toolbar with nothing to show is not
drawn. A change of the view's slots (`updateView`) MUST be drawn at once, and a slot that a message does not name is emptied.

**R-PANEL-3** A panel MUST have exactly one vertical scroll, whatever `root` is: a `List` or `Table` at the root runs to the
edges of the panel, a `Form` or `Section` is drawn as grouped fields, each tab of `Tabs` is drawn as what its own child is,
and a `Column` is segments, in which a `List` or `Table` grows to its content and does not scroll. No container inside the panel
scrolls vertically (a long text input excepted). The toolbar, the header of a table and the header of a section in a list MUST stay at
the top of that one scroll as it moves.

**R-BUTTON-3** Where a `Button` is mounted decides which of its presentation properties apply. Alone, `label`, `icon`,
`iconOnly` and `variant` all do. In the toolbar, a section header, the footer of a form and the buttons of a dialog `label`, `icon`
and `variant` do, `iconOnly` is not asked, the renderer stands out the primary action and chooses between icon and label by the
room, and the accessible name stays the label. In a menu (a `Menu`'s members, the actions of an entry, folded actions, and
a primary action shown in a menu) the label, the icon and `danger` apply and `iconOnly` and the other variants do not. A menu
item without an icon MUST NOT be refused or hidden: a renderer that wants an icon supplies one by meaning.

| Mounted in | Properties that apply |
| --- | --- |
| alone | `label`, `icon`, `iconOnly`, `variant` |
| the toolbar, a section header, a form or dialog footer | `label`, `icon`, `variant`; icon or label by the room |
| a menu item, or the primary action in a menu | `label`, `icon`, `danger` |
| the target itself (an entry, a row) | none: it is the trigger |

**R-BUTTON-4** `visible`, `@checks`, `confirm` and the wait and result of R-ACTION-3 MUST apply wherever a `Button` is mounted: an
item that is not shown is not there, one whose checks fail is shown disabled. When an entry, a row or an item that closes its
menu at once starts an action, the wait and the failure MUST be shown on the entry or the row, or in a notice of the panel,
and MUST NOT be lost because the menu closed.

**R-ACTION-6** A fault that is found only when a value is evaluated (a focus value that is missing, an expression that fails)
MUST NOT be dropped silently: the renderer degrades by the rule of the property and reports a non-fatal fault with a code
(the way `LINK_URL_REFUSED` is). What a person or the host decides (a refused focus request, the way a target was opened)
is not a fault and MUST NOT be reported as one.

### Focus actions

**R-FOCUS-1** An action whose kind is `focus` MUST be sent as a focus request through the runtime for the panel this view is
mounted in, with the values evaluated when it is triggered. It MUST NOT be sent to the provider as an action, and the provider
MUST receive no message.

**R-FOCUS-2** A page opens a focus target by the person's gesture: a click or Enter is `default`; a click with Shift and Ctrl
or Command is `new`; a click with Ctrl or Command, and a middle click, is `background`. A renderer MUST ask for a way only when
the host declares it for every key of the action, and MUST otherwise ask `default`. A menu item activates `default`. An action
that is an event MUST ignore the gesture, and the gesture MUST NOT come from the component's declaration.

**R-FOCUS-3** When a value of a focus action is missing or null, the target MUST NOT be activatable (disabled, in a menu too),
MUST send no request, and the renderer MUST report a non-fatal fault with the code `FOCUS_VALUE_MISSING`. It MUST become
activatable when the value arrives.

**R-FOCUS-4** The host's answer is the result of a focus action. While it is awaited the target is waiting (R-ACTION-3). A request
the host does not accept, or a connection that is lost, MUST show the renderer's own text and no text of the host, mark the target failed
and leave it ready to be triggered again.

**R-FOCUS-5** An entry whose primary action is a focus action with at least one value MUST be marked current, and exposed so to
assistive technology, exactly when every key of the action is read by the panel and every value, evaluated now, is JSON-equal to
the value of that key in the focus the host routes now. A missing or null focus does not match, and keys of the focus that the action
does not name do not matter.

### Items, lists and menus

**R-ITEM-1** An `Item` MUST lay out its media, title, description and trailing content in their places, and its `child` below
the text block. Its accessible name MUST be its title, or the label of its primary action when it has no title.

**R-ITEM-2** Entries of one `List` MUST line up whatever state they are in. In a grid, tiles are of one size and a tile with no
media keeps the place of the media; in rows, when any entry has media every entry keeps the media column. The same entries are
drawn as rows or as a grid by `variant` alone.

**R-ITEM-3** An entry's menu button MUST have a rail of its own that is kept for every entry of a list, so that it never moves or
covers the trailing content or the child. It MUST be there for assistive technology while the entry has a menu item, whether or not a
pointer is over the entry, and MUST NOT be there when no item is shown.

**R-ITEM-4** An entry with a primary action is one target: activating it, anywhere but on a control inside it, triggers the primary
action. While that action is not shown or not allowed the entry is still shown and cannot be activated. A control inside an
entry does its own work and MUST NOT trigger the primary action.

**R-LIST-2** The arrow keys MUST move the focus between the entries of a `List` (up and down in rows; left, right, up and down in a
grid; Home and End to the ends), and Enter MUST trigger the primary action of the entry that has the focus.

**R-LIST-3** A `Section` in a `List` MUST be drawn as a titled section of the entries it holds, with its header kept at the top of the scroll.

**R-MENU-1** The menu of an entry or a row MUST be, in order, its primary action, the other ways of opening the primary action when
it is a focus action and the host declares them, the author's actions, a divider, and the standard items of the renderer. It MUST be
the same menu from the entry's menu button, its context menu and the keyboard.

**R-MENU-2** A menu MUST drop the dividers that are left at its start or end, or next to another divider, by members that are
not shown. A `Menu` none of whose members is shown MUST NOT be shown, and that MUST go up to the menu it is in; an entry with no item
shown MUST have no menu button.

**R-MENU-3** The standard copy item MUST copy the one text, value or cell the pointer is over, or the title of an entry when
the focus is on it, and MUST NOT copy a whole row or entry. It is part of the menu of an activatable entry or row, whose text cannot be
selected (R-AFFORD-3).

### Tables

**R-TABLE-4** `rowPrimaryAction` and `rowActions` MUST be evaluated in the scope of the row: a relative path, a check and a
context value read the row's own data, for rows that come from the data model and for rows written in the component.

**R-TABLE-5** In a `Table` with `selection`, a click MUST only change the selection; Enter and the first item of the row's menu
trigger the primary action, and for a coarse pointer the renderer MUST draw a control at the end of the row that triggers it. The
primary action MUST NOT depend on a double click. Without `selection`, a click on a row is its primary action.

### Confirmations

**R-CONFIRM-2** A confirmation asked from the menu of a row is about that row. When every row has a distinct `rowKey` the renderer
MUST find the row by it after the rows are reordered; without one it MUST find the row by its place only while the value there is
the one it was. When the row is gone the confirmation MUST be closed and no action sent. Before the action is sent the renderer
MUST check once more that its button is shown, its checks pass and what would be sent is what was confirmed, and MUST otherwise send
nothing and close the confirmation.

**R-CONFIRM-3** A confirmation asked from an entry, a row or a menu MUST survive a data refresh and a redraw of the tree that do not
concern its target.

### Sections and forms

**R-SECTION-1** A `Section` MUST draw its title and description with its primary action and actions in its header. It draws no
card of its own, and is not collapsible.

**R-SECTION-2** A `Section` in a `Form` MUST be drawn as a group of its fields, and elsewhere as a titled area.

**R-FORM-1** A `Form` MUST draw its primary action and actions in a footer after its fields, and not among them.

**R-FORM-2** Enter in a single-line field MUST trigger the primary action of the nearest enclosing `Form` or `Modal`, once, whatever
section the field is in, and the field's edit MUST arrive first (R-EDIT-10). A field in neither, or whose scope has no primary action that
can be used, takes only the rule of its own control: its value goes out. A `search` field outside a `Form` MUST NOT reach the
primary action of another.

**R-INPUT-2** Enter in a single-line field is a submission and nothing else is. The Enter that an input method uses to choose a
candidate, and the Enter that makes a newline in a multi-line field, are edits: they MUST send nothing. One Enter MUST make at
most one request.

**R-FORM-3** The primary action of a `Form` MUST carry the `@checks` of every field of the form that is shown, and its own. When
one fails, its message MUST be at its field and no action MUST be sent.

**R-FORM-4** A `Form` MUST put labels beside their controls when it is wide and above them when it is narrow, with description and
messages following the field. A form is wide from the width `form.wide_threshold_pt` names; beside its control, a label sits on the
baseline of the control's first line (see [Presentation parameters](#presentation-parameters)).

### Affordances of targets

**R-AFFORD-1** Every activatable target (a button, an entry, a row) MUST respond visibly to a pointer over it, a press and the
keyboard focus.

**R-AFFORD-2** On a pointer platform the `@accessibility.description` of a component MUST be seen as a tip over it.

**R-AFFORD-3** The text inside an activatable entry or row MUST NOT respond to selection by a pointer, and a click on it is the
primary action. A target that is not activatable keeps its text selectable.

**R-AFFORD-4** The text of a `Text`, a `Markdown`, the value of a `FactList`, a cell of a `Table` and the code of a `CodeBlock` MUST
be selectable by a pointer, and so can be copied, wherever it is not inside an activatable target (R-AFFORD-3).

**R-AFFORD-5** A `Link`, and a link in a `Markdown`, that is followed MUST have the standard entry that copies its address, in a menu
opened by the secondary gesture of a pointer (a context menu, a long press) and, with the keyboard on it, by the key that opens a
context menu. The address is copied as it is followed. A pointer is not made to open the link to copy it.

**R-AFFORD-6** An `Image` and a `Video` MUST have the standard entries that copy the address they come from and that save them, in a
menu opened as R-AFFORD-5 says. An `Image` is for that reason focusable, except inside an `Item`, whose own menu is the one the person
has there.

**R-AFFORD-7** A `CodeBlock` MUST have a control that copies all of its code, and it MUST be reachable with the keyboard and, for a
pointer that cannot hover, be there without one.

A `CheckBox` may be drawn as a switch where that is what the platform does for a choice between two; it keeps the state, the
accessible name and the edit of a check box.

### Markdown

**R-MARKDOWN-1** A `Markdown` MUST show its `text` as the elements of a subset of CommonMark and no others: paragraphs (a soft
line break is a space; two spaces or a backslash before the line end make a line break), emphasis and strong emphasis (`*` and
`_`), inline code, links written `[text](https://github.com/agentfirstkit/agent-first-ui/blob/main/docs/address "title")`, bullet and ordered lists (an ordered list that does not count from 1
keeps where it starts), block quotes, fenced and indented code blocks, and headings written with `#`. A change of `text` MUST
change what is shown, and a `text` that is missing or null is no text.

**R-MARKDOWN-2** What the subset does not have MUST be shown as the characters that were written: raw HTML, images
(`[alt](https://github.com/agentfirstkit/agent-first-ui/blob/main/docs/address)`), tables, strikethrough (`~~`), an address that is not in a link, a heading underlined with `=` or `-`, a
thematic break, a link by reference and the entities of HTML. The renderer MUST NOT make markup out of the text: nothing in the
text makes an element but what R-MARKDOWN-1 lists.

**R-MARKDOWN-3** The headings of a `Markdown` MUST start under the nearest heading that holds it: going outwards from the
component, the `heading` of a `Text` before it among the components it is among, or the title of the `Section` it is in (level 2),
whichever comes first; with none, the title of the panel, which is level 1. A heading written with *n* `#` MUST be shown at that
level plus *n*, and never deeper than level 6, so that it is never larger than the heading it is under. A heading that is shown
at level 6 because it was deeper MUST be reported, once for each component, as a non-fatal fault with the code
`MARKDOWN_HEADING_CLAMPED`. A `Text` stays literal (R-TEXT-1) and has no part in this.

**R-MARKDOWN-4** A link in a `Markdown` MUST follow R-LINK-1 and R-LINK-2: it is followed only to an `http`, `https` or `mailto`
address, any other address leaves the text of the link as plain text and is reported once for each component and address as a
non-fatal fault with the code `LINK_URL_REFUSED`, and a link that is followed has the standard entry of R-AFFORD-5.

### Files

**R-FILE-1** The value of a `FileInput` MUST always be a list, whether `multiple` is set or not: empty when no file is chosen, one
entry at most without `multiple`, each `{ref, name, mediaType, size}`. Without `multiple` a file that is chosen replaces the one held;
with it, the files are added to the ones held.

**R-FILE-2** The bytes of a chosen file MUST NOT be written in the value. The renderer MUST offer each file to the provider through
the runtime's channel for the bytes a viewer gives the provider, put the reference of the offer in `ref`, and write the `mediaType`
and `size` of the file in its entry. An offer MUST be held for as long as the value holds its entry, and MUST be withdrawn when the
person removes the file or the provider writes a value without it.

**R-FILE-3** The system's file picker and the dragging of files onto the control MUST be the same choice. A file that `accept`
does not list MUST NOT be taken, by either, and the person MUST be told so in the renderer's own words, not in a text that the
provider gave. `accept` lists media types, a type with `/*` for all of a kind, and extensions with a leading dot; omitted, it
accepts any file.

**R-FILE-4** The files a value holds MUST be listed by their names with their sizes, and each MUST have a control that removes it,
which writes the list without it. A value that is not a list, and an entry that has no name, MUST be shown as no file in their
place and be reported once for each component as a non-fatal fault with the code `FILE_VALUE_INVALID`. A value that is missing or
null is the empty list and is not a fault.

**R-FILE-5** The `@checks` of a `FileInput` MUST be shown below it as those of any control (R-CHECKS-1), and the `FileInput` is
one of the fields of the `Form` or the `Modal` it is in, so that its checks are part of the joint check of R-FORM-3.

### Tabs and dialogs

**R-TABS-1** The `selected` property of `Tabs`, when it is bound, MUST select the tab whose `child` it is, follow every write of the
provider, and be written with the `child` of the tab when the person chooses one. A value that names no tab of the component,
and a value that is missing or null, MUST select the first tab and be reported, once for each component, as a non-fatal fault with
the code `TABS_SELECTED_UNKNOWN`. Without `selected` the choice of the person is local UI state (R-UISTATE-1).

**R-MODAL-1** A `Modal` whose `open` is bound to the data model MUST be open exactly when the value is true, a missing or null
value is false, and every write of the provider changes the dialog, closing it too. When the person closes it, by its button
or by the key that dismisses a dialog, the renderer MUST write false; when the person opens it with its `trigger`, it MUST write
true. A write of the provider that closes the dialog MUST NOT be written back. A `Modal` with only a `trigger` is opened and
closed by the person, and whether it is open is local UI state (R-UISTATE-1).

**R-MODAL-2** A `Modal` MUST draw its `actions` and its `primaryAction` in a button area below its child, after the renderer's own
button that closes it and with the primary action last. Enter in a single-line field in the dialog MUST run the primary action
once, as R-FORM-2 says, and the primary action MUST carry the `@checks` of every field the dialog holds, as R-FORM-3 says: when one
fails, its message is at its field and no action is sent.

### Fields

**R-INPUT-3** The `contentType` of a `TextField` MUST tell the person's device what the text is, and nothing more: the keyboard
(search, email, address or telephone number), the autofill that suits it, and for `search` the style of a search field. It MUST NOT
validate, change or refuse the text, which is the work of `@checks`. It is independent of `variant`: a `TextField` that is `obscured`
stays masked, and one that is `longText` stays a field of several lines.

**R-INPUT-4** A single-line `TextField` of `contentType` `search` MUST have a control that empties it, which is there while the
field holds text and writes the empty text as the person's edit. Enter in it follows R-FORM-2 and R-INPUT-2: it reaches the primary
action of the `Form` or `Modal` it is in, and of none other.

**R-CHOICE-2** A `ChoicePicker` without `displayStyle` MUST be drawn as segments, as a popup or as a list of choices, chosen by the
number of its options and the width of their labels as they are when it is drawn: segments for up to four options none of whose
labels is longer than fourteen characters, a popup for eight options or more to choose one of, and a list for the rest, and for
any picker whose options have a description or that is `filterable`. What it is drawn as MUST NOT change what is selected, what is
written when the person chooses, or its accessible name.

## Presentation parameters

A host gives a renderer a theme: a partial assignment of the presentation parameters that AFUI's theme guide lists
(`docs/theme.md`), resolved once by the host into the theme's canonical JSON. A renderer that does not link this crate reads that
JSON and the parameter vocabulary in `tests/fixtures/view/theme-conformance/params.json`; the web renderer reads the CSS projection
of it.

**R-THEME-1** Each group of parameters (`text`, `space`, `shape`, `control`, `collection`, `form`) arrives in one of two states, and a
renderer MUST take one of two complete paths for each, never a mixture:

- `platform`: the theme left the whole group out. A native renderer draws the group with the platform's own primitives (system
  controls, system text styles, its own spacing); the web renderer draws it with the AFUI baseline.
- `resolved`: every value of the group is given, and the renderer MUST draw with exactly those values. A value the theme did not
  write is the AFUI baseline's, not the platform's.

Colors are always resolved. `font.ui` and `font.mono` are independent of the groups; an omitted one is the platform font.

**R-THEME-2** A renderer MUST map its parts to text roles and control sizes as this table does. The map belongs to the contract,
not to a theme.

| Part | Text role | Control size |
| --- | --- | --- |
| `Text` heading 1, 2, 3 | `title`, `title2`, `title3` | |
| `Text` heading 4 to 6, `Item` title, `Section` title, `Table` caption, `Disclosure` title, `FactList` label | `headline` | |
| `Text` body, `Markdown` body, a field's value | `body` | |
| `Item` description, `Section` description, a field's description and its messages, a `ChoicePicker` option's description, a `FileInput` hint, size and notice, the view's error | `callout` | |
| `Progress` label | `caption` | |
| A field's label | `label` | |
| `CodeBlock`, a monospaced `Table` cell, code in `Markdown` | `mono` | |
| `Markdown` heading 1, 2, 3 to 6 | `title2`, `title3`, `headline` | |
| A confirmation's title | `title3` | |
| `Button` alone, in a `Form`'s footer or in a dialog's button area; `TextField`; `DateTimeInput`; a popup `ChoicePicker` | the size's `text` | `regular` |
| `Button` and `Menu` in a toolbar or a section header; a chip of a `ChoicePicker`; a `FileInput`'s choose button; a menu's entries; an entry's more button | the size's `text` | `small` |
| A check box or radio of a `ChoicePicker` | | `regular` (its `icon_pt`) |
| A number `TextField` | | `control.number_width_pt` wide |

**R-THEME-3** A renderer MUST lay a view out by these rules, reading the parameters they name:

- A wide form's label column is `form.label_width_percent` of the form's width, between `form.label_min_width_pt` and
  `form.label_max_width_pt`; the label sits on the baseline of its control's first line, and the button area follows the
  content and ends at the form's trailing edge.
- The segments of a segmented panel share one leading edge, `space.page_pt` in from the panel's.
- An icon tile's first line holds its icon, its title and its status; its description and its child run the full width beneath
  it.
- The tiles of one grid row are the same height, and a tile's title and description show at most `collection.title_lines` and
  `collection.description_lines` lines.
- A toolbar narrower than `collection.bar_threshold_pt` shows a button that has an icon as the icon alone; a panel narrower than
  `collection.narrow_threshold_pt` stacks fact lists and stretches lone buttons to its width.

**R-THEME-4** Under a coarse pointer, every activatable element MUST have a hit area at least 44 points in both directions. The
renderer extends the area beyond what it draws; the theme's sizes do not change, and no theme can lower the bound.

**R-THEME-5** Applying a theme MAY lay the view out again. It MUST NOT change the identity of a field, an entry or an action; a
draft, a selection, an input method's composition and the focus MUST stay as they were; the switch MUST NOT submit, or start any
action; and what is being edited MUST stay in view.

## Time

The current time is an input of evaluation, not something a function reads: the
same expression over the same data and the same time always gives the same text. A
renderer has one clock, shared by everything it draws.

**R-TIME-1** A `formatDate` with `style` set to `relative`, and a `formatElapsed`
with no `until`, MUST give their text from the clock's time, wherever they stand: in a
`Text`, in a cell of a `Table`, and inside a `formatString`. The renderer MUST evaluate such an
expression again at each tick of the clock, which comes at least once a second, and MUST show the
new text, without drawing anything else again. An expression that does not read the time, one
with an `until` among them, MUST NOT be evaluated again for the clock.

**R-TIME-2** The renderer MUST stop following the clock for an expression the moment it no longer reads
the time: when its component is no longer part of the view, when a replacement takes the view's place, and when an
`until` is given to it. The clock itself MUST run only while something follows it.

**R-TIME-3** `formatElapsed` MUST count whole seconds from `since` to `until`, or to the clock's time
when there is no `until`, never fewer than zero, and write them in the viewer's language in the two largest
units that are not zero. A `since` that is missing or null gives a missing value, and one that is no time gives an
empty text.

## Unrecognised content

A renderer either supports a session completely or does not draw it. It does not
draw a placeholder for what it does not know, and it does not draw the part of an
interface it can. The session checks every message against its own vocabulary, so
a renderer that claims to support the session should never meet something it does
not recognise. When it does, its claim was wrong, and the rules below apply.

**R-UNKNOWN-1** A renderer MUST NOT substitute a placeholder for content it does
not recognise, and MUST NOT display a part of a message or replacement that contains such content.
It reports a fault, and the faulting message or replacement contributes nothing to the display.

**R-UNKNOWN-2** A renderer MUST treat a component type the vocabulary does not
define as a fatal fault.

**R-UNKNOWN-3** A renderer MUST treat a property the vocabulary does not define for
its component type as a fatal fault. The properties that apply to every component, and the reserved
keys with an `@` prefix that the vocabulary defines, are defined.

**R-UNKNOWN-4** A renderer MUST treat a value of an enumerated property that the
vocabulary does not list as a fatal fault.

**R-UNKNOWN-5** A renderer MUST treat a call to a function the vocabulary does not
define as a fatal fault. This is
a different case from a call to a defined function that fails when it runs,
which is the subject of the expression rules below.

**R-UNKNOWN-6** The framing around messages is read tolerantly. A renderer MUST
ignore a field of a transport message that it does not know, and this is not a
fault. Ignoring a field the renderer does not know never leaves a person looking
at an incomplete interface. An unknown component, property, enumerated value or
function does.

## Renderer faults

A fault is a condition the renderer reports about itself. It is **fatal** when it
leaves the content undisplayable: a message that is not valid, a view with components but without a `root` component, a reference to a
component that does not exist or that forms a cycle, unrecognised
content, or an internal failure of the renderer. Any other fault is **non-fatal**:
the view stays, and the report only tells the session.

A fault is one message sent up the road an edit takes, and no request: it is
ordered with the person's edits and actions and takes none of the room for
requests that are waiting for an answer. Nothing answers it.

**R-FAULT-1** On the first fatal fault the renderer MUST report it to the session,
exactly once. It MUST then ignore every later message. A second fatal fault is never
reported.

**R-FAULT-2** A renderer MUST check a message, or a replacement, in full before it
changes anything it shows or holds: the vocabulary (component types, properties, enumerated values,
required properties, the type of a literal and function names), component references and cycles, and the
root. A message or a replacement that fails this check is applied to nothing: no component it
defines, and no data model it writes, takes effect.

**R-FAULT-3** After any fatal fault, whether the check found it or it arose later
while applying or drawing, such as an enumerated value read from the data model, the
renderer MUST stop showing the view and show the person only a notice that the
interface could not be displayed. A view that remained could not be told from a
current one, so none remains.

**R-EXPR-1** A failure while evaluating one expression, such as a malformed
template or a function that rejects its arguments, MUST NOT remove, freeze or
fault the view. The value of that expression is missing, and the place it fed
shows what it shows for a missing value, with no marker in it; every other component
carries on.

**R-EXPR-2** Where a verdict is needed, a failed expression MUST give one without
stopping anything. A failed `visible` displays the component. A failed check
counts as failed, so the control it guards is blocked, and the check's own message
is shown. A failed expression in an action's context stops that action, which is
not sent, and the person sees a generic notice.

**R-EXPR-3** A failed expression MUST be reported to the session as a non-fatal
fault with the code `EXPRESSION_ERROR` and the `path` of its component, once for each component
and expression: it is not reported again when it fails again, when the data it reads
changes, or in another instance of the same template. Another component with the same
expression, and another expression of the same component, are reported on their own.
A call to a function that is not in the vocabulary is not this: it is R-UNKNOWN-5. Only the Provider
can correct what it wrote, and this report is the only way it hears that it wrote it wrong.

**R-FAULT-4** A fault MUST be reported as one message,
`{"fault": {"fatal", "code", "path", "message"}}`. `fatal` is `true` or `false`.
The `code` is `VALIDATION_FAILED` for invalid or unrecognised content,
`RENDERER_FAILURE` for an internal failure and `EXPRESSION_ERROR` for an
expression that failed; a renderer MAY report a code of its own for any other
non-fatal fault. `path` is a JSON Pointer to the place in the message or the replacement,
counted from its first message, and is empty when the fault concerns no place. `message` says what
went wrong. The report MUST NOT contain any value from the content.

**R-FAULT-5** A fault that could not be sent yet is held, and the renderer MUST NOT send
an action behind it: the action ends in a failure the person can try again, as R-EDIT-10
says of an edit, and goes when the person tries again once the fault has gone.

**R-FAULT-6** A renderer MUST send a fault after every edit the person made before it,
including the edits it had not yet sent, and before every action the person
triggers after it. When the road to the session has no room for the fault yet, the
renderer holds it, and sends it in its place as soon as there is room.

## Fixtures

The fixtures are under `tests/fixtures/view/renderer-conformance/kept/`.
The runner validates each case against `schema.json` before it runs it.

A case is a list of steps. Each step makes one thing happen to the renderer and
then states what must be true. The steps are abstract. Only the `payload` of a
`receive` step holds wire messages, so when the protocol changes the cases that
remain change their payloads and nothing else.

| Step | What a renderer does |
| --- | --- |
| `receive` | hands the payload to the renderer as the runtime would deliver it; `kind` says whether it is an incremental message or the first, a middle or the last part of a replacement |
| `restart` | tells the renderer that the runtime reports this viewer must start over |
| `resume` | resumes a dropped connection without a restart |
| `declined` | the session declines the renderer's connection before it is listed: the connection ends for good with the refusal's code and its structured detail |
| `edit` | the person changes the value of the control that is bound to a path, as typing would; with `composition` the change is part of an input method's composition or its commit |
| `activate` | the person triggers a component, or responds to its confirmation when `target` is given |
| `choose-files` | the person chooses files for a `FileInput`, with the system's picker or by dragging them onto it |
| `remove-file` | the person removes a file that a `FileInput` lists |
| `reply` | the provider answers the latest request the renderer sent, an action |
| `set-ui-state` | the person changes local UI state: expands a disclosure, picks a tab, sorts a table, scrolls, moves the focus or the selection |
| `set-clock` | the renderer's clock is set to an instant; the clock is the runner's, and nothing moves it but these two steps |
| `advance-clock` | the clock moves forward by a number of seconds, and ticks as it would have |

The assertions of a step read the renderer's own model and its component tree. A
native renderer reads its data model and its view tree, not pixels. An assertion
a renderer cannot evaluate is a failure, never a skip.

| Assertion | What it reads |
| --- | --- |
| `model` | the value, or the absence of a value, at a path of the view's data model |
| `displayed` | whether the view is being shown; a view with no components is not |
| `component_visible` | whether a component is displayed to the person |
| `progress` | the ratio of a determinate `Progress`, or that it is indeterminate, and its label |
| `text` | the text a component shows, or that it shows a value |
| `check_messages` | separate validation messages below the owning control, in declaration order, and their association with that control alongside its optional helper |
| `accessible_names` | the accessible names and optional semantic roles of the components |
| `markdown` | what a `Markdown` shows, as the elements it is made of |
| `files` | the files a `FileInput` holds, and that each has an offer of bytes that is still held |
| `file_offers` | the offers of bytes the renderer made, and whether each is withdrawn |
| `field_hints` | the keyboard, autofill, masking and clear button of a `TextField` |
| `choice_presentation` | what a `ChoicePicker` is drawn as |
| `button_area` | the labels of the buttons in the button area of a `Form` or a `Modal`, in order |
| `text_includes` | strings that must appear in the text the person reads |
| `links` | the address a `Link` leads to and how it opens, or that it leads nowhere |
| `instances` | how many instances a component repeated by a template has |
| `fact_lists` | the labels, displayed values, name and layout of a fact list |
| `image_variants` | the fit, shape and accessible name of an image |
| `option_descriptions` | option label and secondary description |
| `row_alignment` | the cross-axis alignment of a `Row` and whether it wraps |
| `table_badges` | the badge level and name in a table cell |
| `table_rows` | the keys of a table's rows, in the order shown |
| `ui_state` | the local UI state of a component |
| `action_state` | the state a component shows for its action |
| `notice` | the status notice, which is none, an exact text, or a generic one |
| `text_excludes` | strings that must not appear in any text the person reads |
| `actions_sent` | how many actions the renderer has sent so far |
| `last_action` | the latest action the renderer sent |
| `clock_running` | whether the renderer is following the clock |
| `rebuilt` | whether the renderer drew the view again during the step |
| `reports` | the faults reported to the session during the step |
| `faulted` | whether the renderer is in the failed state |

The viewer of a case reads English (`en-US`), and its clock starts at 2026-01-01T00:00:00Z in every case, so that what a
formatter writes does not depend on the machine the runner is on. `manifest.json` lists every case and the schema by path and
SHA-256, with the wire format the cases are written in. A renderer reads the cases
through it and checks each against its hash, and it is regenerated, never edited.

A component is named by its id. A component a template repeats
also names its instance, which is the path of the element it shows. Fixtures that
involve scrolling run in a viewport that `schema.json` can set; a renderer picks
the nearest size it has.

### Theme conformance

The theme cases are under `tests/fixtures/view/theme-conformance/` and are listed, with their hashes, in its `manifest.json`;
both are generated from the parameter table and the sample files, never edited. `themes/` holds four themes: `empty.json` (no
field), `compact.json` and `comfortable.json` (a density alone) and `full.json` (every group written, far from the baseline).
`views/` holds the sample views. Each case in `cases/` pairs one view with one theme and lists its expectations: the component, the
part (a selector inside the component's element, empty for the element itself), what is measured (`height`, `padding_x`,
`min_width`, `radius`, `font_size`, `line_height`, `gap` or `line_count`), the parameter, and the value in points. Where the case
writes `platform`, the group is the platform's: the web renderer asserts the baseline value, a native renderer its platform
primitive. `interaction/` holds a case that switches themes in the middle of an edit and checks R-THEME-5.
