app.ts is the app's data module: the only TypeScript entry that Exact loads. It is 45 lines. It imports each package's sources object, merges them, exports the grants, and exports one function, answer, that Exact calls for every resource and mutation in the root contract.
Line by line
Lines | What it does |
|---|---|
Header: lead-owned, packages edit only inside marked blocks, "Grants must be literal here (the build reads them without running the module)" | |
Imports the | |
| |
| |
| |
| |
|
The answer dispatcher
Exact calls answer with the source name and the argument list written in the contract. Every package source has the signature (args, store, storage, native):
Argument | What it is | Used by |
|---|---|---|
| The call arguments, then any | all sources |
| Secret store with | identity, and through it discuss, activity, profile, agents, me, vault |
| App file system ( | vault store only |
| Host capabilities | no source in this snapshot reads it |
A source returns a value, a promise, or a never-settling fetch with exactStream for a stream resource. Sources never read a clock: time arrives as an argument. The module runs in the data module runtime under the 100 ms turn budget.
The generated types
app.contract.d.ts is generated by Exact from app.contract and is not checked in. It types Sources (one key per source the contract calls, with its argument tuple and reply shape), Answer, Result<'name'> and StreamSocket. A source that the contract does not call has no key, so a package's sources object is typed Partial<Sources>.
Grants
The grants list is read by the build without running the module, so each entry is a literal. Details of the grant language are in Grants and capabilities.
Grant | Purpose |
|---|---|
| Any HTTPS origin: Seed sites, notify, vault, agents servers, and sites reached by deep link |
| Commented "pkg:profile live dev tests". Already covered by the line above |
| The local test server. Listed twice (activity and vault blocks) |
| The Keychain item that holds identity keys |
| Agents: plain HTTP for local daemons and WebSockets for streams. These four are one string with embedded newlines |
| The Keychain item for the vault key and remote credentials |
| Read the encrypted vault file |
| Write the vault directory |
The mock agents server listens on port 3068 (settings.ts), not the 3058 named in the grant. Requests to it are allowed by the broader net.fetch http: grant.
The reserved exactTime workaround
exactTime is a reserved source that hosts answer themselves. Two packages still define a fallback returning {epochAtZero: 0, utcOffset: 0}:
src/read/sources.ts: "the web build's server render ... installs no reserved exactTime answer, so once the app has any TS source the prerender asks the data module for it and the build fails". It is typed outside Sources, which has no exactTime key.
src/agents/sources.ts: the same fallback, for the build-time Markdown render.
Both are reached only at build time. Since agents is merged after read, its copy is the one in the merged object.
Source index
Source | Package | Documented in |
|---|---|---|
| read | |
| read | |
| discuss | |
| activity | |
| profile | |
| me | |
| crypto | |
| vault | |
| agents | |
| agents | |
| reserved, answered by the host |
Identity exports no sources. Other packages import it as a library.
Related
The root contract: where each source is called
Package conventions and ownership blocks: the >>> blocks in this file
Do you like what you are reading? Subscribe to receive updates.
Unsubscribe anytime