Problem
grepai watch automatically discovers and indexes all linked git worktrees via go-git. In projects that use tools which create many worktrees (e.g. Claude Code's EnterWorktree), this causes the watcher to become unstable:
- Each worktree triggers a full parallel initial scan (thousands of files each)
- Multiple concurrent scans overwhelm the Ollama embedding endpoint with requests, causing
context canceled errors
- The filesystem event channel fills up (
Event channel full, dropping event)
- The watcher exits,
KeepAlive restarts it, and the cycle repeats — we observed 95,000+ restart cycles in a single day
The main project is a Django monolith with ~6,100 files. With 2-3 active worktrees, the watcher was trying to scan ~18,000+ files simultaneously, which Ollama (nomic-embed-text on Apple Silicon) couldn't sustain.
Workarounds attempted
| Approach |
Result |
parallelism: 1 |
Helped but didn't prevent crashes — worktree scans still run in parallel |
.claude in ignore list |
Prevents indexing .claude/ files but doesn't prevent worktree discovery |
Git CLI shim intercepting worktree list |
No effect — grepai uses go-git, not the CLI |
Temporarily renaming .git/worktrees/ |
grepai retries discovery every ~12s; also breaks git in active worktrees |
ThrottleInterval in launchd plist |
Mitigates restart storms but doesn't fix root cause |
Proposed solution
Add a config option to disable worktree auto-discovery:
watch:
discover_worktrees: false # default: true (current behavior)
When false, grepai watch would only index the project at the working directory and skip linked worktree discovery entirely.
Alternative proposals
watch.max_worktrees: N — limit how many worktrees to watch (0 = none)
watch.worktree_ignore_patterns: [".claude/*"] — filter specific worktrees by path pattern
- Sequential rather than parallel worktree scanning — index one worktree at a time
Environment
- grepai: 0.35.0
- OS: macOS 14.5 (Apple Silicon)
- Embedder: Ollama with nomic-embed-text
- Backend: gob
- Project: ~6,100 files, 2-3 concurrent worktrees created by Claude Code
Problem
grepai watchautomatically discovers and indexes all linked git worktrees via go-git. In projects that use tools which create many worktrees (e.g. Claude Code'sEnterWorktree), this causes the watcher to become unstable:context cancelederrorsEvent channel full, dropping event)KeepAliverestarts it, and the cycle repeats — we observed 95,000+ restart cycles in a single dayThe main project is a Django monolith with ~6,100 files. With 2-3 active worktrees, the watcher was trying to scan ~18,000+ files simultaneously, which Ollama (nomic-embed-text on Apple Silicon) couldn't sustain.
Workarounds attempted
parallelism: 1.claudeinignorelist.claude/files but doesn't prevent worktree discoveryworktree list.git/worktrees/ThrottleIntervalin launchd plistProposed solution
Add a config option to disable worktree auto-discovery:
When
false,grepai watchwould only index the project at the working directory and skip linked worktree discovery entirely.Alternative proposals
watch.max_worktrees: N— limit how many worktrees to watch (0 = none)watch.worktree_ignore_patterns: [".claude/*"]— filter specific worktrees by path patternEnvironment