Description
Summary
Issue #1605 fixed openRepo() / openReadonlyWithNative() (via the shared resolveDbSettings() helper in src/db/connection.ts) to derive loadConfig()'s rootDir from the resolved --db path rather than process.cwd(), so cross-repo --db /other/project/.codegraph/graph.db invocations read the target repo's .codegraphrc.json instead of the invoking directory's.
That fix was scoped to openRepo()/openReadonlyWithNative() only. While wiring db.busyTimeoutMs through the remaining ad-hoc read-only query call sites for #1763, I found the same process.cwd()-based pattern still present in several other functions that independently call loadConfig():
manifestoData()insrc/features/manifesto.ts—loadConfig(process.cwd())hybridSearchData()insrc/domain/search/search/hybrid.ts— bareloadConfig()moduleBoundariesData()insrc/features/structure-query.ts— bareloadConfig()diffImpactData()insrc/domain/analysis/diff-impact.ts— bareloadConfig()resolveComplexityQueryOptions()(used bycomplexityData()) insrc/features/complexity-query.ts—loadConfig(process.cwd())auditData()insrc/features/audit.ts— bareloadConfig()(note:resolveThresholds()in the same file does correctly derive rootDir fromcustomDbPath, so this file is internally inconsistent)
By contrast, checkData() in src/features/check.ts already derives repoRoot from the resolved DB path and calls loadConfig(repoRoot) correctly.
Impact
Running any of the affected commands with --db /other/project/.codegraph/graph.db from a different working directory reads config (manifesto rule thresholds, analysis.impactDepth/auditDepth, search.topK/rrfK, structure.cohesionThreshold, and now db.busyTimeoutMs) from the invoking directory's .codegraphrc.json instead of the target repo's. Confirmed via a test that had to work around this (see PR for #1763) by mocking process.cwd() rather than relying on DB-path-derived config resolution.
Fix direction
Standardize these functions on the same rootDir-from-resolved-db-path derivation already used by resolveDbSettings() (src/db/connection.ts) and checkData()/resolveThresholds() (src/features/check.ts / src/features/audit.ts). Since deriving rootDir requires resolving customDbPath via findDbPath() first, consider exporting a small shared helper (mirroring deriveRootDirFromDbPath() added privately to src/db/connection.ts in #1763) rather than duplicating the findDbPath + path.dirname(path.dirname(...)) dance in each of the six call sites.
Scope
Out of scope for #1763 (which only threads db.busyTimeoutMs through the existing config resolution mechanism of each function, without changing what rootDir that resolution uses) and out of scope for #1605 (scoped to openRepo()/openReadonlyWithNative() only). This is a real pre-existing correctness gap, not a regression introduced by either.
Activity
fix: derive loadConfig() rootDir from --db path in read-only query fu…
fix: resolve loadConfig() from --db path, not process.cwd(), in remai…
fix(cli): derive config from the target dir/--db instead of a cwd-pin…
fix(cli): resolve display config from customDbPath, not process.cwd() (…