> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bijection.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Review business operations

> Ask the Approvals app for an attributed decision and act on its result.

The [Approvals app](https://github.com/bijectionhq/bijection/tree/main/npm-packages/apps/approvals)
records attributed votes and decides requests against a requirement of
seats. Mount it by calling it at a path of your tree:

```ts bijection/mounts.ts theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
import { approvals as approvalsApp } from "@bijectionhq/app-approvals";

export const approvals = approvalsApp({
  classes: ["engineering", "finance"],
  floor: { veto: 1 },
});
```

```ts bijection/app.ts theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
import { app } from "@bijectionhq/bijection";
import { approvals } from "./mounts";
import * as release from "./release";

export default app({ release, approvals });
```

The mount brings its own `approvals.reviewer` role. Reviewers decide at the
exposed paths `approvals.decisions.decide`, `approvals.decisions.pending`
and `approvals.requests.history`. Enrol a reviewer from your own mutation
with `ctx.call(approvals.reviewers.enrol, { class, principal, kind })`. Pass the
installer roles allowed to enrol reviewers and re-arm landings in `operators`.
To let another installer role withdraw requests, pass it in `requesters`.

## Ask for a decision

`ask(ctx, approvals, request, { once, within, then })` submits the mount's
`decided` target in your transaction and returns its `Task`. The request
names the subject, a digest of exactly what reviewers approve, and the
requirement.

```ts bijection/release.ts theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
import { ask } from "@bijectionhq/app-approvals";
import { mutation, t } from "@bijectionhq/bijection";
import { approvals } from "./mounts";
import { buyer } from "./roles";
import { orders } from "./schema";

export const decided = mutation(
  { args: { order: t.key(orders), result: t.result(approvals.decided) } },
  async (ctx, { order, result }) => {
    const approved = result.ok && result.value.status === "approved";
    await ctx.patch(orders(order), { state: approved ? "approved" : "rejected" });
  },
);

export const requestRelease = mutation(
  { allow: [buyer], args: { order: t.key(orders) } },
  async (ctx, { order }) => {
    const fact = (await ctx.get(orders(order)))!;
    await ask(ctx, approvals, {
      subject: `orders/${order}`,
      digest: `${order}@${fact.version}:${fact.amount}`,
      requirement: { seats: [{ class: "finance", k: 1 }] },
    }, { once: ["release", order], within: { days: 7 }, then: decided.with({ order }) });
    await ctx.patch(orders(order), { state: "asked" });
  },
);
```

The task settles in the commit of the vote that decides it. Its value is a
`Decision`: `status` (`approved` or `rejected`), the `request`, the
`digest`, the effective `requirement` and the counted `votes`. A request
refused at ask (`InvalidRequirement`, …), a withdrawn ask (`Withdrawn`)
and a missed deadline (`Expired`) arrive as refusals.

Withdraw a pending ask with `ctx.call(approvals.requests.withdraw, { task })`.
It answers the request's latch, so a decision that settled first wins.

## Govern a landing

Pass a landing `policy` when you mount the app, and ask with
`act: { kind: "land", branch }`. The policy is a query answering the
`seen` version it approves. When the request is approved, the mount lands
exactly that version, and a branch that moved past it refuses `Conflict`.
See [Review, approve and land a branch](https://docs.bijection.com/branches/workflow.md).

The [purchase orders example](https://github.com/bijectionhq/bijection/tree/main/examples/purchase-orders)
runs an approval as the first step of a [chain](https://docs.bijection.com/operations/processes.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.