Bundles

docs/bundle.md · wiki index

Bundles

Everything is a bundle. A bundle is one directory for one model on one target:

plugins/<model>/<target>/

It holds the weights, the engine that runs them, the hardware profile the engine was built for, and the facts it declares. It is the unit of work, the unit of replacement, and the unit that an agent is given. The normative text is section 5 of spec.md; this page explains why.

inf3r distributes the host tooling, the protocol, and this contract, not model bundles, weights, or engine images. A real bundle is end-user content: an operator creates it, owns its engine and image recipe, and deploys it. The in-repo fixtures exist to prove the protocol and the gate.

Why the directory is the unit

Generic inference engines serve a long list of models across a wide range of hardware. To do that, they have to compromise on kernel choice, memory layout, KV/SSM state handling, quantisation, batching, and dispatch paths.

inf3r starts from the opposite premise: an agent or author pointed at one (model, target) pair can beat a generic engine when the surrounding system gets out of the way.

That is why inf3r is not an engine integrator. It is the host infrastructure that makes one model on one target a bounded, sovereign unit of work. The host owns the boring, shared things — API routes, auth, scheduling, VRAM ledger, residency, process isolation, shared KV cache tiers, the verification gate, and the benchmark harness. The bundle owns everything about running that pair.

An agent can be pointed at one directory, change or replace what is inside, run two commands (inf3r verify and inf3r bench), and know immediately whether the result is correct and faster. Nothing outside the directory moves: the bundle id does not change, deploy.toml does not change, other models cannot regress, and clients do not change.

There is deliberately no shared per-engine abstraction layer between bundles. Copying a bundle's engine glue into a new (model, target) directory is cheap and intentional: it leaves every pair free to diverge, specialize, or replace a bound runtime piece by piece with custom kernels.

This is why the protocol exists. The engine can be any language because the boundary is the wire. The bundle exists so that the wire has a unit.

The five parts

partwhy it exists
bundle.tomlNames the engine, the entry, the binary, the digested files, and the digest. It is how the directory says what it is.
BUNDLE.mdThe card. Four header lines (model, target, engine, run), so a person and a check can read the directory at a glance.
target.tomlThe hardware profile. Arch, backend, compute capability, driver floor, and the memory of the selected devices. The host refuses a profile it cannot meet, before spawn.
model/The weights. Mounted content: never tracked, never in an image, never in the digest.
engine/The bound runtime, when the engine is not authored. A README when the engine is authored in src/.

Every bundle also has src/ and Cargo.toml: the entry point. The entry point is a package because cargo and the gate need one process to start. The engine behind it is not constrained by that.

A bundle is its own cargo workspace (D19). Its Cargo.toml declares [workspace], keeps literal package fields, and reaches the engine crates by path. Cargo writes the bundle's own Cargo.lock. Adding a bundle changes no root member, no root lock, and no engine build. The shared engine crates deny unsafe_code; a kernel or FFI bundle may allow it in its own manifest with a stated reason, because the unsafe belongs to the engine that bundle exists to carry.

ops/build.sh builds the engine and every bundle into one target directory:

./ops/build.sh release

From inside one bundle, cargo build --release builds only that bundle and its path dependencies.

A directory without the five parts is not a bundle. The shape check and the gate refuse it.

The archetypes

Every bundle speaks the same wire protocol and passes the same gate. Inside the directory, an engine takes one of three shapes:

Authored (engine = "authored"). src/ is the engine. This is the end state when chasing peak performance for one pair: the bundle owns its kernels, its memory layout, its KV/SSM state, its batching, and its sampler. Rust is the default because the tree already gives the GGUF/safetensors readers, the vocabulary, the template, the sampler, and the stop set, and the bundle's own workspace may opt into unsafe for CUDA or kernel FFI (D19).

plugins/toy/x64-cpu/
  src/main.rs          the decoder
  engine/README.md     says the engine is src/
  model/               empty; the test writes the GGUF

Direct library binding (engine = "library"). engine/ holds a premade shared runtime (libllama, libstable-diffusion, libaudio, libonnxruntime, etc.) and src/ is a thin, self-contained FFI shim implementing inf3r_plugin_sdk::Plugin (and CacheCodec when caching KV state) directly over the C API. There is no sidecar server, no loopback port, and no HTTP hop — only one process speaking Wire 2 with true token-level cancel, credit backpressure, and zero-copy descriptors. This is the clean bootstrap baseline for a real model: cheap to bring up, easy to copy per pair, and easy to specialize or replace with custom kernels inside the same directory.

inf3r new --bind library writes the shim, a build.rs, and a placeholder engine/engine.c that exports inf3r_engine_abi, inf3r_engine_open_fd, inf3r_engine_generate, and inf3r_engine_close. The placeholder echoes the prompt, so a new bundle compiles and passes the gate before a real C API is wired. Replacing it with a thin adapter over the hosted library is the whole edit; the Plugin and the wire do not move. The generated [lints.rust] allows unsafe_code with a comment naming src/ffi.rs as the only place it may appear; every other bundle keeps the workspace's deny.

Compatibility binding (engine = "binary" or engine = "http"). engine/ holds an external CLI program or local HTTP service and src/main.rs is one line calling the generic binder:

fn main() -> std::process::ExitCode { inf3r_bind::main() }

This is strictly the cheap escape hatch for quick prototypes or third-party services that cannot be linked as a library. It trades away native cancel and credit backpressure, but every capability in the table has a neutral bridge; inf3r-bind never carries vendor-specific engine flags or routes. A binary runtime that loads once can set worker = "jsonl" and serve jobs from a persistent process, with {"ready":true}, one request line, and events until done or error.

plugins/echo/x64-cpu/
  engine/echo.py       the runtime
  src/main.rs          one line
  model/               empty; no weights

All three shapes are the same citizen to the core. The core cannot tell them apart. The gate judges them identically, and replacing a bound baseline with an authored engine in the same directory is invisible to the rest of the system.

The rules that carry the design

  1. One directory, one pair. Copying a bundle to another host copies the whole answer.
  2. The id is the pair, not the engine. Swapping an engine does not change the id, the bind, or the client. This is what makes replacement cheap.
  3. The engine is free. Any language, any binary, any library. Only the entry point is a package.
  4. The weights are content. model/ is mounted and ignored by git, by the image, and by the digest. A package with weights inside is not a package, it is a download, and no process downloads anything.
  5. The target is authority. A bundle whose profile the machine does not meet is refused before spawn, with the field, the required value, and the measured value.
  6. Nothing in crates/ names a model, a bundle, or an engine. Adding or replacing one changes no engine code.
  7. The gate is the only judge. A bundle that passes is a bundle. An author's preference is not an argument.
  8. A bundle owns its build. It is a standalone workspace with its own lock and lint table. The root workspace owns the engine crates and never names a bundle (D19). Adding a bundle is a directory operation, not a root change.
  9. A bundle owns its image. Its container recipe lives in its own directory, with its own pinned base, engine source or packages, and entry point. There is no shared engine base and no central engine registry. The host image builder stages the directory and runs the recipe; it knows no engine. Two bundles using the same upstream engine still ship two independent copies.

The agent workflow

1. enter one bundle directory
2. replace the engine: edit src/, or replace engine/ and keep the one-line entry
3. cargo build --release             # the bundle's own workspace and lock
4. inf3r verify --weights <file>     # the contract
5. inf3r bench <capability>          # the numbers
6. keep the change if it is faster, otherwise revert

The id, the deploy file, and the client stay the same through all six steps. That is the property the rest of the system was built to protect.

What is forbidden

Where to go next