The core
The core owns every process, every byte of memory, and every job that is not inside a model. This page gives the state of each object and the event that moves it. A state that is not in a table does not exist.
1. Objects
| Object | Key | Lives in |
|---|---|---|
| Peer | server id from hello | supervisor |
| Model | serve name | catalog and residency |
| Device | target.id plus index | ledger |
| Load | one per resident model | ledger |
| Job | stream id on one connection | admission and the core |
2. Peer
DISCOVERED ──probe──► PROBED ──spawn──► SPAWNED
SPAWNED ──hello/welcome/catalogue──► HANDSHAKEN
HANDSHAKEN ──grant + ready──► READY
READY ──bye + last terminal──► DRAINING ──exit──► CLOSED
any ──fatal, exit, or timeout──► FAILED
FAILED ──backoff──► SPAWNED
| Event | Guard | Result |
|---|---|---|
| probe answers | the catalogue is valid | PROBED |
| probe answers | the catalogue is invalid | FAILED |
| spawn returns a pid | SPAWNED | |
welcome arrives | version overlap | HANDSHAKEN |
catalogue arrives | names are unique | HANDSHAKEN |
ready arrives | READY | |
bye sent | no job is open | DRAINING |
| the process exits | CLOSED | |
fatal arrives | FAILED |
Rules:
- A peer that fails twice in one minute is not spawned a third time. The backoff doubles from the measured start time, and sixty seconds is its ceiling.
- A peer in
FAILEDholds no ledger reservation. The core closes its socket, stops the child, fails every live job on it withplugin_crashed, settles the device, and releases the reservation. - A peer in
DRAININGaccepts no new job. - A permanent failure marks the peer unloadable. A request is refused until an operator switch starts it again. A transient failure waits for its backoff, and a successful start clears the failure memory.
3. Residency
Unload is process death (decision D13). There is no unload frame: the core stops the child and releases the reservation. The state below is the state of the supervisor, not of the plugin.
COLD ──spawn, load──► LOADING ──ready──► RESIDENT ──stop child──► COLD
RESIDENT ──idle for idle_unload──► WARM
WARM ──new job──► RESIDENT
| Intent | Cold start | Idle unload | Chosen by |
|---|---|---|---|
pinned | allowed | never | operator |
warm | allowed | idle_unload | operator |
interactive | allowed | on pressure | engine |
always | at start | never | operator |
A cold bind is discovered with --describe and no load. Its names enter the
catalog, and the first request starts the child through the loader with the
weight files that the deploy file names. An unload removes the peer but keeps
the catalog names, so the next request reloads the same name with the same
weights.
Rules:
idle_unloadis a duration that the operator states, or it is absent.- A model is unloaded when its idle window passes, or when its ledger reservation is needed by another model. The web sweeps idle plugins while it serves; the ledger decides the pressure eviction.
- The order of unload is least recently used. A
pinnedmodel is never chosen.
4. Ledger
A load reserves weights + context × kv_bytes_per_token on every device that
its bind names. A job reserves nothing. Decision D5.
FREE(bytes) ──reserve──► HELD(load) ──release──► FREE(bytes)
Rules:
- A reservation is a number of bytes on one device. It is not a percentage.
reservefails when the device has fewer free bytes than the request. The refusal isno_roomwithRetry-After.- The core reports the reservation of a model at
load, beforegrant. - A reservation that no load holds is a bug. The ledger asserts it at drop.
- A device is added to the ledger without rebuilding it, so a reservation on an already-declared device survives a later declaration.
- The bind names the devices. A card that another bind owns is not part of this load's bill.
- A release waits until the driver reports the free bytes that remain after the release, not until the driver reports the size of the released bytes.
5. Job
SUBMITTED ──refuse──► REFUSED
SUBMITTED ──admit──► QUEUED ──slot──► RUNNING
RUNNING ──done──► DONE
RUNNING ──cancel──► CANCELLED
RUNNING ──deadline──► EXPIRED
RUNNING ──reader gone──► CANCELLED
RUNNING ──peer lost──► FAILED
| Event | Guard | Result |
|---|---|---|
| submit | a refusal code applies | REFUSED with that code |
| submit | the queue is full | REFUSED with queue_full |
| submit | a slot is free | RUNNING |
| slot frees | a job is QUEUED | best priority, then arrival; an aged background job competes as interactive |
done | DONE | |
cancel | CANCELLED | |
| the reader drops the job | CANCELLED | |
| deadline | no frame before the budget | EXPIRED |
Rules:
- A refusal is decided before a queue slot. The order is: name, capability, parts, size, queue, room.
- A job in
RUNNINGholds one slot of its plugin'smax_inflight. Every served name of one plugin, aliases included, shares that one set of slots. - The deadline starts at admission. The queue wait spends it, and the
plugin receives only the remaining time in
open. A read that would wait past the deadline ends the job astimeoutinstead of blocking forever. - A background waiter that waits longer than one second competes as interactive. Its earlier arrival number then puts it first, so a stream of new interactive jobs cannot starve it.
- A job never outlives its peer. When the peer is
FAILED, every job on it becomesFAILEDwithplugin_crashed. The job whose own deadline failed keeps thetimeoutcode, because its budget ended before the peer failed. - A caller that drops a job without reading it has cancelled it. The row ends
as
cancelled; it does not stayrunningfor the life of the process. The web removes terminal rows after its retention window.
5.1 The scheduler
| Question | Answer |
|---|---|
| What owns the slots? | One peer, named by the bundle id. Every served name of that peer shares them. |
| What is the slot count? | max_inflight from the catalogue, or the deploy file's value for the bind. |
| What bounds the waiters? | A queue capacity per peer. Above it the job is refused with queue_full. |
| Who runs next? | The highest class, then the lowest arrival number. |
| When does a class change? | A background waiter becomes interactive after one second. |
| What happens at a deadline? | The waiter is removed. A job whose deadline passed before it arrived is refused with timeout, before it takes a queue place. |
inf3r-sched takes the current instant from its caller. It has no thread and no
sleep, so a test ages a waiter by passing a later instant. A slot is a lease:
dropping it releases the slot. Registering the same peer again keeps the slots
in use, because a restart must not free a slot that a live job still holds.
6. The session pump
One thread per peer reads frames. This table is what it does with each frame.
| Frame | Action |
|---|---|
welcome | check the version. Record max_inflight. |
catalogue | check the names. Store it. |
ready | record the measured load time. Set the model RESIDENT. |
accept | record est_ms. |
event | credit the sender. Append to the job. |
done | close the job. Release the slot. Return the artifacts. |
reject | close the job. Refuse the request with the code. |
fatal | mark the peer FAILED. Fail its jobs. |
pong | note the round trip. |
Rules:
- The pump never blocks on a worker. It reads and it routes.
- A frame for a stream that is not open is
fatal{stream}. - A
donefor a job that the core markedCANCELLEDkeeps the outcomecancelled.
7. Failure classes
| Class | Example | Peer | Jobs |
|---|---|---|---|
| Refusal | busy, unknown_model | stays READY | the one job is REFUSED |
| Timeout | no frame for the budget | FAILED | EXPIRED |
| Protocol | a frame out of order | FAILED | FAILED |
| Crash | the process exits | FAILED | FAILED |
| Load | ready never arrives | FAILED | REFUSED with load_failed |
Rule: a class that kills the peer records the failure, fails its jobs, and frees its ledger reservation. The failure is recorded before the settle wait, so a request that arrives during the wait sees the backoff; the reservation is released after the device settles. The settle target is the free line the child left, captured before its start, not the card's nominal capacity: a desktop compositor or another process may own part of the card permanently.
8. Invariants
Each one is a test against the mock plugin.
- The sum of every reservation on a device is at most the device size.
- A peer in
READYhas exactly one load in the ledger, or none if it serves no model. - A job that the core reports as finished has no open stream.
- A frame for an unknown stream ends the session.
- No job outlives the peer that runs it.
- A refused request has a code from section 12 of the spec.
6. KV cache
The core owns KV cache as a host resource (D22). It does not parse a prompt, a token, a chat template, or an engine slot format.
| Object | Key | Lives in |
|---|---|---|
| Cache tier | name and st_dev | state/cache |
| Cache entry | domain-separated SHA-256 | one tier |
| Cache lease | session and lease id | the core, until release or crash |
| Cache session | one peer connection | the core |
The rules:
- One manager owns each filesystem. Core refuses two tiers on one
st_devand holds a per-st_devabstract socket, a host-mounted deviceflock, and a tierflock(D26). - A bundle declares only a codec, a slot count, a state kind, and a maximum entry size. It declares no quota, TTL, tier, or path.
- A lookup returns an opaque read descriptor. A reserve returns an opaque writable descriptor. A path never crosses the socket (D23).
- A prefix key is a boundary, not a promise that a longer prefix can be
truncated.
checkpoint_exactengines never roll back (D24). - A miss, a corrupt restore, or a tainted turn erases the VRAM slot. A cache error costs prefill and never changes the answer.
- A flush is bounded. The core kills the child when the budget ends, even if the flush did not finish (D25).
- A lease belongs to its peer session. EOF, fatal, a timeout, or a child crash aborts every write lease and releases every read lease. A lease that is not released within ten seconds is abandoned, not counted as a hit.
- A cache entry has no HTTP route.
/cachereturns metadata only. - Tiers are ordered hot to cold. A full hot tier demotes a cold victim before eviction; maintenance promotes an entry back after its second hit, and only demotes when the measured restore estimate is below the entry's prefill cost.
- Disk pressure on a tier's
st_devevicts that tier beforeblobsrefuses an upload or a model load. Host memory pressure demotes or evicts RAM-backed entries before a load is refused. Both paths skip pinned entries. - A zero
pin_boundis a zero budget: pins are refused. A pinned entry does not expire and counts against both the tier bound and the pin bound.