Deduplicate project indexes by git/path identity#754
Conversation
|
Thanks for splitting out project identity deduping. Triage: high-priority path/project identity fix, but the PR is currently conflicting. Please rebase on current |
|
Thank you — the problem is real (duplicate project indexes for the same repo) and splitting this out of #625 was the right move. After a careful review we can't merge the current identity key, though, and want to be specific about why: canonical_root is derived from git's common-dir and is deliberately identical for a main repo and all its linked worktrees (that's what it was built for in #749 — branch-level identity). Used as project identity, indexing a worktree resolves to the main repo's project and reuses/overwrites its DB — silently breaking multi-worktree workflows (which we use heavily ourselves). Two more issues: identity_nested in the reverse direction means opening a monorepo root adopts a child project's name and its incomplete graph; and the scan opens every cached .db + runs a git subprocess per project on every pipeline creation and session-detect, which is costly and invasive (read-write opens of other projects' stores). CI is currently red on all five platforms and the branch conflicts with main. Concrete path to merge: (1) key identity per-worktree — canonicalized worktree root, or (canonical_root, worktree_path) pair — so worktrees stay distinct projects; (2) drop the reverse-nesting adoption; (3) cache the identity scan (or restrict it to index-time, not every session-detect). Also note #625 declares itself gated on this PR, so it inherits the same rework. If you'd rather not carry the redesign we completely understand — say the word and we'll distill the per-worktree variant with credit to you. Thanks for pushing on a real pain point. |
…on (default on) Add the auto_watch config key (default: true) and route both session watcher-registration sites in mcp.c (autoindex completion and the already-indexed connect path) through a register_watcher_if_enabled() helper. When disabled, the skip is logged as a short structured line (watcher.register.skipped reason=auto_watch_off). Default is TRUE (opt-out): existing users keep background auto-sync unchanged; the knob exists for multi-project users who want each session contained to explicit indexing. Distilled from the auto_watch half of PR DeusData#625. The PR's bundled project-index dedup commit is excluded here — it belongs to DeusData#754's own review. Unlike the original PR, no watch registration is added to the index_repository handler (none exists on main; adding one would be new behavior beyond the gate), and the default is flipped from off to on to preserve current behavior. Tests: default-unset registers the watcher on connect (guards the no-behavior-change promise); auto_watch=false registers nothing — verified RED against the ungated production code, GREEN with the gate. Co-authored-by: Andy11-cpu <canada11@duck.com> Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
Reuse an existing cached project when the same repository is opened from a different path. Match by git canonical root or canonical filesystem path so duplicate .db files are not created. Signed-off-by: Andy11-cpu <canada11@duck.com>
f7b112e to
9376ca1
Compare
|
Rebased on current 1. Per-worktree identity (not 2. Dropped reverse nesting 3. Cached identity scan 4. CI / conflict fixes
Commit: |
|
Thank you for tackling this — index duplication is a real annoyance and the git-worktree-identity idea is a good instinct. After a careful review we're going to close this one, and I want to be transparent about why:
Given #780 already covers the safe dedup and the new behavior is the risky part, we don't want to ship the auto-merge-and-delete identity model. If you'd like to pursue a safe version — detect a likely-duplicate index and warn (or offer an explicit, opt-in merge) rather than silently merging + unlinking — that'd be a welcome, much lower-risk direction and we'd happily review it. Really appreciate the effort here. |
Summary
project_resolvemodule to match repos by git canonical root or canonical pathMotivation
Split from #625 — prevents duplicate
.dbfiles when the same repository is indexed from multiple paths.Test plan
test_project_resolve.c(canonicalize, identity key, find existing, pipeline reuse)make -f Makefile.cbm test(CI)Signed-off-by: Andy11-cpu canada11@duck.com