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

@Maicololiveras Maicololiveras commented May 28, 2026

Copy link
Copy Markdown

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
@Alan-TheGentleman Alan-TheGentleman added the type:bug Bug fix label Jun 13, 2026
@Alan-TheGentleman

Copy link
Copy Markdown
Collaborator

This is linked to the approved #283 scope and looks focused on the remaining consolidate/prune bug. I added the type:bug label so the process gate can run. Next step is code review after the required checks are green.

@github-actions

Copy link
Copy Markdown

This PR has been inactive for 30 days. Please rebase, update it, or leave a comment — otherwise it will be closed in 14 days.

@Alan-TheGentleman Alan-TheGentleman left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reopening attention on this — the status:stale label is process drift, not code decay: groupSimilarProjects and cmdProjectsPrune are unchanged on main and the branch is still mergeable.

Your diagnosis is better than the issue's. #283 blamed a loose name-similarity threshold, but the actual collapse is the shared-directory union at cmd/engram/main.go:1946-1950, which unions every project sharing any directory — so one $HOME entry transitively merges the whole store. That matches Group 2 in the report containing <user-home> plus the path-named entries. Skipping directories touched by >3 distinct projects is the right lever, and leaving project.FindSimilar untouched is the right call.

One question before merge:

  • The --paths-only prune flag is #283 bug 2 cleanup, not bug 4. Would you split it into its own PR? It reuses existing prune machinery so it's low-risk, but this PR's title and tests are all about grouping.

Happy to merge the grouping fix as-is if you'd rather keep them together — just say so and I'll drop the request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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)

2 participants