The root contract (app.contract)
The anatomy of app.contract, section by section: imports, routes, the App component's declarations, actions, provide and the route switch.

app.contract is the root of the app: 942 lines holding the routes, the single App component, and every resource, mutation and task of every package. Its first line states why: "Routes, tabs, and every resource/mutation (Exact allows them only here)".

Why everything lives in the root

In Contract a child component declares no resource, mutation or task. The Exact compiler refuses it with type-child-resource (contract-for-agents.md). So package contracts such as read.contract hold only shapes, pure functions and view components, and the root declares the data and passes it down as props, with actions passed as action props. The cost is one large shared file. Ownership blocks keep it editable by several authors.

Section map

Lines

Section

What it holds

1-3

Header

The ownership rule

4-17

Imports

use of screens and shapes from ui, read, activity, agents, discuss, me, then profile and vault in their own blocks

19-20

readScopedHref

Rewrites a /d/... href so it stays on the visible reader's server. See Deep links

22-24

shape Time

epochAtZero, utcOffset: the fields read from the reserved exactTime source

26-65

routes nav

Four tab routes and 21 routes beneath them. See Navigation

67-72

shape CryptoSelfTest

The reply of the hidden crypto parity resource

74-78

component App, shared state

server, currentAccount, time

79-273

Package declarations

One decl block per package

275-280

Shared actions

pick, follow, back

281-733

Package actions

One actions block per package

735-742

provide

Values injected into read's components

743-929

View: route switch

One screen call per route

930-942

View: tab bar

Four role="tab" buttons

Shared state

Three declarations are used by every package (lines 76-78):

Name

Kind

Meaning

server

state, persist

The Seed site the app reads and publishes to. Default https://hyper.media. Changed in Me

currentAccount

state, persist

Account id of the selected identity, "" when none

time

resource exactTime()

Host clock facts. Wall time is always time.epochAtZero + performanceNow(), computed in an action and passed to a source

Declarations per package

Each block is described in a child page, with one line per state, derive, resource, mutation and task:

Block

Lines

Page

pkg:read decl, pkg:discuss decl

79-120

Read and Discuss declarations

pkg:activity decl, pkg:agents decl

121-207

Activity and Agents declarations

pkg:me decl, pkg:profile decl, pkg:crypto decl, pkg:vault decl

208-273

Me, Profile, Crypto and Vault declarations

Actions

Three shared actions come first: pick(name) selects a tab, follow(url) goes to a location scoped to the reader's server, back pops. Then each package has an actions block: read 281-327, discuss 328-365, activity 366-415, agents 416-550, me 551-669, profile 670-686, vault 688-733. Actions are the only place that writes state, sends a mutation (send m = source(...)), refreshes a resource, or reads the clock. Each package's actions are listed on its screens page, for example Agents screens.

Provide

The provide block is owned by discuss. It exposes discussions, discussNow, discussUtc, readNow and readUtc so that read's DocDiscussionSlot and row components can inject them without the root threading them through DocScreen props. The two now values are time.epochAtZero + readTick, the minute clock.

The view

The root node is main navigationKey=... navigationBack="back" navigate=follow testId="app" accent-color="brand". Inside it, a for t in nav.tabs loop draws one role="tabpanel" per tab, and a for e in t.stack loop draws every entry of that tab's stack. A chain of if e.name == "..." picks the screen component and binds its props to root state and actions. Screens of covered entries stay mounted, which is why screens take eid and often active. The tab bar follows.

User stories

The code described here exists to deliver these stories. Each story lists this page in its Trace (traceability).

Do you like what you are reading? Subscribe to receive updates.

Unsubscribe anytime

Connections0
Linked document ยท Outgoing linkLinked document ยท Outgoing linkLinked document ยท Outgoing linkLinked document ยท Outgoing linkRoot declarations: Activity and Agents ยท Child document ยท Outgoing linkRoot declarations: Me, Profile, Crypto and Vault ยท Child document ยท Outgoing linkRoot declarations: Read and Discuss ยท Child document ยท Outgoing linkLinked document ยท Outgoing linkLinked document ยท Outgoing linkLinked document ยท Outgoing linkLinked document ยท Outgoing linkLinked document ยท Outgoing linkLinked document ยท Outgoing linkLinked document ยท Outgoing linkLinked document ยท Outgoing linkLinked document ยท Outgoing linkLinked document ยท Outgoing linkLinked document ยท Outgoing linkLinked document ยท Outgoing linkLinked document ยท Outgoing linkLinked document ยท Outgoing linkThe root contract (app.contract)The root contract (app.coโ€ฆ
Citations 0Children & links 21

Loading child documentsโ€ฆ

Connections show where other documents or comments link to this document.

Related documents

Loading connectionsโ€ฆ