Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions changelog.d/cluster-devnet-production-separate-pairs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
### DevNet and production no longer share a pair

- On a Mac with both the production app (`darkbloom`) and the DevNet app (`darkbloom-dev`), each app now keeps its own pairing, cluster setup, logs, cluster service and login job, each in its own folder (`~/.darkbloom` and `~/.darkbloom-dev`), and each app's pair uses its own ports on the cable. The DevNet app no longer reads the production app's pair, restarts its cluster service or removes its login job: `darkbloom-dev cluster pair --forget`, `darkbloom-dev cluster stop --service` and `darkbloom-dev uninstall` act on the DevNet app's pair only, and the production app's commands on its own only. This ends the 0.10.9 known limitation about the two apps on one Mac.
- Only one app's pair runs on a Mac at a time. Both apps take one device lock (`~/Library/Application Support/io.darkbloom.cluster/native-device.lock`, an empty file in a folder neither app owns) while a pair's part, a member's preparation or a GLM model check uses the GPU. The other app's pair then waits: its status says which app holds the Mac's GPU, and it starts by itself within seconds of that app's pair stopping. A wait never counts as a failing pair, so production never falls back to serving on its local API because DevNet held the Mac. A DevNet pair can no longer push a production pair out of memory.
- Production wins on a Mac both apps serve from. Production 0.10.10 and earlier take no lock, so the DevNet app also waits while a production serving process runs on that Mac (`darkbloom start`, a pair's part or its worker, read from the process list) or production's cluster service says its pair serves there (its published status, read only), and a running DevNet pair stops within seconds once production starts serving there (say both start at login). So a waiting DevNet pair never takes the GPU while production's pair restarts, for example for its update. DevNet never tells you to stop production: production serves there, and its owner decides.
- Providers with the production app alone see no other change: its files, its login job and its ports are the same as before, and its pair takes the device lock, which nothing else holds there.
- After this update the DevNet app starts unpaired, even on a Mac where it had paired, and copies nothing from the production app: update the DevNet app on both Macs, then run `darkbloom-dev cluster` on both to pair it again. If the DevNet app was the last to pair on a Mac before this update, the production app's `darkbloom cluster` may say the Secure Enclave key changed: choose **Pair again** there.
- The two apps still share the models and the cable port setup (one cable, one network setup). Uninstalling one app keeps the cable port setup while the other app is installed, so it asks for no password, and removes only its own pairing, cluster setup and cluster service; the other app's uninstall undoes the cable port setup later. `cluster link --remove` in one app now names the other app when that app still uses the port and asks first, even with `--yes`; without a terminal it changes nothing.
- A model copy between the two Macs stages in the shared model store under its own app's name (production's `.darkbloom-incoming-…` as before, DevNet's `.darkbloom-incoming-dev-…`). A copy short of disk space frees only its own app's abandoned copies, never the other app's copy under way.
77 changes: 63 additions & 14 deletions docs/architecture/inference.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Provider inference engine

> Last updated: 2026-11-05
> Last updated: 2026-11-06

How a chat-completion request is served inside the `darkbloom` provider
process: one in-process engine (`mlx-swift-lm`
Expand Down Expand Up @@ -542,17 +542,66 @@ lists it under Local Network or in its firewall reads `ClusterService.appName`
(`BuildEnvironment.current.appDisplayName`): the screens (through
`ClusterOnboardingCommand.app`, including the pairing hint's firewall line and
the line that asks to pair again after a reinstall) and the link follower's
refusal. Both apps serve a pair's API on port 8000,
so one of them serves a pair on a Mac at a time. Each keeps its own cluster
incident log, owned by `DarkbloomClusterRemote`
(`ClusterIncidentLog.defaultFile(homeDirectory:install:)`): production's is
`~/.darkbloom/cluster/incidents.json`, another install's its own file, such as
`incidents.dev.json`, which a build from before installs had their own files
never reads or rewrites; a corrupt one is kept beside it under its own name
(`incidents.corrupt.json`, `incidents.dev.corrupt.json`). `ClusterIncidentLog.files`
names a log's files: the log, its lock sidecar and that corrupt copy.
`darkbloom uninstall` removes an install's own with it while the shared folder
stays for the other install; production's shared `incidents.json` stays. Every
refusal.

Each build keeps its own cluster state, in its own folders (`ClusterUserPaths`,
from `BuildEnvironment.installDirectory` and `configDirectory`): the pairing
store, the setup and service folder (the service's lock, pid, status, update
request and logs, the screens' transcripts), the device folder (lease, journal,
link records, the prefix cache's key), the observability files and the saved
setups. Production's stay in `~/.darkbloom` and `~/.config/darkbloom`; DevNet's
are in `~/.darkbloom-dev` and `~/.config/darkbloom-dev`. The cluster service's
login job carries the build's prefix (`BuildEnvironment.clusterServiceLabelPrefix`),
and a build lists, replaces and removes only its own jobs
(`ClusterServiceAgentPlan.isOwnAgent`: a production-shaped job an older DevNet
build wrote is DevNet's by its program). The per-user locks are named after the
build's CLI (`ClusterConsoleInstanceLock.lockFileName`), the pair's prefix cache
is in the build's cache namespace (`ClusterPrefixCacheSettings.rootDirectoryName`),
and every port on the cable adds the build's `BuildEnvironment.clusterPortOffset`
(`ClusterCablePorts`). Two builds' pairs on the same Macs therefore never read,
stop or answer each other. Their device leases and journals are separate, but
every build's device scope (a pair's owner session, a member's preparation, a
GLM calibration) also takes one lock all builds share
(`ClusterMachineDeviceLock`: `~/Library/Application Support/io.darkbloom.cluster/native-device.lock`,
flock only, in a folder no app or build owns; `ClusterUserPaths.machineDeviceLock`),
after its own lease. So one build's native session never runs on the GPU beside
another's, and the refusal names the other app. A build other than production's
also refuses while production serves here, so production wins by default
(`ClusterMachineDeviceLock.productionServingHere`, read only, never
production's locks): a serving process of production's own app runs
(`productionServing`: `darkbloom start`, `cluster link-follower`, its worker
owner or its worker, run from production's folder, from the process table),
which covers production before 0.10.11 (it takes no lock), or production's
cluster service published within two minutes that its pair serves here
(`productionPairServes`: its `service-status.json`, `serving` and `pairRunning`),
which covers the seconds production's part restarts (an update, a crash). That
build's cluster service also stops its running part when production starts
serving (both start at login, say). The cluster service never starts its part
into a hold: `ClusterMachineDeviceLock.heldByAnotherBuild`
probes the lock shared and lets it go at once (a start at that moment retries
for up to 100 ms, `ClusterDeviceExclusion.machineLockTries`), and the part
waits (`ClusterOtherAppHold`), named in the status's `heldBack`. A part that
ended on the refusal never counts toward the local-only fallback
(`ClusterApprovalCheck.memberQuickEnds`), and the part starts on the first tick
after the hold ends, with its backoff and any approval set aside as failing
cleared (`blockerCleared`). Each
build's model copies stage under its own name in the store both share
(`ClusterModelStore.stagingPrefix`: production's `.darkbloom-incoming-<digest>`,
DevNet's `.darkbloom-incoming-dev-<digest>`), and a copy short of disk reclaims
only its own build's abandoned staging. They share the models, and the cable
port setup, which `darkbloom uninstall` keeps while the other build is
installed; `cluster link --remove` names another build whose link record still
holds the port and asks at a terminal (`ClusterLinkRepair.otherInstallsUsingCable`).
A port the other build set up is adopted with what its link record
says that setup changed (its bridge slot and the services it turned off), read
from that record and never written there
(`ClusterLinkRepair.Environment.otherInstallsIsolationEntries`), so the build
uninstalled last can still undo it all. Each
keeps its own cluster incident log, owned by `DarkbloomClusterRemote`
(`ClusterIncidentLog.defaultFile(installDirectory:install:)`): production's is
`~/.darkbloom/cluster/incidents.json`, DevNet's `~/.darkbloom-dev/cluster/incidents.dev.json`;
a corrupt one is kept beside it under its own name (`incidents.corrupt.json`,
`incidents.dev.corrupt.json`). Every
reader and writer opens this build's with
`ClusterIncidentLog.forThisInstall`. Each record also names the install that
wrote it (`ClusterIncident.install`), and a build reads only its own, counting
Expand Down Expand Up @@ -3943,8 +3992,8 @@ part the same key with a different file (`ClusterServiceAgent.partHealthPath`,
service's heartbeat and still waits for its registration as a supervised member.
An empty or absent key is passed on unchanged.

One cluster service runs per home: it holds an exclusive `flock` on
`~/.darkbloom/cluster-setup/service.lock` while it runs, and `ClusterService.running`
One cluster service runs per home and build: it holds an exclusive `flock` on
`~/.darkbloom/cluster-setup/service.lock` (DevNet's in `~/.darkbloom-dev`) while it runs, and `ClusterService.running`
reports whether one holds it. `darkbloom update --rollback` takes the same lock
(`ClusterService.holdStopped`) while it swaps the installed release, so no cluster
service starts on a release that is being replaced; a service that starts then
Expand Down
4 changes: 3 additions & 1 deletion docs/developer/build.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Build The Provider And Landing

> Last updated: 2026-11-05
> Last updated: 2026-11-06

Build the provider, its source-matched native resources, and the independent
landing site from this repository. Backend, sidecar, console and admin builds
Expand Down Expand Up @@ -710,9 +710,11 @@ tests use the production values.
| `legacyConfigDirectoryNames` | `.config/eigeninference` | none | none |
| `launchAgentLabel` | `io.darkbloom.provider` | `io.darkbloom.provider.dev` | `io.darkbloom.provider.staging` |
| `watchdogAgentLabel` | `io.darkbloom.watchdog` | `io.darkbloom.watchdog.dev` | `io.darkbloom.watchdog.staging` |
| `clusterServiceLabelPrefix` | `io.darkbloom.cluster-service.` | `io.darkbloom.cluster-service.dev.` | `io.darkbloom.cluster-service.staging.` |
| `logSubsystem` | `com.darkbloom.provider` | `com.darkbloom.provider.dev` | `com.darkbloom.provider.staging` |
| `serviceLogSubsystem` | `dev.darkbloom.provider` | `dev.darkbloom.provider.dev` | `dev.darkbloom.provider.staging` |
| `defaultLocalPort` | `8000` | `8001` | `8002` |
| `clusterPortOffset` | `0` | `10` | `20` |
| `keychainServicePrefix` | `io.darkbloom` | `io.darkbloom.dev` | `io.darkbloom.staging` |
| `encryptedCacheNamespace` | `darkbloom` | `darkbloom-dev` | `darkbloom-staging` |
| `modelRevisionRef` | `main` | `darkbloom-dev` | `darkbloom-staging` |
Expand Down
18 changes: 14 additions & 4 deletions docs/operations/provider-release.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Release A Provider Version

> Last updated: 2026-11-04
> Last updated: 2026-11-06

Build, sign, notarize and publish an explicitly authorized provider artifact.
The pipeline registers its exact official identity through the external platform
Expand Down Expand Up @@ -375,9 +375,17 @@ is historical; verify current endpoints with the platform owner.

A dev build installs and runs beside a production provider on the same Mac.
The two installs do not share a path, a port, a launchd label or a keychain
item, and each command prints its own name in its help text. The table is a
generated copy of `provider-swift/identity/provider-identity.json`, the only
declaration of these values:
item, and each command prints its own name in its help text. That includes the
two-Mac cluster: each install keeps its own pairing, cluster setup, service
lock and observability files in its own folders (`ClusterUserPaths`), its
cluster service's login job carries `clusterServiceLabelPrefix`, its per-user
cluster locks are named after `cliName`, and the ports its pair uses on the
cable add `clusterPortOffset` (`ClusterCablePorts`). Shared on purpose: the
models, the cable port setup, the sweep of cluster processes whose parent is
gone, and the range the pair's local API port is chosen from (8000 to 8020). The
table is a generated copy of
`provider-swift/identity/provider-identity.json`, the only declaration of these
values:

<!-- BEGIN provider identity: generated from provider-swift/identity/provider-identity.json by scripts/generate-provider-identity.py; do not edit -->

Expand All @@ -395,9 +403,11 @@ declaration of these values:
| `legacyConfigDirectoryNames` | `.config/eigeninference` | none | none |
| `launchAgentLabel` | `io.darkbloom.provider` | `io.darkbloom.provider.dev` | `io.darkbloom.provider.staging` |
| `watchdogAgentLabel` | `io.darkbloom.watchdog` | `io.darkbloom.watchdog.dev` | `io.darkbloom.watchdog.staging` |
| `clusterServiceLabelPrefix` | `io.darkbloom.cluster-service.` | `io.darkbloom.cluster-service.dev.` | `io.darkbloom.cluster-service.staging.` |
| `logSubsystem` | `com.darkbloom.provider` | `com.darkbloom.provider.dev` | `com.darkbloom.provider.staging` |
| `serviceLogSubsystem` | `dev.darkbloom.provider` | `dev.darkbloom.provider.dev` | `dev.darkbloom.provider.staging` |
| `defaultLocalPort` | `8000` | `8001` | `8002` |
| `clusterPortOffset` | `0` | `10` | `20` |
| `keychainServicePrefix` | `io.darkbloom` | `io.darkbloom.dev` | `io.darkbloom.staging` |
| `encryptedCacheNamespace` | `darkbloom` | `darkbloom-dev` | `darkbloom-staging` |
| `modelRevisionRef` | `main` | `darkbloom-dev` | `darkbloom-staging` |
Expand Down
Loading
Loading