Skip to content

fix(metrics-core): normalize user capacity by the configured lookback - #3488

Merged
kang-heewon merged 2 commits into
trunkfrom
fix/3218-user-capacity-lookback
Oct 11, 2026
Merged

kang-heewon merged 2 commits into
trunkfrom
fix/3218-user-capacity-lookback

Conversation

@kang-heewon

@kang-heewon kang-heewon commented Oct 11, 2026 •

Copy link
Copy Markdown
Member

Closes #3218.

User carrying capacity now converts the full lookback period's NRR into daily churn using lookbackDays. Constant daily inflow of 100 and decline of 0.01/day therefore produce capacity 10000 for 1, 7, 30 and 60-day samples. Days retain the existing local calendar-date semantics across DST; the 30-day result and invalid-input failure behavior are preserved.

Validation

Standard profile: bounded single-package formula correction, with no public API shape, provider query or dependency changes. Includes a metrics-core patch changeset.

  • Negative control: the original formula fails the 1/7/60-day regressions; 30 days passes.
  • TZ=UTC pnpm --filter @croco/metrics-core test: 330 tests pass.
  • TZ=America/New_York pnpm --dir packages/metrics-core exec vitest run src/tests/CarryingCapacity.spec.ts: 46 tests pass, including calendar windows crossing spring DST.
  • Affected package typecheck/lint and 10-package dependency build: pass. Initial missing declaration artifacts were repaired by building dependencies.
  • Independent code review: PASS; repository/retention boundaries and callers inspected, no findings.
  • Final source cleanup review: no changes required.
  • Review companion selected architecture/public API/repository gates: pass. pnpm check: 28 pass, 1 not applicable; the first architecture check overlapped a dependency rebuild and passed when rerun after the build.
  • Normal pre-push full tests: 311/311 tasks pass. Guarded full typecheck: 328/328 tasks pass; tracked files unchanged.

The generated API reference correction documents the logarithmic formula and local calendar-day configuration. pnpm docs:api:check passes, and the metrics-core source/test tree is identical to the reviewed implementation. The earlier local Chromium shutdown timeout did not recur: the unchanged browser test passes all three tests in 927ms. Normal push completed for head fc9f999a1329beaaab8ae07252103b64cdf074d0: full tests pass 311/311 tasks, guarded full typecheck passes 328/328 tasks, and the checkout remains clean.

Visual evidence

The exact two generated Markdown files render through the existing Astro/Starlight configuration using the repository's isolated build-root pattern. Screenshots show locale-valid test fixture routes at 1440×1000; no console/page errors or horizontal overflow were observed. This copy-only correction introduces no interaction change.

  • Calculator formula: isolated locale fixture /en/api/metrics-core/src/classes/carryingcapacitycalculator/.
  • Calendar-day configuration: isolated locale fixture /en/api/metrics-core/src/type-aliases/userccconfig/.

Known pre-existing limitation: canonical /api/... pages return 404 because TypeDoc root output does not match Starlight's locale prefix. The fixture verifies the changed Markdown rendering, not deployment routing, and does not change the product's route behavior.

Calculator formula, isolated locale fixture, 1440x1000
Calendar-day configuration, isolated locale fixture, 1440x1000

CI and merge status

Head: fc9f999a1329beaaab8ae07252103b64cdf074d0. Assessed base: 6d6863ffa1f760e63ddfdde491e263ee99456a3a.

All required checks and selected optional checks pass on this head: CI, review companion, and benchmark. GitHub reports MERGEABLE/CLEAN. No unresolved review threads or requested changes remain; actual rules require zero approvals.

Cumulative trunk drift includes unrelated metric-expression grouping, admin generation, QStash failure handling, Problem registry metadata, HTTP nullable responses, saga compensation and protocol/CLI schema compatibility classification. It does not interact with the carrying-capacity calculation or retention/provider contract. No rebase was needed; source review and regression evidence remains applicable to the byte-identical metrics-core source/test tree.

Summary by CodeRabbit

  • 개선 사항
    • 사용자 수용량 계산에서 고정된 30일 기준 대신 설정된 조회 기간을 사용해 일일 이탈률을 계산합니다.
    • 조회 기간은 현지 달력 날짜 기준으로 적용되며, 일광 절약 시간 변경도 반영됩니다.

Copilot AI balanced review requested due to automatic review settings October 11, 2026 02:46

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 93d16a41-03f5-4f91-b41e-ef165d57a5d3









📥 Commits

Reviewing files that changed from the base of the PR and between c18f79a and b828192.










📒 Files selected for processing (3)
  • .changeset/metrics-user-capacity-lookback.md
  • packages/metrics-core/src/libs/CarryingCapacityCalculator.ts
  • packages/metrics-core/src/tests/CarryingCapacity.spec.ts









Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.











📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough

Walkthrough

사용자 수용 용량 계산에서 일일 이탈률을 산출할 때 고정된 30일 대신 설정된 lookbackDays를 사용합니다. 1일, 7일, 30일, 60일 기간을 검증하는 테스트와 @croco/metrics-core의 patch changeset을 추가합니다.

Changes

사용자 수용 용량 계산

Layer / File(s) Summary
일일 이탈률 계산과 기간별 검증
packages/metrics-core/src/libs/CarryingCapacityCalculator.ts, packages/metrics-core/src/tests/CarryingCapacity.spec.ts, .changeset/metrics-user-capacity-lookback.md
calculateUserCC가 일일 이탈률 계산에 lookbackDays를 사용합니다. 설명은 조회 기간이 로컬 달력 날짜 기준임을 명시합니다. 테스트는 1, 7, 30, 60일 lookback에서 메트릭 조회 기간과 계산 결과를 확인합니다. 테스트의 import 경로를 부모 모듈로 변경하고 patch changeset을 추가합니다.

Priority: ➖ Normal

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

Change: Bug fix · Severity of issue fixed: Medium






































Merge Risk: ⚪ Minimal · up to b8281

No actionable merge-blocking risk is identified; the change is ready to merge after normal checks.

Pre-merge checks | Passed 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check Passed 직접 연결된 활성 이슈 #3218의 코딩 요구사항을 충족합니다. calculateUserCC는 전체 lookback 기간의 retention.nrr를 설정된 lookbackDays로 환산합니다. 이에 따라 1, 7, 30, 60일 테스트에서 동일한 일일 이탈률과 capacity를 검증합니다. 30일 계산 결과와 로컬 달력 날짜 및 DST 의미를 …
Out of Scope Changes check Passed 변경 범위는 #3218의 기간 환산 오류 수정에 한정됩니다. 소스 변경은 calculateUserCC의 공식 설명과 lookbackDays 사용이며, 테스트는 해당 기간 불변성과 기존 동작을 검증합니다. metrics-core patch changeset도 이 수정의 배포 문서입니다. 관련 없는 도메인 모델, RevenueCC, provider …
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed 제목은 설정된 lookback을 사용해 사용자 수용 용량을 정규화하는 핵심 변경을 정확하고 간결하게 설명합니다.

✨ Finishing Touches 💡 1
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR










🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR











🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR











  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@github-actions

github-actions Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

📊 Benchmark Results

✅ All benchmarks passed

Benchmark p75 Threshold Baseline vs Baseline Status Notes
CrocoApp constructor 8.5μs 30.0ms 8.2μs +3.4% ✅ -
CrocoApp lambdaHandler (10 controllers) 1.0ms 50.0ms 258.4μs +305.0% ❌ -
Lambda cold-start simulation 1.1ms 80.0ms 418.1μs +173.7% ❌ -
Lambda cold-start with headers 1.1ms 80.0ms 369.7μs +187.0% ❌ -
Lambda cold-start with binary body 1.1ms 80.0ms 339.1μs +211.1% ❌ -
Lambda cold-start with query params 1.0ms 80.0ms 301.3μs +236.2% ❌ -
Lambda cold-start with authorizer context 1.0ms 80.0ms 299.8μs +245.9% ❌ -
Lambda cold-start realistic scenario 1.0ms 80.0ms 299.2μs +236.3% ❌ -
EventBusConfig.start (10 handlers) 4.6μs 10.0ms 1.4μs +222.9% ❌ -
EventPublisher.publishNow single event 2.3μs 2.0ms 1.7μs +36.8% ❌ -
DefaultHandlerResolver.resolve × 10 0.2μs 5.0ms 0.1μs +87.5% ❌ -
Container.get singleton (cold) 57.8μs 5.0ms 70.3μs -17.7% ✅ -
Container.register × 50 components 2.2ms 10.0ms 3.2ms -32.7% ✅ -
Container.validate (50 components) 2.5ms 20.0ms 3.4ms -26.9% ✅ -
Container.get singleton (warm) 0.7μs 500.0μs 1.6μs -55.2% ✅ -
TelemetryRuntime.init (lambda preset) 9.7μs 200.0ms 1.1ms -99.1% ✅ -
lambdaPreset config creation 1.1μs 2.0ms 1.4μs -21.8% ✅ -

Updated: 2026-10-11T12:13:35.059Z · Commit: fc9f999

@kang-heewon
kang-heewon merged commit 5ea4425 into trunk Oct 11, 2026
21 checks passed
@kang-heewon
kang-heewon deleted the fix/3218-user-capacity-lookback branch October 11, 2026 12:50
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.

[metrics-core] calculateUserCC가 임의 lookback 기간의 NRR을 항상 30일로 환산해 수용 한계를 왜곡한다

2 participants