inf3r — the brief
docs/index.md · wiki index
inf3r — the brief
This page is the original brief. It is not the specification. Where the two
disagree, spec.md is right. Section 5 of spec.md is the normative text for
the bundle tree.
Everything is a bundle. A bundle is one directory for one model on one target: the weights, the engine that runs them, the hardware profile, and the facts it declares. It is the unit of work, the unit of replacement, and the unit an agent is given. The engine inside can be authored in Rust for speed, or bound from a runtime that already exists, in any language. The protocol exists so that the engine can be anything. The bundle exists so that the protocol has a unit.
inf3r ships the host, the protocol, the bundle contract, the SDK, the host
tooling, and test fixtures. It does not ship model bundles, weights, engine
images, or a registry of them. A real bundle is end-user content: an operator
creates it under plugins/<model>/<target>/, owns its engine, pin, and image
recipe, and deploys it. The fixtures exist to prove the protocol and the gate.
What it is. An inference engine addressed by model and target. You point it at one model and one inference target; it runs that pair, alongside as many others as the machine can hold. Every modality is supported — text, embeddings, speech in and out, music, images, video, typed decisions — as capabilities a model declares, not as separate entry points.
What it is for. Hosting any engine per (model, target) pair so that a
strong agent or author pointed at one bundle directory can beat generic
multi-model engines. inf3r is not an engine integrator — it provides the
shared host infrastructure (protocol, routing, VRAM ledger, residency, shared
KV cache, verification gate, and benchmark loop). Inside one bundle directory,
binding a premade runtime (library FFI, or binary/http via inf3r-bind)
is the cheap bootstrap baseline; writing or specializing custom kernels (Rust,
CUDA, or any language) in that same directory is the payoff. A reference is a
reference, not a host dependency: wrapping it to set a baseline and rewriting
it to beat that baseline are the same move. No shared engine layer in
crates/, no tensor abstraction, no kernel library, no mandated runtime, no
mandated language.
Components
| owns | binary | |
|---|---|---|
| core | discovery, catalog, ledger, admission, residency, switching, supervision, the peer protocol | inf3r-core |
| web | HTTP, auth, wire encoding, SSE, OpenAI and native surfaces | inf3r-web |
| bundle | one model on one target: the engine, the weights, the profile, the facts | inf3r-<model>-<target> |
| cli | operator commands: ps, queue, new, reload, doctor | inf3r |
Core and web ship in one control container and are not supported running apart. A bundle engine runs in its own sibling container (D28), never in the control. The boundary exists to keep HTTP, auth and JSON out of the engine. The web is a client of the core over the same framed protocol plugins use.
crates/format/* holds the data vocabulary for a medium — PCM, tokens, frames,
clips — and has no plugin trait. A capability is wire vocabulary, one page
under .f0rge/wiki/docs/capabilities/, and one entry in the catalogue. It is
not a Rust trait, because the engine behind a bundle may be any language.
Core
| discovery | scan bundle directories, read --describe |
| routing | model name + target → plugin; capabilities checked |
| admission | per-device priority queues, deadlines, bounded, refusal with a reason |
| residency | pin / warm / idle_unload, LRU eviction that waits for idle |
| switching | drain → unload → reserve → spawn → load → ready, under a device lock |
| reservation | byte ledger per device, atomic across devices, all-or-nothing |
| lifecycle | spawn, handshake, health, restart with backoff, circuit breaker, reap |
| protocol | one framing, two roles: plugins serve, fronts and the CLI call |
| observability | one request id across the boundary; every decision logged |
Web
Listen. A Unix socket and a TCP listener. Either can run alone, and both can run at once. Unix socket HTTP serves local use with a peer-uid check; TCP on the tailnet uses a bearer token. One token, from config, compared in constant time. No accounts, no tenancy, no sessions.
Endpoints. The canonical capability routes are the twelve paths in section
7 of spec.md; POST <canonical route> is one of those paths.
| endpoint | capability required | body | response |
|---|---|---|---|
POST <canonical route> | that capability | native job | SSE or one object |
POST /openai/v1/chat/completions | chat | OpenAI chat | SSE chunks, [DONE] |
POST /openai/v1/embeddings | embed | OpenAI embeddings | JSON |
POST /openai/v1/audio/speech | tts | OpenAI speech | chunked audio |
POST /openai/v1/audio/transcriptions | stt | multipart file and fields | JSON, text, or verbose JSON |
POST /openai/v1/images/generations | image-gen | OpenAI images | JSON, base64 |
POST /openai/v1/images/edits | image-edit | multipart image, mask, and prompt | JSON, base64 |
GET /openai/v1/models | — | — | served names as OpenAI models |
GET /models | — | — | catalogue rows: served name, plugin, capability names/vocab/degraded/cancel |
GET /capabilities | — | — | the twelve static rows: name, route, parts, channels, stream |
GET /jobs | — | — | job rows and the running count |
GET /stats | — | — | peers, engines, devices, blobs, cache |
GET /healthz | — | — | liveness, no auth |
Every route except /healthz needs auth when a token is configured. A Unix
socket peer proves its uid; a TCP peer sends the bearer token.
Lifecycle of a request. Parse → auth → validate → resolve model name to
plugin → check capability → submit to core → translate frames to the endpoint's
wire shape → close. Every request carries x-request-id, echoed on the response
and logged by the core and the plugin.
Refusals. The core's reasons map to HTTP, never to a hang:
| reason | status |
|---|---|
unknown_model | 404 |
capability_missing | 400 |
queue_full | 429 + Retry-After |
no_room | 503 + Retry-After |
load_failed | 503 |
plugin_crashed | 502 |
mismatch | 500, config error |
timeout | 504 |
Streaming. SSE framing is exact: data: <json>\n\n per chunk,
data: [DONE]\n\n once at the end, : ping keepalives during prefill, an error
chunk if the failure happens after headers. Non-SSE endpoints use chunked
binary. A client disconnect is propagated to the core as a cancel frame, and the
plugin stops within one step.
Limits. Body size, a read timeout, a total deadline for the request head, a write timeout, and a cap on concurrent connections. Above the cap is 503. Multipart is parsed only for transcriptions. No CORS, no compression, no caching.
A bundle provides
- One model, one target, one entry point, one process.
- Five parts:
bundle.toml,BUNDLE.md,target.toml,model/,engine/. - One engine, authored or bound. The engine can be any language. The entry point is a package so that cargo and the gate have one process to start.
--describe: id, model, target, protocol version, capabilities, needs, weights, limits.- Goldens, enforced by CI. A bench is expected; the core does not track or compare it.
Names and configs
| file | question |
|---|---|
plugins/<model>/<target>/bundle.toml | what is this bundle, what engine does it bind, and what is the digest? |
plugins/<model>/<target>/target.toml | what hardware was this bundle built for? |
plugins/<model>/<target>/models/*.toml | what can this bundle serve? name, weights, quant, sampling, template, stop sets, aliases |
deploy.toml | how does this host run it? web listener and token, bundle bindings, devices, budget, sharing, residency |
Cargo.toml | how is the entry point built? |
Names are the user's. The bundle id is the directory path the user chooses, and
uniqueness is that path; the core never derives a name. The five parts are the
bundle contract, not a convention: CI refuses a directory that does not have
them. Quantisation is part of the name only if the user puts it there. Sampling
is opaque to the core and to the web. The weights live in model/, are mounted
by the operator, and never enter git or an image.
Device sharing is config, not policy: per host, per device, exclusive or time-sliced.
Adding a bundle
1. pick a model and a target
2. inf3r new <model> <target> <capability> or copy a bundle that passes
3. engine in src/ (authored) or engine/ (bound) + one line of binder
4. weights in model/ mounted, never committed
5. target.toml, models/*.toml, bundle.toml, BUNDLE.md
6. inf3r verify --weights <file> then bench
7. bind the bundle id in deploy.toml devices, budget, sharing, residency
8. core discovers it, routes to it, queues for it, swaps it in and out
No change to crates/. No core rebuild. To make the pair faster, replace the
engine inside one directory, run the gate and the bench, and stop when the
numbers are better. The bundle id and the client stay the same.
Rules
- No model names in
crates/. No bundle name and no engine name either. - No bundle depends on another bundle. Sibling targets of one model do not depend on each other.
- Dependencies point one way:
edge → run → state.format/*andfiles/*are leaves; plugins may depend on all of them. unsafeonly intarget/*and kernel crates, each with a stated reason.- The scheduler never batches. The engine never admits.
- The core never interprets model internals, sampling settings, or names.
- No bundle is privileged: a hand-written CUDA engine and a wrapped upstream are the same citizen.
- The core contains no HTTP, no auth, no wire types.
- The web contains no scheduling, no residency, no device knowledge.
Requirements
- R1 A plugin runs standalone:
--describeworks with no core present. - R2 The core starts with zero plugins and reports an empty catalog.
- R3 Every request is admitted, queued with a deadline, or refused with a reason. Queues are bounded.
- R4 A plugin crash affects only that plugin; the core stays up and reports it.
- R5 Reloading one plugin restarts neither the core nor any other plugin.
- R6 A plugin whose declared needs do not match the probed host is refused before spawn, with the mismatch named.
- R7 One request id identifies a request in core logs and plugin logs.
- R8 In-flight streams are never cut by eviction; eviction waits for idle.
- R9 Every plugin ships goldens, and CI runs them.
- R10 CI runs fmt, clippy
-D warnings, tests, and a build per entry indeploy.toml. - R11 The core links no plugin, no model runtime, no HTTP server:
cargo check -p inf3r-corepulls no CUDA and no TLS. - R12 A plugin built against protocol version N runs on any core that supports N, regardless of how it was built.
- R13 Adding a model+target pair touches no file in
crates/. - R14 Unload returns the device's free bytes to their pre-load value.
- R15 A cancelled or disconnected request stops consuming compute within one step, at both hops.
- R16 A failed load releases its full reservation.
- R17
inf3r new <model> <target>produces a plugin that builds, describes itself, and passes an empty golden set with no edits. - R18 SSE output matches the recorded conformance fixtures byte for byte.
- R19 Every route except
/healthzrequires auth when a token is configured. - R20 Every endpoint checks the model's declared capability before submitting.
Non-goals
Training, fine-tuning, quantising, downloading weights. A UI. Cross-host distributed inference in v1. LoRA hot-swap. Windows. A shared tensor or kernel API — deliberately absent. Core and web as separately deployable services. Accounts, quotas, CORS. Benchmark history and cross-plugin comparison.
Status
The engine runs: twelve capability routes through a real binary, a conformance
plugin, a Python plugin with no SDK, a fault injector, a binding gate, and a
release script. The current state is section 25 of spec.md; what is left is
plan.md.
This page is the original brief. It is not the specification.
| Document | Purpose |
|---|---|
bundle.md | The bundle pattern: why the pair is the unit, the anatomy, the archetypes, the rules. |
spec.md | The system specification. The tree, the API, the rules, the freeze contract. |
protocol.md | The peer protocol, wire 2. Normative. |
plan.md | The build order, the milestones, and the definition of done. |
core.md | The core as state tables: peer, residency, ledger, job, schedule, pump. |
ops.md | The install layouts, the first run, the signals, and the container. |
binding.md | How to bind an engine, write one, and pass the gate. |
capabilities/ | One page per capability: parts, parameters, channels, usage. |
spec/schema.md | The f0rge file format. It is not an inf3r document. |
spec/protocol.cddl | The machine grammar of the peer protocol. |
This file and spec.md disagree. Use spec.md. Requirements R1 to R40 and the
decisions D1 to D28 are in spec.md.