fix(nutrition): explain adaptive TDEE evidence - #2342
Conversation
Replace uncalibrated confidence with server-owned fit evidence and an observed rolling range. Seed canonical review body-weight samples without replacing unrelated sensor data.\n\nRefs #2137
|
🤖 Review skipped: Repository rate limit exceeded. Free accounts are limited to 2 reviews per 4 hours per repository. Upgrade to a paid plan for unlimited reviews. |
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
|
Warning Review limit reached
Next review available in: 18 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the 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 configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (24)
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. Comment |
Reviewer's GuideRefactors adaptive TDEE to operate on dense calendar-day windows with explicit evidence and unavailability reasons, wires that new contract through the server, web, mobile, and review ClickHouse seed, and adds deterministic body-weight samples plus tests and docs for the review fixture. Sequence diagram for adaptive TDEE estimation with evidencesequenceDiagram
actor Client
participant Router as nutritionAnalyticsRouter
participant Repo as NutritionAnalyticsRepository
participant CH as ClickHouse
participant Estimator as adaptiveTdeeEngine
Client->>Router: adaptiveTdee({ days })
Router->>Repo: getAdaptiveTdee(days)
Repo->>Repo: getAdaptiveTdeeData(days)
Repo->>CH: query fitness.v_nutrition_daily
Repo->>CH: query analytics.daily_body_measurement
CH-->>Repo: AdaptiveTdeeDataPoint[]
Repo->>Repo: buildAdaptiveTdeeCalendar(sourceData, days, today, accessWindow)
Repo->>Repo: smoothWeightData(calendar)
Repo->>Estimator: estimateTdee(smoothedData, days)
Estimator-->>Repo: AdaptiveTdeeResultData
Repo->>Router: new AdaptiveTdeeEstimate(result)
Router-->>Client: AdaptiveTdeeResult (status, estimateRange, evidence, dailyData)
File-Level Changes
Assessment against linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
PR Summary by QodoExplain adaptive TDEE availability with server-owned evidence and seeded weights
AI Description
Diagram
High-Level Assessment
Files changed (22)
|
Mobile PreviewScan to open on device:
To test on device:
|
|
Storybook previews for This comment updates automatically on each PR push. |
Code Review by Qodo
Context used✅ Compliance rules (platform):
208 rules✅ Skills:
fix-provider, write-tests, cloudflare 1.
|
Use one timezone-local date boundary, bound all-time evaluation, name metric-stream seed columns, and cover estimator thresholds for mutation testing. Refs #2137
|
🤖 Review skipped: Repository rate limit exceeded. Free accounts are limited to 2 reviews per 4 hours per repository. Upgrade to a paid plan for unlimited reviews. |
Summary
Root cause
The review fixture populated Postgres DEXA rows but no canonical ClickHouse
body_weightsensor samples. Adaptive TDEE reads weight only through the deduped ClickHouse body-measurement model, so retries could never produce an estimate. The estimator also treated 28 available nutrition rows as 28 calendar days and exposed a weight-row ratio as confidence.Validation
pnpm test:changed(14 files, 127 tests)pnpm --filter @dofek/server typecheckpnpm --filter @dofek/web typecheckpnpm --filter @dofek/mobile typecheckpnpm lint:sandbox+daily_body_measurementThe full local analytics integration suite could not complete because the shared Docker VM repeatedly restarted ClickHouse while many workspace containers were active. Focused real-engine coverage and the production repository path passed; CI will run the isolated suite. Root
pnpm lintalso reaches unchanged analytics SQL and fails on pre-existing sqlfluff CP04/LT08 behavior; all changed-code lint gates pass viapnpm lint:sandbox.Fixes #2137
Summary by Sourcery
Explain adaptive TDEE availability using canonical ClickHouse body-weight samples, dense calendar evaluation, and server-owned evidence, and render the new evidence contract consistently on web and mobile.
New Features:
Bug Fixes:
Enhancements:
Documentation:
Tests:
Summary by cubic
Replaced adaptive TDEE “confidence” with server-owned fit evidence and an observed rolling range, and seeded deterministic canonical body-weight data so the review fixture produces estimates on web and mobile. Uses one timezone-local end date across stores and bounds “All time” evaluation to 365 days. Fixes #2137.
New Features
status,unavailableReason,evidence(fit window, coverage, exclusions), andestimateRange; builds dense calendar days, intersects access windows, and uses a single user-timezone end date.body_weightrows into canonicalingest.metric_stream, tombstoning only priorreview-seed-body-weight-*rows; all metric-stream columns are named and unrelated sensor rows are preserved.Migration
confidenceanddataPoints. Usestatus,estimateRange,unavailableReason, andevidence.dailyData.caloriesInmay benull, anddailyDataincludesnutritionStatusandlowerPrioritySourcesExcluded.pnpm review:seed-clickhouseto add canonical weight samples.Written for commit b81f29e. Summary will update on new commits.