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

# Overview

> Understanding the Installer blob type.

The **Installer** Blob Type (`blobhub.package.installer`) lists what an organization installed from apps. Each entry is
an **installation**: one record, its log, and the blobs and service accounts it made. An install reads one version of
an [app blob](https://docs.blobhub.io/blob-types/app/overview.md), makes the app's blobs in the installer blob's own organization and applies
each blob's [manifest](https://docs.blobhub.io/blob-types/app/blob-yaml.md) to it.

The example on these pages is the installer blob `acme-corp/installed-apps`, holding the installation `reports` of Field
Reports (`acme-corp/field-reports`), which made the blobs `reports-flows` and `reports-schedules` and the service
account `reports-runner`.

* **One revision, edited in place.** An installer blob has one managed revision, as a scheduler blob has, and every
  command goes to it.
* **Several per organization.** An organization may keep one installer blob for everything it installs, or several.
  Each is created as any blob is, with [Create Blob](https://docs.blobhub.io/rest-api/orgs/create-blob.md) and the type
  `blobhub.package.installer`.
* **It is deleted last.** Deleting an installer blob is refused with 409 `installer_not_empty` while it lists an
  installation that is not `uninstalled`. Deleting the installer blob, or its organization, deletes every installation
  record and log with it.

## Installations

An installation is named by its alias, unique within its installer blob: 1 to 31 of `a`-`z`, `0`-`9`, `_` and `-`,
starting with a letter or a digit. Its blobs are named `<installation>-<folder>` and its service accounts
`<installation>-<alias>`, so `reports` makes `reports-flows`, `reports-schedules` and `reports-runner`. Each blob name
must also be a valid blob alias, 6 to 42 characters, or the install is refused with `invalid_installation`.

Its record, as [Get Installation](https://docs.blobhub.io/blob-types/installer/operations/get-installation.md) answers it:

| Field | Type | Description |
| :- | :- | :- |
| `alias` | string | The installation's alias: `reports`. |
| `app` | string | The app blob it installs, as `org/blob`: `acme-corp/field-reports`. |
| `version` | string | The version its last install or upgrade asked for, whether or not it reached `ready`: `0.3.0`. |
| `revision_id` | string | The app blob's revision that holds that version. |
| `status` | string | `installing`, `ready`, `failed`, `uninstalling` or `uninstalled` ([Statuses](#statuses)). |
| `operation` | string | The last operation started on it: `install`, `upgrade` or `uninstall`. |
| `development` | boolean | `true` for an installation of a draft ([Development installations](#development-installations)). Written when the record is made, or made again by an install over an `uninstalled` record, and never otherwise. |
| `inputs` | object | The documents it was given, by input name. A secret is never kept here. |
| `blobs` | object | Each blob it made, from its folder to its blob id. Empty once it is `uninstalled`. |
| `accounts` | object | Each service account it made, from its alias to its user id. Empty once it is `uninstalled`. |
| `created_at`, `updated_at` | string | When the record was created and last changed. |

* **A secret stays out of the record.** A secret input reaches only the credential bodies that read it, and is stored
  as any [credential](https://docs.blobhub.io/general/credentials.md) is. The record keeps the documents, so an upgrade is given only what
  changes.
* **The record outlives the blobs.** An `uninstalled` installation keeps its properties, its inputs and its whole log
  until it is removed.
* **A record holds a place.** An installer blob holds at most
  `blobhub.package.installer.installations_per_revision` records, an `uninstalled` one included until it is removed
  ([Limits](https://docs.blobhub.io/general/limits.md#the-catalog)).

## Statuses

```mermaid theme={null}
stateDiagram-v2
  direction LR
  [*] --> installing: install
  installing --> ready
  installing --> failed
  ready --> installing: upgrade
  failed --> installing: again
  ready --> uninstalling: uninstall
  failed --> uninstalling: uninstall
  uninstalling --> uninstalled
  uninstalled --> installing: install
  uninstalled --> [*]: remove
```

| Status | Means |
| :- | :- |
| `installing` | An install or upgrade is running. |
| `ready` | The last install or upgrade applied every manifest, and its migration, if the app has one, completed. |
| `failed` | The last install or upgrade stopped. What it made stays, and the log says why. Install again. |
| `uninstalling` | An uninstall is running. |
| `uninstalled` | Its blobs and accounts are gone; its record and log stay. Install again, or remove it. |

One operation runs per installation at a time. While it is `installing` or `uninstalling`, another install or
uninstall is refused with 409 `installation_busy`.

A busy record does not stay busy forever: one whose operation started more than two hours ago (7200 seconds) is read as
`failed` by `get_installation` and `list_installations`. The stored record and the log do not change until the next
install or uninstall, or the worker's next delivery of that operation, ends it `failed` with the log line
`<operation> failed: out of time` and goes on. `remove` still refuses it with 409 `installation_not_uninstalled`, naming
the stored status. Install again to retry.

## Install and upgrade

```mermaid theme={null}
sequenceDiagram
  participant C as CLI or web
  participant I as Installer blob
  participant W as Install worker
  participant V as App blob version
  participant T as Blob types
  C->>I: plan(installation, app, inputs)
  I->>V: check the caller may read it, read app.yaml
  I-->>C: inputs to ask, lines, limits, problems, digest
  C->>I: install(the same, confirmed: the digest)
  I->>I: plan again, run the checks, compare the digest
  I->>I: log: requested, the plan's lines
  I->>I: create missing accounts, store credentials
  I-->>C: installation, installing
  loop each blob, in template order
    W->>W: create it when missing, mark it
    W->>V: read its folder, render its manifest
    W->>T: apply the manifest
    W->>I: log: applied
  end
  W->>W: delete blobs the version no longer has
  W->>T: run the migration workflow, wait
  W->>I: log: ready
```

* **Plan, then install.** [`plan`](https://docs.blobhub.io/blob-types/installer/operations/plan) says what an install would do and writes
  nothing, and, when it has no problem, answers a `digest` of what it says.
  [`install`](https://docs.blobhub.io/blob-types/installer/operations/install) does it, with `confirmed` set to the digest of the plan the
  caller showed: it plans again and refuses with `plan_changed` when the plan it makes now has another digest
  ([The checks, in order](#the-checks-in-order)).
* **Install converges.** Each step makes or updates what is missing, so a failed install is run again and what it made
  stays.
* **Upgrade is install, forward only.** The same request, naming an existing installation and a newer version,
  upgrades it. A committed version older than the record's `version`, the version last asked for, is refused with
  `version_downgrade`: a repair moves forward, as a new version. The same version again is allowed, as after a
  `failed` install. Its `inputs` carry only what changes: the record remembers the documents, and a secret whose
  credentials exist counts as given.
* **A version says which installed versions it moves from.** Its
  [`upgrade.from`](https://docs.blobhub.io/blob-types/app/app-yaml#upgrade) names the oldest; an installation last ready at an older one is
  refused with `upgrade_unsupported`, and installs a version in between first.
* **An install checks the limits a version needs.** Every plan evaluates the version's
  [requirements](#requirements) at the organization and at the blobs the install will leave; one that is not met is
  the problem `limit_unmet`.
* **An app may ask an upgrade to wait.** While its [busy object](#the-busy-object) says so, a plan refuses with
  `app_busy`.
* **An upgrade cannot change a folder's blob type.** If the blob `reports-flows` is a `blobhub.compute.scheduler` and
  the version's `flows` folder names a `blobhub.compute.workflow`, the
  [plan](https://docs.blobhub.io/blob-types/installer/operations/plan.md#problems) refuses with `invalid_app` before anything is written. To
  change the type, uninstall the installation and install again, which makes the blob new.
* **Accounts and credentials are written by the request,** before it answers; the blobs by a worker after it. A
  credential with a `body` is written when absent, or rewritten when every input it reads is given again; an
  `account_key` credential is minted and a `writable` one created empty only when absent
  ([Credentials](https://docs.blobhub.io/blob-types/app/app-yaml.md#credentials)).
* **Blobs are applied in the order their templates need.** A blob that reads `blobs.flows` follows `flows`
  ([Templates](https://docs.blobhub.io/blob-types/app/templates.md#install-time-names)). A blob the version no longer has is deleted, with its
  data.
* **Running executions are not stopped.** Each runs from its own copy of its definition, so it finishes on the version
  it started with.
* **Nothing calls home.** An installation holds its own copy of the version.

## Uninstall and remove

* **Uninstall** deletes the installation's blobs with their data, and the service accounts it made with their
  credentials: each account is retired, as [Lifecycle](https://docs.blobhub.io/general/service-accounts.md#lifecycle) describes, so its keys,
  credentials and memberships go and its record stays for attribution. The installation's record stays, as
  `uninstalled`, with its inputs and its log. Installing it again makes the record again: it keeps its alias, its
  inputs and its log, and like a first install it skips checks 6 to 8 and 14
  ([The checks, in order](#the-checks-in-order)), and its kind is set by what it installs. Uninstall waits as an
  upgrade does: while an operation or a migration runs, or while the app's [busy object](#the-busy-object) says so, it
  is refused.
* **Remove** deletes an `uninstalled` record and its log, which ends that installation's log; deleting the
  installer blob or its organization ends all of them. A record that is not `uninstalled` is refused with 409
  `installation_not_uninstalled`.

Both confirm by digest, as `install` does: sent without `confirmed`, each answers `app_not_confirmed` with the `lines`
it would act on and their `digest`, and sent again with that digest, it runs.

## Requirements

A **requirement** is a limit an installation's blob needs: a [limit](https://docs.blobhub.io/general/limits.md)'s id and a bound. An app
declares its own in each folder's `blob.yaml` ([Limits](https://docs.blobhub.io/blob-types/app/blob-yaml.md#limits)); the platform derives the
rest from the content. Every plan evaluates each one at the place the install will leave and answers it as a row of its
[`limits`](https://docs.blobhub.io/blob-types/installer/operations/plan#limits). One that is not met is the problem `limit_unmet`, which asks
[support@blobhub.io](mailto:support@blobhub.io) to set it, or, past the limit's most permissive value, says it cannot be set.

```mermaid theme={null}
flowchart LR
  dec["Declared<br/>blob.yaml limits"]
  der["Derived<br/>each blob type's check<br/>and the installer's own"]
  merge["Merged per place and id<br/>the stricter bound wins"]
  res["Read at its place<br/>a new blob: the org's<br/>a blob that exists: its own"]
  rows["The plan's limits<br/>need, value, met"]
  prob["limit_unmet<br/>ask support to set it<br/>or it cannot be set"]
  dec --> merge
  der --> merge
  merge --> res --> rows
  rows -->|unmet| prob
```

* **Merged per place and id.** When two requirements name the same limit at the same place, the stricter bound wins:
  the larger `at_least` or `room`, the smaller `at_most`, the union of `includes`.
* **Read at its place.** The place is the organization, or a folder's blob as the install will leave it
  ([which one](https://docs.blobhub.io/blob-types/app/blob-yaml.md#limits)). A blob the install creates has no overrides yet, so it reads the
  organization's chain; a blob that exists reads its own
  ([How a value is chosen](https://docs.blobhub.io/general/limits.md#how-a-value-is-chosen)). A held count is read from its holder
  ([Holdings](https://docs.blobhub.io/general/limits.md#holdings)).
* **The target version, against the place as it is now.** Every plan evaluates the requirements of the version it
  would install, at the values in force when it plans. A requirement the installed version had and the target drops is
  not checked. Nothing is remembered between plans, and nothing is raised or lowered.

### Derived requirements

Each blob type's check of its manifest answers the overridable limits its content needs, in a declaration's shape, and
the installer adds its own. A type never reports such a limit as a problem at its catalog default; a fixed limit or a
malformed document stays a problem ([Content and runtime](https://docs.blobhub.io/blob-types/app/blob-yaml.md#content-and-runtime)).

| Derived by | Limit | Need |
| :- | :- | :- |
| The installer | `<type id>.enabled`, for the type of each folder whose blob does not exist yet | On, at the organization |
| The installer | `platform.blobs_per_org` | `room`: the folders whose blob does not exist yet |
| The installer | `blobhub.package.installer.installations_per_revision` | `room: 1` on a first install, at the installer blob |
| Workflow | `blobhub.compute.workflow.definitions_per_revision`, `blobhub.compute.workflow.playgrounds_per_revision`, `blobhub.compute.workflow.widgets_per_revision`, `blobhub.compute.workflow.listeners_per_revision` | `at_least`: how many definitions of that category the manifest leaves |
| Workflow | `blobhub.compute.workflow.sessions_per_revision` | `room`: the declared sessions that do not exist yet |
| Workflow | `blobhub.compute.workflow.session_objects_per_session` | `at_least`: the most objects one declared session lists |
| Workflow | `blobhub.compute.workflow.listener_parallel_runs` | `at_least`: the highest `max_parallel` a listener sets |
| Scheduler | `blobhub.compute.scheduler.schedules_per_revision` | `at_least`: how many schedules the manifest lists |
| Scheduler | `blobhub.compute.scheduler.min_interval_seconds` | `at_most`: the shortest interval a schedule repeats at |
| ONNX model | `blobhub.model.onnx.model_bytes` | `at_least`: the model file's size |

An install makes a revision match its manifest, and removes what the manifest no longer lists first, so a count the
manifest leaves is right for an upgrade as for a first install. A requirement with nothing to count answers no row: no
`room` row when the install makes nothing new, no row for a category the manifest leaves empty, such as
`blobhub.compute.workflow.listeners_per_revision` for Field Reports, and no `<type id>.enabled` row when every blob
exists.

Field Reports' first install, at 0.2.0 as `reports`, needs these; only the first `reports-flows` row is declared:

| Where | Limit | Need |
| :- | :- | :- |
| `acme-corp` | `blobhub.compute.workflow.enabled`, `blobhub.compute.scheduler.enabled` | on |
| `acme-corp` | `platform.blobs_per_org` | room for 2 more: `reports-flows` and `reports-schedules` |
| `acme-corp/installed-apps` | `blobhub.package.installer.installations_per_revision` | room for 1 more: `reports` |
| `acme-corp/reports-flows` | `blobhub.compute.workflow.executions_per_session` | at least 400, as `flows` declares |
| `acme-corp/reports-flows` | `blobhub.compute.workflow.definitions_per_revision` | at least 2: `reports-compile` and `reports-migrate` |
| `acme-corp/reports-flows` | `blobhub.compute.workflow.playgrounds_per_revision` | at least 1: `reports-desk` |
| `acme-corp/reports-flows` | `blobhub.compute.workflow.widgets_per_revision` | at least 1: `report-viewer` |
| `acme-corp/reports-flows` | `blobhub.compute.workflow.sessions_per_revision` | room for 1 more: `reports` |
| `acme-corp/reports-flows` | `blobhub.compute.workflow.session_objects_per_session` | at least 2: `config` and `seeds/report-templates` |
| `acme-corp/reports-schedules` | `blobhub.compute.scheduler.schedules_per_revision` | at least 1: `nightly-reports` |
| `acme-corp/reports-schedules` | `blobhub.compute.scheduler.min_interval_seconds` | at most 86400: `nightly-reports` fires once a day |

Its upgrade to 0.3.0, whose manifests list the same, needs only the rows at its two blobs that are not `room`: both
blobs, the session and the record exist by then.

### When a requirement is not met

Each unmet requirement is one problem, a sentence ready to print, in the form of its need:

```text theme={null}
limit_unmet: <where> needs <id> at least N; it would be <value>. Ask support@blobhub.io to set it
limit_unmet: <where> needs <id> at most N; it would be <value>. Ask support@blobhub.io to set it
limit_unmet: <where> needs room for N more under <id>; it has <value>. Ask support@blobhub.io to set it
limit_unmet: <where> needs <id> to include a, b; it lacks b (<level>). Ask support@blobhub.io to set it
limit_unmet: <where> needs <id>; it is off (<level>). Ask support@blobhub.io to set it
limit_unmet: <where> needs <id> at least N; it would be <value>. <id> cannot be set above <bound>
limit_unmet: <where> needs room for N more under <id>; it has <value>. <id> cannot be set above <bound>, so only removing what is held makes room
```

* **`<where>`** is the organization, or the blob as `<org>/<blob>`.
* **`<value>`** is the row's `value`: `N (<level>)`, or for `room`, `F (V allowed, H held, <level>)`, what is free,
  then what is allowed and held. A retention kept forever is `forever (<level>)`, which meets any `at_least`.
* **`<level>`** is where the value comes from: `default`, `platform` for a fixed limit, or the `user`, `org` or `blob`
  override ([Reading limits](https://docs.blobhub.io/general/limits.md#reading-limits)).
* **Support sets it.** The first five forms end `Ask support@blobhub.io to set it`: send the problem to
  [support@blobhub.io](mailto:support@blobhub.io) as the request ([Changing a limit](https://docs.blobhub.io/general/limits.md#changing-a-limit)).
* **The row's `fix`** says what would meet it, `{"target": "org:<org>" | "blob:<org>/<blob>", "value": <JSON>}`, as
  `{"target": "org:acme-corp", "value": 25}` or
  `{"target": "blob:acme-corp/reports-flows", "value": ["requests", "yaml"]}`. The digest covers it.
  * **The target** is `blob:<org>/<blob>` when the blob exists and the limit may be set on a blob, and `org:<org>`
    otherwise.
  * **The value** is JSON: the bound; for `room`, the held count plus the room; for `includes`, the modules the place
    has and those it needs; for on, `true`. It is the strictest that any row of that target and id needs, leaving out a
    row past the bound, so the values, set in any order, never undo one another.
* **Past the bound, it cannot be set.** When the value that would meet the need is past the limit's most permissive
  value in the [catalog](https://docs.blobhub.io/general/limits.md#the-catalog), `<bound>`, no override can meet it: the row's `fix` is `null`,
  and the problem ends `<id> cannot be set above <bound>` instead of asking support, as the last two forms show, or
  `below` for a limit whose bound is a minimum. Only the `room` form goes on `, so only removing what is held makes
  room`: any other need past its bound clears only with a version, or a draft, whose need stays within the bound. A
  count the content holds past its bound, which [`describe`](https://docs.blobhub.io/blob-types/app/operations/describe) reports and a commit
  refuses ([Content and runtime](https://docs.blobhub.io/blob-types/app/blob-yaml.md#content-and-runtime)), is such a row when a plan meets it:
  in a draft, or in a version committed before the bound was lowered.

One example per need, and two past a bound, each Field Reports falling short at values chosen for the example:

| Need | Problem, ready to print |
| :- | :- |
| `at_least`, on the upgrade, were `acme-corp` to hold the limit at 300 | `limit_unmet: acme-corp/reports-flows needs blobhub.compute.workflow.executions_per_session at least 400; it would be 300 (org). Ask support@blobhub.io to set it`; `fix` is `{"target": "blob:acme-corp/reports-flows", "value": 400}` |
| `room`, on the first install, with one place left for two blobs | `limit_unmet: acme-corp needs room for 2 more under platform.blobs_per_org; it has 1 (24 allowed, 23 held, org). Ask support@blobhub.io to set it`; `fix` is `{"target": "org:acme-corp", "value": 25}` |
| `at_most`, were the upgrade's `schedules` to fire a schedule every five minutes and `acme-corp` to hold the limit at 600 | `limit_unmet: acme-corp/reports-schedules needs blobhub.compute.scheduler.min_interval_seconds at most 300; it would be 600 (org). Ask support@blobhub.io to set it`; `fix` is `{"target": "blob:acme-corp/reports-schedules", "value": 300}` |
| `includes`, were `flows` to declare `includes: [requests, yaml]` and `acme-corp` to allow `requests` alone | `limit_unmet: acme-corp/reports-flows needs blobhub.compute.workflow.code_imports to include requests, yaml; it lacks yaml (org). Ask support@blobhub.io to set it`; `fix` is `{"target": "blob:acme-corp/reports-flows", "value": ["requests", "yaml"]}` |
| on, on the first install, were schedulers off for `acme-corp` | `limit_unmet: acme-corp needs blobhub.compute.scheduler.enabled; it is off (org). Ask support@blobhub.io to set it`; `fix` is `{"target": "org:acme-corp", "value": true}` |
| `at_least` past the bound, were the draft installed as `reports-dev` to list 101 listeners in `flows` | `limit_unmet: acme-corp/reports-dev-flows needs blobhub.compute.workflow.listeners_per_revision at least 101; it would be 20 (default). blobhub.compute.workflow.listeners_per_revision cannot be set above 100`; `fix` is `null` |
| `room` past the bound, on the first install, were `installed-apps` to hold 200 installations under a limit already set to its most permissive value, 200 | `limit_unmet: acme-corp/installed-apps needs room for 1 more under blobhub.package.installer.installations_per_revision; it has 0 (200 allowed, 200 held, blob). blobhub.package.installer.installations_per_revision cannot be set above 200, so only removing what is held makes room` |

* **`limit_unmet` is not `limit_exceeded`.** `limit_unmet` is a plan's problem: found before anything is written, it
  says what is needed, what the place has and who sets it, or that it cannot be set. `limit_exceeded` is
  a write's refusal, which an install meets only when a write loses a race the plan could not see, such as another blob
  created between the plan and the worker's step ([How an operation fails](#how-an-operation-fails)).
* **An install never raises a limit; BlobHub does.** Limits other than the defaults are set by BlobHub
  ([Changing a limit](https://docs.blobhub.io/general/limits.md#changing-a-limit)), so the sentence asks [support@blobhub.io](mailto:support@blobhub.io) to set it, and is the
  request to send. Nothing overrides `limit_unmet`: once the limit is set, the next plan finds it met. Past the
  limit's bound there is nothing to ask for: under `room`, only removing what the place holds makes room, and any other
  need clears only with a version, or a draft, whose need stays within the bound.

## The checks, in order

Every plan runs the same checks, in one order, and `install` runs them again before it acts; `uninstall` and `remove`
run a few of them, below. A problem at checks 1 to 8 stops the plan, and the answer holds only that check's problems: at
1, 2, 3 or 4 (`invalid_installation`, `installation_busy`, `migration_running`, `version_not_found`), one; at 5
(`invalid_app`), every problem of the version's definition; at 6 to 8, the first of `development_mismatch`,
`version_downgrade` and `upgrade_unsupported`. Those are the only stops: past check 8, checks 9 to 14 all run, and each
adds its problems, so one answer lists every problem with the inputs, the blobs, the rendered content, the limits, the
person and the busy object. The command's checks compare what was confirmed with the plan made now.

```mermaid theme={null}
flowchart LR
  rec["1 to 3: the record"]
  ver["4 to 8: the version"]
  con["9 to 14: the content"]
  ans["The answer<br/>lines, limits, problems<br/>a digest if none"]
  cmd["15 to 16: the command<br/>the digest it confirms"]
  wrk["The install worker"]
  rec --> ver --> con --> ans
  rec -.->|"a problem stops it"| ans
  ver -.->|"a problem stops it"| ans
  ans -->|"no problems, install"| cmd -->|"digest matches"| wrk
```

| # | Refusal | Checked | Cleared by |
| :- | :- | :- | :- |
| 1 | `invalid_installation` | The installation's alias | The request |
| 2 | `installation_busy` | The record is `installing` or `uninstalling`, and not past its two hours ([Statuses](#statuses)) | Waiting |
| 3 | `migration_running` | The record's last migration has not ended ([The migration workflow](#the-migration-workflow)) | Waiting, or stopping it |
| 4 | `version_not_found` | The app and the version | The request |
| 5 | `invalid_app` | The version's definition, its `limits` and `upgrade` included | A new version |
| 6 | `development_mismatch` | A development installation takes only the draft, any other only committed versions ([Development installations](#development-installations)) | The request |
| 7 | `version_downgrade` | A committed version older than the record's `version` | A newer version |
| 8 | `upgrade_unsupported` | The version the record was last ready at is older than the target's `upgrade.from` | A version in between, installed first |
| 9 | `input_invalid`, `input_missing` | The inputs | The request |
| 10 | `invalid_installation`, `alias_in_use`, `blob_not_ready`, `invalid_app` | The blobs the install makes or keeps: their names, the blobs holding them, their types | The organization, or a new version |
| 11 | `invalid_app` | Each rendered manifest, as its blob type checks it | A new version, or new inputs |
| 12 | `limit_unmet`, `invalid_app` | Every requirement, declared and derived ([Requirements](#requirements)), and each `limits` bound a template renders: one that renders to the wrong kind of value, or to a value its limit refuses, is `invalid_app` | BlobHub's support; past a bound, removing what is held for `room`, or a version within the bound for any other need; for `invalid_app`, a new version, or new inputs |
| 13 | `person_required` | The install makes service accounts, credentials or keys, and the request does not come from a person ([Access](#access)) | A person's key or session |
| 14 | `app_busy` | The installed version's busy object, and, after a failed upgrade, the last ready version's too; a development installation's, its own version's alone ([The busy object](#the-busy-object)) | The app, time, or a person writing the object |
| 15 | `app_not_confirmed` | `install`, `uninstall` or `remove` without `confirmed` | Confirming |
| 16 | `plan_changed` | `confirmed` is not the digest of the plan made now | Reviewing again |

Each problem's sentence, ready to print, is under [Plan's problems](https://docs.blobhub.io/blob-types/installer/operations/plan.md#problems).

* **Checks 6 to 8 and 14 apply to a record that is `ready` or `failed`.** A first install, and an install over an
  `uninstalled` record, skip them; both make the record, whose kind is set by what they install. A development
  installation skips 7 and 8.
* **`uninstall` runs 2, 3 and 14, then 15 and 16.** Before check 2, a record that is already `uninstalled` is refused
  with 409 `installation_uninstalled`. **`remove`** runs its own check, `installation_not_uninstalled`, then 15 and
  16\.
* **Nothing overrides a check.** `--yes` on the command line and the Review switch in the web approve lines; a plan with
  a problem has nothing to approve. A problem clears only as its row says.

### The busy object

An app names, under [`upgrade.busy`](https://docs.blobhub.io/blob-types/app/app-yaml#upgrade), one session object its own workflows write to
say an upgrade or an uninstall must wait. Its keys, how it is read and the app's duty are under
[The busy object](https://docs.blobhub.io/blob-types/app/app-yaml.md#the-busy-object) in `app.yaml`; this is the installer's side.

* **When a plan reads it:** on an upgrade, on a repeat install of the same version, and in the plan `install` and
  `uninstall` make again before they act. A first install, an install over an `uninstalled` record, and `remove`
  read none.
* **Whose object:** the **installed** version's `upgrade.busy`, the record's `version`, because that version's workflows
  write it. The target version's `upgrade.busy` is read once it is installed. A `failed` record whose last ready version
  differs from its `version` reads two declarations, its `version`'s and the last ready version's, found by version in
  the app blob as check 4 finds one, and the first busy object refuses; a declaration whose app revision is gone is not
  read. A development installation reads only its `version`'s, because a draft cannot be found by version.
* **What a plan says:** `app_busy` names the object, so whoever reads the sentence knows where to look:
  `app_busy: reports is busy until 2026-12-03T03:00:00Z: the nightly reports run (acme-corp/reports-flows, session
  reports, object install/busy)`.
* **The escape:** a person with WRITE on the blob can write the object, or delete it, when the app is broken and holds
  it busy. An `until` in the past frees it on its own.
* **The worker does not read it again.** The seconds between the plan `install` makes again and the worker's first
  write are the app's to cover, by writing `busy` ahead of its work by a margin.

## The log

One stream per installation, appended by every operation and never rewritten. A first install of Field Reports:

```text theme={null}
14:20:03  install 0.2.0 requested by Ana Ruiz
14:20:03  creates blob reports-flows (blobhub.compute.workflow)
14:20:03  …the plan's other lines
14:20:04  created service account reports-runner
14:20:04  stored 3 credentials on reports-runner
14:20:05  created blob reports-flows; applied 4 definitions, 1 session, 2 objects
14:20:06  created blob reports-schedules; applied 1 schedule
14:20:06  running reports-migrate in session reports
14:20:10  reports-migrate completed in 4.1 s
14:20:10  ready at 0.2.0
```

* **Everything an operation decides or does is a message**: who asked, the plan it confirmed, each step's outcome, and
  a failure with its reason and the execution or blob it concerns. Each entry carries `id`, `at`, `operation`, `level`
  (`info`, `warning` or `error`), `message` and `by`, the user who asked.
* **It is the progress view.** While an operation runs, new messages appear at the end; nothing else shows progress.
  [List Log](https://docs.blobhub.io/blob-types/installer/operations/list-log.md) follows it from the last id a client holds.
* **It is the history.** The record carries no separate history field; past installs and upgrades are read from the
  log.
* **It is bounded** by `blobhub.package.installer.log_entries_per_installation`
  ([Limits](https://docs.blobhub.io/general/limits.md#the-catalog)). Past it the oldest entries are trimmed; nothing is refused.

### How an operation fails

A worker that cannot go on ends the operation `failed` and writes an `error` entry, the last of the operation. Its
message reads `<operation> failed: <reason>`, as in `install failed: alias_in_use: <sentence>`. Nothing is answered to a
request by then, so the reason is read from the log. The table names the code each reason starts with:

| Error | Means |
| :- | :- |
| `blob_not_ready` | A blob the install made never became ready, or was deleted meanwhile. |
| `alias_in_use` | Another blob took a name the install was to create, between the plan and the worker's step. |
| `limit_exceeded` | A limit was reached while the worker made a blob or applied a manifest: a write lost a race the plan could not see, such as another blob created since the plan. |
| `renderer_unavailable` | The template renderer could not be reached. The worker tries again; see the paragraph below. |
| `internal_error` | The platform failed unexpectedly: `the install stopped at <step>`. Nothing is quoted from the inputs. |

A blob type's own refusal of a manifest is written under its own code. A step that fails for a reason a later attempt
may mend, such as `renderer_unavailable`, is tried again. If it still fails after 10 minutes, the last entry reads
`<operation> failed: out of time after <N> attempts`. If the attempts end sooner, it is the last reason seen, such as
`install failed: renderer_unavailable: <sentence>`.

## The migration workflow

An app may name, under [`migration`](https://docs.blobhub.io/blob-types/app/app-yaml#migration) in `app.yaml`, a workflow an install runs
after it applies every manifest. It is an ordinary workflow the app ships in one of its workflow blobs, and it moves
the app's data from the shape one version left to the shape the next one reads. The platform's whole part is to start
it at the right moment and wait.

```mermaid theme={null}
flowchart LR
  apply["Every manifest applied<br/>new content in place"]
  mig["The app's migration workflow<br/>input: from, to"]
  data["Session data<br/>data_version 1 to 2"]
  ready["Installation ready"]
  fail["Installation failed<br/>install again reruns it"]
  apply --> mig
  mig -->|"one step per<br/>data version"| data
  mig -->|completed| ready
  mig -->|"failed, or 15 minutes"| fail
```

| Aspect | Contract |
| :- | :- |
| When | After an install has applied every manifest: on the first install and on every upgrade, before the installation turns `ready` |
| Where | In the session `migration.session` of the blob `migration.blob`, which the install has made sure exists: Field Reports runs `reports-migrate` in the session `reports` of `reports-flows` |
| As whom | The app account `migration.as`: `reports-runner` |
| Input | `installation`: `{"alias": "reports", "from": "0.2.0", "to": "0.3.0"}`; `from` is `null` on a first install, and on an install after an uninstall. It arrives as the run's `input_data` entry aliased `installation`: a message whose one `json` part is that document, the form a listener's batch gives each event |
| Waits | Up to 15 minutes |
| Completed | The installation turns `ready` |
| Failed, stopped or timed out | The installation turns `failed`. The new content stays. The log names the execution. Installing again runs it again. A migration that times out is not stopped: until it ends, a plan refuses with `migration_running` |
| What it may do | Whatever a workflow of that account may: read and write the app's sessions, objects, threads and graphs |

The entry reaches the migration's `data.message` component aliased `installation`
([Alias and run input](https://docs.blobhub.io/blob-types/workflow/workflows/component-data.md#alias-and-run-input)), as each event of a
[listener's batch](https://docs.blobhub.io/blob-types/workflow/workflows/listeners.md#templates) reaches a flow: one message, one `json` part.

```json theme={null}
{
  "alias": "installation",
  "value": {
    "type": "message",
    "message": {
      "role": "system",
      "content": [
        {"type": "json", "json": {"alias": "reports", "from": "0.2.0", "to": "0.3.0"}}
      ]
    }
  }
}
```

What the app owes in return:

* **The new version's workflows may run before its migration ends.** Listeners and schedules are not held during an
  install, so those workflows must accept the data of any version [`upgrade.from`](https://docs.blobhub.io/blob-types/app/app-yaml#upgrade)
  admits.
* **A migration may run again** over data it already moved, as an install after a `failed` one does, so it must be
  idempotent.
* **An app whose workflows cannot work on the old data takes its own lock:** they check a data version its migration
  writes last, and wait until it is theirs.

**One migration at a time.** The record keeps the execution id of its last migration, which the record's reads never
serve. While that execution has not ended, a plan refuses with `migration_running`, which names it:
`migration_running: the migration to 0.3.0 still runs as execution 3c9e1f42-7b05-4d8a-a6e2-91f0d4b7c358 in
acme-corp/reports-flows; let it end or stop it`. It ends on its own, or by
[Stop Execution](https://docs.blobhub.io/blob-types/workflow/operations/stop-execution.md); a second migration never starts beside the first.

**What the platform does not do:** it holds no schema, compares no data, takes no snapshot and stops no other
execution.

### Between any two versions

The app keeps a `data_version` object in its session and gives each change of shape one step. Field Reports 0.2.0
keeps its report templates as one list, in an object an install writes only once (`write: once`), so what the app
stored there since is kept; 0.3.0 reads them keyed by site, so its migration reshapes them. 0.2.0 stored no data
version, so an upgrade from it starts at 1. The workflow runs every step between the stored data version and its own,
so skipping app versions and running twice are both safe. In its `logic.code` component, reading the `installation`
input on a route of that name:

```python theme={null}
STEPS = {1: key_templates_by_site}               # data version n -> n + 1
TARGET = 2                                       # the shape 0.3.0 reads

installation = get_data_input("installation")["message"]["content"][0]["json"]
stored = download_session_object("app/data_version")
version = stored["version"] if stored else None
if version is None:                              # a first install has nothing to move
    version = TARGET if installation["from"] is None else 1
while version < TARGET:
    STEPS[version]()
    version += 1
    upload_session_object("app/data_version", {"type": "json", "version": version})   # after each step, so a rerun resumes
upload_session_object("app/data_version", {"type": "json", "version": version})
```

* **A later version** that changes the shape again adds its step under the next number and raises `TARGET`. An
  installation still at 0.2.0 that upgrades straight to it runs both steps.
* **A step may call a model**, say to rewrite stored documents into a new shape: the migration is a workflow.
* **Only forward.** A plan refuses a version older than the installation's with `version_downgrade` before anything
  runs, so a migration only ever moves forward, from any version `upgrade.from` admits; it needs no step back.

## Installed blobs

An installed blob is an ordinary blob of its own type, beside every other blob of the organization: private when it is
created, and owned by the installer blob's organization. A blob belongs to at most one installation. Every blob read
carries its mark, `installation`, naming its installer blob and installation; a plain blob has none:

```json theme={null}
"installation": {"blob": "6b0f2d94-e71a-4c58-9d23-4a8e1c57f0b6", "alias": "reports", "development": false}
```

Its content is written only by an install. While it is installed, a request that would change its content is refused,
and its runtime stays open:

| Request on an installed blob | Answer |
| :- | :- |
| A content write: a workflow blob's `create_definition`, `update_definition`, `upload_definition` and `delete_definition`; a scheduler blob's `create_schedule`, `delete_schedule`, and an `update_schedule` that changes more than `enabled`; an ONNX blob's uploads | 409 `blob_installed` |
| A revision operation: create, commit, reopen, reset or delete a revision | 409 `blob_installed` |
| Deleting the blob | 409 `blob_installed` |
| Its runtime: sessions, objects, threads, graphs, files and executions; turning a listener on or off; a schedule's `enabled` | Proceeds |
| Its Readme and License, its sharing, and an update of the blob itself | Proceeds |

Uninstall deletes the blob. A development installation's blobs are the exception: they stay editable.

## Development installations

A development installation is an installation of an app blob's draft, `version: "draft"`: the developer's way to try a
draft through the same path a customer's install takes. It is possible only in the app blob's own organization;
elsewhere `draft` is refused with `version_not_found`. In the example it is `reports-dev`, in
`acme-corp/installed-apps`.

* **Its blobs are editable.** Its record and its blobs' marks carry `development: true`, and nothing on its blobs is
  refused with `blob_installed`, so the workflow editor and the playground work on them as on any blob.
* **The kind is fixed when the record is made.** A development installation takes only the draft, and any other
  installation takes only committed versions: `development` is written when the record is made, or made again by an
  install over an `uninstalled` record, and never otherwise.
  Either mismatch is refused with `development_mismatch`, before anything is written:
  * `development_mismatch: reports-dev is a development installation and installs only the draft`
  * `development_mismatch: reports installs committed versions; install the draft as another installation`
* **It moves to whatever the draft is.** Every install of it is the draft, so the checks for an older version and for
  `upgrade.from` do not apply ([The checks, in order](#the-checks-in-order)).
* **One command from git to running blobs.** `blobhub app push --install reports-dev` builds, makes the draft equal the
  build and installs the draft over `reports-dev`; `blobhub app pull reports-dev` copies graph and layout edits back
  into the sources ([App commands](https://docs.blobhub.io/cli/app/overview.md)). It confirms by itself over a new installation or a development
  one, unless the plan's `deletes` is not empty: a plan that deletes a blob waits for `--yes`.
* **An install applies the draft again,** so an edit not pulled into the sources is replaced by the next install.

## Access

| Action | Needs |
| :- | :- |
| Plan, install, upgrade | ADMIN on the installer blob and on its organization, the role that creates blobs there; and to see the app |
| Uninstall, remove | ADMIN on the installer blob and on its organization |
| List installations, read one, read the log | READ on the installer blob |

* **Seeing the app** is the app blob's rule: it is public, or the caller is a member of it or of its organization
  ([App access](https://docs.blobhub.io/blob-types/app/overview.md#access)). A private app is shared by adding a person, or a service account,
  as a member with READ; that user may install it wherever they may install.
* **Access is the caller's, not the key's reach.** A key scoped to the installer blob's organization reaches nothing
  outside it, so the platform reads the version itself once it has checked that the key's user may read the app blob.
  An app the caller cannot read, or that does not exist, is 403.
* **A person installs first.** Creating a service account and storing a credential are on
  [the access perimeter](https://docs.blobhub.io/general/organizations-and-access.md#the-access-perimeter), so an install that makes service
  accounts, credentials or keys needs a person behind the request. The plan says so: asked with a
  [service account](https://docs.blobhub.io/general/service-accounts.md)'s own key, or by any caller that is not a person, it answers the problem
  `person_required`, naming the account it would make, or the credentials it would write on an account that exists,
  and nothing is written. An uninstall that retires an account needs a person too, and a service
  account's own key is refused with 403. An upgrade that makes none of them runs under a service account's key, in CI.
* **An app account** is a member of its installation's blobs, with WRITE, and of nothing else. It has no key unless a
  credential asks for one or an admin mints it.
* **Losing access stops upgrades and nothing else.** An installation holds its own copy of the version and keeps
  working.

## Commands

Every command is a `POST` to `/revisions/:id/data/command` (writes) or `/revisions/:id/data/query` (reads), on the
installer blob's one revision.

| Command | Reads or writes | Description |
| :- | :- | :- |
| [`plan`](https://docs.blobhub.io/blob-types/installer/operations/plan) | Reads | What an install would do: the inputs it asks for, its lines, the limits it needs, its problems and its digest. |
| [`install`](https://docs.blobhub.io/blob-types/installer/operations/install) | Writes | Install an app, upgrade an installation, or install it again. |
| [`uninstall`](https://docs.blobhub.io/blob-types/installer/operations/uninstall) | Writes | Delete an installation's blobs and accounts; keep its record and log. |
| [`remove`](https://docs.blobhub.io/blob-types/installer/operations/remove) | Writes | Delete an `uninstalled` record and its log. |
| [`list_installations`](https://docs.blobhub.io/blob-types/installer/operations/list-installations) | Reads | Every installation's record. |
| [`get_installation`](https://docs.blobhub.io/blob-types/installer/operations/get-installation) | Reads | One installation's record. |
| [`list_log`](https://docs.blobhub.io/blob-types/installer/operations/list-log) | Reads | An installation's log, oldest first, from the last id a client holds. |

* **`plan` writes nothing.** It is the dry run, the web's source of install fields and the command line's printout.
* **Lines and log messages are sentences.** The command line and the web print them as they are.
* **`install`, `uninstall` and `remove` need `confirmed`,** the `digest` of the plan the caller showed. Without it each
  refuses with `app_not_confirmed`, carrying the `lines` it would act on and their `digest`; with the digest of another
  plan than the one made now, with `plan_changed`.

## Refusals

| Refusal | When |
| :- | :- |
| `app_not_confirmed` | `install`, `uninstall` or `remove` without `confirmed`; carries `lines` and `digest` |
| `plan_changed` | `confirmed` is not the digest of the plan made now; carries that plan, in the whole shape [`plan`](https://docs.blobhub.io/blob-types/installer/operations/plan#response) answers, `app` and `from_version` included |
| `forbidden` (403) | The app blob does not exist, or is not public and the caller is not a member of it or of its organization |
| `blob_not_ready` | The app blob is not ready, or a blob of the installation is still being deleted after an uninstall; or, to `install` and `uninstall`, a delete has claimed the installer blob first, and nothing is written |
| `version_not_found` | No committed revision of the app blob holds that version, or `draft` names an app blob in another organization |
| `development_mismatch` | The draft over an installation of committed versions, or a committed version over a development installation |
| `version_downgrade` | A committed version older than the installation's `version` |
| `upgrade_unsupported` | The installation was last ready at a version older than the target's `upgrade.from` |
| `input_missing` | A required input was not given, in this request or an earlier one |
| `input_invalid` | A document fails its schema |
| `alias_in_use` | A blob the install would create exists and is not this installation's |
| `invalid_app` | The version has a problem of its own, or a credential's `body` does not render or fit its type |
| `invalid_installation` | The installation's alias breaks its rule, or a blob name made from it is not a valid blob alias |
| `limit_unmet` | A requirement is not met where the install would leave it ([Requirements](#requirements)) |
| `person_required` | The install makes service accounts, credentials or keys, and the request does not come from a person |
| `app_busy` | A busy object says the app is busy: the installed version's, and, after a failed upgrade, the last ready version's too ([The busy object](#the-busy-object)) |
| `limit_exceeded` | A write lost a race the plan could not see, such as a blob created meanwhile; carries `limit` |
| `installation_busy` | An operation on the installation is already running and started less than two hours ago |
| `installation_uninstalled` | `uninstall` names a record that is already `uninstalled`; install it again, or remove it |
| `migration_running` | The installation's last migration still runs ([The migration workflow](#the-migration-workflow)) |
| `installation_not_uninstalled` | `remove` on a record that is not `uninstalled` |
| `installation_not_found` | `uninstall`, `remove`, `get_installation` or `list_log` names no installation of the installer blob |
| `renderer_unavailable` (503) | `plan` or `install` could not reach the platform's template renderer; nothing was written. Ask again |
| `installer_not_empty` | Deleting an installer blob that lists an installation that is not `uninstalled` |
| `blob_installed` | A content write, a revision operation or a delete on an installed blob ([Installed blobs](#installed-blobs)) |

`plan` answers `invalid_installation`, `installation_busy`, `migration_running`, `version_not_found`, `invalid_app`,
`development_mismatch`, `version_downgrade`, `upgrade_unsupported`, `input_invalid`, `input_missing`, `alias_in_use`,
`blob_not_ready`, `limit_unmet`, `person_required` and `app_busy` as problems, sentences that start with their code, in
[the order they are checked](#the-checks-in-order). `install` refuses with the first problem's code, the body carrying
`problems`, `lines` and `limits`. `uninstall` and `remove` refuse in the same shape, with one problem:
`installation_uninstalled`, `installation_busy`, `migration_running`, `app_busy`, `installation_not_uninstalled`, and
`blob_not_ready` when a delete has claimed the installer blob. `plan_changed` carries the plan, `app_not_confirmed` its
`lines` and `digest`, and `limit_exceeded` its `limit`; any other refusal carries only `error` and `message`. Each
command's page lists its own refusals with their statuses.


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