Repository navigation
provider: owner pause for me first (local-first L1, stacked on #1870) - #1877
Merged
Merged
Conversation
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>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
#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>
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>
7 of 9 tasks
12 of 20 tasks
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>
11 of 16 tasks
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
marked this pull request as ready for review
November 7, 2026 07:10
This branch had an error being deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 headf7c398b9f2through the signed, non-force merge0f97f1d946(earlier,2a2987cd5cthrough373f5adf04).Draft. Do not merge: no
devmerges until the owner says so, because adevmerge 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, undernice -n 19. They ran undersandbox-execwith 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_FILEandDARKBLOOM_VERIFIED_WEIGHTS_FILEpointed at a temporary folder.Red, at
550ec294dd(tests plus an unwired skeleton):swift test --skip-build --no-parallel --filter 'MeFirstPolicyTests|ProviderBusyWireTests|OwnerPauseLoopTests|OwnerPauseWireTests'.ownercodec round trip, and an unknown reason still decoding.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:
CoordinatorClientregistration and heartbeat tests;UpdateDrainAwarenessTests,CoordinatorLifecycleBarrierTests,PlannedProviderDisconnectTests;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 ofClusterMemberLoopTestsandAutopilotBusyReasonTests. 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 pausedregisterand heartbeat, and its open heartbeat, were decoded by 90ee'sprotocol.DecodeProviderMessageand applied to itsaddonhold.State:drainingwithowner, which is not an add-on hold, so the Mac keeps its uptime;idlewith 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 --allandscripts/docs-impact-check.py --base 00f5afa24dpass.The independent review's nits (approve with nits), on the same CPU-only setup:
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.1de0e9f6fb: 28/28 in four serial runs, and 44/44 in five parallel runs beside 4 neighbouring suites.docs-check.sh,docs-impact-check.py --base f7c398b9f2andmake changelog-checkpass.Dev-identity build and test run, and full CI.
Components touched
Protocol / interface changes
busy_reasongainsowner, sent only besidestatus: drainingand never withbusy_addon. Deployed coordinators key the add-on hold onaddononly, so they treatowneras a plain drain. Older providers decode an unknown reason as absent.daemon-state.jsongains an optionalme_firstobject.Documentation impact
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.Changelog
changelog.d/local-first-owner-pause.mdand ranmake changelog-check.Notes for reviewers
API for L2 and L5b
All on
ProviderLoop, actor-isolated (provider-swift/Sources/ProviderCore/ProviderLoop+MeFirst.swift):enableMeFirst(idle: Duration)LocalSettings.meFirstEnabled(in:)and a coordinator. Pass.seconds(60 * resolvedMeFirstIdleMinutes). The first call wins.noteLocalUse(.start)localReservations.reserveinacquireModelForLocal. For L5b: in the leader's local admission.noteLocalUse(.end)releaseLocalReservation. Exactly one.endper.start; an unmatched one is ignored.ownerPausesPublic,meFirstSnapshotstatussnapshot (DaemonState.meFirst).resumeIfOwnerIdle()reassertOwnerPauseAfterReconnect). Tests drive it with a fake clock (meFirstNowMs).For tests on the fake clock (L2, L5b): once a
.endhas armed the real resume timer, move the clock and resume withresumeIfOwnerIdleForTesting(advancing:by:)(inOwnerPauseLoopTests.swift), which does both in one actor turn. A separateclock.advancethenresumeIfOwnerIdle()lets the timer end the pause in between, and the call then returns false.How it's kept cheap (owner criterion 8)
MeFirstPolicyis a pure state machine: a counter and two timestamps on a clock the caller passes in.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..connectedevent 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 saysidleorserving.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.noteLocalUsereturns at once, and no timer or task ever exists.withMeFirstOffNothingPausesAndNoTimerOrTaskIsLeft;theResumeTimerRunsOnlyWhileIdleTimeCountsAndEndsThePauseByItself: no timer while open or while a request runs, and none left after the resume;Decisions to check
ProviderState.ownerPausesPublic, notservingDrain.servingDrainalso closes local admission.throwIfRefusingNewLocalWorkis untouched, andrefusingNewWorkstays apart: its other readers (revision and MTP gates) do not see the pause.load_modelandprefetch_model, with the existing drain failures. Theprefetch_modelevent handling moved out ofProviderLoop+Serve.swiftintohandleCoordinatorPrefetchso it can be tested. The behaviour is the same apart from the owner term.draining.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:).publishBusy()is the one writer, with an add-on hold outranking the owner pause. It replacespublishAddonBusy()and thestate.busy = nilinleaveAddonHold.capacityRebuildForTesting, nil in production, at the top ofupdateAggregateCapacity. The add-on release path rebuilds capacity, which reads MLX's Metal allocator. The seam keeps that test off the GPU.coordinatorRequestsInFlightis factored out oflifecycleRemaining, with the same result. It feedsdarkbloom_requests_finishing.Known edges and follow-ups
idleorservingheartbeat, and the pause's heartbeats saydraining. If the pause outlasts the provider's 30 s readiness wait,darkbloom switchexits 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 (90eeproviderdrain.Authority.AppliedCapacityandResume). Nothing needs redoing. A follow-up for L4 could print that instead whenstatussays paused.selfrequests to a paused Mac wait, andpreferrequests 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 inresumeAfterModelSwitch.Limitations
review-L1.md) approved with nits. Nits 1 to 6 are addressed ind675ba9ee5and1de0e9f6fb, 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 endRefactor Pass
Done by a separate refactor subagent, 2026-11-06 23:20Z to 2026-11-07 00:15Z (
date -u). Headaf7671a17e→373f5adf04(the merge of #1870's2a2987cd5c) →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.ownerand theMeFirstSnapshotfields are as they were.desired_modelsreplay. The add-on release and the pause's end repeated the same guard and replay, in a different order. Both now callreplayDesiredModels(deferred:), beside the deferral inProviderLoop+Prefetch.swift. Same conditions, same log lines.ProviderLoop+MeFirst.swift: the pause cancels nothing; an add-on hold outranks it;desired_modelswait for whichever ends last; heartbeats only on transitions; at most one timer, and none while me first is off.owner-pause.mdgains invariant 5, the pause cancels nothing.reassertOwnerPauseAfterReconnectno longer ends the pause inside aguardcondition.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-onlyresumeIfOwnerIdleForTesting(advancing:by:)does both in one actor turn.ownerGoesIdleand the four other advance-then-resume steps use it, with the same assertions.aPauseEndingUnderAnAddOnHoldLeavesTheBusyFieldsAndDesiredModelsToIt: the hold keeps the busy fields anddesired_models, and its release replays them. It passes on373f5adf04too, and covers the add-on release's replay without the GPU.OwnerPauseOutbound.completed(_:)is gone.Evidence (prod identity, CPU-only, the author's sandbox without the GPU or
~/.darkbloom*, Xcode 27.2,nice -n 19):373f5adf04; 27/27 on the final tree in 5 serial runs; 20 parallel runs with 4 more suites, 51/51 each.anAddOnHoldOutranksThePauseAndItsReleaseKeepsItfails.AutopilotBusyReasonTests,OperatorModelFilterTests,ModelRevisionPublicationTests,ModelPrefetchCoordinatorTests,AddonHoldLoopTestsandAddonHoldServeLoopTests. Those suites are CI's.373f5adf04and onc82ac10088: 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, includingreleaseReopensAdmissionAndReplaysDeferredDesiredModels. The two Vercel failures were already there ataf7671a17e.scripts/docs-check.sh,scripts/docs-impact-check.py(against2a2987cd5cand againstdev's merge base) andmake changelog-checkpass.Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.