macOS: keep Spotlight's file results off, and add a way to stop the indexer - #83
Merged
Conversation
The Spotlight pane's own switches are a results filter and nothing more: with Files and Folders both off, a probe file dropped in ~/projects was still in `mdfind` twenty seconds later. So the two halves are separate here — `defaults.sh` records which rows are off, and a new target stops `mds` from indexing at all. The array name lies. `EnabledPreferenceRules` lists what is turned *off*; `System.files` and `System.folders` appeared in it the moment those two switches went dark, which is how the list was read rather than guessed. Why the indexer half is a whole volume and not ~/projects: nothing else works. `man mdutil`, `man mds`, `man mdimport` and `man mdfind` between them say nothing about exclusions. `.metadata_never_index` in the folder changed nothing. The Privacy list does work, but its plist is behind TCC even for root, so scripting it needs Full Disk Access on the terminal — and is undocumented anyway. The motive is a kernel panic on 2026-08-12: the vnode table filled up while mds reindexed a monorepo behind several coding agents, every mmapped page after that faulted with SIGBUS, launchd took one and the kernel had nowhere to go.
"Help Apple Improve Search" hands Safari, Siri, Spotlight and Lookup queries to Apple, and the key does not exist until the switch is touched — absent means opted in, which is why it belongs in a file rather than in a memory of having clicked it once. 2 is the opted-out value, taken from what the switch itself wrote rather than from a guess: `defaults read` was diffed across the flip.
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.
Two separate things, because they turn out to be separate mechanisms: which rows Spotlight is allowed to show, and whether
mdsindexes files at all.Why
A kernel panic on 2026-08-12, #82. The vnode table filled up (
263168 numvnodes, 0 free) while mds reindexed a monorepo behind several coding agents, APFS could no longer create vnodes, every mmapped page after that faulted with SIGBUS,launchdtook one and the kernel panicked withinitproc exited.The results half —
bin/macos/defaults.shThe key name lies:
EnabledPreferenceRuleslists what is turned off. Read, not guessed —defaults readwas snapshotted, the Files and Folders switches flipped, and those two entries appeared in the array. A row left at Apple's default is simply absent, so the whole array is the state and adding a line means switching something off.This does not stop indexing. With both switches off, a probe file dropped in
~/projectswas inmdfindtwenty seconds later. It filters what Spotlight shows, and that is all.The indexer half —
make macos-spotlight-offA whole volume, because nothing finer exists:
man mdutil,man mds,man mdimport,man mdfind— not one mention of exclusions. A volume is the only granularity Apple documents..metadata_never_indexin~/projects— tested, changed nothing./System/Volumes/Data/.Spotlight-V100/VolumeConfiguration.plist, which TCC hides even from root: PlistBuddy reportsFile Doesn't Existfor a filesudo mdutil -Pprints happily. Scripting it needs Full Disk Access handed to whichever terminal runs it, and it is undocumented besides.Costs Finder's "This Mac" search. App results (Mail, Notes, Messages) come from CoreSpotlight and are expected to survive — that is the one claim here not verified live, and it says so in the Makefile.
Its own target, not part of
make macos: that one writes nothing outside$HOMEand asks for no password, same reasonmacos-touchidstands alone.macos-spotlight-onreverses it.Conflicts with #32
#32 (draft) adds a check that warns from
make macoswhen too few apps are indexed, pointing atsudo mdutil -E /. With indexing off that check nags forever, and both branches touchbin/macos/defaults.sh. Whichever lands second needs the other taken into account — the check would have to skip whenmdutil -sreports indexing disabled.Checks
make lint bin-testpasses.defaults.test.shasserted a hardcoded domain count, 11 → 12. Neithermake macosnormake macos-spotlight-offwas run as part of preparing this.