feat(render): Claude rate_limits 세그먼트(5h/7d 쿼터 % + 리셋 카운트다운)#30
Merged
Conversation
Claude Code statusLine stdin JSON의 rate_limits.{five_hour,seven_day}
(used_percentage + resets_at)를 읽어 5h/7d 쿼터 %와 리셋 카운트다운("2h30m")을
calm statusline에 렌더한다(--source claude 전용, 네트워크 0, Pro/Max graceful absence).
- 시간 산술은 main.rs resolve_claude_rate_limits에서 pre-resolve(Option C),
render.rs는 이미 해소된 값의 순수 포맷만 유지. 부패 방어(스큐/inf/NaN/거대음수/
상한/epoch-zero)는 순수 compute_remaining_secs에 격리(checked_sub로 오버플로 패닉 방지).
- percent는 clamp_rate_percent로 0..=100 양자화(NaN/음수/151 방어). countdown은 순수 format_reset_countdown.
- rate_limits/윈도우는 lenient 역직렬화로 타입 드리프트 흡수(한 윈도우 드리프트가 전체 파싱을 안 깸).
- lterm/codex 경로 비트 동일(회귀 0): 신규 필드는 parse_claude_input만 설정(I6),
render 블록은 rate_5h_percent 게이트라 codex 경로 미발화. internal raw는 render 미참조(I7, AC24 잠금).
- config: show_rate_limit(기본 true) + rate_limit_warn_threshold(opt-in, 기본 off=무색 calm).
- 테스트 +18(AC1-24, I7). ralplan 합의(Planner/Architect/Critic 2R) + 독립 code-review(HIGH 오버플로 1건 수정) 반영.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- src/render.rs [testability] rate_limit_warn_threshold_colors_value가 process-global
NO_COLOR과 격리 안 돼 env-변경 테스트와 병렬 경합 → nondeterministic flaky(Codex MEDIUM).
ENV_LOCK 획득 + remove_var("NO_COLOR")로 결정화(기존 truecolor 테스트 패턴). pct==t 경계
(inclusive 발화) + percent==0 렌더(presence 게이트) 테스트 추가.
- src/claude.rs [testability] format_reset_countdown 86399→"23h59m" sub-day 경계 +
compute_remaining_secs at-cap(max_secs 허용 / +1 None) 경계 테스트 보강(리뷰어 mutation 갭).
quad-review-loop round 1/5, fingerprint: MEDIUM|testability|src/render.rs|no_color-race
Co-Authored-By: Claude Opus 4.8 (1M context) <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.
요약
Claude Code statusLine stdin JSON의
rate_limits.{five_hour,seven_day}(used_percentage+resets_atUnix epoch)를 읽어 **5h/7d 쿼터 % + 리셋 카운트다운("2h30m")**을 calm statusline에 렌더한다.--source claude전용, 네트워크 호출 0, Pro/Max 한정 graceful absence.커뮤니티 리서치(quad-research, 4트랙)에서 rate-limit 가시성이 최다 요청(서드파티 워크어라운드 난립)으로 확인된 기능. 데이터가 이미 stdin JSON에 있어 네트워크 0으로 구현 가능.
설계 (ralplan 합의 Planner→Architect→Critic 2R)
resets_at − now)을 render가 아니라main.rs resolve_claude_rate_limits에서 pre-resolve → render.rs는 "이미 해소된 값의 순수 포맷" 계약 유지.compute_remaining_secs(스큐/inf/NaN/거대음수/상한/epoch-zero → None,checked_sub로 오버플로 패닉 방지) +format_reset_countdown+clamp_rate_percent(0..=100). 각각 직접 단위테스트.parse_claude_input만 설정(I6), render 블록은rate_5h_percent게이트(I7: internal raw는 render 미참조, AC24 잠금).rate_limit_warn_thresholdopt-in(기본 off).변경
claude.rs: ClaudeInput 6필드, RawRateLimits/Window, 순수함수 3종, 파싱.main.rs:resolve_claude_rate_limitspre-resolve.render.rs: collect_segments rate 블록(5h=49/7d=47) + 합본 세그먼트.config.rs:show_rate_limit(기본 on) +rate_limit_warn_threshold(opt-in).검증
-D warnings클린 · 테스트 377(362 lib + 15 oneline, 신규 +18) 통과 · release--locked클린.checked_sub수정·재검증.🤖 Generated with Claude Code