vitna.ai/docs/routing/delivery Machine view
Raw .md llms.txt
> Source: https://vitna.ai/docs/routing/delivery
> Raw Markdown: https://vitna.ai/docs/routing/delivery.md
> Corpus index: https://vitna.ai/llms.txt

# Delivery targets

Where a workload's accepted decision gets applied. Without one, a decision is
only readable; with one, it is emittable.

## The shape

`aperture.workload` carries a `delivery` column, a JSON object:

```json
{ "kind": "env", "key": "MODEL_SONNET" }
```

```json
{ "kind": "policy", "alias": "deep-research" }
```

| Field | Meaning |
|---|---|
| `kind` | How the value is delivered: `env` for a variable a consumer loads, `policy` for a lane a runtime resolves |
| `key` | The environment name to set. `env` only, and required there. |
| `alias` | The lane a caller names in a request. Required on `policy`, optional on `env`. |

An empty `{}` means nothing emits this workload, and that is the ordinary case.
Most workloads are decided and never deployed by anything Vitna can write.

## A workload can be both

An `env` target may carry an alias as well:

```json
{ "kind": "env", "key": "MODEL_OPUS", "alias": "deep-research" }
```

That row is written by [`aperture:config`](config.md) as a variable and carried
by [`aperture:policy`](policy.md) as a lane, from one decision. It is the state a
team holds while it moves from one mode to the other, and a schema that could
not express it would force a flag day.

## Setting one

```bash
npm run aperture:workload:edit -- <id> --env-key MODEL_SOMETHING
npm run aperture:workload:edit -- <id> --policy-alias deep-research
```

Both flags merge rather than replace, so naming a lane on a workload that
already writes a variable does not stop it writing one. An empty value removes
that half:

```bash
npm run aperture:workload:edit -- <id> --env-key ""
```

Removing both leaves `{}`, which is the register saying nothing applies this
workload, rather than a kind with nothing behind it.

## The database settles the shape, not the command

A check constraint requires `delivery` to be empty, an `env` kind with a key
matching `^[A-Z][A-Z0-9_]*$` and optionally an alias, or a `policy` kind with an
alias matching `^[a-z][a-z0-9-]*$` and no key.

That is in the database rather than only in the command that writes it, because
an env key that is not an env key produces a configuration line the consumer
silently ignores, and an alias that is not a lane name is a lane no caller can
address. A silent ignore is the exact failure this whole phase exists to
prevent.

The two patterns are also the ones the emitters read from, in one place, and a
test compares the constraint's text against them: a constraint that admitted an
alias the emitter refuses would let a row into the register that no policy could
ever carry.

## One key, one workload. One alias, one workload

Two workloads claiming the same key is a refusal, not a merge. The second would
otherwise win silently, and which one won would depend on iteration order.

The same holds for an alias, and it matters more: two workloads claiming one
lane means a request has two answers.

## Why an environment fragment, and why also a document

The first consumer already reads its model ids from the environment, so applying
a decision costs no code at the other end. A consumer with no such variable has
nothing to load a fragment into, which is what the policy document is for.

A third consumer that loads neither would add its own arm to the `kind` check
and its own writer. The constraint is written to make that an addition rather
than a loosening, and `policy` was the first time that was collected on.
Human Machine Shift+M