> ## 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.

# Legal holds

> Keep a family member or an erasable fact from destruction while a hold stands, isolated to the holder's label.

A **legal hold** keeps one unit from being destroyed: a family member
(`family.of(key)`) or one fact of an erasable table.

Erasure has two phases:

1. **Closure (`ctx.erase(unit)`).** The erasing commit writes a `sys.erasures`
   fact at the unit's label and returns the closure `Version`. Set reads at
   every version and in every world answer over survivors. An addressed read
   returns `null` by default. `ctx.get(point, { closed: true })` includes the
   closure for frames that admit it. The closed assertion still supersedes
   earlier assertions.
2. **Destruction (host custody collector).** Physical destruction of the unit's
   keys runs asynchronously after the unit's public hold cutoff
   (`closureAt + max(120 s, holdWindow)`) has passed and no standing hold
   remains. When destruction finishes, the host records a `sys.destructions`
   fact at the unit's declared `erasable.custody` label.

The same applies when a fact reaches its table's `lifetime`: reads close at once,
the public cutoff is measured from closure, and destruction waits until the last
standing hold is lifted. Nothing else gets around a hold except an operator who
overrides holds by name to delete the whole installation (see below).

## Producing held content

At head, use `ctx.get(table(id).held(hold))` for one minted record or
`ctx.page(table.byId().held(hold), { size: 50 })` for a page of sealed
handles. These reads require the `holds` right and clearance of the hold's
label. They return handles without opening the records.

In a writable Root frame outside a trial, with the same right, pass a handle to
`ctx.open(sealed, { hold })`. The hold must stand and cover the closed record.
The kernel applies `act.produce` guards
and commits a `sys.disclosures` entry of kind `produce` at the hold's label
before releasing the content. The entry names the hold, unit, function, and
number of values produced. The last lift ends production and lets the
collector destroy the key.

When a hold on a live fact records a typed reference to a File, it
preserves the exact File generation. A provider-backed File up to 512 KiB
has its verified ciphertext copied into the Store when the hold is placed.
A larger one keeps its original provider object, which is not deleted
while any hold on that generation stands. After the held fact closes,
`ctx.get(file.held(hold))` can return a handle to that generation.
Open it with `ctx.open(handle, { hold })` to obtain its `id`, total `size`,
base64 `sha256`, and up to 512 KiB of `bytes` starting at `offset`. `next`
is a handle to the following part, opened the same way, or `null` after the
last. Each part is a separate production with its own disclosure entry.
Reusing the File id cannot change the generation produced under the hold.

```ts theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
import { sys, type File, type MutationCtx } from "@bijectionhq/bijection";

export async function produceFile(
  ctx: MutationCtx,
  file: File,
  hold: ReturnType<typeof sys.holds>,
) {
  const chunks: Uint8Array[] = [];
  let handle = await ctx.get(file.held(hold));
  while (handle) {
    const part = await ctx.open(handle, { hold });
    chunks.push(part.bytes);
    handle = part.next;
  }
  return chunks;
}
```

## Label isolation and non-interference

A hold lives at the commit label `c` of the mutation that placed it
(`unitLabel ⊑ c ⊑ custody`). Holds are strictly non-interfering:

* `ctx.erase(unit)` never reads holds and answers an erasure point whose fact carries the closure `Version`
  whether or not any hold stands.
* A lower label never observes a higher label's hold—not through `sys.holds`,
  not through `ctx.erase`, not through hold capacity, not through `ctx.lift`,
  and not through the hold cutoff.
* After closure, a fresh hold at label `c` is admitted only before the public
  cutoff (`now < closureAt + max(120 s, holdWindow)`), or if a hold already
  visible at `c` still stands. Past the cutoff with no visible hold, `ctx.hold`
  refuses `HoldCutoffPassed` regardless of whether a higher-labelled hold
  stands.
* The cutoff governs admission of new holds. Custody reserves an admitted
  placement or lift before the Store append orders its decision.
* Hold capacity is bounded by the caller label's own `holds` quota (never an
  installation-wide shared counter).

```ts theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
import { mutation, sys, t } from "@bijectionhq/bijection";

export const holdTenant = mutation({ args: { org: t.string, matter: t.string } }, async (ctx, { org, matter }) => {
  const hold = await ctx.hold(tenant.of(org), { message: `Litigation ${matter}: keep until the court releases it` });
  return hold;
});

export const release = mutation({ args: { hold: t.string } }, async (ctx, { hold }) => {
  await ctx.lift(sys.holds(hold));
});
```

`ctx.hold(unit, { message })` takes the unit itself: `family.of(key)` or a
point of an erasable table, `t(id)`. It does not take the unit's name. It
returns the hold, a `sys.holds` point.
`ctx.lift(hold)` lifts exactly that hold at its label. Each call places its own
hold, so two teams—even at different labels—can hold the same unit for
different matters and lift them independently. The `message` (1 to 256 bytes)
says why the unit is held. It is recorded for the people who review holds, so
write it for them.

## Custody label and hold window

Declare `erasable: { custody, holdWindow }` on an erasable table or label
family to choose where destruction evidence lives and how long fresh holds may
be placed after closure:

```ts theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
export const legal = label();
export const attachments = table(
  { name: t.string },
  { erasable: { custody: legal, holdWindow: { days: 7 } } },
);
```

* `custody` defaults to the unit's own label (`unitLabel ⊑ custody`). It is the
  ceiling on every hold over the unit and the label at which `sys.destructions`
  is written.
* `holdWindow` defaults to the 120-second drain bound and may be up to 30 days.

## Read the holds and destruction evidence

Every standing hold is a `sys.holds` fact `{ id, unit, message, as, at }` at the
label of the mutation that placed it. The `unit` is `member:<tag>` for a family
member, or `fact:<id>` for an erasable app fact, typed `UnitName`. `as` is the
principal who placed the hold, and `at` is when.

```ts theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
const onRow = await ctx.list(sys.holds.where({ unit: `fact:attachments/${id}` }).first(20));
const newest = await ctx.page(sys.holds.by("at").descending(), { size: 50, cursor: null });
```

A lift retracts the fact, so `sys.holds` lists only the standing holds your
clearance admits. An empty `sys.holds` query means no hold **you clear**
stands—higher-labelled holds may still exist in their own label places.

Auditors cleared for `erasable.custody` read `sys.destructions`
(`{ id, unit, erasure, at, evidence }`) to observe verified physical
destruction.

## Who may hold

A role's `hold` right names the units its holders may hold and lift, in the
same way that `erase` names the units they may erase:

```ts theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
export const counsel = role({ hold: [tenant], clear: [tenant] });
```

Guard the acts like any grave act. `act.hold()` and `act.lift()` offer the
held `unit`:

```ts theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
export const reviewedLifts = forbid(act.lift(), {
  message: "A hold on a tenant is lifted only by the legal review flow.",
  under: label.public,
  where: (a) => a.unit.startsWith("member:").and(a.holdings.has(counsel).not()),
});
```

## Refusals

| Refusal | When |
| - | - |
| `Erased` (`HoldCutoffPassed`) | The unit's public post-closure hold cutoff has passed and no hold visible to the caller stands. |
| `Disallowed` (`HoldAboveCustody`) | The caller's commit label is not bounded by the unit's declared `erasable.custody` label. |
| `Limit` (`HoldCapacity`) | The caller label's own `holds` quota is full. |
| `Disallowed` (`ErasureInBranch`) | `ctx.erase`, `ctx.hold`, or `ctx.lift` was called inside an open branch. Run these acts at Root. |
| `Absent` | The caller's label shows no erasable fact: none exists, or it sits at a label the caller does not clear, and the caller cannot tell which. `ctx.erase` also takes a deleted fact whose versions the table's history still keeps. Or the hold to lift is absent at the caller's label. |
| `Disallowed` (`HoldsFenced`) | The installation is being deleted, so its holds no longer change. |

## Holds and deleting an installation

The platform reads the host-only hold index across every label before it deletes
an installation. A delete waits for every standing hold to be lifted unless the
operator overrides the complete inventory by name and digest. From the moment a
delete is reserved, holds can no longer be placed or lifted (`HoldsFenced`).


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