Skip to content

fix(cli): close #283 bug 4 — tighten consolidate grouping + prune path-named projects#445

Open
Maicololiveras wants to merge 1 commit into
Gentleman-Programming:mainfrom
Maicololiveras:fix/consolidate-shared-dir-grouping
Open

fix(cli): close #283 bug 4 — tighten consolidate grouping + prune path-named projects#445
Maicololiveras wants to merge 1 commit into
Gentleman-Programming:mainfrom
Maicololiveras:fix/consolidate-shared-dir-grouping

Conversation

@Maicololiveras
Copy link
Copy Markdown

@Maicololiveras Maicololiveras commented May 28, 2026

Closes #283 — the remaining approved scope (bug 4).

Per your retest, bugs 1–3 are already fixed on main. This PR covers the two halves of bug 4, kept tight and additive.

🛟 Grouping — the data-loss footgun

groupSimilarProjects unioned every project that shared any directory. A noisy ancestor ($HOME or a session root) listed under many projects collapsed the whole store into one component, so projects consolidate --all proposed merging dozens of unrelated projects into a single bucket.

  • Skip any directory shared by more than maxSharedProjectsForDirMatch (3) distinct projects.
  • Genuine rename signals (a directory shared by a couple of projects) still group.

🧹 Cleanup of pre-existing path-named garbage

  • New --paths-only flag on engram projects prune narrows the 0-observation candidate set to projects whose name is a filesystem path.
  • Detection mirrors the write-boundary rejection in normalizeExplicitWriteProject (ContainsAny(name, "/\\")), so it targets exactly the names newer versions already refuse to create.
  • Reuses the existing prune machinery (dry-run, interactive selection, cascade delete) — no new command surface beyond the flag.

✅ Regression coverage (TDD)

  • Noisy shared dir is not grouped; small shared dir still groups; name similarity untouched.
  • Path-like detector table; prune --paths-only lists only path-named empty projects.

go build ./..., go vet, and gofmt all clean on the touched packages.


Suggested labels (external contributor can't self-apply): type:bug · priority:high · status:needs-review

… grouping + prune path-named projects

Bug 4 from issue Gentleman-Programming#283 has two halves, both addressed here.

Grouping (data-loss footgun): groupSimilarProjects unioned every project
that shared ANY directory. A noisy ancestor (e.g. $HOME or a session root)
listed under dozens of projects collapsed the whole store into one
component, so `projects consolidate --all` proposed merging unrelated
projects into a single bucket. Now skip any directory shared by more than
maxSharedProjectsForDirMatch (3) distinct projects; genuine rename signals
(a directory shared by a few projects) still group.

Cleanup of pre-existing garbage: add `--paths-only` to `projects prune`,
restricting the 0-observation candidate set to projects whose name is a
filesystem path. Mirrors the write-boundary rejection in
normalizeExplicitWriteProject (ContainsAny(name, "/\\")), so cleanup targets
exactly the names newer versions already refuse to create. Reuses the
existing prune machinery (dry-run, interactive selection, cascade delete).

Regression coverage (unit + command-level): noisy shared dir not grouped;
small shared dir still groups; name similarity untouched; path-like detector
table; `consolidate --all` proposes no merge for noisy-shared-dir projects;
`prune --paths-only` lists and deletes only path-named empty projects.
@Maicololiveras Maicololiveras force-pushed the fix/consolidate-shared-dir-grouping branch from 4f3a806 to 053923f Compare May 29, 2026 12:30
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.

MCP server fails on multi-repo cwd + 3 related bugs (ambiguity, path-as-name, case-sensitivity, unsafe consolidate)

1 participant