Skip to content

Add Swift provider runtime - #110

Merged
Gajesh2007 merged 34 commits into
masterfrom
swift-provider
May 15, 2026
Merged

Gajesh2007 merged 34 commits into
masterfrom
swift-provider

Conversation

@Gajesh2007

Copy link
Copy Markdown
Member

Summary

Adds the Swift-native provider package under provider-swift/, wired to local MLX submodules and Hummingbird for the standalone OpenAI-compatible endpoint surface.

This also updates the coordinator trust path for the Swift provider cutover:

  • accepts the canonical mlx-swift backend for private text routing
  • makes Swift runtime verification backend-aware instead of requiring Python/vllm runtime hashes
  • makes binary hash policy fail closed when configured
  • requires challenge binary hashes to match the registration attestation hash
  • preserves RDMA status reporting without treating RDMA enabled as an automatic hypervisor failure

The PR includes new focused tests for Swift runtime eligibility and binary-hash registration/challenge enforcement.

Submodule note

This PR adds:

  • libs/mlx-swift at 49d73ab
  • libs/mlx-swift-lm at 3ec4b8a

The mlx-swift-lm commit is on Gajesh2007/mlx-swift-lm:codex/local-mlx-swift-dependency and changes its Package.swift to use the sibling local ../mlx-swift submodule. That is needed so the parent repo can resolve both MLX packages locally during SwiftPM builds.

Validation

  • swift build --package-path provider-swift
  • swift test --package-path provider-swift
  • go test ./internal/api
  • go test ./internal/registry
  • git diff --cached --check

@vercel

vercel Bot commented May 1, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
d-inference Ready Ready Preview May 15, 2026 5:20pm
d-inference-console-ui-dev Ready Ready Preview May 15, 2026 5:20pm
d-inference-landing Ready Ready Preview May 15, 2026 5:20pm

Request Review

@Gajesh2007

Copy link
Copy Markdown
Member Author

@codex Review this

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b56b240188

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread coordinator/internal/api/provider.go Resolved
…Labs forks

This is the v0.5.0 cutover commit on the Swift provider PR. It lands
true continuous batching as the production inference path, threads
per-row sampling through the request, hard-fails on CPU-only hosts,
renames the user-visible CLI surface from "eigeninference" to
"darkbloom" with backward compatibility, and re-homes the mlx-swift /
mlx-swift-lm submodules to Layr-Labs forks.

Continuous batching (default, no parallel implementations)
----------------------------------------------------------
Replaces the per-request BatchScheduler with one shared BatchGenerator
ported from upstream `mlx_lm.generate`. All concurrent requests are
merged into one batched forward pass per step. Bit-identical against
single-stream greedy on:
  - Qwen3 0.6B-8bit (dense), B=2 / B=4-ragged
  - Qwen3.5 0.8B-MLX-4bit (hybrid SSM + attention), B=2
  - Gemma 4 26B-A4B-it-8bit (MoE, 26 GB), B=2

The mlx-swift-lm side of this work is at
Layr-Labs/mlx-swift-lm@darkbloom-continuous-batching:
  - BatchKVCache + BatchedCache protocol
  - SequenceStateMachine, PromptProcessingBatch, GenerationBatch,
    BatchGenerator
  - RowSamplers (temperature / top-P / top-K / seed)
  - Gemma 4 MoE support + K=V branch fix in Gemma4Attention

Production scheduler in provider-swift/Sources/ProviderCore/Inference/
BatchScheduler.swift wraps the engine in an actor; detached worker
calls into the actor only for short critical sections so cancel/submit
never queue behind a long-running step. submit() builds a per-row
sampler from request.{temperature, top_p, top_k, seed}.

Validation also covers eviction-and-admission: row 0 finishes mid-batch,
row C is admitted into its slot, row C's tokens match a solo run, row B
(running through the eviction) also matches its solo run. This locks in
BatchKVCache.filterBatched + extendBatched correctness end-to-end.

Sampler unit tests cover greedy passthrough, top-K=1 determinism,
top-K masking, top-P collapse-to-dominant, top-P=1 identity, seeded
reproducibility, and different-seed divergence.

GPU-only enforcement
--------------------
ProviderCore/Inference/GPUEnforcement.swift:
  - probeMetal(): non-throwing Metal device probe
  - requireMetal(): throws on missing GPU; pins Device.setDefault(.gpu);
    idempotent

Wired into BatchScheduler.loadModel, StartCommand, BenchmarkCommand,
and `darkbloom doctor`. Doctor surfaces a `[PASS] metal gpu: <name>,
<N> GB working set` line; `[FAIL]` on Intel/Linux. CPU fallback for
inference is rejected up-front with a descriptive error.

Rename: eigeninference → darkbloom (Swift CLI surface)
------------------------------------------------------
Canonical names:
  - eigeninference-enclave  → darkbloom-enclave (binary + struct)
  - Sources/eigeninference-enclave-cli/ → Sources/darkbloom-enclave-cli/
  - SwiftPM target EigenInferenceEnclaveCLI → DarkbloomEnclaveCLI
  - eigeninference-bundle-macos-arm64.tar.gz →
    darkbloom-bundle-macos-arm64.tar.gz
  - ~/.config/eigeninference/ → ~/.config/darkbloom/ (preferred path)
  - Mobileconfig prefix: EigenInference-Enroll-* → Darkbloom-Enroll-*

Backward compatibility:
  - install.sh creates a `eigeninference-enclave` symlink to
    `darkbloom-enclave` so existing install scripts keep resolving.
  - Config loader still reads ~/.config/eigeninference/ and the App
    Support legacy paths as fallbacks; new writes always go to
    ~/.config/darkbloom/.
  - LocalDataCleanup.purge() removes both directories.
  - release-swift.yml publishes the latest tarball under both
    canonical and legacy filenames.
  - NodeKeyPair.legacyDirNames and SecurityHardening MDM-profile-name
    matchers still accept the old name.
  - Coordinator/Rust/UI surfaces (R2 buckets, Stripe descriptors,
    Solana memos, telemetry source attribution) intentionally
    untouched.

CLI subcommands shipped in v0.5.0
---------------------------------
darkbloom serve / start / stop, status, doctor, models {list, catalog,
download, remove}, enroll, unenroll, login, logout, logs, autoupdate,
benchmark, update, verify. start --foreground is the launchd
entrypoint; start --local --port N runs a standalone OpenAI-compatible
HTTP server. PID-file single-instance enforcement, caffeinate-based
sleep prevention, panic-hook telemetry, and metallib hash in
attestation are all wired in.

Submodule re-homing
-------------------
.gitmodules now points to Layr-Labs/mlx-swift and Layr-Labs/mlx-swift-lm.
The mlx-swift pointer is unchanged (clean `main`). The mlx-swift-lm
pointer advances from 3ec4b8a (codex/local-mlx-swift-dependency) to
91612d5 (darkbloom-continuous-batching) which carries the batching
engine + Gemma 4 MoE fork on Layr-Labs/mlx-swift-lm.

Tests
-----
135 / 135 tests pass in 16.5 s with DARKBLOOM_LIVE_MLX_TESTS=1 and
DARKBLOOM_LIVE_MLX_GEMMA=1 (live MLX inference against real models
plus the gated 27 GB Gemma generation test).
Layr-Labs/mlx-swift-lm@main now carries the continuous-batching engine,
per-row samplers, and Gemma 4 MoE port at 8d76944. Same tree as the
prior 91612d5 commit on the darkbloom-continuous-batching branch, but
without the local-path mlx-swift dep hack, so the fork is consumable
by URL outside this repo.
@Gajesh2007

Copy link
Copy Markdown
Member Author

@codex can you review this

The .claude/ directory holds local agent state (cursor task files,
working notes, the in-progress migration plan). Those don't belong in
the repo. Untrack the two committed markdown files and broaden the
.gitignore from `.claude/worktrees/` to `.claude/` so future agent runs
don't add them back. Strip the dead links to .claude/swift-migration-plan.md
from CLAUDE.md, provider-swift/README.md, docs/ARCHITECTURE.md, and
scripts/fetch-metallib.sh -- the surrounding prose stands on its own.

The local files remain on disk for active reference; only the tracking
is removed.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1a3ee7834f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread coordinator/api/install.sh Resolved
Two related additions to the provider's model lifecycle:

1) Idle-timeout unload
----------------------
ProviderLoop now runs a background monitor that polls every minute.
If `idleTimeoutMins` minutes (default 60) have elapsed since the last
inference activity AND no requests are in flight, the loaded
ModelContainer is dropped. The next inference request lazy-reloads.
`idleTimeoutMins == 0` disables the monitor; the model stays
resident forever.

The decision is extracted into `IdleTimeoutPolicy.shouldUnload(...)`
so the rule is unit-testable without spinning up the full ProviderLoop
actor (which depends on Secure Enclave, coordinator client, and
security posture). Five unit tests pin the policy: (a) unloads when
all conditions met, (b) never unloads with inflight requests,
(c) never unloads with no model loaded, (d) waits for the timeout to
elapse, (e) zero-timeout edge case is still defensive.

Activity tracking: `lastInferenceAt` updates on every request
admission and on every request finish (`removeInflightTask`). The
worker is a detached `Task` so cancel/submit on the actor never
queue behind the timer.

2) Coordinator-driven model preload
-----------------------------------
New WebSocket message `coordinator → provider: load_model`. The
provider has no inbound listener (security: a discovered IP can't
reach the GPU), so the coordinator pushes preload requests over the
existing outbound WebSocket connection that the provider opened.
Use case: the coordinator predicts demand for model X on machine Y
in the next hour and warms it ahead of time.

Provider behavior:
  - If model is already loaded: short-circuit, reply succeeded.
  - Otherwise: emit `load_model_status` "started" immediately,
    kick off `ensureModelLoaded` in a detached Task, then emit
    "succeeded" or "failed" (with an error string) when the load
    settles.

Wire surface added in three places (per AGENTS.md sync rule):
  - coordinator/internal/protocol/messages.go: `TypeLoadModel`,
    `TypeLoadModelStatus`, `LoadModelMessage`, `LoadModelStatusMessage`,
    plus the `LoadModelStatusStarted/Succeeded/Failed` constants.
  - provider-swift/.../Protocol/Messages.swift: new
    `CoordinatorMessage.loadModel(...)` case + `ProviderMessage
    .loadModelStatus(...)` case + Codable on both sides.
  - provider-swift/.../Coordinator/CoordinatorClient.swift: dispatch
    inbound `load_model` to a new `CoordinatorEvent.loadModel(modelId)`
    and add `OutboundMessage.loadModelStatus(...)` for the reply.

ProviderLoop wires `handleLoadModelRequest(modelId:send:)` for the
new event. Round-trip tests cover decoding a Go-style `load_model`
JSON and encoding all three lifecycle status replies (started /
succeeded / failed-with-error) with snake_case wire keys.

Rust legacy provider intentionally untouched. The coordinator
should gate `load_model` dispatch on `backend == "mlx-swift"` so
the Rust path never receives an unknown message; that gate lives
on the coordinator side and isn't part of this commit.

Tests
-----
141 / 141 tests pass with DARKBLOOM_LIVE_MLX_TESTS=1 and
DARKBLOOM_LIVE_MLX_GEMMA=1 (live MLX inference + Gemma 4 26B-A4B-it-8bit
MoE batching included). New: 5 IdleTimeoutPolicy tests + 1
loadModel round-trip protocol test.
The errorResponse function only populated type and message, missing
code and param required by the OpenAI API spec. Without code, SDKs
cannot programmatically distinguish error types (e.g. Python SDK
e.code returns None, retry logic breaks, Sentry groups all errors
as one).

Changes:
- errorResponse now accepts optional errorDetailOpt variadic args
- code defaults to errType for backward compatibility
- withParam() and withCode() helpers for call-site overrides
- model-not-found errors include param="model"
- model-is-required errors include param="model"
- insufficient_funds uses OpenAI-canonical code "insufficient_quota"
- rate_limit_exceeded gets explicit withCode for clarity

All 202 existing call sites are backward-compatible: the variadic
signature means they compile unchanged, and the default code=errType
matches the implicit behavior SDKs already assumed.

Closes #142
* Fix Darkbloom analytics tracking

* Harden release workflow protections (#103)

* Harden release registration and binary hash policy (#99)

* Harden release registration and binary hash policy

* derive release download URL from allowlist

* Stabilize provider coordinator test

---------

Co-authored-by: Gajesh Naik <26431906+Gajesh2007@users.noreply.github.com>

* Remove stale Python integration test (#109)

* e2e: add local simulation environment skeleton

Introduces scripts/e2e-runner.py, a Python orchestrator that spins up the
real coordinator binary with test-friendly configuration (in-memory store,
mock billing, no trust requirements) alongside a simulated or real
provider, and runs HTTP/WebSocket-level assertions against the live stack.

Key components:
- Coordinator class: builds and spawns coordinator with EIGENINFERENCE_MIN_TRUST=none,
  EIGENINFERENCE_BILLING_MOCK=true, and in-memory store
- SimulatedProvider: pure-Python WebSocket client speaking the full provider protocol
  (register, attestation challenge/response, heartbeat, inference request/response)
- Test framework: decorator-based test registration, pass/fail summary, signal-safe
  cleanup via atexit + signal handlers
- Test stubs: test_basic (registration + discovery), test_inference (consumer
  request routing), test_multi_provider (two providers, same model)

TODO:
- RealProvider wrapper around darkbloom serve --coordinator
- Coordination between provider challenge cycle and consumer request timing
- API key handling for consumer vs admin routes
- Python dependency management (websockets, cryptography)

* Revert "e2e: add local simulation environment skeleton"

This reverts commit d02074e. The Python E2E runner adds noise on top of
the existing Go integration tests (internal/api/integration_test.go +
fullstack_integration_test.go) which already cover the full coordinator
protocol surface. The cross-language orchestration doesn't buy anything
over what httptest.Server + simulated providers already provide.

* Remove stale Python integration test

@ethenotethan

tests/integration_test.py is superseded by the Go-based coordinator
integration tests at coordinator/internal/api/:

- Test coverage for coordinator protocol (register, challenge, heartbeat,
  inference) is covered by integration_test.go using httptest.Server +
  Go simulated providers — same coverage, no binary build needed
- Full-stack GPU inference is covered by fullstack_integration_test.go
  with real vllm-mlx backends (gated behind LIVE_FULLSTACK_TEST=1)
- The Python test uses stale binary names ('eigeninference-provider'),
  old flags ('--backend mlx-lm'), and predates attestation challenges,
  E2E encryption, and the vllm-mlx backend migration
- No external dependency coverage (Postgres, Stripe, etc.) is lost — the
  coordinator main.go wiring for those is trivially tested elsewhere
- The Python SDK tests (4.5.x) belong in the SDK repo, not the infra repo

---------

Co-authored-by: Hank Bob <hankbob@researchoors.com>

* chore: remove unused dependencies (#112)

* chore: remove unused dependencies

* test: fix console ui test isolation

* chore: prune repo-wide dead code findings

* ci: run CI on any PR, not just master/main (#119)

* ci: remove racing deploy-dev-coordinator workflow (#137)

Cloud Build (deploy/gcp/cloudbuild.yaml) already deploys the coordinator
on the same trigger (push to master touching coordinator/** or deploy/gcp/**).
Having both paths active creates a race condition where two CI systems
simultaneously deploy to the same dev VM — see #115.

* feat: add Datadog observability stack for dev coordinator

Install Datadog Agent on the dev GCE VM (DogStatsD, APM, journald logs)
and wire the coordinator to emit structured metrics, split attestation
counters, model_type tags, reactive provider-count gauges, and a
completion-tokens counter. Rebuild the dev dashboard with 7 sections
covering metrics, logs, traces, and system health.

* fix: prevent double-decrement when untrusted provider disconnects

Disconnect now checks StatusUntrusted before decrementing the online
counter and model-provider gauges, since MarkUntrusted already
decremented them.

* feat: add fleet version and binary hash observability

New metrics:
- providers.per_version gauge (per provider binary version)
- providers.per_binary_hash gauge (per attested binary hash)
- coordinator.min_provider_version_set gauge (1 when configured)
- provider_version_below_minimum counter (tagged by gate and version)

Gates instrumented:
- registration (provider.go)
- challenge revalidation (provider.go)
- manifest sync (server.go)

Registry additions:
- ProviderCountByVersion()
- ProviderCountByBinaryHash()

Dashboard: Fleet Version & Binary Hash group with providers by version,
providers by binary hash, min provider version, below-minimum events,
and top binary hashes toplist.

* fix: update Dockerfile + cloudbuild for go.mod at repo root

go.mod moved from coordinator/ to repo root during the swift-provider
merge. Build context is now repo root, Dockerfile copies coordinator/
subdir explicitly.

* fix: chmod +x coordinator binary in Dockerfile

* fix: ensure coordinator binary is executable in builder stage

* fix: rename coordinator source dir in builder to avoid colliding with binary path

* fix: copy full repo in Dockerfile builder so go.mod resolves all packages

* fix: remove unused modelTypeTag and format Go files for CI

* fix: skip python/dangerous-modules check for swift runtime in private text gate

* billing telemetry + MarkUntrusted race fix + Swift routing tests

- Add Datadog histogram metrics for reservation amounts, settlement
  refunds, provider credits, and platform fees
- Add store.debit/credit.latency_ms histograms for DB operation timing
- Add billing.cost_clamped and billing.reservation_refunds counters
- Fix race in MarkUntrusted: hold r.mu write lock through counter
  decrement to prevent double-decrement with Disconnect
- Add unit tests for Swift provider privacy caps (with/without Python)
- Add E2E test for Swift provider routing via challenge-verified path
- Update dev-network-dashboard.json with Billing & Store group

* fix Heartbeat reviving untrusted providers causing onlineCount double-decrement

* revert orthogonal landing/console-ui/provider changes

* remove unbounded binary_hash cardinality, add input token metrics + store latency, fix dashboard group-by

* fix review feedback: ModelType() untrusted filter, routing.cost_ms by provider, billing in cents, dead comment

---------

Co-authored-by: Gajesh Naik <26431906+Gajesh2007@users.noreply.github.com>
Co-authored-by: anupsv <6407789+anupsv@users.noreply.github.com>
Co-authored-by: hankbob <hankbobtheresearchoor@gmail.com>
Co-authored-by: Hank Bob <hankbob@researchoors.com>
Master had 8 commits ahead; 7 were already incorporated via PR #143
(Datadog observability), which folded them as sub-commits into the new
coordinator/api/ directory structure. The only novel master commit was
85cedc7 (workflow version-comment fix), which auto-merged into ci.yml,
claude.yml, and codex.yml.

Conflict resolutions:
- Deleted: legacy Rust release.yml (replaced by release-rust-bridge.yml
  + release-swift.yml on swift-provider)
- Deleted: legacy SwiftUI app/EigenInference/ (removed by Swift CLI migration)
- Deleted: coordinator/internal/api/release_handlers.go (moved to
  coordinator/api/release_handlers.go in the restructure)
- Deleted: docs/release-runbook.md (superseded by coordinator-deploy-runbook.md)
- Took swift-provider version for the 3 coordinator/api/*.go content
  conflicts (master's edits to the old paths are already present at
  the new paths)

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: eaf35c1bee

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread .github/workflows/release-swift.yml Resolved
Comment thread .github/workflows/release-swift.yml Resolved
@github-actions

github-actions Bot commented May 15, 2026 •

Copy link
Copy Markdown
Contributor

Benchmark Results

Runner: macos-15 (M1 Virtual) | Date: 2026-05-15 17:25 UTC

1-provider-streaming

1 providers, 1 users, 30 requests, concurrency=5, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 1 0.5 GB
Metric Value
Total Requests 30
Success 30
Errors 0
Total Duration 11.124s
Throughput 2.7 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 30 814ms 5ms 3.394s 7.491s
parse 30 36µs 13µs 198µs 215µs
reserve 30 1ms 1ms 5ms 6ms
route 30 358ms 0s 772ms 7.473s
queue_wait 8 1.342s 575ms 7.473s 7.473s
encrypt 30 144µs 139µs 185µs 191µs
dispatch 30 20µs 18µs 39µs 45µs
coordinator_to_provider 30 453ms 2ms 3.385s 3.386s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=35.566µs (threshold=1ms)
parse:p95<=5ms PASS p95=198µs (threshold=5ms)
reserve:mean<=50ms PASS mean=1.3583ms (threshold=50ms)
reserve:p95<=200ms PASS p95=4.645ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=144.466µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=185µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=19.8µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=39µs (threshold=50ms)

1-provider-non-streaming

1 providers, 1 users, 20 requests, concurrency=5, streaming=false

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 1 0.5 GB
Metric Value
Total Requests 20
Success 20
Errors 0
Total Duration 5.565s
Throughput 3.6 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 20 1.37s 546ms 4.145s 4.145s
parse 20 17µs 16µs 38µs 38µs
reserve 20 1ms 1ms 5ms 5ms
route 20 255ms 0s 3.74s 3.74s
queue_wait 4 1.276s 536ms 3.74s 3.74s
encrypt 20 146µs 138µs 186µs 186µs
dispatch 20 22µs 16µs 100µs 100µs
coordinator_to_provider 20 630ms 4ms 3.14s 3.14s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=17.35µs (threshold=1ms)
parse:p95<=5ms PASS p95=38µs (threshold=5ms)
reserve:mean<=50ms PASS mean=1.47875ms (threshold=50ms)
reserve:p95<=200ms PASS p95=5.29ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=145.95µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=186µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=21.95µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=100µs (threshold=50ms)

7-provider-multi-model

7 providers, 5 users, 50 requests, concurrency=10, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 4 0.5 GB
mlx-community/gemma-3-270m-4bit 3 0.2 GB
Metric Value
Total Requests 50
Success 50
Errors 0
Total Duration 51.245s
Throughput 1.0 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 50 5.028s 98ms 27.816s 28.204s
parse 50 43µs 23µs 104µs 269µs
reserve 50 7ms 2ms 34ms 44ms
route 50 1.402s 0s 10.005s 20.011s
queue_wait 10 2.006s 2.783s 3.775s 3.775s
encrypt 50 168µs 148µs 380µs 442µs
dispatch 50 44µs 35µs 119µs 195µs
coordinator_to_provider 50 3.612s 9ms 27.525s 28.169s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=42.88µs (threshold=1ms)
parse:p95<=5ms PASS p95=104µs (threshold=5ms)
reserve:mean<=50ms PASS mean=6.5583ms (threshold=50ms)
reserve:p95<=200ms PASS p95=34.48ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=168.36µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=380µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=43.62µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=119µs (threshold=50ms)

3-provider-high-concurrency

3 providers, 10 users, 60 requests, concurrency=20, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 3 0.5 GB
Metric Value
Total Requests 60
Success 60
Errors 0
Total Duration 16.08s
Throughput 3.7 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 60 3.756s 1.494s 11.245s 11.369s
parse 60 60µs 39µs 187µs 234µs
reserve 60 22ms 6ms 82ms 99ms
route 60 2.202s 1.275s 10.773s 11.028s
queue_wait 44 3.004s 1.338s 10.773s 11.03s
encrypt 60 231µs 170µs 471µs 706µs
dispatch 60 0s 0s 0s 1ms
coordinator_to_provider 60 1.508s 9ms 7.328s 7.355s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=59.9µs (threshold=1ms)
parse:p95<=5ms PASS p95=187µs (threshold=5ms)
reserve:mean<=50ms PASS mean=22.430566ms (threshold=50ms)
reserve:p95<=200ms PASS p95=81.56ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=231.133µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=471µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=79.483µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=301µs (threshold=50ms)

1-provider-queue-saturation

1 providers, 10 users, 40 requests, concurrency=15, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 1 0.5 GB
Metric Value
Total Requests 40
Success 40
Errors 0
Total Duration 12.826s
Throughput 3.1 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 40 3.643s 3.727s 5.982s 6.996s
parse 40 49µs 35µs 183µs 213µs
reserve 40 6ms 2ms 18ms 26ms
route 40 3.253s 3.549s 5.938s 6.947s
queue_wait 33 3.944s 3.701s 5.938s 6.947s
encrypt 40 231µs 170µs 439µs 585µs
dispatch 40 44µs 27µs 150µs 202µs
coordinator_to_provider 40 374ms 4ms 3.708s 3.708s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=48.95µs (threshold=1ms)
parse:p95<=5ms PASS p95=183µs (threshold=5ms)
reserve:mean<=50ms PASS mean=5.6864ms (threshold=50ms)
reserve:p95<=200ms PASS p95=17.661ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=231.4µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=439µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=43.8µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=150µs (threshold=50ms)

3-provider-20-users

3 providers, 20 users, 60 requests, concurrency=10, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 3 0.5 GB
Metric Value
Total Requests 60
Success 60
Errors 0
Total Duration 13.13s
Throughput 4.6 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 60 906ms 25ms 5.06s 5.064s
parse 60 0s 0s 0s 4ms
reserve 60 10ms 7ms 35ms 50ms
route 60 46ms 0s 689ms 692ms
queue_wait 6 461ms 689ms 692ms 692ms
encrypt 60 229µs 145µs 478µs 819µs
dispatch 60 64µs 35µs 198µs 720µs
coordinator_to_provider 60 837ms 11ms 4.98s 5.001s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=139.483µs (threshold=1ms)
parse:p95<=5ms PASS p95=407µs (threshold=5ms)
reserve:mean<=50ms PASS mean=9.894533ms (threshold=50ms)
reserve:p95<=200ms PASS p95=34.692ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=229.4µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=478µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=63.966µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=198µs (threshold=50ms)

1-provider-scaling

1 providers, 5 users, 30 requests, concurrency=10, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 1 0.5 GB
Metric Value
Total Requests 30
Success 30
Errors 0
Total Duration 11.432s
Throughput 2.6 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 30 2.845s 2.278s 5.926s 5.926s
parse 30 29µs 24µs 55µs 84µs
reserve 30 3ms 2ms 9ms 10ms
route 30 2.258s 2.134s 5.904s 5.905s
queue_wait 22 3.08s 2.273s 5.904s 5.905s
encrypt 30 177µs 144µs 385µs 446µs
dispatch 30 38µs 24µs 74µs 335µs
coordinator_to_provider 30 580ms 3ms 4.326s 4.327s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=28.566µs (threshold=1ms)
parse:p95<=5ms PASS p95=55µs (threshold=5ms)
reserve:mean<=50ms PASS mean=3.172866ms (threshold=50ms)
reserve:p95<=200ms PASS p95=9.016ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=176.6µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=385µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=37.8µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=74µs (threshold=50ms)

3-provider-scaling

3 providers, 5 users, 30 requests, concurrency=10, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 3 0.5 GB
Metric Value
Total Requests 30
Success 30
Errors 0
Total Duration 8.974s
Throughput 3.3 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 30 1.722s 15ms 5.227s 5.228s
parse 30 78µs 41µs 146µs 772µs
reserve 30 6ms 4ms 21ms 22ms
route 30 30µs 24µs 87µs 96µs
encrypt 30 0s 0s 1ms 1ms
dispatch 30 51µs 36µs 179µs 265µs
coordinator_to_provider 30 1.703s 11ms 5.176s 5.187s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=78.366µs (threshold=1ms)
parse:p95<=5ms PASS p95=146µs (threshold=5ms)
reserve:mean<=50ms PASS mean=6.4777ms (threshold=50ms)
reserve:p95<=200ms PASS p95=21.198ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=272.366µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=1.01ms (threshold=50ms)
dispatch:mean<=5ms PASS mean=50.933µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=179µs (threshold=50ms)

5-provider-scaling

5 providers, 5 users, 30 requests, concurrency=10, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 5 0.5 GB
Metric Value
Total Requests 30
Success 30
Errors 0
Total Duration 14.333s
Throughput 2.1 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 30 2.983s 26ms 9.104s 9.106s
parse 30 61µs 41µs 190µs 443µs
reserve 30 9ms 4ms 35ms 49ms
route 30 44µs 30µs 158µs 262µs
encrypt 30 187µs 133µs 379µs 946µs
dispatch 30 48µs 32µs 98µs 266µs
coordinator_to_provider 30 2.969s 20ms 9.048s 9.087s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=60.533µs (threshold=1ms)
parse:p95<=5ms PASS p95=190µs (threshold=5ms)
reserve:mean<=50ms PASS mean=9.242ms (threshold=50ms)
reserve:p95<=200ms PASS p95=35.116ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=187.066µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=379µs (threshold=50ms)
dispatch:mean<=5ms PASS mean=47.8µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=98µs (threshold=50ms)

3-provider-heavy-100conc-10kb

3 providers, 20 users, 100 requests, concurrency=100, streaming=true

Model Providers RAM
mlx-community/Qwen3.5-0.8B-MLX-4bit 3 0.5 GB
Metric Value
Total Requests 100
Success 100
Errors 0
Total Duration 29.108s
Throughput 3.4 req/s

Latency Decomposition

Segment Count Mean P50 P95 Max
total_e2e 100 17.411s 18.547s 26.27s 27.737s
parse 100 0s 0s 2ms 9ms
reserve 100 41ms 42ms 49ms 72ms
route 100 16.542s 18.407s 25.968s 27.568s
queue_wait 88 18.799s 19.748s 25.969s 27.572s
encrypt 100 1ms 0s 2ms 48ms
dispatch 100 0s 0s 1ms 2ms
coordinator_to_provider 100 762ms 28ms 6.119s 6.152s

Assertion Report: PASS

Assertion Result Detail
parse:mean<=1ms PASS mean=391.85µs (threshold=1ms)
parse:p95<=5ms PASS p95=1.582ms (threshold=5ms)
reserve:mean<=50ms PASS mean=40.80705ms (threshold=50ms)
reserve:p95<=200ms PASS p95=48.699ms (threshold=200ms)
encrypt:mean<=5ms PASS mean=971.5µs (threshold=5ms)
encrypt:p95<=50ms PASS p95=1.525ms (threshold=50ms)
dispatch:mean<=5ms PASS mean=194.01µs (threshold=5ms)
dispatch:p95<=50ms PASS p95=692µs (threshold=50ms)

Twelve fixes informed by three reviewer subagents (codex-rescue,
independent Claude, full pipeline audit) to ensure the bridge release
→ Swift release cutover works on first try, with no silent breakage.

Coordinator:
- accept darkbloom-bundle-<platform>.tar.gz (was eigeninference-bundle-)
- restore TestProviderRegistrationWithoutAttestationRejectedWhenBinaryHashPolicyConfigured
  (dropped during the master→swift-provider merge)

release-swift.yml:
- ship bin/{darkbloom,darkbloom-enclave,mlx.metallib} as real-file copies
  (was symlinks) so coordinator's tar.TypeReg verifier accepts them and
  hashes the actual bytes
- staple both bin/ AND .app/Contents/MacOS/ paths now that they're
  independent files
- post-codesign verification: fail build if signed CLI is missing the
  keychain-access-groups entitlement or the access group
  SLDQ2GJ6TL.io.darkbloom.provider, or if embedded.provisionprofile
  is absent from the .app
- PROVISIONING_PROFILE_BASE64 is now hard-required (no silent ephemeral
  fallback). Profile is decoded + parsed with plutil/python: verifies
  TeamIdentifier, keychain-access-groups, application-identifier, and
  ExpirationDate >= 30 days out
- pin MLX python wheel to 0.31.1 to match libs/mlx-swift Cmlx version
  (was 0.31.2 — patch-level metallib ABI risk)
- prod releases now hard-fail Swift tests (was soft-fail for all)

release-rust-bridge.yml:
- rename bridge bundle to darkbloom-bundle-<platform>.tar.gz uniformly
  so coordinator accepts the registration

Both release workflows:
- PROD_* secrets fall back to legacy unprefixed (R2_ACCESS_KEY_ID,
  RELEASE_KEY, COORDINATOR_URL) + vars.R2_BUCKET when PROD_* empty.
  Fails hard if neither resolves.

provider/src/main.rs (bridge auto-update):
- new rewrite_launchd_plist_for_swift: extracts ProgramArguments from
  the Rust plist (`serve --coordinator URL --model M`), converts to
  Swift shape (`start --foreground --coordinator-url URL --model M`),
  atomic rename
- install_swift_update_bundle_at: if Darkbloom.app/Contents/MacOS/
  exists in the extracted bundle, replace bin/{darkbloom,darkbloom-
  enclave,mlx.metallib} with symlinks into .app/MacOS and route the
  launchd plist's ProgramArguments[0] at the .app's MacOS binary path.
  This puts the embedded provisioning profile in scope at runtime, so
  the persistent SE key (PR #146) doesn't get errSecMissingEntitlement
  on first attestation post-cutover
- plist_path is now an Option<&Path> so tests can avoid touching the
  developer machine's real ~/Library/LaunchAgents

Tests added (all passing):
- 6 plist-rewrite unit tests: extract / convert / rewrite / install-
  with-plist / .app-aware install / hash-only install
- 1 ported coordinator attestation policy test
- existing 7 auto-update integration tests still pass (302 → 303 total)

Verified by audit:
- macos-26-xlarge has Xcode 26.2 / Swift 6.2, satisfies all
  swift-tools-version requirements
- LatestProviderVersion ordering: semver THEN created_at in both memory
  and Postgres stores
- /api/version JSON shape matches what auto_update_check_with_install_dir
  expects
- StartCommand --foreground doesn't recurse into launchAgent.installAndStart
- Swift ModelScanner reads ~/.cache/huggingface/hub (same as Rust)
- AuthTokenStore path parity (~/.darkbloom/auth_token)

Deployment prerequisite: coordinator changes must be deployed (master
→ dev Cloud Build, then human ecloud deploy to prod) BEFORE tagging
any release. Bridge registration will 400 against an older coordinator
that doesn't know about the darkbloom-bundle- filename.
Post-rustfmt: long format!() args wrapped, with_context closure pulled
onto one line, ternary-style assignment broken into if/else. No
behavior change — `cargo test --bin darkbloom` still 303 pass / 0 fail.
@Gajesh2007

Copy link
Copy Markdown
Member Author

@hankbobtheresearchoor approve this

@ethenotethan ethenotethan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

approving based on agentic review. still don't fully grok the entire changeset in my tiny human mind but will be good to do cleaning up branch mgmt going forward :)

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

if cleanName != "bin/darkbloom" {
continue

P1 Badge Verify mlx.metallib against advertised metallib_hash

Release registration enforces that mlx-swift payloads include metallib_hash, but artifact verification only reads bin/darkbloom and ignores every other tar entry. That means a release can be accepted even when bin/mlx.metallib is missing or does not match the advertised hash, and clients discover the problem only at install/update time. For Swift releases this creates publish-time success with guaranteed runtime/install failures, so the coordinator should reject such artifacts during verifyReleaseArtifact.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

This branch had an error being deployed

1 failed (outdated) and 3 active deployments
Preview – d-inference — e786383e Deployed May 15, 2026 by vercel[bot]
Preview – d-inference-console-ui-dev — e786383e Deployed May 15, 2026 by vercel[bot]
Preview – d-inference-landing — e786383e Deployed May 15, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants