---
title: Finance setup
description: Track a durable request to initialize a client's firm-owned Finance space.
owner: engineering
sourceFiles:
  - packages/contracts/src/server/finance-setup.ts
  - packages/db/src/schema/finance-setup.ts
  - apps/server/src/domain/finance-setup/service.ts
  - apps/server/src/domain/finance-setup/data.ts
  - apps/server/src/domain/finance-setup/provision.ts
  - apps/server/src/domain/finance-setup/background.ts
  - apps/server/src/domain/finance-setup/agent-grant.ts
  - apps/server/src/domain/finance-setup/grant-store.ts
  - packages/db/src/schema/finance-executor-grant.ts
  - apps/server/src/domain/finance-setup/executor-client.ts
  - apps/server/src/domain/finance-setup/executor-data.ts
  - packages/db/src/schema/finance-executor-app.ts
  - apps/server/src/http/finance-setup.ts
  - apps/server/src/http/Api.test.ts
---

## Setup intent

Finance belongs to the firm that curates it and refers to a particular client business. A setup request records that the space needs initialization. It does not assert that an agent, computer, Executor app, account or financial diagnostic is ready.

Creating a client-bound Finance space stores one pending setup operation in the same transaction as the space and its storage request. Existing eligible spaces can request setup through the API. The operation's stable identifier and creating actor survive repeated requests and page reloads. Repeating the idempotent request returns the existing operation rather than starting another setup or changing its creator.

An opt-in Server cron consumer provisions a native Executor app from operator-reviewed source. It is disabled by default and requires a configured firm, HTTPS host, Executor organization, management token and exact-version template. See [provisioning configuration](/reference/cli#executor-app-provisioning-configuration). No external app creation runs in an HTTP request.

The consumer claims at most one operation per invocation and checks the creating user's current account standing, manager membership and exact business relationship before external mutations. It persists the target and template before creating an app, and the returned app ID before deployment. A changed host/organization or revoked authority blocks further activation. Deployment resumes with the saved source rather than a subsequently changed template.

`executor` in the setup response is null until a claim exists, then contains `status` and nullable `appId`. Status progresses through `creating`, `created`, `deploying` and `provisioned`. A failed or unconfirmed mutation becomes `reconcile_required`; claims abandoned for five minutes also enter reconciliation. Neither is automatically retried. Reconciliation and reauthorization controls are follow-up work; do not reset these records to pending to repeat app creation.

`provisioned` establishes native app creation and deployment only. Native agent-grant readiness is reported separately by connection status; human provider consent and Finance readiness remain separate integrations. Overall setup remains `pending`. External app identities, original scope and template receipts survive space deletion; this consumer never deletes apps, accounts or credentials.

Creation dispatches setup through `SpaceProvisioning` after the database transaction commits, so a slow external service does not hold space creation open. The Worker uses its native background execution context; the minute-based scheduled consumer recovers pending work. Both paths retain SQL claims and current-authority checks. A failed setup does not delete the space or repeat an unknown mutation.

With automatic grants enabled, a deployed app is followed by its service-owned native MCP connection and OAuth grant. The new `finance_executor_grant` receipt has `creating`, `ready` and `reconcile_required` states. The grant is read-only and restricted to exactly one native app in browser-approval mode. A service session is used only by the control plane. Executor ties OAuth validity to that session, so successful issuance retains the native session and discards its privileged cookie; signing it out would immediately invalidate the agent token. Native session expiry or revocation still stops access, and automatic reauthorization across that expiry remains outside this preview. Failed issuance signs its session out. Grant ciphertext is bound to the immutable app/space/organization/host metadata; no plaintext token enters public setup responses. Provider OAuth is still a separate human action. See [space connections](/architecture/space-connections#clickable-linear-preview) for the UI and authority boundaries.

## API

| Method and path | Result |
| --- | --- |
| `PUT /spaces/:spaceId/finance-setup` | Request setup without browser-supplied ownership or business fields. Return the new or existing pending operation. |
| `GET /spaces/:spaceId/finance-setup` | Read the persisted operation after current manager and business checks. |

The browser uses the existing `/api` proxy prefix. Authentication and trusted-origin policy follow the other server API groups. Missing, inaccessible, unbound and ineligible spaces return 404; a changed saved relationship returns the declared 409 conflict. This slice has no reset or reauthorization endpoint: a later execution integration must reconcile changed authority before admitting a new setup generation.

## Ownership and access

The server derives the owner and business association from the authorized space. Browser-supplied actor, organization and business identifiers cannot replace that authority. The active organization must be the owning firm, and the client relationship must still be valid. Client-facing work shares do not authorize reading internal setup or initializing runtime capabilities.

Recheck current membership, organization state, Finance type and the business relationship on requests and status reads. A saved setup operation must not revive access after revocation. The operation retains the verified business and relationship identifiers as immutable scope snapshots. Revoking the relationship remains possible; recreating it does not revive the old request. A current manager receives 409 if the current relationship differs from the saved scope. The operation's creator and organization are immutable attribution, not a standing execution grant.

## Integration boundaries

| Part | Responsibility |
| --- | --- |
| Client and space | Workbench persists the business, provider relationship and firm-owned space association. |
| Setup operation | Workbench records durable progress and exposes authorized status. |
| Shared Finance agent | A space principal owns the shared session and workspace; private Wes keeps separate user-owned state. |
| Computer | Shared deployed container resources supply isolated runtime instances. Initialize durable storage before execution; boot compute when needed. |
| Executor | A space app and its explicit audience/group are separate setup steps. Workbench participants are not automatically provider tool callers. |
| Connections | Record the consenting person, exact account/company and space grant separately. Provider authorization is distinct from a successful data refresh. |
| Finance readiness | Assess required inputs and period after refresh. A prepared package or connected account does not prove diagnostic readiness. |

## Following slices

The [space connections design](/architecture/space-connections) describes the confirmed product direction, proposed Executor provisioning and consent lifecycle, and implementation ownership. It distinguishes the existing pending operation from the background consumer and shared connection capabilities still to implement.

The execution integration must persist step receipts, reconcile unknown external outcomes before replay and use current authority when resuming. Agent identity, workspace initialization, Executor group membership, app activation and permission synchronization each need independently observable outcomes. A client must be able to authorize the selected business connection without receiving broad app editing or Finance-tool access.

Conversations, financial results and owner-safe sharing use their owning persisted models. A later reviewed request/reply resumes the original job; it does not create a second work hierarchy. Setup success, input readiness, financial review and delivery remain separate outcomes.

The coordination homes are [WB-15](https://linear.app/wurthy/issue/WB-15) for readiness and [WB-22](https://linear.app/wurthy/issue/WB-22) for Finance integration. [The task model](/architecture/task-model) owns persisted work, while the [authentication architecture](/architecture/authentication) owns roles and grants.

Per-Space storage has a separate [durable catalog and readiness boundary](/architecture/space-storage). Its readiness does not change the pending Finance setup status.

The infrastructure module owns the Cron Trigger expression. The Effect Worker registers a native scheduled-event listener through its Alchemy Worker context; returning a `scheduled` function in the RPC shape does not register an event handler. The listener runs the same bounded, SQL-claimed consumer as the immediate space-creation dispatch.
