docs: add VoidBuildSystem handbook

This commit is contained in:
faumaray committed 2026-12-06 12:58:59 +03:00
1 parent 1f9a5d5804
commit 00e14bae98
19 files changed
+3240

No files matched your search

@@ -0,0 +1,153 @@
---
title: Run a Package Registry
description: Start vbs-registry, bootstrap an administrator, create tokens, publish releases, and operate storage safely
section: Shipping & Publishing
badge: vbs-registry
order: 2
tags: [registry, server, rbac, tokens, csrf, web-ui, storage, backup]
updated: 2026-12-06
---
# Run a Package Registry
`vbs-registry` is the reference package registry and shared cache. It serves immutable source releases, binary variants, metadata, owner/token administration, an audit log, a web UI and the remote-cache/worker endpoints.
:::callout{type="warning" title="Scope in 1.0.0"}
- POSIX only; the registry is not built on Windows.
- HTTP/1.1 with one request per connection and serialized API handling.
- No built-in TLS. Run it behind a TLS-terminating reverse proxy for anything other than loopback.
- Sessions, workers, leases and the action queue are in memory and are lost on restart. Packages, blobs, users, tokens and audit entries persist.
:::
## Start the service
```sh
export VBS_REGISTRY_ADMIN_PASSWORD='a long bootstrap password'
vbs-registry \
--data-dir /var/lib/vbs-registry \
--web-root ./registry/web \
--bind 127.0.0.1 \
--port 8080
```
| Flag | Default | Meaning |
| --- | --- | --- |
| `--data-dir` | `registry-data` | Metadata and CAS root |
| `--web-root` | `<source>/registry/web` | Static admin UI; point it at the packaged assets in a deployment |
| `--bind` | `127.0.0.1` | IPv4 bind address |
| `--port` | `8080` | `0` selects an ephemeral port |
| `--admin-password-env` | `VBS_REGISTRY_ADMIN_PASSWORD` | Environment variable holding the bootstrap password |
The administrator is created from `bootstrap_admin_user = "admin"` plus that password **only when the database has no metadata yet**. The environment password is ignored for an existing database; there is no password-reset CLI. If you start an empty registry without the environment variable, it has no users and no way to log in.
Storage defaults, configurable only through the C++ `RegistryConfig` API in 1.0.0:
| Setting | Default |
| --- | --- |
| Maximum request/upload body | 32 MiB |
| Maximum reported package storage | 2 GiB |
| Bootstrap admin user | `admin` |
| Audit cap | 2000 entries (oldest 500 trimmed) |
## Data directory
```text
registry-data/
├── metadata.v1.json # users, tokens, packages, releases, audit
├── registry.lock # per-save advisory lock
├── cas/blobs/<2>/<sha256> # package and binary blobs (0444)
└── action-cache/
├── blobs/<2>/<sha256> # remote-cache output blobs
└── actions/<2>/<sha256>.json # remote-cache action records
```
Metadata is rewritten synchronously on every mutation. Blobs are published before the metadata commit that references them, so a crash cannot advertise a missing artifact. Interrupted staging files are conservative: they are simply not referenced.
## Authentication and authorization
There are three roles: `reader`, `publisher` and `admin`.
- **Sessions**: `POST /api/v1/auth/login` sets an HttpOnly `SameSite=Strict` session cookie and returns a CSRF token. Sessions last 24 hours and are not persisted. Mutating cookie requests must send `X-CSRF-Token`; bearer requests are exempt from CSRF.
- **Tokens**: `POST /api/v1/tokens` returns `vbs_tok_…` exactly once. Only its SHA-256 is stored. A token can be listed and revoked, never re-read.
- **Scopes**: `read`, `publish` and `admin` are consulted. Publishing to an existing package requires ownership unless you are an admin. A new publisher becomes the package owner.
- **Private packages**: hidden from anonymous listing and access, but any authenticated principal with `read` can read them. This is team-level visibility, not a per-user ACL.
```sh
curl -sS -X POST http://127.0.0.1:8080/api/v1/auth/login \
-H 'Content-Type: application/json' \
-d '{"username":"admin","password":"…"}'
```
The response includes `csrf_token`; send it as `X-CSRF-Token` on cookie-authenticated mutations. For automation, create a token and use `Authorization: Bearer vbs_tok_…`, which avoids CSRF and session lifetime concerns.
## Web administration
Open `http://127.0.0.1:8080/` and sign in. The UI supports:
- package search and detail, release download and yank;
- source release upload;
- token creation, listing and revocation;
- storage usage, user creation and the audit log.
It does **not** expose binary-variant browsing/publishing, owner management, metadata editing or upload progress in 1.0.0. Those operations are available through the HTTP API and `vbs` commands.
## Publish from the CLI
```sh
export VBS_REGISTRY_URL=http://127.0.0.1:8080
export VBS_REGISTRY_TOKEN=vbs_tok_...
vbs publish --name my-lib --version 1.2.3 --description "A small library"
vbs releases list --name my-lib
vbs releases show --name my-lib --version 1.2.3
```
`vbs publish` uploads a deterministic source archive. The registry validates safe extraction, enforces immutability, and stores the blob before committing metadata. Publishing identical bytes again is idempotent; different bytes for the same version is `409`.
Binary variants:
```sh
vbs publish-binary --name my-lib --version 1.2.3 \
--variant linux-x86_64-gcc16-release \
--file dist/libmy_lib.a
vbs binaries list --name my-lib --version 1.2.3
vbs binaries fetch --name my-lib --version 1.2.3 \
--variant linux-x86_64-gcc16-release --output libmy_lib.a
```
## Metadata, owners and audit
| Operation | Route | Authority |
| --- | --- | --- |
| Update description/private | `PATCH /api/v1/packages/<name>` | Publish authority + CSRF |
| List owners | `GET /api/v1/packages/<name>/owners` | Read access |
| Add owner | `PUT /api/v1/packages/<name>/owners/<user>` | Publish authority + CSRF |
| Remove owner | `DELETE /api/v1/packages/<name>/owners/<user>` | Publish authority + CSRF; last owner is rejected |
| Users | `GET/POST /api/v1/users` | Admin |
| Audit | `GET /api/v1/audit?actor=&action=&outcome=&limit=&offset=` | Admin |
| Stats | `GET /api/v1/stats` | Admin |
| Storage | `GET /api/v1/admin/storage` | Admin |
An empty registry can be bootstrapped with an admin token, but there is no CLI for user management in 1.0.0; use the API or web UI.
## Backup and recovery
The service exposes `backup_to(dir)` and `restore_from(dir)` in the C++ `RegistryService` API, but no CLI or HTTP route in 1.0.0. Those helpers copy metadata and source-release blobs only; binary blobs and the action cache are not included.
For a complete backup:
1. Stop the writer so no metadata or blob publication is in flight.
2. Copy the entire `--data-dir` tree, preserving ownership and permissions.
3. Restart the service and verify metadata, a release download, a binary download and a CAS action.
Restoring metadata without its blobs produces explicit `500 integrity_error` responses rather than silent partial downloads, but the data is still lost. Copying the whole data directory is the only complete backup path in 1.0.0.
## Operational limits
- One request per connection; API calls serialize on the registry mutex. A slow download does not block package mutations, but a slow publish does hold the upload path.
- Header limit 64 KiB, body limit 32 MiB, 10 s socket timeouts.
- `Range` supports a single range. `HEAD` is routed as `GET` with the body suppressed and `Content-Length` preserved.
- Strong `ETag` and `If-None-Match` (including weak prefixes, lists and `*`) are supported for metadata and downloads.
- Rate limiting, login throttling, token expiry through the HTTP API, user deactivation and TLS are not built in.
Next: [connect a remote cache and workers](/build-system/consumer/remote-ci) or [read the registry API internals](/build-system/developer/registry-internals).