Operations

docs/ops.md · wiki index

Operations

This page is the host side of inf3r. It describes the files, the install layouts, the first run, the signals, and the container. The code is the authority when a sentence here is not precise.

1. The files

FileOwnerPurpose
inf3r-webinstallthe edge server; it holds the core
inf3rinstallthe operator client
inf3r-web.serviceinstallthe systemd unit
deploy.tomloperatorthe one host, its listeners, and its binds
tokenoperator or entry pointthe bearer token for TCP clients
blobs/serverthe content store
plugins/<model>/<target>/bundle packageone bundle
inf3r-<model>-<target>bundle packagethe bundle binary below bin_dir

The server never writes deploy.toml. It reads the file at start.

inf3r ships no model bundle, weight, engine image, or bundle registry. The table above is the contract; a real bundle is operator content. The in-repo fixtures are clearly labelled and exist for protocol and CI proof.

2. The two install layouts

ops/install.sh has two layouts.

  1. Checkout. The script is ops/install.sh. The binaries are below ${CARGO_TARGET_DIR:-target}/release or below releases/build/<version>/ when the version argument names one. The root install.sh wrapper runs this script.
  2. Release directory. The script sits beside inf3r-web, inf3r, and inf3r-web.service. The release step makes this directory.

The script installs both binaries into /usr/local/bin and the unit into /etc/systemd/system. It creates the inf3r account and /var/lib/inf3r on a real install. It starts no service.

DESTDIR stages the files below another root. A staged install does not create the account. CI uses this to compare the two layouts without root.

DESTDIR=/tmp/stage ./install.sh
DESTDIR=/tmp/stage ./releases/build/0.0.0-ci/install.sh

A release has two parts. The release directory holds inf3r-web, inf3r, inf3r-web.service, and install.sh. The source distribution holds the host tooling, the fixtures, and the docs. Neither part holds a real-model bundle, a weight, an engine library, a built bundle image, or a registry of bundles. An operator creates and builds those separately.

3. The first run

  1. Build or install the two binaries. Build every bundle with ./ops/build.sh release, or install the bundle packages.
  2. Put each bundle below a directory that the deploy file names in bundle_dirs. Put its binary below bin_dir. The binary name is inf3r-<model>-<target>, with each / of the id replaced by -.
  3. Create the token file. It holds 64 lowercase hex characters and one newline. Keep it readable by the inf3r account only.
  4. Create the blob directory. The server uses its free space when blob_bound is absent.
  5. Write deploy.toml. It has one [[node]], at least one web listener, and one [[node.bind]] for each bundle that the host serves.
  6. Start inf3r-web --deploy /etc/inf3r/deploy.toml, or enable the unit after the deploy file is ready.

A container bind needs Docker. The system unit runs as inf3r, which normally cannot reach the interactive user's rootless socket at /run/user/<uid>/docker.sock. Use the compose control (the supported path), run a user unit under the daemon user, or give inf3r access to the socket and set DOCKER_HOST in /etc/inf3r/docker.env; the unit reads that optional file. inf3r doctor reports the Docker check, and the server refuses a container bind with that setup error instead of reporting a misleading missing image.

A deploy file is one host (D21). Two hosts have two files. A second [[node]] is refused. web may name unix, tcp, or both. Both listeners share one core, one stop flag, and one connection cap.

The local Unix socket uses the peer uid. A TCP client uses the bearer token. The server reads the token file; it does not write it. The operator writes the file, or the container entry point writes the first one.

4. Signals

SIGTERM and SIGINT have the same meaning.

  1. The first signal stops the accept loops. Connections that are running finish their own jobs. The server waits up to 30 seconds for them.
  2. The second signal exits at once with status 1. The drain is best effort.
  3. After the drain, the server stops each child and exits with status 0.

The unit sets Restart=on-failure, so a crash restarts the server. A normal drain does not restart it.

5. The container

docker/Containerfile builds the control with the pinned Rust toolchain. The runtime image is Debian slim. It carries inf3r-web, inf3r, and inf3r-probe; it carries no plugin binary and no engine library. The mock bundle's manifests are baked below /opt/inf3r/plugins/mock/x64-cpu. Other bundles are mounted as a manifest-only tree at /opt/inf3r/plugins-extra; the compose deploy names both roots. A model is a mount and never a layer.

docker/entrypoint.sh does three things before it execs the server:

  1. It creates /var/lib/inf3r/blobs.
  2. It writes 64 hex characters and a newline into /var/lib/inf3r/token when that file is absent or empty. A mounted token file keeps its bytes.
  3. It runs inf3r-web --deploy /etc/inf3r/deploy.toml.

The default deploy file binds mock/x64-cpu warm as a sibling container and listens on TCP port 8080. The compose file mounts docker/config read-only at /etc/inf3r, the state volume at /var/lib/inf3r, the host runtime directory at /run/inf3r, the rootless Docker socket, and the host Docker CLI. The engine is not a compose service: its lifetime follows the control's supervisor. The engine receives no Docker socket, no cache directory, no network, and only its private socket directory.

socket_dir is the path in the control; socket_host_dir is the same directory as the host daemon sees it. The control creates one random instance below the mount, and the engine receives only that instance mounted at the same path. The operator must make both names the same backing directory; the control cannot check a host path from inside its own namespace. The compose default uses /run/user/1000/inf3r; change both values when the daemon runs under another uid.

5.1 Bundle images

Every bundle owns its complete image recipe inside its own directory, normally plugins/<model>/<target>/Dockerfile. The host does not choose an engine, a language, a base, a binary, or a pin for it. Two bundles that use the same upstream engine each build and ship their own copy and may diverge at any time.

ops/images.sh build <bundle-id> stages the one bundle and the shared SDK workspace (Cargo.toml, Cargo.lock, crates/) into a temporary context, excludes model/, runs the bundle's Dockerfile in Docker, stamps the generic labels, and tags inf3r/<bundle-id>:sha-<12>. The final image contains that bundle's engine, plugin binary, and manifest tree. The host never compiles an engine; Docker runs every build.

./ops/images.sh build mock/x64-cpu
./ops/images.sh check mock/x64-cpu
./ops/images.sh tag mock/x64-cpu

build also tags the content image inf3r/<bundle-id>:local, the stable alias that the compose deploy names. The final tag, image id, and source digest are recorded in target/images.lock. check recomputes the source, verifies the image id and the bundle id, binary, and source labels, and scans the whole image for a bundle model/ directory, a weight-like name, or a suspiciously large ambiguous weight file. Staging also checks weight magic bytes. A failed Docker run, shell, or find fails the check instead of passing it.

The control verifies the image again before it starts a sibling. A bare name and :latest are refused. With INF3R_IMAGES_LOCK set, the image id and org.inf3r.source.sha256 label must match the lock row; compose mounts target/images.lock at /opt/inf3r/images.lock and sets the variable. Without a lock, the verifier accepts a content tag whose sha- suffix matches the label, or an immutable digest; the local alias is accepted only while the same image still has its content tag.

./ops/images.sh build mock/x64-cpu
cd docker
docker compose up -d --build
docker compose exec -T inf3r cat /var/lib/inf3r/token

The token has a trailing newline. The CLI accepts it in --token-file.

ops/compose-proof.sh is the non-interactive proof: it starts the control and the sibling mock, waits for the healthcheck, checks the catalogue, proves the control has no plugin process, restarts the control and compares the token and blob directory, runs the container gate from the host and from inside the control, and checks that neither container mounts a host engine path. It uses only local images and stages two manifest-only bundles.

The container gate is the same judge as the host gate:

inf3r verify --container mock/x64-cpu --deploy docker/config/gate.toml \
    --image inf3r/mock/x64-cpu:sha-<12> --socket-dir /tmp/ifg-gate --budget 2m

It asks the Docker daemon to start the bundle image as a sibling of the gate process and connects over the private socket. It never starts the plugin on the host. --image requires --container, refuses :latest, and must already be local; the gate passes --pull=never. --socket-dir is the root in the gate process; --socket-host-dir is the same root as the daemon sees it. A host-side gate defaults to the deploy's socket_host_dir for both; a gate inside a control passes --socket-dir and gets a private child root so it cannot collide with the control's warm engine. The gate checks node.conflicts(), the image pin, and the lock before it starts anything. --socket-dir keeps the private socket root short enough for SUN_LEN. The cache checks run in container mode because their trace file lives inside the one private socket directory; cache_abort_on_crash is the only skip, because its fault mode is a host fixture. A cold --describe is a one-shot container over the same image.

5.2 Rootless GPU and socket proof

ops/gpu-proof.sh is the host-side proof for the container tranche. It checks that Docker is rootless, finds the user's Docker socket (or uses DOCKER_HOST), and refuses a missing image rather than pulling one. On a driver package update, reboot before the proof: nvidia-smi can otherwise report a libnvidia-ml version newer than the loaded kernel module.

INF3R_PROOF_IMAGE=inf3r:gpu-proof INF3R_ENGINE_IMAGE=inf3r/mock/x64-cpu:local \
    ./ops/gpu-proof.sh 0 1

For each card, it runs:

  1. An engine-sandbox container with only --device nvidia.com/gpu=<n>, no --privileged, a read-only root, --cap-drop ALL, and no network. It checks that the UUID the container sees is the host UUID of the requested card.
  2. The probe helper with --pid=host and nvidia.com/gpu=all. It reads the host record, free bytes, and the engine container's resident bytes. all is required because CDI renumbers a subset: a container holding only cuda:1 sees it as cuda:0.
  3. A control container holding the rootless Docker socket and a fake mock/cuda bundle whose profile declares CUDA, sm00, and 1024 MiB. The control starts the mock as a sibling container on the requested card and serves /models and /stats over a private Unix socket. The check also asserts the private directory is 0700, the socket is 0666 and owned by the host uid, the engine has a host pid, and the probe returns its RSS.
  4. A CUDA allocation in an engine-shaped sandbox. The probe reads its VRAM, free memory must fall, and after the container stops free memory must return to its baseline within the settle tolerance. This is the VRAM settle path, not a claim that the mock uses a GPU.

The script also prints the UID mapping. On a rootless Docker host the observed mapping is:

container userhost owner
0:0the daemon uid
1000:1000a subordinate uid
65534:65534a subordinate uid

That is why the control and every engine run as 0:0: root maps to the daemon uid that owns the socket, while a non-root container uid maps to a subordinate uid that the control's peer check does not expect.

On a two-device host the proof prints one block per device:

gpu     cuda:0  <uuid>  free <bytes>
control cuda:0  pid <pid>  rss <bytes>  socket s/.../....sock
vram    cuda:0  used <bytes>  free <bytes> -> <bytes>  settle <ms>
gpu     cuda:1  <uuid>  free <bytes>
control cuda:1  pid <pid>  rss <bytes>  socket s/.../....sock
vram    cuda:1  used <bytes>  free <bytes> -> <bytes>  settle <ms>
gpu-proof: ok

The control/probe image and the engine image were local; no image, weight, or runtime was downloaded. INF3R_ENGINE_IMAGE names the bundle image, and INF3R_ALLOC_IMAGE names the local CUDA devel image used for the allocation; INF3R_ALLOC_MB changes the size.

5.3 The security boundary

Docker is the only engine runtime. Podman is out of scope. The boundary has three layers:

layertrustwhat it holds
host kernel, driver, rootless Docker daemontrusteddevices, namespaces, the image store, the engine process tree
control container (inf3r-web)trustedthe rootless Docker socket, the host cache, the ledger, the blob store, the token, the deploy file
engine containeruntrustedthe plugin and the bundle manifests, one private socket instance, the devices its bind names

The control is trusted because it can start any container through the rootless socket. An engine is not: it never receives the Docker socket, the host cache directory, the blob store, or the token. It has no network, a read-only root, a writable /tmp, --cap-drop ALL, and no-new-privileges. Its only writable host mount is its own random instance directory below the runtime root. The engine still runs as container root 0:0; under rootless Docker that maps to the unprivileged daemon uid, so the socket peer uid check keeps its meaning.

The control reads the deploy file and the bundle manifests. It starts one engine container per instance through the Docker CLI. Each engine carries the managed label and the control's runtime-root scope; the startup sweep removes only that scope, never another control's engines. Weights, media, and cache objects cross as read-only descriptors over Wire 2; an engine names a grant as /proc/self/fd/<n> and never sees a host cache path. A bind mount is an asset mount, read-only, and must resolve below an asset_dirs entry; it may not overlap the blob store, a cache tier, or either socket root. The source and target are normalized, symlinks and .. are refused, and the token, /etc, /var/run, /run, the control home, and the Docker socket stay outside the engine. The control, not the engine, owns every cache decision (D22/D23).

5.4 Migrating a host-mode deployment

Host mode is still supported: runtime = "process" is the default and the existing bin_dir rule is unchanged. Container mode is per bind, so one file can serve both while an operator moves a host over.

  1. Build the bundle image with ./ops/images.sh build <bundle-id>. The image carries the plugin and the bundle manifests, never a weight or model/.
  2. Add runtime = "container", image = "<pinned ref>", and, when the image needs a different entrypoint, command = [...]. Leave network unset: the default is none.
  3. If the control itself runs in a container, set socket_dir and socket_host_dir to the same backing directory as seen from the control and from the Docker daemon. Host mode needs neither.
  4. Add probe_image for every container bind. It supplies the sibling's host PID and process memory even on a CPU-only bind; for GPUs it asks for nvidia.com/gpu=all so CDI does not renumber a subset.
  5. Put a read-only asset below an asset_dirs entry, if the image needs one. Each entry must be an absolute existing directory with no symlink; the source and target cannot contain .., the source cannot be the token, the control home, /etc, /var/run, or /run, and neither path may name a Docker socket. Do not mount a weight file, the cache tier, the blob store, or docker.sock into an engine.
  6. Run inf3r verify --container <bundle-id> --deploy <file> and then the same deploy under the control. Keep the host-mode bind until both pass.
  7. A system service runs as inf3r and cannot normally reach the interactive user's rootless socket. Use the compose control (the supported container-native path), a user unit under the Docker user, or set DOCKER_HOST in /etc/inf3r/docker.env and grant inf3r socket access. The server refuses the bind with this setup error, and inf3r doctor reports it.

The control image contains no plugin binary and no engine library, so a container-native host never executes an engine in host user space. A rollback changes runtime back to process (or removes the bind) and keeps the same bundle id, models, and client API.

6. What the operator owns

The operator owns the deploy file, the token, the weight mounts, and the device choice. The server owns the child processes or sibling containers, the ledger, the blob store, and the job table. A bundle owns its engine, its profile, its model facts, and its goldens.

No process downloads, installs, or loads a weight file or a model runtime without written authorisation. The authorisation names the file. A bundle that needs one waits for that sentence.

7. The KV cache

The cache is a host resource, not a bind property. It has one [node.cache] table and one or more [[node.cache.tier]] tables. A tier is a directory, a bound, and a headroom; its filesystem must be unique in the file.

[node.cache]
enabled      = true
persist      = "reboot"   # "reboot" or "session"
pin_bound    = "20GB"
flush_budget = "5s"
default_ttl  = "7d"

[[node.cache.class]]
name = "standard"
ttl  = "7d"

[[node.cache.tier]]
name     = "nvme"
dir      = "/var/lib/inf3r/cache"
bound    = "100GB"
headroom = "20GB"

An absent or zero pin_bound is a zero pin budget: every pin request is refused. A pinned entry is protected from TTL expiry and eviction until it is unpinned; it still counts against both the tier bound and pin_bound. An unbounded tier must declare positive headroom. The per-filesystem claim is the abstract socket inf3r-cache-fs-<major>:<minor> plus the device lock $INF3R_CACHE_AUTHORITY_DIR/inf3r-cache-dev-<major>-<minor>.lock (default /run/user/<uid>, fallback the temp directory). A container that shares a cache filesystem must mount that runtime directory or set the same INF3R_CACHE_AUTHORITY_DIR; otherwise the tier .lock still protects the exact directory, not the whole filesystem.

A bind names cache_class = "standard" and cache_mode = "auto", "read_only", or "off". A read-only bind still restores; the core refuses every write grant for it. A bridge engine can pay one prefix prefill before that refusal, because the binder cannot see the write policy until the grant; it never writes an entry. The class is host policy. A bundle cannot declare a quota or a TTL.

The cache directory must be 0700, disjoint from blob_dir, and on its own filesystem. Start one manager per host. A second manager is refused by the per-device claim and the tier lock.

inf3r cache ls lists metadata. inf3r cache stats reads the cache object of /stats. inf3r cache pin <id> and unpin <id> change the pin. inf3r cache evict <all|model|id> removes entries. inf3r cache gc compacts the WAL.

Tiers are ordered hot to cold. A RAM tier is detected from TMPFS_MAGIC; it demotes to the next disk tier before eviction. A full hot tier demotes a cold victim instead of recomputing it. A second hit promotes a cold entry back to the hot tier on the maintenance clock. /stats reports each tier's kind, read_mb_s, write_mb_s, demotions_in, and demotions_out.

inf3r verify runs five cache checks on a cache-capable binding: cache_fingerprint, cache_roundtrip, cache_cold_erase, cache_corrupt_fallback, and cache_abort_on_crash. The checks use a real temporary store; a binding without a cache codec skips them.

inf3r doctor checks the tier directory, its 0700 mode, the blob overlap, and the pinned bound.