Summary
DbPathResolver (DbPathResolver.cs:23-24) resolves the DB by checking .cdidx/codeindex.db relative to the current working directory before walking up to find the workspace root. A user running cdidx search foo from a sub-directory therefore gets a different DB than running the same command from the project root — silently, with no warning when the workspace-root DB exists but a stale or empty sub-directory DB is preferred. The surprise grows with monorepo workspaces where each child has its own .cdidx/.
Where
src/CodeIndex/Cli/DbPathResolver.cs:23-24 (resolution order)
Suggested approach
(1) Change the resolution to prefer the workspace-root .cdidx/codeindex.db (walk up from CWD looking for .cdidx/) over the CWD-local .cdidx/. (2) Only fall back to CWD-local if no ancestor has a .cdidx/ directory. (3) Whenever the resolved DB differs from <CWD>/.cdidx/codeindex.db, emit a one-line stderr hint: "Using DB at /path/to/workspace/.cdidx/codeindex.db (CWD has no .cdidx/)". (4) Surface the resolved DB path and source in status --json under db_path_source (workspace_root / cwd_local / flag / env). (5) Add a regression test that runs from a sub-directory and asserts the workspace-root DB is used. (6) Cross-link with #1763 (--data-dir override).
Summary
DbPathResolver(DbPathResolver.cs:23-24) resolves the DB by checking.cdidx/codeindex.dbrelative to the current working directory before walking up to find the workspace root. A user runningcdidx search foofrom a sub-directory therefore gets a different DB than running the same command from the project root — silently, with no warning when the workspace-root DB exists but a stale or empty sub-directory DB is preferred. The surprise grows with monorepo workspaces where each child has its own.cdidx/.Where
src/CodeIndex/Cli/DbPathResolver.cs:23-24(resolution order)Suggested approach
(1) Change the resolution to prefer the workspace-root
.cdidx/codeindex.db(walk up from CWD looking for.cdidx/) over the CWD-local.cdidx/. (2) Only fall back to CWD-local if no ancestor has a.cdidx/directory. (3) Whenever the resolved DB differs from<CWD>/.cdidx/codeindex.db, emit a one-line stderr hint: "Using DB at /path/to/workspace/.cdidx/codeindex.db (CWD has no .cdidx/)". (4) Surface the resolved DB path and source instatus --jsonunderdb_path_source(workspace_root/cwd_local/flag/env). (5) Add a regression test that runs from a sub-directory and asserts the workspace-root DB is used. (6) Cross-link with #1763 (--data-dir override).