Skip to main content

Reference

Complete field-by-field specification for every construct in the RUF Spec YAML format.


ruf

Declares the RUF Spec YAML version. Required on every root file.

ruf: "1.0"

versioning

Declares the version format used by the client app. Optional — omit if the application does not use construct versioning.

versioning: semantic   # or: incremental
ValueClient version formatExample
semanticMAJOR.MINOR.PATCH+BUILD"2.2.1+5"
incrementalInteger build number"42"

See Versioning Formats for the full resolution algorithm.


current_version

The current version of this application spec. Follows the format declared in versioning. Used as documentation and by tooling to identify the latest variant.

current_version: "2.2.1"

meta

Defines the shape of SessionMeta for this application. Uses TypeScript-like type annotations. The shape is application-specific — the protocol does not mandate specific fields.

meta:
token?: string
cart:
items: CartItem[]
total: number
currency: string
selectedAddress?:
id: string
street: string
city: string
isVerified: boolean

Fields suffixed with ? are optional. Nested objects are defined inline. Arrays use Type[] syntax.

See Type Syntax for the full reference.


shared

Holds reusable constructs referenced across multiple screens via $ref. Contains three sub-sections:

shared:
components: {} # Keyed by component identifier
actions: {} # Keyed by action identifier
metrics: {} # Keyed by metric identifier

All shared constructs are referenced via $ref: '#/shared/<type>/<key>'.


screens

Each key is the screen name in SCREAMING_SNAKE_CASE. The value is a Screen definition or a $ref to a screen file.

screens:
HOME: { ... }
PRODUCT:
$ref: './screens/product.ruf.yaml'

Screen definition

Fields

FieldRequiredDescription
descriptionNoHuman-friendly description for maintainability
aliasNoShort human-readable alias
paramsNoTyped route-level parameters. Passed at navigation time.
default_transitionNoDefault page animation. See Screen Transitions.
flowsNoList of flow names this screen belongs to. See Flows.
componentsYesList of component definitions or $ref entries
actionsYesList of action definitions or $ref entries
metrics.navigationNoMetrics fired when this screen becomes active
metrics.screenNoMetrics fired when this screen's content loads

Example

PRODUCT:
description: Product detail page
alias: Product
params:
productId: string
referrer?: string
default_transition: RIGHT_TO_LEFT
flows:
- DISCOVERY
components: [...]
actions: [...]
metrics:
navigation:
- rel: screenView
type: FIREBASE
name: screen_view
payload:
screen_name: string

Component definition

Fields

FieldRequiredDescription
descriptionNoHuman-friendly description for maintainability
aliasNoShort human-readable alias
relYesStable identity key within the screen (e.g. appbar, product_list)
behaviorsYesList of named rendering variants

Behavior entry fields

FieldRequiredDescription
nameYesVariant discriminator (e.g. VISIBLE, HIDDEN, LOADING, ACTION)
localeConditionallyMap of key: type pairs for text strings. Required if the behavior renders content.
payloadConditionallyTyped payload shape. Required if the behavior renders content.
mergeStrategyNoAPPEND, REPLACE, or MATCH. Only for list-type payloads. Defaults to REPLACE.

A HIDDEN behavior with no locale or payload is valid:

- name: HIDDEN

mergeStrategy values

ValueBehavior
REPLACEIncoming component fully replaces the cached one (default)
APPENDNew list items are appended to the existing list
MATCHNew items matched against existing by id field; matched items updated, others unchanged

Example

- rel: product_list
description: Paginated list of products
behaviors:
- name: VISIBLE
locale:
empty_message: string
load_more_label: string
payload:
items: ProductItem[]
hasMore: boolean
mergeStrategy: APPEND
- name: HIDDEN
- name: LOADING
locale: {}
payload: {}

Action definition

Fields

FieldRequiredDescription
descriptionNoHuman-friendly description for maintainability
aliasNoShort human-readable alias
typeYesAction identifier string. The screen name is not part of the type — it is provided separately in the request.
payloadNoTyped input fields. Fields suffixed with ? are optional.
navigates_toNoList of possible screen destinations this action may lead to
errorsNoMap of error code → ActionResult shape

navigates_to entry fields

FieldRequiredDescription
screenYesTarget screen name
transitionNoPage animation for this transition. Overrides default_transition.
flow.nameYesFlow identifier (e.g. CHECKOUT, AUTH)
flow.behaviorYesSTART_NEW, KEEP, or REMOVE_PREVIOUS

errors map

Errors are keyed by their code. Each code defines the type of ActionResult it produces.

TOAST:

errors:
EB010:
type: TOAST
severity: ERROR # SUCCESS | ERROR | WARN

ERROR:

errors:
EV012:
type: ERROR

FORM_ERRORfields lists the field identifiers that may carry errors:

errors:
EV020:
type: FORM_ERROR
fields:
- email
- phone

SUCCESS is the implicit happy path — no entry needed in errors.

Use unique error codes

Using stable, unique codes makes errors programmatically handleable and supports i18n. See Unique Error Codes.

Example

- type: SUBMIT_ORDER
description: Submits the current cart as an order
payload:
paymentMethodId: string
tip?: number
notes?: string
navigates_to:
- screen: ORDER_CONFIRMATION
transition: RIGHT_TO_LEFT
flow:
name: CHECKOUT
behavior: REPLACE
- screen: PAYMENT_FAILED
transition: FADE
flow:
name: CHECKOUT
behavior: KEEP
errors:
EB042:
type: TOAST
severity: ERROR
EV010:
type: FORM_ERROR
fields:
- payment_method
- address

Metric definition

Fields

FieldRequiredDescription
descriptionNoHuman-friendly description for maintainability
aliasNoShort human-readable alias
relYesStable identifier for this metric
typeYesEmitter type string — user-defined (e.g. FIREBASE, GOOGLE_ANALYTICS)
nameYesEvent name as it appears in the analytics system
payloadYesTyped map of event properties

Example

- rel: purchase_complete
description: Fired after a successful order placement
type: FIREBASE
name: purchase
payload:
value: number
currency: string
item_id: string

$ref syntax

Any list entry (component, action, metric) can be replaced with a $ref pointing to a shared definition.

Referencing shared constructs

components:
- $ref: '#/shared/components/appbar'

actions:
- $ref: '#/shared/actions/go_to_webview'

metrics:
navigation:
- $ref: '#/shared/metrics/screen_view'

Path format: #/shared/<type>/<key>

Referencing screen files

screens:
HOME:
$ref: './screens/home.ruf.yaml'

File paths are relative to the current file. The referenced file contains the screen definition directly at the root level — not nested under screens:.


Type syntax

Payload and locale values use TypeScript-like type annotations:

SyntaxMeaning
stringString value
numberNumeric value
booleanBoolean value
fieldName?: stringOptional string field
string[]Array of strings
ProductItem[]Array of a named type
'ios' | 'android'String literal union
Record<string, string>String-keyed string map
Inline objectNested object (fields defined inline)

Optional fields use ? on the field name:

payload:
productId: string
referrer?: string
quantity: number

Versioning

Any component, action, metric, or the meta section can declare version-specific variants using a versions: map. The top-level definition is always latest. See Versioning Formats for how the server resolves which variant to use.

versions: on meta

Declares the SessionMeta shape at each historical version, enabling tooling to generate migration updaters. The version field is implicit — do not declare it.

meta:
token?: string
cartCount: number
selectedAddress?:
id: string
label: string
versions:
"1":
token?: string
# cartCount and selectedAddress were not present in v1
"2":
token?: string
cartCount: number
# selectedAddress was not present in v2

See SessionMeta Versioning.

versions: on components

- rel: payment_method
behaviors:
- name: VISIBLE
locale:
brand_label: string
payload:
brand: string
last4: string
- name: HIDDEN
versions:
"2.1.9":
behaviors:
- name: VISIBLE
locale:
card_label: string
payload:
type: string
last4: string
- name: HIDDEN

versions: on actions

- type: PLACE_ORDER
payload:
paymentMethodId: string
navigates_to:
- screen: ORDER_CONFIRMATION
transition: FADE
flow:
name: CHECKOUT
behavior: REPLACE
versions:
"2.1.9":
navigates_to:
- screen: WEBVIEW
transition: RIGHT_TO_LEFT
flow:
name: CHECKOUT
behavior: KEEP

versions: on metrics

- rel: order_completed
type: FIREBASE
name: purchase
payload:
transaction_id: string
value: number
currency: string
versions:
"2.1.9":
payload:
order_id: string
total: number

Semantics

Each entry under versions: is a full redefinition of the construct — not a partial patch. The server selects exactly one variant per construct per request and does not merge definitions.

See Constructs Versioning for a complete guide.