Skip to content

provider: owner pause for me first (local-first L1, stacked on #1870) - #1877

Merged
jonathan308 merged 11 commits into
devfrom
local-first/l1-owner-pause
Nov 7, 2026
Merged

jonathan308 merged 11 commits into
devfrom
local-first/l1-owner-pause

Conversation

@jonathan308

@jonathan308 jonathan308 commented Nov 6, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Adds the owner pause, "me first", to the provider (PR L1 of the local-first stack for provider 0.10.11). While the owner uses this Mac through its local API, the provider takes no Darkbloom work. It takes Darkbloom work again once none of the owner's requests has run for the idle time (2 minutes by default). Nothing turns it on yet: L2 hooks the local API's model acquisition and release into noteLocalUse.

Stacked on #1870: the base is now #1870's branch local-first/l0-config, so the diff shows only L1. It includes #1870's newest head f7c398b9f2 through the signed, non-force merge 0f97f1d946 (earlier, 2a2987cd5c through 373f5adf04).

Draft. Do not merge: no dev merges until the owner says so, because a dev merge publishes a DevNet build.

Linked issue

None. This is part of the local-first goal.

Test plan

All runs are CPU-only, on Xcode 27.2 with DARKBLOOM_RELEASE_ENVIRONMENT=prod, under nice -n 19. They ran under sandbox-exec with a profile that denies ~/.darkbloom* and the GPU's user client (AGXDeviceUserClient). Under it Metal sees no device, so any test path that opened the GPU would fail. One did, and was rewritten. DARKBLOOM_STATE_FILE, DARKBLOOM_LOADED_MODELS_FILE and DARKBLOOM_VERIFIED_WEIGHTS_FILE pointed at a temporary folder.

  • Red, at 550ec294dd (tests plus an unwired skeleton): swift test --skip-build --no-parallel --filter 'MeFirstPolicyTests|ProviderBusyWireTests|OwnerPauseLoopTests|OwnerPauseWireTests'.

    • The selection has 26 tests, 22 of them new. 19 fail, with 67 issues.
    • The 7 that pass are the 4 existing busy-field tests and 3 new guards: me first off, the owner codec round trip, and an unknown reason still decoding.
    • Correction: the red commit's message says "22 of 26 fail"; the log shows 19.
  • Green, at af7671a17e: the same filter passes 26/26 in three serial runs. Two parallel runs, with 4 neighbouring suites added, pass 42/42.

  • Regressions that need no GPU, 96 tests:

    • the CoordinatorClient registration and heartbeat tests;
    • UpdateDrainAwarenessTests, CoordinatorLifecycleBarrierTests, PlannedProviderDisconnectTests;
    • the add-on hold drain-ownership, store, IPC and peer suites, and the Autopilot busy-reason mapping tests;
    • DaemonStateServedCountTests, DesiredModelsForPostureTests, ServingReadinessTests;
    • CoordinatorModelSwitchTests, AutopilotModelSwitchOwnershipTests, the cluster member refusal test;
    • StatusCommandRunTests, AddonCommandTests.
  • Suites that need the GPU, left to CI: AddonHoldLoopTests, AddonHoldServeLoopTests, ProviderModelSwitchTests, ProviderLifecycleTests, and the rest of ClusterMemberLoopTests and AutopilotBusyReasonTests. They reach MLX's Metal allocator through a capacity rebuild, an unload or a request's terminal profile. Each stopped at the sandbox's GPU denial before any assertion failed.

  • Wire check against the deployed coordinator's code, the V0 export of 90ee29fc0d. This build's paused register and heartbeat, and its open heartbeat, were decoded by 90ee's protocol.DecodeProviderMessage and applied to its addonhold.State:

    • paused: draining with owner, which is not an add-on hold, so the Mac keeps its uptime;
    • open: idle with no busy fields.

    SPIKE-V0's runs showed what the coordinator then does: 8 of 8 public requests rerouted, and one typed refusal on a race. No server or port was used for this check.

  • make changelog-check, scripts/docs-check.sh --all and scripts/docs-impact-check.py --base 00f5afa24d pass.

  • The independent review's nits (approve with nits), on the same CPU-only setup:

    • Red, at d675ba9ee5: 2 of 28 fail. The pause's first request wrote the daemon state file, and a registration after the idle time sent 3 heartbeats instead of 2. The new me-first-off guard passes.
    • Green, at 1de0e9f6fb: 28/28 in four serial runs, and 44/44 in five parallel runs beside 4 neighbouring suites.
    • Mutants: the review's M10 (me first off counts as paused) and M6 (no resume on reconnect) are now killed, with 6 and 4 issues.
    • Regressions: the review's 13 selections have 0 failures. The same six stop at the GPU denial.
    • Cost, re-measured with the review's probe (3 × 380 rounds, not committed): the first request of a pause costs the loop actor p50 3.6 µs, p99 12 µs, max 17 µs. It was 0.52 ms, 0.98 ms and 12 ms. Any other start or end while paused costs about 0.1 µs.
    • docs-check.sh, docs-impact-check.py --base f7c398b9f2 and make changelog-check pass.
  • Dev-identity build and test run, and full CI.

Components touched

  • provider-swift (Swift CLI)
  • native runtime / MLX
  • landing (Next.js)
  • enclave (Swift)
  • CI / provider release
  • docs

Protocol / interface changes

For the platform owner: providers now send busy_reason: "owner" beside status: draining while their owner uses the Mac through its local API. The deployed coordinator (90ee29fc0d) ignores the unknown reason: it treats the Mac as a plain drain, so it skips it for routing and keeps its uptime and rewards (coordinator/registry/heartbeat.go:195-224; the add-on hold keys on addon only). No deploy is needed. A later coordinator change could show it, for example in the console's routing reason, which reads "draining" today.

  • No protocol/interface changes
  • Yes, additive.
    • busy_reason gains owner, sent only beside status: draining and never with busy_addon. Deployed coordinators key the add-on hold on addon only, so they treat owner as a plain drain. Older providers decode an unknown reason as absent.
    • daemon-state.json gains an optional me_first object.
    • No release, config or CLI change.

Documentation impact

  • Canonical documentation updated:
    • new docs/architecture/owner-pause.md: mechanism, API, cost, invariants (including that the pause doesn't survive a restart) and known gaps, linked from the architecture index;
    • docs/reference/protocol-messages.md: the busy fields;
    • docs/architecture/addon-hold.md: invariant 12, precedence;
    • docs/architecture/model-autopilot.md: the busy reason.
  • No documentation needed. Reason:

Changelog

  • Added changelog.d/local-first-owner-pause.md and ran make changelog-check.
  • No user-visible change, or an explicitly authorized release/history change.

Notes for reviewers

API for L2 and L5b

All on ProviderLoop, actor-isolated (provider-swift/Sources/ProviderCore/ProviderLoop+MeFirst.swift):

Call When
enableMeFirst(idle: Duration) Once at serve start, where me first applies: LocalSettings.meFirstEnabled(in:) and a coordinator. Pass .seconds(60 * resolvedMeFirstIdleMinutes). The first call wins.
noteLocalUse(.start) Right after a local request takes its model reservation. For L2: after localReservations.reserve in acquireModelForLocal. For L5b: in the leader's local admission.
noteLocalUse(.end) When that reservation is released. For L2: releaseLocalReservation. Exactly one .end per .start; an unmatched one is ignored.
ownerPausesPublic, meFirstSnapshot Read-only: the flag, and the status snapshot (DaemonState.meFirst).
resumeIfOwnerIdle() Called by the timer. A fresh registration makes the same check before its first heartbeat (reassertOwnerPauseAfterReconnect). Tests drive it with a fake clock (meFirstNowMs).

For tests on the fake clock (L2, L5b): once a .end has armed the real resume timer, move the clock and resume with resumeIfOwnerIdleForTesting(advancing:by:) (in OwnerPauseLoopTests.swift), which does both in one actor turn. A separate clock.advance then resumeIfOwnerIdle() lets the timer end the pause in between, and the call then returns false.

How it's kept cheap (owner criterion 8)

  • No polling. MeFirstPolicy is a pure state machine: a counter and two timestamps on a clock the caller passes in.
  • Per local request: an O(1) update. That is no I/O, no heartbeat and no task. Only the first start sends one event heartbeat. It writes no file: the loop's regular write, every 2 s while serving, brings the pause to status, as it brings the request counts. Measured: p50 3.6 µs, p99 12 µs for the first request of a pause, and about 0.1 µs for any other edge.
  • One timer. It is armed when the owner's idle time starts counting (the end of the last request) and sleeps to the deadline. A request that starts meanwhile only moves the deadline, so the timer wakes at most once per idle time while the owner keeps working. It is cancelled when the pause ends, and at shutdown.
  • Heartbeats only on transitions, on top of the usual baseline:
    • one at pause entry and one at resume;
    • after a reconnect, the existing .connected event heartbeat already carries the status, so nothing extra is sent. A pause whose idle time passed while the connection was down ends just before that heartbeat, which then says idle or serving.
  • Hot path. Coordinator dispatch adds one Bool check (rejectIfDraining). The heartbeat and quote paths read one more Bool under the lock they already take. Nothing is added per token, to lanes or to GPU use.
  • No extra processes.
  • With me first off, noteLocalUse returns at once, and no timer or task ever exists.
  • Tests that pin this:
    • withMeFirstOffNothingPausesAndNoTimerOrTaskIsLeft;
    • theResumeTimerRunsOnlyWhileIdleTimeCountsAndEndsThePauseByItself: no timer while open or while a request runs, and none left after the resume;
    • the wire tests: one heartbeat at entry, none across 50 more requests, one at resume, nothing after; and exactly one, routable, after a registration that ends the pause.

Decisions to check

  • A separate flag, ProviderState.ownerPausesPublic, not servingDrain. servingDrain also closes local admission. throwIfRefusingNewLocalWork is untouched, and refusingNewWork stays apart: its other readers (revision and MTP gates) do not see the pause.
  • Refused while paused:
    • coordinator load_model and prefetch_model, with the existing drain failures. The prefetch_model event handling moved out of ProviderLoop+Serve.swift into handleCoordinatorPrefetch so it can be tested. The behaviour is the same apart from the owner term.
    • Autopilot commands, which report draining.
  • Not refused: desired-build download retries that were scheduled before the pause. Refusing them would drop their retry budget, which would be a new stall.
  • Replays of desired_models. The update, switch and add-on replays skip while the pause is on. The pause's own end replays them, unless a drain or hold is still on. The add-on release and the pause's end share one guard, replayDesiredModels(deferred:).
  • Busy fields. publishBusy() is the one writer, with an add-on hold outranking the owner pause. It replaces publishAddonBusy() and the state.busy = nil in leaveAddonHold.
  • Wall clock, as the add-on leases use. A clock that goes back re-anchors the countdown, and one sleep never exceeds the idle time. After a long disconnect, for example a sleeping Mac whose timer runs late, the fresh registration checks the idle time before the connection's first heartbeat.
  • Test seam capacityRebuildForTesting, nil in production, at the top of updateAggregateCapacity. The add-on release path rebuilds capacity, which reads MLX's Metal allocator. The seam keeps that test off the GPU.
  • coordinatorRequestsInFlight is factored out of lifecycleRemaining, with the same result. It feeds darkbloom_requests_finishing.

Known edges and follow-ups

  • A live model switch during a long pause. After a switch the coordinator reopens routing only on an idle or serving heartbeat, and the pause's heartbeats say draining. If the pause outlasts the provider's 30 s readiness wait, darkbloom switch exits with an error: "Model selection applied locally, but coordinator routing readiness is unconfirmed". The switch itself completes: the new selection serves locally, and the heartbeat that ends the pause reopens routing to it (90ee providerdrain.Authority.AppliedCapacity and Resume). Nothing needs redoing. A follow-up for L4 could print that instead when status says paused.
  • Model revision activations and MTP idle upgrades are unchanged. They wait for an idle model, but can still start in a gap between the owner's requests.
  • On 90ee (C1 dropped), the owner's own coordinator self requests to a paused Mac wait, and prefer requests go to the network (SPIKE-V0 F4).

All three are under "Known gaps" in docs/architecture/owner-pause.md, and the first also at the wait in resumeAfterModelSwitch.

Limitations

  • Only the prod identity was built and tested locally.
  • The independent review (review-L1.md) approved with nits. Nits 1 to 6 are addressed in d675ba9ee5 and 1de0e9f6fb, or in this body.

Before And After

flowchart LR
  subgraph Before
    L1[local request] --> A1[acquireModelForLocal] --> E1[shared engine]
    C1[coordinator dispatch] --> G1{rejectIfDraining: drain, shutdown, reconnect} -->|open| E1
    S1[refusingNewWork] --> H1[heartbeat: draining or idle/serving]
    B1[add-on hold] -->|writes state.busy directly| H1
  end
  subgraph After
    L2[local request] --> A2[acquireModelForLocal, unchanged] --> E2[shared engine]
    A2 -. L2 wires .-> N2["noteLocalUse(.start/.end)"] --> P2[MeFirstPolicy, pure]
    P2 -->|paused / resumed| O2[ownerPausesPublic]
    O2 --> H2["heartbeat: draining + busy_reason owner"]
    O2 --> G2{rejectIfDraining} -->|paused| R2[capacity / 503 / draining]
    O2 --> Q2[quotes: slot_state; load/prefetch: drain failures; desired_models deferred]
    BH[add-on hold] --> PB[publishBusy: addon > owner] --> H2
  end
Loading
sequenceDiagram
  participant Owner as Owner's tool
  participant Loop as ProviderLoop
  participant Coord as Coordinator
  Owner->>Loop: local request (noteLocalUse .start)
  Loop->>Coord: event heartbeat: draining, busy_reason owner
  Coord--xLoop: racing dispatch
  Loop->>Coord: capacity / 503 / draining (one refusal, failover)
  Owner->>Loop: request ends (noteLocalUse .end): timer armed
  Note over Loop: idle time (2 min) with no local request
  Loop->>Coord: event heartbeat: idle or serving, no busy fields
  Loop->>Loop: replay deferred desired_models
Loading

Refactor Pass

Done by a separate refactor subagent, 2026-11-06 23:20Z to 2026-11-07 00:15Z (date -u). Head af7671a17e → 373f5adf04 (the merge of #1870's 2a2987cd5c) → c82ac10088: one signed, behaviour-preserving commit, pushed as a fast-forward. No public name or signature changed: enableMeFirst(idle:), noteLocalUse(.start/.end), ownerPausesPublic, meFirstSnapshot, resumeIfOwnerIdle(), MeFirstPolicy, ProviderBusyReason.owner and the MeFirstSnapshot fields are as they were.

  • One desired_models replay. The add-on release and the pause's end repeated the same guard and replay, in a different order. Both now call replayDesiredModels(deferred:), beside the deferral in ProviderLoop+Prefetch.swift. Same conditions, same log lines.
  • Invariants stated at the top of ProviderLoop+MeFirst.swift: the pause cancels nothing; an add-on hold outranks it; desired_models wait for whichever ends last; heartbeats only on transitions; at most one timer, and none while me first is off. owner-pause.md gains invariant 5, the pause cancels nothing.
  • Control flow: reassertOwnerPauseAfterReconnect no longer ends the pause inside a guard condition.
  • The switch gap is documented where it bites (see "Known edges").
  • Tests, none weakened:
    • A race in the fake-clock tests, fixed. They advanced the clock, then called resumeIfOwnerIdle() in a second actor turn. The real resume timer, armed by the last .end, could end the pause in between, and the call then returned false. Seen once in 12 parallel runs. A loaded probe (not committed) lost 7 of 6,000 rounds that way, and 0 of 6,000 with the fix. The test-only resumeIfOwnerIdleForTesting(advancing:by:) does both in one actor turn. ownerGoesIdle and the four other advance-then-resume steps use it, with the same assertions.
    • A new test for the other order of the precedence, aPauseEndingUnderAnAddOnHoldLeavesTheBusyFieldsAndDesiredModelsToIt: the hold keeps the busy fields and desired_models, and its release replays them. It passes on 373f5adf04 too, and covers the add-on release's replay without the GPU.
    • The unused helper OwnerPauseOutbound.completed(_:) is gone.

Evidence (prod identity, CPU-only, the author's sandbox without the GPU or ~/.darkbloom*, Xcode 27.2, nice -n 19):

  • The L1 selection: 26/26 on 373f5adf04; 27/27 on the final tree in 5 serial runs; 20 parallel runs with 4 more suites, 51/51 each.
  • Mutants of the shared guard: without the drain and hold terms only the new test fails; without the pause term only anAddOnHoldOutranksThePauseAndItsReleaseKeepsIt fails.
  • 13 regression selections: identical per-test outcomes before and after. That is 101 passing tests, and the same stops at the GPU denial in AutopilotBusyReasonTests, OperatorModelFilterTests, ModelRevisionPublicationTests, ModelPrefetchCoordinatorTests, AddonHoldLoopTests and AddonHoldServeLoopTests. Those suites are CI's.
  • CI passed in full on 373f5adf04 and on c82ac10088: 6,834 distinct passing tests on the new head, which is the merge's 6,833 plus the new test, and 0 failed. The add-on hold suites passed, including releaseReopensAdmissionAndReplaysDeferredDesiredModels. The two Vercel failures were already there at af7671a17e.
  • scripts/docs-check.sh, scripts/docs-impact-check.py (against 2a2987cd5c and against dev's merge base) and make changelog-check pass.
  • The red count in this body was already right: 19 of 26 fail, with 67 issues, as the red log shows. The red commit's message keeps its "22 of 26", corrected above.

Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

jonathan308 and others added 5 commits November 6, 2026 14:12
Tests first for the local-first settings section, with a skeleton that
compiles but is not wired: [local] is never decoded or validated and the
writer changes nothing.

- an absent [local] keeps today's mode, port, bind and route;
- every key round-trips with the documented spelling;
- invalid values are refused with one plain line naming the key;
- the [local] edit keeps unknown keys and every other value, is a no-op
  when the file already says it, and refuses before writing.

Red (prod, CPU-only, sandboxed): 11 of 15 core tests and both CLI tests
fail (49 issues).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
LocalSettings {mode, meFirst, meFirstIdleMinutes, route, port, bind} in
provider.toml's new [local] section:

- Parse: every key optional; ProviderConfig.local is nil while the
  section is absent, so other writers never add it.
- Validate: enums, me_first_idle_minutes 1-120, port 1-65535, bind as
  `cluster local` takes it. A refusal is one plain line naming the key,
  what it takes and what the file has (LocalSettingsError), never a
  decoder dump. Integers are narrowed here: TOMLKit traps on its own.
- Defaults when absent: the launch flags decide the mode as today; port is
  the build's defaultLocalPort, bind 127.0.0.1, route this-mac (my-macs
  once an account key is saved), me first on only for mode both, and the
  owner's 2-minute idle before Darkbloom traffic resumes.
- Write: ConfigManager.updateLocal / setLocalSettings edit the raw TOML
  table under the config lock, like the cluster pointer and model
  selection writers, so unknown keys keep their values. Shaped like
  setIdleUnloadMinutes: refuse before writing, no-op when the file holds
  the change, pin explicit defaults.

Green (prod, CPU-only, sandboxed): LocalSettingsTests 15/15,
LocalSettingsMutationTests 2/2; config regression suites 128 + 33 pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… per test case

Same behaviour. The public API is unchanged: LocalSettings, its fields and
enums, the resolvers, validate(), LocalSettingsError, ConfigManager.updateLocal
and setLocalSettings.

- ConfigManager.updatingLocal says why the section edit is safe:
  - `local` is a section or absent, because parseValidating refused anything
    else and the encoder writes one;
  - an existing section is edited in place, because TOMLKit hands out the
    table's own node;
  - a new section always gets a key, because `after` differs from an empty
    `before`.
- LocalSettings.CodingKeys drops CaseIterable. Nothing iterates the keys, and
  [local] takes unknown keys on purpose. Elsewhere in Config/, CaseIterable
  CodingKeys feed key checks (exact fields, retired keys).
- LocalSettingsTests.validateMatchesDecoding calls validate() once per case
  and checks the words on the refusal that #expect(throws:) returns. Before,
  a second call in a do/catch checked the words only when something was
  thrown. A mutant validate() (no port check; bind found unquoted) fails the
  test on the same two cases, before and after.

Checks, all CPU only (empty kernel libraries in the test build, no command
buffer submitted), on Xcode 27.2 at nice 19 with ~/.darkbloom* denied:
- LocalSettingsTests 15/15 and LocalSettingsMutationTests 2/2: dev identity
  before and after, and prod identity after.
- The PR's config regression filter: prod 128 + 33 pass. Dev 128 + 33, with
  the same 3 issues before and after, all in ClusterPrefixCacheSettingsTests,
  which hard-codes prod's cache paths. They are pre-existing, and CI tests
  prod only.
- docs-check, docs-impact-check --base origin/dev and changelog check pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Tests first for "me first": while the owner uses this Mac through its
local API, Darkbloom work pauses and resumes after the owner's idle time.
The skeleton compiles but is not wired: the policy never pauses,
noteLocalUse does nothing, and only the busy reason `owner` exists.

- the policy's edges on a fake clock: idle 1 min at 59.9 s / 60 s, the
  2-minute default at 119.9 s / 120 s, no resume while a local request
  runs, the countdown from the end of the last request;
- heartbeat JSON while paused (draining, busy_reason owner) and after
  resume (idle or serving, no busy fields);
- a racing coordinator request gets one capacity/503/draining refusal;
  load_model and prefetch_model get the drain failures;
- a local acquire during the pause succeeds; Darkbloom work accepted
  before it finishes and is never cancelled;
- quotes refuse while paused; desired_models wait, then replay;
- an add-on hold outranks the pause and its release keeps it;
- event heartbeats only on transitions, and a fresh registration keeps
  the pause (loopback mock coordinator);
- with me first off, nothing pauses and no timer or task exists;
- an unknown busy_reason still decodes.

A test seam skips the capacity rebuild (it reads MLX's Metal
allocator), so these loop tests never open the GPU.

Red (prod, CPU-only, sandbox without the GPU): 22 of 26 tests fail
(67 issues). The 4 that pass are the me-first-off guard and the busy
codec guards.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
While the owner uses this Mac through its local API, the provider takes
no Darkbloom work, and takes it again once none of the owner's requests
has run for the idle time (2 minutes by default). Nothing enables it
yet: the local API's hooks come next (L2).

- MeFirstPolicy: a pure state machine on a caller's clock.
- ProviderState.ownerPausesPublic, apart from refusingNewWork: the
  heartbeat says draining with busy_reason owner, quotes refuse, and
  local admission is untouched.
- rejectIfDraining gives a racing dispatch the typed
  capacity/503/draining refusal; load_model and prefetch_model get the
  drain failures; Autopilot reports draining.
- desired_models wait and are replayed when the pause ends; a drain,
  switch or hold ending mid-pause leaves them to it.
- One busy writer (publishBusy): an add-on hold outranks the pause, and
  its release hands the busy fields back.
- Event heartbeats on entry and resume; a fresh registration carries the
  owner's busy fields and its first heartbeat repeats draining.
- DaemonState.meFirst for status.
- API: enableMeFirst(idle:), noteLocalUse(.start/.end),
  resumeIfOwnerIdle(), meFirstSnapshot.

Cost: event-driven. A local request's start and end are O(1) updates;
heartbeats only on transitions; one timer, armed when the idle time
starts counting and gone when the pause ends; nothing when me first is
off.

Green (prod, CPU-only, sandbox without the GPU): 26/26, three serial
runs and two parallel ones. Regressions: 96 tests in 9 GPU-free
selections pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
d-inference Error Error Nov 7, 2026 1:38am UTC
d-inference-console-ui-dev Error Error Nov 7, 2026 1:38am UTC
d-inference-landing Ready Ready Preview Nov 7, 2026 1:38am UTC
darkbloom-status Ready Ready Preview Nov 7, 2026 1:38am UTC
eigen-homepages-darkbloom Ready Ready Preview Nov 7, 2026 1:38am UTC

Request Review

#1870's head moved 00f5afa -> 2a2987c: a comment on the [local]
section edit in ConfigManager.updatingLocal, the internal
LocalSettings.CodingKeys without CaseIterable, and one validate() per
case in LocalSettingsTests.validateMatchesDecoding. No public name or
signature changed and no owner-pause file is touched, so the merge is
clean.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jonathan308 and others added 2 commits November 6, 2026 15:32
From the independent review of #1870; the public API is unchanged.

- Bug: clearing the last key of a file that holds only [local] threw a
  false "did not serialize" error, because the round-trip guard refused
  an empty text. An empty table now serializes to an empty file, which
  loads as defaults. Red first: clearingTheOnlySection failed with that
  error; it now passes.
- Route.myMacsFirst's comment: the coordinator with
  X-Darkbloom-Route: self first, then prefer, as the router does.
- Docs and comments say exactly what the writer keeps: every value,
  unknown keys included. Like every config writer, it drops comments and
  re-sorts sections and keys. Other writers drop unknown keys.

Tests (prod, CPU-only, sandboxed): LocalSettingsTests 16/16,
LocalSettingsMutationTests 2/2, config/idle/beta/model-switch suites
130 + 35 pass; changelog, docs and docs-impact checks pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… switch gap documented

Behaviour-preserving. No public name or signature changed:
enableMeFirst(idle:), noteLocalUse(.start/.end), ownerPausesPublic,
meFirstSnapshot, resumeIfOwnerIdle(), MeFirstPolicy,
ProviderBusyReason.owner and the MeFirstSnapshot fields are as they were.

- The add-on hold's release and the owner pause's end repeated the same
  guard and replay of the deferred desired_models, in a different order.
  Both now call replayDesiredModels(deferred:), beside the deferral in
  ProviderLoop+Prefetch, so whichever of a drain, a hold and the pause
  ends last replays them. Same conditions, same log lines.
- ProviderLoop+MeFirst states its invariants: the pause cancels nothing;
  an add-on hold outranks it; desired_models wait for whichever ends
  last; heartbeats only on transitions; at most one timer, and none while
  me first is off. reassertOwnerPauseAfterReconnect no longer ends the
  pause inside a guard condition.
- The known gap is documented where it bites: a model switch during the
  pause waits up to 30 s for an idle or serving heartbeat that the pause
  never sends, so switch reports routing readiness unconfirmed; the
  selection holds, and the heartbeat that ends the pause reopens routing
  (a comment at the wait in resumeAfterModelSwitch; owner-pause.md gains
  "Known gaps", with the PR's two other known edges, and invariant 5).
- Tests, none weakened:
  - A race in the fake-clock tests: they advanced the clock, then called
    resumeIfOwnerIdle() in a second actor turn, and the real resume timer
    armed by the last .end could end the pause in between, so the call
    returned false. Seen once in 12 parallel runs; a loaded probe lost
    7 of 6000 rounds that way, and 0 of 6000 with the fix. The test-only
    resumeIfOwnerIdleForTesting(advancing:by:) does both in one actor
    turn; ownerGoesIdle and the four other advance-then-resume steps use
    it, with the same assertions.
  - A new test, the other order of the precedence: a pause that ends
    under an add-on hold leaves the busy fields and desired_models to the
    hold, whose release replays them. It passes on 373f5ad too, and it
    covers the hold's replay without the GPU.
  - The unused helper OwnerPauseOutbound.completed(_:) is gone.

Tests (prod, CPU-only, sandbox without the GPU): the L1 selection 26/26
before, 27/27 after (serial, repeated; 20 parallel runs with 4 more
suites, 51/51); each term of the shared replay guard is pinned by a
mutant; 13 regression selections give the same per-test outcomes before
and after. docs-check, docs-impact and changelog-check pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jonathan308 added a commit that referenced this pull request Nov 7, 2026
#1877 moved 373f5ad -> c82ac10, its refactor pass: one
desired_models replay, invariants and known gaps in owner-pause.md, and
resumeIfOwnerIdleForTesting(advancing:by:), which advances the test
clock and resumes in one actor turn. No name L2 uses changed. The
owner-pause.md edits merge with L2's without conflict.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jonathan308 added a commit that referenced this pull request Nov 7, 2026
After #1877's refactor pass:

- LocalUseOwnerPauseTests ask for the resume with L1's
  resumeIfOwnerIdleForTesting(advancing:by:), which moves the test clock
  and resumes in one actor turn, so the real resume timer cannot end
  the pause first. The tests assert that the call itself ends the pause
  again, in place of the state check that tolerated the timer.
- owner-pause.md states the hooks' exactly-once rule as invariant 6.

Tests (prod, CPU-only, sandbox without the GPU): the 13 L2 tests and
L1's 27 pass in three serial runs, and 54/54 in two parallel runs with
the neighbouring suites; docs, docs-impact and changelog checks pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jonathan308 and others added 3 commits November 6, 2026 17:21
L0's review nits on [local]. Clean: L1 touches none of L0's files.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
From #1877's independent review:

- the pause's first request must not write the daemon state file: the
  loop's regular write carries it within 2 s, and only the resume writes
  at once;
- a fresh registration after the owner's idle time ends the pause with
  the connection's one event heartbeat, not two;
- with me first off, the frames are byte-for-byte unchanged and the
  loop's own gates admit: dispatch, load_model, prefetch_model,
  desired_models and Autopilot (a guard, which kills the review's M10).

Red (prod, CPU-only, sandbox without the GPU): 2 of 28 fail, the first
two above (the file holds the entry snapshot; 3 heartbeats instead of
2). The off guard passes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
From #1877's independent review:

- The pause's first request writes no file. enterOwnerPause dropped its
  synchronous writeDaemonState(): the loop already rewrites the daemon
  state, me_first included, every 2 s while serving, and the resume
  still writes at once. The first request of a pause now costs the loop
  p50 3.6 us, p99 12 us (was 0.52 ms and 0.98 ms; 3 x 380 rounds).
- A fresh registration ends a pause whose idle time passed while the
  connection was down before the connection's first event heartbeat, so
  that one heartbeat says idle or serving: no second, possibly stale,
  heartbeat (finishPlannedReconnect calls reassertOwnerPauseAfterReconnect
  first).
- Docs: `darkbloom switch` exits with an error when a long pause outlasts
  its readiness wait, though the switch completes and nothing needs
  redoing; the pause doesn't survive a restart; the 2 s write.

API names unchanged.

Green (prod, CPU-only, sandbox without the GPU): 28/28 in four serial
runs, 44/44 in five parallel runs with neighbouring suites. The review's
regression selections: 0 failures (the same six stop at the GPU
denial). Mutants M10 (off means paused) and M6 (no resume on reconnect)
are killed by the new tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jonathan308 added a commit that referenced this pull request Nov 7, 2026
#1877 (L1) took its independent review's fixes: the pause's first request
writes no daemon-state file (the loop's regular write carries it), and a
fresh registration ends a pause whose idle time passed before the
connection's first event heartbeat, so that one heartbeat says idle or
serving. It also merged #1870's newest head (f7c398b).

One conflict, in docs/architecture/owner-pause.md, resolved by keeping both
sides: the resumeIfOwnerIdle() row keeps #1877's reconnect wording and this
branch's member beat. Everything else merged cleanly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jonathan308 added a commit that referenced this pull request Nov 7, 2026
The required refactor pass on #1881. Behaviour-preserving: no public name or
signature changes, and the shipped code is byte for byte the same (the
prelinked ProviderCore.o is identical before and after; the one source file
touched changes only in comments).

- ProviderLoop+ClusterPairMeFirst states its invariants as a list: the
  leader decides for the pair, whatever its number of Macs (the process that
  owns the pair's local API owns the pause; nothing counts ranks); every
  other member stays control-only; nothing in flight is cancelled; nothing
  polls (O(1) request edges, heartbeats only on transitions, the idle check
  on the pause's one timer and the member beat that already runs every 5 s).
- Tests: ClusterPairMeFirstTests runs its leader on #1875's
  PairLeaderFixture, which it copied in 75 lines (LeaderRunFixture). The
  fixture is internal now and takes the leader's [local] section, shared
  serving by default as before; its discovery check also covers the pid.
  ControlOnlyMember replaces the untouched member's setup and beat-and-
  compare, written out in two tests. Dead code is gone: stableHeartbeat's
  unused `dropping:` and pairMember's `coordinatorURL`. Every test keeps
  its assertions (the same count of #expect and #require in each).
- owner-pause.md: the tests paragraph said the pair suite runs without the
  GPU. Its two tests that complete Darkbloom requests need a Metal device
  (each terminal reads MLX's memory counters), though they submit no GPU
  work.

Checks (prod, CPU-only: empty kernel libraries, a sampler saw no GPU work):
ClusterPairMeFirstTests 7/7, #1877's suites 28/28, #1875's cluster
selection 305/305 and the drain/settings selection 46/46, the same 386
per-test outcomes as the merge before this commit; the pair suites 5 more
times and #1877's 3 more times. Mutants (no forwarding to the pause, no
resume on the member beat, a saved single-Mac mode honoured, no timer
cancel on stop, the fixture ignoring [local]) are each killed. docs-check,
docs-impact-check and changelog check pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jonathan308 added a commit that referenced this pull request Nov 7, 2026
1de0e9f

L2's head moved 19190cd -> d6425d8: its refactor pass (2e7984d:
the end hook in one branch, exactly-once stated, one heartbeat client)
and #1877's review fixes (1de0e9f: a pause's first request writes no
state file, the loop's 2 s daemon-state write carries it; a fresh
registration ends an expired pause before its first event heartbeat).
L0's f7c398b, which both carry, is already here.

Clean: none of it touches a file of L4's own. L4 reads only the
MeFirstSnapshot fields and their daemon-state keys, which are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jonathan308
jonathan308 changed the base branch from local-first/l0-config to dev November 7, 2026 06:28
@jonathan308
jonathan308 marked this pull request as ready for review November 7, 2026 07:10
@jonathan308
jonathan308 merged commit d6425d8 into dev Nov 7, 2026
17 of 19 checks passed

This branch had an error being deployed

2 failed and 3 active deployments
Preview – d-inference-landing — 1de0e9f6 Deployed Nov 7, 2026 by vercel[bot]
Preview – eigen-homepages-darkbloom — 1de0e9f6 Deployed Nov 7, 2026 by vercel[bot]
Preview – d-inference-console-ui-dev — 1de0e9f6 Deployed Nov 7, 2026 by vercel[bot]
Preview – darkbloom-status — 1de0e9f6 Deployed Nov 7, 2026 by vercel[bot]
Preview – d-inference — 1de0e9f6 Deployed Nov 7, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant