inf3r — system specification
docs/spec.md · wiki index
inf3r — system specification
Status: settled. Section 26 lists the decisions. How to read this: sections 1–7 give the idea. Sections 8–17 give the parts. Sections 18–24 give the rules, the build, and the work. Section 25 gives the current state of the repository. How to edit this: change the text in place. Keep the section numbers. If you add a decision, give it the next D number in section 26. If you remove a rule, say why in the same paragraph. Language: ASD-STE100 Simplified Technical English. Short sentences. One word has one meaning. Section 3 gives the definitions.
1. About this document
This document is the specification of inf3r. It is the only normative text. If the code and this document disagree, the code is wrong.
The document describes:
- the idea and the vocabulary
- the repository tree and the bundle tree
- the shape of a request
- the core, the web, and the plugin protocol
- the HTTP API and the event stream
- the manifest, the deploy file, and the crates
- the requirements, the rules, and the build
- the current state and the open decisions
2. What inf3r is
inf3r is an inference engine. A client gives a model name and a capability. The engine finds the plugin for that pair and runs it.
inf3r runs as many model and target pairs as the machine can hold. A target is one hardware configuration. The pairs share devices through the ledger.
Every modality is supported. The modalities are text, embeddings, speech in and out, music, images, video, and typed decisions. A modality is data. It is not a separate entry point. A model declares what it can do. The engine routes on that declaration.
inf3r is not a model runner and not an integrator of other engines. It is a host for bundles.
A bundle is one directory. It holds one model, one target, and one engine. Generic engines compromise across architectures, quantisations, and hardware. A bundle makes one pair a bounded, self-contained unit of work so an author or an agent can write a faster engine built specifically for that model on that target. One copy of the directory is a complete answer for one pair, and one replacement of the engine changes nothing outside the directory.
A bundle author picks a model and a target. The author can write a dedicated
engine for that pair, or bind a premade runtime as a cheap baseline inside the
same directory — directly through a library FFI shim, or through the
compatibility binder for an external binary or local HTTP runtime. The author
can use any reference: llama.cpp, candle, ort, a vendored research repository,
or hand-written CUDA. A reference is a reference, not a host dependency, and
there is no shared per-engine layer in crates/. Wrapping a reference to set a
baseline and replacing it with custom kernels are the same move inside one
directory.
The host gives the bundle the shared infrastructure: a small protocol, a manifest format, a residency and ledger system, a shared host KV cache, a verification gate, and a benchmark harness. The host does not give the bundle a tensor abstraction, a kernel library, a runtime, or a required language.
inf3r distributes the host tooling, the protocol, the bundle contract, and the
in-repo fixtures. It does not distribute model bundles, weights, engine images,
or a registry of them. An end user creates a bundle under
plugins/<model>/<target>/ and owns its engine, pin, image recipe, and
deployment.
The engine is host independent. deploy.toml binds the plugins to one host.
The same binaries run on a different host with a different deploy.toml. A
rebuild is not necessary.
3. Words used in this document
| Word | Meaning |
|---|---|
| core | The process inf3r-core. The core finds plugins, routes jobs, and controls devices. |
| web | The process inf3r-web. The web has HTTP, auth, SSE, and the adapters. |
| cli | The process inf3r. The cli gives operator commands. |
| bundle | One directory for one model on one target. It holds the engine, the manifests, and the model directory. The unit of work. |
| engine | The code inside a bundle that runs inference. An engine is authored or bound. The engine can be any language. |
| plugin | The process that a bundle becomes when the core starts it. Also the role on the wire. |
| target | One hardware configuration. A target names the backend, the devices, and the memory. |
| model | One set of weights and its behaviour. A model serves one name or more names. |
| pair | One model on one target. One bundle implements one pair. |
| job | One task from a client. A job names one model and one capability. |
| part | One input item of a job. A part is text, image, audio, video, tokens, or JSON. |
| capability | The name of a task type. Examples are chat, embed, and stt. |
| vocabulary | The parts, channels, and parameters that one capability permits. |
| channel | The name of one output stream of a job. |
| event | One status message about a job. |
| blob | One file in the blob store. A blob has a content address. |
| blob store | The directory that holds blobs. |
| manifest | The files that describe a bundle, its engine, its target, and its models. |
| adapter | Web code that changes one API format into a job. |
| ledger | The record of reserved bytes for each device. |
| reserve | To record bytes in the ledger before a model load. |
| unload | To stop a model and free the device memory. |
| admit | To accept a job into a queue. |
| residency | The rule that keeps a model on a device or removes it. |
| publish | To move a completed artifact file into the blob store. |
| golden | A recorded input and output pair. CI compares the new output with the recorded output. |
Abbreviations:
- HTTP: Hypertext Transfer Protocol.
- JSON: JavaScript Object Notation.
- SSE: Server-Sent Events.
- CBOR: Concise Binary Object Representation.
- CDDL: Concise Data Definition Language.
- SHA-256: Secure Hash Algorithm, 256 bit.
- LRU: Least Recently Used.
- FFI: Foreign Function Interface.
- CI: Continuous Integration.
- API: Application Programming Interface.
4. The tree
This is the repository tree. A * marks a directory that is empty today. A
planned mark names a file or crate that the spec needs and the tree does not
have.
inf3r/
├── Cargo.toml workspace. members = crates/*/*; a bundle is its own
│ workspace (D19).
├── ops/build.sh build the engine and every bundle into one target.
├── Cargo.lock exact dependency pins.
├── rust-toolchain.toml Rust 1.99.1, profile minimal, rustfmt and clippy.
├── deploy.toml the bindings for each host. Not the code.
├── .gitignore /target, dist, build, venv, and f0rge runtime output.
├── .stignore sync exclusions. Same set as .gitignore.
│
├── crates/ all engine code. No model names. No model code.
│ ├── edge/ the boundary with the outside world.
│ │ ├── api/ wire JSON and SSE. Native types plus the adapters.
│ │ ├── bind/ the declarative binder for a bound engine.
│ │ ├── cli/ operator commands. binary `inf3r`.
│ │ ├── proto/ the six nouns, framing, codec, descriptors, credit.
│ │ ├── sdk/ the plugin traits and serve().
│ │ └── server/ HTTP, auth, and the request path. binary `inf3r-web`.
│ │
│ ├── state/ what the machine is and what it has room for.
│ │ ├── catalog/ model file to checkpoint and capability list.
│ │ ├── host/ probe of devices, memory, architecture, and driver.
│ │ ├── ledger/ byte reservations for each device.
│ │ ├── blobs/ content store and LRU.
│ │ └── bundle/ the bundle anatomy, the manifest, and the digest.
│ │
│ ├── run/ what is running and why.
│ │ ├── core/ discovery, routing, admission, residency. (planned)
│ │ ├── sched/ queues, deadlines, eviction, switching.
│ │ └── supervisor/ start, drain, swap, restart, stop.
│ │
│ ├── format/ four data vocabularies. No inference types.
│ │ ├── text/ token, tokenizer, template, stop set, sampling.
│ │ ├── audio/ pcm, rate, channels, transcript, mel, vad, wav.
│ │ ├── image/ frame, pixel format, colour, tile, png.
│ │ └── video/ timebase, clip, container.
│ │
│ └── files/ two weight readers and one hash. Leaves.
│ ├── gguf/ GGUF: metadata, tensor index, bounded window.
│ ├── safetensors/ safetensors reader.
│ └── sha256/ the one streaming SHA-256.
│
├── plugins/ operator bundles and in-repo fixtures. Section 5.
├── goldens/ * engine goldens and the capability-shape goldens.
├── docker/ * image build. Core and web in one image.
│
├── spec/
│ ├── schema.md the f0rge file format. Copied from the template.
│ ├── protocol.cddl the machine grammar of the peer protocol.
│ └── fixtures/ the f0rge frontmatter goldens.
│
└── .f0rge/ the forge. All work and all docs.
├── ci/
│ ├── ci.env runner: local
│ ├── README.md the step table
│ └── steps/ 00_tools.sh, 01_fmt.sh, ... 11_compose.sh
├── wiki/
│ ├── docs/ this file, the index, the protocol, ops, and proposals.
│ ├── research/ * notes.
│ └── experiments/ * measurements.
├── issues/ * one directory for each issue.
├── prs/ * one directory for each pr.
├── tasks/ * one file for each task.
├── merges/ * one record for each CI-gated merge.
├── releases/ * one file for each release. build/ and out/.
├── labels.md []
└── milestones.md []
Two rules about the tree:
- The core does not contain HTTP code, auth code, or model vocabulary.
- The web does not contain scheduling code, residency code, or device code.
5. The bundle tree
A bundle is a directory. One bundle is one model on one target. The path is the bundle id. The core does not make the name. The layout below is the bundle contract. It is not a convention. CI refuses a directory that does not have it. Requirement R31.
plugins/<model>/<target>/
├── bundle.toml the bundle manifest. Id, model, target, engine kind,
│ files, and digest.
├── BUNDLE.md the card. Four header lines and the command that
│ runs the bundle.
├── target.toml the hardware profile that the bundle was built for.
├── models/
│ ├── <served-name>.toml one file for each name that the bundle serves.
│ └── <alias>.toml an alias is a second name for one model.
├── model/ the weights. Mounted by the operator. Ignored by git.
├── engine/ the runtime, when the bundle binds one. A README when
│ the bundle authors its engine.
├── goldens/
│ ├── chat.basic.json one recorded request and the output it owes.
│ └── <case>.json one file for each recorded case.
├── src/ the entry point. The authored engine, an FFI
│ shim, or one line that calls the binder.
├── Cargo.toml the package. It is its own workspace (D19).
├── Cargo.lock the bundle's own dependency pin.
├── Dockerfile optional. The bundle's own container image recipe.
└── README.md optional. The longer page for this bundle.
Five parts make a directory a bundle: bundle.toml, BUNDLE.md,
target.toml, model/, and engine/. A directory without them is not a
bundle. The shape check and inf3r bundle verify both refuse it. Requirement R31.
The repository carries the contract, the host tooling, and the fixtures. A real model bundle is end-user content: the operator chooses the model, target, engine, pin, and image recipe. The fixture names in this section are labelled as fixtures and do not describe a release catalogue.
The manifest is one key on one line. The tree has one parser and no TOML dependency.
# bundle.toml — an authored bundle.
id = "mock/x64-cpu"
model = "mock"
target = "cpu"
summary = "the conformance bundle"
engine = "authored"
binary = "inf3r-mock-x64-cpu"
files = "target.toml,models/mock.toml,BUNDLE.md"
sha256 = "..."
# bundle.toml — an illustrative bound bundle. The names are the operator's.
id = "example/gpu"
model = "example"
target = "gpu"
summary = "a bound engine on two cards"
engine = "http"
entry = "engine/runtime"
args = ["--host", "127.0.0.1", "--port", "{port}", "--model", "{model}"]
# worker = "jsonl" # only for engine = "binary": one resident process
binary = "inf3r-example-gpu"
files = "target.toml,models/example.toml,BUNDLE.md"
sha256 = "..."
engine is authored, binary, http, or library. authored has no
entry: the entry point is the engine. The other kinds name entry, and the
binder starts it or connects to it. worker = "jsonl" is optional and only
valid with engine = "binary": the entry stays resident, reads one JSON request
per line, and writes event lines until done or error. Without it a binary
entry is one job per process. args is optional and uses {model} for
the first granted weight, {weights} for every granted weight in grant order,
{weightN} for one of them, and {port}. args is a space-separated string or
an inline array of quoted strings. A quoted word keeps its spaces. In the string
form, a backslash escapes a quote. binary is the package binary at the bundle
root. files is the comma-separated list that the digest covers, below the
bundle root.
A path in binary, entry, or files is relative and normal. It has no
absolute path. A .. removes one normal component; it is refused when it would
leave the bundle root. A leading ./ is removed. A path under model/ is
refused, including a symlink that resolves into model/. The digest
never covers model/ and never covers bundle.toml itself.
The digest is SHA-256 over the binary and each file in sorted path order. A piece contributes its relative path, its byte length, and its bytes, each with a length prefix as 8 little-endian bytes. The hash reads a file in bounded chunks, so a large binary is never held in memory.
The path below plugins/ is the bundle id. The model and target names are the
operator's; the core never derives them. Two hosts may use different target
names for the same model.
5.1 Three archetypes
- Authored.
src/is the engine. The bundle owns its kernels, its KV, its batching, and its layout. This is the fast path for one pair. Rust is the default because the tree gives the GGUF reader, the vocabulary, the template, the sampler, and the stop set. The bundle can use another language. The gate starts the package and does not care what is inside it. - Direct library.
engine/holds a local shared runtime andsrc/is the bundle's own FFI shim implementingPlugin(andCacheCodecwhen it persists state). There is no sidecar, no loopback port, and no HTTP hop. This is the primary path for hostinglibllama,libstable-diffusion,libaudio, orlibonnxruntime. Section 15.1, method 4. - Compatibility.
engine/holds an external binary or HTTP service andsrc/main.rscalls the engine-neutral binder. The binder maps the capability to the runtime and declares the facts the runtime can keep. It is the cheap adapter for a third-party service, not the primary host path. Section 15.1, method 2.
The engine inside a bundle can be any language. The entry point is a package because cargo and the gate need one process to start. The language of the engine is not the language of the entry point. Decision D15.
5.2 Rules for bundles
- No bundle depends on another bundle. Two targets of one model do not depend on each other.
- The bundle id is the pair. It does not change when the engine changes. A new
engine is a new
src/orengine/in the same directory. The deploy file and the client do not change. Decision D14. - A bundle ships goldens. CI runs them. Requirement R9.
- A bundle is not privileged. A bound runtime and a hand-written engine are the same citizen.
- The weights are content.
model/is never tracked, never in an image, and never in the digest. Requirement R32. Decision D16. - No modality directory. A bundle serves capabilities. The capability names
already say which. The bundle id is its path below
plugins/. crates/does not name a model, a bundle, or an engine. Requirement R13.- The bundle is the unit of replacement. To try a faster engine, replace the contents of one directory and run the gate. Nothing else changes.
6. The shape of a request
The engine has six nouns. These nouns are the complete shared shape. A new capability adds vocabulary. A new capability does not add a noun.
Job = { id, model, capability, input: [Part], output: OutputSpec,
params, stream, deadline_ms, priority, request_id }
Part = { kind: text|image|audio|video|tokens|json,
mime, role, ref: inline(bytes) | blob(sha256) }
Channel = text | tokens | pcm | image | clip | embedding | decision | progress
Event = { seq, job, request_id, at,
body: started|delta|usage|progress|done|error }
Outcome = completed | failed | cancelled | expired
Refusal = { code, message, retryable, retry_after_s }
Five rules for the shape:
- A medium is data. A task is a capability. An image is a part. An image is
not an endpoint. Vision is not a capability. An image part goes into
chat. paramsis opaque to the core. The plugin readsparams. The manifest names the parameter schema.- The same
Eventobject goes through all three hops. The hops are plugin to core, core to web, and web to client. See requirement R7 and R18. - The socket carries control data only. A blob reference becomes a file descriptor at the peer hop. The core makes that substitution; a plugin never sees a blob.
- The core resolves names and bytes. The plugin defines the model behaviour.
The Part shape is almost the same as the OpenAI content part. Thus each
adapter is small.
7. Capabilities
This is the capability table. It is also the table that GET /capabilities
returns. The table is static: it does not depend on which models are loaded.
| Capability | Route | Input parts | Output channels | Stream |
|---|---|---|---|---|
chat | POST /chat | text, image, audio, json | text, tokens, decision, progress | yes |
embed | POST /embed | text | embedding | no |
rerank | POST /rerank | text, json | embedding | no |
tts | POST /tts | text | pcm, progress | yes |
stt | POST /stt | audio, text | text, tokens, progress | yes |
music | POST /music | text, audio | pcm, progress | yes |
image-gen | POST /image/generate | text, image | image, progress | yes |
image-edit | POST /image/edit | image, text | image, progress | yes |
t2v-gen | POST /video/text-to-video | text, image | clip, progress | yes |
i2v-gen | POST /video/image-to-video | image, text | clip, progress | yes |
decide | POST /decide | text, json, image | decision | no |
extract | POST /extract | text, json | decision | no |
The capability key is the stable task name. The route is the canonical HTTP
spelling of that task. They are related but not identical strings: the image
and video tasks group below /image and /video. The route is not a second
name and not a second code path. Section 10 gives the route list. Section 20.1
gives the freeze contract.
Notes:
- One model can declare more than one capability. Each capability has its own limits.
progressis the only channel that all capabilities can use. A long video job needs this channel.rerankis separate fromembed. The shape is different. A query and a document array go in. Scores go out.- A capability that is not in the manifest cannot be reached by any route. Requirement R24.
8. The core
The core is the process inf3r-core. It owns these functions:
| Function | Behaviour |
|---|---|
| discovery | Scan the bundle directories. Start each plugin with --describe. Read the catalogue. Check the schema. Check the uniqueness of all served names. |
| routing | Map a model name and a capability to one plugin. Check that the plugin declares the capability. |
| admission | Use one queue for each device. The queues have priorities and deadlines. The queues are bounded. A full queue gives a refusal with a reason. |
| ledger | Record the reserved bytes for each device. One reservation covers all devices of a target. The reservation is all or nothing. |
| residency | Keep a model on a device, or remove it. The modes are pin, warm, and idle_unload. The eviction is LRU. The eviction waits for the model to be idle. |
| switching | Drain, unload, reserve, start, load, ready. The sequence runs under a device lock. |
| supervision | Start, handshake, health check, restart with a delay, circuit breaker, stop, and removal. |
| protocol | One framing with two roles. A plugin serves. A front or the cli calls. |
| observability | One request id across all hops. The core logs every decision. |
The core uses one path for all capabilities:
model name -> catalog entry -> capability declared -> host binding
-> device selection -> ledger reserve -> model load
-> submit -> accepted or refuse -> events -> publish -> done
The core must not hang. Every request is admitted, queued with a deadline, or refused with a reason. Requirement R3.
9. The web
The web is the process inf3r-web. The core and the web ship in one control
container. An engine is a sibling container when the bind names
runtime = "container".
They are not supported running apart. The boundary exists to keep HTTP, auth,
and JSON out of the engine.
The web uses the same framed protocol as a plugin. The web is a client of the core.
9.1 Listeners
- A Unix domain socket is the local listener. It is optional. The web checks the peer uid against the effective uid of its own process.
- A TCP listener is the remote listener. It is optional. Remote use goes through TCP on the tailnet.
- At least one of the two listeners is configured. Both can run at once.
- One bearer token. The token comes from the deploy file. The comparison is constant time.
- No accounts. No tenancy. No sessions.
- Every route except
/healthzneeds auth. A Unix peer authenticates by uid; a TCP peer authenticates by token. Requirement R19.
9.2 Limits
The web has these limits:
- body size
- idle read timeout, for the first byte and between later bytes
- total deadline for the request head
- write timeout
- concurrent connections
A client above the concurrent limit gets 503 and a closed connection. A read
that times out gets 408; a body that is too large gets 413. The cap covers
the whole connection, including a streamed reply, so a slow reader cannot make
the accept loop grow without bound. Both listeners share the cap.
A request that says Expect: 100-continue gets HTTP/1.1 100 Continue before
its body when the head is acceptable. A client such as curl waits for that line
before it sends a body over 1 KiB.
The web parses multipart only for the OpenAI compatibility routes. There is no CORS, no compression, and no cache.
10. The HTTP API
The API has no version number. A version number exists so that one server can serve two shapes at once. inf3r does not need that. The engine, the web, the cli, and the clients move together. A published name is permanent. Section 20.1 gives the rules.
The API is RPC, not REST. Each capability route is a POST that makes a job. A
resource route gets, lists, or removes a resource.
The engine has seventeen resource routes:
GET /jobs List jobs. This route is for the operator.
GET /jobs/{id} Get the status of one job.
POST /jobs Submit one job as JSON. The reply is 202 and a status.
DELETE /jobs/{id} Cancel one job. This operation is idempotent.
POST /blobs Upload bytes. The reply gives the blob id and size.
GET /blobs/{id} Download one artifact.
GET /models List the routing catalogue.
GET /capabilities Give the static table in section 7 as JSON.
GET /stats Give peer, engine, device, blob, and cache counters.
POST /reload Reload one bundle or every bundle.
POST /reload/{bundle} Reload the bundle that the path names.
GET /cache List cache metadata. Never cache bytes.
POST /cache/pin Pin one entry by its 64-hex address.
POST /cache/unpin Unpin one entry.
DELETE /cache Evict all, one model, or one entry.
POST /cache/gc Compact the cache WAL.
GET /healthz Give the liveness status. Needs no auth.
The engine has twelve capability routes. Each one is the same handler as
POST /jobs, with capability filled from the path:
POST /chat POST /music
POST /embed POST /image/generate
POST /rerank POST /image/edit
POST /tts POST /video/text-to-video
POST /stt POST /video/image-to-video
POST /decide POST /extract
A capability route is a spelling of POST /jobs. It is not a second
implementation. The request body can omit capability. The path maps to the
stable capability key in section 7; the old flat image and video spellings are
not routes.
A target with a query string is not a route, and neither is a trailing slash. The route table has no query and no near miss.
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.
The OpenAI compatibility routes are under /openai/v1/. The v1 in that prefix
is the OpenAI version, not an inf3r version. Section 10.3 gives the routes.
Every request has an x-request-id. The web echoes it on the response. The core
and the plugin log it.
10.1 Discovery and status
GET /models lists every catalogue entry that the host has discovered, warm or
cold. It is the routing catalogue, not a weight inventory:
{"models": [
{"serve": "<served-name>", "plugin": "<model>/<target>",
"capabilities": [
{"name": "chat", "vocab": "chat.v1", "degraded": false, "cancel": "token"}
]}
]}
It does not report loaded or installed state, weight files, limits, or
parameter schemas. An alias is another serve row, not a separate field. Loaded
state is inferred from stats.engines, never from models.
GET /stats reports the runtime:
{
"peers": [{"plugin": "<id>", "model": "<served>", "in_flight": 0}],
"engines": [{"plugin": "<id>", "served": ["<served>"], "slots": 1,
"in_flight": 0, "queued": 0, "declared_bytes": 0,
"load_ms": 0, "measured_bytes": 0, "tokens_out": 0,
"first_token_ms": 0, "tokens_per_s": 0}],
"devices": [{"device": "cuda:0", "bytes": 0, "used": 0}],
"blobs": {"bytes": 0, "limit": 0},
"cache": {"enabled": false}
}
peers has one row for each catalogue name, including a cold name; its
in_flight is the queue count. engines has one row for each resident plugin.
load_ms, measured_bytes, tokens_out, first_token_ms, and tokens_per_s
are present only after the engine has measured them. devices reports each
ledger device, its total bytes, and its used bytes. blobs reports the store's
bytes and limit. cache is the cache stats object, or {"enabled": false} when
the cache is off. Its top-level keys are enabled, hits, misses,
hit_rate_bp, saved_prefill_ms_total, evictions, evictions_by_reason,
demotions, promotions, corrupt_entries, active_writes, active_reads,
pinned_bytes, pin_bound, save_count, save_ms, save_ms_p50,
save_ms_p95, restore_count, restore_ms, restore_ms_p50, restore_ms_p95,
tiers, and models. ops.md section 7 describes the tier and model rows.
GET /capabilities returns the static table of section 7:
{"capabilities": [
{"name": "chat", "route": "/chat", "parts": ["text"],
"channels": ["text"], "stream": true}
]}
The table does not depend on the catalogue or on which engines are resident.
10.2 Submit a job
POST /jobs
{
"model": "example",
"capability": "image-edit",
"input": [
{"kind":"image","mime":"image/png","blob":"<sha256>","role":"source"},
{"kind":"image","mime":"image/png","blob":"<sha256>","role":"mask"},
{"kind":"text","text":"replace the sky with a storm"}
],
"params": {"steps": 28, "guidance": 4.5, "seed": 7},
"output": {"image": {"mime":"image/png"}},
"stream": true,
"priority": "interactive",
"deadline_ms": 120000
}
Rules for submission:
- The core does not examine
params. The plugin examinesparams. The web putsoutputinsideparamsunder its own name, because the wire has one opaque parameter map and no sibling output field. - An inline part keeps the whole request inside the body limit. A larger part
is an upload to
/blobsand a reference. Requirement R22. - There is no URL part. The client fetches a remote file, then uploads it.
modelis a served name from a model manifest. The core does not make a default name.stream=falsegives one object. It holdsrequest_id,status,output(the concatenated text),events(each non-text event withchannel,mime, and base64b64),artifacts, andusagewhen the plugin reported it.stream=truegives an SSE event stream.priorityisinteractiveorbackground.deadline_msstarts at admission. A job that is older than the deadline is refused withtimeout.
10.3 Adapters
An adapter changes one API format into a job. An adapter uses the same server shape.
| Route | Job that it makes |
|---|---|
/openai/v1/chat/completions | chat. messages becomes text and image parts. tools and response_format become json parts. |
/openai/v1/embeddings | embed. input becomes one part or more parts. |
/openai/v1/audio/speech | tts. The text becomes one part. The reply is audio bytes. |
/openai/v1/audio/transcriptions | stt. Multipart becomes one audio part and one text part. |
/openai/v1/images/generations | image-gen. size, n, and quality go into params. |
/openai/v1/images/edits | image-edit. Multipart becomes two image parts and one text part. |
GET /openai/v1/models | Nothing. It lists the served names as OpenAI model objects. |
The six adapters and the model list are the only routes with a version. That version belongs to the OpenAI contract. It is not an inf3r version.
Rules for adapters:
- An adapter can refuse a request only if the capability also refuses it.
- An adapter can make N jobs from one request. For example,
n=4makes four jobs. - An adapter cannot add a core feature. Requirement R23.
- One function in
inf3r-apimakes the SSE output from the event object. The adapter adds[DONE]. - The OpenAI vocabulary is only in
crates/edge/api. The core knows nomessages, nochoices, and no base64. The web supplies identifiers, time, descriptors, and bytes. - A standard field that the capability names becomes a part or a parameter.
The chat adapter maps
messagesto text and image parts. Thedeveloperrole becomessystem.tools, or the olderfunctions, becomes one json part with roletoolsand payload{"tools": [...]}.response_formatbecomes one json part with roleresponse_format. The sampling fields becomeparams. A field outside the capability is ignored. An unknown top-level field is not a refusal. - A text
progressevent becomesreasoning_content. Whenstream_options.include_usageis true, a non-empty terminal usage becomes oneusagechunk with no choices, before[DONE]. - The error type follows the status: 401 is
authentication_error, 403 ispermission_error, 429 israte_limit_error, 5xx isserver_error, and every other status isinvalid_request_error. - The transcription adapter reads the multipart fields
file,model,prompt,language,response_format, andtimestamp_granularities[].response_formatisjson,text, orverbose_json. - The image edit adapter reads the multipart fields
image,mask,prompt, andmodel. A file field stays a descriptor. - The embeddings adapter reads
input,dimensions, andencoding_format. The format isfloatorbase64. The plugin's CBOR array of vectors becomes the OpenAIdataarray. - The speech adapter uses the MIME of the first
pcmevent as the responseContent-Type. An image reply is alwaysb64_json, because the engine has no public URL.
11. The event stream
All hops send this object. The plugin sends it to the core. The core sends it to the web. The web sends it to the client.
{"seq":1,"job":"019...","request_id":"r-7","at":"2026-01-01T00:00:00.1Z",
"body":{"t":"started","model":"example","plugin":"example/gpu","est_ms":9000}}
{"seq":4,"job":"019...","body":
{"t":"delta","channel":"progress","pct":0.21,"stage":"denoise"}}
{"seq":9,"job":"019...","body":
{"t":"delta","channel":"text","text":"Hel"}}
{"seq":10,"job":"019...","body":
{"t":"delta","channel":"pcm","pcm":{"rate":24000,"fmt":"f32le"},"b64":"..."}}
{"seq":20,"job":"019...","body":
{"t":"usage","text_in":12,"text_out":84,"images":1}}
{"seq":21,"job":"019...","body":
{"t":"done","outcome":"completed",
"artifacts":[{"channel":"image","mime":"image/png","blob":"<sha256>","bytes":1843200}],
"meta":{"finish_reason":"stop"}}}
Rules for events:
seqincreases by one for each event of a job.- Each channel keeps its own order.
- A job has one terminal event only. The terminal event is
donewith an outcome, orerror. - A cancel gives
donewithoutcome: cancelled. The client then has one terminal path. - The plugin sends
usagein the terminal frame. The core collectsusagefor/stats. The web emits oneusageevent beforedonewhen the counts are not empty. - The SSE format is exact:
data: <json>\n\nfor each event, anddata: [DONE]\n\nonce at the end. A ping comment,: ping\n\n, keeps the connection alive before the first event and during a long wait. Requirement R18. - If a failure occurs after the headers, the web sends one final
errorevent. It does not close the connection without a terminal event. - A client disconnect sends a cancel frame to the core. The plugin stops within one step. Requirement R15.
12. Refusals
A refusal comes before admission. A refusal always has a code from this table.
| Code | HTTP | Condition |
|---|---|---|
unknown_model | 404 | The name is not in the catalog. |
unknown_capability | 400 | The model does not declare the capability. |
capability_missing | 400 | The model declares the capability. The host does not serve it. |
invalid_part | 400 | The kind is not permitted. The mime or the role is incorrect. |
payload_too_large | 413 | An inline part is more than 1 MiB. |
queue_full | 429 | The queue is full. The reply has Retry-After. |
no_room | 503 | The ledger cannot reserve the bytes. The reply has Retry-After. |
load_failed | 503 | The plugin failed to start or to load. |
plugin_crashed | 502 | The plugin stopped during the job. |
mismatch | 500 | The manifest does not agree with the hardware probe. |
protocol | 500 | The plugin did not obey the protocol. |
timeout | 504 | The job exceeded the deadline. |
ambiguous_model | 500 | Two plugins serve one name. The core reports this error at startup. |
Rules for refusals:
- A refusal never hangs. The request always gets a status.
- The reply has this shape:
{"error":{"code":"...","message":"...","retryable":false,"request_id":"..."}}. - A refusal after the headers becomes a terminal
errorevent. It does not change the HTTP status.
13. Blobs
- A blob has a SHA-256 content address.
- The blob store belongs to the core. A plugin never sees a blob, a blob id, or a path. A plugin sees a file descriptor. Section 10 of the protocol gives the rules.
- The client uploads bytes to
/blobs. The core computes the address. - The store removes the LRU blob when it needs room. A blob that a live job references is never removed.
- The size of the store comes from the free space of its filesystem. The operator can set an upper bound. There is no default size.
- A plugin writes an artifact and sends the descriptor with
done. The core takes ownership, checks the length, and stores the bytes. - An upload above the inline limit is spooled to an unlinked file and streamed into the store. The web does not hold the whole body in memory. A body above the store bound is refused.
The socket carries descriptors and small inline values. A 4K frame, a 60 s clip,
or a 15 GB weight file is never a message. A plugin in C, Python, Go, or Zig
needs sendmsg and a way to read a descriptor; a bounded read and mmap are
both allowed. Requirement R22.
14. The peer protocol
The normative text is .f0rge/wiki/docs/protocol.md. The machine grammar is
spec/protocol.cddl. This section gives only the contour of the contract.
- One 8-byte header:
u32 length,u16 stream,u8 type,u8 flags. The length is at most0xFFFFFF. - Sixteen frame types. Session frames use stream
0. - Three job states:
open → (accept | reject) → done. - Credit is an absolute watermark for each stream. A terminal frame is never credit-limited.
- Media is one file descriptor or inline bytes. On the plugin hop, the kernel's peer credentials authenticate the accepted socket.
- The core decodes the envelope. It never decodes a payload.
- The catalogue is the only description of a peer that the core reads.
- A peer reads control frames on a thread that never blocks on the worker.
- Two versions are compatible when their ranges overlap. Requirement R12.
- A plugin crash affects only the jobs of that plugin. Live streams get
errorwithplugin_crashed. The ledger releases all bytes. Requirement R16. - After a failure, the supervisor waits for as long as the failure took. It
classifies
version,frame,stream,size, anddependencyas permanent and marks the peer unloadable. Every other failure is transient. A successful job clears the state. - The protocol has no tunable numbers. The only ceiling is the length field: 16 MiB. A larger object is a descriptor.
15. The bundle
A bundle provides:
- One model, one target, one entry point, and one process.
--describe: the id, the target, the protocol version, the capabilities, the needs, the weights, and the limits.- Its own internals. The engine inside can be any language. The entry point is the package that the gate starts.
- Goldens. CI runs them. A bench is expected. The core does not track or compare a bench.
15.1 Four ways to be an engine
-
Authored with the SDK. The crate is
inf3r-plugin-sdk. A plugin implementsPlugin:catalogue,load, andrun(capability, request, emitter).impl Plugin for MyModel { fn catalogue(&self) -> Catalogue { /* what this bundle serves */ } fn load(&self, grant: &Grant) -> Result<Ready, Failure> { /* the weights */ } fn run( &self, capability: &str, req: Request<'_>, out: &mut dyn Emitter, ) -> Result<Report, Failure> { /* the capability */ } } fn main() -> std::io::Result<()> { inf3r_plugin_sdk::launch(Arc::new(MyModel::new())) }The SDK is synchronous. One job uses one thread. The SDK uses no async runtime. The plugin controls its own concurrency. The plugin controls its CUDA streams and its batching. An async runtime would add policy. The core is thus not the correct place for concurrency policy.
The SDK checks the model, the capability, and every part kind against the catalogue before it sends
accept. ThePlugin::admithook then checks the parameters and the roles. A refusal from either check is arejectinOPEN, so the caller never sees anacceptfor a job that the plugin did not start. -
Bound with the binder. The crate is
inf3r-bind. The entry point is one line, and the engine is a runtime that already exists inengine/:fn main() -> std::process::ExitCode { inf3r_bind::main() }The catalogue shapes are per bridge: binary chat is text, HTTP chat carries text, image, audio, and JSON with the progress channel, HTTP STT emits text, and the HTTP image routes advertise only the parts those routes use. The binary generic bridge keeps its richer shapes. A model file's
partsoverride wins.bundle.tomlgives the engine kind and the entry:engine = "binary": the binder startsengine/entryand uses its standard input and standard output as the request and the reply. Chat is a prompt of text lines. Another capability is one JSON request line; each reply line is text or a JSON object withchannel,mime, and base64b64, andevent: truemakes it an event instead of an artifact. Both streams run at once, so a prompt above a pipe buffer cannot deadlock. Withworker = "jsonl"the entry loads once, prints{"ready":true}, and reads one request object per line. A request carriesid,model,capability,params, andparts. A reply carries the sameid, then either achannelwithb64and optionalevent, or a terminal{"done":true,"usage":{...},"meta":{...}}.{"error":{"code","message"}}is a job failure. A job has one fixed deadline; cancellation and that deadline are polled while the binder waits, so a silent or chatty engine cannot extend the job. A request or reply line above 32 MiB is refused, and the request is written on a separate thread so a full pipe cannot block the job. A missing or mismatchedid, a malformed line, a duplicate terminal, or a crash stops the worker; the next job starts a new one. The one-shot binary path has the same job deadline, line cap, and blocked-pipe handling.engine = "http": the binder startsengine/entryor connects to the URL. It waits for/healthto answer below 500 before it reports ready, because a runtime can listen before the weights are in place. It mapschat,embed,rerank,stt,tts,image-gen, andimage-editto the seven OpenAI routes below/v1.music,t2v-gen,i2v-gen,decide, andextractuse the neutralPOST /<capability>bridge: the same request object as a binary engine, and one object, array, NDJSON, or SSE reply withchannel,done, anderror. NDJSON and SSE events are emitted as they arrive; a short socket poll checks cancellation and the job deadline, and a request or reply above 32 MiB is refused withsize. A chat request carries every capability parameter, the model stop strings, the image and audio parts as data, andstream_options.include_usage. It declarescancel: requestandstops: nativebecause the runtime keeps those. Anhttpsentry is refused: a bound runtime is a local process.engine = "library": the bundle links a local shared library inengine/directly from its ownsrc/via FFI (method 4), implementinginf3r_plugin_sdk::Pluginwithout a sidecar server or HTTP hop. The generic binderinf3r-bindrefusesengine = "library"; this is not a gap, because the foreign ABI belongs inside the bundle's own shim andinf3r new --bind librarywrites that shim.
inf3r-bindis a thin, engine-neutral compatibility adapter for externalbinaryandhttpruntimes — not the primary host path for first-class engines. It never injects vendor-specific engine flags or routes into a child runtime. It passes every granted weight descriptor to the engine, not only the first. A declaration with a path uses that path. A descriptor-only grant uses/proc/self/fd/<n>and the descriptor is inherited across the process start (and every worker restart);{weights}and{weightN}name the rest. The engine's stderr is copied to the binder's stderr, andinf3r-webpassesINF3R_BUNDLE_DIRso a binary that is not beside its checkout still findsbundle.toml. The binder reads everymodels/*.toml; analias_offile adds a second served name and inherits the source capabilities. It maps content and reasoning deltas to channels, and states in the catalogue what the runtime cannot do. A model file with no capability section keeps the historical implicitchat; once it declares any capability, only those names enter the catalogue. -
Raw protocol. The engine uses any language. The process obeys sections 14.1 to 14.4. It has
--describe. Goldens prove the bundle. Requirement R21. -
Direct library binding (
engine = "library"). The bundle's ownsrc/links a local runtime library (libllama,libstable-diffusion,libaudio,libonnxruntime, or a research repository) directly via FFI or a-syscrate and implementsPlugin(andCacheCodecwhen caching KV state). There is no sidecar server, no loopback port, and no HTTP hop. Theunsafestays inside that bundle's own workspace with a stated reason (D19). Copying the bundle to another pair and specializing or replacing the bound runtime with custom kernels changes nothing outside the directory.
inf3r new <model> <target> <capability> makes a bundle. The bundle has the
five parts of section 5, a target file, a model file, an empty golden set, and a
correct --describe. Requirement R17. The flag --bind binary|http selects
method 2 and writes the one-line binder entry point. The flag --bind library
selects method 4 and writes a compiling FFI shim plus a placeholder C engine
that the bundle replaces. The flag --engine selects method 1.
15.2 Goldens
A golden file has this shape:
{
"name": "chat.basic",
"protocol": 1,
"request": { "capability": "chat", "input": [...], "params": {...} },
"expect": {
"events": [ {"t": "started"}, {"t": "delta", "channel": "text", "text": "Hi"} ],
"done": { "outcome": "completed" }
},
"compare": ["channel", "text"]
}
Rules for goldens:
- A golden compares only the fields in
compare. A different value in another field is not a failure. - CI runs all goldens of all plugins that the deploy file binds. Requirement R9.
- A golden that records time or a seed must set the seed.
- The engine goldens live in
goldens/. They cover SSE output, refusal codes, and protocol frames. Requirement R18.
16. The manifest
The manifest has three levels. bundle.toml names the engine, the files, and the
digest. The target file gives the hardware. The model files give the served
names and the capabilities.
16.1 target.toml
[target]
name = "gpu"
backend = "cuda"
arch = ["x86_64"]
compute = "sm00"
devices = 2
vram_mb = [1024, 1024]
driver_min = "550"
cuda_min = "13.5"
requires = ["cublas", "cudnn>=9"]
sharing = "exclusive"
[limits]
max_inflight = 8
max_part_bytes = 268435456
load_ms = 9000
start_ms = 30000
accounting = "declared"
The target file is the hardware half of the pair. It is a profile, not a label. The core probes the host and checks every field before it starts the bundle. The refusal names the field, the required value, and the measured value. Requirement R6 and D17.
backend is cuda, rocm, vulkan, metal, or cpu. A selected device
whose id names another backend is refused. compute is the compute capability
of each selected device, as sm00 or gfx0000. vram_mb is the required
device memory, in the order of the bind's devices list. A host with mixed
cards checks only the devices that the bind selected. devices is the least
number that the bundle needs; the bind must select at least that many.
cuda_min is the lowest CUDA runtime that the engine was built against and
applies only to a cuda target. requires names the libraries that the engine
links.
Every key in [limits] is optional. The parser keeps the value on
Profile::limits; a limit is a budget of the bundle, not a measurement of the
machine. max_inflight is a u16, max_part_bytes a u64, and load_ms a
u32. accounting is the bundle's own word for how it counts memory. A bundle that
sets accounting = "split" declares that only part of its resident weight set
is on the selected devices: vram_bytes gives one byte count per device in
vram_mb order, and ram_bytes gives the bytes expected in host RAM. The
host checks the device portion against the device ledger and the RAM portion
against the process tree, so a hybrid CPU+GPU target is not charged its whole
weight file to the card. A file that names either byte count without
accounting = "split" is refused. A bound bundle also reads max_inflight as
its welcome limit and start_ms as the longest wait for its HTTP engine to
answer /health; without start_ms it waits for the web's 120 s load
deadline.
sharing is exclusive or timeslice. The deploy file can override it.
16.2 models/<served>.toml
[model]
serve = "example"
family = "example"
[weights]
files = ["weights/example-Q8_0.gguf"]
quant = "Q8_0"
bytes = 15600000000
[capabilities.chat]
vocab = "chat.v1"
context = 32768
kv_bytes_per_token = 524288
template = "chatml"
stops = ["<|im_end|>"]
params = "chat.v1"
[capabilities.embed]
vocab = "embed.v1"
dims = 4096
Rules for the model file:
serveis the name from the user. The core does not make this name. Two plugins with oneservename make the errorambiguous_model.vocabis the vocabulary version. It is independent of the wire protocol version.- The plugin uses
templateandstops. The core does not use them. The crateformat/textgives the template engine to the plugin. Decision D6. bytesis the ledger unit.context × kv_bytes_per_tokenis the KV cache of one load. Both are capability limits, and the core reserves the larger cache that any capability of the model declares. Decision D5.- An alias is a second model file with the same weights and
[model] alias_of = "<served-name>". The alias does not declare capabilities. It uses the capabilities of its source.
16.3 The catalogue
The catalogue is the only description of a peer that the core reads. The JSON shape is in the CDDL. Section 12 of the protocol gives the rules.
{
"v": 1,
"max_inflight": 8,
"target": {"id": "gpu", "backend": "cuda", "arch": ["sm00"],
"devices": 2, "vram_mb": [1024, 1024]},
"models": [
{"serve": "example", "alias_of": null,
"capabilities": {"chat": {"vocab": "chat.v1", "parts": ["text", "image"],
"channels": ["text", "tokens", "progress"]}}}
]
}
target.tomlandmodels/*.tomlare the bundle's own files. The process uses them to build the catalogue. The core never opens them.bundle.tomlis read by the cli and by the binder; the core reads the deploy file and the catalogue.--describeprints the catalogue to stdout and stops. It does no loading, so it has no deadline. Requirement R1.- Discovery runs
--describe, checks the schema, and checks name uniqueness at startup. A duplicateservename isambiguous_model. - A peer that does not answer
--describenever reachesREADY. The supervisor then handles it like any other failed start.
17. Deploy
deploy.toml contains the bindings for one host. It is not code. The same
binaries run on a different host with a different deploy file.
[[node]]
host = "example"
bin_dir = "target/release"
bundle_dirs = ["plugins"]
blob_dir = "/var/lib/inf3r/blobs"
blob_bound = "200GB" # optional; default is the free space of blob_dir
# unix, tcp, or both. The local socket serves the CLI; TCP serves the tailnet.
web = { unix = "/run/inf3r/web.sock", tcp = "100.64.0.5:8080" }
auth_file = "/etc/inf3r/token"
[[node.bind]]
bundle = "example/gpu"
models = ["example"]
devices = ["cuda:0", "cuda:1"]
vram = [1024, 1024]
pin = true
max_inflight = 8
[[node.bind]]
bundle = "example-video/gpu"
models = ["example-video"]
devices = ["cuda:1"]
warm = false
idle_unload = "5m"
priority = "background"
max_inflight = 1
A container-native file for one host is the same node with two extra roots and a sibling bind:
[[node]]
host = "inf3r"
bin_dir = "/opt/inf3r/bin"
bundle_dirs = ["/opt/inf3r/plugins", "/opt/inf3r/plugins-extra"]
blob_dir = "/var/lib/inf3r/blobs"
socket_dir = "/run/inf3r"
socket_host_dir = "/run/user/1000/inf3r"
probe_image = "inf3r:compose"
web = { tcp = "0.0.0.0:8080" }
auth_file = "/var/lib/inf3r/token"
[[node.bind]]
bundle = "mock/x64-cpu"
runtime = "container"
image = "inf3r/mock/x64-cpu:sha-0123456789ab"
command = ["/opt/inf3r/bin/inf3r-mock-x64-cpu"]
models = ["mock"]
devices = ["cpu:0"]
warm = true
Rules for the deploy file:
- One
[[node]]is one host. A deploy file names one host; a second node is refused. A host with two configurations gets two files, not two nodes. - A
bindnames a bundle id and the models that the host serves from it. The bundle id is the path belowplugins/. It has no modality segment. The bind names a bundle, not an engine: a new engine in the same directory uses the same bind. devicesselects the devices.vramis the fallback capacity for a device whose driver does not report its total; a probed GPU total is authority. The core reserves the model's bytes, not this capacity. The unit is MB.pinmeans the model stays on the device. The core does not unload it.warmmeans the core loads the model at startup.warm = falsemeans load on demand.idle_unloadis a duration. After that time with no job, the core unloads the model.priorityisinteractiveorbackground. It sets the default priority for the jobs of this binding.- A build uses each
bindentry. Requirement R10. The CI build proves that each binding can start. A bind's optionalmax_inflightis an upper bound for this host, not a raise: the core takes the smaller of it and the bundle's own welcome. A JSON-lines worker welcomes one, so a deploy value of eight still runs one job at a time; a cold bind admits one job until the live welcome is known. - The binary of a process bind is
bin_dir/inf3r-<id>, with each/of the id replaced by-.mock/x64-cpurunsbin_dir/inf3r-mock-x64-cpu. The rule is one line and a bundle never has to name its own binary. A container bind runs the plugin from its image;commandoverrides the image entrypoint. weightsis optional. It overrides the weight file that the model file names. A relative path is below the bundle'smodel/directory. The deploy file is the only authority on which file a host mounts.webnamesunix,tcp, or both. At least one listener is required. Both listeners serve the same routes and the same core.socket_diris the private socket root in the control. It is absolute and defaults to/run/inf3r. A control container that mounts a host runtime directory at a different path also namessocket_host_dir, the path that the Docker daemon resolves; the engine receives only its own instance below the host path, mounted at the control path. Both values must name the same directory and are absolute. The operator must make both names the same backing directory; a host path cannot be checked from inside the control's namespace.socket_host_dirrequiressocket_dir. A host-side gate usessocket_host_dirfor its own listener; a gate inside a control passes--socket-dirand uses a private child root. The gate runsconflicts()before it starts a container.probe_imageis the image that runsinf3r-probeoutside the control's namespaces. Every container bind requires it, not only a CUDA bind: the probe is also the only correct view of a sibling's host PID and process memory. It is non-empty and pinned like every image: a bare name and:latestare refused, as is a malformed digest.runtimeisprocessorcontainer; the default isprocess. A process bind names no image, command, or mounts. A container bind requires animageand may overridecommand; the image carries the plugin and the bundle manifests.- A container image is pinned by a non-
latesttag or asha256:digest. A bare name is resolved by Docker as:latest, so it is refused with:latestand with an empty reference. The control never pulls an image at request time. A content tagsha-<12>must agree with the image'sorg.inf3r.source.sha256label. WhenINF3R_IMAGES_LOCKnames the build record, the control also checks the image id and source label against the row; without a lock, only a content tag or digest is accepted, or the local alias when the same image still carries its content tag. The image contains no weight file and nomodel/directory. networkisnonefor a container bind. The default is alreadynone. An engine is a sibling with no network, no Docker socket, and no writable host mount except the one private socket instance that the supervisor creates. Every engine carriesinf3r.managed=1andinf3r.control=<runtime root>; a control's startup sweep removes only its own scope, so two controls can share one Docker daemon.mountsis an array ofsource:target[:ro]strings. Both paths are absolute and lexically normalized; a..component is refused. The mode isrounless it isrw, andrwis refused. The source must exist, contain no symlink, and resolve below anasset_dirsentry. A source may not name the Docker socket or a directory that contains one, be the control token or its parent, be under/etc,/var/run,/run, or/root, or be the control home or a parent. The target may not be/,/etc,/var/run,/run,/root, or a Docker socket. A mount may not overlapblob_dir, a cache tier, or either socket root. The control's cache directory is never mounted into an engine.- A container bind still names
models,devices,weights, and the residency fields exactly as a process bind does. The weight files cross as read-only descriptors; the deploy file does not need to mount them. Multi-file weights and assets use the same descriptor grant. - The cache is a control resource (D22/D23). An engine has no cache directory, quota, or tier; its cache traffic crosses the private socket as descriptors. The cache authority is owned by the control.
asset_dirsis an array of absolute host directories that a container engine may mount from. Each entry must exist, be a directory, contain no symlink, and not expose a protected path. The default is empty: with no entry, a container bind has no host asset mount. Use descriptors for weights, media, and cache objects (rule 18).- A control image carries the mock manifests below
/opt/inf3r/plugins. Other bundles are delivered as a manifest-only tree mounted read-only at/opt/inf3r/plugins-extraand named as the secondbundle_dirsentry; the tree holdsbundle.toml,target.toml,models/*.toml, and documentation, never an engine tree, plugin binary, library, or weight.ops/control-manifests.shstages it, and compose mounts it fromINF3R_MANIFEST_DIR. - A container bind may set
pids_limit,memory,shm,log_max_size, andlog_max_files. The defaults are 256 pids, 16 GiB host memory, 512 MiB/dev/shm, 10 MiB per rotated log file, and 3 files. The host memory limit does not govern GPU memory; the device ledger does. A process bind names none of these limits.
18. The crates
This table gives the owner of each crate and the allowed dependencies. The dependency rules point one way. A crate that is not in the list may not be imported.
| Crate | Directory | Owns | May depend on |
|---|---|---|---|
inf3r-api | edge/api | Wire JSON, SSE, and the adapters. | json, proto |
inf3r-json | edge/json | The JSON value, the parser, and the writer. | none |
inf3r-cli | edge/cli | The operator commands. Talks to the web over HTTP. | deploy, json, bundle, verify, host |
inf3r-proto | edge/proto | The six nouns, framing, CBOR, descriptors, and credit. | none |
inf3r-plugin-sdk | edge/sdk | The Plugin trait, serve(), and the cache codec handle. | json, proto |
inf3r-server | edge/server | HTTP, auth, the request path, and the SSE writer. | api, proto, core, catalog, blobs |
inf3r-catalog | state/catalog | A model file to a checkpoint and a capability list. | files, format |
inf3r-host | state/host | The hardware probe for CUDA, ROCm, Vulkan, Metal, and CPU memory. | none |
inf3r-ledger | state/ledger | Byte reservations for each device. | none |
inf3r-blobs | state/blobs | The content store, the LRU, and the publish. | sha256 |
inf3r-cache | state/cache | The host KV ledger, tiers, WAL, CRC32C, and eviction. | sha256, rustix |
inf3r-bundle | state/bundle | The bundle anatomy, the manifest, and the digest. | sha256 |
inf3r-bind | edge/bind | The binder for a bound engine. | sdk, proto |
inf3r-core | run/core | Discovery, routing, admission, residency, and the cache host. | proto, sched, supervisor, state, cache |
inf3r-sched | run/sched | The queues, the deadlines, the eviction, and the switch. | host, ledger, catalog |
inf3r-supervisor | run/supervisor | Start, drain, swap, restart, stop. | sdk, ledger |
inf3r-text | format/text | Token, tokenizer, template, stop set, and sampling. | none |
inf3r-audio | format/audio | PCM, rate, channels, transcript, mel, VAD, resample, and wav. | none |
inf3r-image | format/image | Frame, pixel format, colour, tile, and png. | none |
inf3r-video | format/video | Timebase, clip, and container. | none |
inf3r-gguf | files/gguf | The GGUF metadata, tensor index, and bounded tensor window. | none |
inf3r-safetensors | files/safetensors | The safetensors reader. | none |
inf3r-sha256 | files/sha256 | The one streaming SHA-256. | none |
Rules for the crates:
- No crate contains a model name.
format/*andfiles/*are leaves. They have no dependencies.- No crate contains
unsafe. Every crate deniesunsafe_code, and there is no exception inside this workspace. Section 20.3 gives the one rule that an FFI dependency must meet. A bundle is not a crate here (D19). - The core links no plugin, no model runtime, and no HTTP server.
cargo check -p inf3r-coremust not pull CUDA or TLS. Requirement R11.
A bundle is a package but not a member of this workspace. Its Cargo.toml
declares [workspace], its own literal package fields, its own lints, and path
dependencies into crates/. Cargo writes a Cargo.lock beside that manifest.
Adding, removing, or replacing a bundle changes no root member, no root lock,
and no engine build. CI still builds and tests every bundle by manifest. D19.
19. Requirements
Core behaviour
- 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. The queues are bounded.
- R4 A plugin crash affects only that plugin. The core stays up and reports it.
- R5 A reload of one plugin restarts neither the core nor another plugin.
- R6 A plugin whose declared needs do not match the probed host is refused before start. The refusal names the mismatch.
- R7 One request id identifies a request in the core log and the plugin log.
- R8 A live stream is never cut by an eviction. The eviction waits for idle.
- R9 Every plugin ships goldens. CI runs them.
- R10 CI runs format, clippy with
-D warnings, test, and a build for each binding in the deploy file. - R11 The core links no plugin, no model runtime, and no HTTP server. A check of
inf3r-corepulls no CUDA and no TLS. - R12 A plugin that was built for protocol version N runs on any core that supports N. The build method does not matter.
- R13 A new model and target pair changes no file in
crates/. - R14 An unload returns the free bytes of the device to the value before the load.
- R15 A cancelled or disconnected request stops the compute within one step, at both hops.
- R16 A failed load releases the full reservation.
- R17
inf3r new <model> <target> <capability>produces a plugin that builds, describes itself, and passes an empty golden set with no edits. - R18 The SSE output matches the recorded golden byte for byte.
- R19 Every route except
/healthzneeds auth when a token is configured. - R20 Every route checks the declared capability of the model before it submits.
API shape
- R21 A plugin in any language can implement the protocol with no Rust code and no code generator.
- R22 Media bytes do not cross the plugin socket. Inline data is 1 MiB or less.
- R23 No capability adds a new route shape. Every capability route is the
canonical path in section 7 and uses the same handler as
POST /jobs. - R24 A capability that the manifest does not declare cannot be reached by any route.
- R25 A published capability name keeps its parts, channels, parameter schema, and default values. CI fails if the shape of a published capability changes.
- R26 A reader ignores an unknown part kind, an unknown channel, an unknown parameter, and an unknown event field. It does not fail.
The peer protocol
- R27 The frame header is 8 bytes. The body length is at most
0xFFFFFF. A larger object travels as a file descriptor. - R28 A peer reads control frames on a thread that never blocks on the worker.
- R29 Credit is an absolute watermark. A terminal frame is never credit-limited.
- R30 A peer that ignores the whole extension range completes every job correctly.
Bundles
- R31 Every directory under
plugins/is a bundle. It hasbundle.toml,BUNDLE.md,target.toml,models/*.toml,model/, andengine/. CI refuses a directory that does not. - R32 A weight file is never tracked, never in an image, and never in a package
digest. The bundle's
model/directory is the only home for weights. - R33 The bundle id is the pair. It does not change when the engine changes.
- R34 The host refuses a bundle whose target profile the machine does not meet, before any child process starts. The refusal names the field, the required value, and the measured value.
- R35 KV cache is host-global state. Core owns every quota, TTL, tier, and eviction policy. No bundle declares one.
- R36 Cache frames exist only on Wire 2. They carry descriptors with
SCM_RIGHTS; no filesystem path crosses the socket. - R37 A miss, corrupt restore, or tainted slot erases the VRAM slot even when caching is disabled. A cache error costs prefill, never correctness.
- R38 Unload is two phases: a bounded
cache_flush, then process death (D13). A flush that exceeds its budget never blocks the kill. - R39 One cache manager owns each filesystem. A second manager is refused by a
per-
st_devabstract socket and the tierflock. - R40 A runtime, weight, KV-affecting argument, chat template, or codec change
invalidates old entries. An ephemeral
--hostor--portchange does not.
20. Rules of the system
- No model name 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. Section 18 gives the table.
unsafeonly with a stated reason. Section 19, R11, and decision D8.- 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, and no JSON.
- The web contains no scheduling, no residency, and no device knowledge.
20.1 The freeze contract
The API has no version number. A version number exists so that one server can serve two shapes at once. inf3r does not need that. The engine, the web, the cli, and the clients move together. Thus inf3r gets the effect of a version from these rules instead. CI enforces them.
- A published capability name never changes meaning.
chatmeans one thing forever. - A new input is optional. The default value of a new input reproduces the old behaviour. A new required field is not permitted.
- A default value never changes.
- A reader ignores an unknown part kind, an unknown channel, an unknown parameter, and an unknown event field. It does not fail.
paramsstays opaque to the core. Growth then costs no schema change.- A break gets a new name. The new name describes the shape, not an ordinal.
The name
v2is not permitted. A new task gets a new capability name and a new route. - A retired name keeps answering. Or it answers with a refusal that names its replacement. A silent removal is not permitted. A capability key is a name; its canonical route is transport spelling. The two are related but not the same string. The route table in section 7 is the complete list.
- The six nouns in section 6 are additive only. A new field in a noun is optional. A noun never changes meaning.
The plugin socket keeps its version. The reason is different. A plugin is a
separate binary. A user can pin it. The core and the plugin are not released
together. Thus protocol {min, max} with interval overlap is correct there. The
rule is: version where the artifacts decouple. Do not version where the
releases are joint.
20.2 No magic numbers
A value in the code is a bug unless it is one of these:
- Measured. The engine observes it. The user cannot set it.
- Declared. The plugin author states it as a fact about the model and the target: load time, bytes, context, concurrency.
- Intent. The operator states it as a word:
pinned,warm,interactive,always,never. - A named resource. A bound that protects a physical limit, and the comment names the limit. Examples are a 24-bit length field, one allocation, and one socket read.
Config holds intent only. It never hides an engine decision.
The test: could the engine observe this instead? If yes, it is a bug. If it is the operator's preference, it is a word. If it is the author's fact, it is in the catalogue.
20.3 No unsafe
Every crate under crates/ denies unsafe_code. There is no exception, and no
crate in the engine workspace opts out.
A bundle is its own workspace (D19). It starts from the same deny rule, but a
kernel or FFI bundle may set unsafe_code = "allow" in its own [lints.rust]
when the unsafe is the engine that the bundle exists to carry. The bundle says
why in a comment. The boundary is the bundle manifest: inf3r bundle verify
checks the anatomy and the digest, and inf3r verify checks the wire. Nothing
in crates/ becomes unsafe to support it.
A dependency that must cross into FFI is allowed in the engine workspace when
all four of these hold. It is pinned exactly. It exposes a safe API. It is
needed for something the standard library cannot do. Its version is written in
the root Cargo.toml with a comment that says why.
The dependencies that meet this bar are few. Descriptor passing is the first:
rustix gives sendmsg and recvmsg with owned descriptor buffers, so a
received descriptor is closed by a drop. There is no place in this tree where a
raw descriptor number is constructed or forgotten.
Memory mapping does not meet the bar. A safe file-mapping API cannot promise
that another process will not truncate the file, so the safe crates keep the
mapping call unsafe. The engine therefore reads weights and media through a
bounded offset window: inf3r-gguf::Window, TensorWindow, and PartReader.
A bundle that wants a mapping pins its own crate and owns the unsafe inside its
own workspace.
21. Build, test, and release
21.1 Build
./ops/build.sh release
The script builds the engine workspace and then every bundle with its own
manifest, into one target directory. The root command alone does not build a
bundle: a bundle is not a workspace member (D19). The toolchain is Rust 1.99.1.
The edition is 2024. The resolver is 3. Cargo.toml uses exact pins only. An
update is deliberate. It is never drift.
21.2 CI
The CI steps are scripts in .f0rge/ci/steps/. The filename order is the run
order. Exit 0 is a pass. The first non-zero exit fails the run. The runner is
local because the container gate needs the host Docker socket; ci.env names
the target directory and the uv path. The host executes the engine-neutral
crates and the in-repo fixtures (mock, toy, echo). An external engine
bundle is never executed on the host; its container image is the gate.
00_tools.sh make uv available; CI installs it into the target cache when
the host lacks it
01_fmt.sh cargo fmt --check in the workspace and in every bundle
02_clippy.sh cargo clippy --all-targets -- -D warnings in both
03_check.sh cargo check/test in the workspace; fixtures test on the host,
external bundles compile only
04_shape.sh the shape rules that a review forgets, and capability-shape goldens
05_goldens.sh the engine goldens, the bundle goldens, the fault injector, and the gate
06_build.sh build the engine and every bundle, then every bind in the deploy file
07_release.sh copy the release binaries
08_image.sh build the control image, build and check the mock bundle's own
self-contained image, record the digests, and run the gate
against the final image; a host without docker fails
09_bundles.sh every plugins/<model>/<target> has the five parts and a golden,
ignores model/, tracks no weights, and matches its digest;
fixtures run a host golden, external engines stay container-only
10_install.sh stage both binaries and the unit from a checkout and a release
11_compose.sh start the compose control and its sibling mock engine, check the
healthcheck, token/state restart, and container gate
21.3 Image
The control image's Rust, Debian, and uv bases are digest-pinned in
docker/Containerfile, repeated in docker/control.lock, and carried as
org.inf3r.control.base.* labels that 08_image.sh records in
target/control.lock and checks.
ops/images.sh build <bundle-id> builds one self-contained bundle image from
that bundle's own Dockerfile. The recipe lives inside the bundle directory;
the host chooses no engine, language, base, binary, or pin. The generic
builder stages only that bundle plus the shared SDK workspace (Cargo.toml,
Cargo.lock, crates/), excludes model/, builds inside Docker, and tags
inf3r/<bundle-id>:sha-<12> from the staged-context digest. Two bundles that
use the same upstream engine each build and ship their own copy.
The build context contains source and build files, not weights: the staging
scan refuses the bundle's model/ path, symlinks, unambiguous weight names,
ambiguous weight names above 1 MiB, and weight-like magic before Docker sees the
context. It does not impose an engine-file extension allowlist; a bundle may
contain C, C++, Rust, Python, headers, CMake files, patches, or lockfiles. The
whole final image is scanned again for a bundle model/ directory, unambiguous
weight names, and ambiguous weight names above 1 MiB.
The final tag, image id, and source digest are recorded in
${CARGO_TARGET_DIR:-target}/images.lock. ops/images.sh check <bundle-id>
recomputes the source digest, compares it with the lock and the image's
org.inf3r.source.sha256 label, checks the bundle id and binary labels and the
image id, and scans the whole image root for a model/ directory or a
weight-like file. A failed Docker run, shell, or find is an error, not a clean
scan. ops/images.sh tag <bundle-id> prints the final reference for a deploy
caller.
08_image.sh runs the pipeline for mock/x64-cpu and then starts that final image
through the container gate. The control verifies a container image before it
starts the sibling: it refuses a bare or :latest reference, and it compares
the image id and org.inf3r.source.sha256 label with
INF3R_IMAGES_LOCK when that variable names a lock. Compose mounts
target/images.lock at /opt/inf3r/images.lock; the CLI finds the lock in
${CARGO_TARGET_DIR:-target}/images.lock unless the variable overrides it.
Adding a bundle with an arbitrary engine requires edits only inside
plugins/<model>/<target>/; the host tooling never maps a bundle to a shared
engine base. An image is built from local pinned inputs; the control never
pulls one at request time.
21.4 Release
f0rge release create <version> --notes <file|->writes the note and runs the build scripts.- The release build copies
target/release/inf3r-web,target/release/inf3r, the unit, andinstall.shintoreleases/build/<version>/. - The install command is
./install.sh <version>, orcargo install --lockedwhen the repository has no install script. The checkout root has a wrapper that runsops/install.sh; the release copy is the same script beside the binaries. It installs both binaries and the unit.DESTDIRstages them without creating the service account. - The engine has no install step of its own. A plugin is installed by its own
package. The core finds it below
bundle_dirs.
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. Together they are the host product: its
binaries, service and install files, fixtures, and documentation. Neither part
holds a real-model bundle, a weight, an engine library, a built bundle image, or
a registry of bundles. An operator builds and deploys those separately.
21.5 Logging
- The core writes one line for each decision. The line has the request id, the job id, the reason, and the decision.
- A log line is JSON. It goes to stdout.
- The log does not contain a token, a prompt, or an image.
22. Operations
The cli is the process inf3r. It is a client of the web. It does not import
the core.
| Command | Behaviour |
|---|---|
inf3r ps | List the bundles, the processes, the devices, the models, and the residency state. |
inf3r queue | List the queues, the depth, the priorities, and the oldest deadline. |
inf3r new <model> <target> <capability> | Make a bundle. Requirement R17. |
inf3r bundle verify <dir> | Check the five parts and the digest. Exit 1 on a problem. |
inf3r bundle seal <dir> | Compute the digest and write it into bundle.toml. |
inf3r verify [--program <path>] [--budget <time>] [--load-budget <time>] [--job-budget <time>] [--suite <file>] | Run the binding gate against one bundle. |
inf3r verify --container <id> --deploy <file> [--image <ref>] [--socket-dir <dir>] [--socket-host-dir <dir>] | Start the container bind, or the named image, as a sibling Docker container and run the same gate over its private socket. The host dir is the daemon-side mount path. |
inf3r reload [bundle] | Run discovery again. Reload one bundle or all bundles. |
inf3r doctor | Check the host, the deploy file, the bundle manifests, the token, and the blob store. |
Rules for the cli:
- A command prints a table for a human. The option
--jsonprints one object. - A command exits 0 on success. It exits 1 on a condition that the user must correct. It exits 2 on a usage error.
doctordoes not change state. It only reports.--socketnames the local Unix socket.--tcp host:portnames the remote listener. A TCP command carries--tokenor--token-file; a Unix command does not.psreadsGET /statsand prints the bundles, their processes, the devices, the models, and the residency rows.reloadsendsPOST /reload. An empty object reloads every bundle; abundlestring reloads one bundle. A sibling bundle keeps its process.
23. Add a bundle
The steps for a new pair:
- Pick a model and a target.
- Run
inf3r new <model> <target> <capability>. The command writes the five parts of section 5, the target file, the model file, and the goldens. To copy a bundle that already passes is also correct. - Put the engine in place. An authored engine goes in
src/. A bound engine goes inengine/, andsrc/main.rsis the one-line binder entry point. Build the bundle in its own workspace, or run./ops/build.sh release. - Put the weights in
model/. The directory stays out of git. Add the file name to the model file, or name an absolute path indeploy.toml. - Edit
target.tomlto the hardware that the engine was built for. Editbundle.tomlandBUNDLE.mdto match. - Run
inf3r verify --weights <file>; for a container bind, runinf3r verify --container <id> --deploy deploy.toml. Run the bench. - Bind the bundle id in
deploy.toml. Set the devices, the memory, the sharing, and the residency. - The core discovers the bundle. Then it routes to it, queues for it, and switches it in and out.
The steps change no file in crates/. The steps do not rebuild the core.
Requirement R13.
The workflow for an agent is the same steps from 3 to 6. The agent replaces the engine inside one directory, runs the gate and the bench, and stops when the numbers are better. The bundle id, the deploy file, and the client stay the same. Decision D14.
The test of this rule is the closure rule:
A new modality adds vocabulary. A new modality does not add a shape.
The steps for a new capability:
- Add one capability page under
.f0rge/wiki/docs/capabilities/. The page gives the parts, the parameters, and the channels. - Add one or two rows to section 7.
- If necessary, add one adapter route.
- If necessary, add a manifest key.
The steps do not change the types in inf3r-api, the code in inf3r-sched, the
code in inf3r-server, or the frame set. A new frame type is a protocol change.
A protocol change needs a version increase.
24. Non-goals
- Training, fine-tuning, quantising, and weight download.
- A graphical interface.
- Cross-host distributed inference in version 1.
- LoRA hot-swap.
- Windows.
- A shared tensor API or a shared kernel API. They are deliberately absent.
- Core and web as separately deployable services.
- Accounts, quotas, and CORS.
- Benchmark history and comparison across plugins.
- A URL part in the API. The client must upload the bytes.
- Server-side fetch of remote media.
25. v1.0 state
This section gives the state of the host and tooling. It is not a bundle catalogue.
| Item | State |
|---|---|
| Workspace | The engine workspace is crates/*/*. edge, state, run, files, and format are written. Every crate has tests. Every bundle is a separate workspace (D19). |
| Core binary | Not separate. crates/run/core is a library; inf3r-web holds it. Decision D11. |
| Web binary | target/release/inf3r-web. It reads deploy.toml, checks every target profile, starts every bind, and serves HTTP and SSE. |
| Plugin SDK | The Plugin trait, serve(), the emitter, the catalogue, and --describe. The cache codec and transport are in the same crate. |
| KV cache | crates/state/cache: per-st_dev authority, ordered RAM/disk tiers, economic demotion and second-hit promotion, disk/RAM pressure hooks, CRC32C WAL and snapshot, TTL, pins, supersession, and metrics. Wire 2 carries cache frames as descriptors. The compatibility binder uses the optional /inf3r/cache bridge; a runtime that does not advertise it runs uncached. A direct library bundle can implement the same codec in its own src/. |
| Bundles | The contract is plugins/<model>/<target>/ with five parts, its own workspace, and its own image recipe. The repository carries test fixtures: mock/x64-cpu (twelve capabilities, no weights, no device, authored), toy/x64-cpu (a real decoder over a generated GGUF, authored), and echo/x64-cpu (a Python runtime behind one line of Rust, bound). A real model bundle is operator content, not a release artifact. |
| Bundle crate | inf3r-bundle: the manifest, the five parts, the anatomy check, the digest, and seal. The digest never reads model/. |
| Binder | inf3r-bind: reads bundle.toml, every model file, and its aliases; serves all twelve capability names through the neutral binary bridge and the seven OpenAI-shaped plus five neutral HTTP bridges; starts a one-shot or resident (worker = "jsonl") binary or an HTTP runtime; and declares the lifecycle words that the runtime can keep. |
| Goldens | crates/test/goldens: record, replay, and diff the first difference. plugins/*/*/goldens/ holds plugin goldens. |
| Gate | inf3r verify starts a binding, checks the handshake, the catalogue, --describe, one job per suite step, extension immunity, cancel, credit replenishment, a descriptor input part, a descriptor output artifact, crash, and restart. A cache-capable binding also gets cache_fingerprint, cache_roundtrip, cache_cold_erase, cache_corrupt_fallback, and cache_abort_on_crash against a real temporary store. goldens/conformance.json is the default step list; --suite reads a bundle's own. The whole run, the load, and one job have separate deadlines. With --container, the same checks run over a sibling container's private socket; cache_cold_erase runs in container mode because the trace file lives in the one private socket directory; cache_abort_on_crash is the only skip because its fault mode is a host-process fixture. |
| CI | Twelve local steps: tools, format, clippy, check and test, shape and capability-shape goldens, engine and bundle goldens, build, release, image and the mock container gate, bundles, install, and the compose control plus sibling engine proof. The host runs engine-neutral crates and in-repo fixtures; an external engine runs only in its container. |
| Docs | .f0rge/wiki/docs/{index,spec,protocol,core,binding,bundle,ops,plan}.md and twelve capability pages. |
| Protocol grammar | spec/protocol.cddl; crates/edge/proto implements it. |
| Backlog | The forge holds the issues. The roadmap in section 26 D-numbers is settled. |
| Residency | pin, warm, idle_unload, LRU on no_room, and a switch with an edge per step. Unload is process death (D13). |
| Not present | A weight file in git, in an image, or in a digest. An engine library belongs to its own bundle image, never to the repository or the host; weights and runtime builds are operator mounts. |
cargo test --workspace is the engine acceptance test. Each bundle also runs
its own tests in its own workspace. inf3r-web starts the mock and answers a
streamed chat in crates/edge/server/tests/engine.rs. 09_bundles.sh refuses a
directory under plugins/ that is not a bundle.
26. Decisions
All decisions are settled. A later change is a new decision with a new number.
D1 — encoding. CBOR, grammar in spec/protocol.cddl, JSON mirror for
conformance only.
D2 — bulk data. A file descriptor at the peer hop, a blob reference at the API hop. The core substitutes. No URL.
D3 — submit route. POST /jobs is generic. POST <canonical route> is the
same handler with the capability key filled from the path. Section 7 is the one
route table.
D4 — SDK concurrency. Synchronous. One worker per job, one reader thread per peer, no async runtime.
D5 — ledger unit. A load reserves the declared weight bytes plus
context × kv_bytes_per_token, both declared in the catalogue. A target that
declares a split resident set charges only its vram_bytes to the selected
devices and checks its ram_bytes against the child's host RSS. A job reserves
nothing extra. Unload releases exactly the reserved bytes.
D6 — template and tokenizer. Both in the plugin. format/text gives the
engine five turn layouts, a marker detector for a GGUF chat template, a GPT-2
byte BPE that uses the byte-to-Unicode spelling, and a SentencePiece BPE that
reads add_space_prefix. format/vocab reads both from the model metadata.
D7 — rerank. Separate from embed.
D8 — target crates. Removed. Kernels live in plugins. crates/ holds no
device code.
D9 — home of the six nouns. A new leaf crate crates/edge/proto
(inf3r-proto) owns the nouns, the framing, the codec, the descriptor helpers,
and credit. edge/sdk is the traits and serve(). The core depends on proto
and not on sdk.
D10 — capability names. The short names in section 7. A published name is permanent.
D11 — one process for core and web. The core is a library and inf3r-web
holds it. A second process would add a hop that carries the same frames, and the
web already speaks them. A separate core needs a reason that this host does not
have: a GPU host serves one node. Section 24 rule 7 keeps the split as a
non-goal, so this decision matches the non-goal instead of contradicting it.
D12 — the unit is the pair. One (model, target) per process. A per-pair binary can carry a template, a stop set, and a sampler default that would be wrong for another model. The ledger holds one reservation per process and a crash isolates to one model. An engine that serves many models is bound as several processes, not one.
D13 — unload is process death. The core stops the child, releases the
reservation, and lets the kernel free the memory. No unload frame enters the
protocol. A runtime cannot fail to free memory that it does not keep. The cost
is reload time, and that cost is why pin, warm, and idle_unload exist.
D14 — the unit is the bundle. One model on one target is one directory:
the weights it needs, the engine that runs them, the hardware profile it was
built for, and the facts it declares. Adding, replacing, or deleting a pair is a
directory operation. The id is the pair, so a new engine in the same directory
keeps the bind and the client unchanged. Nothing in crates/ names a model, a
bundle, or an engine.
D15 — the entry point is a package; the engine is free. Every bundle has one cargo package at its root, because cargo needs one entry point to build and the gate needs one process to start. The engine behind that entry point is any language, any binary, any library, or an authored implementation. A bound bundle's entry point is one line of Rust; its engine is not Rust. A bundle with no Rust at all is still possible over the raw protocol, and the gate judges it the same way.
D16 — the weights are content. model/ is part of the bundle but never part
of the repository, the image, or the package digest. An operator mounts it. A
bundle without its weights is a complete bundle; it is not loadable until the
file is present. The deploy file is the only authority on which weight file a
host mounts.
D17 — the target profile is authority. target.toml states the hardware
that the bundle was built for: arch, backend, compute capability, driver floor,
and the memory of each selected device. The host checks every field before
spawn, against the bind's devices rather than every card in the machine.
A mismatch refuses the bundle with the field, the required value, and the
measured value. There is no silent downgrade and no warning-only mode.
D18 — a capability is not a Rust trait. The capability page and the
catalogue are the contract. inf3r-plugin-sdk exposes one untyped
Plugin::run(capability, request, emitter), so a bundle in any language reads
the same parts. The typed per-modality crates were removed because no process
used them, and each would duplicate a wire shape that the page already owns. A
typed helper may live inside one bundle; it is not a shared crate.
D19 — a bundle is a standalone workspace. The root workspace holds
crates/ and nothing else. Every bundle declares [workspace] in its own
Cargo.toml, keeps its own Cargo.lock, and reaches the engine crates by path.
A new bundle adds no root member, no root lock entry, and no root build step.
CI still builds and tests every bundle by manifest, because a bundle that does
not build is not a bundle. The unsafe boundary follows the same line: engine
crates deny unsafe_code without exception, and a kernel or FFI bundle may opt
out in its own manifest with a stated reason. The bundle boundary is the
manifest, the digest, and the gate, not a shared lint table.
D20 — a weight is read through a window, not mapped. The engine reads a
weight or media descriptor at an offset through a bounded window. It does not
map the descriptor. A safe file-mapping API cannot promise that another process
will not truncate the file, so the safe crates keep the mapping call unsafe
and no engine crate can call it. inf3r-gguf::Window parses the index once and
reads only the tensor, TensorWindow bounds a safetensors tensor, and
PartReader bounds one input part. A bundle that wants a mapping pins its own
crate and owns the unsafe in its own workspace (D19). The wire stays the same.
D21 — one deploy file is one host. A deploy.toml describes one host and
has exactly one [[node]]. A second node is refused. Two hosts have two files;
the operator starts one server per file. web may name unix, tcp, or both,
and both listeners share one core, one stop, and one connection cap.
D22 — KV cache is a core resource. Core owns the cache ledger, tiers, TTL,
pins, and eviction in crates/state/cache. A bundle owns only its codec and
slot table. A per-bundle quota or proxy recreates the old broker with no global
truth. R35.
D23 — cache crosses the wire only as descriptors. Wire 2 reserves
0x20..=0x27 for cache frames. A lookup returns a read descriptor; a reserve
returns a writable temp descriptor; a commit returns only metadata. No path,
hash, or prompt text crosses the socket. Wire 1 peers negotiate down and never
see a cache frame. R36.
D24 — prefix chains, lineage, and cold erase. A key is an opaque 32-byte
prefix boundary, sent longest-first. A committed tip may supersede its parent;
two lineages promote a shared parent to an anchor. checkpoint_exact models
never roll back. A miss erases the slot unconditionally. R37.
D25 — flush is bounded and before death. Unload sends cache_flush with the
operator's budget, then kills the child whether or not the flush finished.
Write-behind normally makes the flush empty. The cache never delays D13 beyond
its budget. R38.
D26 — one disk authority. Core refuses two tiers on one st_dev and holds
an abstract socket plus a tier flock. Strata and any foreign disk cache must
route through this ledger or be disabled. Pinned bytes count against both the
tier bound and the global pin bound. R39.
D27 — the engine cache bridge is optional and is never faked. A bound engine
may advertise GET /inf3r/cache and implement one-slot save, restore, erase, and
an optional prefix checkpoint. The binder uses the bridge when advertised and
runs uncached otherwise; it never injects a vendor flag or calls a vendor route.
A prefix checkpoint is used only when the engine advertises it; an engine
without the operation never receives a request that pretends it exists. The
bridge is engine-local HTTP, not Wire 2, and it never chooses a key, tier, TTL,
pin, or eviction policy.
D28 — Docker is the engine runtime; the control container is trusted and the engines are not.
Docker, and only Docker, runs engines. Rootless Docker is the target runtime;
Podman is out of scope. The control
container runs inf3r-web and holds the host's rootless Docker socket. It is
the trusted orchestrator: it starts, measures, and stops engine containers. A
separate host-side launcher is rejected because it adds another privileged
process without removing the control plane's authority over jobs, state, and
scheduling. The Docker socket is never mounted into an engine container.
An engine container is a sibling, not a child: one bundle instance per
container, --network none, --read-only, a writable --tmpfs /tmp,
--cap-drop ALL, --security-opt no-new-privileges, and only the CDI devices
that the bind names. It never receives the Docker socket, the host cache
directory, the control process's file descriptors, or another bundle's socket
directory. The image contains the plugin and its engine libraries, never a
weight file (D16/R32).
The control container and every engine run as container root (0:0) under
rootless Docker. Rootless Docker maps that root to the unprivileged host uid
that runs the rootless daemon, so SO_PEERCRED reports the same uid on both
sides and the existing peer-uid check keeps its meaning. Container root is not host root: the capabilities are
dropped, the root filesystem is read-only, and no host path is writable except
the one private socket directory. The rootless Docker user namespace maps
container root to the unprivileged host uid that runs the daemon. A non-root
container uid maps to a subordinate host uid instead: measured on one rootless
host, container root 0:0 wrote as host 1000:1000, container 1000:1000 as
host 100999:100999, and container 65534:65534 as host 165533:165533. The
subordinate numbers are host-specific. A non-root container would need a socket
mode wide enough for its subordinate uid, while the control's peer-uid check
expects the daemon uid, so the first container tranche keeps 0:0 for both
sides.
A private socket directory is created per engine instance as
/run/inf3r/<instance>, mode 0700, owned by the control uid. Only that
directory is mounted into its engine, at the same path. The socket file is
created inside it with a 128-bit random name and mode 0666; the directory's
mode and the fact that siblings do not receive the mount are the access
boundary. The random path is the launch token: it is passed to the plugin as
--socket <path> and exists nowhere else. Filesystem sockets replace abstract
sockets because an abstract name does not cross a network namespace. The
control closes the listener and removes the instance directory before it asks
the container to stop, so a restart cannot find the old socket; the container
stop/remove then runs even if the Docker CLI already exited.
Weights cross the container boundary as read-only descriptors over Wire 2, not
as host paths. The control opens each deploy-named weight file, and a directory
model is passed as one directory descriptor; the grant's path field is empty
in container mode, so the engine names the object through
/proc/self/fd/<n>. This keeps D2/R22 and D16/R32: the bytes do not cross the
socket and no weight path enters the engine. Media and KV-cache descriptors use
the same mechanism. Process mode keeps the existing path-bearing grants.
The control has no GPU and a separate PID namespace. It learns a container's
host pid from Docker, and a generic probe helper container (built by the image
pipeline, with host PID visibility and nvidia.com/gpu=all) supplies GPU
totals, per-host-pid VRAM, and process-tree resident bytes. The probe asks for
all cards, not the subset that one bind names: CDI renumbers a subset, so a
probe that received only cuda:1 would see it as cuda:0; all preserves the
host indices that the deploy file and the ledger use. The engine still receives
only the device that its own bind names. Host::probe, the D17 profile check,
verify_devices, and the VRAM settle use that probe in container mode and the
local probe in process mode. The probe is an implementation of the existing
Host/Memory seams, not a second ledger.
Images live in the local rootless Docker store and are built from pinned source
tags or commit SHAs. Every bundle owns its complete image recipe inside its own
directory; the final image is tagged inf3r/<bundle-id>:sha-<12> and is
referenced by its sha256: digest in the deploy record; latest is never a
runtime reference. There is no shared engine base and no central engine
registry. The control never pulls an image at request time. ops/images.sh
records the final digest and source digest in target/images.lock; the image
labels carry the bundle id, binary, and source digest. The control and the CLI
gate refuse a missing, mismatched, or unpinned image before a container starts;
the deploy parser only validates the reference spelling.