This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index at /llms.txt, or add .md to any page's URL.

Composition and lifetime

The first component is the root. Each component use is Name(prop=value, …). Supply every declared prop exactly once; props have no defaults (pass none for an option). An action prop or inject takes an action name or action(args) with captured arguments; the eventual event payload is appended at invocation. To choose between actions, pass one action that makes the choice in its body. A conditional supplied as an action prop or inject, including through a derive, is refused at the argument or provider binding. A child derive that aliases an action name or captured call can supply either binding.
Value props and injects replace value reads only: beside min: number, min(4, 9) still calls the function, in views and actions alike. An action prop or inject named like an app fn is refused when an expression in the component calls that name and inlining could substitute the action into the call. Rename either declaration. Handler-only uses are allowed. An expression's match or arrow binder protects its bound name; a view's for or match binder does not protect call heads.
A derive supplies a value, even when its expression is a function call. Beside fn pick, derive pick = pick(1) makes ${pick} read that result; pick(5) still calls the function. States and device-fact resources also supply values only: beside fn pick, state pick = 7 makes ${pick} read 7, while pick(5) calls the function. These names leave calls intact in derives, state initializers, actions and slot fills.
A child's action may call its action props and injected actions, with the arguments after those captured where they were bound: the parent's action runs in the same commit, and the child never writes the parent's state itself. A swipe that decides, in the child, to tell its parent resets its own state, then calls the prop last in an if arm:
text
component Row
props
id: string
archive: action
state dx = 0
action release(dy: number)
dx = 0
if dy > 120
archive(id)
Children may hold state, derives, actions, resources, mutations and tasks at bounded uses (A feature's requests). A child used under for owns row state keyed to that row's identity. Stable keys matter when content is inserted, removed, filtered, or reordered. A child's derive is compiled once per component use and evaluated at each read in that instance's frame. A computed prop or inject argument shares that representation. Each read uses the reader's list and call budgets and can trap there. A literal stays inline, so the web compiler can fold size == "sm" when a component takes the enum argument size="sm". A root derive evaluates once per settlement, so put a calculation there when its result should be shared across readers. Action-body reads, action calls and fn calls still expand in place. The web build reports its entry's bytes and each component's own plan instructions and compiled instance count. Shared bodies count per use; a for is one compiled instance regardless of its runtime item count.
A root that has outgrown the 1,500-line cap keeps its members and moves them into files by feature: members "./composer.contract" in its body, and in that file a members App block of states, derives, resources, mutations, actions, tasks and sequences. The program is the one-file program, and every file sees every member; each file uses the shapes and fns it calls (docs/contract-grammar.md, "Components and actions").
A state cannot start from a resource, but a child's state can start from a prop. So a form that edits a saved record is a child made once the record is in: the source answers loaded: true, the placeholder says false, and the child's states take the record's fields when it is made. The initializer runs once per child: a later draft (a refresh, a normalized answer) does not reset the form, and while a refresh is out saved keeps its value, so the editor stays.
A native host (and the wasm web target; the default JS target keeps none) can make that child from a kept answer. When the data module is not ready at boot, a resource whose source read device state (a file, a database, a secret, a watched topic) shows the last answer the runner kept for it (asked with the same identifying arguments, and at most 256 KiB counting them, 512 KiB for all of them together; with values are not counted), so the form's states take those fields. A larger answer is not kept, and an older one kept for the resource is forgotten, so a launch never shows an answer since replaced; logs says too big to keep once, naming the resource and what to do. An identifying argument that changes every launch (the launch's time or seed) never matches the kept one: pass it after with, as resource lib = library() with time.epochAtZero; the compiler and logs both say so. A source declared in app.contract keeps no answer, as the launch asks it at boot, and neither does a resource whose identifying arguments read a declared resource, which a launch starts on its placeholder: pass such an argument after with when it does not identify the answer. An identifying argument that differs from the kept one and is "" or none, or reads a device-state resource still on its placeholder (an id an action sets once a session answers, a search field's empty query), is not known yet: the kept answer waits, logs says so, and it shows once the arguments reach the ones it was kept for, also after the data module is ready, unless an answer for other arguments was kept in its place first. A known value that differs means the kept answer is not used; logs names the argument and the state or resource it reads, never an identifying value. An answer that must never reach the device's storage (a one-time code, a message shown once) ends its line with transient: resource code = otp(request) as shape Code transient. It is never kept, a launch starts from its placeholder, and an answer an earlier build kept is forgotten at the next launch. An app with a Health, contacts, calendar or photo-library grant keeps only the answers of resources marked keep, the same last clause: resource summary = readSummary() as shape Summary keep. The mark says the answer, and its identifying arguments, hold no data from those stores; a resource read from a native module cannot take it. In such an app the boot forgets every other kept answer, and one kept before the mark was added, and logs names each resource whose kept answer the first frame shows. Where a marked resource's ask calls native code, nothing is kept for it and logs says not kept once, naming it. Without such a grant, keep changes nothing. Keep a first screen's resources small and move their bulk into a resource the first frame does not need. A write the resource does not hear about (a file or database save from a mutation without refreshes saved, not a store write it reads) leaves that answer behind: after a restart the form opens with the old fields and keeps them when the fresh answer lands. Refresh the resource after each write, as below, or key the child by a string or number from the answer (for d in [saved] key=…) so a different answer makes it again.
contract
shape Draft
name: string
loaded: bool
component App
resource saved = loadDraft() as shape Draft else empty(name="", loaded=false)
mutation stored as shape Draft refreshes saved
action keep(name: string)
send stored = saveDraft(name)
view
main
if saved.loaded
Editor(draft=saved, keep=keep)
component Editor
props
draft: Draft
keep: action
state name = draft.name
action edit(value: string)
name = value
action save
keep(name)
view
column
input value=name input=edit aria-label="Name" testId="name"
button "Save" press=save testId="save"
A component provide section lists name = expr or bare name entries. A descendant declares inject with typed fields. The nearest provider in the component-use chain wins and covers the providing component's whole view. The old view wrapper provide name = expr is refused. Use a small wrapper component if a subsection needs different values.
slot declares a receiving component's one content slot. children places the caller's nodes in its view. The fill keeps its caller's variables and providers, not the receiving component's provider override. Do not invent named slots or render-function props.

One element shown in another place: portal

An if arm creates and destroys, and a key keeps a row only within its own list, so declaring a playing video again in a detail screen restarts it. Write it once, outside the screens, and name where it shows with portal (LLP 1013.002). The same element moves; its state, handlers and lifetime stay its declaration's.
contract
component App
state open = false
state alive = true
action toggle
open = not open
view
column
button press=toggle
text (open ? "Close" : "Open")
box id="card-player" width=168 height=148
box id="detail-player" width="100%" height=320
if alive
column portal=(open ? "detail-player" : "card-player")
video "assets/motion.mp4" autoplay=true muted=true playsinline=true loop=true
•
The destination is the first element with that id in declaration order in the app root. It must be a plain box (box, view, column, row, main, section, article, aside, nav or footer with no role, navigationKey or popover) that its parent lays out. A list's row, a table's part, a route's header item, a button's face, a dialog or a route can't receive content or move; the compiler refuses what it can prove.
•
The element goes after the destination's own children. An empty value leaves it where it is written.
•
With no destination (a missing id, its own descendant, a cycle, a box inside hidden content) it is alive but not shown: no space, no input, not in tree, journaled once. A muted autoplay video there pauses at its position and plays on from it when shown (Firefox keeps it playing).
•
Its press, pointer-button and key events bubble through where it is written, not where it is shown; hover, focus on the web and the painted hosts' pan, swipe and long press still follow where it is shown. Colours, color-scheme and modes come from where it is shown (on the web; native hosts still resolve design-token modes at the declaration).
•
Removing the declaration removes it; a new one starts fresh.
•
Hosts: the web, macOS, iOS and Android move the same element, and a playing video plays on through the move; Linux and Windows move it with no video decoder. A page rendered ahead leaves it out and builds afresh. The reference's "A portal element on each host" has each host's table. docs/recipes/keep-a-playing-video.md is a card that opens into a detail; apps/shared-elements' Player and Flight screens show both forms.
Imports resolve local .contract declarations, with cycle and app-boundary checks. Paths begin with ./ and cannot contain .. segments. They do not load app logic or expand the available built-in function roster. Compiler-owned router names exist only with a routes declaration.

A feature's requests

A feature written as a child (a tab's screen, a pushed screen) owns its resources as it owns its state: it declares them. Each instance asks for its own after the render that makes it, and lets go when the render destroys it, so an answer that arrives after a screen was popped changes nothing. A tab's root screen lives for the session, hidden while another tab shows; a pushed screen lives from the push to the pop.
Permission to ask is when, not visibility: a hidden instance's ungated resource keeps its answer and asks again when its arguments change or it is refreshed. Gate a tab's resource on its tab showing, by a prop the parent passes:
contract
routes nav
tab today "/"
tab history "/history"
component App
view
main
for t in nav.tabs key=t.name
column role="tabpanel" display=(nav.tab == t.name ? "flex" : "none")
for e in t.stack key=e.id
if e.name == "history"
History(shown=(nav.tab == t.name))
else
text "Nothing logged yet."
component History
props
shown: bool
state range = "week"
resource days = days(range) when shown as shape string[] else empty()
action reload
refresh days
view
column
button press=reload
text "Reload"
for d in days key=d
text d
days asks nothing until the History tab first shows. While the tab is hidden it is idle and keeps its last answer; when the tab shows again it is asked again, and that answer shows until the new one lands (current(days) is false until then). refresh days reaches only the instance whose action ran: two instances ask, refresh and answer apart, even with equal arguments. A state initializer does not read its own component's resources, nor, through a prop, those of a component around it with no if, match or for between them (type-state-reads-request); a derive or the view does.
A component may own a mutation the same way (LLP 1035.005.004 D6). Each instance sends it on its own, with its own pending, failure, queue and answer, and its refreshes names the component's own resources. Its then runs in the instance that sent it and may call an action prop, which is how the answer reaches the root: Shelf's BookScreen owns mutation quoted … then detected, and detected calls showQuote(lines), passed as showQuote=showQuote(e.params.id). Leaving the screen forgets what it sent: a reply after that changes nothing, its then does not run, and a queued send not yet asked is dropped.
A component that owns a resource, mutation or task is used where its instances are bounded: outside every region, under if and match, or in a row of stack(nav), t.stack or nav.tabs. Under any other for, or in a virtualized list, it is refused (type-child-resource): declare the root's resource over the list (resource feeds = load(id) for id in ids key=id) and pass each row its answer, or declare the mutation in the root and pass each row an action that sends it (add=addWork). Only the root declares a resource over a list, so a screen that needs one request per element takes the root's list resource as a prop.
A child's task runs in its instance's frame and ends when that instance is destroyed. A hidden instance stays alive; gate its task with when active if it should stop while hidden. Data two features read belongs to the root, which passes it down; name its declarations with the feature's prefix (historyDays), since the root and its members files share one set of names.

Progressive tab traces

In the iOS simulator recipe, the warm snapshot showed Explore in .state.slots.nav.tab, rows ticket 4 in .state.pending, and both Stocks answers in .state.instances. Use those fields for component-owned resources. In this capture .state.resourceStatus reported a fallback while the rows were visible.
The warm Explore press committed epoch 6. The journal tied the rows 503 to ticket 4, then recorded that rows kept its value and the failure update committed epoch 7. The display-link samples covering those epochs had seq ranges [6,6] and [7,7]. The first sample's t was 6,108.24 ms and the press was journaled at 6,126.14 ms. Use the epoch to identify the batch. Subtracting those times cannot give tap-to-frame latency. The frame's apply measures batch application and commit measures Core Animation commit duration. The trace has no physical presentation timestamp for the tab.
In the ordered comparison before LLP 1162 §8 Q2, the rows 200 journal entry reported wall 623 ms; delivery wait 1020 ms, where delivery wait measured the time from transport completion to delivery behind history. Resource reads now deliver on completion, while writes and mutations keep their order; exactIndependentHttp remains the opt-out for requests that leave the ordered sequence altogether (including bypassing send barriers and using the independent lane's budget). Native HTTP scheduling
To capture a slow return in your own development app on a connected iPhone, tap with four fingers and choose Save Trace: it has the session's journal and work. On the Mac run bun scripts/agent.mjs trace --phone <phone-UDID> --app <app-directory> from the Exact repo to copy that trace. For its frames, choose Record Frames first, reproduce it, then choose Record Frames again to stop: the recording's trace is saved and put on the clipboard as compact JSON, and the alert's Share… sends the saved file to the Mac, where bun scripts/agent.mjs trace <file> --json reads it whole (the default rendering skips a recording's segments and late frames); trace --phone copies only Save Trace's. A build samples frames only while it records, as a production bake does, unless the agent launched it under its clock. The simulator can reach the Mac’s fixture at 127.0.0.1. On a phone that address reaches the phone itself.
Linux and Chromium.
On the same Mac, leave the fixture running in terminal A. If the simulator app is still running, quit it from B with xcrun simctl terminate "$sim" dev.exact.progressivetabs. In B at the repo root, run the ordered comparison on the headless Linux host.
Terminal
app=docs/recipes/progressive-tabs
bun scripts/build-linux.mjs "$app"
bun scripts/agent.mjs linux --app "$app" 'tap compare' 'tap tab-explore' 'clock until state pending == [] within 60000' logs
While B waits, release both replies in A within 60 seconds. After both Held lines, type /rows/Stocks 200 and press Return, then /history/Stocks 503 and Return. The rows fulfil line in B gives its HTTP wall time and delivery wait behind history.
Browser fetch handles its own scheduling and ignores the native independence hint. After the Linux drive exits, run bun host/web/dev.mjs --app "$app" in B and open the printed URL in one Chromium tab. Click Explore and release the two Stocks 200s in A. Click Home, then Explore. With both replies held, run await (await exact.attachReads())({op: 'state'}) in the browser console to read the route, pending tickets and epoch. Release /rows/Stocks 503 in A. When the rows error appears, repeat the console read. Focus the page and press ⌥⇧T to save the trace, then release /history/Stocks 503 in A. In B stop the dev server with Ctrl-C. Set file to the path the browser console printed and run bun scripts/agent.mjs trace "$file". The Chromium trace omits the state snapshot. Match the epochs you read in the console to its frame callbacks’ seq ranges.

Tabular numbers

Use font-variant-numeric="tabular-nums" for numeric columns and values that change in place: prices in a ledger, timetable times, timers, scores, counters, progress percentages and recalculated totals.
Use default spacing for prose, ordinary labels, static standalone statistics, and fields merely accepting numbers. Choose by how the value is used, regardless of its size or currency symbol: static columns need alignment, and updating headlines need stable digits.
contract
component App
state balance = "$1,234.50"
view
text balance font-variant-numeric="tabular-nums"
Apply it to numeric text, keeping the platform font. It makes digits equal-width without monospacing letters. Font support is required; unsupported fonts remain unchanged. The property inherits. normal restores the font's default, which may already be tabular; Exact does not accept proportional-nums.
Equal-width digits do not fix the whole value's width: 99 → 100, signs, precision, separators and units can still move content. Reserve space for the formatted range when layout must stay still. Align numeric columns to a common edge (usually right for left-to-right numbers), with consistent units and precision where appropriate. Digits alone do not align decimals; do not pad with spaces or misleading zeroes.
Supported for ordinary text on macOS, iOS, tvOS, Linux, Windows, Android and both web targets, including prerendered pages, and for Android's native input and textarea. Exceptions:
•
Terminal: ordinary digits already occupy equal-width cells. Explicit font-variant-numeric settings are currently rejected.
•
Native buttons: unsupported. Keep their typography; use separate text for a readout. This property also does not style Canvas/GPU drawing or native hatches.
•
Text wrapping around shapes on web: a paragraph using tabular-nums skips Exact's wrapping along image or shape outlines and uses ordinary browser layout. Keep readouts separate from prose that needs this wrapping.
exact:content components set their own typography: SummaryCard uses tabular digits for value and detail. Use text for a static statistic needing default spacing.
Check the actual font, locale and host, including fallback digits, 11 → 88, 99 → 100 and large accessibility text. Widths can differ across hosts. Keep locale-aware formatting and accessible labels. See a numeric readout for sizing.

Content components: exact:content

The platform answers the controls and the chrome; the app's own content is the author's to design (LLP 1116.000 D3): a summary at the top, bars where numbers compare, rows with a hierarchy, an empty state that says what to do. exact:content is a built-in library of nine components that draw it with nothing but roles (-exact-secondary-background, -exact-secondary-label, AccentColor, the system hues, the text styles, symbols, the determinate progress), so dark mode, Dynamic Type and the tint come with them:
contract
use SummaryCard, StatBar, RingProgress, DoneMark, EmptyState, RowText from "exact:content"
shape Day
key: string
name: string
ml: number
fn ml(n: number): string = `${formatNumber(n, "decimal")} ml`
component Water
state total = 750
state days = [Day(key="mon", name="Mon", ml=1800), Day(key="tue", name="Tue", ml=2250)]
action drink
total = total + 250
view
scroll height="100%" accent-color="-exact-system-teal"
column gap=16 padding=16
RingProgress(label="of 2,000 ml", value=ml(total), fraction=total / 2000, tint=none)
SummaryCard(label="Today", value=ml(total), detail="of 2,000 ml", progress=some(total / 2000), symbol=some("symbol:activity"))
for d in days key=d.key
StatBar(label=d.name, value=ml(d.ml), fraction=d.ml / 2000, tint=none)
row justify-content="space-between"
for d in days key=d.key
DoneMark(caption=d.name, done=d.ml >= 2000)
if total == 0
EmptyState(symbol="symbol:calendar", title="No water yet", message="Each glass you log adds to today.")
button "Log a glass" press=drink buttonStyle="bordered-prominent"
for d in days key=d.key
RowText(title=d.name, detail="", value=some(ml(d.ml)))
Component
Props
Draws
SummaryCard
label: string, value: string, detail: string, progress: option<number>, symbol: option<string>
a card: the symbol and label, the value large in tabular figures, the detail beside it where the card is wide and under it where it is narrow, the fraction as progress
StatBar
label: string, value: string, fraction: number, tint: option<string>
the label and value (the value under the label where both do not fit) over a bar fraction (held to 0–1) of the width: the accent short of the goal, the system green at 1 or past it, tint (a colour role) when given; one meter to a reader
RingProgress
label: string, value: string, fraction: number, tint: option<string>
a ring filled fraction of the way round from the top, in the bar's colours over a grey track, the value large in its centre and the label under it, at the default body's sizes at every text size; 200 across, down to 120 in a narrower box; one progressbar to a reader
DoneMark
caption: string, done: bool
a filled check in the system green, or an empty circle in grey, with caption (short: a weekday; "" for none) under it; one image to a reader, named by its caption and state ("Mon, done")
EmptyState
symbol: string, title: string, message: string; a slot
a centred symbol (none at the accessibility text sizes), the title as a heading, the message; the nodes indented under the use (your button) under them; a scroll where it is taller than its space (in a flex column, give the column min-height=0)
RowText
title: string, detail: string, value: option<string>
a title, a secondary line under it ("" for none) and a trailing value in tabular figures (under them where they do not fit on one line): a grouped list row's content, or any list's
Badge
label: string, tint: option<string>
a status in a word ("Full", "Cancelled") in a capsule, the caption style semibold, keeping its own size beside a title; none the neutral grey, some("AccentColor"), or a system hue under white ink (dark on the light hues: green, mint, teal, cyan, yellow, orange); Windows contrast themes use the system highlight/text pair for these tints; read as its text
RoundButton
label: string, tint: option<string>, press: action, disabled: bool, testId: string
the platform's own button as an 80-point circle (the Clock's Start, Stop, Lap): filled with tint (a role: "AccentColor", "-exact-system-red"), ink the host picks for contrast; a light hue (green, mint, teal, cyan, yellow, orange) is the platform's tinted style, the hue on the hue at low opacity; none is the neutral grey with the label's ink; the title stays the default body size at every text size
AnswerTile
label: string, status: string, press: action, testId: string
a full-width tile for one answer, the label in the headline style; status "idle" (a neutral fill), "selected" (the accent's outline and checkmark), "correct" (the system green, dark ink, a check), "wrong" (the system red, white ink, a cross), "dimmed" (the rest, once told), or "chosen" (the person's own pick once told or closed: the selected look, disabled, so a closed poll still marks the vote while the rest dim); told, dimmed and chosen tiles are disabled; as a grouped list's row it is the list's cell on every host (-exact-row-look), the checkmark its accessory; a reader hears "Quito, correct"
•
Props have no defaults: pass none for an option. A symbol is an image source: a role ("symbol:calendar") draws on every host, "symbol:sf/<name>" on Apple only.
•
They are in the app's accent: accent-color on the root (or any ancestor) tints them as it tints the controls, on the web and iOS (macOS keeps the system accent, as AppKit does). A state is a second colour: progress short of its goal is the accent, a goal met (fraction 1 or more, a card's progress at 1) the system green, done against not done green against grey. A tint overrides it: a budget gone over passes some("-exact-system-red"), a breakdown whose bars are shares rather than goals passes some("AccentColor").
•
They draw no chrome, and two controls: RoundButton and AnswerTile, the emphasis a timer's or a quiz's screen needs, which paint on a button would make your own box. Any other action is your own button, beside a card or indented under EmptyState. Inset-grouped lists are for settings and forms; a content screen is a scroll of these.
•
Each fills its container's width; arrange them with CSS. In a flex-wrap="wrap" row, flex="1 1 320px" puts a card beside the bars on a wide window and stacks them on a phone.
•
The source is contract/lib/content.contract. To change one, copy it into the app.
Is this helpful
Last updated November 30, 2026
Exact Docs