fix(claude): worktree 경로 절대성 가드로 상대 git_worktree FP 차단 (M-2)#23
Merged
Conversation
결함: derive_git_branch는 is_safe_base_path(traversal 차단)만 호출하고
is_absolute() 검사가 없었다. "repo"/"." 같은 상대경로가 입력되면
canonicalize가 understatus 프로세스 cwd 기준으로 해석해 엉뚱한 repo의
branch를 반환하는 false-positive가 발생했다.
수정(Option A, ralplan 합의):
- derive_git_branch에 is_absolute() 가드 추가(is_safe_base_path 직후)
- derive_git_branch_from_cwd의 기존 가드에 대칭 주석 1줄 보강
("한쪽 변경 시 양쪽 동기화" 계약 명시)
- 단위 테스트 git_worktree_relative_path_rejected 추가:
RawWorkspace를 직접 구성해 cwd-독립으로 상대 입력 즉시 거부를 고정
(통합 테스트는 러너 cwd에 .git이 없으면 false-green 위험)
is_safe_base_path 계약·이름은 불변(Option B 폐기).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
무엇을 / 왜 (M-2)
derive_git_branch(Claudeworkspace.git_worktree/repo경로)에 절대성 가드가 누락돼 있었다. 상대 경로("repo"/".")가 들어오면read_branch_from_git_dir의canonicalize가 understatus 프로세스 cwd 기준으로 해석해 엉뚱한 repo의 branch를 표시하는 false-positive(phantom-branch)가 발생한다.derive_git_branch_from_cwd(lterm cwd 경로)는 이미is_absolute()가드를 갖고 있어, 두 경로의 방어 비대칭이 원인이었다. 이번 PR로 대칭화한다.설계 (ralplan 합의: Option A)
Planner는 공유 헬퍼
is_safe_base_path에 절대성을 흡수하는 Option B를 권고했으나, Architect·Critic이 역권고:is_safe_base_path의 공개 계약(doc "절대경로 자체는 허용") + 정합 테스트(absolute_system_path_yields_no_branch)를 반전시켜 "1줄 DRY"보다 검수 비용이 큼.→ Option A:
derive_git_branch에is_absolute()가드 개별 추가.is_safe_base_path계약/이름 불변. 양 가드에 대칭 교차참조 주석.변경
derive_git_branch(claude.rs)에is_absolute()거부 가드 추가(상대 → None).git_worktree_relative_path_rejected:derive_git_branch직접 호출,"repo"/"."/repo:"repo"세 케이스 → None (러너 cwd 무관, is_absolute가 fs 접근 전 즉시 거부).검증
~/.cargo/bin/cargo): fmt / clippy -D warnings / test 340 passed(326+14, +1) / 0 failed / build --releaseabsolute_system_path_yields_no_branch등 보존),is_safe_base_path불변. 버전 범프 불요.🤖 Generated with Claude Code