Skip to content

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

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

fix(analytics): reject invalid KPI numeric evidence on current main#421
seonghobae wants to merge 4 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

Reject impossible numeric KPI evidence during durable snapshot replay.

Exact current-head evidence

  • protected base: 961f44a19c4ced87f8062b3ab9842a9a08d05235;
  • test-only RED head: 6610529acb9b6bdf41c1f7d5d491dbf00fdfef7e;
  • exact GREEN head: 2c7d16752eddd675593c760d3da00d781b7b74f4;
  • CI, Security Scan, SAST Semgrep, and fuzz: terminal-success;
  • mergeable: true;
  • unresolved review threads: zero.

Contract

Persisted NaN, positive/negative infinity, rates outside [0,1], and negative p95 preview latency fail closed through the existing controlled invalid-line error instead of entering buyer-visible analytics.

Scope boundary

KPI replay numeric integrity only. Denominator semantics, tenant query isolation, API shape, and canonical documentation are unchanged.

Merge gate

Keep this exact head unchanged. Auto-merge may act only after live checks remain successful, zero valid unresolved findings remain, and a qualifying independent non-author approval is attached to this exact head. Automated evidence and predecessor reviews do not transfer.

@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: 32 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: 3ce76465-d7b9-4960-969e-bd106a99accf

📥 Commits

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

📒 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
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 제목은 현재 main에서 잘못된 KPI 숫자 증거를 거부하는 핵심 변경을 정확하고 간결하게 설명합니다.
✨ 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

Copy link
Copy Markdown
Collaborator Author

Exact-current-head read-only review request for 2c7d16752eddd675593c760d3da00d781b7b74f4 on protected main 961f44a19c4ced87f8062b3ab9842a9a08d05235. CI, Security Scan, SAST Semgrep, and fuzz are terminal-success; the two-file analytics-integrity delta is mergeable with zero unresolved threads. Verify fail-closed non-finite/out-of-domain KPI replay while preserving the existing controlled invalid-line boundary. Do not mutate the branch or bypass independent approval.

@opencode-agent review
@cwl-noema-review review
@strix review
@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 14, 2026

Copy link
Copy Markdown
🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

head_commit="2c7d16752eddd675593c760d3da00d781b7b74f4"
base_commit="961f44a19c4ced87f8062b3ab9842a9a08d05235"

echo "== Repository state =="
git rev-parse HEAD
git cat-file -t "$head_commit"
git cat-file -t "$base_commit"
git merge-base --is-ancestor "$base_commit" "$head_commit" && echo "BASE_IS_ANCESTOR=true" || echo "BASE_IS_ANCESTOR=false"

echo "== Requested diff =="
git diff --check "$base_commit" "$head_commit"
git diff --find-renames --unified=80 "$base_commit" "$head_commit" -- \
  src/main/java/com/clearfolio/viewer/analytics/KpiSnapshotLedger.java \
  src/test/java/com/clearfolio/viewer/analytics/KpiSnapshotLedgerTest.java

echo "== Production file outline =="
ast-grep outline src/main/java/com/clearfolio/viewer/analytics/KpiSnapshotLedger.java --items all --view expanded

echo "== Test file outline =="
ast-grep outline src/test/java/com/clearfolio/viewer/analytics/KpiSnapshotLedgerTest.java --items all --view expanded

echo "== Validation and replay call sites =="
rg -n -C 5 -P '\b(KpiSnapshotLedger|Double\.parseDouble|Double\.isFinite|nullableLong|invalid line|read|parse|replay)\b' \
  src/main/java src/test/java

Length of output: 101296


@seonghobae Reviewed the requested head 2c7d16752eddd675593c760d3da00d781b7b74f4 against baseline 961f44a19c4ced87f8062b3ab9842a9a08d05235.

No findings.

rate() rejects NaN, both infinity values, and values outside [0.0, 1.0]. nullableLong() rejects negative p95 values. Each new rejection uses the existing controlled error message: "kpi snapshot ledger contains an invalid line".

The regression tests cover the invalid values and the inclusive valid boundaries. The diff has no whitespace errors. This review did not modify the branch.

⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown
Collaborator Author

@opencode-agent review
@coderabbitai review
@cwl-noema-review review
@strix review

Review exact head 2c7d16752eddd675593c760d3da00d781b7b74f4 only. Exact-head CI, Security Scan, SAST Semgrep, and fuzz are terminal-success; unresolved inline findings are zero. Verify fail-closed replay for NaN, infinities, rates outside [0,1], and negative p95 preview latency without changing KPI denominator semantics or tenant scope.

Review read-only; preserve independent reviewer identity. Do not mutate the branch, synthesize author approval, weaken protection, or merge.

@coderabbitai

coderabbitai Bot commented Aug 15, 2026

Copy link
Copy Markdown
🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

head_commit="2c7d16752eddd675593c760d3da00d781b7b74f4"
base_commit="961f44a19c4ced87f8062b3ab9842a9a08d05235"
prod="src/main/java/com/clearfolio/viewer/analytics/KpiSnapshotLedger.java"
test="src/test/java/com/clearfolio/viewer/analytics/KpiSnapshotLedgerTest.java"

echo "== Exact commit verification =="
printf 'HEAD='
git rev-parse HEAD
printf 'REQUESTED_HEAD='
git rev-parse "$head_commit"
printf 'BASE='
git rev-parse "$base_commit"
git merge-base --is-ancestor "$base_commit" "$head_commit" && echo "BASE_IS_ANCESTOR=true"
git diff --check "$base_commit" "$head_commit"

echo "== Changed paths =="
git diff --name-status "$base_commit" "$head_commit"

echo "== Requested diff =="
git diff --find-renames --unified=70 "$base_commit" "$head_commit" -- "$prod" "$test"

echo "== Production outline =="
ast-grep outline "$prod" --items all --view expanded

echo "== Test outline =="
ast-grep outline "$test" --items all --view expanded

echo "== Production validation and parse boundary =="
rg -n -C 12 -P '\b(rate|nullableLong|Double\.parseDouble|Double\.isFinite|invalidLine|invalid line|read|parse)\b' "$prod"

echo "== Regression tests for numeric replay data =="
rg -n -C 10 -P '\b(NaN|Infinity|POSITIVE_INFINITY|NEGATIVE_INFINITY|rate|p95|invalidLine|invalid line|replay|ledger)\b' "$test"

echo "== KPI denominator and tenant-scope references in changed production file =="
rg -n -C 8 -P '\b(denominator|tenant|Tenant|query|rate|snapshot)\b' "$prod"

Length of output: 33247


@seonghobae Reviewed exact head 2c7d16752eddd675593c760d3da00d781b7b74f4 against baseline 961f44a19c4ced87f8062b3ab9842a9a08d05235.

No findings.

rate() rejects NaN, positive infinity, negative infinity, and values outside the inclusive range [0.0, 1.0]. nullableLong() rejects negative p95 preview latency. Each rejection preserves the existing controlled error message: "kpi snapshot ledger contains an invalid line".

The replay field mapping remains unchanged. KPI denominator values and tenant filtering remain unchanged. The regression tests cover invalid replay values and valid inclusive boundaries.

The review was read-only. I did not mutate the branch, approve, merge, or change repository protections. I did not execute tests in this inspection; I considered the reported terminal-success checks as supplied context.

⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown
Collaborator Author

Superseded by current-main PR #437.

The exact #421 numeric-integrity delta has been test-first reconciled into #437's versioned terminal-outcomes ledger on current protected base: persisted NaN, infinities, rates outside [0,1], and negative p95 preview latency now fail through the controlled invalid-line boundary, while inclusive 0/1 rate and zero-latency boundaries remain valid. Keeping two branches that both modify KpiSnapshotLedger.java and its regression would create an unsafe competing merge order and risk losing either metric-version migration or numeric validation.

#437 now owns the combined denominator-version migration and domain-valid durable numeric contract. No check, review, or approval evidence from #421 transfers to #437's new head.

@seonghobae seonghobae closed this Aug 15, 2026
auto-merge was automatically disabled August 15, 2026 11:42

Pull request was closed

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