# Packaging, signing and updates

> The .zbot package format, publisher signatures, and how hosts accept updates.

## The `.zbot` package

`zbot pack` writes one file:

```
"ZBOT" ‖ 0x01 ‖ header ‖ signature ‖ manifest JSON ‖ component
```

Each variable part is length-prefixed (`u32`, big-endian). The **header** names the package and
binds everything else to it:

| # | Field | Content |
|---|---|---|
| 1 | format | `0x01` |
| 2 | package_format | `zaun-bot/v1` |
| 3 | app_id | from the manifest |
| 4 | version | from the manifest |
| 5 | publisher_key | the publisher's composite ML-DSA-65 + Ed25519 public key (1 985 bytes) |
| 6 | world | `zaun:bot/bot@0.1.0` |
| 7 | manifest_sha3 | SHA3-256 of the manifest |
| 8 | component_sha3 | SHA3-256 of the WebAssembly component |
| 9 | created_at | milliseconds since the epoch |

The signature (3 374 bytes) is the publisher key's composite signature over the header. A host
verifies it and both hashes before reading the manifest or compiling anything. Limits: header ≤ 4 KiB,
manifest ≤ 64 KiB, component ≤ 64 MiB (a TypeScript bot is about 24 MB, a Rust one a few hundred KB).

## Signing

Publisher keys use the same post-quantum composite scheme as every other Zaun key, so a package
signature stays trustworthy against a future quantum attacker.

> **Caution: Planned**
>
> `zbot keygen` and `zbot sign` are not built yet. Today, `zbot pack --unsigned` writes a development
> package with a zero signature and a zero publisher key. Hosts load it only with
> `allow_unsigned = true`, and its bot card says "unsigned".
## Updates

- The host **pins the publisher key** at install. An update must be signed by the same key and carry
  a higher version; anything else is refused.
- An update that asks for nothing beyond the current grants replaces the running version.
- One that asks for more waits as **pending** until the owner grants the new request; the old version
  keeps running. The previous version is kept for rollback.

Keep your publisher key offline and backed up: losing it means communities must reinstall a bot
signed with a new key.
