fix(sem): drop one leading UTF-8 BOM from an ignore file, as git does

main

Commit

Suhaan Thayyil4d ago

#419's own notes say only snapshot-query's loader was changed and that other readers of caller-written files were not audited. This is one of them, and it fails more quietly than the loader did.

Git accepts exactly one UTF-8 byte-order mark at byte zero of an exclude file and drops it before the first pattern -- verified against git 2.54.0, where check-ignore -v on a BOM-prefixed .gitignore reports the rule as vendor/. This reader did not, so the first rule of such a file was the mark plus the pattern and matched nothing. Reproduced end to end with a binary from this branch: a .graphignore reading zzcustom/ indexes zzcustom/lib.js when the file carries a mark and excludes it when it does not, with no warning either way. An ignore file is where a repository says what to keep out of the index and out of an agent's context, so disagreeing with git about it silently is the part that matters.

Windows PowerShell 5.1 writes that mark for Out-File and Set-Content -Encoding utf8, which is how a .graphignore created there arrives. One mark, at byte zero, exactly as the git-config preflight and the Claude settings reader already do; a second, or one on a later line, stays pattern text.

Both cache namespaces are bumped with it (search-snapshot v31, provider-records v26). The ignore file's bytes are in the key and they do not change here -- only what they mean does -- so without the bump this build would serve entries that hold the files the repository asked to exclude.

Each case is put to the installed git as well as to the matcher, so the test fails if the two ever disagree rather than pinning a remembered rule.