diff --git a/.github/actions/provider-ci-build/action.yml b/.github/actions/provider-ci-build/action.yml index 40b34a38ac..c20cae65d7 100644 --- a/.github/actions/provider-ci-build/action.yml +++ b/.github/actions/provider-ci-build/action.yml @@ -4,6 +4,9 @@ inputs: lane: description: provider, sdk or cluster; each owns independent build outputs required: true + save-caches: + description: "'true' to save this lane's caches; ci.yml passes true only for pushes to master and dev" + default: 'false' runs: using: composite steps: @@ -33,7 +36,21 @@ runs: shell: bash env: LANE: ${{ inputs.lane }} - run: python3 scripts/provider-ci-cache.py keys --lane "$LANE" >> "$GITHUB_OUTPUT" + run: | + python3 scripts/provider-ci-cache.py keys --lane "$LANE" >> "$GITHUB_OUTPUT" + # actions/cache stores a path outside the workspace relative to the + # workspace, so SwiftPM's cache is shared only between equal layouts. + echo "home-layout=$(printf '%s\n' "$HOME" "$GITHUB_WORKSPACE" | shasum -a 256 | cut -c1-12)" >> "$GITHUB_OUTPUT" + echo "actions/cache compressor: $(command -v zstd >/dev/null && echo zstd || echo gzip)" + # Dependency clones for a cold build; the lane's own build cache already + # holds them when it is restored. + - name: Restore SwiftPM repositories + id: spm-repos + uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 + with: + path: ~/Library/Caches/org.swift.swiftpm/repositories + key: spm-repos-v1-${{ runner.os }}-${{ steps.keys.outputs.home-layout }}-${{ inputs.lane }}-${{ hashFiles('**/Package.resolved', '!**/.build/**') }} + restore-keys: spm-repos-v1-${{ runner.os }}-${{ steps.keys.outputs.home-layout }}-${{ inputs.lane }}- - name: Restore lane-specific Swift test build id: swift-cache uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 @@ -84,11 +101,10 @@ runs: id: timestamps shell: bash run: python3 scripts/provider-release-cache.py snapshot-mtimes - # Pushes save their build. A pull request saves only when it restored - # nothing, so its later pushes do not each add an entry that evicts the - # base branch's entry from the repository cache. + # Only callers' trusted pushes save (save-caches): a pull request's entry + # is scoped to its merge ref, where nothing else restores it. - name: Save lane-specific Swift test build - if: ${{ !cancelled() && steps.timestamps.outcome == 'success' && steps.swift-cache.outputs.cache-hit != 'true' && (github.event_name != 'pull_request' || steps.swift-cache.outputs.cache-matched-key == '') }} + if: ${{ !cancelled() && inputs.save-caches == 'true' && steps.timestamps.outcome == 'success' && steps.swift-cache.outputs.cache-hit != 'true' }} uses: actions/cache/save@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 with: path: | @@ -96,6 +112,12 @@ runs: libs/mlx-swift-lm/.build libs/darkbloom-cluster/.build key: ${{ steps.keys.outputs.swift-key }} + - name: Save SwiftPM repositories + if: ${{ !cancelled() && inputs.save-caches == 'true' && steps.timestamps.outcome == 'success' && steps.spm-repos.outputs.cache-hit != 'true' }} + uses: actions/cache/save@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 + with: + path: ~/Library/Caches/org.swift.swiftpm/repositories + key: ${{ steps.spm-repos.outputs.cache-primary-key }} - name: Restore source-matched Metal cache id: metallib-cache uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 @@ -118,7 +140,7 @@ runs: bin=$(swift build --package-path "$package" --show-bin-path) ./scripts/stage-test-metallib.sh "$bin" - name: Save validated source-matched Metal cache - if: ${{ !cancelled() && steps.metallib.outcome == 'success' && steps.metallib-cache.outputs.cache-hit != 'true' }} + if: ${{ !cancelled() && inputs.save-caches == 'true' && steps.metallib.outcome == 'success' && steps.metallib-cache.outputs.cache-hit != 'true' }} uses: actions/cache/save@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 with: path: ${{ runner.temp }}/metallib-cache diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2a03edd479..f8b4bb303d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,7 +2,7 @@ name: CI on: push: - # dev pushes save the build caches that pull requests into dev restore. + # Pushes to master and dev save the caches that other runs restore. branches: [master, main, dev] pull_request: @@ -14,6 +14,16 @@ permissions: # master; BuildEnvironmentTests checks that the build is the one requested. env: DARKBLOOM_RELEASE_ENVIRONMENT: prod + # Only pushes to master and dev save caches. A pull request restores its + # base branch's entries and saves none (docs/developer/build.md#ci-caching). + SAVE_CACHES: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev') }} + # Every checkout but Docs Lint's skips the evidence tarballs and landing media + # (408 MB of the tree), which only Docs Lint reads. The rest of the evidence + # stays: provider-ci-cache.py hashes every tracked Package.swift. + CHECKOUT_SPARSE: | + /* + !/docs/reports/evidence/**/*.gz + !/landing/public/media/ # Only revisions of the same PR supersede each other; pushes stay independent. concurrency: @@ -26,9 +36,11 @@ jobs: permissions: contents: read - # Chooses a Darkbloom Sandbox or the Blacksmith fallback for the read-only - # Linux jobs below. It waits for the classifier but still runs if it fails. - # The macOS jobs are not routed (docs/developer/build.md). + # Chooses a Darkbloom Sandbox or the Blacksmith fallback for each read-only + # job below. It follows the classifier so only jobs that will run are + # requested, and still routes the unconditional jobs if the classifier fails. + # A lane is granted whole or falls back whole, so each shard has a lane of + # its own and gets a free Mac even when there is not one per shard. route: needs: changes if: ${{ !cancelled() }} @@ -38,6 +50,18 @@ jobs: lanes: | release-integrity linux_arm64 blacksmith-4vcpu-ubuntu-2404 docs linux_arm64 blacksmith-4vcpu-ubuntu-2404 + test-provider-1 macos_arm64 blacksmith-12vcpu-macos-27 ${{ needs.changes.outputs.provider == 'true' && 1 || 0 }} + test-provider-2 macos_arm64 blacksmith-12vcpu-macos-27 ${{ needs.changes.outputs.provider == 'true' && 1 || 0 }} + test-provider-3 macos_arm64 blacksmith-12vcpu-macos-27 ${{ needs.changes.outputs.provider == 'true' && 1 || 0 }} + test-provider-summary macos_arm64 blacksmith-12vcpu-macos-27 ${{ needs.changes.outputs.provider == 'true' && 1 || 0 }} + test-provider-sdk macos_arm64 blacksmith-12vcpu-macos-27 ${{ (github.event_name == 'push' || needs.changes.outputs.sdk == 'true') && 1 || 0 }} + test-cluster-checks macos_arm64 blacksmith-12vcpu-macos-27 ${{ needs.changes.outputs.cluster == 'true' && 1 || 0 }} + test-cluster-1 macos_arm64 blacksmith-12vcpu-macos-27 ${{ needs.changes.outputs.cluster == 'true' && 1 || 0 }} + test-cluster-2 macos_arm64 blacksmith-12vcpu-macos-27 ${{ needs.changes.outputs.cluster == 'true' && 1 || 0 }} + test-cluster-3 macos_arm64 blacksmith-12vcpu-macos-27 ${{ needs.changes.outputs.cluster == 'true' && 1 || 0 }} + test-cluster-gpu-1 macos_arm64 blacksmith-12vcpu-macos-27 ${{ needs.changes.outputs.cluster == 'true' && 1 || 0 }} + test-cluster-gpu-2 macos_arm64 blacksmith-12vcpu-macos-27 ${{ needs.changes.outputs.cluster == 'true' && 1 || 0 }} + test-cluster-focused macos_arm64 blacksmith-12vcpu-macos-27 ${{ needs.changes.outputs.cluster == 'true' && 1 || 0 }} release-integrity: name: Release Integrity @@ -45,7 +69,43 @@ jobs: runs-on: ${{ fromJSON(needs.route.outputs.routes)['release-integrity'] }} timeout-minutes: 30 steps: + # Every checkout in this workflow uses the same five steps: restore the + # newest .git a push saved, discard it unless git fsck accepts it, check + # out, and save .git once a day per branch (docs/developer/build.md#ci-caching). + - name: Select today's .git cache + id: git-day + run: | + day=$(date -u +%F) + echo "day=$day" >> "$GITHUB_OUTPUT" + echo "month=${day%-*}" >> "$GITHUB_OUTPUT" + echo "actions/cache compressor: $(command -v zstd >/dev/null && echo zstd || echo gzip)" + - name: Restore the newest saved .git + id: git-cache + uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 + with: + path: .git + key: git-v1-${{ runner.os }}-${{ steps.git-day.outputs.day }} + restore-keys: | + git-v1-${{ runner.os }}-${{ steps.git-day.outputs.month }}- + git-v1-${{ runner.os }}- + - name: Discard a damaged cached .git + run: | + if [ -d .git ] && ! { git rev-parse --verify -q HEAD >/dev/null && + git fsck --connectivity-only --no-progress >/dev/null 2>&1; }; then + echo "::warning title=.git cache::git fsck rejected the restored .git; checking out without it." + rm -rf .git + fi - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + persist-credentials: false # Keeps the job token out of the saved .git/config. + sparse-checkout: ${{ env.CHECKOUT_SPARSE }} + sparse-checkout-cone-mode: false + - name: Save .git for later runs + if: env.SAVE_CACHES == 'true' && steps.git-cache.outputs.cache-hit != 'true' + uses: actions/cache/save@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 + with: + path: .git + key: ${{ steps.git-cache.outputs.cache-primary-key }} # A plain build of master must be prod and a plain build of dev must be # dev. The target is the pull request's base branch, or the pushed branch. - name: Check the provider's plain-build default for the target branch @@ -116,9 +176,41 @@ jobs: # Full-history checkouts of this repository have taken up to 21 minutes. timeout-minutes: 45 steps: + - name: Select today's .git cache + id: git-day + run: | + day=$(date -u +%F) + echo "day=$day" >> "$GITHUB_OUTPUT" + echo "month=${day%-*}" >> "$GITHUB_OUTPUT" + echo "actions/cache compressor: $(command -v zstd >/dev/null && echo zstd || echo gzip)" + # Full history: a separate key family, so shallow jobs never restore it. + - name: Restore the newest saved .git + id: git-cache + uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 + with: + path: .git + key: git-full-v1-${{ runner.os }}-${{ steps.git-day.outputs.day }} + restore-keys: | + git-full-v1-${{ runner.os }}-${{ steps.git-day.outputs.month }}- + git-full-v1-${{ runner.os }}- + - name: Discard a damaged cached .git + run: | + if [ -d .git ] && ! { git rev-parse --verify -q HEAD >/dev/null && + git fsck --connectivity-only --no-progress >/dev/null 2>&1; }; then + echo "::warning title=.git cache::git fsck rejected the restored .git; checking out without it." + rm -rf .git + fi - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: fetch-depth: 0 # Frozen source links require committed document provenance. + filter: blob:none # Old file contents are fetched only when read. + persist-credentials: false + - name: Save .git for later runs + if: env.SAVE_CACHES == 'true' && steps.git-cache.outputs.cache-hit != 'true' + uses: actions/cache/save@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 + with: + path: .git + key: ${{ steps.git-cache.outputs.cache-primary-key }} - name: Initialize pinned SDK documentation run: git submodule update --init --depth 1 libs/mlx-swift-lm - name: Test historical source-link validation @@ -130,16 +222,17 @@ jobs: test-provider: # The provider suite runs in shards on separate Macs - # (scripts/provider-test-shards.py). Each shard runs its suites serially in + # (scripts/provider-test-shards.py), each routed through its own + # test-provider- lane above. Each shard runs its suites serially in # one process. Shard 1 also runs the MLX-free test targets in one parallel # process; shard 2 also runs Prompt Parity. The last shard runs every suite # that no other shard selects, the isolated processes and the native gates - # below. Provider Unit Tests Summary - # checks that the shards together executed the full suite and reports coverage. + # below. Provider Unit Tests Summary checks that the shards together + # executed the full suite and reports coverage. name: Provider Unit Tests (shard ${{ matrix.shard }}) - needs: changes + needs: [changes, route] if: ${{ needs.changes.outputs.provider == 'true' }} - runs-on: blacksmith-12vcpu-macos-27 + runs-on: ${{ fromJSON(needs.route.outputs.routes)[format('test-provider-{0}', matrix.shard)] }} timeout-minutes: 60 strategy: # A failed shard does not cancel the other shards. @@ -147,14 +240,47 @@ jobs: matrix: shard: [1, 2, 3] steps: + - name: Select today's .git cache + id: git-day + run: | + day=$(date -u +%F) + echo "day=$day" >> "$GITHUB_OUTPUT" + echo "month=${day%-*}" >> "$GITHUB_OUTPUT" + echo "actions/cache compressor: $(command -v zstd >/dev/null && echo zstd || echo gzip)" + - name: Restore the newest saved .git + id: git-cache + uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 + with: + path: .git + key: git-v1-${{ runner.os }}-${{ steps.git-day.outputs.day }} + restore-keys: | + git-v1-${{ runner.os }}-${{ steps.git-day.outputs.month }}- + git-v1-${{ runner.os }}- + - name: Discard a damaged cached .git + run: | + if [ -d .git ] && ! { git rev-parse --verify -q HEAD >/dev/null && + git fsck --connectivity-only --no-progress >/dev/null 2>&1; }; then + echo "::warning title=.git cache::git fsck rejected the restored .git; checking out without it." + rm -rf .git + fi - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: submodules: recursive + persist-credentials: false + sparse-checkout: ${{ env.CHECKOUT_SPARSE }} + sparse-checkout-cone-mode: false + - name: Save .git for later runs + if: env.SAVE_CACHES == 'true' && steps.git-cache.outputs.cache-hit != 'true' + uses: actions/cache/save@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 + with: + path: .git + key: ${{ steps.git-cache.outputs.cache-primary-key }} - name: Build provider CI prerequisites id: provider-ci-build uses: ./.github/actions/provider-ci-build with: lane: provider + save-caches: ${{ env.SAVE_CACHES }} # The provider lane builds with --enable-code-coverage. Every provider # process after this step writes its own profile here, and the report # step at the end of this job merges them. @@ -288,8 +414,10 @@ jobs: DARKBLOOM_PREFIX_CACHE: '0' DARKBLOOM_PREFIX_CACHE_MEMORY: '0' run: ../scripts/run-nested-suite.sh testGracefulDrainAfterServedRequestRetiresNativeOwnerWithinDeadline --no-parallel + # The 1.87 GB codec is fetched only when the audio gate's inputs changed + # (scripts/ci-component-paths.py MIMO_AUDIO) and on master pushes. - name: Restore pinned MiMo audio codec - if: ${{ !cancelled() && matrix.shard == strategy.job-total && steps.provider-ci-build.outcome == 'success' }} + if: ${{ !cancelled() && matrix.shard == strategy.job-total && steps.provider-ci-build.outcome == 'success' && needs.changes.outputs.mimo_audio == 'true' }} uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57 id: mimo-audio-cache with: @@ -297,10 +425,10 @@ jobs: key: mimo-audio-source-v2-077033345d80eef3a315e8d394e0589667e80e4cdaba9bc5a7488410c6657265 - name: Prepare selected MiMo audio fixture id: mimo-audio-fixtures - if: ${{ !cancelled() && matrix.shard == strategy.job-total && steps.provider-ci-build.outcome == 'success' }} + if: ${{ !cancelled() && matrix.shard == strategy.job-total && steps.provider-ci-build.outcome == 'success' && needs.changes.outputs.mimo_audio == 'true' }} run: python3 scripts/prepare-mimo-audio-fixtures.py --cache "$RUNNER_TEMP/mimo-audio-source" --output "$RUNNER_TEMP/mimo-audio-fixtures" --github-env "$GITHUB_ENV" - name: Cache verified MiMo audio codec - if: ${{ !cancelled() && matrix.shard == strategy.job-total && steps.mimo-audio-fixtures.outcome == 'success' && steps.mimo-audio-cache.outputs.cache-hit != 'true' }} + if: ${{ !cancelled() && env.SAVE_CACHES == 'true' && matrix.shard == strategy.job-total && steps.mimo-audio-fixtures.outcome == 'success' && steps.mimo-audio-cache.outputs.cache-hit != 'true' }} uses: actions/cache/save@1bd1e32a3bdc45362d1e726936510720a7c30a57 with: path: ${{ runner.temp }}/mimo-audio-source @@ -347,22 +475,55 @@ jobs: test-provider-summary: # Checks the shards against the full suite list and reports coverage. name: Provider Unit Tests Summary - needs: [changes, test-provider] + needs: [changes, route, test-provider] if: ${{ !cancelled() && needs.changes.outputs.provider == 'true' }} - runs-on: blacksmith-12vcpu-macos-27 + runs-on: ${{ fromJSON(needs.route.outputs.routes)['test-provider-summary'] }} timeout-minutes: 30 steps: + - name: Select today's .git cache + id: git-day + run: | + day=$(date -u +%F) + echo "day=$day" >> "$GITHUB_OUTPUT" + echo "month=${day%-*}" >> "$GITHUB_OUTPUT" + echo "actions/cache compressor: $(command -v zstd >/dev/null && echo zstd || echo gzip)" + - name: Restore the newest saved .git + id: git-cache + uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 + with: + path: .git + key: git-v1-${{ runner.os }}-${{ steps.git-day.outputs.day }} + restore-keys: | + git-v1-${{ runner.os }}-${{ steps.git-day.outputs.month }}- + git-v1-${{ runner.os }}- + - name: Discard a damaged cached .git + run: | + if [ -d .git ] && ! { git rev-parse --verify -q HEAD >/dev/null && + git fsck --connectivity-only --no-progress >/dev/null 2>&1; }; then + echo "::warning title=.git cache::git fsck rejected the restored .git; checking out without it." + rm -rf .git + fi - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: submodules: recursive - # This restores the shards' build, or on a pull request the base - # branch's build, and rebuilds it from the same sources and flags. - # `swift test list` and llvm-cov read its binaries. + persist-credentials: false + sparse-checkout: ${{ env.CHECKOUT_SPARSE }} + sparse-checkout-cone-mode: false + - name: Save .git for later runs + if: env.SAVE_CACHES == 'true' && steps.git-cache.outputs.cache-hit != 'true' + uses: actions/cache/save@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 + with: + path: .git + key: ${{ steps.git-cache.outputs.cache-primary-key }} + # On a push this restores the shards' build; on a pull request, the base + # branch's newest compatible build. It rebuilds from the same sources and + # flags; `swift test list` and llvm-cov read its binaries. - name: Build provider CI prerequisites id: provider-ci-build uses: ./.github/actions/provider-ci-build with: lane: provider + save-caches: ${{ env.SAVE_CACHES }} - name: Download shard reports uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0 with: @@ -512,20 +673,53 @@ jobs: # SDK-lane input changes (scripts/ci-component-paths.py SDK); every push to # dev or master runs it, and a failure there notifies without blocking. name: Provider SDK Tests - needs: changes + needs: [changes, route] if: ${{ github.event_name == 'push' || needs.changes.outputs.sdk == 'true' }} - runs-on: blacksmith-12vcpu-macos-27 + runs-on: ${{ fromJSON(needs.route.outputs.routes)['test-provider-sdk'] }} timeout-minutes: 60 steps: + - name: Select today's .git cache + id: git-day + run: | + day=$(date -u +%F) + echo "day=$day" >> "$GITHUB_OUTPUT" + echo "month=${day%-*}" >> "$GITHUB_OUTPUT" + echo "actions/cache compressor: $(command -v zstd >/dev/null && echo zstd || echo gzip)" + - name: Restore the newest saved .git + id: git-cache + uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 + with: + path: .git + key: git-v1-${{ runner.os }}-${{ steps.git-day.outputs.day }} + restore-keys: | + git-v1-${{ runner.os }}-${{ steps.git-day.outputs.month }}- + git-v1-${{ runner.os }}- + - name: Discard a damaged cached .git + run: | + if [ -d .git ] && ! { git rev-parse --verify -q HEAD >/dev/null && + git fsck --connectivity-only --no-progress >/dev/null 2>&1; }; then + echo "::warning title=.git cache::git fsck rejected the restored .git; checking out without it." + rm -rf .git + fi - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: submodules: recursive + persist-credentials: false + sparse-checkout: ${{ env.CHECKOUT_SPARSE }} + sparse-checkout-cone-mode: false + - name: Save .git for later runs + if: env.SAVE_CACHES == 'true' && steps.git-cache.outputs.cache-hit != 'true' + uses: actions/cache/save@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 + with: + path: .git + key: ${{ steps.git-cache.outputs.cache-primary-key }} - name: Build SDK CI prerequisites id: provider-ci-build timeout-minutes: 35 uses: ./.github/actions/provider-ci-build with: lane: sdk + save-caches: ${{ env.SAVE_CACHES }} # FLAKE-ORDERING GUARD (audit fix, v0.8.0): every nested step below runs # under !cancelled() with successful build/metallib prerequisites. A # failed suite cannot hide a later correctness gate, and a failed build @@ -682,14 +876,46 @@ jobs: # metadata and argument checks) and runs it on the retained fixtures: no GPU, # no model load, no weights. Every runner runs even after another fails. name: Cluster Metadata Checks - needs: changes + needs: [changes, route] if: ${{ needs.changes.outputs.cluster == 'true' }} - runs-on: blacksmith-12vcpu-macos-27 + runs-on: ${{ fromJSON(needs.route.outputs.routes)['test-cluster-checks'] }} timeout-minutes: 60 steps: + - name: Select today's .git cache + id: git-day + run: | + day=$(date -u +%F) + echo "day=$day" >> "$GITHUB_OUTPUT" + echo "month=${day%-*}" >> "$GITHUB_OUTPUT" + echo "actions/cache compressor: $(command -v zstd >/dev/null && echo zstd || echo gzip)" + - name: Restore the newest saved .git + id: git-cache + uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 + with: + path: .git + key: git-v1-${{ runner.os }}-${{ steps.git-day.outputs.day }} + restore-keys: | + git-v1-${{ runner.os }}-${{ steps.git-day.outputs.month }}- + git-v1-${{ runner.os }}- + - name: Discard a damaged cached .git + run: | + if [ -d .git ] && ! { git rev-parse --verify -q HEAD >/dev/null && + git fsck --connectivity-only --no-progress >/dev/null 2>&1; }; then + echo "::warning title=.git cache::git fsck rejected the restored .git; checking out without it." + rm -rf .git + fi - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: submodules: recursive + persist-credentials: false + sparse-checkout: ${{ env.CHECKOUT_SPARSE }} + sparse-checkout-cone-mode: false + - name: Save .git for later runs + if: env.SAVE_CACHES == 'true' && steps.git-cache.outputs.cache-hit != 'true' + uses: actions/cache/save@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 + with: + path: .git + key: ${{ steps.git-cache.outputs.cache-primary-key }} - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 with: python-version: '3.12.10' @@ -700,7 +926,8 @@ jobs: # reused across runs: SwiftPM rebuilds what changed, and source timestamps # are restored only for files whose contents match the cached build's # (scripts/provider-release-cache.py). The key binds the toolchain, the - # package manifests, the submodule pins, the runner script and the paths. + # package manifests, the submodule pins, the runner script and the paths; + # it drops `git describe` text, which depends on the refs a cached .git holds. - name: Resolve cluster metadata build cache key id: cluster-build-key if: ${{ steps.toolchain.outcome == 'success' }} @@ -709,7 +936,7 @@ jobs: run: | set -euo pipefail identity=$( { swift --version 2>&1; xcodebuild -version; xcrun --show-sdk-path; \ - git submodule status --recursive; echo "$GITHUB_WORKSPACE $RUNNER_TEMP $MANIFESTS"; } | shasum -a 256 | cut -c1-32) + git submodule status --recursive | awk '{print $1, $2}'; echo "$GITHUB_WORKSPACE $RUNNER_TEMP $MANIFESTS"; } | shasum -a 256 | cut -c1-32) echo "prefix=cluster-metadata-release-v1-$identity-" >> "$GITHUB_OUTPUT" echo "key=cluster-metadata-release-v1-$identity-$GITHUB_SHA" >> "$GITHUB_OUTPUT" - name: Restore cluster metadata build @@ -745,15 +972,14 @@ jobs: DARKBLOOM_CLUSTER_METADATA_BUILD_JOBS: '12' DARKBLOOM_CLUSTER_METADATA_BUILD_ROOT: ${{ runner.temp }}/cluster-native-metadata run: bash libs/darkbloom-cluster/Tests/PrefillScheduleChecks/run.sh - # Pushes save the cluster build; a pull request saves it only when it - # restored nothing (as the provider lane's Swift build). + # Only pushes to master and dev save the cluster build (SAVE_CACHES). - name: Record source timestamps for the cluster build - if: ${{ !cancelled() && steps.capability-checks.outcome == 'success' && steps.cluster-build-cache.outputs.cache-hit != 'true' && (github.event_name != 'pull_request' || steps.cluster-build-cache.outputs.cache-matched-key == '') }} + if: ${{ !cancelled() && env.SAVE_CACHES == 'true' && steps.capability-checks.outcome == 'success' && steps.cluster-build-cache.outputs.cache-hit != 'true' }} run: | python3 scripts/provider-release-cache.py snapshot-mtimes cp provider-swift/.build/provider-release-source-mtimes.json "$RUNNER_TEMP/cluster-native-metadata/" - name: Upload cluster metadata build cache - if: ${{ !cancelled() && steps.capability-checks.outcome == 'success' && steps.cluster-build-cache.outputs.cache-hit != 'true' && (github.event_name != 'pull_request' || steps.cluster-build-cache.outputs.cache-matched-key == '') }} + if: ${{ !cancelled() && env.SAVE_CACHES == 'true' && steps.capability-checks.outcome == 'success' && steps.cluster-build-cache.outputs.cache-hit != 'true' }} uses: actions/cache/save@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 with: path: ${{ runner.temp }}/cluster-native-metadata @@ -782,23 +1008,56 @@ jobs: # separate Macs (scripts/cluster-test-plan.py): every test without a # switch, and the switched tests that pass on these runners. name: Cluster Runtime Tests (shard ${{ matrix.shard }}) - needs: changes + needs: [changes, route] if: ${{ needs.changes.outputs.cluster == 'true' }} - runs-on: blacksmith-12vcpu-macos-27 + runs-on: ${{ fromJSON(needs.route.outputs.routes)[format('test-cluster-{0}', matrix.shard)] }} timeout-minutes: 60 strategy: fail-fast: false matrix: shard: [1, 2, 3] steps: + - name: Select today's .git cache + id: git-day + run: | + day=$(date -u +%F) + echo "day=$day" >> "$GITHUB_OUTPUT" + echo "month=${day%-*}" >> "$GITHUB_OUTPUT" + echo "actions/cache compressor: $(command -v zstd >/dev/null && echo zstd || echo gzip)" + - name: Restore the newest saved .git + id: git-cache + uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 + with: + path: .git + key: git-v1-${{ runner.os }}-${{ steps.git-day.outputs.day }} + restore-keys: | + git-v1-${{ runner.os }}-${{ steps.git-day.outputs.month }}- + git-v1-${{ runner.os }}- + - name: Discard a damaged cached .git + run: | + if [ -d .git ] && ! { git rev-parse --verify -q HEAD >/dev/null && + git fsck --connectivity-only --no-progress >/dev/null 2>&1; }; then + echo "::warning title=.git cache::git fsck rejected the restored .git; checking out without it." + rm -rf .git + fi - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: submodules: recursive + persist-credentials: false + sparse-checkout: ${{ env.CHECKOUT_SPARSE }} + sparse-checkout-cone-mode: false + - name: Save .git for later runs + if: env.SAVE_CACHES == 'true' && steps.git-cache.outputs.cache-hit != 'true' + uses: actions/cache/save@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 + with: + path: .git + key: ${{ steps.git-cache.outputs.cache-primary-key }} - name: Build cluster test products id: provider-ci-build uses: ./.github/actions/provider-ci-build with: lane: cluster + save-caches: ${{ env.SAVE_CACHES }} - name: Run cluster runtime tests if: ${{ !cancelled() && steps.provider-ci-build.outcome == 'success' }} timeout-minutes: 40 @@ -811,23 +1070,56 @@ jobs: # ones and the benchmarks (scripts/cluster-test-plan.py). They run and # report on every pull request; a failure does not fail the workflow. name: Cluster GPU Tests (non-blocking, shard ${{ matrix.shard }}) - needs: changes + needs: [changes, route] if: ${{ needs.changes.outputs.cluster == 'true' }} - runs-on: blacksmith-12vcpu-macos-27 + runs-on: ${{ fromJSON(needs.route.outputs.routes)[format('test-cluster-gpu-{0}', matrix.shard)] }} timeout-minutes: 60 strategy: fail-fast: false matrix: shard: [1, 2] steps: + - name: Select today's .git cache + id: git-day + run: | + day=$(date -u +%F) + echo "day=$day" >> "$GITHUB_OUTPUT" + echo "month=${day%-*}" >> "$GITHUB_OUTPUT" + echo "actions/cache compressor: $(command -v zstd >/dev/null && echo zstd || echo gzip)" + - name: Restore the newest saved .git + id: git-cache + uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 + with: + path: .git + key: git-v1-${{ runner.os }}-${{ steps.git-day.outputs.day }} + restore-keys: | + git-v1-${{ runner.os }}-${{ steps.git-day.outputs.month }}- + git-v1-${{ runner.os }}- + - name: Discard a damaged cached .git + run: | + if [ -d .git ] && ! { git rev-parse --verify -q HEAD >/dev/null && + git fsck --connectivity-only --no-progress >/dev/null 2>&1; }; then + echo "::warning title=.git cache::git fsck rejected the restored .git; checking out without it." + rm -rf .git + fi - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: submodules: recursive + persist-credentials: false + sparse-checkout: ${{ env.CHECKOUT_SPARSE }} + sparse-checkout-cone-mode: false + - name: Save .git for later runs + if: env.SAVE_CACHES == 'true' && steps.git-cache.outputs.cache-hit != 'true' + uses: actions/cache/save@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 + with: + path: .git + key: ${{ steps.git-cache.outputs.cache-primary-key }} - name: Build cluster test products id: provider-ci-build uses: ./.github/actions/provider-ci-build with: lane: cluster + save-caches: ${{ env.SAVE_CACHES }} - name: Run non-blocking cluster GPU tests if: ${{ !cancelled() && steps.provider-ci-build.outcome == 'success' }} continue-on-error: true @@ -840,14 +1132,46 @@ jobs: # The model-free runner scripts under libs/darkbloom-cluster/Tests that # Cluster Metadata Checks does not run (scripts/cluster-test-plan.py). name: Cluster Focused Checks - needs: changes + needs: [changes, route] if: ${{ needs.changes.outputs.cluster == 'true' }} - runs-on: blacksmith-12vcpu-macos-27 + runs-on: ${{ fromJSON(needs.route.outputs.routes)['test-cluster-focused'] }} timeout-minutes: 60 steps: + - name: Select today's .git cache + id: git-day + run: | + day=$(date -u +%F) + echo "day=$day" >> "$GITHUB_OUTPUT" + echo "month=${day%-*}" >> "$GITHUB_OUTPUT" + echo "actions/cache compressor: $(command -v zstd >/dev/null && echo zstd || echo gzip)" + - name: Restore the newest saved .git + id: git-cache + uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 + with: + path: .git + key: git-v1-${{ runner.os }}-${{ steps.git-day.outputs.day }} + restore-keys: | + git-v1-${{ runner.os }}-${{ steps.git-day.outputs.month }}- + git-v1-${{ runner.os }}- + - name: Discard a damaged cached .git + run: | + if [ -d .git ] && ! { git rev-parse --verify -q HEAD >/dev/null && + git fsck --connectivity-only --no-progress >/dev/null 2>&1; }; then + echo "::warning title=.git cache::git fsck rejected the restored .git; checking out without it." + rm -rf .git + fi - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: submodules: recursive + persist-credentials: false + sparse-checkout: ${{ env.CHECKOUT_SPARSE }} + sparse-checkout-cone-mode: false + - name: Save .git for later runs + if: env.SAVE_CACHES == 'true' && steps.git-cache.outputs.cache-hit != 'true' + uses: actions/cache/save@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 + with: + path: .git + key: ${{ steps.git-cache.outputs.cache-primary-key }} - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 with: python-version: '3.12.10' diff --git a/.github/workflows/component-changes.yml b/.github/workflows/component-changes.yml index 1d2e566fb8..e7a348e93f 100644 --- a/.github/workflows/component-changes.yml +++ b/.github/workflows/component-changes.yml @@ -9,6 +9,8 @@ on: value: ${{ jobs.changes.outputs.sdk }} cluster: value: ${{ jobs.changes.outputs.cluster }} + mimo_audio: + value: ${{ jobs.changes.outputs.mimo_audio }} permissions: contents: read @@ -23,6 +25,7 @@ jobs: provider: ${{ steps.paths.outputs.provider }} sdk: ${{ steps.paths.outputs.sdk }} cluster: ${{ steps.paths.outputs.cluster }} + mimo_audio: ${{ steps.paths.outputs.mimo_audio }} steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: diff --git a/.github/workflows/docs-impact.yml b/.github/workflows/docs-impact.yml index 681d40640c..ded43866a5 100644 --- a/.github/workflows/docs-impact.yml +++ b/.github/workflows/docs-impact.yml @@ -58,6 +58,14 @@ jobs: with: ref: ${{ github.event.pull_request.head.sha }} fetch-depth: 0 + # The diff needs commits and trees; old file contents are fetched only + # when read. Evidence tarballs and landing media are never read. + filter: blob:none + sparse-checkout: | + /* + !/docs/reports/evidence/**/*.gz + !/landing/public/media/ + sparse-checkout-cone-mode: false - name: Test documentation-impact validation run: python3 scripts/test-docs-impact-check.py - name: Check documentation impact diff --git a/CHANGELOG.md b/CHANGELOG.md index eaf320c1ff..d46ee6a3f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,9 +8,409 @@ or console deployment, feature activation, model promotion or hardware qualification. Sections marked historical retain the original candidate's qualification, opt-in and deployment limits rather than claiming activation. -## v0.10.6 — candidate (unpublished) +## v0.10.7 — candidate (unpublished) -Prepared on 2026-10-31; tagging and publication are separate steps. +Prepared on 2026-11-03; tagging and publication are separate steps. + +### Upgrade and rollout notes + +- Both Macs of a pair must update to 0.10.7. The Gemma 4 and MiMo-V2.6-Flash plans change (#1706, #1707, #1715), as does the Qwen tensor-parallel control wire (#1727), and a pair whose Macs run different builds refuses to pair: it fails closed until both Macs run the same release. +- A pair on 0.10.6 cannot update itself into 0.10.7: its cluster service predates the pair's coordinated update. On each pair, once: run `darkbloom update` on both Macs, then log out and back in on both (or restart them), as `docs/provider/two-mac-cluster.md` ("Updating Darkbloom on the pair") describes. From 0.10.7 on, the two Macs of a pair update together by themselves (#1702). If `darkbloom cluster` then says that a Qwen pair of two different Macs, which 0.10.6 saved with unequal tensor-parallel shares, is not offered for pairing, press `m` and choose the model again: it is planned with equal shares and registers (#1723). +- Gemma 4 and MiMo-V2.6-Flash tensor parallel are public (#1736): `ClusterPublicModels` declares `gemma-4-26b-qat-4bit` and `mimo-v2.6-flash-mopd` in pipeline and tensor parallel, as it does GLM-5.3-Flash and Qwen3.8-27B, and MiMo-V2.6-Flash's speculative pipeline too, so this release's cluster runtime facts carry their pair-serving grants and parity qualifications. Their tensor parallel is in this build (#1706, #1707, #1716), and a pair chooses it only on tensor parallel's own measured speed and only where it keeps every feature of the mode it would replace (#1715), so normal setups keep the pipeline for now. Speed on a real pair is not measured for either model's tensor parallel, and MiMo has no tensor-parallel qualification record yet. The entry "MiMo-V2.6-Flash and Gemma 4 26B QAT serve public cluster traffic" below says their tensor parallel serves once its code is in the build: in 0.10.7 it is. +- `darkbloom update --rollback` (#1729) puts back the release a Mac ran before its last update (0.10.6, after this update) and quarantines the one it leaves, without contacting a coordinator. It refuses on a Mac that serves in a pair: stop that Mac's cluster service first. The other Mac follows a rollback only to a release that has #1739, so a pair rolled back to 0.10.6 needs the rollback on each Mac. +- The operator's enabled-model filter wins over coordinator model changes (#1730): with `enabled_models` set, a coordinator `load_model` or `prefetch_model` outside it is refused (`model_not_selected`), and a provider no longer moves to a new build of a model by itself; `darkbloom switch` takes one. +- On one Mac, Gemma 4 replies keep the space before punctuation (#1693) and characters outside its vocabulary (#1703), with the same token IDs and cache keys, and a client `stop` sequence matches only the answer's `content`, not reasoning (#1650). +- The registration is the one 0.10.6 sent: the same fields and a `darkbloom_cluster_runtime_v2` block, carried while `PROD_CLUSTER_RUNTIME_ENABLED` is `true`. After the tag the platform snapshots its provider contracts from the tagged commit and sets `LatestProviderVersion` to `0.10.7`. +- MLX pins: `libs/mlx` and the nested `mlx` (`72dffa2d`) and `libs/mlx-swift` (`c633d221`) are unchanged from v0.10.6. `libs/mlx-swift-lm` moves from `7933a0fa` to `32f5c744`, its fork's `main` (SDK #370, #371, #375 to #377 and #379 to #384). It changes Swift files only, and the one Metal kernel it adds, an FP32-output variant of MiMo's decode down projection, compiles at run time (`MLXFast.metalKernel`), not into `mlx.metallib`, so the tag build's `metallib_hash` should equal v0.10.6's `98bab9d7…614be`. Complete SSD checkpoints stay per build: 0.10.7 does not restore those 0.10.6 wrote. +- The 39 entries below are the pending fragments rendered verbatim, in filename order. #1711 (a latent GPT-OSS cache-metadata fix), #1743 (two race fixes; one keeps `darkbloom cluster stop` from failing with "could not save the stop request") and the CI and test PRs #1665, #1691, #1733, #1737, #1741, #1747, #1749, #1750 and #1753 have no entry. + +### App Attest restart covers the first episode after an update + +- The `is_supported_false` restart now also works in the first process after an update from a version that did not record its App Attest authorizations. At serve start, when `app-attest-verified.json` is missing, the provider fills it once from the previous `daemon-state.json`, with evidence from the last 7 days: the last successful Apple call of a stored key that Apple attested, or an App Attest grant left by an unclean exit. All other conditions stay the same. +- A Mac whose previous provider was itself reporting `is_supported_false` has no such evidence, so it still waits for the coordinator to grant App Attest again. + +### App Attest recovers by itself after a self-update + +- A provider that launchd runs as its provider job now relaunches through launchd after a startup self-update, as it already did after a background update. Only a provider that launchd does not run, such as `darkbloom start --foreground` in a terminal, replaces itself in place. A background update or App Attest restart in such a provider no longer starts the LaunchAgent instead. +- When App Attest reports `is_supported_false` on a Mac that the coordinator verified for App Attest in the last 7 days, the provider restarts once through launchd. It waits until the state lasts 5 minutes and the provider is idle, and it checks Apple's answer again after the drain. If the new process still reports unsupported, it does not restart again until the coordinator verifies the Mac again. This restart and the stall restart share one limit: one automatic App Attest restart per 6 hours. Cluster members never restart for it. +- The provider keeps the time of its last App Attest authorization in `app-attest-verified.json` beside the daemon state file. +- The local provider log gets an `App Attest entitlement evidence` line at startup and at each `is_supported_false` answer: the start reason, the App Attest entitlements of the running process and of the code on disk, and the executable's modification time relative to the process start. It is not sent to the coordinator. + +### Cache restores finish sooner + +- Restoring a prefix-cache checkpoint decodes its older attention rows from the + default `balanced` checkpoint precision on the CPU. The decoder now checks each + row for values its native type cannot hold once per row instead of once per + eight values, with the same bytes and the same refusals. On Gemma 4 26B + follow-up requests served from the SSD cache, time to first token fell by about + 0.2 s per restore (about 25% over an 11-request conversation on an M3 Ultra), + and responses that save a checkpoint also end about 0.2 s sooner. Output is + unchanged. + +### Responses that save a cache checkpoint finish sooner + +- Saving a prefix-cache checkpoint encodes its older attention rows at the default + `balanced` checkpoint precision. That encoding now prepares its buffers and its + check once per segment instead of once per row and writes the same bytes. On a + Gemma 4 26B request that saves a checkpoint, the end of the response arrived + about 0.7 s sooner (1.7–2.0 s → 1.0–1.2 s on an M3 Ultra), with identical + output. Requests that save no checkpoint are unchanged. + +### Pair Macs set up with `darkbloom cluster` update themselves + +- A Mac set up with `darkbloom cluster` now updates itself, as a single Mac does: with `auto_update` on (the default) and without `DARKBLOOM_NO_UPDATE_CHECK`, its cluster service checks the coordinator's latest release every 30 minutes, at the pair's update slot, which both Macs derive from their pairing's cluster ID. +- Each Mac downloads, verifies and stages the release while the pair serves. Only once both Macs have it does the pair stop taking new requests; the Mac that serves the pair finishes its accepted requests (at most 120 seconds, never cancelling one), then both Macs install the release and restart their cluster services, and the cluster sets itself up again for the new release with no command run. +- A pair under constant traffic updates too: once it takes no new requests, the accepted ones finish. A pair still running a request at the bound takes requests again and tries at the next slot. A release one Mac cannot download or verify is installed on neither Mac; both try again at the next slot. +- An installed release is promoted once its cluster service has stayed healthy for 10 minutes; three starts of its service that end on their own restore the previous release and quarantine the new one, as the watchdog does for a single Mac. +- Before a Mac restarts into an installed release, its cluster service runs the new `darkbloom --version` once (at most 30 seconds). A release that does not answer with its version is never restarted into: the Mac restores the previous release at once, quarantines the new one and starts its cluster service again, so a release that cannot start no longer leaves the Mac with nothing to roll it back. +- `darkbloom update` on a cluster Mac installs the release and then restarts the cluster service into it together with the other Mac, after the pair drained; logging out and back in is no longer needed. Run it on both Macs (or let the other Mac update at the next slot); the first Mac waits up to 15 minutes for the second, also when automatic updates are off. A Mac whose partner has automatic updates off downloads nothing at the slot. +- A pair that serves on the leader's local API, or a Mac that serves alone, is not drained for an update yet: it does not update while it serves, and a cluster set to serve locally (`darkbloom cluster local`) or a Mac serving alone downloads nothing at the slot. +- A cluster service started by an earlier release does none of this: to reach this release, run `darkbloom update` on both Macs, then log out and back in on both (or restart them) once. + +### Tensor parallel only where it keeps every feature + +- On a two-Mac pair, Gemma 4 and MiMo V2.6 Flash use tensor parallel only where it keeps every feature and caching behavior of the mode it would replace: prompt-prefix and SSD cache reuse, speculative (MTP) rounds, batch lanes, media, penalties and logit bias, stop handling and logprobs. What tensor parallel adds, such as logprobs where the pipeline has none, never counts against it. Each mode's features come from the installed cluster worker's capability record. +- Gemma 4's tensor parallel keeps every feature of its pipeline, prompt-prefix and SSD reuse included, so its measured speed decides. MiMo's tensor parallel decodes in speculative rounds, so it keeps every feature of the speculative pipeline and its measured speed decides; only where the plain pipeline is the mode it would replace do that pipeline's batch lanes keep it. The plan's "Tensor parallel or pipeline" line says what tensor parallel would drop ("Pipeline: tensor parallel would drop batch lanes up to 8 (it serves 1) that the pipeline keeps; held back until it keeps them."), and the model list says "tensor parallel: drops a feature". +- Where only tensor parallel fits the two Macs, the plan refuses with that reason and saves no setup, instead of saving one with fewer features. The developer's forced mode (debug builds) still places tensor parallel, and the plan says exactly what it drops. +- Qwen and GLM plans are unchanged. + +### Simpler two-Mac cluster setup + +- `darkbloom cluster` setup says far less: four steps (Connect, Pair, Model, Start), a line per thing that happened, + and the next thing to do last. Every choice is a list (↑↓ and enter, as `darkbloom start` picks models; numbered in + plain transcripts); q or Esc cancels. +- The model list shows only the models approved for clusters (GLM-5.3-Flash, Qwen3.8 27B, MiMo-V2.6-Flash and + Gemma 4 26B QAT) that the two Macs can serve, each with its size and its split: tensor parallel or pipeline. The + serving lines name the split too. +- The Mac you set up on leads and keeps leading: every plan puts rank 0 on it, the cluster service's own re-plans + included, so a pair set up with 0.10.6 whose other Mac took over leading moves back at its next plan. +- macOS's password and Local Network prompts come at stated moments (sudo in the terminal over SSH); both Macs ask + about Darkbloom's Local Network access right after pairing, and the setup waits until Allow or q. +- Both Macs confirm the pairing code; the Mac that follows only shows the status. The serving line says whether the + pair earns through Darkbloom or serves locally only. +- `darkbloom doctor` includes the cluster's checks on a Mac paired for a cluster. + +### Qwen pairs of two different Macs register with the coordinator + +- Affected: a pair of two different Macs set up with `darkbloom cluster` to serve through Darkbloom, with a Qwen model planned in tensor parallel. The planner gave the faster Mac the larger share of every layer (for example 2:1 on an M3 Ultra and an M5 Max), and the coordinator registration cannot name unequal shares yet. Both Macs still said `Registered with the coordinator as a cluster member`, then each Mac's part refused to register ("The saved roster registration is not valid for this Mac: invalidPlan"), the pair fell back to the leader's local API, and the coordinator never formed it or routed it a request. This hit Qwen3.8 27B, which pairs only in tensor parallel, and Qwen3.5 9B where tensor parallel was chosen. GLM-5.3-Flash, pipeline splits and two identical Macs were not affected. +- A pair served through Darkbloom is now planned with equal tensor-parallel shares, so it registers and is routed like a pair of identical Macs; on two different Macs the slower one sets the pace. A pair that serves you alone (`darkbloom cluster local`) keeps the faster unequal split. +- A setup saved with unequal shares (by 0.10.6, or a local cluster switched to Darkbloom with `p`) is not offered for pairing, and the leader says why before it stops either Mac's part: `Not offered for pairing: this Mac's check refused it: Unequal tensor-parallel shares serve local clusters only …`. If `darkbloom cluster` shows this once both Macs run this release, press `m` and choose the model again: it is planned with equal shares and registers. + +### Both Macs of a pair roll back together + +- When one Mac of a `darkbloom cluster` pair rolls a release back (three failed starts of its cluster service, a failed start check, or `darkbloom update --rollback` while its cluster service was stopped), the other Mac now rolls back to the same earlier release, and the pair serves it together. Before, the pair stayed split until a newer release updated both Macs. +- The other Mac checks at its start and every minute while no update runs, also with automatic updates off. It finishes the accepted requests of its part first, as for an update, restores the release it kept from before its last update, quarantines the rolled-back release and restarts. Both Macs then skip that release, and the next newer release updates both. +- A Mac that keeps another earlier release, or none, or whose part serves on the leader's local API or alone, does not follow (yet) and says so once in `~/.darkbloom/cluster-setup/service.log`. While a pair runs on it, a Mac whose partner stops answering during the follow waits at most a minute, then changes nothing and tries again at the pair's next update slot. A Mac whose partner quarantined a release does not install that release either. +- Both Macs need this release or a later one, and the release a Mac rolls back to must have it too: the Mac that rolled back reports the rollback from the restored release. A rollback of this release itself is therefore not followed; rollbacks of later releases are. +- To roll back a pair by hand, stop one Mac's cluster service with `darkbloom cluster stop --service`, run `darkbloom update --rollback` there, and start it again with `darkbloom cluster`; the other Mac follows. + +### Two-Mac pairs recover after losing a rank during a stop + +- A two-Mac pair no longer stays unable to serve when it loses a rank while + its slot is stopping. Until the provider restarted, its leader refused every + later start, and `darkbloom cluster stop` left that Mac's part still + releasing. +- Fixed a deadlock in the pair's request engine. Stopping the pair slot + cancelled a request's stream while the engine was telling that request the + pair had lost a rank. The stream's cancellation waited for the engine, and the + engine waited for the cancellation to finish, so the slot never stopped. + Cancellation and stream termination now never wait for the engine. +- The leader also releases a committed start as soon as its session ends, + instead of after the old slot has fully stopped, so a slow stop can no longer + make it refuse later starts with "a committed start is already served". The + release receipt still waits, bounded, for the slot to retire, and a pair still + never serves two slots at once. + +### MiMo-V2.6-Flash and Gemma 4 26B QAT serve public cluster traffic + +- Two more models are approved for public traffic on two-Mac clusters, in pipeline and tensor parallel, as GLM-5.3-Flash and Qwen3.8 27B are: MiMo-V2.6-Flash (`mimo-v2.6-flash-mopd`) and Gemma 4 26B QAT (`gemma-4-26b-qat-4bit`). A release's cluster runtime facts carry their pair-serving grants and parity qualifications, so a pair of either model earns through Darkbloom on any Apple silicon pair, and `darkbloom cluster` lists them. +- Their tensor parallel serves once its code is in the build (Gemma 4 and MiMo tensor parallel PRs); until then they pair as a pipeline. MiMo-V2.6-Flash's speculative pipeline, its default split, is declared too. + +### A running cluster service answers after the Macs pair again + +- When the two Macs pair again while their cluster services run (`darkbloom cluster` or `darkbloom cluster pair`), each service starts its setup and control-lease listeners again with the new pairing within about 5 seconds. They used to keep the earlier pairing's key until the service restarted, so the other Mac's leases and its "Reading both Macs over the cable" step were refused (`refused (handshakeRejected)`). The service log says `this Mac's pairing changed (): answering the paired Mac with the new one`. +- A Mac left with no pairing stops answering over the cable. A pairing store that cannot be read leaves the listeners as they are. +- A Mac that paired again under a new Secure Enclave key of its own drops its earlier control state, as it already did when the other Mac's key changed. +- A cluster service started by an earlier release keeps the earlier behavior until it restarts (log out and back in, or `darkbloom cluster stop --service` and then `darkbloom cluster`). + +### Tensor parallel for Gemma 4 and MiMo only on measured speed + +- Gemma 4 and MiMo V2.6 Flash pairs choose tensor parallel only once tensor parallel's own speed is measured on both Macs: each Mac's half timed by a tensor-parallel load (Gemma), or requests this Darkbloom build served in tensor parallel. An estimate from the Macs' device index alone does not choose it, because the index overstates what half a model saves on big Macs: on two M5 Ultra it predicts a short Gemma request 6% faster in tensor parallel, where the plans expect decode 6-8% slower. +- When the estimate says tensor parallel would be faster, the pair keeps the pipeline. The plan's "Tensor parallel or pipeline" line says the predicted gain and that it comes from the device index, and the model list says "tensor parallel: not measured yet". +- Normal setups do not load tensor parallel to measure it, so these pairs keep the pipeline for now. MiMo does not yet time its halves at load, so MiMo pairs reach tensor parallel only from requests the same build served in tensor parallel. +- Tensor parallel must also keep every feature of the mode it would replace (see "Tensor parallel only where it keeps every feature"). +- Qwen and GLM still choose tensor parallel wherever it fits. + +### Fresh MDM removal guidance + +- Keep `darkbloom status` and both `darkbloom doctor` authorization summaries from offering MDM removal when the coordinator decision is too old for removal readiness. An unexpired App Attest serving lease stays visible; removal advice asks for fresh readiness and keeps existing profiles installed. The `darkbloom unenroll` checks are unchanged. + +### Gemma 4 replies keep characters outside its vocabulary + +- A Gemma 4 reply that ended in characters its vocabulary writes as byte tokens, such as many newer emoji, rare CJK and most Hangul syllables, lost all of them: `all zipped up 🗜` came back as `all zipped up `, and a reply made only of such characters came back empty. A long reply could also corrupt such a character when streaming restarted its decode inside its bytes. +- The Swift tokenizer library releases byte tokens only when a later token arrives. The provider's tokenizer bridge now releases a trailing run itself. `/detokenize` keeps it too. +- Token IDs, numeric logprobs, sampling and cache keys do not change, with one exception: a stop string that a trailing run completes now matches when the run completes, one token sooner, so `completion_tokens` can fall by one. +- A streamed reply's `logprobs` gains the entries of those tokens, which it used to drop. A byte token's `logprobs` text and `bytes` are U+FFFD or its ASCII character instead of empty, not the real byte. A reply cut inside a character by `max_tokens` now ends in U+FFFD instead of dropping it. + +### Gemma 4 plain decode commits by operation count + +- Plain decode steps of Gemma 4, the rows served without its assistant, commit a Metal command buffer every 100 operations instead of many times per step. Outputs are bitwise identical. Prefill and assistant rounds keep MLX's defaults. + +### Gemma 4 text keeps its spaces before punctuation + +- Gemma 4 replies, reasoning and tool arguments no longer lose the space before `.`, `,`, `?` and `!`, or repeat a quote. `git add .` came back as `git add.`, `bash ./run.sh` as `bash./run.sh`, `x != y` as `x!= y`, and, when streamed, `role = 'start'` as `role = ''start'`. +- Gemma 4's published `tokenizer_config.json` omits `clean_up_tokenization_spaces`, and the Swift tokenizer library reads a missing key as cleanup on, where Python Transformers reads it as off. The provider now resolves a missing key to off in memory for every model. An explicit Boolean is kept. +- Token IDs, sampling, model state and cache keys do not change. Only the text decoded from the same tokens does. Stop strings match the text as spelled: one with a space before punctuation can now match, and one that matched only the cleaned text (`add.` for `add .`) no longer does. + +### Faster Gemma 4 pipeline pairs + +- Gemma 4 pipeline stages compute a prompt chunk's expert blocks in one shared dispatch per operation instead of one subgraph per prompt token, with the same bytes for every token (unchanged arithmetic receipt). Batch-decode rows share the same dispatch. On one synthetic expert layer this cut a 2,048-token chunk from about 370 ms to about 31 ms; pair throughput is not yet measured. +- A Gemma 4 pipeline pair whose setup prefills serially, coordinator-registered pairs included, now serves four requests at once. Each lane is admitted against live memory on both Macs. A pair planned with the one-chunk lookahead keeps serving one request at a time. +- The planner's hardware prior counts 8 of Gemma 4's 128 experts per token instead of every expert byte. + +### Gemma 4 tensor parallel on two-Mac clusters + +- Gemma 4 26B (QAT 4-bit and 8-bit) can run tensor parallel on a pair: each Mac holds half of every layer's heads and expert channels, both share every token over the encrypted link, and the pair returns the same tokens a single Mac would on the synthetic checks. Text only. +- The planner chooses tensor parallel for Gemma 4 only where it predicts it faster than the pipeline, from tensor parallel's own speed measured on both Macs (see "Tensor parallel for Gemma 4 and MiMo only on measured speed"). Prompt-heavy requests keep the pipeline. Qwen and GLM still choose tensor parallel wherever it fits. +- In tensor parallel, Gemma 4 returns logprobs (`logprobs` / `top_logprobs`), and each Mac reserves memory for its own half of the model: about 8.0 GB of weights at QAT 4-bit (14.9 GB at 8-bit) plus its own KV, with a conservative 5.5 GiB activation reserve until a pair measures one. +- Gemma 4 tensor parallel keeps prompt prefixes as the pipeline does, in memory and in the encrypted SSD tier: a repeated or shared prompt prefix is restored only when both Macs hold it, with exactly the tokens of a request that prefilled the whole prompt, and it survives a restart of both Macs. Each request reserves room for its own prompt's prefix (about 0.44 GB a Mac for a 32K-token prompt); kept prefixes use free memory only and are dropped first when memory runs short. +- Gemma 4 tensor-parallel pairs serve one request at a time unless `DARKBLOOM_CLUSTER_BATCH_LANES` names more. Speed on a real pair is not measured yet. + +### A latent stop race in GLM tensor parallel's one-token decode + +- No released pair is affected, and serving is unchanged: every v0.10.6 GLM-5.3-Flash tensor-parallel pair loads the model's NextN (MTP) layer and decodes every request in MTP rounds, which already end both Macs together when a request stops just before the model's end token. +- The one-token decode, which only a build without that layer runs, now does the same: both Macs end at the end token and return the text up to the stop (for example, a stop string that matched just before the answer ended). Before, the stopped Mac built one more step alone and waited in a collective the other Mac, already finished at that token, never joined, so the request would stall and fail on both Macs. + +### GPT-OSS plain decode commits by operation count + +- Plain decode steps of GPT-OSS commit a Metal command buffer every 100 operations instead of after almost every MoE layer. Outputs are bitwise identical. Prefill keeps MLX's defaults. + +### MiMo pipeline decode command buffers and expert routing + +- MiMo V2.6 Flash pairs encode decode steps, lane steps and speculative rounds + in Metal command buffers of up to 100 operations with no input-size bound, as + GLM and Qwen tensor parallel already do. Prefill keeps the rank's limits. + Tokens, logits and caches are byte-identical on synthetic stages. The speed + effect on the registered model has not been measured yet. +- A MiMo request's memory charge now prices every full-attention layer's decode + score rows at once, which the larger command buffers can keep alive together. + The LOAD quote is unchanged. Only requests whose prompt frames are shorter + than a stage's full-attention layers times the decode rows (32 tokens at most) + are charged slightly more. +- The planner's hardware prior now counts MiMo's routed experts at the 8 of 256 + a token uses: 10.77 GB read per decode step instead of 166.6 GB. The prior + prices only tensor parallel, so MiMo's pipeline plans are unchanged. + +### MiMo image-candidate pairs keep cluster prompt prefixes + +- A MiMo V2.6 Flash pair serving the private, local-only image candidate no + longer fails its requests while the cluster prefix cache is on (the + default). That candidate is the only MiMo load with contiguous caches. MiMo + still required the five metadata values that older MLX SDKs wrote for a + sliding-window cache, while the pinned SDK writes seven (adding the capacity + origin and a wrapped flag), so requests, text or image, failed at their + first prompt-prefix capture. Prefixes are now captured and restored. The + four text serving modes use paged histories with prefix reuse off and were + not affected. + +### MiMo V2.6 Flash tensor parallel on two-Mac clusters + +- MiMo V2.6 Flash text can run tensor parallel on a pair: each Mac holds half of every layer's heads and expert channels and half of the output head, both share every token over the encrypted link, and on the synthetic checks the two Macs agree bit for bit with a one-process simulation of both halves. The image candidate stays a pipeline. +- Each Mac's half of a layer's attention output and feed-forward is kept at full 32-bit precision until both halves are added, then rounded once, so a pair never rounds more than one Mac does. On the synthetic checks, the two halves of an expert's output add up bit for bit to the full output that one Mac rounds once. +- The planner chooses tensor parallel for MiMo only where it predicts it faster than the pipeline with speculative decoding, which MiMo's qualification records credit 1.37x, from tensor parallel's own speed measured on both Macs (see "Tensor parallel for Gemma 4 and MiMo only on measured speed"). Two 128 GB Macs, which cannot hold MiMo alone, can serve it this way. Qwen and GLM still choose tensor parallel wherever it fits. +- In tensor parallel, MiMo returns logprobs (`logprobs` / `top_logprobs`), serves one request at a time with speculative decoding (see "MiMo V2.6 Flash tensor parallel with speculative decoding"), and each Mac reserves memory for its own half: 84.0 GB of weights plus its own KV, work and buffers, with a conservative 5.5 GiB activation reserve until a pair measures one (about 100 GiB per Mac at the longest request, the draft heads included). +- No MiMo tensor-parallel qualification record exists yet, and speed on a real pair is not measured. + +### MiMo V2.6 Flash tensor parallel with speculative decoding + +- A MiMo V2.6 Flash tensor-parallel pair decodes with MiMo's own trained draft heads: each round checks up to two drafted tokens in one pass through the pair, so every token a round keeps shares that pass's link and weight costs. +- It is on by default: the installed provider starts both Macs' tensor-parallel workers with two drafts a round. +- Output is identical to tensor parallel without drafting, token for token and bit for bit on the synthetic checks: greedy (with or without logprobs) and sampled. Each Mac's halves stay at full 32-bit precision inside a round too, exactly as in a one-token step. Every kind of stop works inside a round. Requests with penalties or a logit bias, and sampled requests that ask for logprobs, decode one token at a time, as in the speculative pipeline. +- Each Mac holds the draft heads whole (about 2 GB more) and reserves their per-request state, and the plan counts both before it chooses tensor parallel. Two 128 GB Macs still fit, at about 100 GiB a Mac. +- Because MiMo's tensor parallel now keeps the speculative pipeline's rounds, feature parity no longer holds it back where that pipeline is the mode it would replace; its measured speed decides, and the plan credits the rounds no speed-up until they are measured. Where the plain pipeline is the mode it would replace, that pipeline's batch lanes still keep it. +- Not yet measured on a real pair: the speed-up, the heads' acceptance rate and qualification records. + +### The Models page shows what the network registered + +- Each model on the Models page now says whether this Mac's live registration carries it: "Registered with the network" (the network sends it requests), "Registered for Autopilot" (Autopilot can load it), or, for a selected or pool model, a warning "Not registered with the network yet". Before, the page showed only what was selected, downloaded or loaded, so a selected model the network did not know looked like it was serving. +- The provider writes the registered set to its state file (`registered_models`). +- A Mac with Autopilot that is busy at every check, or always under a lease, now reports a newly verified build after at most 10 minutes. The re-registration closes admission, lets accepted requests finish, then reconnects. Before, such a Mac could wait without end, and Autopilot could not use the build. + +### Pipeline decode command buffers for the remaining cluster models + +- Cluster pairs of the Qwen and Bonsai rows, Nemotron 3.5 Lightning, Gemma 4, + GPT-OSS 20B and GLM-5.3-Flash encode decode steps (pipeline and phase split), + lane steps and speculative rounds in Metal command buffers of up to 100 + operations with no input-size bound, as GLM and Qwen tensor parallel already + do. Prefill keeps the rank's limits. Tokens, logits and caches are + byte-identical on synthetic stages. The speed effect on registered models has + not been measured yet, and each family keeps the change only if a pair A/B + shows a gain. +- A request's memory charge on those pairs, other than GLM's, now prices every + attending layer's decode rows at once, which the larger command buffers can + keep alive together. The LOAD quotes are unchanged. Only requests whose prompt + frames are shorter than their decode rows (at most 80) are charged more, and + only on a rank that decodes. + +### The enabled-model filter wins over coordinator model changes + +- A model you deselect with `darkbloom switch` or delete with `darkbloom models remove` no longer comes back on its own. Before, when the coordinator moved a public model to a newer build, every Mac serving that model downloaded the newer build, served it in place of the build its operator chose and loaded it, even when `enabled_models` left it out. For example, with `gemma-4-26b` selected and `gemma-4-26b-qat-4bit` deselected, `gemma-4-26b-qat-4bit` returned within minutes and `darkbloom status` showed `Serving outside the enabled model filter: gemma-4-26b-qat-4bit`. +- With `enabled_models` set, the provider now refuses a coordinator `load_model` or `prefetch_model` for a model outside it (`model_not_selected`), and keeps serving the build you selected when its public model moves to a build you did not list. The log then says `desired_models: → is outside the enabled model filter; not converging`. +- **Your provider no longer moves to a new build of a model by itself.** To take one, run `darkbloom switch` and pick the model's public name; the picker shows its newest build under that name. Until you do, the newer build gets that model's requests first. +- `darkbloom switch` applies its selection as the filter at once, without a restart. +- Nothing changes with an empty `enabled_models` (serve every downloaded model), or for Autopilot's consented downloads and placements. + +### Child process exit waits + +- Report a finished child process without the former polling and run-loop delay. Bounded children (the paged-kernel preflight, update staging, runtime smoke and signature checks, `darkbloom doctor` and `verify` probes) are reported up to about 120 ms sooner each, and waiting for `launchctl`, `codesign`, `profiles`, `open` and `log` no longer runs the calling thread's run loop. Timeouts and the SIGTERM-then-SIGKILL escalation are unchanged. + +### Provider status App Attest lease + +- Keep `darkbloom status` and `darkbloom doctor` reporting App Attest authorization until the coordinator lease expires. They required a renewal within the last 10 seconds, so one delayed renewal showed `Trust: self_signed / online` although serving continued. `darkbloom unenroll` still requires a renewal within 10 seconds before offering MDM removal. + +### Roll a Mac back to its previous release + +- `darkbloom update --rollback` restores the release a Mac ran before its last update. When the updater installs a release, it keeps the signed release it replaces; the rollback puts that release back, also after the new one has served for 10 minutes and was promoted. +- It shows the installed and restored versions and asks `Roll back to vX? [y/N]` before changing anything (`--yes` skips the question). The running provider finishes its accepted requests (`--timeout`, `--force` as for `darkbloom update`), the kept release replaces the installed one in the watchdog's journaled swap under the update lease, and the provider restarts on it. It contacts no coordinator. +- The rolled-back release is quarantined on that Mac: the provider's 30-minute update check, the startup check and the watchdog do not reinstall it, and the next newer release installs normally, so automatic updates can stay on. `darkbloom update --override-quarantine` installs it again on request. +- It refuses and changes nothing on a Mac that serves in a `darkbloom cluster` pair, while a provider runs in the foreground (`darkbloom start --foreground`), while another update or recovery runs, when no earlier release is kept or the kept one is already installed, when the installed bundle is not the release the updater recorded, and when the kept release fails its hash or signature check. +- Only one earlier release is kept. A Mac rolls back to the release it ran before its last update, not further. + +### Qwen tensor-parallel decode control in the selection sum + +- A Qwen tensor-parallel pair's plain decode step now carries the next step's + plan and report in its own sealed selection sum, so the step pays one sealed + sum and one host read fewer than before. Tokens, logits and native state are + unchanged; assisted (MTP) rows, prompt steps and idle steps keep their own + exchange. +- Owner answers, cancellations and joins now apply one step later while plain + rows decode. A row decodes its next token once the owner answered the token + before it, so an answer that arrives while a step computes no longer leaves + the row idle for a step. Rank 0 still publishes a token only after the + owner's answer to the one before it. A token selected before a stop answer is + never published, so streamed text, usage and logprobs are unchanged. +- A clean stop the owner asks for (a stop string, for example) can cost one + more forward, which is discarded. On a one-lane pair every such stop after a + request's first token does (assisted rows excepted), and that request's + finish arrives one decode step later than before. +- Both ranks of a pair must run this build: the load agreement binds the new + control wire (`qwen-tp-independent-history-batch-v2-folded-control`). +- `darkbloom-cluster-tp-check qwen-decode` times the batch driver's decode on + two ranks over the loopback ring, with the control exchanged or folded, and + checks that both retire the same tokens. + +### Qwen tensor-parallel decode routes, row exactness and finiteness check + +- A Qwen3.8-27B tensor-parallel row now decodes the same bytes alone as beside + other rows and in verify windows on the registered weights. A one-row decode + step's fused SwiGLU computed its sigmoid with Metal's fast `exp`, while + cohort and window steps use MLX's precise `exp`. The two round a gate of + exactly bf16 -6.84375 differently, which could change later tokens. Dense + Qwen tensor-parallel output changes only where a one-row decode step meets + that gate value, and there it now equals the cohort path. Regenerate + tensor-parallel serving references recorded with earlier builds once. + Single-Mac output is unchanged. +- A non-finite logit on either rank of a Qwen tensor-parallel pair now fails + both ranks in the same selection step, before any token is published; + previously the other rank waited in the selection collective. The check moved + into the selection's sealed sum, so a decode step no longer pays a separate + finiteness read. Selected tokens are unchanged. +- Each rank logs its decode routes once per load, when it first serves + (`darkbloom-qwen-tp-decode-census-v1`): which projections take the + batch-invariant kernel and at which layout per row count, the attention and + residual-norm routes, and the arithmetic switches in force. +- `darkbloom-cluster-tp-check qwen-rows` checks, on one Mac over the loopback + ring, that a Qwen3.8-27B row decodes the same bytes alone, beside other rows + and in verify windows at the registered per-rank widths, with random weights + that follow the registered artifact's value statistics or with the registered + checkpoint itself; `qwen-rows layers` names the first layer that differs. + +### Qwen tensor-parallel pairs serve up to 8 requests at once, sized to memory + +- `darkbloom cluster` now sets how many requests a Qwen tensor-parallel pair + serves at once: 8, 6, 4 or 2, the most that both Macs' memory holds now with + the full load reservation for that many. The pair serves them from its first + load. Before, it served one at a time: a local pair widened only after a + burst, through a reload the burst waited for, and a pair serving Darkbloom + traffic never widened. +- On two idle Macs, Qwen3.8-27B serves 8 at once from 64 GB a Mac without the + speculative assistant (4 at 48 GB, 2 at 32 or 36 GB), and 8 from 96 GB a Mac + with it (local clusters only); smaller Macs serve fewer. Two M5 Ultras serve 8 either + way. When not even 2 fit, the pair serves one request at a time, as before. +- Memory safety is unchanged: both Macs reserve that many requests' full memory + when the model loads and admit each request alone. A local pair set up + narrower still widens when requests queue; a pair set up for 8 is never + reloaded for it. +- Existing setups keep serving one request at a time until they are planned + again, as after an update. A pair serving Darkbloom traffic keeps its width + beside its approval; no approval, registration or committed-start digest + changes. + +### Qwen tensor-parallel prompt wavefront + +- A Qwen tensor-parallel pair now prefills a text prompt faster, in steps of up + to eight consecutive 512-token frames built as one graph, layer by layer: + while one frame's sealed sum crosses the link, the next frame computes. Every frame + keeps its own shapes and kernels, so logits, KV, recurrent state, prefix + captures and tokens are unchanged. Steps run two frames while another lane + decodes and end at the prompt-cache capture point. Media prompts, assisted + (MTP) prompts, packed KV and routed-expert models keep one frame a step. +- The merged step's frames in flight are charged in LOAD, the placement quote + and each request's charge: a Qwen3.8-27B tensor-parallel rank needs about + 367 MB more at any width. +- `darkbloom-cluster-tp-check qwen-prefill --wavefronts 1,8` and + `darkbloom-cluster-tp-check qwen-wavefront` measure the merged steps on one + rank and on two ranks over the loopback ring. + `DARKBLOOM_QWEN_TP_PROMPT_WAVEFRONT=0` restores one frame a step for + diagnosis; both ranks must agree. + +### Qwen3.8 27B tensor parallel reuses whole prompt prefixes + +- A Qwen tensor-parallel pair now reuses a repeated prompt's prefix to its last whole 512-token chunk instead of at most 4,096 tokens, including prompts longer than 32,768 tokens: a repeated 33K-token prompt restores 32,768 tokens on both Macs, as one Mac does. It also keeps the boundaries the next turn of a conversation and prompts that share a long system prompt need, so in each of these cases it reuses at least what one Mac reuses, to the nearest 512 tokens. +- A prefix restored from memory returns exactly the tokens of a request that prefilled the whole prompt (checked bit for bit on synthetic pairs at 8K, 16K and 32K boundaries); one restored from the SSD tier's default `balanced` records is close but not identical, as before. Both Macs must hold a boundary; otherwise both start from zero. +- Each request reserves room for its own prompt's prefix (about 1.8 GB a Mac for a 32K-token prompt on the 27B), and a pair loads with one such prefix per lane: about 1.1 GB a Mac more than before at one lane. Every pair size that ran the 27B in tensor parallel still does. Kept prefixes use free memory only (half of what is left after loading) and are dropped first when memory runs short. Prefixes kept on SSD by an earlier build are not reused. +- Requests served by the assistant (MTP) lanes still reuse at most 4,096 prompt tokens, less than one Mac reuses for a long prompt; deepening them is a separate change. Speed on a real pair is not measured yet. + +### Stop sequences no longer match Gemma 4 or `` reasoning + +- A client `stop` sequence on Gemma 4 models such as `gemma-4-26b-qat-4bit`, + and on models that reason in `` blocks (Qwen 3.5, 3.6 and 3.8, + among others), now matches only the text returned as `content`. With + reasoning on, it used to match the reasoning too, so a sequence that + appeared while the model reasoned (for example `"."` or `"\n\n"`) ended the + request before any answer: `finish_reason` `stop`, reasoning only, empty + content. +- With tools declared, tool-call frames are not cut either, except a frame + whose arguments quote its own closing tag, or a bare `` frame + written without its wrapper. When a request has no tool handler (no declared + tools, or a media request on a family without native media tools), a literal + tool tag in an answer is text the client receives, and stops still apply to it. + Whitespace before the answer's first character (the blank line after + ``) cannot complete a stop sequence on its own. +- A stop sequence that names a marker no longer fires on it: ``, or + `` with tools declared. + +### Sandbox setup shows the add-on's own sizing plan + +- `darkbloom sandbox setup` now asks the Darkbloom Sandbox installer for the add-on's own plan before it asks you to confirm. After its own chip, macOS, session, network, power and sleep checks, setup runs the downloaded installer with `--plan` (add-on 1.1.1 and later). The installer verifies the release and sizes this Mac without installing anything. Setup then prints the plan's cores, memory and disk lines and how many Linux and macOS jobs this Mac can run at a time. Example: `Disk: 157 GiB free; 100 GiB stays free for you; Linux images 4 GiB + 30 GiB per Linux job; macOS images 46 GiB + 40 GiB per macOS job`. +- Disk follows the add-on's rules. A tenth of the disk (50 to 100 GiB) stays free. The first job of a platform also needs that platform's VM images (Linux 4 GiB, macOS 46 GiB, nothing once installed). Each Linux job takes 30 GiB and each macOS job 40 GiB. +- When no job fits, setup prints the plan's message and how much disk to free for one Linux job and for one macOS job. It then stops without installing. +- The installer is now downloaded before the question, so the plan is shown before you confirm. Nothing is installed before you answer `y`. +- With an older installer that cannot report a plan, setup prints `[INFO] Sizing` and estimates with the same rules. +- Setup's output is line-buffered: run over ssh or into a pipe, it shows the approval link as soon as the installer has it, not once setup ends. +- With add-on 1.1.2 and later, a Mac waiting for approval keeps waiting in the background, also across restarts, and enrolls by itself, and setup now says so. On the waitlist it says you can close the window, and after Ctrl-C it says that the Mac keeps waiting; both point at `darkbloom sandbox status`. With an earlier add-on, setup words both as before. + +### Sandbox setup offers the add-on's new plan on a Mac that is set up + +- Running `darkbloom sandbox setup` on a Mac that is set up now asks the Darkbloom Sandbox installer for the add-on's plan again (`--plan`, which changes nothing). When the plan's Linux and macOS job counts differ from the installed ones, setup shows the plan's CPU, memory and disk lines and asks, for example `This Mac now fits 1 Linux + 1 macOS (installed: 3 Linux + 0 macOS). If a job is running, the installer refuses and changes nothing. Apply? [Y/n]`. Yes reinstalls with the plan's counts; no prints the `--linux-slots`/`--macos-slots` command that applies it later. When the counts match, the output is exactly as before. +- With `--yes` or without a terminal, setup applies the plan only when it adds jobs and removes none; otherwise it prints `Not applied` and the command, and exits 0. +- While jobs run, setup skips the check and says to run it again once they finish. When the installer refuses because a job is running (exit 4), setup now says that a job is running, to run setup again when it finishes, and that it never passes the installer's `--force`, which would stop running jobs, which aren't paid. +- Explicit `--linux-slots`/`--macos-slots`, an installer without `--plan` and a failed download behave as before. A platform missing from the add-on's `status --json` counts as 0 slots. +- When the add-on's plan gives macOS no job for want of free disk space, setup adds one line: ``Free space here is what `df -h ~` shows as Avail; Finder also counts purgeable space, which macOS frees only when it needs to (restarting, or removing Time Machine local snapshots: `tmutil listlocalsnapshots /`, frees it now). A macOS job needs about N GB more.`` N counts the disk the plan's Linux jobs take, so a Mac planned for 3 Linux jobs and no macOS job gets a real number. + +## v0.10.6 + +Published 2026-10-31 ([release](https://github.com/Layr-Labs/d-inference/releases/tag/v0.10.6)). ### Upgrade and rollout notes diff --git a/changelog.d/app-attest-first-episode.md b/changelog.d/app-attest-first-episode.md deleted file mode 100644 index e1802854a5..0000000000 --- a/changelog.d/app-attest-first-episode.md +++ /dev/null @@ -1,4 +0,0 @@ -### App Attest restart covers the first episode after an update - -- The `is_supported_false` restart now also works in the first process after an update from a version that did not record its App Attest authorizations. At serve start, when `app-attest-verified.json` is missing, the provider fills it once from the previous `daemon-state.json`, with evidence from the last 7 days: the last successful Apple call of a stored key that Apple attested, or an App Attest grant left by an unclean exit. All other conditions stay the same. -- A Mac whose previous provider was itself reporting `is_supported_false` has no such evidence, so it still waits for the coordinator to grant App Attest again. diff --git a/changelog.d/app-attest-unsupported-restart.md b/changelog.d/app-attest-unsupported-restart.md deleted file mode 100644 index 97ed5acd15..0000000000 --- a/changelog.d/app-attest-unsupported-restart.md +++ /dev/null @@ -1,6 +0,0 @@ -### App Attest recovers by itself after a self-update - -- A provider that launchd runs as its provider job now relaunches through launchd after a startup self-update, as it already did after a background update. Only a provider that launchd does not run, such as `darkbloom start --foreground` in a terminal, replaces itself in place. A background update or App Attest restart in such a provider no longer starts the LaunchAgent instead. -- When App Attest reports `is_supported_false` on a Mac that the coordinator verified for App Attest in the last 7 days, the provider restarts once through launchd. It waits until the state lasts 5 minutes and the provider is idle, and it checks Apple's answer again after the drain. If the new process still reports unsupported, it does not restart again until the coordinator verifies the Mac again. This restart and the stall restart share one limit: one automatic App Attest restart per 6 hours. Cluster members never restart for it. -- The provider keeps the time of its last App Attest authorization in `app-attest-verified.json` beside the daemon state file. -- The local provider log gets an `App Attest entitlement evidence` line at startup and at each `is_supported_false` answer: the start reason, the App Attest entitlements of the running process and of the code on disk, and the executable's modification time relative to the process start. It is not sent to the coordinator. diff --git a/changelog.d/checkpoint-row-decoder.md b/changelog.d/checkpoint-row-decoder.md deleted file mode 100644 index 96ee68c9b4..0000000000 --- a/changelog.d/checkpoint-row-decoder.md +++ /dev/null @@ -1,10 +0,0 @@ -### Cache restores finish sooner - -- Restoring a prefix-cache checkpoint decodes its older attention rows from the - default `balanced` checkpoint precision on the CPU. The decoder now checks each - row for values its native type cannot hold once per row instead of once per - eight values, with the same bytes and the same refusals. On Gemma 4 26B - follow-up requests served from the SSD cache, time to first token fell by about - 0.2 s per restore (about 25% over an 11-request conversation on an M3 Ultra), - and responses that save a checkpoint also end about 0.2 s sooner. Output is - unchanged. diff --git a/changelog.d/checkpoint-row-encoder.md b/changelog.d/checkpoint-row-encoder.md deleted file mode 100644 index 0779a093f3..0000000000 --- a/changelog.d/checkpoint-row-encoder.md +++ /dev/null @@ -1,8 +0,0 @@ -### Responses that save a cache checkpoint finish sooner - -- Saving a prefix-cache checkpoint encodes its older attention rows at the default - `balanced` checkpoint precision. That encoding now prepares its buffers and its - check once per segment instead of once per row and writes the same bytes. On a - Gemma 4 26B request that saves a checkpoint, the end of the response arrived - about 0.7 s sooner (1.7–2.0 s → 1.0–1.2 s on an M3 Ultra), with identical - output. Requests that save no checkpoint are unchanged. diff --git a/changelog.d/ci-git-swiftpm-cache.md b/changelog.d/ci-git-swiftpm-cache.md new file mode 100644 index 0000000000..453f30eb74 --- /dev/null +++ b/changelog.d/ci-git-swiftpm-cache.md @@ -0,0 +1,11 @@ +### CI caches .git and SwiftPM repositories; only master and dev pushes save caches + +- Every `ci.yml` job that checks out restores the newest saved `.git` first, so the checkout fetches only new objects and reuses submodule clones. A restored `.git` that `git fsck` rejects is deleted first; no step continues on error. The `.git` key names the UTC day, so each branch saves `.git` at most once a day. The full-history `docs` job keeps its own entries. +- The build lanes restore SwiftPM's repository clones, which a cold build otherwise downloads. +- Checkouts download less. Every job but Docs Lint skips the evidence tarballs under `docs/reports/evidence` and `landing/public/media` (408 MB of tarballs and landing videos), which no other job reads. Docs Lint and Docs Impact fetch history without file contents, about 37 MiB instead of about 1 GB, and fetch old file versions only when the provenance check reads them. +- Only pushes to `master` and `dev` save CI caches. A pull request restores its base branch's entries, then `master`'s, and saves none, so it no longer evicts them from the repository's 10 GB Actions cache. +- Provider builds on Darkbloom Macs use the CMake 3.31.12 already in the image's tool cache instead of downloading 80 MB each time; other runners still download and verify it. +- The MiMo audio gate, and the 1.87 GB codec its fixture needs, run only when the gate's inputs change (MiMo, audio and media provider code, the MiMo tests, the MLX pins, the fixture scripts or the gate's recipe) and on every `master` push. Pull requests never save the codec. +- Checkouts no longer keep the job token in `.git/config`, which the `.git` cache would otherwise store. +- Each job logs whether `actions/cache` compresses with zstd or gzip; entries saved with one are not restored by a runner using the other. +- Limitation: on a pull request, the provider summary job restores its base branch's newest compatible build and rebuilds the commit's changes instead of reusing its shards' build. diff --git a/changelog.d/ci-macos-darkbloom-route.md b/changelog.d/ci-macos-darkbloom-route.md new file mode 100644 index 0000000000..8e1fa03580 --- /dev/null +++ b/changelog.d/ci-macos-darkbloom-route.md @@ -0,0 +1,6 @@ +### CI's macOS jobs ask for Darkbloom Sandboxes again + +- The macOS jobs of `ci.yml` read the Darkbloom route again, as they did before they moved to Blacksmith only. Each provider shard (`test-provider-1` to `test-provider-3`), the shard summary (`test-provider-summary`), the SDK lane (`test-provider-sdk`), the cluster metadata checks (`test-cluster-checks`), each cluster runtime and GPU shard (`test-cluster-1` to `test-cluster-3`, `test-cluster-gpu-1`, `test-cluster-gpu-2`) and the cluster focused checks (`test-cluster-focused`) run on a Darkbloom Mac when the plane grants their lane, and on `blacksmith-12vcpu-macos-27` otherwise. +- A lane is requested only when its job runs: the provider lanes when provider inputs change, the SDK lane on pushes and SDK-lane changes, and the cluster lanes when cluster inputs change. +- The provider shard count, the cache-save rules and the `.git` and SwiftPM caches are unchanged. +- Limitation: a lane the plane's approval does not name keeps Blacksmith, as do all lanes while `DARKBLOOM_ROUTING` is not `on` and for pull requests from forks. diff --git a/changelog.d/cluster-auto-update.md b/changelog.d/cluster-auto-update.md deleted file mode 100644 index 96cfbf1c21..0000000000 --- a/changelog.d/cluster-auto-update.md +++ /dev/null @@ -1,10 +0,0 @@ -### Pair Macs set up with `darkbloom cluster` update themselves - -- A Mac set up with `darkbloom cluster` now updates itself, as a single Mac does: with `auto_update` on (the default) and without `DARKBLOOM_NO_UPDATE_CHECK`, its cluster service checks the coordinator's latest release every 30 minutes, at the pair's update slot, which both Macs derive from their pairing's cluster ID. -- Each Mac downloads, verifies and stages the release while the pair serves. Only once both Macs have it does the pair stop taking new requests; the Mac that serves the pair finishes its accepted requests (at most 120 seconds, never cancelling one), then both Macs install the release and restart their cluster services, and the cluster sets itself up again for the new release with no command run. -- A pair under constant traffic updates too: once it takes no new requests, the accepted ones finish. A pair still running a request at the bound takes requests again and tries at the next slot. A release one Mac cannot download or verify is installed on neither Mac; both try again at the next slot. -- An installed release is promoted once its cluster service has stayed healthy for 10 minutes; three starts of its service that end on their own restore the previous release and quarantine the new one, as the watchdog does for a single Mac. -- Before a Mac restarts into an installed release, its cluster service runs the new `darkbloom --version` once (at most 30 seconds). A release that does not answer with its version is never restarted into: the Mac restores the previous release at once, quarantines the new one and starts its cluster service again, so a release that cannot start no longer leaves the Mac with nothing to roll it back. -- `darkbloom update` on a cluster Mac installs the release and then restarts the cluster service into it together with the other Mac, after the pair drained; logging out and back in is no longer needed. Run it on both Macs (or let the other Mac update at the next slot); the first Mac waits up to 15 minutes for the second, also when automatic updates are off. A Mac whose partner has automatic updates off downloads nothing at the slot. -- A pair that serves on the leader's local API, or a Mac that serves alone, is not drained for an update yet: it does not update while it serves, and a cluster set to serve locally (`darkbloom cluster local`) or a Mac serving alone downloads nothing at the slot. -- A cluster service started by an earlier release does none of this: to reach this release, run `darkbloom update` on both Macs, then log out and back in on both (or restart them) once. diff --git a/changelog.d/cluster-feature-parity.md b/changelog.d/cluster-feature-parity.md deleted file mode 100644 index 5836a1a955..0000000000 --- a/changelog.d/cluster-feature-parity.md +++ /dev/null @@ -1,6 +0,0 @@ -### Tensor parallel only where it keeps every feature - -- On a two-Mac pair, Gemma 4 and MiMo V2.6 Flash use tensor parallel only where it keeps every feature and caching behavior of the mode it would replace: prompt-prefix and SSD cache reuse, speculative (MTP) rounds, batch lanes, media, penalties and logit bias, stop handling and logprobs. What tensor parallel adds, such as logprobs where the pipeline has none, never counts against it. Each mode's features come from the installed cluster worker's capability record. -- Gemma 4's tensor parallel keeps every feature of its pipeline, prompt-prefix and SSD reuse included, so its measured speed decides. MiMo's tensor parallel decodes in speculative rounds, so it keeps every feature of the speculative pipeline and its measured speed decides; only where the plain pipeline is the mode it would replace do that pipeline's batch lanes keep it. The plan's "Tensor parallel or pipeline" line says what tensor parallel would drop ("Pipeline: tensor parallel would drop batch lanes up to 8 (it serves 1) that the pipeline keeps; held back until it keeps them."), and the model list says "tensor parallel: drops a feature". -- Where only tensor parallel fits the two Macs, the plan refuses with that reason and saves no setup, instead of saving one with fewer features. The developer's forced mode (debug builds) still places tensor parallel, and the plan says exactly what it drops. -- Qwen and GLM plans are unchanged. diff --git a/changelog.d/cluster-onboarding-simple.md b/changelog.d/cluster-onboarding-simple.md deleted file mode 100644 index 73e3b45e2f..0000000000 --- a/changelog.d/cluster-onboarding-simple.md +++ /dev/null @@ -1,15 +0,0 @@ -### Simpler two-Mac cluster setup - -- `darkbloom cluster` setup says far less: four steps (Connect, Pair, Model, Start), a line per thing that happened, - and the next thing to do last. Every choice is a list (↑↓ and enter, as `darkbloom start` picks models; numbered in - plain transcripts); q or Esc cancels. -- The model list shows only the models approved for clusters (GLM-5.3-Flash, Qwen3.8 27B, MiMo-V2.6-Flash and - Gemma 4 26B QAT) that the two Macs can serve, each with its size and its split: tensor parallel or pipeline. The - serving lines name the split too. -- The Mac you set up on leads and keeps leading: every plan puts rank 0 on it, the cluster service's own re-plans - included, so a pair set up with 0.10.6 whose other Mac took over leading moves back at its next plan. -- macOS's password and Local Network prompts come at stated moments (sudo in the terminal over SSH); both Macs ask - about Darkbloom's Local Network access right after pairing, and the setup waits until Allow or q. -- Both Macs confirm the pairing code; the Mac that follows only shows the status. The serving line says whether the - pair earns through Darkbloom or serves locally only. -- `darkbloom doctor` includes the cluster's checks on a Mac paired for a cluster. diff --git a/changelog.d/cluster-pair-equal-tensor-shares.md b/changelog.d/cluster-pair-equal-tensor-shares.md deleted file mode 100644 index 7604e1c227..0000000000 --- a/changelog.d/cluster-pair-equal-tensor-shares.md +++ /dev/null @@ -1,5 +0,0 @@ -### Qwen pairs of two different Macs register with the coordinator - -- Affected: a pair of two different Macs set up with `darkbloom cluster` to serve through Darkbloom, with a Qwen model planned in tensor parallel. The planner gave the faster Mac the larger share of every layer (for example 2:1 on an M3 Ultra and an M5 Max), and the coordinator registration cannot name unequal shares yet. Both Macs still said `Registered with the coordinator as a cluster member`, then each Mac's part refused to register ("The saved roster registration is not valid for this Mac: invalidPlan"), the pair fell back to the leader's local API, and the coordinator never formed it or routed it a request. This hit Qwen3.8 27B, which pairs only in tensor parallel, and Qwen3.5 9B where tensor parallel was chosen. GLM-5.3-Flash, pipeline splits and two identical Macs were not affected. -- A pair served through Darkbloom is now planned with equal tensor-parallel shares, so it registers and is routed like a pair of identical Macs; on two different Macs the slower one sets the pace. A pair that serves you alone (`darkbloom cluster local`) keeps the faster unequal split. -- A setup saved with unequal shares (by 0.10.6, or a local cluster switched to Darkbloom with `p`) is not offered for pairing, and the leader says why before it stops either Mac's part: `Not offered for pairing: this Mac's check refused it: Unequal tensor-parallel shares serve local clusters only …`. If `darkbloom cluster` shows this once both Macs run this release, press `m` and choose the model again: it is planned with equal shares and registers. diff --git a/changelog.d/cluster-pair-follows-rollback.md b/changelog.d/cluster-pair-follows-rollback.md deleted file mode 100644 index 2a6cebd878..0000000000 --- a/changelog.d/cluster-pair-follows-rollback.md +++ /dev/null @@ -1,7 +0,0 @@ -### Both Macs of a pair roll back together - -- When one Mac of a `darkbloom cluster` pair rolls a release back (three failed starts of its cluster service, a failed start check, or `darkbloom update --rollback` while its cluster service was stopped), the other Mac now rolls back to the same earlier release, and the pair serves it together. Before, the pair stayed split until a newer release updated both Macs. -- The other Mac checks at its start and every minute while no update runs, also with automatic updates off. It finishes the accepted requests of its part first, as for an update, restores the release it kept from before its last update, quarantines the rolled-back release and restarts. Both Macs then skip that release, and the next newer release updates both. -- A Mac that keeps another earlier release, or none, or whose part serves on the leader's local API or alone, does not follow (yet) and says so once in `~/.darkbloom/cluster-setup/service.log`. While a pair runs on it, a Mac whose partner stops answering during the follow waits at most a minute, then changes nothing and tries again at the pair's next update slot. A Mac whose partner quarantined a release does not install that release either. -- Both Macs need this release or a later one, and the release a Mac rolls back to must have it too: the Mac that rolled back reports the rollback from the restored release. A rollback of this release itself is therefore not followed; rollbacks of later releases are. -- To roll back a pair by hand, stop one Mac's cluster service with `darkbloom cluster stop --service`, run `darkbloom update --rollback` there, and start it again with `darkbloom cluster`; the other Mac follows. diff --git a/changelog.d/cluster-pair-serving-epoch.md b/changelog.d/cluster-pair-serving-epoch.md deleted file mode 100644 index c267c91d93..0000000000 --- a/changelog.d/cluster-pair-serving-epoch.md +++ /dev/null @@ -1,16 +0,0 @@ -### Two-Mac pairs recover after losing a rank during a stop - -- A two-Mac pair no longer stays unable to serve when it loses a rank while - its slot is stopping. Until the provider restarted, its leader refused every - later start, and `darkbloom cluster stop` left that Mac's part still - releasing. -- Fixed a deadlock in the pair's request engine. Stopping the pair slot - cancelled a request's stream while the engine was telling that request the - pair had lost a rank. The stream's cancellation waited for the engine, and the - engine waited for the cancellation to finish, so the slot never stopped. - Cancellation and stream termination now never wait for the engine. -- The leader also releases a committed start as soon as its session ends, - instead of after the old slot has fully stopped, so a slow stop can no longer - make it refuse later starts with "a committed start is already served". The - release receipt still waits, bounded, for the slot to retire, and a pair still - never serves two slots at once. diff --git a/changelog.d/cluster-public-mimo-gemma.md b/changelog.d/cluster-public-mimo-gemma.md deleted file mode 100644 index af6f88c4e5..0000000000 --- a/changelog.d/cluster-public-mimo-gemma.md +++ /dev/null @@ -1,4 +0,0 @@ -### MiMo-V2.6-Flash and Gemma 4 26B QAT serve public cluster traffic - -- Two more models are approved for public traffic on two-Mac clusters, in pipeline and tensor parallel, as GLM-5.3-Flash and Qwen3.8 27B are: MiMo-V2.6-Flash (`mimo-v2.6-flash-mopd`) and Gemma 4 26B QAT (`gemma-4-26b-qat-4bit`). A release's cluster runtime facts carry their pair-serving grants and parity qualifications, so a pair of either model earns through Darkbloom on any Apple silicon pair, and `darkbloom cluster` lists them. -- Their tensor parallel serves once its code is in the build (Gemma 4 and MiMo tensor parallel PRs); until then they pair as a pipeline. MiMo-V2.6-Flash's speculative pipeline, its default split, is declared too. diff --git a/changelog.d/cluster-service-follows-repair.md b/changelog.d/cluster-service-follows-repair.md deleted file mode 100644 index d321ed5bd3..0000000000 --- a/changelog.d/cluster-service-follows-repair.md +++ /dev/null @@ -1,6 +0,0 @@ -### A running cluster service answers after the Macs pair again - -- When the two Macs pair again while their cluster services run (`darkbloom cluster` or `darkbloom cluster pair`), each service starts its setup and control-lease listeners again with the new pairing within about 5 seconds. They used to keep the earlier pairing's key until the service restarted, so the other Mac's leases and its "Reading both Macs over the cable" step were refused (`refused (handshakeRejected)`). The service log says `this Mac's pairing changed (): answering the paired Mac with the new one`. -- A Mac left with no pairing stops answering over the cable. A pairing store that cannot be read leaves the listeners as they are. -- A Mac that paired again under a new Secure Enclave key of its own drops its earlier control state, as it already did when the other Mac's key changed. -- A cluster service started by an earlier release keeps the earlier behavior until it restarts (log out and back in, or `darkbloom cluster stop --service` and then `darkbloom cluster`). diff --git a/changelog.d/fastest-plan-evidence.md b/changelog.d/fastest-plan-evidence.md deleted file mode 100644 index 83485417a1..0000000000 --- a/changelog.d/fastest-plan-evidence.md +++ /dev/null @@ -1,7 +0,0 @@ -### Tensor parallel for Gemma 4 and MiMo only on measured speed - -- Gemma 4 and MiMo V2.6 Flash pairs choose tensor parallel only once tensor parallel's own speed is measured on both Macs: each Mac's half timed by a tensor-parallel load (Gemma), or requests this Darkbloom build served in tensor parallel. An estimate from the Macs' device index alone does not choose it, because the index overstates what half a model saves on big Macs: on two M5 Ultra it predicts a short Gemma request 6% faster in tensor parallel, where the plans expect decode 6-8% slower. -- When the estimate says tensor parallel would be faster, the pair keeps the pipeline. The plan's "Tensor parallel or pipeline" line says the predicted gain and that it comes from the device index, and the model list says "tensor parallel: not measured yet". -- Normal setups do not load tensor parallel to measure it, so these pairs keep the pipeline for now. MiMo does not yet time its halves at load, so MiMo pairs reach tensor parallel only from requests the same build served in tensor parallel. -- Tensor parallel must also keep every feature of the mode it would replace (see "Tensor parallel only where it keeps every feature"). -- Qwen and GLM still choose tensor parallel wherever it fits. diff --git a/changelog.d/fresh-mdm-removal-guidance.md b/changelog.d/fresh-mdm-removal-guidance.md deleted file mode 100644 index e6b044c65c..0000000000 --- a/changelog.d/fresh-mdm-removal-guidance.md +++ /dev/null @@ -1,3 +0,0 @@ -### Fresh MDM removal guidance - -- Keep `darkbloom status` and both `darkbloom doctor` authorization summaries from offering MDM removal when the coordinator decision is too old for removal readiness. An unexpired App Attest serving lease stays visible; removal advice asks for fresh readiness and keeps existing profiles installed. The `darkbloom unenroll` checks are unchanged. diff --git a/changelog.d/gemma-byte-fallback-flush.md b/changelog.d/gemma-byte-fallback-flush.md deleted file mode 100644 index 3f22c7588c..0000000000 --- a/changelog.d/gemma-byte-fallback-flush.md +++ /dev/null @@ -1,6 +0,0 @@ -### Gemma 4 replies keep characters outside its vocabulary - -- A Gemma 4 reply that ended in characters its vocabulary writes as byte tokens, such as many newer emoji, rare CJK and most Hangul syllables, lost all of them: `all zipped up 🗜` came back as `all zipped up `, and a reply made only of such characters came back empty. A long reply could also corrupt such a character when streaming restarted its decode inside its bytes. -- The Swift tokenizer library releases byte tokens only when a later token arrives. The provider's tokenizer bridge now releases a trailing run itself. `/detokenize` keeps it too. -- Token IDs, numeric logprobs, sampling and cache keys do not change, with one exception: a stop string that a trailing run completes now matches when the run completes, one token sooner, so `completion_tokens` can fall by one. -- A streamed reply's `logprobs` gains the entries of those tokens, which it used to drop. A byte token's `logprobs` text and `bytes` are U+FFFD or its ASCII character instead of empty, not the real byte. A reply cut inside a character by `max_tokens` now ends in U+FFFD instead of dropping it. diff --git a/changelog.d/gemma-decode-command-buffers.md b/changelog.d/gemma-decode-command-buffers.md deleted file mode 100644 index 49963036d1..0000000000 --- a/changelog.d/gemma-decode-command-buffers.md +++ /dev/null @@ -1,3 +0,0 @@ -### Gemma 4 plain decode commits by operation count - -- Plain decode steps of Gemma 4, the rows served without its assistant, commit a Metal command buffer every 100 operations instead of many times per step. Outputs are bitwise identical. Prefill and assistant rounds keep MLX's defaults. diff --git a/changelog.d/gemma-decode-keeps-spaces.md b/changelog.d/gemma-decode-keeps-spaces.md deleted file mode 100644 index 7b902c5121..0000000000 --- a/changelog.d/gemma-decode-keeps-spaces.md +++ /dev/null @@ -1,5 +0,0 @@ -### Gemma 4 text keeps its spaces before punctuation - -- Gemma 4 replies, reasoning and tool arguments no longer lose the space before `.`, `,`, `?` and `!`, or repeat a quote. `git add .` came back as `git add.`, `bash ./run.sh` as `bash./run.sh`, `x != y` as `x!= y`, and, when streamed, `role = 'start'` as `role = ''start'`. -- Gemma 4's published `tokenizer_config.json` omits `clean_up_tokenization_spaces`, and the Swift tokenizer library reads a missing key as cleanup on, where Python Transformers reads it as off. The provider now resolves a missing key to off in memory for every model. An explicit Boolean is kept. -- Token IDs, sampling, model state and cache keys do not change. Only the text decoded from the same tokens does. Stop strings match the text as spelled: one with a space before punctuation can now match, and one that matched only the cleaned text (`add.` for `add .`) no longer does. diff --git a/changelog.d/gemma-pipeline-speed.md b/changelog.d/gemma-pipeline-speed.md deleted file mode 100644 index 171b5279d8..0000000000 --- a/changelog.d/gemma-pipeline-speed.md +++ /dev/null @@ -1,5 +0,0 @@ -### Faster Gemma 4 pipeline pairs - -- Gemma 4 pipeline stages compute a prompt chunk's expert blocks in one shared dispatch per operation instead of one subgraph per prompt token, with the same bytes for every token (unchanged arithmetic receipt). Batch-decode rows share the same dispatch. On one synthetic expert layer this cut a 2,048-token chunk from about 370 ms to about 31 ms; pair throughput is not yet measured. -- A Gemma 4 pipeline pair whose setup prefills serially, coordinator-registered pairs included, now serves four requests at once. Each lane is admitted against live memory on both Macs. A pair planned with the one-chunk lookahead keeps serving one request at a time. -- The planner's hardware prior counts 8 of Gemma 4's 128 experts per token instead of every expert byte. diff --git a/changelog.d/gemma-tensor-parallel.md b/changelog.d/gemma-tensor-parallel.md deleted file mode 100644 index e2ecce6bfb..0000000000 --- a/changelog.d/gemma-tensor-parallel.md +++ /dev/null @@ -1,7 +0,0 @@ -### Gemma 4 tensor parallel on two-Mac clusters - -- Gemma 4 26B (QAT 4-bit and 8-bit) can run tensor parallel on a pair: each Mac holds half of every layer's heads and expert channels, both share every token over the encrypted link, and the pair returns the same tokens a single Mac would on the synthetic checks. Text only. -- The planner chooses tensor parallel for Gemma 4 only where it predicts it faster than the pipeline, from tensor parallel's own speed measured on both Macs (see "Tensor parallel for Gemma 4 and MiMo only on measured speed"). Prompt-heavy requests keep the pipeline. Qwen and GLM still choose tensor parallel wherever it fits. -- In tensor parallel, Gemma 4 returns logprobs (`logprobs` / `top_logprobs`), and each Mac reserves memory for its own half of the model: about 8.0 GB of weights at QAT 4-bit (14.9 GB at 8-bit) plus its own KV, with a conservative 5.5 GiB activation reserve until a pair measures one. -- Gemma 4 tensor parallel keeps prompt prefixes as the pipeline does, in memory and in the encrypted SSD tier: a repeated or shared prompt prefix is restored only when both Macs hold it, with exactly the tokens of a request that prefilled the whole prompt, and it survives a restart of both Macs. Each request reserves room for its own prompt's prefix (about 0.44 GB a Mac for a 32K-token prompt); kept prefixes use free memory only and are dropped first when memory runs short. -- Gemma 4 tensor-parallel pairs serve one request at a time unless `DARKBLOOM_CLUSTER_BATCH_LANES` names more. Speed on a real pair is not measured yet. diff --git a/changelog.d/glm-tensor-parallel-stop-race.md b/changelog.d/glm-tensor-parallel-stop-race.md deleted file mode 100644 index e107a4a153..0000000000 --- a/changelog.d/glm-tensor-parallel-stop-race.md +++ /dev/null @@ -1,4 +0,0 @@ -### A latent stop race in GLM tensor parallel's one-token decode - -- No released pair is affected, and serving is unchanged: every v0.10.6 GLM-5.3-Flash tensor-parallel pair loads the model's NextN (MTP) layer and decodes every request in MTP rounds, which already end both Macs together when a request stops just before the model's end token. -- The one-token decode, which only a build without that layer runs, now does the same: both Macs end at the end token and return the text up to the stop (for example, a stop string that matched just before the answer ended). Before, the stopped Mac built one more step alone and waited in a collective the other Mac, already finished at that token, never joined, so the request would stall and fail on both Macs. diff --git a/changelog.d/gptoss-decode-command-buffers.md b/changelog.d/gptoss-decode-command-buffers.md deleted file mode 100644 index 986e75d062..0000000000 --- a/changelog.d/gptoss-decode-command-buffers.md +++ /dev/null @@ -1,3 +0,0 @@ -### GPT-OSS plain decode commits by operation count - -- Plain decode steps of GPT-OSS commit a Metal command buffer every 100 operations instead of after almost every MoE layer. Outputs are bitwise identical. Prefill keeps MLX's defaults. diff --git a/changelog.d/mimo-pipeline-decode-buffers.md b/changelog.d/mimo-pipeline-decode-buffers.md deleted file mode 100644 index 7f38c5d844..0000000000 --- a/changelog.d/mimo-pipeline-decode-buffers.md +++ /dev/null @@ -1,15 +0,0 @@ -### MiMo pipeline decode command buffers and expert routing - -- MiMo V2.6 Flash pairs encode decode steps, lane steps and speculative rounds - in Metal command buffers of up to 100 operations with no input-size bound, as - GLM and Qwen tensor parallel already do. Prefill keeps the rank's limits. - Tokens, logits and caches are byte-identical on synthetic stages. The speed - effect on the registered model has not been measured yet. -- A MiMo request's memory charge now prices every full-attention layer's decode - score rows at once, which the larger command buffers can keep alive together. - The LOAD quote is unchanged. Only requests whose prompt frames are shorter - than a stage's full-attention layers times the decode rows (32 tokens at most) - are charged slightly more. -- The planner's hardware prior now counts MiMo's routed experts at the 8 of 256 - a token uses: 10.77 GB read per decode step instead of 166.6 GB. The prior - prices only tensor parallel, so MiMo's pipeline plans are unchanged. diff --git a/changelog.d/mimo-rotating-cache-metadata.md b/changelog.d/mimo-rotating-cache-metadata.md deleted file mode 100644 index 8e62c2009e..0000000000 --- a/changelog.d/mimo-rotating-cache-metadata.md +++ /dev/null @@ -1,11 +0,0 @@ -### MiMo image-candidate pairs keep cluster prompt prefixes - -- A MiMo V2.6 Flash pair serving the private, local-only image candidate no - longer fails its requests while the cluster prefix cache is on (the - default). That candidate is the only MiMo load with contiguous caches. MiMo - still required the five metadata values that older MLX SDKs wrote for a - sliding-window cache, while the pinned SDK writes seven (adding the capacity - origin and a wrapped flag), so requests, text or image, failed at their - first prompt-prefix capture. Prefixes are now captured and restored. The - four text serving modes use paged histories with prefix reuse off and were - not affected. diff --git a/changelog.d/mimo-tensor-parallel.md b/changelog.d/mimo-tensor-parallel.md deleted file mode 100644 index 6b524874ca..0000000000 --- a/changelog.d/mimo-tensor-parallel.md +++ /dev/null @@ -1,7 +0,0 @@ -### MiMo V2.6 Flash tensor parallel on two-Mac clusters - -- MiMo V2.6 Flash text can run tensor parallel on a pair: each Mac holds half of every layer's heads and expert channels and half of the output head, both share every token over the encrypted link, and on the synthetic checks the two Macs agree bit for bit with a one-process simulation of both halves. The image candidate stays a pipeline. -- Each Mac's half of a layer's attention output and feed-forward is kept at full 32-bit precision until both halves are added, then rounded once, so a pair never rounds more than one Mac does. On the synthetic checks, the two halves of an expert's output add up bit for bit to the full output that one Mac rounds once. -- The planner chooses tensor parallel for MiMo only where it predicts it faster than the pipeline with speculative decoding, which MiMo's qualification records credit 1.37x, from tensor parallel's own speed measured on both Macs (see "Tensor parallel for Gemma 4 and MiMo only on measured speed"). Two 128 GB Macs, which cannot hold MiMo alone, can serve it this way. Qwen and GLM still choose tensor parallel wherever it fits. -- In tensor parallel, MiMo returns logprobs (`logprobs` / `top_logprobs`), serves one request at a time with speculative decoding (see "MiMo V2.6 Flash tensor parallel with speculative decoding"), and each Mac reserves memory for its own half: 84.0 GB of weights plus its own KV, work and buffers, with a conservative 5.5 GiB activation reserve until a pair measures one (about 100 GiB per Mac at the longest request, the draft heads included). -- No MiMo tensor-parallel qualification record exists yet, and speed on a real pair is not measured. diff --git a/changelog.d/mimo-tp-speculative.md b/changelog.d/mimo-tp-speculative.md deleted file mode 100644 index 6641eb2cd0..0000000000 --- a/changelog.d/mimo-tp-speculative.md +++ /dev/null @@ -1,8 +0,0 @@ -### MiMo V2.6 Flash tensor parallel with speculative decoding - -- A MiMo V2.6 Flash tensor-parallel pair decodes with MiMo's own trained draft heads: each round checks up to two drafted tokens in one pass through the pair, so every token a round keeps shares that pass's link and weight costs. -- It is on by default: the installed provider starts both Macs' tensor-parallel workers with two drafts a round. -- Output is identical to tensor parallel without drafting, token for token and bit for bit on the synthetic checks: greedy (with or without logprobs) and sampled. Each Mac's halves stay at full 32-bit precision inside a round too, exactly as in a one-token step. Every kind of stop works inside a round. Requests with penalties or a logit bias, and sampled requests that ask for logprobs, decode one token at a time, as in the speculative pipeline. -- Each Mac holds the draft heads whole (about 2 GB more) and reserves their per-request state, and the plan counts both before it chooses tensor parallel. Two 128 GB Macs still fit, at about 100 GiB a Mac. -- Because MiMo's tensor parallel now keeps the speculative pipeline's rounds, feature parity no longer holds it back where that pipeline is the mode it would replace; its measured speed decides, and the plan credits the rounds no speed-up until they are measured. Where the plain pipeline is the mode it would replace, that pipeline's batch lanes still keep it. -- Not yet measured on a real pair: the speed-up, the heads' acceptance rate and qualification records. diff --git a/changelog.d/models-page-network-registration.md b/changelog.d/models-page-network-registration.md deleted file mode 100644 index e38dff93e8..0000000000 --- a/changelog.d/models-page-network-registration.md +++ /dev/null @@ -1,5 +0,0 @@ -### The Models page shows what the network registered - -- Each model on the Models page now says whether this Mac's live registration carries it: "Registered with the network" (the network sends it requests), "Registered for Autopilot" (Autopilot can load it), or, for a selected or pool model, a warning "Not registered with the network yet". Before, the page showed only what was selected, downloaded or loaded, so a selected model the network did not know looked like it was serving. -- The provider writes the registered set to its state file (`registered_models`). -- A Mac with Autopilot that is busy at every check, or always under a lease, now reports a newly verified build after at most 10 minutes. The re-registration closes admission, lets accepted requests finish, then reconnects. Before, such a Mac could wait without end, and Autopilot could not use the build. diff --git a/changelog.d/pipeline-decode-buffers.md b/changelog.d/pipeline-decode-buffers.md deleted file mode 100644 index 05582151fa..0000000000 --- a/changelog.d/pipeline-decode-buffers.md +++ /dev/null @@ -1,15 +0,0 @@ -### Pipeline decode command buffers for the remaining cluster models - -- Cluster pairs of the Qwen and Bonsai rows, Nemotron 3.5 Lightning, Gemma 4, - GPT-OSS 20B and GLM-5.3-Flash encode decode steps (pipeline and phase split), - lane steps and speculative rounds in Metal command buffers of up to 100 - operations with no input-size bound, as GLM and Qwen tensor parallel already - do. Prefill keeps the rank's limits. Tokens, logits and caches are - byte-identical on synthetic stages. The speed effect on registered models has - not been measured yet, and each family keeps the change only if a pair A/B - shows a gain. -- A request's memory charge on those pairs, other than GLM's, now prices every - attending layer's decode rows at once, which the larger command buffers can - keep alive together. The LOAD quotes are unchanged. Only requests whose prompt - frames are shorter than their decode rows (at most 80) are charged more, and - only on a rank that decodes. diff --git a/changelog.d/provider-enabled-filter-wins.md b/changelog.d/provider-enabled-filter-wins.md deleted file mode 100644 index fcf1abe7b2..0000000000 --- a/changelog.d/provider-enabled-filter-wins.md +++ /dev/null @@ -1,7 +0,0 @@ -### The enabled-model filter wins over coordinator model changes - -- A model you deselect with `darkbloom switch` or delete with `darkbloom models remove` no longer comes back on its own. Before, when the coordinator moved a public model to a newer build, every Mac serving that model downloaded the newer build, served it in place of the build its operator chose and loaded it, even when `enabled_models` left it out. For example, with `gemma-4-26b` selected and `gemma-4-26b-qat-4bit` deselected, `gemma-4-26b-qat-4bit` returned within minutes and `darkbloom status` showed `Serving outside the enabled model filter: gemma-4-26b-qat-4bit`. -- With `enabled_models` set, the provider now refuses a coordinator `load_model` or `prefetch_model` for a model outside it (`model_not_selected`), and keeps serving the build you selected when its public model moves to a build you did not list. The log then says `desired_models: → is outside the enabled model filter; not converging`. -- **Your provider no longer moves to a new build of a model by itself.** To take one, run `darkbloom switch` and pick the model's public name; the picker shows its newest build under that name. Until you do, the newer build gets that model's requests first. -- `darkbloom switch` applies its selection as the filter at once, without a restart. -- Nothing changes with an empty `enabled_models` (serve every downloaded model), or for Autopilot's consented downloads and placements. diff --git a/changelog.d/provider-process-exit-wait.md b/changelog.d/provider-process-exit-wait.md deleted file mode 100644 index 5771412db8..0000000000 --- a/changelog.d/provider-process-exit-wait.md +++ /dev/null @@ -1,3 +0,0 @@ -### Child process exit waits - -- Report a finished child process without the former polling and run-loop delay. Bounded children (the paged-kernel preflight, update staging, runtime smoke and signature checks, `darkbloom doctor` and `verify` probes) are reported up to about 120 ms sooner each, and waiting for `launchctl`, `codesign`, `profiles`, `open` and `log` no longer runs the calling thread's run loop. Timeouts and the SIGTERM-then-SIGKILL escalation are unchanged. diff --git a/changelog.d/provider-status-app-attest-lease.md b/changelog.d/provider-status-app-attest-lease.md deleted file mode 100644 index 36f92ec11d..0000000000 --- a/changelog.d/provider-status-app-attest-lease.md +++ /dev/null @@ -1,3 +0,0 @@ -### Provider status App Attest lease - -- Keep `darkbloom status` and `darkbloom doctor` reporting App Attest authorization until the coordinator lease expires. They required a renewal within the last 10 seconds, so one delayed renewal showed `Trust: self_signed / online` although serving continued. `darkbloom unenroll` still requires a renewal within 10 seconds before offering MDM removal. diff --git a/changelog.d/provider-update-rollback.md b/changelog.d/provider-update-rollback.md deleted file mode 100644 index ffa75cc843..0000000000 --- a/changelog.d/provider-update-rollback.md +++ /dev/null @@ -1,7 +0,0 @@ -### Roll a Mac back to its previous release - -- `darkbloom update --rollback` restores the release a Mac ran before its last update. When the updater installs a release, it keeps the signed release it replaces; the rollback puts that release back, also after the new one has served for 10 minutes and was promoted. -- It shows the installed and restored versions and asks `Roll back to vX? [y/N]` before changing anything (`--yes` skips the question). The running provider finishes its accepted requests (`--timeout`, `--force` as for `darkbloom update`), the kept release replaces the installed one in the watchdog's journaled swap under the update lease, and the provider restarts on it. It contacts no coordinator. -- The rolled-back release is quarantined on that Mac: the provider's 30-minute update check, the startup check and the watchdog do not reinstall it, and the next newer release installs normally, so automatic updates can stay on. `darkbloom update --override-quarantine` installs it again on request. -- It refuses and changes nothing on a Mac that serves in a `darkbloom cluster` pair, while a provider runs in the foreground (`darkbloom start --foreground`), while another update or recovery runs, when no earlier release is kept or the kept one is already installed, when the installed bundle is not the release the updater recorded, and when the kept release fails its hash or signature check. -- Only one earlier release is kept. A Mac rolls back to the release it ran before its last update, not further. diff --git a/changelog.d/qwen27-tp-decode-control.md b/changelog.d/qwen27-tp-decode-control.md deleted file mode 100644 index 28d8a95e36..0000000000 --- a/changelog.d/qwen27-tp-decode-control.md +++ /dev/null @@ -1,22 +0,0 @@ -### Qwen tensor-parallel decode control in the selection sum - -- A Qwen tensor-parallel pair's plain decode step now carries the next step's - plan and report in its own sealed selection sum, so the step pays one sealed - sum and one host read fewer than before. Tokens, logits and native state are - unchanged; assisted (MTP) rows, prompt steps and idle steps keep their own - exchange. -- Owner answers, cancellations and joins now apply one step later while plain - rows decode. A row decodes its next token once the owner answered the token - before it, so an answer that arrives while a step computes no longer leaves - the row idle for a step. Rank 0 still publishes a token only after the - owner's answer to the one before it. A token selected before a stop answer is - never published, so streamed text, usage and logprobs are unchanged. -- A clean stop the owner asks for (a stop string, for example) can cost one - more forward, which is discarded. On a one-lane pair every such stop after a - request's first token does (assisted rows excepted), and that request's - finish arrives one decode step later than before. -- Both ranks of a pair must run this build: the load agreement binds the new - control wire (`qwen-tp-independent-history-batch-v2-folded-control`). -- `darkbloom-cluster-tp-check qwen-decode` times the batch driver's decode on - two ranks over the loopback ring, with the control exchanged or folded, and - checks that both retire the same tokens. diff --git a/changelog.d/qwen27-tp-decode-loop.md b/changelog.d/qwen27-tp-decode-loop.md deleted file mode 100644 index 8afa8a9b3b..0000000000 --- a/changelog.d/qwen27-tp-decode-loop.md +++ /dev/null @@ -1,25 +0,0 @@ -### Qwen tensor-parallel decode routes, row exactness and finiteness check - -- A Qwen3.8-27B tensor-parallel row now decodes the same bytes alone as beside - other rows and in verify windows on the registered weights. A one-row decode - step's fused SwiGLU computed its sigmoid with Metal's fast `exp`, while - cohort and window steps use MLX's precise `exp`. The two round a gate of - exactly bf16 -6.84375 differently, which could change later tokens. Dense - Qwen tensor-parallel output changes only where a one-row decode step meets - that gate value, and there it now equals the cohort path. Regenerate - tensor-parallel serving references recorded with earlier builds once. - Single-Mac output is unchanged. -- A non-finite logit on either rank of a Qwen tensor-parallel pair now fails - both ranks in the same selection step, before any token is published; - previously the other rank waited in the selection collective. The check moved - into the selection's sealed sum, so a decode step no longer pays a separate - finiteness read. Selected tokens are unchanged. -- Each rank logs its decode routes once per load, when it first serves - (`darkbloom-qwen-tp-decode-census-v1`): which projections take the - batch-invariant kernel and at which layout per row count, the attention and - residual-norm routes, and the arithmetic switches in force. -- `darkbloom-cluster-tp-check qwen-rows` checks, on one Mac over the loopback - ring, that a Qwen3.8-27B row decodes the same bytes alone, beside other rows - and in verify windows at the registered per-rank widths, with random weights - that follow the registered artifact's value statistics or with the registered - checkpoint itself; `qwen-rows layers` names the first layer that differs. diff --git a/changelog.d/qwen27-tp-default-lanes.md b/changelog.d/qwen27-tp-default-lanes.md deleted file mode 100644 index beaec56878..0000000000 --- a/changelog.d/qwen27-tp-default-lanes.md +++ /dev/null @@ -1,20 +0,0 @@ -### Qwen tensor-parallel pairs serve up to 8 requests at once, sized to memory - -- `darkbloom cluster` now sets how many requests a Qwen tensor-parallel pair - serves at once: 8, 6, 4 or 2, the most that both Macs' memory holds now with - the full load reservation for that many. The pair serves them from its first - load. Before, it served one at a time: a local pair widened only after a - burst, through a reload the burst waited for, and a pair serving Darkbloom - traffic never widened. -- On two idle Macs, Qwen3.8-27B serves 8 at once from 64 GB a Mac without the - speculative assistant (4 at 48 GB, 2 at 32 or 36 GB), and 8 from 96 GB a Mac - with it (local clusters only); smaller Macs serve fewer. Two M5 Ultras serve 8 either - way. When not even 2 fit, the pair serves one request at a time, as before. -- Memory safety is unchanged: both Macs reserve that many requests' full memory - when the model loads and admit each request alone. A local pair set up - narrower still widens when requests queue; a pair set up for 8 is never - reloaded for it. -- Existing setups keep serving one request at a time until they are planned - again, as after an update. A pair serving Darkbloom traffic keeps its width - beside its approval; no approval, registration or committed-start digest - changes. diff --git a/changelog.d/qwen27-tp-prefill.md b/changelog.d/qwen27-tp-prefill.md deleted file mode 100644 index 2f113dafb5..0000000000 --- a/changelog.d/qwen27-tp-prefill.md +++ /dev/null @@ -1,17 +0,0 @@ -### Qwen tensor-parallel prompt wavefront - -- A Qwen tensor-parallel pair now prefills a text prompt faster, in steps of up - to eight consecutive 512-token frames built as one graph, layer by layer: - while one frame's sealed sum crosses the link, the next frame computes. Every frame - keeps its own shapes and kernels, so logits, KV, recurrent state, prefix - captures and tokens are unchanged. Steps run two frames while another lane - decodes and end at the prompt-cache capture point. Media prompts, assisted - (MTP) prompts, packed KV and routed-expert models keep one frame a step. -- The merged step's frames in flight are charged in LOAD, the placement quote - and each request's charge: a Qwen3.8-27B tensor-parallel rank needs about - 367 MB more at any width. -- `darkbloom-cluster-tp-check qwen-prefill --wavefronts 1,8` and - `darkbloom-cluster-tp-check qwen-wavefront` measure the merged steps on one - rank and on two ranks over the loopback ring. - `DARKBLOOM_QWEN_TP_PROMPT_WAVEFRONT=0` restores one frame a step for - diagnosis; both ranks must agree. diff --git a/changelog.d/qwen27-tp-prefix-depth.md b/changelog.d/qwen27-tp-prefix-depth.md deleted file mode 100644 index 81b1598c15..0000000000 --- a/changelog.d/qwen27-tp-prefix-depth.md +++ /dev/null @@ -1,6 +0,0 @@ -### Qwen3.8 27B tensor parallel reuses whole prompt prefixes - -- A Qwen tensor-parallel pair now reuses a repeated prompt's prefix to its last whole 512-token chunk instead of at most 4,096 tokens, including prompts longer than 32,768 tokens: a repeated 33K-token prompt restores 32,768 tokens on both Macs, as one Mac does. It also keeps the boundaries the next turn of a conversation and prompts that share a long system prompt need, so in each of these cases it reuses at least what one Mac reuses, to the nearest 512 tokens. -- A prefix restored from memory returns exactly the tokens of a request that prefilled the whole prompt (checked bit for bit on synthetic pairs at 8K, 16K and 32K boundaries); one restored from the SSD tier's default `balanced` records is close but not identical, as before. Both Macs must hold a boundary; otherwise both start from zero. -- Each request reserves room for its own prompt's prefix (about 1.8 GB a Mac for a 32K-token prompt on the 27B), and a pair loads with one such prefix per lane: about 1.1 GB a Mac more than before at one lane. Every pair size that ran the 27B in tensor parallel still does. Kept prefixes use free memory only (half of what is left after loading) and are dropped first when memory runs short. Prefixes kept on SSD by an earlier build are not reused. -- Requests served by the assistant (MTP) lanes still reuse at most 4,096 prompt tokens, less than one Mac reuses for a long prompt; deepening them is a separate change. Speed on a real pair is not measured yet. diff --git a/changelog.d/reasoning-stop-outside-reasoning.md b/changelog.d/reasoning-stop-outside-reasoning.md deleted file mode 100644 index ce6d54f182..0000000000 --- a/changelog.d/reasoning-stop-outside-reasoning.md +++ /dev/null @@ -1,18 +0,0 @@ -### Stop sequences no longer match Gemma 4 or `` reasoning - -- A client `stop` sequence on Gemma 4 models such as `gemma-4-26b-qat-4bit`, - and on models that reason in `` blocks (Qwen 3.5, 3.6 and 3.8, - among others), now matches only the text returned as `content`. With - reasoning on, it used to match the reasoning too, so a sequence that - appeared while the model reasoned (for example `"."` or `"\n\n"`) ended the - request before any answer: `finish_reason` `stop`, reasoning only, empty - content. -- With tools declared, tool-call frames are not cut either, except a frame - whose arguments quote its own closing tag, or a bare `` frame - written without its wrapper. When a request has no tool handler (no declared - tools, or a media request on a family without native media tools), a literal - tool tag in an answer is text the client receives, and stops still apply to it. - Whitespace before the answer's first character (the blank line after - ``) cannot complete a stop sequence on its own. -- A stop sequence that names a marker no longer fires on it: ``, or - `` with tools declared. diff --git a/changelog.d/sandbox-setup-plan.md b/changelog.d/sandbox-setup-plan.md deleted file mode 100644 index 20821ad746..0000000000 --- a/changelog.d/sandbox-setup-plan.md +++ /dev/null @@ -1,9 +0,0 @@ -### Sandbox setup shows the add-on's own sizing plan - -- `darkbloom sandbox setup` now asks the Darkbloom Sandbox installer for the add-on's own plan before it asks you to confirm. After its own chip, macOS, session, network, power and sleep checks, setup runs the downloaded installer with `--plan` (add-on 1.1.1 and later). The installer verifies the release and sizes this Mac without installing anything. Setup then prints the plan's cores, memory and disk lines and how many Linux and macOS jobs this Mac can run at a time. Example: `Disk: 157 GiB free; 100 GiB stays free for you; Linux images 4 GiB + 30 GiB per Linux job; macOS images 46 GiB + 40 GiB per macOS job`. -- Disk follows the add-on's rules. A tenth of the disk (50 to 100 GiB) stays free. The first job of a platform also needs that platform's VM images (Linux 4 GiB, macOS 46 GiB, nothing once installed). Each Linux job takes 30 GiB and each macOS job 40 GiB. -- When no job fits, setup prints the plan's message and how much disk to free for one Linux job and for one macOS job. It then stops without installing. -- The installer is now downloaded before the question, so the plan is shown before you confirm. Nothing is installed before you answer `y`. -- With an older installer that cannot report a plan, setup prints `[INFO] Sizing` and estimates with the same rules. -- Setup's output is line-buffered: run over ssh or into a pipe, it shows the approval link as soon as the installer has it, not once setup ends. -- With add-on 1.1.2 and later, a Mac waiting for approval keeps waiting in the background, also across restarts, and enrolls by itself, and setup now says so. On the waitlist it says you can close the window, and after Ctrl-C it says that the Mac keeps waiting; both point at `darkbloom sandbox status`. With an earlier add-on, setup words both as before. diff --git a/docs/developer/build.md b/docs/developer/build.md index 52f3ae2687..e5a9c06da1 100644 --- a/docs/developer/build.md +++ b/docs/developer/build.md @@ -1,6 +1,6 @@ # Build The Provider And Landing -> Last updated: 2026-11-03 +> Last updated: 2026-11-04 Build the provider, its source-matched native resources, and the independent landing site from this repository. Backend, sidecar, console and admin builds @@ -167,7 +167,11 @@ and linking on that SDK. Ordinary development retains the package's Swift 6.3 minimum; release evidence must use the selected release toolchain. Pinned Python 3.12.10 and checksum-verified CMake 3.31.12 provide missing build -tools. `scripts/prepare-metal-toolchain.py` requires a working compiler probe, +tools. `scripts/install-release-cmake.sh` uses the CMake 3.31.12 that Darkbloom macOS +images unpack from the same checksum-verified archive into +`$RUNNER_TOOL_CACHE/cmake/3.31.12/universal`, when its `universal.complete` +marker exists and the binary reports that exact version; elsewhere it +downloads and verifies the 80 MB archive. `scripts/prepare-metal-toolchain.py` requires a working compiler probe, not merely a completed component download. It clears stale discovery state, waits boundedly for registration, and uses Apple's component export/import fallback. The specific transient asset-catalog download error gets at most @@ -249,11 +253,13 @@ see [resource and release tooling checks](test.md#focused-tooling-checks). Darkbloom Sandbox when its plane grants one, otherwise the job's Blacksmith fallback. It runs on GitHub-hosted `ubuntu-24.04` with no token permissions or checkout. Each routed job runs on `fromJSON(needs.route.outputs.routes)['']`, -where the lane is the job's name. +where the lane is the job's name; each shard of a sharded job reads its own +lane, `format('-{0}', matrix.shard)`. | Workflow | Routed jobs | Fallback | |---|---|---| | `ci.yml` | `release-integrity`, `docs` | `blacksmith-4vcpu-ubuntu-2404` | +| `ci.yml` | `test-provider` (lanes `test-provider-1` to `test-provider-3`, one per shard), `test-provider-summary`, `test-provider-sdk`, `test-cluster-checks`, `test-cluster` (lanes `test-cluster-1` to `test-cluster-3`), `test-cluster-gpu` (lanes `test-cluster-gpu-1` and `test-cluster-gpu-2`), `test-cluster-focused` | `blacksmith-12vcpu-macos-27` | | `docs-impact.yml` | `commit-signatures`, `docs-impact` | `blacksmith-4vcpu-ubuntu-2404` | | `landing.yml`, `desktop.yml`, `nightly-linear-package.yml` | `check`, `frontend`, `test` | `blacksmith-4vcpu-ubuntu-2404` | | `provider-release-cache.yml` | `warm`, pull requests only | `blacksmith-12vcpu-macos-27` | @@ -266,21 +272,35 @@ fallback and the plane is not contacted. When it is on, the route job sends one most once after a transient failure. It uses a grant only when the grant repeats the exact Darkbloom labels for the job's profile. Errors, timeouts and malformed replies keep the fallback; the plane never fails the route job. +Every job of a lane shares one `runs-on` value, so the plane grants a lane +whole, for its requested job count, or not at all. Each shard is therefore a +lane of its own and runs on a Darkbloom Mac whenever one is free, +independently of the other shards. The plane grants only the lanes its +approval names; any other lane keeps its fallback. + +```mermaid +flowchart LR + C["changes
(classifier)"] --> Q{"routing on, same-repo
run, lane count > 0?"} + Q -- no --> F["Blacksmith fallback
(macOS: blacksmith-12vcpu-macos-27)"] + Q -- yes --> R["one POST /v1/ci/routes
for all requested lanes"] + R --> P{"plane grants the lane
with the exact labels?"} + P -->|"no, error or timeout"| F + P -- yes --> D["Darkbloom Sandbox
(darkbloom-macos-arm64)"] + classDef dark fill:#d4f7dc,stroke:#1a7f37,color:#0b2e13 + classDef fallback fill:#fff4ce,stroke:#9a6700,color:#3b2300 + class D dark + class F fallback +``` + +A push run asks exactly as a same-repository pull request does; the request +names only the repository, run and lanes, and the plane's approval decides +which pushed branches it admits. Other branches get `branch_not_admitted` and +keep their fallback, so a push saves caches on Darkbloom only from an admitted +branch and only in routed lanes ([CI Caching](#ci-caching)). Release, signing, publication, model registration, review automation and `master` or dispatched cache warming keep literal Blacksmith labels. The component classifier and the `Provider Tests` gate run on `ubuntu-24.04`. -The macOS jobs of `ci.yml` (`test-provider`, `test-provider-summary`, -`test-provider-sdk`, `test-cluster-checks`, `test-cluster`, `test-cluster-gpu` -and `test-cluster-focused`) are not routed. They always run on -`blacksmith-12vcpu-macos-27`. In 43 provider shard jobs on Darkbloom macOS -sandboxes (2026-10-31 to 11-02), the median job took 17.3 min against 9.8 min -on Blacksmith (362 jobs). The depth-1 checkout took 146 s at the median and up -to 22 min, against 13 s on Blacksmith. The sandboxes found almost no build -cache. Saving the cache took about 150 s. Five jobs stopped in checkout until -the 60-minute job timeout. `scripts/test-darkbloom-route.py` checks that these -jobs keep the literal label. - Jobs on Darkbloom Sandboxes use GitHub's Actions cache, not Blacksmith's colocated cache, so their first runs start without cached build products. Darkbloom Linux sandboxes are ARM64; the Blacksmith Linux fallback is x64. The @@ -288,6 +308,92 @@ decision is fixed for the run: **Re-run failed jobs** reuses it, so turn routing off and use **Re-run all jobs** to move a run back to Blacksmith. See the [routing checks](test.md#focused-tooling-checks). +## CI Caching + +`.github/workflows/ci.yml` and `.github/actions/provider-ci-build/action.yml` +restore caches in every run. Only pushes to `master` and `dev` save them, when +the exact key missed: the workflow's `SAVE_CACHES` is +`github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev')`, +and `ci.yml` passes it to the composite action as `save-caches`. An entry saved +by a pull request is scoped to its merge ref, so only that pull request could +restore it, and it evicted its base branch's entries from the repository's +10 GB quota. A pull request restores its base branch's newest compatible entry, +then `master`'s. Blacksmith runners keep their own colocated cache, so an entry +saved there never reaches a Darkbloom Sandbox, and the reverse: a push warms +the caches of the runners it ran on. + +| Cache | Path | Key; restore prefixes | Saved by, on pushes to `master` and `dev` | +|---|---|---|---| +| Git objects | `.git` | `git-v1--`; `git-v1---`, then `git-v1--` | every job that checks out | +| Full-history Git objects | `.git` | the same under `git-full-v1-`, so shallow jobs never restore it | `docs` | +| SwiftPM repositories | `~/Library/Caches/org.swift.swiftpm/repositories` | `spm-repos-v1----`; `spm-repos-v1----` | each build lane | +| Swift test build | each lane's `.build` directory | `swift-key`; `swift-prefix` from `scripts/provider-ci-cache.py` | each build lane | +| Metal library | `$RUNNER_TEMP/metallib-cache` | `metallib-key`, exact only | each build lane | +| MiMo audio codec | `$RUNNER_TEMP/mimo-audio-source` | `mimo-audio-source-v2-`, exact only; fetched only when the audio gate runs ([test guide](test.md)) | the last provider shard | +| Cluster metadata build | `$RUNNER_TEMP/cluster-native-metadata` | toolchain, submodule pins, manifests and paths, then the commit | `test-cluster-checks` | + +Every checkout uses the same five steps. The job computes the UTC day +(`date -u +%F`) and restores `.git`. A step that cannot fail then deletes the +restored `.git` unless `git rev-parse --verify HEAD` and +`git fsck --connectivity-only` accept it. One ordinary `actions/checkout` +follows: it fetches only the objects `.git` lacks and reuses the submodule +repositories under `.git/modules`, and its failure fails the job. No step uses +`continue-on-error`. A `.git` that passes fsck but still breaks the checkout +fails the job; change the key version, such as `git-v1`, to start over. The +`.git` key names the day, not the commit, so a branch saves `.git` once a day: +later runs that day restore the exact key and save nothing. Checkouts set +`persist-credentials: false`, so the saved `.git/config` holds no job token. + +Checkouts download only what their job reads. Every checkout but Docs Lint's +skips the `.gz` tarballs under `docs/reports/evidence` and `landing/public/media` +(`CHECKOUT_SPARSE`, 408 MB of evidence tarballs and landing videos): a sparse +checkout fetches commits and trees without file contents (`blob:none`), then +only the files it checks out. The reports and the rest of the evidence stay: a +provider test hashes `docs/reports/2026-10-31-public-cluster-models.md`, and +`scripts/provider-ci-cache.py` hashes every tracked `Package.swift`, including +one under `docs/reports/evidence`. Docs Lint +checks link targets on disk, so it checks out every file, but fetches history +with `filter: blob:none`; the provenance check then fetches the old document +versions it reads (about 29 MiB for its 12 checks). Docs Impact +(`.github/workflows/docs-impact.yml`) needs commits, trees and the docs, so it +uses both settings. + +```mermaid +flowchart LR + W[UTC day] --> R["Restore .git
(today, else newest)"] + R --> V{"git fsck
accepts .git?"} + V -- no --> D[Delete .git] --> K + V -- yes --> K[actions/checkout] + K --> G{"master or dev push,
no exact hit?"} + G -- yes --> S[Save .git] + G -- no --> B + S --> B["Restore SwiftPM, build
and Metal caches; build; test"] + B --> M{"master or dev push,
no exact hit?"} + M -- yes --> T[Save each cache] + classDef save fill:#d4f7dc,stroke:#1a7f37,color:#0b2e13 + classDef fail fill:#ffe1e1,stroke:#cf222e,color:#3d0a0a + class S,T save + class D fail +``` + +- Swift build prefixes contain no pull-request data; the commit is only the + key's suffix. A pull request that changes a CI recipe file, a manifest, a + lockfile or a submodule pin has a new prefix and builds cold. On a pull + request, the provider summary job restores the base branch's build like the + shards and rebuilds what the commit changed; on a push it restores the + shards' own build. +- `actions/cache` stores a path outside the workspace relative to the + workspace, so the SwiftPM key includes ``, a hash of `$HOME` and the + workspace path. The cluster key reads only each submodule's state, pin and + path from `git submodule status`, because its `git describe` text depends on + the refs a restored `.git` holds. +- `actions/cache` compresses with zstd when `zstd` is on `PATH` and with gzip + otherwise, and the method is part of each entry's version: a runner without + zstd never restores an entry saved with it. Each job logs + `actions/cache compressor: zstd` or `gzip` before its first cache step. +- Concurrent jobs of one push save the same key; one wins, and the others log a + `409 Conflict` warning. + ## Dev Build Identity A dev release build (`DARKBLOOM_RELEASE_ENVIRONMENT=dev`) has its own install diff --git a/docs/developer/test.md b/docs/developer/test.md index 5c93ea75fb..c8c4487a4c 100644 --- a/docs/developer/test.md +++ b/docs/developer/test.md @@ -139,11 +139,18 @@ suite moves from the parallel class to the serial class when it fails or flakes in parallel; when in doubt, a suite stays serial. The jobs that use the `provider-ci-build` action and Cluster Metadata Checks -restore their build cache by the exact key first, then by the key prefix. A -push to `dev`, `main` or `master` saves its build. A pull request saves its build only when it restored nothing. -Its later pushes then restore that entry or the base branch's entry and add no -new entry, so they do not evict the base branch's entries. CI has no separate -push-only Swift cache job. +restore their build cache by the exact key first, then by the key prefix. Only +a push to `dev` or `master` saves a build; a pull request restores its base +branch's entry and saves nothing ([CI caching](build.md#ci-caching)). CI has +no separate push-only Swift cache job. + +The last provider shard runs the MiMo audio gate (`testNativeAudioRelease`), +whose fixture needs the 1.87 GB pinned audio codec, only when the gate's +inputs change (`MIMO_AUDIO` in `scripts/ci-component-paths.py`: the MiMo, +audio and media provider code, the MiMo tests, the MLX pins, the audio and +provider fixture scripts and the gate's recipe) and on every `master` push, which runs every +component. A pull request outside those inputs neither downloads the codec +nor runs the gate. The SDK has independent test products under `libs/mlx-swift-lm`. CI validates native memory ownership, cancellation, media decoding, paged KV and resource @@ -1244,11 +1251,11 @@ summary), or 5 when an SDK-lane input changes. A cluster pull request adds 7 Macs (metadata checks, 3 runtime shards, 2 GPU shards and focused checks). CI runs the runtime test target (`DarkbloomClusterRuntimeTests`) on the -provider's Blacksmith macOS runners, in selections that -`scripts/cluster-test-plan.py` defines. Each selection runs in a process of its -own through `scripts/run-nested-suite.sh`, which fails when the selection runs -no test or skips a test. Every process starts with `MLX_QMV_BATCH_INVARIANT=1`, -as every cluster process does. +provider's macOS CI runners (see [CI runner routing](build.md#ci-runner-routing)), +in selections that `scripts/cluster-test-plan.py` defines. Each selection runs +in a process of its own through `scripts/run-nested-suite.sh`, which fails when +the selection runs no test or skips a test. Every process starts with +`MLX_QMV_BATCH_INVARIANT=1`, as every cluster process does. | Selection | Job | Tests | |---|---|---| @@ -1826,9 +1833,10 @@ removed first, its failure fatal only when `CLUSTER_RUNTIME_SEND` is true, and HTTPS plane with a throwaway certificate; the host needs Bash, Python, jq, curl and openssl. It covers the default-off switch, fork pull requests, exact label grants, HTTP errors, the single retry, timeouts, untrusted or plain-HTTP planes -and hostile reply text. It also pins each routed job's fallback, timeout and -read-only permissions, and keeps release workflows and the macOS jobs of -`ci.yml` on literal Blacksmith runners. No check contacts the real plane. +and hostile reply text. It also pins each routed job's lanes (one per provider +or cluster shard, matching the job's matrix), fallback, timeout and read-only +permissions, and keeps release workflows on literal Blacksmith runners. No check +contacts the real plane. Docs-impact tests retain provider, protocol, privacy, native capacity, cache, release/model publication and fixture mappings. Historical links need exact diff --git a/docs/operations/provider-release.md b/docs/operations/provider-release.md index 8346a2fdaa..218d7cc028 100644 --- a/docs/operations/provider-release.md +++ b/docs/operations/provider-release.md @@ -27,135 +27,81 @@ runs the resolve, build, qualification, signing, R2 staging and publication chain for one environment. To find the newest dev release, read `https://api.dev.darkbloom.dev/v1/releases/latest`. -`ProviderCore.version` is prepared as `0.10.6`, a patch release over `v0.10.5` -and the first production release with two-Mac clusters. `darkbloom cluster` -sets up two Macs joined by one Thunderbolt 5 cable (macOS 26.2 or later, RDMA -over Thunderbolt) to serve one model together, GLM-5.3-Flash and Qwen3.8-27B in -tensor parallel, and `darkbloom cluster local` serves a pair without a -coordinator. Every release lane computes the build's -[cluster runtime facts](#cluster-runtime-facts), from which a coordinator with -darkbloom-platform#643 derives the build's cluster approvals, pair-serving -grants and public qualifications. A registered pair's cluster service is no -longer restarted by its own part's heartbeats (#1690), pair members register the -models their pair-serving grant admits (#1686), a single Qwen3.8-27B request in -tensor parallel decodes about 6% faster on two M5 Ultra (#1680) and model -downloads show one progress line (#1683). Single-Mac serving needs no -coordinator change and no provider-version floor, though three answers to -coordinator requests and the local API change. See the -[`v0.10.6` changelog entry](../../CHANGELOG.md) for the full scope. - -Before tagging `v0.10.6`: +`ProviderCore.version` is prepared as `0.10.7`, a patch release over `v0.10.6`. +The two Macs of a pair set up with `darkbloom cluster` update together by +themselves (#1702), and `darkbloom update --rollback` puts back a Mac's previous +release (#1729), which the other Mac of a pair follows (#1739). Gemma 4 and +MiMo-V2.6-Flash gain tensor parallel on a pair (#1706, #1707, #1716), chosen +only on its own measured speed and only where it keeps every feature of the mode +it would replace (#1715), and `ClusterPublicModels` declares both public in +pipeline and tensor parallel (#1736). The operator's enabled-model filter wins +over coordinator model changes (#1730). Both Macs of a pair must run 0.10.7: a +pair of mixed builds refuses to pair, and a pair on 0.10.6 updates by hand once +([updating Darkbloom on the pair](../provider/two-mac-cluster.md#updating-darkbloom-on-the-pair)). +See the [`v0.10.7` changelog entry](../../CHANGELOG.md) for the full scope. + +Before tagging `v0.10.7`: - Confirm that the tagged commit pins `libs/mlx` and the nested `mlx` to - `72dffa2d` and `libs/mlx-swift` to `c633d221`, as v0.10.5 did, and - `libs/mlx-swift-lm` to `7933a0fa`, its fork's `main`. Only the SDK pin moves - (from `2beb401f`, through #1680 and #1684): SDK #373 changes - `AffineQuantizedVectors.swift` alone. -- The tag build's `metallib_hash` should equal v0.10.5's - `98bab9d77dc5078ad8dd8f1fd17e8f3581415193506e4791a3c4f1ebaab614be`: the MLX - core is unchanged, and the dev-branch release of this preparation's base, - `0.10.5-dev.branch.18` from `a0413a8a`, registered that hash on DevNet. A - different hash needs an explanation, such as a changed Metal toolchain. -- The tag is the first production run of the release steps that came with the - cluster: the build and signing of the [cluster helpers](#cluster-helpers) and - the cluster runtime facts. The dev-branch lane runs the same reusable - workflow; its run - [41167361754](https://github.com/Layr-Labs/d-inference/actions/runs/41167361754) - passed both, and DevNet's coordinator accepted its block. That proves neither - the derived approvals nor pairing; step 5 below checks both in production. -- Before step 3 below, check that the production catalog lists `glm-5.3-flash` - and `EigenLabs/Qwen3.8-27B-4bit-mtp`, because the facts step leaves out a - model the environment's catalog lacks. Check that the coordinator's catalog - has room within its bounds of 64 approvals, 64 pair-serving grants and 256 - parity qualifications, which newer releases fill first, each release whole: - 0.10.6 adds at most 24 approvals and 24 grants (`s1` and `s2` for each of at - most 12 models) and 8 parity qualifications (4 each for GLM-5.3-Flash and - Qwen3.8-27B). See [cluster runtime facts](#cluster-runtime-facts). -- The tagged commit is this preparation's squash commit on `master`, and - `changelog.d/` must hold only its `README.md` there. On the `master` checkout - you tag: - - ```bash - git log -1 --format=%s # must print: Prepare provider 0.10.6 (#) - make changelog-check # must print: changelog: 0 valid fragment(s) - ``` - - A fragment at the tag reached `master` without an entry in this release's - changelog. + `72dffa2d` and `libs/mlx-swift` to `c633d221`, as v0.10.6 did, and + `libs/mlx-swift-lm` to `32f5c744`, its fork's `main`. Only the SDK pin moves + (from `7933a0fa`): SDK #370, #371, #375 to #377 and #379 to #384 change Swift + files only, and the one Metal kernel they add compiles at run time + (`MLXFast.metalKernel`), not into `mlx.metallib`. +- The tag build's `metallib_hash` should equal v0.10.6's + `98bab9d77dc5078ad8dd8f1fd17e8f3581415193506e4791a3c4f1ebaab614be`, because + the MLX core is unchanged. A different hash needs an explanation, such as a + changed Metal toolchain. +- `PROD_CLUSTER_RUNTIME_ENABLED` is `true` since v0.10.6, so this tag registers + a cluster runtime facts block. On the exact tag tree, re-run the release's + facts step read-only against production's catalog, as for 0.10.6: + `scripts/provider-cluster-runtime-facts.sh darkbloom prod `, + with an unsigned app staged the way the build job stages it, must exit 0. + The facts step leaves out a model the catalog lacks, so check the rows of + `gemma-4-26b-qat-4bit` and `mimo-v2.6-flash-mopd` as well as + `glm-5.3-flash` and `EigenLabs/Qwen3.8-27B-4bit-mtp`. +- Check the coordinator's catalog room + ([cluster runtime facts](#cluster-runtime-facts)): v0.10.6's block holds 24 + approvals, and this release adds 2 per model of its block, within the bound + of 64. The next release with a block can leave v0.10.6's approvals out, which + ends public serving for pairs still on 0.10.6; a pair on 0.10.7 or later + updates itself first. +- The tagged commit is on `master` and verified, holds `ProviderCore.version` + `0.10.7`, keeps the plain-build default `prod` + (`scripts/provider-build-default.py --branch master`), and its `changelog.d/` + holds only `README.md` (`make changelog-check` prints + `changelog: 0 valid fragment(s)`; a fragment there reached `master` without + an entry in this release's changelog). Roll out in this order; each step is a separate approval: -1. No DevNet proof: this release goes to production without one. DevNet's - coordinator accepted the block of `0.10.5-dev.branch.18` but derived no - approvals, so production is the first coordinator to derive them, and step 5 - checks them. -2. Production platform: deploy a `darkbloom-platform` coordinator with - [darkbloom-platform#643](https://github.com/Layr-Labs/darkbloom-platform/pull/643). - #643's code reaches the platform's `master` only with its `dev` to `master` - merge; its twin, - [darkbloom-platform#644](https://github.com/Layr-Labs/darkbloom-platform/pull/644), - carries only migration 58 (the `releases.cluster_runtime` column), which no - code on `master` reads. Production runs one combined coordinator, not - DevNet's split Provider Edge and Conductor. Apply migration 58 and set, in - the same deploy: - - `EIGENINFERENCE_CLUSTER_PAIR_APPROVALS_FROM_RELEASES=true` (approvals - derived from releases, the only approval source: - `EIGENINFERENCE_CLUSTER_PAIRS`, the operator's approval table, stays - unset); - - `EIGENINFERENCE_CLUSTER_PAIR_TRUSTED_TLS_PROXIES=127.0.0.1,::1` (the - production coordinator listens on plain HTTP behind Caddy on the same - host, which reaches it over loopback, so without this setting no member - connection attaches to pair control); - - `EIGENINFERENCE_CLUSTER_PUBLIC_ROUTING=true` (public traffic for qualified - clusters). - - App Attest serving must be on for every account: - `EIGENINFERENCE_APP_ATTEST_SERVING=true`, - `EIGENINFERENCE_APP_ATTEST_ENVIRONMENT=production` and - `EIGENINFERENCE_APP_ATTEST_ROLLOUT_PERCENT=100`. A member holds either the - legacy MDM path or an App Attest serving authorization, so a member on - macOS 27 without MDM pairs only through App Attest. -3. Confirm from production's `/health` `build_commit` that it runs the platform - revision of step 2. Check the catalog as above, and re-run the release's - facts step read-only against it: - `scripts/provider-cluster-runtime-facts.sh darkbloom prod `, - with an unsigned app staged from this preparation's source the way the build - job stages it (`scripts/provider-signing-validation.py stage`). It reads the - catalog and the CDN, sends nothing, and must exit 0: a catalog row that the - worker cannot describe stops the release after signing once the variable is - set. Then set the repository variable `PROD_CLUSTER_RUNTIME_ENABLED=true`. - Never before step 2: a coordinator without #643 refuses a registration that - carries `cluster_runtime`, and the release then fails after signing. Set it - before the tag: a release registered without the block never gains one, - because a re-registration must repeat the stored block (409 - `cluster_runtime_conflict`). -4. Merge into `master`, each squash-merged after its approval: first the - two-Mac clustering pull request, then this preparation. The clustering pull - request carries #1690 and #1692 from `dev`, with `master` merged in so plain - builds keep `master`'s `prod` default, and the fixes found while preparing - this release, such as the release facts fix (a catalog model ID that the - worker describes as another registered model is left out). After its squash, - restack this preparation with `scripts/restack-after-squash.py` - ([pull-request stacks](../developer/pull-requests.md)). Let SDK 27 release - preparation pass on `master`. This step does not depend on steps 1 to 3 and - may come first. -5. Tag `v0.10.6` on this preparation's squash commit once the checks above pass - ([step 4](#4-tag-and-push-production-source)). After registration, check the - coordinator log for `release cluster approvals omitted` and - `GET /v1/cluster/approvals` for the derived `release/0.10.6//s<1|2>` - approvals. Then a production pair, the owner's two Macs with App Attest, - must form a session under one of them. Record the run and the session. +1. Production platform: the coordinator deploys first + ([darkbloom-platform#679](https://github.com/Layr-Labs/darkbloom-platform/pull/679), + merged as `f9c1b2d6a3`). + 0.10.7's registration needs nothing new from it: the payload has 0.10.6's + fields, and the block keeps the `darkbloom_cluster_runtime_v2` schema. Its + new parity qualifications use generation modes the coordinator already + knows, MiMo-V2.6-Flash's speculative pipeline (`pipeline_mtp_v1`) included. + Confirm that production's `/health` `build_commit` is `f9c1b2d6a3`. +2. Merge into `master`, each squash-merged after its approval: first the `dev` + to `master` release snapshot (#1754), then this preparation, which is + cherry-picked onto `master` after #1754's squash. Its tree must not bring + back a rendered fragment. Let SDK 27 release preparation pass on `master`. +3. Re-run the facts dry run on the tag tree and check the catalog room, as + above. +4. Tag `v0.10.7` on this preparation's squash commit + ([step 4](#4-tag-and-push-production-source)). After registration, check + that `GET /v1/cluster/approvals` lists the derived + `release/0.10.7//s<1|2>` approvals and that the coordinator log has no + `release cluster approvals omitted`. +5. Each pair on 0.10.6 updates by hand once: `darkbloom update` on both Macs, + then log out and back in on both. Single Macs, and pairs from 0.10.7 on, + update by themselves. 6. The platform snapshots its provider contracts from the tagged commit (`python3 scripts/provider-contracts.py snapshot `), sets - `LatestProviderVersion` to `0.10.6` in the coordinator's `server.go` in the - same change and adds the revision row to its provider-contract reference. Of - the 34 snapshotted inputs, only `contracts/provider/ProviderCore.swift` - changes from v0.10.5. `LatestProviderVersion` is a fallback and does not gate - publication. - -Without steps 2 and 3 the tag still publishes with an unchanged registration, -but 0.10.6 then never derives cluster approvals, and a production pair serves -only on its leading Mac's local API. + `LatestProviderVersion` to `0.10.7` in the coordinator's `server.go` in the + same change and adds the revision row to its provider-contract reference. + `LatestProviderVersion` is a fallback and does not gate publication. 0.10.2's remaining enablement steps do not wait for this tag and still apply; each is a separate approval: @@ -173,31 +119,25 @@ approvals. This preparation tags, deploys and enables nothing; merging it into `master` publishes nothing, because the staging lane runs only while `STAGING_ENABLED` is `true`. -Platform evidence, inspected on 2026-10-31 (recheck before tagging): +Platform evidence, inspected on 2026-11-03 (recheck before tagging): | Claim | Source | |---|---| -| Platform `master` (`2847f27d`) pins the provider contracts at d-inference `8effff7f` (v0.10.4) and keeps `LatestProviderVersion` at `0.10.4`; darkbloom-platform#639 (open) pins v0.10.5's `d3bbcd06`. The 34 inputs equal this preparation's except `ProviderCore.swift` | [`contracts/provider/manifest.json` at `2847f27d`](https://github.com/Layr-Labs/darkbloom-platform/blob/2847f27dda8e4caf9e2441d554067f42a88c9e1f/contracts/provider/manifest.json) and [at #639's `422ca1d4`](https://github.com/Layr-Labs/darkbloom-platform/blob/422ca1d428849c775daa950691a185154f117c18/contracts/provider/manifest.json) (`source_revision`) | +| The coordinator knows the generation mode `pipeline_mtp_v1` and puts it in the `pipeline_speculative` family, at #679's merge commit (`f9c1b2d6a3`), unchanged from platform `master` before it (`482ca9db`) | [`cluster_generation_mode.go` at `f9c1b2d6a3`](https://github.com/Layr-Labs/darkbloom-platform/blob/f9c1b2d6a3c590bcbf03f11b8ccbdbe383a54449/coordinator/protocol/cluster_generation_mode.go) (`ClusterPlanModeFamily`) | +| At #679's merge commit (`f9c1b2d6a3`), the platform still pins the provider contracts at d-inference `8effff7f` (v0.10.4) and keeps `LatestProviderVersion` at `0.10.4`; step 6 moves both | [`contracts/provider/manifest.json` at `f9c1b2d6a3`](https://github.com/Layr-Labs/darkbloom-platform/blob/f9c1b2d6a3c590bcbf03f11b8ccbdbe383a54449/contracts/provider/manifest.json) (`source_revision`); [`server.go` at `f9c1b2d6a3`](https://github.com/Layr-Labs/darkbloom-platform/blob/f9c1b2d6a3c590bcbf03f11b8ccbdbe383a54449/coordinator/api/server.go) (`LatestProviderVersion`) | | `LatestProviderVersion` must equal the snapshotted `ProviderCore.version` | [`provider_version_sync_test.go` at `5ba280d8`](https://github.com/Layr-Labs/darkbloom-platform/blob/5ba280d89aa5e9bd4fbf05e0dfa848059cd3b585/coordinator/tests/api/provider_version_sync_test.go) (`TestLatestProviderVersionMatchesProviderCore`) | -| #643 is merged into platform `dev` (`df61dd6f`), not `master`; #644 (open) carries only its migration to `master`. Only `EIGENINFERENCE_CLUSTER_PAIR_APPROVALS_FROM_RELEASES=true` derives entries from releases, and public routing needs an approval source | [`cluster_pair_config.go` at `df61dd6f`](https://github.com/Layr-Labs/darkbloom-platform/blob/df61dd6f93714b4458d0eef3125c377087c08b52/coordinator/api/cluster_pair_config.go) (`ClusterPairConfig`) | -| Migration 58 adds `releases.cluster_runtime`, and a re-registration must repeat the stored block (409 `cluster_runtime_conflict`) | [`00058_release_cluster_runtime.sql` at `df61dd6f`](https://github.com/Layr-Labs/darkbloom-platform/blob/df61dd6f93714b4458d0eef3125c377087c08b52/coordinator/store/postgres/schema/migrations/00058_release_cluster_runtime.sql); [`releases.go` at `df61dd6f`](https://github.com/Layr-Labs/darkbloom-platform/blob/df61dd6f93714b4458d0eef3125c377087c08b52/coordinator/store/postgres/releases.go) (`SetRelease`) | -| A coordinator without #643 refuses a registration body that carries `cluster_runtime` | [`release_handlers.go` at `2847f27d`](https://github.com/Layr-Labs/darkbloom-platform/blob/2847f27dda8e4caf9e2441d554067f42a88c9e1f/coordinator/api/releases/release_handlers.go) (`DisallowUnknownFields`) | -| Of the platform's deploy configuration, only DevNet's overlay sets `EIGENINFERENCE_CLUSTER_PAIRS`, `EIGENINFERENCE_CLUSTER_PAIR_APPROVALS_FROM_RELEASES` and `EIGENINFERENCE_CLUSTER_PUBLIC_ROUTING`, and it also sets `EIGENINFERENCE_CLUSTER_PAIR_TRUSTED_TLS_PROXIES=127.0.0.1` | [`env-overrides` (DevNet) at `df61dd6f`](https://github.com/Layr-Labs/darkbloom-platform/blob/df61dd6f93714b4458d0eef3125c377087c08b52/deploy/gcp/dev/env-overrides) | -| A member connection attaches to pair control only after its own TLS handshake or through a listed TLS proxy. The production coordinator listens on plain HTTP behind Caddy, and in the split deployment only the trusted-proxy path attaches a member | [`configuration.md` at `df61dd6f`](https://github.com/Layr-Labs/darkbloom-platform/blob/df61dd6f93714b4458d0eef3125c377087c08b52/docs/reference/configuration.md) ("Trusted TLS proxy trade-off") | -| A pair member holds the legacy MDM path or an App Attest serving authorization; App Attest serving reads `EIGENINFERENCE_APP_ATTEST_SERVING`, `EIGENINFERENCE_APP_ATTEST_ENVIRONMENT` and `EIGENINFERENCE_APP_ATTEST_ROLLOUT_PERCENT` | [`cluster-control-protocol.md` at `df61dd6f`](https://github.com/Layr-Labs/darkbloom-platform/blob/df61dd6f93714b4458d0eef3125c377087c08b52/docs/reference/cluster-control-protocol.md) ("Member trust"); [`config.go` at `2847f27d`](https://github.com/Layr-Labs/darkbloom-platform/blob/2847f27dda8e4caf9e2441d554067f42a88c9e1f/coordinator/appattest/service/config.go) (`ConfigFromEnvironment`) | -| DevNet runs `df61dd6f` and accepted the block of `0.10.5-dev.branch.18` (registered 04:33Z), yet its `GET /v1/cluster/approvals` listed only 26 operator approvals, with no `release/` entry, at 04:44Z, 04:57Z, 05:04Z and 05:09Z | DevNet `/health` and `/v1/cluster/approvals`; run [41167361754](https://github.com/Layr-Labs/d-inference/actions/runs/41167361754) (`CLUSTER_RUNTIME_SEND: true`) | - -The production coordinator was not inspected for this preparation; step 3 + +The production coordinator was not inspected for this preparation; step 1 checks its `/health`. -`v0.10.5` was [published on 2026-10-30](https://github.com/Layr-Labs/d-inference/releases/tag/v0.10.5) +`v0.10.6` was [published on 2026-10-31](https://github.com/Layr-Labs/d-inference/releases/tag/v0.10.6) +from `84ddfdba6bb704bf1c68f97c7060289079380ceb`, `v0.10.5` was +[published on 2026-10-30](https://github.com/Layr-Labs/d-inference/releases/tag/v0.10.5) from `d3bbcd064ea290fbeb500e5c51c7870e3695741c`, `v0.10.4` was [published on 2026-10-28](https://github.com/Layr-Labs/d-inference/releases/tag/v0.10.4) from `8effff7f7067fec70b2e3b58de0a4ba47ea3986c`, `v0.10.3` was [published on 2026-10-26](https://github.com/Layr-Labs/d-inference/releases/tag/v0.10.3) -from `3ddd11ce8d7204cc5aadefd2050376c583da4ff8`, `v0.10.2` was -[published on 2026-10-26](https://github.com/Layr-Labs/d-inference/releases/tag/v0.10.2) -from `f9d1af3d0d3e1838974a5cfdff0a08142977b45e`. Publication does not establish +from `3ddd11ce8d7204cc5aadefd2050376c583da4ff8`. Publication does not establish that every optional feature or environment has been activated. ## Prerequisites diff --git a/docs/provider/cli-reference.md b/docs/provider/cli-reference.md index 5308684a61..541c9c49a8 100644 --- a/docs/provider/cli-reference.md +++ b/docs/provider/cli-reference.md @@ -1323,6 +1323,21 @@ darkbloom sandbox uninstall [--yes] images and one Linux job: 1 Linux job, no macOS job. When no job fits, the verdict gives the plan's message and the GiB to free for one Linux job and for one macOS job, and setup stops before installing. + + When the add-on's plan gives macOS no job and its `macos_limit` names disk, + setup prints one more line under the verdict + (`SandboxSizingPlan.freeSpaceNote`): the plan's free space is what `df -h ~` + shows as Avail; Finder also counts purgeable space, which macOS frees only + when it needs to (restarting, or removing Time Machine local snapshots, which + `tmutil listlocalsnapshots /` lists, frees it now); then + `A macOS job needs about N GB more`. N is `diskShortfall` for a macOS job + beside the plan's slots: the floor, the disk the plan's slots take (each + platform's images with its first slot, one job's disk per slot) and a macOS + job with its images, less the free space, in GiB rounded up, which the CLI + writes as GB like its memory figures. With 210 GiB free and 3 Linux jobs + planned, a lone macOS job would fit above the floor, but beside the Linux + jobs it needs about 70 GB more. When no job fits, N equals the verdict's GiB + for one macOS job. The fallback estimate gets no such line. 4. **Confirm.** Explains that inference pauses while a job runs, that each job pays its price minus a 10% fee into the Darkbloom balance, the VM images and the one browser approval, then asks `[y/N]`. `--yes` skips it; without a @@ -1355,7 +1370,24 @@ Rerunning `setup` decides from the add-on's answer | No add-on, or `not_installed` | A first setup: check, plan, explain, confirm, install | | `waiting_for_approval`, `waitlisted`, `enrolling` | Runs the installer again to continue, without the check or the question | | `stopped`, `error`, no answer within 10 s, a failed status, an add-on older than `status --json` | Runs the installer again to repair or update the add-on | -| `ready`, `running`, `paused`, `downloading_images`, `updating`, an unknown state | Reports the state and changes nothing; with `--linux-slots` or `--macos-slots` it runs the installer to apply them | +| `ready`, `running`, `paused`, `downloading_images`, `updating`, an unknown state | Reports the state, then checks the plan again (below); with `--linux-slots` or `--macos-slots` it runs the installer to apply them, without the plan | + +On a Mac that is set up, after the report, setup downloads the installer and +runs its plan as for a first setup, which changes nothing, and compares the +plan's `linux_slots` and `macos_slots` with the installed `slots.linux.total` +and `slots.macos.total` (`SandboxSlotChange`): + +| Case | `setup` | +|---|---| +| Same counts, no plan (an installer without `--plan`, a failed plan), a plan without a job, no `slots` in the status, or a failed download | Today's report exactly: the state, then `To change how many jobs run at a time: darkbloom sandbox setup --linux-slots --macos-slots `, without the free-space line; a failed download adds why it could not check | +| `jobs_running` above `0` | No plan: the add-on's installer refuses a slot change while jobs run (exit `4`; the CLI never passes `--force`), and their disk would shrink the plan. Setup says to run it again once they finish | +| Different counts, at a terminal | The plan's CPU, memory and disk lines and the free-space line when it applies, then `This Mac now fits Linux + macOS (installed: Linux + macOS). If a job is running, the installer refuses and changes nothing. Apply? [Y/n]`. Yes or an empty answer runs the installer with the plan's counts as `--linux-slots` and `--macos-slots`; no prints the command that applies it | +| Different counts, `--yes` or no terminal | The same lines, then `This Mac now fits …` without the question. Applies the plan only when it adds slots and removes none; otherwise prints `Not applied` and the command that applies it, and exits `0` | + +A platform missing from `slots` counts as `0`: the add-on configures and +reports only platforms with a slot. When the installer finds that a job +started since the status, it refuses with exit `4` and changes nothing; setup +prints the exit `4` advice below and exits `4`. ### Installer progress events @@ -1416,7 +1448,7 @@ every tenth. | `0` | The summary: state, jobs at a time (automatic and the limit, or your choice), next commands | | `2` | This Mac cannot host Darkbloom Sandbox as it is (the failed stage says why) | | `3` | Not enrolled: the code was denied or expired, or the waitlist request ended; run `setup` to start again | -| `4` | Jobs are running; run `setup` again once they finish, `pause` meanwhile | +| `4` | A job is running, so the installer changed nothing (it refuses rather than waits); run `setup` again when it finishes, `pause` meanwhile. Setup never passes the installer's `--force`, which would stop running jobs, and stopped jobs aren't paid | | `130` | Stopped; an enrollment waiting for approval goes on, and a rerun follows it. While the Mac waits in the background (`background: true`, not yet enrolled): it keeps waiting, also across restarts, and enrolls by itself; `sandbox status` shows where it is | | other | Setup did not finish; it is safe to rerun | diff --git a/docs/provider/sandboxes.md b/docs/provider/sandboxes.md index 2f9e96daa9..58d031c578 100644 --- a/docs/provider/sandboxes.md +++ b/docs/provider/sandboxes.md @@ -1,6 +1,6 @@ # Host Darkbloom Sandbox CI jobs -> Last updated: 2026-11-02 +> Last updated: 2026-11-03 How to let this Mac run Darkbloom Sandbox jobs, approved GitHub Actions jobs in Linux and macOS virtual machines, beside the inference provider: set it up, @@ -82,11 +82,29 @@ Uninstalling ends running jobs, which are not paid: pause first and uninstall once they finish. Running `setup` again at any time is safe: it reports the state, continues an unfinished setup or repairs the add-on. +On a Mac that is set up, `setup` also asks the installer for the add-on's plan +again. When the plan fits other job counts, for example after you freed disk, +setup shows them beside the installed ones and asks `[Y/n]`. Yes reinstalls +with the plan's counts and restarts the add-on. The installer does not wait +for jobs: if one is running, it refuses and changes nothing, and setup says to +run it again when the job finishes. With `--yes` or without a terminal, setup +applies the plan only when it adds jobs and removes none; otherwise it prints +the command that applies it. When the counts match, setup reports as before. +While jobs run, setup skips the check. The +[CLI reference](./cli-reference.md#setup) has the details. + ## Troubleshooting - **`Free up N GiB of disk for one Linux job`.** No job fits in the free disk. The disk rules are under [Prerequisites](#prerequisites). Free the space it names, then run setup again. +- **`no macOS jobs (limited by free disk space)`, while Finder shows more + free.** The plan counts what `df -h ~` shows as Avail. Finder also counts + purgeable space, which macOS frees only when it needs to. Restart, or remove + Time Machine local snapshots (`tmutil listlocalsnapshots /` lists them), to + free it now. Setup's line `A macOS job needs about N GB more` says how much + more free space a macOS job needs beside the planned Linux jobs. Then run + setup again: it offers the new plan. - **`On the waitlist`.** Darkbloom has not approved your account yet. With add-on 1.1.2 and later you can close the window: the Mac keeps waiting, also across restarts, and enrolls by itself once your account is approved; @@ -99,8 +117,12 @@ state, continues an unfinished setup or repairs the add-on. not paid. Follow the `↳ fix:` line. - **`This Mac was not enrolled`** (exit status 3). The code was denied or expired, or the waitlist request ended. Run setup again for a new code. -- **`Jobs are running on this Mac`** (exit status 4). An add-on update or a - slot change waits for running jobs; run setup again once they finish. +- **`A job is running on this Mac`** (exit status 4). The installer refuses + to replace the add-on or change its slots while a job runs, and changes + nothing; it does not wait. Run setup again when the job finishes; + `darkbloom sandbox pause` keeps new ones from starting. Setup never passes + the installer's `--force`, which would stop running jobs, and stopped jobs + aren't paid. - **`This version of the add-on …`.** The add-on predates the command; it updates itself, or `darkbloom sandbox setup` updates it now. - **`Sandboxes: installed; the add-on did not answer within 2s`.** `darkbloom diff --git a/provider-swift/Sources/ProviderCore/ProviderCore.swift b/provider-swift/Sources/ProviderCore/ProviderCore.swift index 37319a171c..a80001f748 100644 --- a/provider-swift/Sources/ProviderCore/ProviderCore.swift +++ b/provider-swift/Sources/ProviderCore/ProviderCore.swift @@ -5,5 +5,5 @@ public enum ProviderCore { /// Release identity consumed by CLI output, registration and packaging. /// scripts/check-release-version.sh verifies this provider-owned identity /// against the requested release tag and reported binary version. - public static let version = "0.10.6" + public static let version = "0.10.7" } diff --git a/provider-swift/Sources/darkbloom/Sandbox/SandboxEligibility.swift b/provider-swift/Sources/darkbloom/Sandbox/SandboxEligibility.swift index d662a80fa9..05d76d019a 100644 --- a/provider-swift/Sources/darkbloom/Sandbox/SandboxEligibility.swift +++ b/provider-swift/Sources/darkbloom/Sandbox/SandboxEligibility.swift @@ -220,10 +220,10 @@ extension SandboxSizingPlan { var jobMemory: Int64 { max(0, memoryBytes - memoryKeptBytes - providerMemoryBytes) } var canRunJobs: Bool { linux.slots + macOS.slots > 0 } - /// Free disk one job of `platform` needs beyond what is free now, its - /// images included; 0 when it fits. + /// Free disk one more job of `platform` needs, beside the plan's slots, + /// beyond what is free now; 0 when it fits. func diskShortfall(_ platform: Platform) -> Int64 { - max(0, floorBytes + platform.firstSlotBytes - freeBytes) + max(0, floorBytes + linux.plannedBytes + macOS.plannedBytes + platform.nextSlotBytes - freeBytes) } /// The CPU, memory and disk lines, in the `doctor` style. When no job @@ -265,6 +265,18 @@ extension SandboxSizingPlan { return lines } + /// Why Finder shows more free space than the add-on's plan, when it gives + /// macOS no job for want of free disk space (its own `limit`), and the + /// free space one macOS job needs beside the plan's Linux slots. + var freeSpaceNote: String? { + guard macOS.slots == 0, macOS.limit?.contains("disk") == true else { return nil } + let short = diskShortfall(macOS) + return "Free space here is what `df -h ~` shows as Avail; Finder also counts purgeable space, which macOS " + + "frees only when it needs to (restarting, or removing Time Machine local snapshots: " + + "`tmutil listlocalsnapshots /`, frees it now)." + + (short > 0 ? " A macOS job needs about \(gibUp(short)) GB more." : "") + } + /// The plan's message, how much disk to free for one job of each /// platform, and whether the owner's counts are why. private var shortfall: [String] { @@ -293,6 +305,8 @@ extension SandboxSizingPlan.Platform { /// The first slot brings the platform's images. var firstSlotBytes: Int64 { imagesBytes + slotBytes } var nextSlotBytes: Int64 { slots == 0 ? firstSlotBytes : slotBytes } + /// Disk its planned slots take: the images with the first, one job's disk each. + var plannedBytes: Int64 { slots == 0 ? 0 : imagesBytes + Int64(slots) * slotBytes } } private func gb(_ bytes: Int64) -> Int64 { bytes / SandboxEligibility.gib } diff --git a/provider-swift/Sources/darkbloom/Sandbox/SandboxSetupCommand.swift b/provider-swift/Sources/darkbloom/Sandbox/SandboxSetupCommand.swift index 0762808bef..135a89ce32 100644 --- a/provider-swift/Sources/darkbloom/Sandbox/SandboxSetupCommand.swift +++ b/provider-swift/Sources/darkbloom/Sandbox/SandboxSetupCommand.swift @@ -15,7 +15,9 @@ extension Sandbox { it in your browser. Running it again reports the current state, continues an unfinished setup, repairs or updates \ - the add-on, or applies new slot counts. + the add-on, or applies new slot counts. On a Mac that is set up, it asks the installer's plan \ + again and offers the add-on's slot counts when they differ from the installed ones; with --yes \ + or without a terminal it applies them only when they add slots and remove none. """) @Flag(name: .shortAndLong, help: "Don't ask for confirmation.") @@ -77,7 +79,8 @@ extension Sandbox { /// What `setup` does, given the add-on's current answer. enum SandboxSetupPlan: Equatable, Sendable { - /// Set up already; report it and change nothing. + /// Set up already; report it, then offer the add-on's plan when its slot + /// counts differ. case alreadySetUp(SandboxAddonStatus) /// Run the installer over the existing install, for this reason. case rerun(String) @@ -137,23 +140,94 @@ struct SandboxSetupFlow { let changingSlots = options.linuxSlots != nil || options.macOSSlots != nil switch SandboxSetupPlan.decide(existing, changingSlots: changingSlots) { case .alreadySetUp(let status): - print("Darkbloom Sandbox is already set up on this Mac.") - print("") - SandboxStatusView.lines(status, color: color).forEach { print($0) } - print("") - print("To change how many jobs run at a time: \(cli) sandbox setup --linux-slots --macos-slots ") + try await reportAndRecheckSizing(status) case .rerun(let reason): print(reason) - try await withInstaller { try await install($0, script: $1) } + try await withInstaller { try await install($0, script: $1, options: options) } case .fresh: let eligibility = try await checkMac() try await withInstaller { installer, script in guard try await sizeAndConfirm(eligibility, installer: installer, script: script) else { return } - try await install(installer, script: script) + try await install(installer, script: script, options: options) } } } + // MARK: - Already set up + + private static let changeCountsHint = "To change how many jobs run at a time: \(Sandbox.cli) sandbox setup " + + "--linux-slots --macos-slots " + + /// Reports the install, then asks the installer's `--plan` how many jobs + /// this Mac fits now and offers what differs. Changes nothing unless the + /// owner agrees, or, without a prompt, the plan only adds slots. Skipped + /// while jobs run: the installer changes slots only while none does, and + /// their disk would shrink the plan. + private func reportAndRecheckSizing(_ status: SandboxAddonStatus) async throws { + print("Darkbloom Sandbox is already set up on this Mac.") + print("") + SandboxStatusView.lines(status, color: color).forEach { print($0) } + print("") + guard status.jobsRunning == 0 else { + print(Self.changeCountsHint) + print("Jobs are running, so setup did not check whether this Mac now fits other slot counts. Run " + + "`\(cli) sandbox setup` again once they finish; `\(cli) sandbox pause` keeps new ones from starting.") + return + } + try await withInstaller(ifUnavailable: { failure in + print(Self.changeCountsHint) + print("Could not check whether this Mac now fits other slot counts: \(failure)") + }) { installer, script in + let plan = try await withTransientNote("Checking how many jobs this Mac fits now…") { + try await requestAddonPlan(installer, script: script) + } + // The same counts (or no plan to compare) keep today's report exactly. + guard let plan, let change = SandboxSlotChange(installed: status, plan: plan) else { + print(Self.changeCountsHint) + return + } + guard offer(change, plan: plan) else { return } + print("") + try await install(installer, script: script, options: change.applying(to: options)) + } + } + + /// Shows the add-on's plan against the installed counts; true to apply it. + /// With a prompt the default is yes. Without one (`--yes`, or no + /// terminal) it applies only a change that adds slots and removes none. + private func offer(_ change: SandboxSlotChange, plan: SandboxSizingPlan) -> Bool { + print("The add-on's plan for this Mac now:") + printChecks(plan.checks) + if let note = plan.freeSpaceNote { print(" " + note) } + print("") + guard !confirmed, interactiveInput else { + print(change.headline) + guard change.onlyAdds else { + print("Not applied: it removes slots, and without a prompt setup applies only a plan that adds " + + "slots. To apply it: \(change.command)") + return false + } + print("Applying it: it only adds slots.") + return true + } + // The installer stops the agent only between jobs: it refuses (exit 4), it does not wait. + guard SandboxTerminal.confirm(change.headline + " If a job is running, the installer refuses and changes " + + "nothing. Apply?", defaultYes: true) else { + print("Nothing changed. To apply it later: \(change.command)") + return false + } + return true + } + + /// Runs `body` with `note` on the running line of a terminal, erased + /// afterwards; elsewhere prints nothing. + private func withTransientNote(_ note: String, _ body: () async throws -> T) async rethrows -> T { + guard terminal else { return try await body() } + SandboxTerminal.write(note) + defer { SandboxTerminal.write("\r\u{1B}[2K") } + return try await body() + } + // MARK: - Check and confirm /// Prints the checks setup makes itself; throws, before anything is @@ -176,8 +250,9 @@ struct SandboxSetupFlow { /// trade-off, then asks. False when the owner declines; throws when no job /// fits. private func sizeAndConfirm(_ eligibility: SandboxEligibility, installer: URL, script: Data) async throws -> Bool { + let reportedPlan = try await requestAddonPlan(installer, script: script) let plan: SandboxSizingPlan - if let reportedPlan = try await requestAddonPlan(installer, script: script) { + if let reportedPlan { plan = reportedPlan } else { printChecks([SandboxEligibility.Check( @@ -190,6 +265,8 @@ struct SandboxSetupFlow { let verdict = plan.verdict print(DoctorTerminalStyle.verdict(verdict[0], level: plan.canRunJobs ? .pass : .fail, color: color)) verdict.dropFirst().forEach { print($0) } + // The add-on's plan only: the fallback estimate's report stays as it was. + if let note = reportedPlan?.freeSpaceNote { print(" " + note) } guard plan.canRunJobs else { throw ExitCode.failure } print("") Self.tradeOff.forEach { print($0) } @@ -251,8 +328,10 @@ struct SandboxSetupFlow { // MARK: - Install /// Downloads the installer into a new owner-only directory for `body`, - /// then removes it. - private func withInstaller(_ body: (_ installer: URL, _ script: Data) async throws -> Void) async throws { + /// then removes it. A failed download goes to `ifUnavailable` when given, + /// else fails setup. + private func withInstaller(ifUnavailable: ((SandboxInstaller.Failure) -> Void)? = nil, + _ body: (_ installer: URL, _ script: Data) async throws -> Void) async throws { guard let url = SandboxInstaller.scriptURL(server: options.server) else { throw ValidationError("--server must be an https URL, such as \(Sandbox.defaultServer)") } @@ -260,6 +339,7 @@ struct SandboxSetupFlow { do { script = try await SandboxInstaller.download(url) } catch let failure as SandboxInstaller.Failure { + if let ifUnavailable { return ifUnavailable(failure) } printError("\(failure) Check this Mac's connection, then run `\(cli) sandbox setup` again.") throw ExitCode.failure } @@ -268,7 +348,7 @@ struct SandboxSetupFlow { try await body(installer, script) } - private func install(_ installer: URL, script: Data) async throws { + private func install(_ installer: URL, script: Data, options: SandboxSetupOptions) async throws { let jsonProgress = SandboxInstaller.supportsJSONProgress(script) let arguments = [installer.path] + SandboxInstaller.arguments(options, jsonProgress: jsonProgress) let directory = installer.deletingLastPathComponent() @@ -310,8 +390,10 @@ struct SandboxSetupFlow { case 2: return "This Mac cannot host Darkbloom Sandbox as it is; see why above." case 3: return "This Mac was not enrolled: the code was denied or expired, or the waitlist request ended. " + "Run \(rerun) to start again." - case 4: return "Jobs are running on this Mac. Run \(rerun) again once they finish; " - + "`\(Sandbox.cli) sandbox pause` keeps new ones from starting." + // The installer refuses rather than waits; its --force would stop the jobs unpaid. + case 4: return "A job is running on this Mac, so the installer changed nothing. Run \(rerun) again when it " + + "finishes; `\(Sandbox.cli) sandbox pause` keeps new jobs from starting. Setup never passes the " + + "installer's --force: it would stop running jobs, and stopped jobs aren't paid." default: return "Setup did not finish. When the problem above is fixed, run \(rerun) again; it is safe to rerun." } } diff --git a/provider-swift/Sources/darkbloom/Sandbox/SandboxSetupProgress.swift b/provider-swift/Sources/darkbloom/Sandbox/SandboxSetupProgress.swift index c846849965..03468a4f2c 100644 --- a/provider-swift/Sources/darkbloom/Sandbox/SandboxSetupProgress.swift +++ b/provider-swift/Sources/darkbloom/Sandbox/SandboxSetupProgress.swift @@ -454,11 +454,12 @@ enum SandboxTerminal { fflush(stdout) } - /// Asks a yes/no question; anything but y or yes is no. - static func confirm(_ question: String, readInput: () -> String? = { readLine() }, + /// Asks a yes/no question; anything but y or yes is no. With + /// `defaultYes`, an empty answer is yes too. + static func confirm(_ question: String, defaultYes: Bool = false, readInput: () -> String? = { readLine() }, emit: (String) -> Void = { write($0) }) -> Bool { - emit("\(question) [y/N]: ") + emit("\(question) \(defaultYes ? "[Y/n]" : "[y/N]"): ") let answer = readInput()?.trimmingCharacters(in: .whitespacesAndNewlines).lowercased() ?? "" - return ["y", "yes"].contains(answer) + return ["y", "yes"].contains(answer) || (defaultYes && answer.isEmpty) } } diff --git a/provider-swift/Sources/darkbloom/Sandbox/SandboxSlotChange.swift b/provider-swift/Sources/darkbloom/Sandbox/SandboxSlotChange.swift new file mode 100644 index 0000000000..320a9ed4fa --- /dev/null +++ b/provider-swift/Sources/darkbloom/Sandbox/SandboxSlotChange.swift @@ -0,0 +1,42 @@ +import Foundation + +/// The add-on's plan for an installed Mac against the slots it runs now +/// (`status --json`): what rerunning `setup` offers to apply. The counts are +/// the add-on's; the CLI only compares them. +struct SandboxSlotChange: Equatable, Sendable { + var installedLinux: Int + var installedMacOS: Int + var plannedLinux: Int + var plannedMacOS: Int +} + +extension SandboxSlotChange { + /// Nil when the status names no slots to compare, the plan fits no job, + /// or it matches the installed counts. + init?(installed status: SandboxAddonStatus, plan: SandboxSizingPlan) { + guard status.linux != nil || status.macOS != nil, plan.canRunJobs else { return nil } + self.init(installedLinux: status.linux?.total ?? 0, installedMacOS: status.macOS?.total ?? 0, + plannedLinux: plan.linux.slots, plannedMacOS: plan.macOS.slots) + guard installedLinux != plannedLinux || installedMacOS != plannedMacOS else { return nil } + } + + /// Adds slots and removes none: what setup applies without a prompt. + var onlyAdds: Bool { plannedLinux >= installedLinux && plannedMacOS >= installedMacOS } + + /// The owner's options with the plan's counts, as explicit slot options. + func applying(to options: SandboxSetupOptions) -> SandboxSetupOptions { + var options = options + (options.linuxSlots, options.macOSSlots) = (plannedLinux, plannedMacOS) + return options + } + + /// The command that applies it. + var command: String { + "\(Sandbox.cli) sandbox setup --linux-slots \(plannedLinux) --macos-slots \(plannedMacOS)" + } + + var headline: String { + "This Mac now fits \(plannedLinux) Linux + \(plannedMacOS) macOS " + + "(installed: \(installedLinux) Linux + \(installedMacOS) macOS)." + } +} diff --git a/provider-swift/Tests/DarkbloomCLITests/SandboxSetupTests.swift b/provider-swift/Tests/DarkbloomCLITests/SandboxSetupTests.swift index 5d5a9aa8f8..8a86f0521c 100644 --- a/provider-swift/Tests/DarkbloomCLITests/SandboxSetupTests.swift +++ b/provider-swift/Tests/DarkbloomCLITests/SandboxSetupTests.swift @@ -233,6 +233,44 @@ struct SandboxSetupTests { #expect(full.checks.map(\.level) == [.pass, .pass, .fail]) } + /// The free-space note, with what one macOS job needs beside the plan's Linux slots. + private static func freeSpaceNote(macOSNeeds more: Int?) -> String { + "Free space here is what `df -h ~` shows as Avail; Finder also counts purgeable space, which macOS frees " + + "only when it needs to (restarting, or removing Time Machine local snapshots: " + + "`tmutil listlocalsnapshots /`, frees it now)." + + (more.map { " A macOS job needs about \($0) GB more." } ?? "") + } + + @Test("the free-space note appears only when the add-on gives macOS no job for want of disk") + func freeSpaceNoteScope() throws { + func plan(linux: Int = 1, macOS: Int = 0, limit: String = "free disk space", + freeGiB: Int64 = 157) throws -> SandboxSizingPlan { + let line = FakeSandboxInstaller.plan(linux: linux, macOS: macOS, freeGiB: freeGiB) + .replacingOccurrences(of: #""macos_limit":"free disk space""#, with: #""macos_limit":"\#(limit)""#) + return try #require(SandboxSizingPlan(line: line)) + } + // 100 GiB floor + 1 Linux job with its images (34) + macOS images and job (86) - 157 free. + #expect(try plan().freeSpaceNote == Self.freeSpaceNote(macOSNeeds: 63)) + #expect(try plan(freeGiB: 200).freeSpaceNote == Self.freeSpaceNote(macOSNeeds: 20)) + // No job: one macOS job's disk alone, as the verdict's own line says. + #expect(try plan(linux: 0, freeGiB: 120).freeSpaceNote == Self.freeSpaceNote(macOSNeeds: 66)) + // A plan whose numbers fit a macOS job anyway says no number. + #expect(try plan(freeGiB: 400).freeSpaceNote == Self.freeSpaceNote(macOSNeeds: nil)) + for limit in ["cores", "memory", "your choice", "macOS's limit of 2 VMs, yours included"] { + #expect(try plan(limit: limit).freeSpaceNote == nil, "\(limit)") + } + #expect(try plan(macOS: 1).freeSpaceNote == nil) + } + + @Test("the feedback's Mac: 3 Linux slots and no macOS one for want of disk; the note counts the Linux slots") + func freeSpaceNoteWithThreeLinuxSlots() throws { + // 110 GiB above the floor: a lone macOS job (86) would fit, but the 3 Linux jobs and their images take 94. + let plan = try #require(SandboxSizingPlan(line: FakeSandboxInstaller.plan( + message: "3 Linux slots", linux: 3, freeGiB: 210))) + #expect(plan.diskShortfall(plan.macOS) == 70 << 30) + #expect(plan.freeSpaceNote == Self.freeSpaceNote(macOSNeeds: 70)) + } + /// Each event as the renderer gets it. private static func render(_ lines: [String], interactive: Bool = false, finish outcome: SandboxSetupRenderer.Outcome = .succeeded) -> String { @@ -422,8 +460,7 @@ struct SandboxSetupTests { } #expect(advice(2) == "This Mac cannot host Darkbloom Sandbox as it is; see why above.") #expect(advice(3).hasPrefix("This Mac was not enrolled: the code was denied or expired")) - #expect(advice(4) == "Jobs are running on this Mac. Run `darkbloom sandbox setup` again once they finish; " - + "`darkbloom sandbox pause` keeps new ones from starting.") + #expect(advice(4) == Self.jobRunningAdvice) #expect(advice(130) == "Setup stopped. An enrollment waiting for approval goes on; run " + "`darkbloom sandbox setup` again to follow it.") #expect(advice(2, signal: SIGINT) == advice(130)) @@ -500,10 +537,6 @@ struct SandboxSetupTests { try await SandboxSetupFlow(options: first, confirmed: true, addon: .live(), interactiveInput: false, terminal: false, color: false, probe: { _ in .mac(cores: 16, memoryGiB: 128) }).run() - print("== SECOND") - try await SandboxSetupFlow(options: SandboxSetupOptions(server: "https://sandbox.invalid"), - confirmed: false, addon: .live(), interactiveInput: false, - terminal: false, color: false).run() print("== PLAN") print(try String(contentsOf: sandbox.sandboxAddonRoot.appendingPathComponent("plan-arguments"), encoding: .utf8), terminator: "") @@ -511,9 +544,14 @@ struct SandboxSetupTests { print(try String(contentsOf: sandbox.sandboxAddonRoot.appendingPathComponent("installer-arguments"), encoding: .utf8), terminator: "") print("requests \(CoordinatorStub.requests.map { $0.url?.absoluteString ?? "" })") + print("== SECOND") + try await SandboxSetupFlow(options: SandboxSetupOptions(server: "https://sandbox.invalid"), + confirmed: false, addon: .live(), interactiveInput: false, + terminal: false, color: false).run() + print("== END") } let output = decodedText(result.standardOutputContent) - let first = try #require(outputSection(output, from: "== FIRST", to: "== SECOND")) + let first = try #require(outputSection(output, from: "== FIRST", to: "== PLAN")) // The sizing lines are the plan's (157 GiB free), not this Mac's probe (800 GiB). #expect(first.hasPrefix(""" Darkbloom Sandbox setup @@ -533,6 +571,7 @@ struct SandboxSetupTests { Eligible. At a time, this Mac can run: 1 Linux job (your choice) no macOS jobs (limited by free disk space) + \(Self.freeSpaceNote(macOSNeeds: 63)) What changes @@ -546,17 +585,236 @@ struct SandboxSetupTests { Next """)) - let second = try #require(outputSection(output, from: "== SECOND", to: "== PLAN")) - #expect(second.hasPrefix("Darkbloom Sandbox is already set up on this Mac.\n\n" - + "Darkbloom Sandbox 1.0.1: downloading images (Linux 42%)\n")) - #expect(second.hasSuffix( - "\nTo change how many jobs run at a time: darkbloom sandbox setup --linux-slots --macos-slots \n")) // The owner's slot counts reach the plan and the install; one download serves both. let plan = try #require(outputSection(output, from: "== PLAN", to: "== INSTALL")) #expect(plan == "--plan\n--json-progress\n--linux-slots\n1\n") let install = try #require(outputSection(output, from: "== INSTALL", to: "requests")) #expect(install == "--json-progress\n--yes\n--no-browser\n--linux-slots\n1\n") - #expect(output.hasSuffix("requests [\"https://sandbox.invalid/install.sh\"]\n")) + #expect(output.contains("requests [\"https://sandbox.invalid/install.sh\"]\n== SECOND")) + // The rerun reports and asks the plan again (1 Linux, no macOS, against 1 + 1 installed); + // without a prompt it does not remove a slot. + let second = try #require(outputSection(output, from: "== SECOND", to: "== END")) + #expect(second.hasPrefix("Darkbloom Sandbox is already set up on this Mac.\n\n" + + "Darkbloom Sandbox 1.0.1: downloading images (Linux 42%)\n")) + #expect(second.hasSuffix(""" + macOS images 46 GiB + 40 GiB per macOS job + \(Self.freeSpaceNote(macOSNeeds: 63)) + + This Mac now fits 1 Linux + 0 macOS (installed: 1 Linux + 1 macOS). + Not applied: it removes slots, and without a prompt setup applies only a plan that adds slots. To apply \ + it: darkbloom sandbox setup --linux-slots 1 --macos-slots 0 + + """)) + } + + // MARK: - Rerun on a Mac that is set up + + @Test("a slot change compares the plan with the installed totals; none without totals or without a job") + func slotChange() throws { + let plan = try #require(SandboxSizingPlan(line: FakeSandboxInstaller.plan(macOS: 1, freeGiB: 240))) + let change = try #require(SandboxSlotChange(installed: SandboxFixtures.status( + SandboxFixtures.ready(linux: 3, macOS: 0)), plan: plan)) + #expect(change == SandboxSlotChange(installedLinux: 3, installedMacOS: 0, plannedLinux: 1, plannedMacOS: 1)) + #expect(!change.onlyAdds) + #expect(change.applying(to: SandboxSetupOptions(noBrowser: true)) + == SandboxSetupOptions(noBrowser: true, linuxSlots: 1, macOSSlots: 1)) + #expect(SandboxSlotChange(installedLinux: 1, installedMacOS: 0, plannedLinux: 1, plannedMacOS: 1).onlyAdds) + #expect(SandboxSlotChange(installed: SandboxFixtures.status(SandboxFixtures.ready), plan: plan) == nil) + #expect(SandboxSlotChange(installed: SandboxFixtures.status(SandboxFixtures.minimal), plan: plan) == nil) + let none = try #require(SandboxSizingPlan(line: FakeSandboxInstaller.plan(linux: 0, freeGiB: 120))) + #expect(SandboxSlotChange(installed: SandboxFixtures.status(SandboxFixtures.ready), plan: none) == nil) + // An empty answer is yes only where yes is the default. + #expect(SandboxTerminal.confirm("Apply?", defaultYes: true, readInput: { "" }, emit: { _ in })) + #expect(!SandboxTerminal.confirm("Apply?", readInput: { "" }, emit: { _ in })) + #expect(!SandboxTerminal.confirm("Apply?", defaultYes: true, readInput: { "n" }, emit: { _ in })) + } + + /// Runs setup on a Mac with the add-on installed (`status`) against an + /// installer whose plan prints `plan` (none: an installer without plan + /// mode), answering `answer` at a prompt when given; an install prints + /// `installerEvents` and exits with `installerExit`, which setup keeps. + /// Prints the output, then `== PLAN` and `== INSTALL` with the arguments + /// each run got. + private static func rerun(status: String, plan: String?, answer: String? = nil, confirmed: Bool = false, + linuxSlots: Int? = nil, macOSSlots: Int? = nil, + installerEvents: [String] = FakeSandboxInstaller.events, + installerExit: Int32 = 0) async throws -> String { + let expected: ExitTest.Condition = installerExit == 0 ? .success : .exitCode(installerExit) + let result = try await #require(processExitsWith: expected, observing: [\.standardOutputContent]) { + [status = status as String, plan = plan as String?, answer = answer as String?, + confirmed = confirmed as Bool, linuxSlots = linuxSlots as Int?, macOSSlots = macOSSlots as Int?, + installerEvents = installerEvents as [String], installerExit = installerExit as Int32] in + let options = SandboxSetupOptions(server: "https://sandbox.invalid", linuxSlots: linuxSlots, + macOSSlots: macOSSlots) + let sandbox = try CLICommandSandbox.enter(autoRestart: false) + try FakeSandboxAddon.install(.current(status: status), at: sandbox.sandboxAddonRoot) + CoordinatorStub.install(["/install.sh": .init(status: 200, body: Data(FakeSandboxInstaller.script( + events: installerEvents, plan: plan.map { [$0] }, addonStatus: SandboxFixtures.ready(linux: 1, macOS: 1), + exitStatus: installerExit).utf8))]) + if let answer { try replaceStandardInput(with: answer) } + print("== EXPECTED") + SandboxStatusView.lines(SandboxFixtures.status(status)).forEach { print($0) } + print("== OUTPUT") + await exitWithCommandStatus { + defer { + for (marker, file) in [("== PLAN", "plan-arguments"), ("== INSTALL", "installer-arguments")] { + print(marker) + let url = sandbox.sandboxAddonRoot.appendingPathComponent(file) + print((try? String(contentsOf: url, encoding: .utf8)) ?? "none\n", terminator: "") + } + print("== END") + sandbox.remove() + } + try await SandboxSetupFlow(options: options, confirmed: confirmed, addon: .live(), + interactiveInput: answer != nil, terminal: false, color: false).run() + } + } + return decodedText(result.standardOutputContent) + } + + private static let changeHint = "To change how many jobs run at a time: darkbloom sandbox setup " + + "--linux-slots --macos-slots \n" + + /// Today's report for `output`'s Mac: the state, then the slot options. + private static func alreadySetUp(_ output: String) throws -> String { + let status = try #require(outputSection(output, from: "== EXPECTED", to: "== OUTPUT")) + return "Darkbloom Sandbox is already set up on this Mac.\n\n" + status + "\n" + changeHint + } + + @Test("rerun with the plan the Mac runs: today's report, after the plan, changing nothing") + func rerunSamePlan() async throws { + let output = try await Self.rerun(status: SandboxFixtures.ready(linux: 1, macOS: 1), + plan: FakeSandboxInstaller.plan(message: "1 Linux slot and 1 macOS slot", + macOS: 1, freeGiB: 300)) + #expect(try outputSection(output, from: "== OUTPUT", to: "== PLAN") == Self.alreadySetUp(output)) + #expect(output.hasSuffix("== PLAN\n--plan\n--json-progress\n== INSTALL\nnone\n== END\n")) + } + + @Test("rerun with the same plan, macOS short of disk: exactly today's report, without the free-space note") + func rerunSamePlanShortOfDisk() async throws { + // The feedback's Mac before it freed space: 3 Linux slots, macOS short of disk, as installed. + let output = try await Self.rerun(status: SandboxFixtures.ready(linux: 3, macOS: 0), + plan: FakeSandboxInstaller.plan(message: "3 Linux slots", linux: 3, + freeGiB: 210)) + #expect(try outputSection(output, from: "== OUTPUT", to: "== PLAN") == Self.alreadySetUp(output)) + #expect(output.hasSuffix("== PLAN\n--plan\n--json-progress\n== INSTALL\nnone\n== END\n")) + } + + /// The feedback's Mac: 3 Linux slots installed; with more free space the plan fits 1 Linux and 1 macOS. + private static let macOSFits = FakeSandboxInstaller.plan(message: "1 Linux slot and 1 macOS slot", macOS: 1, + freeGiB: 240) + + @Test("rerun when the plan now fits macOS: it offers the plan; yes applies its counts, no changes nothing") + func rerunOffersPlan() async throws { + let offer = """ + The add-on's plan for this Mac now: + [PASS] CPU: 16 cores; you keep 4 + [PASS] Memory: 128 GB; you keep 32 GB, inference keeps 32 GB + [PASS] Disk: 240 GiB free; 100 GiB stays free for you; Linux images 4 GiB + 30 GiB per Linux job; \ + macOS images 46 GiB + 40 GiB per macOS job + + + """ + "This Mac now fits 1 Linux + 1 macOS (installed: 3 Linux + 0 macOS). If a job is running, the " + + "installer refuses and changes nothing. Apply? [Y/n]: " + for answer in ["\n", "y\n"] { + let output = try await Self.rerun(status: SandboxFixtures.ready(linux: 3, macOS: 0), plan: Self.macOSFits, + answer: answer) + let shown = try #require(outputSection(output, from: "== OUTPUT", to: "== PLAN")) + let report = try Self.alreadySetUp(output).replacingOccurrences(of: Self.changeHint, with: "") + #expect(shown.hasPrefix(report + offer + "\n"), "\(answer)") + #expect(shown.contains("Darkbloom Sandbox is set up on this Mac: ready")) + #expect(output.hasSuffix("== INSTALL\n--json-progress\n--yes\n--linux-slots\n1\n--macos-slots\n1\n== END\n")) + } + let declined = try await Self.rerun(status: SandboxFixtures.ready(linux: 3, macOS: 0), plan: Self.macOSFits, + answer: "n\n") + #expect(declined.contains(offer + "Nothing changed. To apply it later: darkbloom sandbox setup " + + "--linux-slots 1 --macos-slots 1\n== PLAN")) + #expect(declined.hasSuffix("== INSTALL\nnone\n== END\n")) + } + + @Test("rerun without a prompt (--yes or no terminal): only a plan that adds slots and removes none is applied") + func rerunUnattended() async throws { + for confirmed in [true, false] { + // 3 Linux + 0 macOS to 1 + 1 removes Linux slots: suggested, not applied. + let removes = try await Self.rerun(status: SandboxFixtures.ready(linux: 3, macOS: 0), plan: Self.macOSFits, + confirmed: confirmed) + #expect(removes.contains("Not applied: it removes slots, and without a prompt setup applies only a plan " + + "that adds slots. To apply it: darkbloom sandbox setup --linux-slots 1 --macos-slots 1\n== PLAN")) + #expect(!removes.contains("[Y/n]")) + #expect(removes.hasSuffix("== INSTALL\nnone\n== END\n")) + // 1 Linux + 0 macOS to 1 + 1 only adds: applied. + let adds = try await Self.rerun(status: SandboxFixtures.ready(linux: 1, macOS: 0), plan: Self.macOSFits, + confirmed: confirmed) + #expect(adds.contains("\nThis Mac now fits 1 Linux + 1 macOS (installed: 1 Linux + 0 macOS).\n" + + "Applying it: it only adds slots.\n\n")) + #expect(adds.hasSuffix("== INSTALL\n--json-progress\n--yes\n--linux-slots\n1\n--macos-slots\n1\n== END\n")) + } + } + + /// Setup's words for the installer's exit status 4. + private static let jobRunningAdvice = "A job is running on this Mac, so the installer changed nothing. Run " + + "`darkbloom sandbox setup` again when it finishes; `darkbloom sandbox pause` keeps new jobs from starting. " + + "Setup never passes the installer's --force: it would stop running jobs, and stopped jobs aren't paid." + + @Test("applying the plan after a job started: the installer refuses (exit 4), setup says so and exits 4") + func rerunRefusedWhileAJobRuns() async throws { + // add-on 1.1.1's refusal (`InstallError.jobsRunning`) at its install stage. + let refusal = "jobs are running on this Mac; rerun when they finish (the agent also updates itself " + + "between jobs), or pass --force to stop them" + let output = try await Self.rerun( + status: SandboxFixtures.ready(linux: 3, macOS: 0), plan: Self.macOSFits, answer: "y\n", + installerEvents: [FakeSandboxInstaller.stage("installing", "started", "Installing"), + FakeSandboxInstaller.stage("installing", "failed", refusal, #""exit_code":4"#)], + installerExit: 4) + #expect(output.contains("\n\n" + Self.jobRunningAdvice + "\n== PLAN")) + #expect(!output.contains("Darkbloom Sandbox is set up on this Mac")) + // The plan's counts, and no --force: the running job is not stopped. + #expect(output.hasSuffix("== INSTALL\n--json-progress\n--yes\n--linux-slots\n1\n--macos-slots\n1\n== END\n")) + } + + @Test("rerun while jobs run: today's report, no plan, and when to run it again") + func rerunWhileJobsRun() async throws { + let output = try await Self.rerun(status: SandboxFixtures.ready(linux: 3, macOS: 0, jobsRunning: 1), + plan: Self.macOSFits) + #expect(try outputSection(output, from: "== OUTPUT", to: "== PLAN") == Self.alreadySetUp(output) + + "Jobs are running, so setup did not check whether this Mac now fits other slot counts. Run " + + "`darkbloom sandbox setup` again once they finish; `darkbloom sandbox pause` keeps new ones from starting.\n") + #expect(output.hasSuffix("== PLAN\nnone\n== INSTALL\nnone\n== END\n")) + } + + @Test("rerun with explicit slot counts applies them without a plan, as before") + func rerunExplicitCounts() async throws { + let output = try await Self.rerun( + status: SandboxFixtures.ready(linux: 3, macOS: 0), plan: Self.macOSFits, linuxSlots: 2, macOSSlots: 0) + let shown = try #require(outputSection(output, from: "== OUTPUT", to: "== PLAN")) + #expect(shown.hasPrefix("Applying the new slot counts.\n")) + #expect(output.hasSuffix("== PLAN\nnone\n== INSTALL\n--json-progress\n--yes\n--linux-slots\n2\n" + + "--macos-slots\n0\n== END\n")) + } + + @Test("rerun with an installer without plan mode, or one that fails it: today's report") + func rerunWithoutPlan() async throws { + for plan in [nil, "not a plan"] as [String?] { + let output = try await Self.rerun(status: SandboxFixtures.ready(linux: 3, macOS: 0), plan: plan) + #expect(try outputSection(output, from: "== OUTPUT", to: "== PLAN") == Self.alreadySetUp(output)) + #expect(output.hasSuffix("== INSTALL\nnone\n== END\n")) + } + } + + @Test("rerun when the installer cannot be downloaded: today's report and why it could not check") + func rerunOffline() async throws { + let result = try await #require(processExitsWith: .success, observing: [\.standardOutputContent]) { + let sandbox = try CLICommandSandbox.enter(autoRestart: false) + defer { sandbox.remove() } + try FakeSandboxAddon.install(.current(status: SandboxFixtures.ready(linux: 3, macOS: 0)), + at: sandbox.sandboxAddonRoot) + try await SandboxSetupFlow(options: SandboxSetupOptions(server: "https://sandbox.invalid"), + confirmed: false, addon: .live(), interactiveInput: false, + terminal: false, color: false).run() + } + #expect(decodedText(result.standardOutputContent).hasSuffix(Self.changeHint + + "Could not check whether this Mac now fits other slot counts: Could not download the Darkbloom Sandbox " + + "installer from https://sandbox.invalid/install.sh: HTTP 404.\n")) } @Test("when the plan fits no job, setup prints why and how much disk to free, and installs nothing") @@ -584,6 +842,7 @@ struct SandboxSetupTests { Not eligible: No slot fits. Free up 14 GiB of disk for one Linux job, or 66 GiB of disk for one macOS job. + \(Self.freeSpaceNote(macOSNeeds: 66)) planned true installed false diff --git a/provider-swift/Tests/DarkbloomCLITests/SandboxTestSupport.swift b/provider-swift/Tests/DarkbloomCLITests/SandboxTestSupport.swift index 9c02785936..450b53eb52 100644 --- a/provider-swift/Tests/DarkbloomCLITests/SandboxTestSupport.swift +++ b/provider-swift/Tests/DarkbloomCLITests/SandboxTestSupport.swift @@ -56,6 +56,16 @@ enum SandboxFixtures { static let minimal = #"{"schema":1,"state":"ready"}"# + /// `ready` with these slot counts (all free unless jobs run) and running jobs. + static func ready(linux: Int, macOS: Int, jobsRunning: Int = 0) -> String { + ready.replacingOccurrences( + of: #""jobs_running":0"#, with: #""jobs_running":\#(jobsRunning)"# + ).replacingOccurrences( + of: #""slots":{"linux":{"free":1,"total":1},"macos":{"free":1,"total":1}}"#, + with: #""slots":{"linux":{"free":\#(max(0, linux - jobsRunning)),"total":\#(linux)},"# + + #""macos":{"free":\#(macOS),"total":\#(macOS)}}"#) + } + static func status(_ json: String) -> SandboxAddonStatus { guard let status = SandboxAddonStatus(json: json) else { fatalError("fixture does not decode: \(json)") } return status diff --git a/scripts/ci-component-paths.py b/scripts/ci-component-paths.py index b6dcab5918..da6677d4f2 100644 --- a/scripts/ci-component-paths.py +++ b/scripts/ci-component-paths.py @@ -10,7 +10,7 @@ import subprocess -COMPONENTS = ("provider", "sdk", "cluster") +COMPONENTS = ("provider", "sdk", "cluster", "mimo_audio") COMMON = ( "Makefile", "mise.toml", ".gitmodules", ".github/workflows/component-changes.yml", ".github/workflows/darkbloom-route.yml", @@ -82,6 +82,22 @@ ) + +# Inputs of the MiMo audio gate in the last provider shard, which needs the +# 1.87 GB pinned audio codec: the MiMo, audio and media provider code, the MiMo +# tests, the MLX pins, the fixture scripts (the audio one runs the provider +# fixture generator with --audio-source) and the gate's recipe. Every one is +# also a provider input. Default-branch pushes run the gate regardless. +MIMO_AUDIO = ( + "provider-swift/Package.swift", "provider-swift/Package.resolved", + "provider-swift/Sources/*MiMo*", "provider-swift/Sources/*Audio*", "provider-swift/Sources/*Media*", + "provider-swift/Tests/ProviderCoreTests/MiMo/*", + "libs/mlx", "libs/mlx/**", "libs/mlx-swift", "libs/mlx-swift/**", "libs/mlx-swift-lm", "libs/mlx-swift-lm/**", + ".github/workflows/ci.yml", "scripts/prepare-mimo-audio-fixtures.py", + "scripts/prepare-mimo-provider-fixtures.py", "scripts/run-nested-suite.sh", +) + + def matches(path, patterns): return any(fnmatchcase(path, pattern) for pattern in patterns) @@ -98,6 +114,7 @@ def classify(paths): selected["provider"] |= matches(path, PROVIDER) selected["sdk"] |= matches(path, SDK) selected["cluster"] |= matches(path, CLUSTER) + selected["mimo_audio"] |= matches(path, MIMO_AUDIO) return selected diff --git a/scripts/install-release-cmake.sh b/scripts/install-release-cmake.sh index 036ee02d5f..bf93b222be 100755 --- a/scripts/install-release-cmake.sh +++ b/scripts/install-release-cmake.sh @@ -7,17 +7,29 @@ if [ "$(uname -s)-$(uname -m)" != Darwin-arm64 ]; then exit 2 fi -archive="$(mktemp)" -trap 'rm -f "$archive"' EXIT -curl --fail --silent --show-error --location --retry 3 \ - https://github.com/Kitware/CMake/releases/download/v3.31.12/cmake-3.31.12-macos-universal.tar.gz \ - --output "$archive" -printf '%s %s\n' \ - '799af7fd545db9bf1b9cfe72f8095880e727a2d4e0df0e3dffc3bc7b95c2d3b0' \ - "$archive" | shasum -a 256 --check -install_root="$RUNNER_TEMP/cmake-3.31.12" -mkdir -p "$install_root" -tar -xzf "$archive" -C "$install_root" -cmake_bin="$install_root/cmake-3.31.12-macos-universal/CMake.app/Contents/bin" +version=3.31.12 +# Darkbloom macOS images unpack this same sha256-checked archive into the +# runner tool cache (darkbloom-sandbox images/macos/guest/provision.sh, +# cmake_toolcache). Use that copy rather than downloading 80 MB again; download +# everywhere else, such as on Blacksmith. +cached="${RUNNER_TOOL_CACHE:-/nonexistent}/cmake/$version/universal" +if [ -f "$cached.complete" ] && + [ "$("$cached/CMake.app/Contents/bin/cmake" --version 2>/dev/null | head -n 1)" = "cmake version $version" ]; then + cmake_bin="$cached/CMake.app/Contents/bin" + echo "Using CMake $version from the runner tool cache" +else + archive="$(mktemp)" + trap 'rm -f "$archive"' EXIT + curl --fail --silent --show-error --location --retry 3 \ + "https://github.com/Kitware/CMake/releases/download/v$version/cmake-$version-macos-universal.tar.gz" \ + --output "$archive" + printf '%s %s\n' \ + '799af7fd545db9bf1b9cfe72f8095880e727a2d4e0df0e3dffc3bc7b95c2d3b0' \ + "$archive" | shasum -a 256 --check + install_root="$RUNNER_TEMP/cmake-$version" + mkdir -p "$install_root" + tar -xzf "$archive" -C "$install_root" + cmake_bin="$install_root/cmake-$version-macos-universal/CMake.app/Contents/bin" +fi "$cmake_bin/cmake" --version printf '%s\n' "$cmake_bin" >> "$GITHUB_PATH" diff --git a/scripts/test-ci-component-paths.py b/scripts/test-ci-component-paths.py index 01ba22c42b..226776161f 100644 --- a/scripts/test-ci-component-paths.py +++ b/scripts/test-ci-component-paths.py @@ -47,16 +47,22 @@ def test_component_and_shared_dependency_matrix(self): "provider-swift/Sources/ProviderCoreFoundation/Manifest.swift": {"provider", "cluster"}, "provider-swift/Tests/ClusterOnboardingChecks/run.sh": {"provider", "cluster"}, "provider-swift/Tests/ProviderCoreTests/Inference/DistributedServeLoopTests.swift": {"provider"}, - "provider-swift/Package.swift": {"provider", "cluster"}, - "libs/mlx-swift-lm": {"provider", "sdk", "cluster"}, - "libs/mlx-swift-lm/Libraries/MLXLMCommon/Generate.swift": {"provider", "sdk", "cluster"}, - "libs/mlx-swift": {"provider", "sdk", "cluster"}, - "libs/mlx": {"provider", "cluster"}, + "provider-swift/Package.swift": {"provider", "cluster", "mimo_audio"}, + "provider-swift/Sources/ProviderCore/Inference/Engine/Factory/MiMo/MiMoV26ManagedMediaForwarding.swift": + {"provider", "mimo_audio"}, + "provider-swift/Tests/ProviderCoreTests/MiMo/MiMoV26ManagedAudioProviderTests.swift": {"provider", "mimo_audio"}, + "scripts/prepare-mimo-audio-fixtures.py": {"provider", "mimo_audio"}, + # The audio fixture script runs this generator with --audio-source. + "scripts/prepare-mimo-provider-fixtures.py": {"provider", "sdk", "mimo_audio"}, + "libs/mlx-swift-lm": {"provider", "sdk", "cluster", "mimo_audio"}, + "libs/mlx-swift-lm/Libraries/MLXLMCommon/Generate.swift": {"provider", "sdk", "cluster", "mimo_audio"}, + "libs/mlx-swift": {"provider", "sdk", "cluster", "mimo_audio"}, + "libs/mlx": {"provider", "cluster", "mimo_audio"}, "libs/darkbloom-cluster/Package.swift": {"provider", "cluster"}, "libs/darkbloom-cluster-worker/Tests/CapabilityChecks/run.sh": {"provider", "cluster"}, "fixtures/prompt-contract/v1/corpus.json": {"provider"}, ".github/actions/provider-ci-build/action.yml": {"provider", "sdk", "cluster"}, - ".github/workflows/ci.yml": {"provider", "sdk", "cluster"}, + ".github/workflows/ci.yml": {"provider", "sdk", "cluster", "mimo_audio"}, "scripts/run-paged-kernel-tests.sh": {"provider", "sdk"}, "scripts/run-provider-tests.sh": {"provider"}, "scripts/provider-test-shards.py": {"provider"}, @@ -74,12 +80,13 @@ def test_component_and_shared_dependency_matrix(self): self.assertEqual({name for name, value in routing.classify([path]).items() if value}, expected) for path in routing.COMMON: self.assertTrue(all(routing.classify([path]).values()), path) - # Every SDK-lane and cluster input is also a provider input. - for pattern in (*routing.SDK, *routing.CLUSTER): - path = pattern.replace("**", "x").replace("*", "Cluster") - self.assertTrue(routing.classify([path])[ - "sdk" if pattern in routing.SDK else "cluster"], path) - self.assertTrue(routing.classify([path])["provider"], path) + # Every SDK-lane, cluster and MiMo audio input is also a provider input. + for component, patterns in (("sdk", routing.SDK), ("cluster", routing.CLUSTER), + ("mimo_audio", routing.MIMO_AUDIO)): + for pattern in patterns: + path = pattern.replace("**", "x").replace("*", "Cluster" if component == "cluster" else "MiMo") + self.assertTrue(routing.classify([path])[component], path) + self.assertTrue(routing.classify([path])["provider"], path) def test_swift_prompt_corpora_select_provider(self): for filename in ("nemotron-prompt-edge-corpus.json", "nemotron-reference-corpus.json"): @@ -219,12 +226,18 @@ def test_push_before_after_and_new_branch_and_manual(self): # push that runs the provider lanes runs them too. self.write("provider-swift/Sources/ProviderCore/Inference/Engine/EngineV2.swift") provider_only = self.commit() - self.assertEqual(self.pr(head, provider_only), {"provider": True, "sdk": False, "cluster": False}) + self.assertEqual(self.pr(head, provider_only), + {"provider": True, "sdk": False, "cluster": False, "mimo_audio": False}) self.assertEqual(self.run_detector("push", {"before": head, "after": provider_only, "ref": "refs/heads/dev"}), - {"provider": True, "sdk": False, "cluster": True}) + {"provider": True, "sdk": False, "cluster": True, "mimo_audio": False}) self.write("libs/darkbloom-cluster/Sources/DarkbloomClusterRuntime/New.swift") cluster = self.commit() - self.assertEqual(self.pr(provider_only, cluster), {"provider": True, "sdk": False, "cluster": True}) + self.assertEqual(self.pr(provider_only, cluster), + {"provider": True, "sdk": False, "cluster": True, "mimo_audio": False}) + # The MiMo audio gate and its 1.87 GB codec run only for their inputs. + self.write("provider-swift/Tests/ProviderCoreTests/MiMo/MiMoV26ManagedAudioProviderTests.swift") + audio = self.commit() + self.assertEqual(self.pr(cluster, audio), {"provider": True, "sdk": False, "cluster": False, "mimo_audio": True}) for ref in ("refs/heads/master", "refs/heads/main"): self.assertTrue(all(self.run_detector("push", {**event, "ref": ref}).values())) self.assertTrue(all(self.run_detector("push", {**event, "before": "0" * 40}).values())) @@ -264,28 +277,28 @@ def test_expensive_jobs_depend_on_successful_classifier(self): jobs = workflow.job_blocks((ROOT / ".github/workflows" / name).read_text()) self.assertIn("uses: ./.github/workflows/component-changes.yml", jobs["changes"]) self.assertIn("contents: read", jobs["changes"]) - # The route job waits for the classifier (ci.yml, route). + # Runner routing follows the classifier, so only selected lanes are requested. self.assertIn(" needs: changes\n", jobs["route"]) for lane, component in lanes.items(): - self.assertIn(" needs: changes\n", jobs[lane]) + self.assertIn(" needs: [changes, route]\n", jobs[lane]) self.assertIn(" if: ${{ needs.changes.outputs." + component + " == 'true' }}\n", jobs[lane]) self.assertNotIn("continue-on-error:", jobs[lane]) ci = workflow.job_blocks((ROOT / ".github/workflows/ci.yml").read_text()) # The GPU job's test step continues on error (scripts/test-cluster-test-plan.py). - self.assertIn(" needs: changes\n", ci["test-cluster-gpu"]) + self.assertIn(" needs: [changes, route]\n", ci["test-cluster-gpu"]) self.assertIn(" if: ${{ needs.changes.outputs.cluster == 'true' }}\n", ci["test-cluster-gpu"]) # The SDK lane runs on every push and on pull requests that change its inputs. - self.assertIn(" needs: changes\n", ci["test-provider-sdk"]) + self.assertIn(" needs: [changes, route]\n", ci["test-provider-sdk"]) self.assertIn(" if: ${{ github.event_name == 'push' || needs.changes.outputs.sdk == 'true' }}\n", ci["test-provider-sdk"]) self.assertNotIn("continue-on-error:", ci["test-provider-sdk"]) # The summary runs after failed shards too, but only when the shards were selected. - self.assertIn(" needs: [changes, test-provider]\n", ci["test-provider-summary"]) + self.assertIn(" needs: [changes, route, test-provider]\n", ci["test-provider-summary"]) self.assertIn(" if: ${{ !cancelled() && needs.changes.outputs.provider == 'true' }}\n", ci["test-provider-summary"]) self.assertNotIn("continue-on-error:", ci["test-provider-summary"]) for policy in ("release-integrity", "docs"): - self.assertNotIn(" if:", ci[policy]) + self.assertNotRegex(ci[policy], r"(?m)^ if:") self.assertIn("python3 scripts/test-ci-component-paths.py", ci["release-integrity"]) self.assertNotIn("cache-swift", ci) diff --git a/scripts/test-cluster-test-plan.py b/scripts/test-cluster-test-plan.py index f9aae9202c..0a24a8b209 100755 --- a/scripts/test-cluster-test-plan.py +++ b/scripts/test-cluster-test-plan.py @@ -102,9 +102,8 @@ def test_jobs_run_every_shard_of_their_lane(self): job = self.jobs[job_id] matrix = re.search(r"(?m)^ shard: \[([0-9, ]+)\]$", job).group(1) self.assertEqual([int(shard) for shard in matrix.split(",")], plan.shards(lane)) - # A dedicated Blacksmith Mac per shard; the route has no lane for it. - self.assertIn(" runs-on: blacksmith-12vcpu-macos-27\n", job) - self.assertNotIn(f" {job_id}-", self.jobs["route"]) + for shard in plan.shards(lane): + self.assertIn(f" {job_id}-{shard} macos_arm64 ", self.jobs["route"]) steps = workflow.step_blocks(job) build = next(step for step in steps if workflow.field(step, "uses") == workflow.BUILD_ACTION) self.assertEqual(workflow.field(build, "lane", indent=10), "cluster") @@ -115,8 +114,7 @@ def test_jobs_run_every_shard_of_their_lane(self): self.assertEqual(plan.shards("focused"), [1]) focused = workflow.step_blocks(self.jobs["test-cluster-focused"]) self.assertEqual(workflow.run_command(focused[-1]), "python3 scripts/cluster-test-plan.py run focused 1") - self.assertIn(" runs-on: blacksmith-12vcpu-macos-27\n", self.jobs["test-cluster-focused"]) - self.assertNotIn(" test-cluster-focused ", self.jobs["route"]) + self.assertIn(" test-cluster-focused macos_arm64 ", self.jobs["route"]) def test_only_the_gpu_job_continues_after_a_failure_and_the_gate_requires_the_others(self): self.assertIn("continue-on-error: true", workflow.step_blocks(self.jobs["test-cluster-gpu"])[-1]) diff --git a/scripts/test-darkbloom-route.py b/scripts/test-darkbloom-route.py index 03ef9fa932..fc13b6b139 100755 --- a/scripts/test-darkbloom-route.py +++ b/scripts/test-darkbloom-route.py @@ -39,12 +39,23 @@ "warm": MACOS_FALLBACK, "docs": LINUX_FALLBACK} GRANTED = {"release-integrity": LINUX, "test-provider": MACOS, "warm": MACOS, "docs": LINUX_FALLBACK} +PROVIDER = "${{ needs.changes.outputs.provider == 'true' && 1 || 0 }}" +SDK = "${{ (github.event_name == 'push' || needs.changes.outputs.sdk == 'true') && 1 || 0 }}" +CLUSTER = "${{ needs.changes.outputs.cluster == 'true' && 1 || 0 }}" PULL_REQUEST_WARM = "${{ github.event_name == 'pull_request' && 2 || 0 }}" -# Every routed job: (profile, fallback label, count expression or None for 1). +# Every routed job: (profile, fallback label, count expression or None for 1) +# of each lane it reads. ROUTED = { "ci.yml": { "release-integrity": ("linux_arm64", LINUX_FALLBACK, None), "docs": ("linux_arm64", LINUX_FALLBACK, None), + "test-provider": ("macos_arm64", MACOS_FALLBACK, PROVIDER), + "test-provider-summary": ("macos_arm64", MACOS_FALLBACK, PROVIDER), + "test-provider-sdk": ("macos_arm64", MACOS_FALLBACK, SDK), + "test-cluster-checks": ("macos_arm64", MACOS_FALLBACK, CLUSTER), + "test-cluster": ("macos_arm64", MACOS_FALLBACK, CLUSTER), + "test-cluster-gpu": ("macos_arm64", MACOS_FALLBACK, CLUSTER), + "test-cluster-focused": ("macos_arm64", MACOS_FALLBACK, CLUSTER), }, "docs-impact.yml": { "commit-signatures": ("linux_arm64", LINUX_FALLBACK, None), @@ -59,9 +70,9 @@ UNROUTED = ("release-swift.yml", "release-provider.yml", "release-dev-branch.yml", "release-desktop.yml", "provider-signing-validation.yml", "register-model.yml", "threat-model-review.yml", "bedrock-smoke.yml", "claude.yml", "codex.yml") -# The CI macOS jobs keep their literal Blacksmith label (build.md, CI Runner Routing). -CI_MACOS_JOBS = ("test-provider", "test-provider-summary", "test-provider-sdk", "test-cluster-checks", - "test-cluster", "test-cluster-gpu", "test-cluster-focused") +# The plane grants a lane whole, so each shard of these jobs reads a lane of its +# own, `-`, and gets a free sandbox even when the others fall back. +SHARDED = {"test-provider", "test-cluster", "test-cluster-gpu"} # Master and dispatched warming feed release builds, so only PRs read the route. RUNS_ON = {"warm": "${{ github.event_name == 'pull_request' && " "fromJSON(needs.route.outputs.routes)['warm'] || 'blacksmith-12vcpu-macos-27' }}"} @@ -125,6 +136,16 @@ def matrix_shards(job): return [shard.strip() for shard in matrix.group(1).split(",")] if matrix else [] +def job_lanes(name, job): + """Return the lanes a routed job reads: one per shard when SHARDED, else its own.""" + return [f"{name}-{shard}" for shard in matrix_shards(job)] if name in SHARDED else [name] + + +def requested_lanes(workflow, routed): + """Return {lane: (profile, fallback, count)} that the caller's route job must request.""" + return {lane: lane_spec for name, lane_spec in routed.items() for lane in job_lanes(name, workflow[name])} + + def lane_lines(route_job): """Return the caller's literal `lanes` block lines, before expression evaluation.""" return literal_block(route_job, "lanes", 6).splitlines() @@ -476,19 +497,24 @@ def test_routed_jobs_read_their_lane_and_keep_their_fallback(self): self.assertIn(" uses: ./.github/workflows/darkbloom-route.yml\n", route) self.assertEqual(job_field(route, "permissions"), "{}") self.assertNotIn("secrets", route) - self.assertEqual(route_lanes(route), expected) + self.assertEqual(route_lanes(route), requested_lanes(workflow, expected)) for name, (_, _, count) in expected.items(): job = workflow[name] with self.subTest(workflow=filename, job=name): self.assertIn("route", needs(job)) + if name in SHARDED: + self.assertTrue(matrix_shards(job)) + lane = f"format('{name}-{{0}}', matrix.shard)" + else: + lane = f"'{name}'" self.assertEqual(job_field(job, "runs-on"), RUNS_ON.get( - name, f"${{{{ fromJSON(needs.route.outputs.routes)['{name}'] }}}}")) + name, f"${{{{ fromJSON(needs.route.outputs.routes)[{lane}] }}}}")) condition = job_field(job, "if") if name != "warm": # A lane is requested exactly when its job runs, once per # matrix entry that reads it. `!cancelled()` cannot be # evaluated in the route job and is true there. - jobs_requested = len(matrix_shards(job)) or 1 + jobs_requested = 1 if name in SHARDED else len(matrix_shards(job)) or 1 expected_count = None if condition is not None: inner = condition.removeprefix("${{ ").removesuffix(" }}") @@ -536,7 +562,7 @@ def test_router_accepts_every_caller_configuration(self): HEAD_REPOSITORY="", REPOSITORY="Layr-Labs/d-inference", RUN_ID="1", RUN_ATTEMPT="1") self.assertEqual(result.returncode, 0, result.stdout + result.stderr) self.assertEqual(routes, [{lane: fallback for lane, (_, fallback, _) - in ROUTED[filename].items()}]) + in requested_lanes(workflow, ROUTED[filename]).items()}]) def test_release_and_credentialed_workflows_keep_literal_runners(self): for filename in UNROUTED: @@ -557,11 +583,6 @@ def test_release_and_credentialed_workflows_keep_literal_runners(self): if name not in routed and not job_field(job, "uses"): with self.subTest(workflow=filename, job=name): self.assertRegex(job_field(job, "runs-on"), r"^(blacksmith-[a-z0-9-]+|ubuntu-24\.04)$") - ci = jobs(self.texts["ci.yml"]) - for name in CI_MACOS_JOBS: - with self.subTest(workflow="ci.yml", job=name): - self.assertEqual(job_field(ci[name], "runs-on"), MACOS_FALLBACK) - self.assertNotIn("route", needs(ci[name])) def test_classifier_gate_and_route_need_no_routed_runner(self): ci = jobs(self.texts["ci.yml"]) diff --git a/scripts/test-provider-ci-workflow.py b/scripts/test-provider-ci-workflow.py index c51a499e52..46185d288a 100644 --- a/scripts/test-provider-ci-workflow.py +++ b/scripts/test-provider-ci-workflow.py @@ -152,6 +152,39 @@ def run_command(step): return textwrap.dedent("\n".join(lines[:end])).strip() +CHECKOUT = "actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2" +CACHE_RESTORE = "actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0" +CACHE_SAVE = "actions/cache/save@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0" +# Pushes to master and dev save caches; pull requests never do. +SAVE_POLICY = (" SAVE_CACHES: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/master' " + "|| github.ref == 'refs/heads/dev') }}\n") +SAVE_CACHES = "env.SAVE_CACHES == 'true'" +SAVE_INPUT = "inputs.save-caches == 'true'" +VALIDATE_GIT = """if [ -d .git ] && ! { git rev-parse --verify -q HEAD >/dev/null && + git fsck --connectivity-only --no-progress >/dev/null 2>&1; }; then + echo "::warning title=.git cache::git fsck rejected the restored .git; checking out without it." + rm -rf .git +fi""" +SPARSE_PATTERNS = ("/*", "!/docs/reports/evidence/**/*.gz", "!/landing/public/media/") +GIT_CACHE_STEPS = ("Select today's .git cache", "Restore the newest saved .git", + "Discard a damaged cached .git", None, "Save .git for later runs") + + +def uses(step): + """The action a step uses, whether `uses:` opens the step or follows `name:`.""" + return field(step, "uses") or field(step, "uses", indent=6) + + +def checkout_options(step): + lines = step.split(" with:\n", 1)[1].splitlines() + return [line.split(" #", 1)[0].strip() for line in lines if line.startswith(" ")] + + +def work_steps(job): + """The steps after the shared .git cache and checkout steps.""" + return [step for step in step_blocks(job) if field(step, "name", indent=6) not in GIT_CACHE_STEPS] + + class ProviderCIWorkflowTests(unittest.TestCase): def setUp(self): self.workflow = WORKFLOW.read_text() @@ -196,38 +229,41 @@ def test_lanes_are_independent_on_dedicated_supported_mac_runners(self): for job_id, lane in LANES.items(): with self.subTest(lane=lane): job = self.jobs[job_id] - # A dedicated Blacksmith Mac per job (per shard); the Darkbloom - # route never chooses a macOS runner for these lanes. - self.assertIn(" runs-on: blacksmith-12vcpu-macos-27\n", job) - self.assertNotIn(f" {job_id} ", self.jobs["route"]) - # The SDK lane runs on every push and on pull requests that - # change its inputs. - condition = (SDK_CONDITION if job_id == "test-provider-sdk" - else "needs.changes.outputs.provider == 'true'") - self.assertIn(" timeout-minutes: 60\n", job) - self.assertIn(" needs: changes\n", job) - self.assertIn(" if: ${{ %s }}\n" % condition, job) if job_id == "test-provider": - # Shards are independent: a failed shard never cancels another. + # Shards are independent: a failed shard never cancels + # another, and each shard reads a route lane of its own. self.assertIn(" strategy:\n # A failed shard does not cancel the other shards.\n" " fail-fast: false\n matrix:\n shard: %s\n" % PROVIDER_SHARDS, job) + route_lanes = [f"test-provider-{shard}" for shard in PROVIDER_SHARDS] + lane_key = "format('test-provider-{0}', matrix.shard)" else: self.assertNotRegex(job, re.compile(r"^ strategy:", re.MULTILINE), msg=job) + route_lanes = [job_id] + lane_key = f"'{job_id}'" + # A Darkbloom macOS sandbox when granted, otherwise the same + # dedicated Blacksmith runner; requested only when the job runs. + self.assertIn(" runs-on: ${{ fromJSON(needs.route.outputs.routes)[%s] }}\n" % lane_key, job) + # The SDK lane runs on every push and on pull requests that change its inputs. + condition = (SDK_CONDITION if job_id == "test-provider-sdk" + else "needs.changes.outputs.provider == 'true'") + requested = f"({condition})" if "||" in condition else condition + for route_lane in route_lanes: + self.assertIn(" %s macos_arm64 blacksmith-12vcpu-macos-27 " + "${{ %s && 1 || 0 }}\n" % (route_lane, requested), self.jobs["route"]) + self.assertIn(" timeout-minutes: 60\n", job) + self.assertIn(" needs: [changes, route]\n", job) + self.assertIn(" if: ${{ %s }}\n" % condition, job) self.assertNotIn("continue-on-error:", job) self.assertNotIn("DARKBLOOM_EXCLUSIVE_NATIVE_GPU_TEST:", job) self.assertIn(" name: Provider Unit Tests (shard ${{ matrix.shard }})\n", self.jobs["test-provider"]) - def test_route_requests_no_macos_lane(self): - # The provider and cluster Mac jobs use the literal Blacksmith label, - # so the route asks the plane for Linux lanes only. - self.assertEqual(re.findall(r"(?m)^ ([a-z0-9-]+) ([a-z0-9_]+) ", self.jobs["route"]), - [("release-integrity", "linux_arm64"), ("docs", "linux_arm64")]) - for job_id in ("test-provider", "test-provider-summary", "test-provider-sdk", "test-cluster-checks", - "test-cluster", "test-cluster-gpu", "test-cluster-focused"): - with self.subTest(job=job_id): - self.assertIn(" runs-on: blacksmith-12vcpu-macos-27\n", self.jobs[job_id]) - needs = re.search(r"(?m)^ needs: (.+)$", self.jobs[job_id]).group(1) - self.assertNotIn("route", needs) + def test_route_requests_exactly_one_lane_per_provider_shard(self): + # The plane grants a lane whole: one lane for all shards would need a + # free Mac for every shard at once and otherwise fall back entirely. + # test_lanes_are_independent_on_dedicated_supported_mac_runners pins + # the matrix to PROVIDER_SHARDS. + self.assertEqual(re.findall(r"(?m)^ (test-provider(?:-[0-9]+)?) ", self.jobs["route"]), + [f"test-provider-{shard}" for shard in PROVIDER_SHARDS]) def test_existing_required_check_requires_every_lane_even_after_failures(self): job = self.jobs["provider-test-gate"] @@ -255,16 +291,19 @@ def test_each_lane_checks_out_recursive_sources_before_its_build(self): for job_id, lane in LANES.items(): with self.subTest(lane=lane): steps = step_blocks(self.jobs[job_id]) - self.assertIn("actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683", steps[0]) - self.assertEqual(field(steps[0], "submodules", indent=10), "recursive") + checkout = next(step for step in steps if uses(step) == CHECKOUT) + self.assertEqual(uses(checkout), CHECKOUT) + self.assertEqual(field(checkout, "submodules", indent=10), "recursive") builds = [step for step in steps if field(step, "uses") == BUILD_ACTION] self.assertEqual(len(builds), 1) + self.assertGreater(steps.index(builds[0]), steps.index(checkout)) self.assertEqual(field(builds[0], "lane", indent=10), lane) self.assertEqual(field(builds[0], "id"), "provider-ci-build") self.assertIsNone(field(builds[0], "if")) if lane == "sdk": self.assertEqual(field(builds[0], "timeout-minutes"), "35") - restores = [step for step in steps if "actions/cache/restore@" in step] + restores = [step for step in steps + if "actions/cache/restore@" in step and field(step, "id") != "git-cache"] if lane == "provider": self.assertEqual(len(restores), 1) self.assertEqual(field(restores[0], "id"), "mimo-audio-cache") @@ -300,14 +339,16 @@ def test_only_the_provider_lane_collects_and_reports_coverage(self): self.assertIn("if-no-files-found: error", steps[shard_upload]) for step in (steps[merge], steps[shard_upload]): self.assertNotIn("continue-on-error:", step) - # The summary merges every shard's profile against the shards' cached - # build and writes the report; the gate requires it. + # The summary merges every shard's profile against a build of the same + # commit (the shards' own on master pushes) and writes the report; the + # gate requires it. summary = self.jobs["test-provider-summary"] self.assertIn(" name: Provider Unit Tests Summary\n", summary) - self.assertIn(" needs: [changes, test-provider]\n", summary) + self.assertIn(" needs: [changes, route, test-provider]\n", summary) self.assertIn(" if: ${{ !cancelled() && needs.changes.outputs.provider == 'true' }}\n", summary) - self.assertIn(" runs-on: blacksmith-12vcpu-macos-27\n", summary) - self.assertNotIn(" test-provider-summary ", self.jobs["route"]) + self.assertIn(" runs-on: ${{ fromJSON(needs.route.outputs.routes)['test-provider-summary'] }}\n", summary) + self.assertIn(" test-provider-summary macos_arm64 blacksmith-12vcpu-macos-27 " + "${{ needs.changes.outputs.provider == 'true' && 1 || 0 }}\n", self.jobs["route"]) self.assertNotIn("continue-on-error:", summary) summary_steps = step_blocks(summary) summary_names = [field(step, "name", indent=6) for step in summary_steps] @@ -340,7 +381,7 @@ def test_only_the_provider_lane_collects_and_reports_coverage(self): "swift build --product darkbloom-fan-helper --enable-code-coverage") def test_provider_entrypoint_and_resource_installer_checks_are_retained(self): - steps = step_blocks(self.jobs["test-provider"]) + steps = work_steps(self.jobs["test-provider"]) expected = ( "python3 scripts/test-qwen4-packaged-resources.py", "python3 scripts/test-stage-swiftpm-resource-bundles.py", @@ -460,7 +501,7 @@ def summary(covered, count): self.assertIn("These targets are only in the total: `darkbloom-fan-helper`.", result.stdout) def test_sdk_retains_every_original_gate_command(self): - steps = step_blocks(self.jobs["test-provider-sdk"]) + steps = work_steps(self.jobs["test-provider-sdk"]) gates = {field(step, "name", indent=6): step for step in steps if field(step, "run")} self.assertEqual(len(gates), sum(bool(field(step, "run")) for step in steps)) self.assertEqual(set(gates), set(SDK_COMMANDS) | {"Run Nemotron production SDK gates"}) @@ -478,7 +519,7 @@ def test_every_sdk_gate_requires_successful_build_but_not_earlier_tests(self): SDK_RETENTION_GATE_NAME: SDK_RETENTION_READY, } preparation_steps = {SDK_MIMO_PREPARE_NAME, SDK_RETENTION_PREPARE_NAME} - for step in step_blocks(self.jobs["test-provider-sdk"]): + for step in work_steps(self.jobs["test-provider-sdk"]): if field(step, "run"): with self.subTest(gate=field(step, "name", indent=6)): name = field(step, "name", indent=6) @@ -643,7 +684,12 @@ def test_audio_qualification_uses_real_codec_and_no_skip_gate(self): steps = step_blocks(self.jobs["test-provider"]) fixture = next(s for s in steps if field(s, "id") == "mimo-audio-fixtures") self.assertIn("prepare-mimo-audio-fixtures.py", run_command(fixture)) - self.assertEqual(field(fixture, "if"), LAST_SHARD_READY) + # The 1.87 GB codec is fetched only when the gate's inputs changed; + # the gate needs the fixture, so it skips with it. + audio_ready = LAST_SHARD_READY.replace(" }}", " && needs.changes.outputs.mimo_audio == 'true' }}") + self.assertEqual(field(fixture, "if"), audio_ready) + restore = next(s for s in steps if field(s, "id") == "mimo-audio-cache") + self.assertEqual(field(restore, "if"), audio_ready) gate = next(s for s in steps if field(s, "name", indent=6) == "Run isolated native MiMo audio gate") self.assertIn("testNativeAudioRelease", run_command(gate)) self.assertIn("run-nested-suite.sh", run_command(gate)) @@ -655,15 +701,17 @@ def test_audio_qualification_uses_real_codec_and_no_skip_gate(self): def test_cluster_metadata_runners_run_every_runner_and_fail_on_any(self): job = self.jobs["test-cluster-checks"] self.assertIn(" name: Cluster Metadata Checks\n", job) - self.assertIn(" needs: changes\n", job) + self.assertIn(" needs: [changes, route]\n", job) self.assertIn(" if: ${{ needs.changes.outputs.cluster == 'true' }}\n", job) - self.assertIn(" runs-on: blacksmith-12vcpu-macos-27\n", job) - self.assertNotIn(" test-cluster-checks ", self.jobs["route"]) + self.assertIn(" runs-on: ${{ fromJSON(needs.route.outputs.routes)['test-cluster-checks'] }}\n", job) + self.assertIn(" test-cluster-checks macos_arm64 blacksmith-12vcpu-macos-27 " + "${{ needs.changes.outputs.cluster == 'true' && 1 || 0 }}\n", self.jobs["route"]) for forbidden in ("continue-on-error:", "secrets.", "DARKBLOOM_EXCLUSIVE_NATIVE_GPU_TEST:"): self.assertNotIn(forbidden, job) steps = step_blocks(job) - self.assertIn("actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683", steps[0]) - self.assertEqual(field(steps[0], "submodules", indent=10), "recursive") + checkout = next(step for step in steps if uses(step) == CHECKOUT) + self.assertEqual(uses(checkout), CHECKOUT) + self.assertEqual(field(checkout, "submodules", indent=10), "recursive") toolchain = next(step for step in steps if field(step, "id") == "toolchain") self.assertEqual(run_command(toolchain), "./scripts/prepare-provider-release-toolchain.sh") runners = { @@ -706,25 +754,31 @@ def test_cluster_metadata_runners_run_every_runner_and_fail_on_any(self): self.assertIn("python3 scripts/provider-release-cache.py restore-mtimes", steps[timestamps]) self.assertIn("python3 scripts/provider-release-cache.py snapshot-mtimes", steps[record]) key = named["Resolve cluster metadata build cache key"] - for component in ("swift --version", "xcodebuild -version", "git submodule status --recursive", + pins = "git submodule status --recursive | awk '{print $1, $2}'" + for component in ("swift --version", "xcodebuild -version", pins, "$GITHUB_WORKSPACE $RUNNER_TEMP $MANIFESTS", "native-metadata.sh"): self.assertIn(component, key) + # `git describe` text depends on the refs a restored .git holds; the + # key keeps only each submodule's state, pin and path. + status = " 0123abc libs/mlx (heads/main)\n+4567def libs/mlx-swift (v0.30.0-2-g4567def)\n" + pinned = subprocess.run(["awk", "{print $1, $2}"], input=status, capture_output=True, text=True, check=True) + self.assertEqual(pinned.stdout, "0123abc libs/mlx\n+4567def libs/mlx-swift\n") for step in (steps[record], steps[upload]): self.assertIn("steps.capability-checks.outcome == 'success'", field(step, "if")) - # A pull request saves only when it restored nothing; pushes save. - self.assertIn("steps.cluster-build-cache.outputs.cache-hit != 'true' && (github.event_name != " - "'pull_request' || steps.cluster-build-cache.outputs.cache-matched-key == '')", - field(step, "if")) + # Only pushes to a saving branch save; a pull request never does. + self.assertIn(SAVE_CACHES + " && ", field(step, "if")) + self.assertIn("steps.cluster-build-cache.outputs.cache-hit != 'true'", field(step, "if")) support = (ROOT / "libs/darkbloom-cluster/Tests/Support/native-metadata.sh").read_text() self.assertIn('task_jobs="${DARKBLOOM_CLUSTER_METADATA_BUILD_JOBS:-4}"', support) self.assertIn('--jobs "$task_jobs"', support) def test_parity_has_no_backend_caches_or_credentials(self): - # Prompt Parity now runs in the provider shards; the only cache that - # job saves directly is the verified MiMo audio codec. + # Prompt Parity now runs in the provider shards; besides .git, the only + # cache that job saves directly is the verified MiMo audio codec. steps = step_blocks(self.jobs["test-provider"]) saves = [step for step in steps if "actions/cache/save@" in step] - self.assertEqual([field(step, "name", indent=6) for step in saves], ["Cache verified MiMo audio codec"]) + self.assertEqual([field(step, "name", indent=6) for step in saves], + ["Save .git for later runs", "Cache verified MiMo audio codec"]) self.assertNotIn("test-provider-parity", WORKFLOW.read_text()) for forbidden in ("coordinator/", "cargo ", "rust-key", "secrets.", "darkbloom-platform"): self.assertNotIn(forbidden, self.jobs["test-provider"]) @@ -741,6 +795,148 @@ def test_offline_workflow_test_runs_in_release_integrity(self): self.assertIn("python3 scripts/test-provider-test-shards.py", self.jobs["release-integrity"]) self.assertIn("python3 scripts/test-native-gpu-ci.py", self.jobs["release-integrity"]) + def test_only_pushes_to_master_and_dev_save_caches(self): + # A pull request's entry is scoped to its merge ref, where nothing else + # restores it, and evicts its base branch's entries from the quota. + self.assertIn("\nenv:\n DARKBLOOM_RELEASE_ENVIRONMENT: prod\n", self.workflow) + self.assertIn(SAVE_POLICY, self.workflow.split("\njobs:\n", 1)[0]) + saves = [(job_id, field(step, "name", indent=6), field(step, "if")) + for job_id, job in self.jobs.items() for step in step_blocks(job) if "actions/cache/save@" in step] + self.assertTrue(saves) + for job_id, name, condition in saves: + with self.subTest(job=job_id, step=name): + self.assertIn(SAVE_CACHES + " && ", condition) + # The composite saves only when its caller passes the same switch. + action = ACTION.read_text() + self.assertIn(" save-caches:\n", action.split("\nruns:\n", 1)[0]) + self.assertIn("\n default: 'false'\nruns:\n", action) + composite = {field(step, "name", indent=4): field(step, "if", indent=6) + for step in step_blocks(action, indent=4) if "actions/cache/save@" in step} + self.assertEqual(set(composite), {"Save lane-specific Swift test build", "Save SwiftPM repositories", + "Save validated source-matched Metal cache"}) + for name, condition in composite.items(): + with self.subTest(step=name): + self.assertIn(SAVE_INPUT + " && ", condition) + calls = [step for job in self.jobs.values() for step in step_blocks(job) if field(step, "uses") == BUILD_ACTION] + self.assertEqual(len(calls), 5) + for call in calls: + self.assertEqual(field(call, "save-caches", indent=10), "${{ env.SAVE_CACHES }}") + + def test_every_checkout_reuses_master_git_and_falls_back_to_a_cold_checkout(self): + checkouts = {job_id: job for job_id, job in self.jobs.items() if "actions/checkout@" in job} + self.assertEqual(set(checkouts), {"release-integrity", "docs", *LANES, "test-provider-summary", + "test-cluster-checks", "test-cluster", "test-cluster-gpu", + "test-cluster-focused"}) + for job_id, job in checkouts.items(): + with self.subTest(job=job_id): + steps = step_blocks(job) + self.assertEqual([field(step, "name", indent=6) for step in steps[:5]], list(GIT_CACHE_STEPS)) + day, restore, validate, checkout, save = steps[:5] + self.assertEqual(run_command(day).splitlines()[:3], ['day=$(date -u +%F)', 'echo "day=$day" >> "$GITHUB_OUTPUT"', + 'echo "month=${day%-*}" >> "$GITHUB_OUTPUT"']) + self.assertIn("command -v zstd >/dev/null && echo zstd || echo gzip", day) + # Full history never seeds, or is restored by, a shallow job. + family = ("git-full-v1" if job_id == "docs" else "git-v1") + "-${{ runner.os }}-" + # One entry per day and branch; restore the newest earlier day. + monthly = family + "${{ steps.git-day.outputs.month }}-" + self.assertEqual(field(restore, "uses"), CACHE_RESTORE) + self.assertEqual(field(restore, "path", indent=10), ".git") + self.assertEqual(field(restore, "key", indent=10), family + "${{ steps.git-day.outputs.day }}") + self.assertIn(f"restore-keys: |\n {monthly}\n {family}\n", restore) + # The validation cannot fail and nothing may continue on error: + # one ordinary checkout follows, and its failure fails the job. + self.assertEqual(run_command(validate), VALIDATE_GIT) + for step in (validate, checkout): + self.assertIsNone(field(step, "if")) + self.assertFalse(any("continue-on-error" in step for step in steps[:5])) + self.assertEqual(uses(checkout), CHECKOUT) + self.assertEqual(sum(uses(step) == CHECKOUT for step in steps), 1) + # Each job keeps its checkout options; a persisted token would + # be saved with .git/config. + sparse = ["sparse-checkout: ${{ env.CHECKOUT_SPARSE }}", "sparse-checkout-cone-mode: false"] + options = {"release-integrity": ["persist-credentials: false", *sparse], + "docs": ["fetch-depth: 0", "filter: blob:none", "persist-credentials: false"] + }.get(job_id, ["submodules: recursive", "persist-credentials: false", *sparse]) + self.assertEqual(checkout_options(checkout), options) + self.assertEqual(field(save, "if"), SAVE_CACHES + " && steps.git-cache.outputs.cache-hit != 'true'") + self.assertEqual(field(save, "uses"), CACHE_SAVE) + self.assertEqual(field(save, "path", indent=10), ".git") + self.assertEqual(field(save, "key", indent=10), "${{ steps.git-cache.outputs.cache-primary-key }}") + + def test_git_validation_keeps_healthy_and_partial_clones_and_discards_damage(self): + with tempfile.TemporaryDirectory() as work: + def git(cwd, *args): + return subprocess.run(["git", "-C", str(cwd), "-c", "user.name=t", "-c", "user.email=t@t", + "-c", "commit.gpgsign=false", "-c", "protocol.file.allow=always", *args], + check=True, capture_output=True, text=True).stdout.strip() + origin = Path(work, "origin") + origin.mkdir() + git(origin, "init", "-q") + for name in ("a", "b"): + (origin / name).write_text(name * 1000) + git(origin, "add", name) + git(origin, "commit", "-q", "-m", name) + git(origin, "config", "uploadpack.allowFilter", "true") + cases = {"healthy": True, "blobless": True, "damaged": False} + for case in cases: + options = ["--filter=blob:none", "--no-checkout"] if case == "blobless" else [] + git(work, "clone", "-q", *options, f"file://{origin}", case) + loose = Path(work, "damaged", ".git", "objects") + tree = git(Path(work, "damaged"), "rev-parse", "HEAD^{tree}") + git(Path(work, "damaged"), "repack", "-q", "-a", "-d") + for pack in (loose / "pack").glob("*.pack"): + pack.unlink() + Path(work, "empty").mkdir() + for case, kept in {**cases, "empty": False}.items(): + with self.subTest(case=case): + result = subprocess.run(["bash", "-e", "-o", "pipefail", "-c", VALIDATE_GIT], + cwd=Path(work, case), capture_output=True, text=True) + self.assertEqual(result.returncode, 0, result.stderr) + self.assertEqual(Path(work, case, ".git").is_dir(), kept, result.stdout) + self.assertEqual("::warning" in result.stdout, case == "damaged") + self.assertTrue(tree) + + def test_sparse_checkouts_skip_only_evidence_tarballs_and_landing_media(self): + env = self.workflow.split("\njobs:\n", 1)[0] + self.assertIn(" CHECKOUT_SPARSE: |\n" + "".join(f" {pattern}\n" for pattern in SPARSE_PATTERNS), env) + self.assertEqual(self.workflow.count("sparse-checkout: ${{ env.CHECKOUT_SPARSE }}"), 8) + docs_impact = (ROOT / ".github/workflows/docs-impact.yml").read_text() + self.assertIn(" filter: blob:none\n sparse-checkout: |\n" + + "".join(f" {pattern}\n" for pattern in SPARSE_PATTERNS) + + " sparse-checkout-cone-mode: false\n", docs_impact) + # Real git decides what the patterns keep: every file a job may read, + # including the report a provider test hashes and the evidence harness + # manifest the provider CI cache hashes, but no evidence tarball or media. + kept = ["Makefile", "docs/reports/report.md", "docs/reports/archive.tar.gz", + "docs/reports/evidence/run/cpu-harness/Package.swift", "docs/reports/evidence/notes.json", + "provider-swift/Tests/Fixtures/clip.mp4", "fixtures/data.gz", "landing/src/page.tsx", + "landing/README.md", "landing/public/favicon.svg", + "docs/reports/2026-10-31-public-cluster-models.md"] + skipped = ["docs/reports/evidence/run/packets.jsonl.gz", "docs/reports/evidence/payloads.tar.gz", + "landing/public/media/demo.mp4", "landing/public/media/poster.png"] + with tempfile.TemporaryDirectory() as work: + def git(*args): + subprocess.run(["git", "-C", work, "-c", "user.name=t", "-c", "user.email=t@t", + "-c", "commit.gpgsign=false", *args], check=True, capture_output=True) + git("init", "-q") + for path in kept + skipped: + (Path(work) / path).parent.mkdir(parents=True, exist_ok=True) + (Path(work) / path).write_text(path) + git("add", "-A") + git("commit", "-q", "-m", "tree") + git("sparse-checkout", "set", "--no-cone", *SPARSE_PATTERNS) + self.assertEqual([path for path in kept if not (Path(work) / path).is_file()], []) + self.assertEqual([path for path in skipped if (Path(work) / path).exists()], []) + self.assertTrue((ROOT / "docs/reports/2026-10-31-public-cluster-models.md").is_file()) + # scripts/provider-ci-cache.py hashes every tracked Package.swift, + # Package.resolved and .gitmodules; the patterns must keep each one. + tracked = subprocess.run(["git", "-C", str(ROOT), "ls-files", "-z"], check=True, + capture_output=True, text=True).stdout.split("\0") + manifests = [path for path in tracked if Path(path).name in {"Package.swift", "Package.resolved", ".gitmodules"}] + self.assertIn("docs/reports/evidence/ssd-read-coordination-runtime-2026-09-06/cpu-harness/Package.swift", manifests) + self.assertEqual([path for path in manifests + if path.endswith(".gz") or path.startswith("landing/public/media/")], []) + def test_composite_action_cannot_bypass_build_and_metallib_on_cache_hits(self): action = ACTION.read_text() self.assertIn("using: composite", action) @@ -785,14 +981,35 @@ def test_composite_cache_keys_retain_swift_and_metal_without_backend_work(self): self.assertEqual(rust_steps, []) self.assertNotIn("rust-key:", action) self.assertNotIn("rust-cache-hit:", action) - self.assertEqual(sum("actions/cache/save@" in step for step in steps), 2) - # Pushes save the Swift build. A pull request saves it only when it - # restored nothing, so its later pushes do not evict the base entry. - swift_save = next(step for step in steps if field(step, "name", indent=4) == "Save lane-specific Swift test build") - self.assertEqual(field(swift_save, "if", indent=6), - "${{ !cancelled() && steps.timestamps.outcome == 'success' && " - "steps.swift-cache.outputs.cache-hit != 'true' && (github.event_name != 'pull_request' " - "|| steps.swift-cache.outputs.cache-matched-key == '') }}") + self.assertEqual(sum("actions/cache/save@" in step for step in steps), 3) + + def test_composite_restores_swiftpm_repositories_per_lane_and_runner_layout(self): + steps = step_blocks(ACTION.read_text(), indent=4) + by_id = {field(step, "id", indent=6): step for step in steps if field(step, "id", indent=6)} + names = [field(step, "name", indent=4) for step in steps] + restore = by_id["spm-repos"] + save = next(step for step in steps if field(step, "name", indent=4) == "Save SwiftPM repositories") + # actions/cache archives this home path relative to the workspace, so + # the key binds the runner layout as well as the lane and the pins. + self.assertIn('echo "home-layout=$(printf \'%s\\n\' "$HOME" "$GITHUB_WORKSPACE" | shasum -a 256', + by_id["keys"]) + self.assertIn("command -v zstd >/dev/null && echo zstd || echo gzip", by_id["keys"]) + prefix = "spm-repos-v1-${{ runner.os }}-${{ steps.keys.outputs.home-layout }}-${{ inputs.lane }}-" + for step in (restore, save): + self.assertEqual(field(step, "path", indent=8), "~/Library/Caches/org.swift.swiftpm/repositories") + self.assertEqual(field(restore, "uses", indent=6), CACHE_RESTORE) + self.assertEqual(field(restore, "key", indent=8), + prefix + "${{ hashFiles('**/Package.resolved', '!**/.build/**') }}") + self.assertEqual(field(restore, "restore-keys", indent=8), prefix) + self.assertLess(steps.index(restore), steps.index(by_id["provider-build"])) + self.assertLess(steps.index(restore), steps.index(by_id["sdk-build"])) + self.assertLess(steps.index(restore), steps.index(by_id["cluster-build"])) + self.assertEqual(field(save, "uses", indent=6), CACHE_SAVE) + self.assertEqual(field(save, "key", indent=8), "${{ steps.spm-repos.outputs.cache-primary-key }}") + self.assertEqual(field(save, "if", indent=6), + "${{ !cancelled() && " + SAVE_INPUT + " && steps.timestamps.outcome == 'success' " + "&& steps.spm-repos.outputs.cache-hit != 'true' }}") + self.assertGreater(names.index("Save SwiftPM repositories"), names.index("Record timestamps for successfully built sources")) if __name__ == "__main__": diff --git a/scripts/test-provider-release-toolchain.py b/scripts/test-provider-release-toolchain.py index 4dc52be897..6af461df80 100644 --- a/scripts/test-provider-release-toolchain.py +++ b/scripts/test-provider-release-toolchain.py @@ -2,6 +2,7 @@ """Exercise toolchain selection/argument propagation without installing software.""" import json import os +import shutil from pathlib import Path import subprocess import tempfile @@ -61,5 +62,59 @@ def test_old_swift_cannot_select_sdk_27(self): self.assertFalse((self.root / "env").exists()) + +class ReleaseCMakeTests(unittest.TestCase): + """The image's tool-cache CMake is used when complete and exact; otherwise download.""" + + def setUp(self): + self.temp = tempfile.TemporaryDirectory(prefix="release cmake ") + self.addCleanup(self.temp.cleanup) + self.root = Path(self.temp.name) + stubs = self.root / "bin" + stubs.mkdir() + # An Apple Silicon Mac whose network refuses, recording each download. + (stubs / "uname").write_text('#!/bin/sh\ncase "$1" in -s) echo Darwin ;; -m) echo arm64 ;; esac\n') + (stubs / "curl").write_text(f'#!/bin/sh\necho "$@" >> "{self.root}/curl.log"\nexit 7\n') + for stub in stubs.iterdir(): + stub.chmod(0o755) + self.cache = self.root / "toolcache" + self.env = {**os.environ, "PATH": f"{stubs}:{os.environ['PATH']}", "RUNNER_TOOL_CACHE": str(self.cache), + "RUNNER_TEMP": str(self.root), "GITHUB_PATH": str(self.root / "path")} + + def provision(self, version="3.31.12", complete=True): + cmake = self.cache / "cmake/3.31.12/universal/CMake.app/Contents/bin/cmake" + cmake.parent.mkdir(parents=True) + cmake.write_text(f"#!/bin/sh\necho 'cmake version {version}'\n") + cmake.chmod(0o755) + if complete: + (self.cache / "cmake/3.31.12/universal.complete").touch() + return cmake.parent + + def install(self): + return subprocess.run([str(ROOT / "scripts/install-release-cmake.sh")], env=self.env, + text=True, capture_output=True) + + def test_uses_the_complete_exact_tool_cache_copy_without_downloading(self): + cached = self.provision() + result = self.install() + self.assertEqual(result.returncode, 0, result.stderr) + self.assertEqual((self.root / "path").read_text(), f"{cached}\n") + self.assertFalse((self.root / "curl.log").exists()) + + def test_downloads_when_the_tool_cache_copy_is_absent_incomplete_or_another_version(self): + for case in ("absent", "incomplete", "another version"): + with self.subTest(case=case): + shutil.rmtree(self.cache, ignore_errors=True) + for leftover in ("curl.log", "path"): + (self.root / leftover).unlink(missing_ok=True) + if case != "absent": + self.provision(version="3.30.0" if case == "another version" else "3.31.12", + complete=case != "incomplete") + result = self.install() + # The refused download fails the step; nothing reaches PATH. + self.assertEqual(result.returncode, 7, result.stderr) + self.assertIn("/v3.31.12/cmake-3.31.12-macos-universal.tar.gz", (self.root / "curl.log").read_text()) + self.assertFalse((self.root / "path").exists()) + if __name__ == "__main__": unittest.main()