fix(clean): apply should_protect_path in dry-run for orphaned system services#895
Merged
Merged
Conversation
…sts (tw93#886) `mo clean --dry-run` reported orphaned LaunchDaemons (e.g. the Microsoft Office helper at `com.microsoft.office.licensingV2.helper.plist`) as "would remove", while the subsequent real `mo clean` silently skipped them: the `should_protect_path` check ran only inside the real-clean branch, so dry-run never consulted protection rules and printed an unreachable promise. Fix in `lib/clean/apps.sh`: - Lift `should_protect_path` above the `DRY_RUN` branch so both modes consult it. Protected files now stop the loop body with a single `Skipping protected orphaned service` debug entry regardless of mode. - Ungate the summary line `"Orphaned services skipped N protected, failed N"` so it prints in dry-run too. The user now sees what was held back; previously dry-run was silent about protected hits. Tests (`tests/clean_apps.bats`): - `dry-run skips protected paths (tw93#886)` — protects every orphan, asserts dry-run does NOT print "Would remove" and DOES print the skipped summary. Without the fix this case used to print "Would remove" in dry-run. - `dry-run reports unprotected orphans (tw93#886)` — confirms the non-protected path is unchanged: dry-run still prints "Would remove" and never prints "Skipping protected". Both tests pass `MOLE_TEST_NO_AUTH=0` explicitly so the function runs past the CI auth-skip guard (`scripts/test.sh` exports `MOLE_TEST_NO_AUTH=1`), and use `|| return 1` after each `[[ ]]` so a failing assertion in the middle of the body fails the test instead of being swallowed by a later passing one. Closes tw93#886
611802e to
2ce6a36
Compare
xronocode
added a commit
to xronocode/pages
that referenced
this pull request
May 15, 2026
- tw93/Mole#895 — fix(clean): apply should_protect_path in dry-run for orphaned system services - tw93/Mole#896 — fix(clean): bump simctl probe timeout and retry on cold boot Both merged by @tw93 2026-05-14; Mole card now has 5 merged PRs.
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
should_protect_pathcheck before the dry-run / real-clean branch inclean_orphaned_system_services()so both modes agree on which paths are protected.Problem
mo clean --dry-runreported an orphaned LaunchDaemon plist as removable:But real
mo cleansilently skipped it becauseshould_protect_pathmatched thecom.microsoft.*protection rule — but only in the real-clean branch. The dry-run branch never calledshould_protect_path.Fix
Hoist the protection check above the
if [[ "$DRY_RUN" == "true" ]]conditional so it runs unconditionally. Now both dry-run and real clean will report the same set of removable orphans.Testing
clean_orphaned_system_servicesbats tests pass, including new regression test.bats tests/clean_apps.bats --filter "orphaned_system_services"→ 4/4 okFixes #886