---
title: "Orient and choose the right layer"
description: "Before changing an app, find its files and target hosts, read the nearest working example, and choose the layer: Contract, the data module, a native module or the host."
modificationDate: "2026-11-30"
---

> ## Documentation index
> Fetch the complete documentation index at: https://exact.expo.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Orient and choose the right layer

<AgentInstructions>

## Submitting feedback

From the app's directory, read `bun exact.mjs feedback status`. Under `never`, keep no note.
Respect `EXACT_FEEDBACK=0` and do not change the policy.

Otherwise record specific, actionable feedback with:
`bun exact.mjs feedback note "Exact docs: https://exact.expo.dev/learn/contract-for-agents/orient-and-choose-the-right-layer: <what was wrong or missing>"`

The note goes to Expo only as that status allows. Include no secrets or personal data.

</AgentInstructions>

1. Identify the app, its root `app.contract`, `app.json`, data module, imports,
   authored tests, and requested target hosts. An external app uses `EXACT_APP_DIR`
   with the same Exact build/driver scripts.
2. Read the nearest working example for the feature. Search `contract/corpus/`,
   `contract/cli/tests/it/`, and the app's sources before designing new syntax.
3. Decide whether the change belongs in Contract, the app's data module, its
   optional native/GPU module, or the host. Do not extend the compiler to avoid
   writing an ordinary data-source function.
4. Check the current branch and dirty files. Preserve other work. Do not commit
   unrelated staged paths or use `git stash` in this repository.

| Work | Normal home |
| --- | --- |
| View structure, UI state, event binding | `.contract` |
| Derived labels, record copies, bounded list transforms, a presentation order by one key (`sortBy`) | Contract expressions / `fn` |
| Network, authentication, storage, a stored or locale order, domain algorithms | App TypeScript/Rust data module |
| Device facts | Reserved source with an admitted shape |
| A system control (button, list, switch, picker, menu, tabs, bars) | Contract's native form ([below](https://exact.expo.dev/learn/contract-for-agents/views-layout-and-interaction.md)); an app native module only where none exists |
| What only the platform's own object can do (a gesture recognizer, a bar's look, drawing into a view) | An access hatch: `hatch="word"` on the node, native code handed its view ([Exact developer reference](https://exact.expo.dev/reference/developer/access-hatches.md)); `bun exact.mjs hatch <word>` writes the stubs |
| Canvas 2D drawing | Data module's canvas surface |
| GPU scene or game | Optional GPU/game artifact |
| App identity, grants/deploy selection, module placement | App manifest and data-module declarations |

Windows apps default to ink, or CPU when the manifest declares `game`;
`host.windows.painter: "ink"` or `"cpu"` selects either, and `EXACT_PAINTER`
overrides both. Headless drives explicitly use CPU unless
overridden, so inspect the desktop capture too. See the
[Windows painter choices](https://exact.expo.dev/reference/developer.md#windows-painter) for device selection
and the other platforms' defaults.

For the implementation, the relevant authorities are:

| Question | Source |
| --- | --- |
| Tokens, indentation, escapes | [`lexer.rs`](https://github.com/expo/exact/blob/41ded8c5ede0b2959ef0daa83b1ff78545dd4428/contract/syntax/src/lexer.rs) |
| Declarations, statements, elements | [`parser.rs`](https://github.com/expo/exact/blob/41ded8c5ede0b2959ef0daa83b1ff78545dd4428/contract/syntax/src/parser.rs) |
| Precedence, templates, callbacks | [`parser/expr.rs`](https://github.com/expo/exact/blob/41ded8c5ede0b2959ef0daa83b1ff78545dd4428/contract/syntax/src/parser/expr.rs) |
| Records, locals, callbacks | [`types/records.rs`](https://github.com/expo/exact/blob/41ded8c5ede0b2959ef0daa83b1ff78545dd4428/contract/types/src/records.rs), [`types/actions.rs`](https://github.com/expo/exact/blob/41ded8c5ede0b2959ef0daa83b1ff78545dd4428/contract/types/src/actions.rs), [`types/lists.rs`](https://github.com/expo/exact/blob/41ded8c5ede0b2959ef0daa83b1ff78545dd4428/contract/types/src/lists.rs) |
| Tags, aliases, authored CSS names | [`lower/tags.rs`](https://github.com/expo/exact/blob/41ded8c5ede0b2959ef0daa83b1ff78545dd4428/contract/lower/src/tags.rs) |
| Kernel property declarations | [`schema.json`](https://github.com/expo/exact/blob/41ded8c5ede0b2959ef0daa83b1ff78545dd4428/kernel/tables/schema.json) |
| Function signatures | [`format.json`](https://github.com/expo/exact/blob/41ded8c5ede0b2959ef0daa83b1ff78545dd4428/plan/tables/format.json), field `stdlib`, plus compiler intrinsics |
| Commands and argument checks | [`types/checks.rs`](https://github.com/expo/exact/blob/41ded8c5ede0b2959ef0daa83b1ff78545dd4428/contract/types/src/checks.rs) |
| Event payloads and arities | [`analyze/lib.rs`](https://github.com/expo/exact/blob/41ded8c5ede0b2959ef0daa83b1ff78545dd4428/contract/analyze/src/lib.rs) |
| Imports and file boundaries | [`cli/sources.rs`](https://github.com/expo/exact/blob/41ded8c5ede0b2959ef0daa83b1ff78545dd4428/contract/cli/src/sources.rs) |
| CLI flags and output | [`cli/main.rs`](https://github.com/expo/exact/blob/41ded8c5ede0b2959ef0daa83b1ff78545dd4428/contract/cli/src/main.rs), [`cli/build.rs`](https://github.com/expo/exact/blob/41ded8c5ede0b2959ef0daa83b1ff78545dd4428/contract/cli/src/build.rs), [`cli/lib.rs`](https://github.com/expo/exact/blob/41ded8c5ede0b2959ef0daa83b1ff78545dd4428/contract/cli/src/lib.rs) (diagnostic JSON) |

The design is recorded in LLP 1006, LLP 1017.000 and LLP 1035.005.000.
A proposal in a design document is not an implemented grammar production.
