Skip to content

hardening: git pill 견고화 (branch cap + 테스트 RAII + SF Symbol 계약)#22

Merged
ictechgy merged 4 commits into
mainfrom
feature/git-pill-hardening
Jun 12, 2026
Merged

hardening: git pill 견고화 (branch cap + 테스트 RAII + SF Symbol 계약)#22
ictechgy merged 4 commits into
mainfrom
feature/git-pill-hardening

Conversation

@ictechgy

Copy link
Copy Markdown
Owner

무엇을 / 왜

git-branch pill 주변 견고화 묶음(quad-review 잔여 LOW + 이전 PR 리뷰 LOW). ralplan 합의(Planner→Architect→Critic)로 항목별 구현/문서화 판정 후 구현. 사용자 비가시 hardening — 동작 변경 0(정상 케이스 불변).

변경 (3 atomic 커밋)

  1. feat(claude) — branch명 길이 cap: read_branch_from_git_dir(양 경로 chokepoint)에 MAX_BRANCH_LEN=256 byte cap, 초과 시 None 거부. 근거: APFS NAME_MAX=255라 정상 branch는 256B 초과 불가 → 초과 = 손상/조작된 .git/HEAD 신호. FP<FN 방어적 상한(표시 거부, stdout/stderr 침묵=인젝션 방어). doc에 None 4원인 열거.
  2. test(claude) — 테스트 RAII 가드: unique_test_dirDeref<Path> + Drop 가드 struct로 승격 → 단언 실패(panic) 시에도 temp 누수 0. 구식 PID-only 3곳(collision 위험)을 통일. catch_unwind panic-safe 증명 테스트 추가.
  3. test(render) — SF Symbol 계약 테스트: 모든 cmux pill icon에 하이픈(-) 부재를 단언(SF Symbol은 점·소문자만, 하이픈=Lucide/nerd-font명=cmux drop). 과거 git-branch 회귀를 영구 차단하는 교차-pill 불변식(model·git·미래 pill 커버).

추가: symlink .git 추종(표준 git 동작) 의도 테스트 + 동기 fs read 트레이드오프 doc(비파괴).

검증

  • 4게이트 그린(~/.cargo/bin/cargo): fmt --check / clippy --all-targets -D warnings / test 339 passed(325+14, +4 신규) / 0 failed / build --release
  • 회귀 0: label_value_segment/render/to_cmux_pills 시그니처 불변, oneline 바이트 보존, 기존 335 테스트 전부 그린. 버전 범프 불요.

🤖 Generated with Claude Code

ictechgy and others added 4 commits June 12, 2026 17:01
read_branch_from_git_dir에 MAX_BRANCH_LEN(256B) 상한을 추가한다. loose ref는
파일시스템 경로 컴포넌트라 정상 branch명은 APFS NAME_MAX(255)를 넘을 수 없어
256B를 절대 초과하지 않는다. 따라서 256B 초과는 손상/조작 신호이므로 표시를
거부해 false-positive(틀린 branch)보다 false-negative(빈 pill)를 택한다(FP<FN).

byte length(.len())로 검사하며, stderr 로그는 추가하지 않는다(understatus는
status를 stdout에 쓰는 프로세스라 출력 오염 위험 — stdout/stderr 모두 침묵).

read_branch_from_git_dir doc도 갱신: None 반환 4원인 열거, 심볼릭 .git 추종이
표준 git 의도 동작임을 명시, 동기 fs read 트레이드오프(NFS 블록) 한 단락 추가.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
unique_test_dir를 TestDir 가드 struct 반환형으로 승격한다. Drop에서
remove_dir_all로 정리해 패닉(단언 실패) 시에도 temp 디렉터리 누수가 0이다.
Deref<Target=Path>로 기존 호출부의 .join()/.to_string_lossy()는 무변경 동작한다.
(주의: unwind 전제 — panic="abort" 도입 시 무효, 현재 Cargo.toml은 unwind 기본.)

- 구식 PID-only temp 경로 3곳(git-test/repoobj/detached)을 unique_test_dir로
  통일해 collision + panic-leak을 동시 해소한다.
- 말미 remove_dir_all 정리 라인은 전부 제거(이제 Drop이 처리).
- test_dir_guard_cleans_up_on_panic: catch_unwind로 의도적 panic을 감싼 뒤
  캡처한 경로 부재를 단언해 가드가 언와인딩에서도 cleanup함을 증명(AC-d1).
- derive_from_cwd_rejects_overlong_branch: 256B 초과 거부 + 정확히 256B 허용
  경계값을 고정(item a 회귀 가드).
- derive_from_cwd_symlink_git_dir_follows_to_some: 심볼릭 .git이 정상 ref를
  가리키면 Some(branch)를 반환해 표준 git symlink 추종이 의도 동작임을 고정.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
cmux는 SF Symbol 이름만 렌더하고 SF Symbol은 하이픈을 쓰지 않으므로(점·소문자)
icon에 `-`가 있으면 Lucide/nerd-font명이라 cmux가 silently drop한다. 과거
`git-branch` 회귀를 영구 차단하기 위해 교차-pill 불변식 테스트를 추가한다.

cmux_pill_icons_contain_no_hyphen: enrich-성공 시나리오(model+ctx+git+cpu+mem
5 pill)에서 모든 pill의 icon이 Some일 때 하이픈을 포함하지 않음을 단언한다.
model(sparkles)+git(arrow.triangle.branch)+미래 pill 전부 커버한다. 기존 git
pill 정확일치 단언(arrow.triangle.branch)은 positive 앵커로 유지한다.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1. render.rs `cmux_pill_icons_contain_no_hyphen`: 루프 뒤에 하한 단언 추가.
   pill 0개 또는 icon 전부 None이면 위 루프가 조용히 통과(vacuous-pass)하는
   것을 차단 — pills.is_empty() 금지 + icons_checked >= 2 보장.

2. claude.rs `read_branch_from_git_dir`: O(1) 길이 검사를 O(n) 제어문자
   스캔보다 앞으로 재배치. 악의적 초대형 HEAD를 전량 스캔 후 거부하던
   비효율 제거(단락 평가로 즉시 탈출). SECURITY 주석 위치 유지.

3. claude.rs `TestDir`: `AsRef<std::path::Path>` impl 추가. 기존
   `Deref<Target=Path>`만으로는 `AsRef<Path>` 바운드 API에 `&tmp`를
   직접 전달 불가 — `&*tmp` footgun 해소. 기존 호출부 변경 없음.

quad-review-loop round 1, PR #22
@ictechgy ictechgy merged commit 13dac4c into main Jun 12, 2026
1 check passed
@ictechgy ictechgy deleted the feature/git-pill-hardening branch June 12, 2026 08:16
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.

1 participant