Skip to content

fix(project-slug): resolve relative root before deriving slug#38

Open
Pawel-N-pl wants to merge 1 commit into
mainfrom
fix/project-slug-relative-root
Open

fix(project-slug): resolve relative root before deriving slug#38
Pawel-N-pl wants to merge 1 commit into
mainfrom
fix/project-slug-relative-root

Conversation

@Pawel-N-pl

Copy link
Copy Markdown

What

get_project_slug(".") (or any relative root) returned the generic "project"
slug instead of the real directory name.

Why

Path(".").name == "", so re.sub(...)[:8] was empty and fell back to the
collision-prone "project". Production passes an absolute {project-root}
(→ e.g. upmonaut) so it was unaffected; manual/relative invocations hit it.

Fix

.resolve() the root before taking .name, mirroring get_project_hash() in
the same module.

Tests

tests/test_project_slug.py — absolute root, relative "." (regression), and
the non-alphanumeric "project" fallback.

Addresses #35.

@Pawel-N-pl Pawel-N-pl requested a review from bma-d as a code owner June 6, 2026 23:19
@coderabbitai

coderabbitai Bot commented Jun 6, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@Pawel-N-pl, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 22 minutes and 44 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 420d28de-8ac4-4160-836c-7c90a0e49a3f

📥 Commits

Reviewing files that changed from the base of the PR and between f332173 and a4dc00b.

📒 Files selected for processing (2)
  • skills/bmad-story-automator/src/story_automator/core/utils.py
  • tests/test_project_slug.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/project-slug-relative-root

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@augmentcode

augmentcode Bot commented Jun 6, 2026

Copy link
Copy Markdown
🤖 Augment PR Summary

Summary: Fixes get_project_slug() so relative roots like "." derive the actual directory slug instead of defaulting to "project".

Changes:

  • Resolve the provided/derived project root to an absolute path before taking Path.name, matching the existing hash logic.
  • Add unit tests covering absolute roots, the "." regression, and the non-alphanumeric fallback.

Notes: Reduces collision risk for manual/relative invocations and aligns slug/hash behavior.

🤖 Was this summary useful? React with 👍 or 👎

@augmentcode augmentcode Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review completed. 1 suggestion posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

# doesn't collapse to the generic "project" fallback. Mirrors get_project_hash().
root = Path(project_root or get_project_root()).resolve()
value = re.sub(r"[^a-z0-9]", "", root.name.lower())[:8]
return value or "project"

@augmentcode augmentcode Bot Jun 6, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Path.resolve() will also collapse symlinks, so callers passing a symlinked project_root may see get_project_slug() change compared to the prior Path(...).name behavior. Is that acceptable given this slug is used in tmux session naming/filtering?

Severity: low

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Intentional, and consistent with the sibling get_project_hash, which already calls .resolve(). This makes a project's slug and hash agree on identity instead of diverging (the previous slug used the unresolved name while the hash resolved). For tmux session naming/filtering it's preferable: the same real project reached via different symlinked paths now maps to one consistent slug+hash, rather than fragmenting sessions per symlink. Net effect is removing a pre-existing slug/hash inconsistency, not introducing new behavior.

@Pawel-N-pl

Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 7, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@bma-d bma-d 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.

Thanks for the work here. I'm requesting changes because the slug fix changes the public session prefix for projects opened through a symlinked root.

root = Path(project_root or get_project_root())
# Resolve before .name so a relative root like "." (whose Path(".").name is "")
# doesn't collapse to the generic "project" fallback. Mirrors get_project_hash().
root = Path(project_root or get_project_root()).resolve()

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.

This currently resolves the project root before deriving the slug. That fixes . but also makes an absolute symlinked root use the target directory basename, so PROJECT_ROOT=/workspace/linked-root pointing at /workspace/actual-root produces actualro instead of linkedro. Existing sessions named under the symlink prefix are then hidden by project-only filtering, which matches sa-{project_slug}-.

Suggested fix: handle . without changing absolute symlink identity, or document and test that project identity is based on the resolved real path.

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.

3 participants