Repository navigation
cluster: the memory re-plan never starts a pair its owner just stopped - #1889
Merged
Merged
Conversation
Review of #1888 (F4, "older gap"): when this Mac's part of the pair is refused at load twice (`memory_gate_refused`), the control leader plans the model again on the memory now (`noteMemoryRefusal`). That re-plan comes due when a part ends, so also right after the owner stops the pair with `darkbloom stop`. It waits for the command lock the stop holds, then plans, adopts and serves without reading the pair's saved start again: `localServe` saves it again, and the pair the owner stopped starts. It also acts on a claim that moved to the other Mac meanwhile. Seams, the same behaviour on a Mac: the re-plan's body is `replanForMemory(model:say:)`, its onboarding steps can be stood in for (`memoryReplan`), and it takes the command lock beside the service's own files, as `checkForUpdate` and `checkApproval` do (the same file on a Mac). New test, failing here: with the owner's command holding the lock as the re-plan comes due, the owner stops the pair (the real `localStop`) or control moves to the other Mac; once the lock is free the re-plan must do nothing. Here it re-plans both times, and after the stop the pair's start is saved again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review of #1888 (F4). The memory re-plan (`replanForMemory`, due after this Mac's part is refused at load twice) comes due when a part ends, so also right after the owner's `darkbloom stop`, whose command lock it then waits for. It planned, adopted and served without reading the pair's saved start again, so its `localServe` started the pair the owner had just stopped. Once it holds the command lock it now acts only while this Mac still leads on a confirmed claim and the pair's start is still saved: the same guard as the re-plan after an update (`checkForUpdate`). A stop the owner issued is never undone, by any of the leader's automatic steps. Docs: architecture/inference.md, the extension's header; changelog fragment memory-replan-keeps-an-owners-stop.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…ne guard Same behaviour. No test expectation is removed or loosened; the test file changes only in two doc comments. - commandLockIfStillStarted (ClusterService+RestartingStop.swift) takes the control command lock beside the service's own files within 5 s and goes on only while, once it is held, the pair's start is still saved and this Mac leads on a confirmed claim. The re-plan after an update (checkForUpdate) and the memory re-plan (replanForMemory) both take the lock through it, so the guard that keeps an owner's stop from being undone is written once, with its reason on it; the PR had copied checkForUpdate's four lines. The approval change keeps its own lock and re-decision: it may change a stopped pair's approval, and it says a busy lock and tries again in a minute. - The file's header gives the memory re-plan a paragraph of its own: it starts the pair too and takes the lock as the re-plan does, so it never starts a pair its owner stopped while it waited, nor acts on a claim that moved meanwhile. The two steps' three invariants read as before. - The memoryReplan stand-in is declared with the service's other stored properties, beside the memory re-plan's state, instead of after init. The doc of that state pointed at "memoryReplan" for the trigger, which now named the stand-in: it names noteMemoryRefusal. - Tests: the memory re-plan test's doc says what its localServe would do (it read as if the re-plan still started the stopped pair), and the command-lock helper's doc no longer says "both steps". Checks (Xcode 27.2, prod identity, nice 19, CPU only, in a sandbox without ~/.darkbloom*, LaunchAgents writes or ports 8000/47420-47423): - ClusterServiceRestartingStopTests 16 tests (26 cases) and 24 related cluster suites (229 tests in all) pass, before and after, with the same build warnings in the touched files. - Mutants on these sources are each caught: the guard without the start's re-read, without the claim's re-check, or checking before it takes the lock; either re-plan back on the bare lock. - docs-check, docs-impact (base d17f629), changelog check and preview, diff --check: clean. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Refactor pass of #1889 (note 1): the memory re-plan adopts its new split through `OnboardingLive.localAdopt`, which on a serving pair stops both parts first (`localStop` clears the pair's saved start before it stops anything) and returns on a failure without putting the start back. The pair then stays stopped, and no memory re-plan acts on a stopped pair again: B6's shape, which #1888 fixed for the re-plan after an update and the approval change. New test, failing here: the memory re-plan's stop fails, because the other Mac doesn't answer or this Mac's part doesn't release. The start must be put back, the stop request a half-done stop keeps dropped, and the next memory re-plan must run. Here the start is lost in both cases, the request stays, and the next re-plan does nothing. The test of an owner's stop that skips the command lock (`releaseForSingleMac`) during a step's failing stop gets the memory re-plan as a third case: the owner's stop must hold, whatever the re-plan restores. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Refactor pass of #1889 (note 1). The memory re-plan adopts through `localAdopt`, which on a serving pair stops both parts first; that stop clears the pair's saved start, and its failure (the other Mac doesn't answer, this Mac's part doesn't release) returned with the start lost. The pair then stayed stopped on both Macs, and no memory re-plan acts on a stopped pair: B6's shape. From the adoption on, every failure of the memory re-plan now puts the start back and drops the stop request a half-done stop keeps (`restoreStart`), as the re-plan after an update does from its stop on. It does so under the command lock it holds, which every stop of the pair holds too, so it never undoes an owner's stop. The failure line says "The pair stays started." Docs: architecture/inference.md, the extension's header; the changelog fragment. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review of #1889 (§4, nits 1-3). The memory re-plan comes due when a part ends, so on the end of a part the owner's `darkbloom stop` stopped, and it then does nothing: the pair is stopped. But its trigger had already set the next slot 10 minutes ahead. An owner who starts the pair again within those minutes, with a split that still doesn't fit, gets no re-plan: the parts keep being refused at load until the slot passes. Seams, the same behaviour on a Mac: `noteMemoryRefusal` reads the incident log of the service's own home (the default one on a Mac) and is reachable from tests, as is `memoryReplanInFlight`; the memory re-plan puts the start back through its steps (`restoreStart`, as `UpdateReplan` does), so a test can see when it does. New tests: - failing here: a part refused, the owner's stop, the stopped part's end (the re-plan comes due and does nothing), a start within the 10 minutes, two more refusals: the pair must be re-planned and served (and, passing, when another command held the lock instead, the slot is kept: re-plans stay at most one per 10 minutes); - passing (the review's untested paths): a re-plan whose stop went through and whose parts then don't start again keeps the start; and in every case the start is put back while the re-plan still holds the command lock (checked at the moment of the restore). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review of #1889 (§4, nit 3). The memory re-plan comes due when a part ends, so also on the end of a part the owner's `darkbloom stop` stopped; it then does nothing, but its trigger had set the next slot 10 minutes ahead. An owner who started the pair again within those minutes, with a split that still doesn't fit, got no re-plan: the parts kept being refused at load until the slot passed. When the re-plan finds the pair's start cleared (the owner stopped it), it now gives its slot back: the owner's next start is re-planned at its next two refusals. A re-plan put off by a busy lock or ended by a failure keeps the slot, so re-plans stay at most one per 10 minutes. The comment on the restore says why it stays before the command lock is let go; the tests now check it there. Docs: architecture/inference.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jonathan308
marked this pull request as ready for review
November 8, 2026 03:12
jonathan308
added a commit
that referenced
this pull request
Nov 8, 2026
…ruth No conflicts. #1895 brings F2 (the following Mac's verdict), which this branch's words (`start --solo` / `start` in `ClusterPairWatch.line`) sit beside; #1896's one port per Mac and #1889's memory replan touch none of this branch's decisions. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
15 of 17 tasks
jonathan308
added a commit
that referenced
this pull request
Nov 8, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jonathan308
added a commit
that referenced
this pull request
Nov 8, 2026
…elay One conflict, in ClusterService.swift: #1889's replanForMemory sits where relayTick's doc comment was. Both sides are kept: #1889's function, then this branch's relayTick doc comment in place of dev's older one. #1896's two pending LS-3 markers (one port per Mac for a pair's API, LocalAPIPort.thisMac) are left for the port change that follows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 8, 2026
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
When this Mac's part of a pair is refused at load twice (
memory_gate_refused), the control leader plans the modelagain on the memory now (
ClusterService.noteMemoryRefusal). That re-plan comes due when a part ends, so also rightafter the owner stops the pair with
darkbloom stop. It waited for the command lock that stop holds, then planned,adopted and served without reading the pair's saved start again: its
localServesaved the start again, and the pairthe owner had just stopped started. #1888 closed the same gap for the re-plan after an update and the approval change;
its re-review left this older one as F4 ("the memory re-plan can still restart a just-stopped pair", re-review §3).
With this PR the invariant holds for all three of the leader's automatic steps: a stop the owner issued is never
undone.
replanForMemory(the re-plan's body, moved out ofnoteMemoryRefusal's thread unchanged) acts, once it holds thecommand lock, only while this Mac still leads on a confirmed claim and the pair's start is still saved. It is the
same guard as
checkForUpdate's, so a hand-over that finished while it waited also stops it.checkForUpdateandcheckApprovalnow do: beside the service's own files (the samefile as every cluster command's on a Mac; tests then never touch the default home). Since the refactor pass, both
re-plans take it through one guard,
commandLockIfStillStarted().84c95a27a1). The re-plan adopts throughlocalAdopt, which on a serving pair stops both parts first; that stop clears the saved start, and its failure (theother Mac doesn't answer, this Mac's part doesn't release) returned with the start lost: the pair stayed stopped, and
no memory re-plan acts on a stopped pair again. That is B6's shape, which cluster: a pair stays started when its automatic stop after an update fails #1888 fixed for its two steps. From the
adoption on, every failure now puts the start back and drops the stop request a half-done stop keeps
(
restoreStart), under the command lock every stop of the pair holds, so it never undoes an owner's stop. Thefailure line ends "The pair stays started." (It still quotes the stop's own lines before that, as cluster: a pair stays started when its automatic stop after an update fails #1888's lines do:
the review's nit 4, left as it is.)
557632292f). The re-plan comes due onthe end of a part the owner's stop ended, and does nothing; but its trigger had already set the next slot 10 minutes
ahead. An owner who started the pair again within those minutes, with a split that still doesn't fit, got no
re-plan: its parts kept being refused at load until the slot passed. A re-plan that finds the pair's start cleared
now gives the slot back, so the owner's next start is re-planned at its next two refusals.
Not changed: the trigger (
noteMemoryRefusal: two refusals, at most once per 600 s, gated oncontrol.leads); afailure before the adoption (nothing is stopped yet; it says why). A re-plan put off by a busy lock, ended by a failure,
or refused for a claim that isn't confirmed (or moved) keeps its slot: the next try needs two more refusals after
the 10 minutes pass. For an unconfirmed claim that means waiting out the slot, not just the next refusal; it is rare
(the leader's part runs only while its claim counts as confirmed) and safer (on a superseded claim the other Mac would
refuse the adoption's stop).
Linked issue
None. Follow-up F4 of #1888's review (
overnight/review-1888.md, "Re-review", §3 "Residual 1").Test plan
Xcode 27.2, prod identity,
swift build --build-testsatnice -n 19, onlyProviderCoreTestsbuilt (an uncommitted,skip-worktree
Package.swiftgate). Tests ran withswift test --skip-build --no-parallelin a sandbox that denies~/.darkbloom*, the GPU's user clients,~/Library/LaunchAgentswrites, and binds and connections on 8000 and47420–47423, each run with its own state files and home.
77fed7bd24(seams with the same behaviour on a Mac:replanForMemory(model:say:), thememoryReplanstand-in for its onboarding steps, the lock beside the service's files; plus the test).aMemoryReplanRightAfterAStopOrAHandOverDoesNothing: the owner's command holds the command lock as the re-plan comesdue; the owner stops the pair (the real
localStop) or control moves to the other Mac; the lock is released.93709ebc21:ClusterServiceRestartingStopTests16/16 (26 cases) at the time. Also passing:ClusterServiceRecoveryTests7,ClusterServicePairingChangeTests4,ClusterServicePartStartCacheTests2,ClusterApprovalServiceStartTests9,ClusterMemberServeLoopTests11,ClusterLeaderFailoverFinishTests14.ModelLoadRefusalTestsneeds Metal (it aborts in this GPU-less sandbox): for CI.93709ebc21, each caught by the new test: the start read before the lock is taken (the owner'scase: the re-plan ran and saved the start), and no claim re-check (the hand-over case).
docs-check(211 files),changelog.py check(38 fragments),docs-impact-check.py --base d17f62905f(5files),
git diff --check: clean.ca6ac85380): one guard for both re-plans, same behaviour; 16 tests (26 cases) and 24related suites pass before and after; its mutants H1–H3, M and U are each caught (
overnight/refactor-1889.md). CI(dev) run 42421246054 succeeded, all 21 jobs.
637b201b6bfor the failed stop:aMemoryReplanWhoseStopFailsLeavesThePairStartedAndTriesAgain(
adoptstands in forlocalAdopton a serving pair with the reallocalStop):(3 issues);
anOwnersStopWithoutTheCommandLockDuringAStepsFailingStopHoldsgets a "memory re-plan" case: areleaseForSingleMacduring the re-plan's failing stop must hold. It passes there and after the fix (the restoreruns under the command lock that stop waits for).
84c95a27a1:ClusterServiceRestartingStopTests17/17 (29 cases). Also passing:ClusterServiceRecoveryTests7,ClusterServicePairingChangeTests4,ClusterApprovalServiceStartTests9,ClusterMemberServeLoopTests11,ClusterLeaderFailoverFinishTests14,ClusterInstallIsolationTests22. Docschecks clean (
docs-check211,changelog.py check38, docs-impact 5 files,git diff --check). It merges cleanlyinto today's
devce9e92e030.becc146028for the slot (seams, the same behaviour on a Mac:noteMemoryRefusalreads theincident log of the service's own home and is reachable from tests, as is
memoryReplanInFlight; the restore goesthrough the steps'
restoreStart, asUpdateReplan's does).aSkippedMemoryReplanGivesItsSlotBackOnlyForAnOwnersStop,the trigger as the service calls it at each part's end, with a recorded
memory_gate_refused:nothing), a start within the 10 minutes, two more refusals: no re-plan there (1 issue); it must re-plan and serve;
aMemoryReplanWhoseStopFailsLeavesThePairStartedAndTriesAgain, "the parts do not start again" (the stop wentthrough, the restart fails before it saves the start); and in every case the start is put back while the re-plan
still holds the command lock, checked at the moment of the restore.
557632292f:ClusterServiceRestartingStopTests18/18 (32 cases), and 8 related suites, 90 tests(
ClusterService{Recovery,PairingChange,Descriptor}Tests,ClusterApproval{ServiceStart,Watch}Tests,ClusterMemberServeLoopTests,ClusterLeaderFailoverFinishTests,ClusterInstallIsolationTests).557632292f, each caught by the suite: the review's Mx2 (a failed restart not restored) and Mx3(the lock let go before the restore: the check at the restore, 6 issues); the slot kept on an owner's stop; the slot
given back for a busy lock too.
docs-check211,changelog.py check38, docs-impact 5 files,git diff --check); it mergescleanly into today's
devce9e92e030.557632292f: run 42431364789 succeeds on its first attempt, all 21 jobs; in Provider Unit Teststhe suite passed with the slot test (2 cases) and the failed-stop test (3 cases).
84c95a27a1: run 42423259553 succeeds on its first attempt, all 21 jobs; in Provider Unit Teststhe suite passed with the new test (2 cases) and the owner's-stop test (3 cases).
93709ebc21: run 42410918256 succeeds on its first attempt, all 21 jobs. The new test ran inProvider Unit Tests (2 cases), and so did
ModelLoadRefusalTests("Model load refusals and waits").darkbloom stopshould stay "■ Stopped".
Components touched
Protocol / interface changes
Documentation impact
docs/architecture/inference.md(the automatic re-plan after memory refusals),and the invariants on
ClusterService+RestartingStop.swift.Changelog
changelog.d/memory-replan-keeps-an-owners-stop.md;python3 scripts/changelog.py checkpasses.Refactor Pass
Done in
ca6ac85380by a dedicated pass (overnight/refactor-1889.md):commandLockIfStillStarted()is the one guardboth re-plans take the command lock through (the PR had copied
checkForUpdate's four lines); the header gives thememory re-plan a paragraph of its own; the
memoryReplanstand-in sits with the other stored properties, and a doc thatnamed
memoryReplanfor the trigger namesnoteMemoryRefusal. Same behaviour, tests unchanged but for two doccomments. Its note 1 (the failed stop) is fixed here (
637b201b6b,84c95a27a1). Its note 2 (a skipped re-plan usesup its 10-minute slot) is fixed for an owner's stop (
becc146028,557632292f), the case the independent reviewfound hurts users. A busy lock, a failure, or an unconfirmed or moved claim still keeps the slot (the trigger still gates
on
control.leads), so an unconfirmed claim waits out the slot, then two more refusals, before the next try.