Last updated: 2026-11-11
How a provider that serves Darkbloom and its owner from one Mac stops taking Darkbloom work while the owner uses the Mac through its local API, and returns once the owner is idle. This explanation is for provider developers; the wire fields are in the protocol reference.
A provider serving Both, me first, its local API beside Darkbloom, shares one engine and one KV budget between the owner's requests and Darkbloom's. The owner pause gives the owner the Mac: Darkbloom work stops arriving while the owner uses it, nothing that has started answering is cut, and the Mac goes back to Darkbloom on its own.
It uses only signals coordinators already honour, so it needs no coordinator
change. A draining heartbeat takes the Mac out of routing and keeps its
uptime. The typed refusal capacity / 503 / error_reason draining fails a
racing request over without spending a retry or derating the Mac.
The pause is not an add-on hold. It keeps every model loaded and admits local requests. It cancels only Darkbloom work still queued for the engine, while one of the owner's requests waits behind it (when the owner's request waits).
stateDiagram-v2
[*] --> Open
Open --> Paused: a local request starts
Paused --> Paused: a local request starts or ends
Paused --> Open: no local request in flight for the idle time
MeFirstPolicy (provider-swift/Sources/ProviderCore/Service/MeFirstPolicy.swift)
is the pure state machine: a count of local requests in flight, when the pause
began and when the owner's last request started or ended, on a millisecond
clock the caller supplies. ProviderLoop+MeFirst.swift in
provider-swift/Sources/ProviderCore/ owns one per serving process:
| API | Behaviour |
|---|---|
enableMeFirst(idle:) |
Turns the pause on with the owner's idle time ([local] me_first_idle_minutes, 2 minutes by default). The first call wins; a changed setting applies at the next start. The local API calls it as it starts, where me first applies (below); a pair's leader enables it from [local] (pairs). |
noteLocalUse(.start) |
A local request acquired a model: acquireModelForLocal calls it right after taking the request's reservation (on a pair's leader, noteClusterPairLocalUse). The first one pauses Darkbloom work. |
noteLocalUse(.end) |
It released the model: releaseLocalReservation calls it when it drops that reservation. The end of the last one starts the idle countdown. Every start is paired with one end; an unmatched end changes nothing. |
resumeIfOwnerIdle() |
Ends the pause once the idle time has passed. The resume timer calls it. A fresh coordinator connection makes the same check before its first heartbeat (reassertOwnerPauseAfterReconnect). On a pair's leader the member beat calls it too. |
meFirstSnapshot |
What status reads (DaemonState.meFirst). |
While paused:
| Concern | Behaviour |
|---|---|
| Heartbeat | status: draining, busy_reason: owner, busy_since_ms (ProviderState.ownerPausesPublic, refusingDarkbloomWork). An event heartbeat goes out when the pause begins |
| Coordinator inference | The typed capacity / 503 / draining refusal (rejectIfDraining), once per racing request |
load_model, prefetch_model |
The drain failures, which coordinators retry later. A coordinator preload never evicts the model the owner is using |
| Autopilot commands | Busy, with reason draining |
| Capacity quotes | Refused with slot_state |
desired_models |
Deferred; replayed when the pause ends |
| Darkbloom work accepted before the pause | Finishes once the engine has started it. While one of the owner's requests waits in the same engine's queue, work still queued gives way (below) |
| Local requests and models | Admitted and kept as usual |
| A fresh registration | register carries the owner's busy fields, and the connection's first event heartbeat repeats the draining status. A pause whose idle time passed while the connection was down ends first, so that one heartbeat says idle or serving |
When the idle time has passed with no local request in flight, the provider
clears the flag, sends an idle or serving event heartbeat, and replays the
deferred desired_models.
startLocalEndpoint (provider-swift/Sources/ProviderCore/ProviderLoop+LocalEndpoint.swift)
calls enableMeFirstIfConfigured before the endpoint can take a request. It
turns me first on with the idle time ProviderLoopConfig.meFirstIdle gives,
which reads [local] from the loaded config through
LocalSettings.meFirstIdle(local:localEndpoint:)
(provider-swift/Sources/ProviderCore/Config/LocalSettings.swift):
| Provider | Me first |
|---|---|
Both, me first (start --me-first or --local-endpoint): the local API beside the coordinator |
On, mode both, unless [local] me_first = false; idle me_first_idle_minutes (default 2) |
The same with [local] me_first = false (what a plain start saves from 0.10.12 on a Mac with no choice saved: Both, Darkbloom never paused), or a saved mode other than both |
Off: local and Darkbloom requests share the Mac, and the heartbeat is unchanged |
Darkbloom network (--network, or launchd's child without a mode flag), and a cluster member without the pair's slot |
Off: no local API |
| A pair's leader with its local API beside Darkbloom | See pairs |
Only me (start --local, StandaloneServer) |
None: no coordinator, so no ProviderLoop and nothing to pause |
With no me_first saved it is on, so a Mac that already served with
--local-endpoint (or that 0.10.11's start question saved as Both, me first)
pauses as before after an update; only a Mac with no choice saved gets me_first = false from the default (StartServingResolver.resolve). That includes the desktop app's "Alongside the network" (Both, me
first), which starts the provider with --local-endpoint. To turn it off,
start once with --no-me-first, which saves me_first = false under [local]
in provider.toml (~/.config/darkbloom/provider.toml): the setting is read
when the provider starts.
The owner's use is the local request's model reservation: from the moment
acquireModelForLocal takes it until releaseLocalReservation drops it. The
request's OneShotRelease drops it exactly once, whether the request
completes, fails, is cancelled or its client disconnects. Every route that
uses a model goes through that acquisition, so no route list is kept:
| Request | Counts |
|---|---|
| Chat completions (streamed or not), completions, responses and the batch route, including Nemotron Super's managed chat | Yes, while it holds the model; a stream holds it until its last token |
A request refused after it took the model, such as an invalid tool_choice |
Yes, briefly |
| A request refused before it holds a model: a model this Mac does not serve (404), a load refused (429), a drain or shutdown, or cancelled while its model loads | No |
/v1/models, /models, /health, /v1/health, /props, /metrics, /tokenize, /detokenize, /apply-template |
No: they hold no model |
| The startup self-test decode | No: it reserves the model directly, without the hooks |
The owner's request shares the engine and its KV memory with Darkbloom work accepted before the pause. When the engine has no room for it, Darkbloom work on that model that is still queued gives way, and work the engine has started, in its prompt or answering, finishes:
sequenceDiagram
participant Owner as Owner's request
participant Bridge as EngineV2Bridge
participant Loop as ProviderLoop
participant Coord as Coordinator
Owner->>Bridge: submitted, waits in the engine's queue
Bridge->>Bridge: still waiting two engine steps later
Bridge->>Loop: giveWayToOwner(model)
Loop->>Coord: capacity / 503 / draining, for each request still queued
Note over Coord: served on another Mac, or a retryable 429 if none has room
Note over Bridge: the owner's request is next in the queue
| Step | Behaviour |
|---|---|
| Who asks | The owner's request on a Mac with me first on: acquireModelForLocal gives its AcquiredModel (and Nemotron Super's lease) a makeRoomForOwner closure, which the local engine binds (MeFirstOwnerRequest.makeRoom) around the call that submits it. Coordinator requests, shared mode and Only me have none |
| When | EngineV2Bridge.watchOwnerWait (provider-swift/Sources/ProviderCore/Inference/Engine/Bridge/EngineV2Bridge+OwnerWait.swift) looks every 250 ms until the request's first token (queueState(of:)). No engine signal says that one request was admitted, so the bridge infers it. The engine admits waiting requests in arrival order (every request has the same priority), so a request waits while the engine's published waiting count is larger than the number of the bridge's live requests submitted after it. That count is published after each engine step and counts a request from its submission. The request asks only once it has stayed waiting across two steps, so one the engine admits at its next step never asks, and it asks again at every look while it still waits. A preempted request, requeued at the front, also reads as waiting: the inference errs toward giving way |
| Who gives way | giveWayToOwner(modelId:) (ProviderLoop+MeFirst.swift): each Darkbloom request on that model that is still queued, not yet in the engine or waiting in its queue (EngineV2Bridge.hasAdmitted(darkbloomRequest:), the same inference). The handler binds the request's coordinator id (MeFirstDarkbloomRequest.id) around the call that starts its stream, and the bridge records it with the request. One the engine put back in its queue (preempted) is queued again. It is cancelled as a coordinator cancel would be (handleCancellation) |
| What it sends | One terminal: capacity / 503 / error_reason draining, the refusal a racing dispatch gets (drainRefusal). A request that gave way before its stream started sends it from the handler |
| What never gives way | A request the engine has admitted, in its prompt or generating, keeps its work: re-routing it would throw that work away, and it could end in a 429. A request that has sent output never gives way either: its task claims the token before it sends its first content, reasoning or tool-call frame (claimOutput), and a request that gave way can't claim it, so it sends nothing after its refusal |
What the deployed coordinator does with that refusal, read in its code at
d7de2162f2:
- It serves the request on another Mac, or answers its client with a
retryable 429 when no other Mac can take it. Until the first content frame, the dispatch waits in
FirstWaitorAcceptedWait, where an error retries on another provider with this one excluded and drops the held role preamble (first_wait.go, accepted_wait.go). The client's response is written only after first content commits (dispatch.go), andinference_acceptedchanges nothing. A draining refusal doesn't use the transient-capacity retry allowance (retry/controller.go). - A re-routed request doesn't wait for capacity: an attempt after the first
fails fast when no Mac can take it now
(primary_run.go).
On a full network, or when its first-content budget can't cover its prompt
on another Mac, the client gets a retryable 429
rate_limit_exceeded, with aRetry-Afterof 2 to 30 seconds (dispatch.go). Work the engine has started never gives way, so this costs a re-routed request only its time in this Mac's queue. - It doesn't count against this Mac. A capacity-coded error records no failed
job in the reputation
(provider_inference.go).
A draining reason returns before every health breaker, the stable-identity
ejection and the capacity cooldown
(providerhealth/policy.go),
and the inference-error breaker counts only 500, 502 and 504
(error_cooldown.go).
Base rewards and the Autopilot floor come from session coverage and
earnings, not from request outcomes
(rewardpolicy/uptime.go).
The attempt's route row reads
provider_errorwithadmitted_but_failed, which only analytics read, and its metrics class iscapacity.
The owner's request then waits only for requests the engine has started, Darkbloom's or the owner's own, up to the engine's 120 s admission lease; after that it fails, as before. On a pair nothing gives way: a local request waits for one of the pair's lanes (pairs).
A pair served through Darkbloom has one owner pause, on its leader: the member
that hosts the pair's slot and runs the pair's local API beside Darkbloom
(the pair's leader takes local requests).
The rule is "the process that owns the local API owns the pause"
(provider-swift/Sources/ProviderCore/ProviderLoop+ClusterPairMeFirst.swift).
sequenceDiagram
participant Owner as Owner's tool
participant Leader as Leader member (slot and local API)
participant Coord as Coordinator
participant Member as Every other member
Owner->>Leader: local request starts waiting for a lane
Leader->>Coord: event heartbeat: draining, busy_reason owner
Note over Coord: the pair is not routable; its session stays
Coord--xLeader: racing dispatch
Leader->>Coord: capacity / 503 / draining
Owner->>Leader: last local request ends
Note over Leader: 2 idle minutes (resume timer, member beat)
Leader->>Coord: event heartbeat: idle or serving, no busy fields
Note over Member: control-only draining heartbeat, unchanged throughout
| Concern | Behaviour |
|---|---|
| Turning it on | darkbloom cluster starts the leader's local API when it serves the pair Both (ClusterServingChoice.both, no question since 0.10.12; it saves [local] me_first = false where none is saved, so the pause stays off unless me_first = true is set by hand): the cluster service adds --local-endpoint --port --bind to the rank-0 part (ClusterLocalServing.memberArguments). prepareClusterMemberControl calls enableClusterPairMeFirstIfConfigured once run() admits the leader's local API, before the API can take a request. It is on unless [local] says me_first = false, with [local]'s idle time. Whatever single-Mac mode [local] saved, a leader's local API beside Darkbloom serves both |
| The owner's use | noteClusterPairLocalUse forwards to noteLocalUse once per local request: from when it starts waiting for one of the pair's lanes, or takes one at once, until it leaves without one or releases it. So the pause begins before the request can wait behind Darkbloom work, and a request refused while the pair isn't serving never counts. A request on another Mac's own port is one of these too: that Mac's relay passes it to the leader's local API (inference), so the pair pauses for it the same way |
| Heartbeat | The leader's: draining with busy_reason: owner, beside its unchanged cluster_session |
| Racing dispatches | The leader's client forwards them while the slot exists, and rejectIfDraining refuses them with capacity / 503 / draining before they reach the pair |
| The idle time | The resume timer, and the member beat (clusterMemberHeartbeat, every 5 s), because a member runs no idle monitor. A stopping leader cancels the timer |
| Every other member | Untouched. Its part runs no local API (its own port is its cluster service's relay to the leader's), so nothing calls the hook there and me first stays off; its heartbeat stays control-only draining with no busy fields |
| What each Mac says | The leader's status lines, which every status on the other Mac asks for over the cable anyway, carry the pause under the pair's serving line (OnboardingLive.pauseLines, read from the leader part's own state file, MeFirstWords.pairLines): Pair: you first — Darkbloom paused for 1 minute (…; back in about 2 minutes if you stay idle). Times are said from now, never as a clock time. Nothing is added to the heartbeat or the link |
| Ranks | Nothing counts them: the leader is the slot's host, a role, not a rank |
darkbloom cluster local |
Unchanged: no member loop and no coordinator, so nothing to pause |
What a coordinator does with a draining leader:
- It stops routing to the whole pair, the owner's own
selfandpreferrequests included. - It keeps the pair's session: membership is an identity and trust decision, not an admission one, so a draining heartbeat never ends it.
The pair's base reward while it is paused depends on the coordinator. A single
Mac paused for its owner keeps its own on every coordinator, and
[local] me_first = false, or choosing Darkbloom network, avoids the pause
altogether.
- The coordinator that ships with 0.10.11
(darkbloom-platform#709
onwards): a pair paused for its owner keeps its base reward, as a single Mac
does, and stays unroutable. Its members' reward intervals count a leader
whose only drain is the owner pause as not draining (the pair must still
admit, have its model loaded and serve the public), while routing and the
owner's listing still treat the pause as a drain
(coordinator/registry/cluster_public_routing.go,
coordinator/internal/registry/providerdrain/authority.go).
Any other drain of the leader, such as an update, a shutdown or an add-on
hold, still ends them, as does a committed
provider_drainbarrier on any member. An update that starts during a pause ends them once its barrier commits or the pause ends, whichever is first, because the leader reportsowneruntil then. - Coordinators before #709, such as
90ee29fc0d, which production ran with 0.10.10: both Macs lose their base reward for the pause plus the 2 idle minutes, counted in 5-minute periods. In the coordinator at90ee29fc0d:- A member's base reward counts only the intervals in which its pair is publicly serving-ready (coordinator/internal/payments/rewardpolicy/uptime.go).
- Every member's heartbeat re-checks that (coordinator/registry/heartbeat.go), a draining leader fails it (coordinator/registry/cluster_public_routing.go), and that closes every member's interval (coordinator/registry/cluster_serving_intervals.go).
- Base rewards settle every 5 minutes (coordinator/internal/payments/rewardpolicy/epoch.go), and a period under 90% coverage pays nothing (coordinator/payments/baserewards/machine_candidates.go, coordinator/payments/baserewards/floor.go).
- A single Mac's own session counts whatever its status (coordinator/internal/payments/rewardpolicy/uptime.go, coordinator/registry/heartbeat.go).
The pause is event-driven:
- A local request's start and end are O(1) updates of the policy: no I/O, no heartbeat, no task. They run in the same actor turn as the reservation and its release, once per request, never per token.
- Heartbeats go out only when the pause begins and ends, beside the usual baseline.
- The end of the pause writes the daemon state file at once. Its start doesn't:
the start lands on the owner's request, and the loop already rewrites the
file every 2 s while serving, so
statusshows the pause within 2 s, as it shows the request counts. - The one timer is armed when the owner's idle time starts counting. It sleeps until the deadline, wakes at most once per idle time while the owner keeps working, and is gone once the pause ends.
- The coordinator and quote paths read one more flag under the lock they already take. Nothing runs per token.
- With me first off,
noteLocalUsereturns at once, and no timer or task exists. - An owner's request on a Mac with me first on has one more timer, from its submission to its first token: every 250 ms it reads the engine's published counts and the bridge's live requests, and only while it waits does it ask Darkbloom work to give way. Each ask looks each Darkbloom request on that model up among the bridge's live requests. Coordinator requests have no timer; the bridge keeps each one's coordinator id with the request.
- On a pair's leader, the member beat that already runs every 5 seconds adds one O(1) check, and the hook adds one call to each local request.
- A
statuson either Mac of a pair reads the pause once, from the leader part's state file, in the leader's status the other Mac already asks for: no new message, and nothing per request.
- An add-on hold outranks the pause. While both apply, the busy fields
describe the hold. Its release hands them back to the pause, which goes on
(
publishBusy,ProviderBusy.publishing). - Only the end of the last drain, hold or pause replays
desired_models. An update, model switch or hold that ends during the pause leaves them deferred, and a pause that ends under a drain or hold leaves them to it (replayDesiredModels). - Local admission never reads the pause:
throwIfRefusingNewLocalWorkis unchanged, andProviderState.refusingNewWorkstays apart fromownerPausesPublic. - A clock that goes back restarts the countdown from the new time, so the pause outlasts the jump by one idle time at most.
- The pause itself cancels nothing, and has no drain bound: Darkbloom work accepted before it that the engine has started runs to the end, unlike under an add-on hold. Work still queued gives way only while an owner's request waits in the same engine's queue, and then sends nothing more.
- The pause belongs to the serving process and isn't saved, unlike an add-on hold. A restart or update during a pause comes back open, and the owner's next request pauses again.
- A local request starts its use once and ends it once, however it ends.
acquireModelForLocalandreleaseLocalReservationcall the hooks in the same actor turn as the reservation and its release. Nothing after the start throws or suspends, so the request always gets itsOneShotRelease, which releases once; a release that drops no reservation ends no use.
darkbloom switchduring the pause can exit with an error, though the switch completes. After a switch, the coordinator reopens routing only on anidleorservingheartbeat (model replacement), and every heartbeat of the pause saysdraining. If the pause outlasts the provider's 30-second readiness wait (resumeAfterModelSwitch),darkbloom switchexits with the error "Model selection applied locally, but coordinator routing readiness is unconfirmed". The new selection is already serving locally, and the heartbeat that ends the pause reopens Darkbloom routing to it: nothing needs redoing.- Model revision activations and MTP idle upgrades don't wait for the pause. They wait for an idle model, so one can start in a gap between the owner's requests.
- The owner's own coordinator requests (
X-Darkbloom-Route: selforprefer) look like public work to the provider. They don't pause the Mac, and while it is paused they don't reach it:selfwaits (on today's coordinator up to 120 seconds, then429 machine_busy), andprefergoes to other Macs.
MeFirstPolicyTests pins the edges on a fake clock, including an idle time of
one minute at 59.9 s and 60 s and the two-minute default at 119.9 s and 120 s.
OwnerPauseLoopTests drives the loop without a serve loop, and
OwnerPauseWireTests checks the heartbeats on the wire against the loopback
mock coordinator. These loop tests skip the capacity rebuild
(capacityRebuildForTesting), which reads MLX's Metal allocator, so they run
without the GPU.
MeFirstSettingsTests pins where me first applies. LocalUseOwnerPauseTests
checks that startLocalEndpoint turns me first on as [local] says, and
sends requests through the local API's own HTTP application
(makeLocalEndpointApplication) to a slot whose engine the test scripts:
the pause and the resume, refused requests and the routes that are not use,
me_first = false with the heartbeat compared byte for byte, one start and
one end per request however it ends, and nothing per token.
MeFirstGiveWayTests runs encrypted coordinator requests and an owner's
request through the local engine on a scripted engine. Two network requests
run, one streaming and one in its prompt, and a third waits behind them; then
the owner's request waits too. Only the queued one gets the one
capacity / 503 / draining terminal and sends no output; the other two finish
untouched, and the owner's request runs when the one in its prompt ends. A
request the engine puts back in its queue gives way at the owner's next look.
A request that gives way in its handler, right after its token is registered
(afterTokenRegisteredForTesting) or as its stream would start, sends the one
refusal and never reaches the engine. An owner's request the engine admits
before two engine steps pass never asks; the test moves the engine's steps.
With me first off, nothing is re-routed. The coordinator requests' terminals read MLX's memory
counters, so the suite replaces that read (terminalMemoryForTesting) and runs
without the GPU.
ClusterPairMeFirstTests covers pairs with a scripted pair owner: the
leader's heartbeat, the racing refusal, work in flight, the member beat's two
minutes on a fake clock, a roster of three ranks, me first off and the cost.
Its two tests that complete Darkbloom requests need a Metal device, because
each request's terminal reads MLX's memory counters, but they submit no GPU
work.