The data module (app.ts)
app.ts line by line: how package sources are merged, the answer dispatcher and its arguments, the literal grants list, and an index of every source.

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

1-3

Header: lead-owned, packages edit only inside marked blocks, "Grants must be literal here (the build reads them without running the module)"

4

Imports the Answer and Sources types from the generated app.contract.d.ts

5-14

// >>> imports: one import {sources as <pkg>} per package

16-28

export const grants: an array of string literals joined with newlines

30-41

parts: the list of Partial<Sources> objects

43

Object.assign({}, ...parts) as Sources: later parts win on a name clash

44-45

export const answer: Answer = (source, args, store, storage, native) => sources[source](args, store, storage, native)

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

args

The call arguments, then any with values, as one array

all sources

store

Secret store with get, set, forget, gated by secret.keep grants

identity, and through it discuss, activity, profile, agents, me, vault

storage

App file system (fs.mkdir, readFile, atomicWriteFile), gated by fs grants

vault store only

native

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

net.fetch https:

Any HTTPS origin: Seed sites, notify, vault, agents servers, and sites reached by deep link

net.fetch https://dev.hyper.media

Commented "pkg:profile live dev tests". Already covered by the line above

net.fetch http://127.0.0.1:4790

The local test server. Listed twice (activity and vault blocks)

secret.keep seed-keys

The Keychain item that holds identity keys

net.fetch http://127.0.0.1:3058, net.fetch http:, net.websocket wss:, net.websocket ws:

Agents: plain HTTP for local daemons and WebSockets for streams. These four are one string with embedded newlines

secret.keep seed-vault-kek

The Keychain item for the vault key and remote credentials

fs.read app:/data/vault/envelope.json

Read the encrypted vault file

fs.write app:/data/vault

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

readOpenSite

read

Open a site by URL

readDocs, readDirectory, readAuthors

read

Loading pages, caches and embeds

discussList, discussThreadList, discussPost

discuss

Discuss: loading and posting

activityLoad, activityApply

activity

Activity: notify client

profileLoad, profilePublish

profile

Profile

meIdentities, meProfileNames, meCheckImport, meNewWords, meCreateIdentity, meImportIdentity, meRemoveIdentity, meRenameIdentity, meExportKey, meCheckServer

me

Me: sources and import logic

cryptoSelfTest

crypto

Crypto

vaultRead, vaultStart, vaultCommand

vault

Vault: the store, Vault: screens and tasks

agentsUseTestKey, agentsNormalizeServer, agentsOverview, agentsModels, agentsSession, agentsLoadRuns, agentsCommand, agentsSaveProvider

agents

Agents: reads, commands and the clock

agentsAgentStream, agentsSessionStream, agentsRunStream

agents

Agents: WebSocket streams

exactTime, exactPage

reserved, answered by the host

The Exact framework

Identity exports no sources. Other packages import it as a library.

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

Unsubscribe anytime

Attributes
name
The data module (app.ts)
summary
app.ts line by line: how package sources are merged, the answer dispatcher and its arguments, the literal grants list, and an index of every source.