Skip to content

fix(analytics): reject invalid KPI numeric evidence on current main - #421

Open
seonghobae wants to merge 3 commits into
mainfrom
fix/kpi-snapshot-numeric-validity-main-20260812-r2
Open

fix(analytics): reject invalid KPI numeric evidence on current main#421
seonghobae wants to merge 3 commits into
mainfrom
fix/kpi-snapshot-numeric-validity-main-20260812-r2

Conversation

@seonghobae

@seonghobae seonghobae commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

Objective

Reconstruct #389's bounded KPI ledger numeric-integrity repair directly on current protected main after #264 advanced the baseline, without stale ancestry.

Test-first current-base state

  • protected base: b66b692ce580b783cddf9e99d96c4f94aa6b1735;
  • exact test-only head: 6610529acb9b6bdf41c1f7d5d491dbf00fdfef7e;
  • current-main KpiSnapshotLedger.java and its focused test were byte-identical to fix(analytics): reject invalid KPI numeric evidence #389's historical protected base before this reconstruction;
  • focused tests require persisted NaN, positive/negative infinity, rates outside [0,1], and negative p95 preview latency to fail closed with the existing controlled invalid-line error.

This Draft intentionally begins RED. Observe exact current-head CI failure before applying the narrow parse-boundary validation; then require exact-head Maven/100% coverage/Javadocs plus CI/Security/SAST/fuzz and fresh review/thread evidence.

Scope

Two-file analytics data-integrity slice only. It does not change KPI denominator semantics, tenant-query isolation, API shape, or canonical documentation. PR #389 remains the stale-base predecessor until this current-base reconstruction proves and preserves its unique semantic delta.

Summary by CodeRabbit

  • 버그 수정

    • KPI 비율 값이 유한하며 0~1 범위인지 검증합니다.
    • 음수 KPI 값과 유효하지 않은 KPI 증거값이 포함된 기록을 거부합니다.
    • 잘못된 기록에 대해 일관된 오류 메시지를 제공합니다.
  • 테스트

    • 비유한 값과 범위를 벗어난 값에 대한 검증 테스트를 추가했습니다.

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@seonghobae, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 37 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

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.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 3c2f21dc-a47a-4108-8855-c665aac5d886

📥 Commits

Reviewing files that changed from the base of the PR and between c21bd4a and 7e41b46.

📒 Files selected for processing (1)
  • src/test/java/com/clearfolio/viewer/analytics/KpiSnapshotLedgerTest.java
📝 Walkthrough

Walkthrough

KPI ledger 파싱이 비율의 유한성 및 [0.0, 1.0] 범위를 검증합니다. 음수 처리 시간도 거부합니다. 테스트는 잘못된 persisted ledger와 오류 메시지를 검증합니다.

Changes

KPI ledger 검증

Layer / File(s) Summary
입력값 검증 및 테스트
src/main/java/com/clearfolio/viewer/analytics/KpiSnapshotLedger.java, src/test/java/com/clearfolio/viewer/analytics/KpiSnapshotLedgerTest.java
rate가 유한하고 [0.0, 1.0] 범위에 있는지 검증합니다. nullableLong은 음수 값을 거부합니다. 테스트는 NaN, 무한대, 범위 밖 비율, 음수 처리 시간과 "kpi snapshot ledger contains an invalid line" 메시지를 확인합니다.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 제목은 현재 main에서 유효하지 않은 KPI 수치 증거를 거부하는 핵심 변경을 정확하고 간결하게 설명합니다.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/kpi-snapshot-numeric-validity-main-20260812-r2

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.

@seonghobae
seonghobae marked this pull request as ready for review August 12, 2026 09:35
@seonghobae
seonghobae enabled auto-merge (squash) August 12, 2026 09:36

@coderabbitai coderabbitai 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.

🧹 Nitpick comments (1)
src/test/java/com/clearfolio/viewer/analytics/KpiSnapshotLedgerTest.java (1)

89-98: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

허용 경계값 테스트를 추가하세요.

현재 테스트는 0.5만 유효한 비율로 사용하고 -0.01, 1.01만 거부합니다. rate의 허용 범위는 [0.0, 1.0]이므로 0.01.0을 성공적으로 로드하는 사례를 추가하세요. KpiSnapshotResponse.fromp95TimeToPreviewMs0L로 생성할 수 있으므로, 0도 성공 사례로 확인하세요. 이 테스트가 없으면 경계 조건이 잘못되어도 회귀 테스트가 통과할 수 있습니다.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/test/java/com/clearfolio/viewer/analytics/KpiSnapshotLedgerTest.java`
around lines 89 - 98, The rejectsNonFiniteOrOutOfRangePersistedKpiEvidence test
currently lacks valid boundary cases. Add successful-load assertions covering
rate values 0.0 and 1.0, plus p95TimeToPreviewMs equal to 0, using the existing
valid-ledger assertion/helper flow.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/test/java/com/clearfolio/viewer/analytics/KpiSnapshotLedgerTest.java`:
- Around line 89-98: The rejectsNonFiniteOrOutOfRangePersistedKpiEvidence test
currently lacks valid boundary cases. Add successful-load assertions covering
rate values 0.0 and 1.0, plus p95TimeToPreviewMs equal to 0, using the existing
valid-ledger assertion/helper flow.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f190d4fb-dd21-4208-b2f8-37939bb89dee

📥 Commits

Reviewing files that changed from the base of the PR and between b66b692 and c21bd4a.

📒 Files selected for processing (2)
  • src/main/java/com/clearfolio/viewer/analytics/KpiSnapshotLedger.java
  • src/test/java/com/clearfolio/viewer/analytics/KpiSnapshotLedgerTest.java

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