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

# blob.yaml

> One blob's manifest in an app: the header, then what a workflow, a scheduler or an ONNX model holds.

Every folder under an app's `blobs/` holds a `blob.yaml`: the manifest of one blob, which says what the blob holds
once the app is installed. The folder's name is the blob's alias in the app
([`app.yaml`](https://docs.blobhub.io/blob-types/app/app-yaml#the-repository)). One format serves every blob type: the same two header lines,
then the blob type's id, then what that type defines.

```yaml theme={null}
type: blob
version: "1.0"
blob_type: blobhub.compute.workflow
```

| Key | Required | Meaning |
| - | - | - |
| `type` | yes | `blob` |
| `version` | yes | `"1.0"`, this format's version. Quote it: unquoted, YAML reads `1.0` as a number |
| `blob_type` | yes | The blob's [type string](https://docs.blobhub.io/blob-types/introduction.md): `blobhub.compute.workflow`, `blobhub.compute.scheduler` or `blobhub.model.onnx` |
| `limits` | no | What the blob needs of its organization's limits ([Limits](#limits)) |

* **The platform refuses a format version or a key it does not know**, naming it, so an old platform never half-reads a
  new manifest. `source` is not a key of a definition or an object. A definition that names its file with `source` is
  two problems:
  `blobs/flows/blob.yaml: definitions[0].source: unknown key; the keys here are alias, category, file, as` and
  `blobs/flows/blob.yaml: definitions[0].file: required`. An object's `source` is two as well:
  `blobs/flows/blob.yaml: sessions[0].objects[0].source: unknown key; the keys here are alias, value, file, write`,
  then `blobs/flows/blob.yaml: sessions[0].objects[0]: needs exactly one of value and file`.
* **Every string leaf is a template**, rendered at install with the names `inputs`, `blobs`, `accounts` and
  `installation` ([Templates](https://docs.blobhub.io/blob-types/app/templates.md#install-time-names)). The files a manifest names, an object's
  `file` among them, are copied as they are.
* **`limits` is the package's.** The app's definition reader reads it, and no blob type ever sees it
  ([Limits](#limits)).
* **`build` is the CLI's.** It says what `blobhub app build` compiles into a definition, and the platform never sees
  it: `build/` holds each manifest without its `build` keys ([Manifest](https://docs.blobhub.io/cli/workflow/manifest.md)).
* **`target` is refused inside an app.** Outside an app the same file deploys a plain blob, where
  `target: {blob, revision}` says which; inside one the installation decides ([Manifest](https://docs.blobhub.io/cli/workflow/manifest.md)).

## Limits

`limits` lists what a blob needs of its organization's [limits](https://docs.blobhub.io/general/limits.md). Each entry names a limit of the
catalog by its id and gives one bound; Field Reports' `flows` declares one ([Workflow](#workflow)). Like the rest of
the manifest it is rendered at install, so a bound may be a template; an id may not.

| Key | For a limit that | Met when | Retention's null (kept forever) |
| - | - | - | - |
| `at_least: n` | has a maximum, or is a retention | value ≥ n | meets it |
| `at_most: n` | has a minimum, as `blobhub.compute.scheduler.min_interval_seconds` | value ≤ n | refused |
| `room: n` | is a quota held by the organization, the blob or its revision | value − held ≥ n | n/a |
| `includes: [m, …]` | has the unit `modules`, as `blobhub.compute.workflow.code_imports` | every m is in the value | n/a |

* **A retention takes `at_least` only.** Lowering a retention deletes executions the app never owned, so `at_most` on
  a retention limit, such as `blobhub.compute.workflow.execution_retention_days`, is refused when the definition is
  read. A bound that assumes the organization's retention says so in a comment and in the app's README. Field
  Reports' `at_least: 400` in `flows` is a year of nightly runs and some by hand, as its comment says: it assumes the
  organization keeps a year of runs. `acme-corp` keeps executions forever, so there the session `reports` reaches 400
  after about a year, which Field Reports' README states.
* **One key per entry, and one entry per id in a file.** A bound is a whole number of at least 0 in the limit's unit
  (a count, bytes, seconds or days), or a template that renders to one; `includes` takes a list of
  module names.
* **Which ids:** those in the [catalog's](https://docs.blobhub.io/general/limits.md#the-catalog) `platform` group or in the folder's own type's
  group. A workflow folder may name `blobhub.compute.workflow.running_executions_per_org`; it may not name a scheduler
  limit. `platform.orgs_per_user` is set per user, so no app can require it.
* **Not declarable: the `<type id>.enabled` flags**, which every install checks. A fixed limit may be named, and is
  checked against its fixed value.
* **Where it is evaluated** follows from the limit, not from the folder. A limit whose levels stop at the organization,
  as `platform.blobs_per_org` and `blobhub.compute.workflow.running_executions_per_org`, is evaluated at the
  organization; any other at the folder's blob, as the install will leave it.
* **An install checks requirements and never raises, lowers or copies a limit.** BlobHub raises one when the plan's
  problem is sent to [support@blobhub.io](mailto:support@blobhub.io) ([Changing a limit](https://docs.blobhub.io/general/limits.md#changing-a-limit)).

What a plan does with each requirement is the installer's: [Requirements](https://docs.blobhub.io/blob-types/installer/overview.md#requirements)
and the plan's [`limits`](https://docs.blobhub.io/blob-types/installer/operations/plan#limits).

### When it is checked

[`describe`](https://docs.blobhub.io/blob-types/app/operations/describe) checks each declaration, so `blobhub app push` prints its problems
and `blobhub app commit` refuses a version that has any. Each problem names the file and the entry. Below, each is one
of Field Reports' files with an entry added or changed, and gone wrong:

| Declaration | Problem, ready to print |
| - | - |
| `limits` that is not a list | `blobs/flows/blob.yaml: limits: must be a list` |
| an entry that is not a mapping | `blobs/flows/blob.yaml: limits[0]: must be a mapping` |
| a key an entry does not have | `blobs/flows/blob.yaml: limits[0].min: unknown key; the keys here are id, at_least, at_most, room, includes` |
| no bound, or two | `blobs/flows/blob.yaml: limits[0]: needs exactly one of at_least, at_most, room and includes` |
| an id that names no limit | `blobs/flows/blob.yaml: limits[0]: no limit is named blobhub.compute.workflow.executions_per_day` |
| an id that is missing, or not a string | `blobs/flows/blob.yaml: limits[1].id: must be a limit id` |
| an id written as a template | `blobs/flows/blob.yaml: limits[1].id: a template is not allowed here` |
| `at_most` on a maximum | `blobs/flows/blob.yaml: limits[0]: blobhub.compute.workflow.executions_per_session is a maximum; use at_least` |
| `at_most` on a retention | `blobs/flows/blob.yaml: limits[0]: blobhub.compute.workflow.execution_retention_days is a retention; use at_least, because a lower retention deletes executions` |
| `room` on a retention | `blobs/flows/blob.yaml: limits[0]: blobhub.compute.workflow.execution_retention_days is not a quota, so use at_least` |
| `at_least` on a minimum | `blobs/schedules/blob.yaml: limits[0]: blobhub.compute.scheduler.min_interval_seconds is a minimum; use at_most` |
| a limit of another type | `blobs/flows/blob.yaml: limits[0]: blobhub.compute.scheduler.schedules_per_revision is not a limit of blobhub.compute.workflow` |
| a `<type id>.enabled` flag | `blobs/flows/blob.yaml: limits[0]: blobhub.compute.workflow.enabled is checked by every install; remove it` |
| one id named twice in a file | `blobs/flows/blob.yaml: limits[1]: blobhub.compute.workflow.executions_per_session is named twice` |
| a fixed limit the bound does not meet | `blobs/flows/blob.yaml: limits[0]: the platform fixes blobhub.compute.workflow.sleep_seconds at 43200` |
| `room` on a limit that is not a quota of the organization, a blob or a revision | `blobs/flows/blob.yaml: limits[1]: room is for a quota held by the organization, a blob or a revision; blobhub.compute.workflow.component_runs_per_execution is not a quota, so use at_least` |
| `includes` on a limit that is not a list of modules | `blobs/flows/blob.yaml: limits[0]: includes is for a limit of modules; use at_least or room` |
| a number for a list of modules | `blobs/flows/blob.yaml: limits[1]: blobhub.compute.workflow.code_imports is a list of modules; use includes` |
| a limit set per user | `blobs/flows/blob.yaml: limits[1]: platform.orgs_per_user is set per user; an app cannot require it` |
| a bound that is not a whole number of at least 0 | `blobs/flows/blob.yaml: limits[0].at_least: must be a whole number of at least 0` |
| a bound past the catalog's most permissive value | `blobs/flows/blob.yaml: limits[1]: blobhub.compute.workflow.listener_parallel_runs cannot be set above 32`, or for a minimum, `blobs/schedules/blob.yaml: limits[0]: blobhub.compute.scheduler.min_interval_seconds cannot be set below 60` |
| a `room` past the catalog's most permissive value | `blobs/flows/blob.yaml: limits[1]: blobhub.compute.workflow.listeners_per_revision cannot be set above 100` |

`room` on a minimum ends `so use at_most` instead. At plan, a problem of a manifest is prefixed `invalid_app: `, as in
`invalid_app: blobs/flows/blob.yaml: limits[0]: blobhub.compute.workflow.execution_retention_days is a retention; use
at_least, because a lower retention deletes executions`.

A templated bound is checked once it renders with the install's inputs, at plan. Were `flows` to take its modules from
an input, as `includes: "{{ inputs.config.modules }}"`, a value that is not a list of module names is refused:
`invalid_app: blobs/flows/blob.yaml: limits[1].includes renders to "requests", not a list of module names`.

A plain blob's deploy, [`blobhub workflow deploy`](https://docs.blobhub.io/cli/workflow/commands/deploy) or
[`blobhub scheduler deploy`](https://docs.blobhub.io/cli/scheduler/commands/deploy) of the same file, applies no requirements: it prints
`limits are checked by an install only` and deploys.

## Workflow

```yaml theme={null}
# blobs/flows/blob.yaml
type: blob
version: "1.0"
blob_type: blobhub.compute.workflow
limits:                            # what this blob needs of the organization; an install checks, never raises
  - {id: blobhub.compute.workflow.executions_per_session, at_least: 400}   # a year of nightly runs, and some by hand
definitions:
  - alias: reports-compile
    category: workflow
    file: definitions/compile.json
    build: {code: {summarize: src/summarize.py}}   # component id: entry point
  - {alias: reports-migrate, category: workflow, file: definitions/migrate.json}
  - {alias: reports-desk, category: playground, file: definitions/desk.json}
  - alias: report-viewer
    category: widget
    file: definitions/report_viewer.json
    build: {widget: widgets/viewer}
  # A listener names who it acts as:
  # - alias: file-report
  #   category: listener
  #   file: definitions/file_report.yaml
  #   as: "{{ accounts.runner.id }}"
sessions:                          # sessions an install makes sure exist, and the objects it writes
  - alias: reports
    objects:
      - {alias: config, value: "{{ inputs.config }}"}        # write: always (the default) or once
      - {alias: seeds/report-templates, file: seeds/report_templates.yaml, write: once}     # a value from a file
```

`definitions` lists the revision's definitions of the four categories:

| Key | Required | Meaning |
| - | - | - |
| `alias` | yes | The definition's alias. An upgrade matches definitions by alias, and removes one no longer listed |
| `category` | yes | `workflow`, `playground`, `widget` or `listener`. The platform reads it from `build/`; [`blobhub app build`](https://docs.blobhub.io/cli/app/commands/build) fills it in from the document when the entry leaves it out ([how](https://docs.blobhub.io/cli/workflow/manifest.md#category)) |
| `file` | yes | The definition's file, relative to the blob's folder. In git the file holds the graph without compiled code; in `build/` the same path holds the compiled document. A widget's file exists only in `build/`: its project produces it. It is read as YAML when it ends `.yaml` or `.yml`, as JSON when it ends `.json` |
| `as` | no; a listener only | Who the listener acts as: an app account, `"{{ accounts.runner.id }}"` |
| `build` | no | What the CLI compiles into the definition: `code`, each code component's id with its entry point, or `widget`, the widget project's folder |

A [listener](https://docs.blobhub.io/blob-types/workflow/workflows/listeners.md#declared-listeners) otherwise acts as whoever last uploaded it,
which in an app is the admin who installed it, so an app names an account with `as`. Its own templates, the
`{{ event.… }}` of its target, are in the file it names, which an install copies untouched, so they render when it
fires.

`sessions` lists the sessions an install makes sure exist, and the objects it writes in them:

| Key | Required | Meaning |
| - | - | - |
| `alias` | yes | The session's alias: `reports` |
| `objects` | no | The [session objects](https://docs.blobhub.io/blob-types/workflow/session-objects/introduction.md) an install writes, each with `alias`, `value` or `file`, and `write` |

| Object key | Required | Meaning |
| - | - | - |
| `alias` | yes | The object's [alias](https://docs.blobhub.io/blob-types/workflow/session-objects/introduction.md#alias-grammar-the-namespace): `config` |
| `value` | one of two | The object's value. `"{{ inputs.config }}"` is a lone expression, so it yields the document itself, not its text |
| `file` | one of two | A YAML or JSON file of the blob's folder, `seeds/report_templates.yaml`, read by its extension: YAML for `.yaml` or `.yml`, JSON for `.json`. Its document is the object's value, copied as it is and never rendered, like a definition's file |
| `write` | no | `always`, the default: every install and upgrade writes the value. `once`: an install writes it only when the object is absent, so what the app stores there later is kept |

An object has `value` or `file`, not both and not neither: `blobhub app build` refuses it with
`MANIFEST_INVALID`. An object whose `value` reads an optional input that was left out is skipped.

## Scheduler

```yaml theme={null}
# blobs/schedules/blob.yaml
type: blob
version: "1.0"
blob_type: blobhub.compute.scheduler
schedules:
  - alias: nightly-reports
    as: "{{ accounts.runner.id }}"
    repeat: recurring_cron
    cron_expression: "0 2 * * ? *"
    timezone: UTC
    enabled: true
    invocation_target_type: workflow
    invocation_target:
      target: {blob: "{{ blobs.flows.id }}", revision: default, session: reports}
      workflow: {definition: reports-compile}
      input_data: []
```

`schedules` lists the blob's schedules. Each holds a schedule's own fields, as
[Create Schedule](https://docs.blobhub.io/blob-types/scheduler/operations/create-schedule.md) takes them and the
[Scheduler overview](https://docs.blobhub.io/blob-types/scheduler/overview.md) describes, and two more:

| Key | Required | Meaning |
| - | - | - |
| `alias` | yes | The schedule's alias. An upgrade matches schedules by alias, and removes one no longer listed |
| `as` | no | Who the schedule fires as: an app account, `"{{ accounts.runner.id }}"` |

* **A schedule otherwise fires as whoever created it**, which in an app is the admin who installed it, so an app
  names an account with `as`.
* **`enabled` is read when the schedule is created.** Once it exists, whether it is on is runtime, and an upgrade
  leaves it as it is.
* **The target names a blob of the installation** by `{{ blobs.flows.id }}`, so an install applies `flows` before
  `schedules`: blobs are applied in the order their templates need.

## ONNX model

Were Field Reports to carry a model, say one that sorts notes by kind, a third folder `blobs/classifier/` would hold
the model file beside its manifest:

```yaml theme={null}
# blobs/classifier/blob.yaml
type: blob
version: "1.0"
blob_type: blobhub.model.onnx
model: classifier.onnx
```

| Key | Required | Meaning |
| - | - | - |
| `model` | yes | The [ONNX model](https://docs.blobhub.io/blob-types/onnx/upload.md) file, relative to the blob's folder: `classifier.onnx` |

`blobhub app build` copies the model file into `build/` as it is: nothing compiles it.

## Content and runtime

An install applies each manifest to its blob: the blob's type makes the blob's content what the manifest says,
creating, updating and deleting, and leaves the blob's runtime alone. Applying converges, so an install run again is
safe. What is content and what is runtime is the type's to say:

| Type | Content: written by an install | Runtime: left alone |
| - | - | - |
| Workflow | Definitions of the four categories, with ones no longer listed removed; declared sessions; declared objects (`write: always` rewrites, `once` writes when absent); each listener's `as` | Every other object, thread, graph and file of a session; executions; whether a listener is on |
| Scheduler | Schedules by alias, with ones no longer listed removed; each schedule's `as` | Run history; `enabled`, once the schedule exists |
| ONNX model | The model file and what the platform derives from it | Nothing |

Each type checks its manifest when a version is committed, with stand-in values for the templates, and again before an
install. A type reports the overridable limits its content needs as requirements, such as how many definitions a
workflow manifest leaves, never as a problem at the catalog's defaults; a fixed limit the content breaks, or a
malformed document, stays a problem ([Requirements](https://docs.blobhub.io/blob-types/installer/overview.md#requirements)). So does a count no
override can allow: [`describe`](https://docs.blobhub.io/blob-types/app/operations/describe) reports a workflow manifest holding more
definitions of a category, or more objects in one session, than the limit's most permissive value, and a commit
refuses it with 400 `invalid_app`:

```text theme={null}
blobs/<f>/blob.yaml: the revision holds <N> <category>s; <id> cannot be set above <bound>
blobs/<f>/blob.yaml: the revision holds <N> objects in session <alias>; <id> cannot be set above <bound>
```

The bounds today are 100 for `blobhub.compute.workflow.listeners_per_revision` and 10000 for
`blobhub.compute.workflow.session_objects_per_session`. A plan that meets such a count, in a draft or in a version
committed before a bound was lowered, answers it as an unmet row
([When a requirement is not met](https://docs.blobhub.io/blob-types/installer/overview.md#when-a-requirement-is-not-met)). What an installing
admin must see, such as a widget's permissions, joins the plan's lines, which an install shows for confirmation.


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