Skip to content

Move index database into .dexter/ folder#10

Open
egze wants to merge 8 commits intoremoteoss:mainfrom
egze:move-db-to-dexter-folder
Open

Move index database into .dexter/ folder#10
egze wants to merge 8 commits intoremoteoss:mainfrom
egze:move-db-to-dexter-folder

Conversation

@egze
Copy link
Copy Markdown
Contributor

@egze egze commented Apr 9, 2026

Summary

  • Moves the SQLite index from <project>/.dexter.db to <project>/.dexter/dexter.db so the repo root stays clean and future dexter artifacts have a dedicated scratch space.
  • Existing databases migrate automatically on the next dexter init or LSP startup: legacy .dexter.db and its -shm/-wal siblings are deleted and a fresh index is built in the new folder. No user action required beyond updating their own .gitignore.
  • All path knowledge is centralized in internal/store via new DBPath, DBDir, LegacyDBPath, and FindProjectRoot helpers. The duplicated root-marker walks in cmd/main.go and internal/lsp/server.go are gone; the LSP call sites now have an inline comment documenting why they intentionally don't pass mix.exs as an extra marker.
  • Editor-extension repos (dexter-vscode, dexter-zed) continue to work via their existing mix.exs/.git fallback markers and can be updated separately.

Test plan

  • make test — all packages pass (store, lsp, integration)
  • make lint — 0 issues
  • New unit tests: TestDBPath, TestDBDir, TestLegacyDBPath, TestFindProjectRoot (6 subtests), TestOpen_CreatesDexterFolder, TestOpen_MigratesLegacyLayout, TestOpen_MigrationWithPartialLegacyFiles
  • New integration test: TestIntegration_LegacyMigration runs against the real binary, seeds legacy files, runs plain dexter init (no --force), asserts legacy deletion + new DB exists + dexter lookup still works
  • Manual smoke test: fresh dexter init creates .dexter/dexter.db; legacy .dexter.db* files are deleted and rebuilt on next init
  • Reviewer: verify .gitignore recommendation lands correctly in README Quick start
  • Reviewer: confirm Neovim root_markers still include the legacy .dexter.db so mid-upgrade users stay anchored

Note

Medium Risk
Moderate risk because it changes on-disk index location and project-root discovery for both CLI and LSP, which could break indexing/lookup if path resolution or migration logic is wrong.

Overview
Moves the SQLite index from .dexter.db at the project root to .dexter/dexter.db, and updates docs and .gitignore guidance accordingly.

Centralizes database path + root discovery in internal/store via new helpers (DBPath, DBDir, LegacyDBPath, FindProjectRoot), rewiring the CLI and LSP to use them (with the LSP explicitly avoiding mix.exs anchoring to keep monorepo behavior).

Adds automatic cleanup-based migration: if legacy .dexter.db/WAL/SHM files exist, they are deleted and the index is rebuilt in .dexter/; unit + integration tests were updated/added to cover the new layout, migration, and root-marker behavior.

Reviewed by Cursor Bugbot for commit dfd09b1. Bugbot is set up for automated code reviews on this repo. Configure here.

@egze egze force-pushed the move-db-to-dexter-folder branch from 27348db to 7c811df Compare April 9, 2026 19:12
Copy link
Copy Markdown
Collaborator

@JesseHerrick JesseHerrick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall the code and migration path looks good, @egze! I tested on my machine and the migration went perfectly.

I have just a few minor notes.

Since this will require a full reindex, I'd say we should wait until the next version that requires an indexVersion bump. We should have one of those soon due to the changes we'll need for worktree support without reindexing, so I'd wait for that release.

Now, on whether this is necessary at all: I'm not 100% convinced. I personally like the simplicity of having the .dexter.db files in the root, but had we started with .dexter/dexter.db then I wouldn't have any issue with that either. So I am curious if others feel as strongly as you do about the need for a separate directory. I don't feel super strongly about this, I just don't love that we need to do a migration.

@egze egze force-pushed the move-db-to-dexter-folder branch from 7c811df to c8bdd9b Compare April 9, 2026 20:24
@egze egze force-pushed the move-db-to-dexter-folder branch from c8bdd9b to dfd09b1 Compare April 9, 2026 20:26
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.

2 participants