Skip to content

feat(index): worktree-aware index seeding#52

Merged
aeneasr merged 1 commit intomainfrom
fix-git-worktree
Mar 17, 2026
Merged

feat(index): worktree-aware index seeding#52
aeneasr merged 1 commit intomainfrom
fix-git-worktree

Conversation

@aeneasr
Copy link
Member

@aeneasr aeneasr commented Mar 17, 2026

Summary

  • Git worktree support: When git worktree add or claude --worktree creates a new worktree, Lumen detects sibling worktree indexes and copies the most recent one as a seed before running the normal Merkle tree diff
  • Incremental instead of full re-index: Worktrees typically share 95%+ of files, so seeding turns minutes of embedding into seconds of incremental update
  • Zero configuration: Detection, seeding, and incremental update are fully automatic

New packages

Package Purpose
internal/git Worktree detection: IsWorktree, CommonDir, ListWorktrees
internal/config FindDonorIndex searches siblings for existing indexes
internal/index SeedFromDonor does atomic SQLite copy with WAL checkpoint

Integration points

  • cmd/stdio.go: Seeds before NewIndexer in getOrCreate() — runs only when DB doesn't exist yet
  • cmd/hook.go: Reports sibling availability in SessionStart context so the user knows fast re-index is available
  • README.md: Documents git worktree support in "What you get" and "Database location"

Edge cases handled

  • git not installed → gracefully skipped
  • Concurrent writes to donor → WAL checkpoint + file copy is safe
  • Stale donor → Merkle diff catches all differences
  • macOS /var/private/var symlinks → resolved via EvalSymlinks

Test plan

  • internal/git: IsWorktree with .git dir vs file, ListWorktrees with real repo, CommonDir, not-a-repo graceful failure
  • internal/config: FindDonorIndex with no siblings, with sibling, wrong model mismatch
  • internal/index: SeedFromDonor copies DB, skips when dst exists, incremental update after seed works correctly
  • go test ./... — all packages pass
  • golangci-lint run — 0 issues

🤖 Generated with Claude Code

…ding

When using git worktrees, lumen now detects sibling worktree indexes and
copies the most recent one as a seed before running the normal merkle diff.
This turns a full re-index (minutes of embedding) into an incremental
update (seconds), since worktrees typically share 95%+ of files.

New packages:
- internal/git: worktree detection (IsWorktree, CommonDir, ListWorktrees)
- internal/config: FindDonorIndex searches siblings for existing indexes
- internal/index: SeedFromDonor does atomic SQLite copy with WAL checkpoint

Integration points:
- cmd/stdio.go: seeds before NewIndexer in getOrCreate()
- cmd/hook.go: reports sibling availability in session context

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@aeneasr aeneasr merged commit 76809bd into main Mar 17, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant