Skip to content

fix(slug): avoid parent repo identity in subdirs#1621

Open
jbetala7 wants to merge 1 commit into
garrytan:mainfrom
jbetala7:oss/fix-1125-gstack-slug-subdir
Open

fix(slug): avoid parent repo identity in subdirs#1621
jbetala7 wants to merge 1 commit into
garrytan:mainfrom
jbetala7:oss/fix-1125-gstack-slug-subdir

Conversation

@jbetala7

Copy link
Copy Markdown
Contributor

Fixes #1125

Summary

  • ignore parent repository remotes when gstack-slug is run from a subdirectory that is not the git root
  • let a .gstack-slug file in the current directory or an ancestor pin the project slug before cache/git inference
  • treat slug cache as a fallback for transient inference failures, not as an immutable source of truth when current inference or an override is available

Root cause

gstack-slug trusted git remote get-url origin before checking whether the current directory was actually the repository root. In a standalone project nested under a larger git repo, Git walked up to the parent repo, so the child project inherited the parent repo slug. Because cache lookup happened first, a bad slug-cache entry could keep that mistake alive indefinitely.

Verification

  • bun test test/skill-validation.test.ts -t gstack-slug
  • bun test test/review-log.test.ts test/gstack-learnings-search.test.ts
  • bun test test/skill-validation.test.ts
  • direct repro: nested directory under a parent repo with remote now returns the child basename instead of me-workspace
  • git diff --check origin/main...HEAD
  • git merge-tree --write-tree HEAD origin/main

Collision check

Searched open PRs/issues for 1125 gstack-slug outer repo subdirectory, gstack-slug subdirectory outer repo, bin/gstack-slug subdirectory slug-cache, slug-cache, and .gstack-slug.

Closest open PR is #564, but that is an older missing-git-context fallback patch. Current origin/main already has basename/unknown fallback behavior; #564 does not address parent-repo inheritance, .gstack-slug overrides, or stale cache recovery.

@jbetala7 jbetala7 force-pushed the oss/fix-1125-gstack-slug-subdir branch from 942e049 to 133c6cb Compare June 3, 2026 06:33
@jbetala7

jbetala7 commented Jun 3, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (post #1848) and resolved the bin/gstack-slug conflict. Now MERGEABLE again (head 133c6cbd).

This fixes a distinct bug from #1848: #1848 added unconditional cache-value sanitization, while this PR stops a nested standalone project from inheriting its parent repo's identity (it checks git rev-parse --show-toplevel == $PWD before trusting origin, and treats the slug cache as a fallback rather than an immutable source). The conflict resolution keeps #1848's hardening: every path (override, remote, basename, and the cache read) runs sanitize_slug, plus a final unconditional sanitize before the value is emitted or cached, so the poisoned-cache shell-injection defense is preserved. #1848's test/gstack-slug-sanitize.test.ts passes against the rebased branch.

Verification:

  • bun test test/gstack-slug-sanitize.test.ts test/user-slug-fallback.test.ts (slug-sanitize green; the one user-slug-fallback failure is pre-existing on clean main c43c850, unrelated to this file)
  • bun test test/skill-validation.test.ts -> 331 pass
  • Functional: from a nested non-root subdir of a repo, SLUG is now the directory basename, not the parent repo slug.

garrytan added a commit that referenced this pull request Jun 3, 2026
… 401ing

The report job upserts its E2E summary via the REST /issues/{n}/comments
endpoints (gh api), which GITHUB_TOKEN gates behind the issues permission, not
pull-requests. The job only granted pull-requests:write, so the GET 401'd on
every PR that produced eval artifacts (PRs with no artifacts exit early and never
reach the call, which masked it). Pre-existing; surfaced here because this PR
runs evals. Confirmed identical failure on #1188 and #1621.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

gstack-slug inherits outer-repo slug when project is a subdirectory; cache is unrecoverable

1 participant