Repository navigation
fix(provider): uninstall never deletes under a running cluster service; the chooser says what each option removes (stacked on #1778) - #1780
Merged
Conversation
…st (B16, B21) The 0.10.8 candidate (c3) on pair-2: on the member of a serving pair, the DevNet app's uninstall skipped "Stop serving" and "Remove this install's cluster service", then deleted the app while `darkbloom-dev cluster service` (a session service, no launchd agent) was still running from it. As tests, with stand-ins for the lock holder (never real launchd or processes): - Beside the other install, this install's running cluster service is stopped before the first deletion (both directions); step 1 says what serves here; the dry run and the summary say so; the pairing and the shared files stay. - The other install's running service is left running, and said so. - A running service that is neither install's keeps every file and fails the run (exit 1); so does this install's service when it did not stop. - B21: beside the other install, option 1 does not promise the pairing or models it keeps, and option 2 says the models stay either way. Red at 8b2eb2f33e: a runtime probe with the old API deleted the app under the running service and showed the old option lines; the tests above do not compile (no `RunningClusterService`, `runningClusterService:`, `stopClusterService:`, `owner(ofExecutable:)`, `stillRunningStep`). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 4ce38617b2e3f2a919a4bddcf5bcfd39c75ec6df)
B16: before deleting anything, the uninstall now finds whose cluster service holds this Mac's lock (`ClusterService.running`, the service's pid file, the process's executable from the kernel, matched to an install by `ClusterServiceAgentPlan.installRoot`). - Beside the other install (step 2's shared path), this install's running service, launchd's or a session's, is stopped first (SIGTERM, as `cluster stop --local-only` ends one, waiting for its lock), so the member's part ends cleanly; then its agent goes; the pairing and cable port setup stay. The other install's service is left running. One from neither install is refused. - In both paths, a check before the first deletion fails the run when a cluster service of this install, or one it can't tell apart, still runs: nothing is deleted, the summary says to stop it with `cluster stop --service` and run the uninstall again, and the command exits 1. The unshared path keeps `Cluster.Stop.parse(["--service"])`, which already ends a session service of this build (`ClusterService.stopDetached`). - Step 1 says when a cluster service serves here instead of the provider. - B21: option 1's line names only what it removes on this Mac (no pairing while another install shares it, "all models" only when none stays); option 2 says when the models stay either way. The CLI reference, the installation and troubleshooting sections and the changelog fragment say so. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 31d2a79a293c89ad863911796872f420e0a9097f)
…drop the path it replaced
Behaviour-preserving cleanup of the uninstall's running cluster service
fix (31d2a79a29). Every printed line and exit code is the same; no test
changed.
- `removeOwnClusterAgent` had no caller left, and its doc comment sat on
top of the new function's. It is removed.
- `handleOwnClusterService` is `removeOwnClusterService`, after its step
("Remove this install's cluster service") and the function it
replaced. Its detail is built from one list without a force unwrap;
each outcome reads as before.
- The dry run's shared step 2 binds the running service instead of
force-unwrapping it twice; its default branch is the base's line again.
- The command probes the cluster service lock once: the Plan's init sets
`clusterServiceRunning` from `runningClusterService`, and the live
lookup is non-nil exactly when `ClusterService.running()` is true.
- `linkedModelsLabel` names the "Models" label the inventory gives a
linked model cache, which option 2's line (`keepsModels`) compares with.
- The CLI reference's step 2 names the function step 2 calls, and says
that booting out the agent ends launchd's service and SIGTERM a
session's (it said both were stopped first with SIGTERM). The
installation section's long line is rewrapped.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit da7dc43b8973420ebdf615b017500e7b607d9354)
…, unreadable locks Validator B's notes on the B16 fix, as tests: - m1: a cluster service started through a link (`bin/<cli>`, or a link elsewhere into an app) is told apart by where the link leads, both directions. - n2: a service that starts again during the steps after step 2 (the cable step can wait for a password) still keeps every file. - m2, m3, n1: the lock reads three ways (free, held, can't be read), a lock that can't be read or a pid that is not a cluster service is nobody's, a missing pid makes no claim about whose, and the stop refuses to signal a process that is not a cluster service. - m4: with no other install, the dry run says what `cluster stop --service` does to the service running here: stops this install's, stops any `<cli> cluster service`, and stops nothing else. Red at da7dc43b89: m1 (6 issues) and n2 (2: files deleted, no check) run and fail; with the others the suite does not compile (no `runningClusterService(lock:pidFile:paths:isClusterService:)`, `unreadableLockNote`, `isThisCLI`, `note`). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit cbc083da6c9178e3cfea16f37af53f384075409e)
…care Validator B's minors and nits on the B16 fix: - m1: the executable is resolved (links included) before telling whose it is, as the install roots are. - m2: only a cluster service is anyone's. This build's is checked with `ClusterService.isClusterService`, the check `cluster stop --service` makes; the other install's by its own `<cli> cluster service` arguments. A pid that is no cluster service (a stale pid file) reads as unknown and is refused, and the stop never signals one. - m3: the lock reads three ways; one that can't be opened is unknown and refused, not "no service". - m4: the docs, the dry run and the changelog say what each path does: with no other install, step 2 stops any `darkbloom cluster service`, and a service under another name fails it with that stop's own message. - n1: without a readable pid the step says so and claims no owner. - n2: the "still running" check runs right before the first deletion, after the steps that can wait (the cable step's password). - n3: one name for the other install in the uninstall docs: the production Darkbloom, Darkbloom Dev. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit d944c49c8d795f4e0a63a248347a1ddada8b8946)
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
13 of 21 tasks
This was referenced Nov 4, 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
darkbloom uninstallno longer deletes the app under a running cluster service. The 0.10.8 candidate (c3) hit this on the member of a serving pair, with the DevNet app beside the production app. The uninstall skipped "Stop serving" and "Remove this install's cluster service", because the service was a session's and had no launchd agent. It then deleted the app whiledarkbloom-dev cluster servicewas still running, so the member's part died mid-run and the leader looped (B16).Now the uninstall finds whose cluster service holds the lock, from its pid file and its executable with links resolved, and only counts a process whose arguments are
<cli> cluster service:cluster stop --service): it stops anydarkbloom cluster service, launchd's or a session's, wherever it runs from, and a service under another name fails the step with that stop's own message;The chooser's option lines now say only what each choice removes on this Mac (B21).
Linked issue
None: the 0.10.8 candidate's findings B16 and B21 (c3 on pair-2); a follow-up to #1772.
Test plan
The runs were made on the validated local branch, on
8b2eb2f33e, whose tree is #1778's head's (26a1013cde). This PR's head has the identical tree (6b640d90f7).swift build --build-tests(prod and dev identities)swift test --skip-build --filter 'ProviderUninstallTests|UninstallCommandTests|LaunchAgentRemovalTests|LaunchAgentLifecycleTests|WatchdogLaunchAdapterTests|ClusterServiceAgentTests': 93/93 (8 new tests across both rounds)ClusterConsoleCommandTests|ParsedInCodeTests|ClusterPairClusterCommandsTests|ClusterStatusPlainTests|ClusterPairControlTests|ClusterPairHabitCommandsTests|StatusCommandRunTests|ClusterPairTruthTests|ClusterPairValidatorFindingsTests): 66 in 9ProviderUninstallTests|UninstallCommandTests: 30/30make docs-check,make docs-impact-check BASE=8b2eb2f33e,make changelog-check,git diff --check0c89e825c9:make docs-check206 OK ·make changelog-check52 valid ·make docs-impact-check BASE=01176687d6OK (11 files) ·git diff --check 01176687d6cleandarkbloom-dev uninstall --keep-models. Step 1 ends "…; this install's cluster service is running (pid N)"; step 2 says "stopped it (pid N), so this Mac's part ended cleanly; …";psshows the service gone before the first "Delete" line; the leader logs a clean member stop, not the "part ended (exit 1) … starting it again" loop; the pairing, the cable port setup and~/.darkbloom/cluster*stay; the command exits 0darkbloom-dev uninstallleaves that service running (same pid), and its pair keeps servingdarkbloom-dev cluster stop --service…"; after that stop, a rerun finishescluster stop --service(stopDetached) stops it, and nothing is deleted before the lock is free (so far verified only by reading)Components touched
Protocol / interface changes
--dry-run --jsonplan is unchanged; no new flags.Documentation impact
docs/provider/cli-reference.md(darkbloom uninstall: option lines, steps 1, 2 and 9);docs/provider/installation.md;docs/provider/troubleshooting.md;docs/provider/two-mac-cluster.md(the two installs' names).Changelog
changelog.d/<topic>.mdfragment and ranmake changelog-check. A line in the still-unreleasedchangelog.d/provider-uninstall-keep-or-remove.md.Notes for reviewers
Commits: signed cherry-picks (
-x) of the validated local commits, in order:bdaeb0192d(from4ce38617b2): the B16 and B21 tests;1311cf38f8(from31d2a79a29): the fix;4a70de9a25(fromda7dc43b89): the refactor pass;6ccc39127d(fromcbc083da6c): the tests for validator B's minors;0c89e825c9(fromd944c49c8d): their fix.Owner lookup.
ProviderUninstall.liveRunningClusterServicereads:service.pid;KERN_PROCARGS2).It resolves the executable's links and matches its install root to this install's app or the other install's. A pid counts only when it is a cluster service: this build's by
ClusterService.isClusterService(the checkcluster stop --servicemakes), the other install's by its own<cli> cluster servicearguments.liveStopClusterServicesignals only such a pid.Shared path (both apps on the Mac). Step 2 refuses a service from neither app, then:
cluster stop --local-onlyends one;The pairing and the cable port setup stay, as in feat(provider): darkbloom uninstall, remove everything or keep models #1772.
Unshared path.
Cluster.Stop.parse(["--service"])is unchanged. It stops a session service whose command is this build's<cli> cluster service, wherever it runs from (ClusterService.stopDetached). A service under another name makes the step fail withstopDetached's message, and nothing is deleted.Both paths. Before the first deletion, a check fails the run while a cluster service of this install, or one it can't tell apart, still runs. Every deletion is then skipped and the run exits 1. Files are never deleted from under a running service.
Step 1 says when a cluster service serves here instead of the provider.
Tests use stand-ins for the lock holder and its stop: never real launchd or processes.
Limit: the live lookup and SIGTERM are reviewed, not exercised. A run on pair-2 is the proof.
Independent validation
Validator B, at the refactor pass's head (
4a70de9a25here; localda7dc43b89): PASS WITH NOTES, 0 blockers, 0 majors, 4 minors, 3 nits.git diff --checkclean.unknown; m2, SIGTERM went toservice.pid's pid without checking it is a cluster service; m3, an unreadable lock counted as "no service"; m4, the one-install path was described as the shared one. The nits: n1, "pid 0" with no readable pid; n2, the check ran right after step 2, not right before the first deletion; n3, two names for the other install. All are fixed in6ccc39127dand0c89e825c9.Delta check at the final head (
0c89e825c9here; locald944c49c8d, the same tree): PASS. All four minors and three nits are fixed, with no regression.liveStopClusterServicechecksisClusterServiceagain right beforekill. Given three pids that are no cluster service, the live stop threw, and all three stayed running.unknownand refused.git diff --checkclean.Nit left (d1, cosmetic, no action needed): the unshared step 2 still decides on
ClusterService.running(), which folds an unreadable lock into "free". Under an unreadable lock that step reads "skipped: no cluster service on this Mac", then the final check fails with the unreadable-lock note. It is safe (nothing is deleted); only the two lines disagree.The pair-2 rerun boxes in the Test plan stay open: the live lookup and stop are exercised only on throwaway processes and seams.
Before And After
flowchart LR subgraph Before["Before (c3 on pair-2)"] direction TB b1["darkbloom-dev uninstall<br/>(member of a serving pair; session cluster service, no agent)"] --> b2["step 1: provider service not running → skipped"] b2 --> b3["step 2 (shared): no own agent → skipped"] b3 --> b4["delete ~/.darkbloom-dev<br/>under the running service"] b4 --> b5["member's part dies; leader loops<br/>'part ended … starting it again'"] end subgraph After direction TB a1["darkbloom-dev uninstall"] --> a2["runningClusterService():<br/>lock, service.pid, KERN_PROCARGS2 → owner"] a2 -->|this install| a3["boot out own agent; SIGTERM the session service;<br/>wait for the lock"] a2 -->|other install| a4["left running; said so"] a2 -->|neither| a5["step 2 fails: nothing deleted, exit 1;<br/>'stop it first with cluster stop --service'"] a3 --> a6["check before deleting: no service of this install runs"] a4 --> a6 a6 --> a7["delete this install's files; pairing and cable stay"] endflowchart LR subgraph Code["Code path (After)"] direction TB c1["UninstallCommand.plan / operations"] --> c2["ProviderUninstall.liveRunningClusterService<br/>(ProviderUninstall+ClusterService.swift)"] c2 --> c3["ProviderUninstall.owner(ofExecutable:paths:)"] c1 --> c4["ProviderUninstall.run"] c4 --> c5["shared: removeOwnClusterService<br/>(agent → stopClusterService)"] c4 --> c6["unshared: stopClusterPart = Cluster.Stop --service (unchanged)"] c5 --> c7["stillRunningStep check → deletions or refusal"] c6 --> c7 endRefactor Pass
Done:
4a70de9a25(removeOwnClusterService, no force unwraps, one lock check). Validator B: PASS WITH NOTES (0/0/4/3). All four minors and three nits are fixed in6ccc39127dand0c89e825c9, and the prod and dev sets, #1774's 66 and the docs gates were rerun.A dedicated refactor subagent reviewed the fix and added one behaviour-preserving commit:
4a70de9a25refactor(provider): name step 2's own-service function for its step, drop the path it replaced.No test changed, and every printed line and exit code is the same.
Changed
ProviderUninstall.removeOwnClusterAgent. The fix left it with no caller, and its doc comment had stayed on top of the new function's.handleOwnClusterService→removeOwnClusterService. Its detail is built from one list, without a force unwrap.clusterServiceRunningfromrunningClusterService."Models"label that option 2's line compares against (linkedModelsLabel).docs/provider/cli-reference.md, step 2: names the function step 2 calls, and says the bootout ends launchd's service and SIGTERM a session's.Left as is
RunningClusterService.describedstays with the engine's other step reasons.runningClusterServiceandstopClusterServiceseams are left as they are.Follow-up (outside this PR): one shared
KERN_PROCARGS2reader inClusterService, forprocessCommand(pid:)(executablePath(pid:)before the minors' fix) andprocessArguments(pid:).After it (sandboxed, filtered, at
4a70de9a25):make docs-check,make docs-impact-check BASE=8b2eb2f33e,make changelog-checkandgit diff --checkpass.Final (this head): prod 93/93, #1774's set 66/66, dev 30/30, and the gates, as in the Test plan.
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.