Skip to content

fix(dashboards): stop falling back to legacy v1 health score - #2227

Open
gaspergrom wants to merge 8 commits into
mainfrom
fix/LFXV2-3379
Open

fix(dashboards): stop falling back to legacy v1 health score#2227
gaspergrom wants to merge 8 commits into
mainfrom
fix/LFXV2-3379

Conversation

@gaspergrom

@gaspergrom gaspergrom commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Issue: #2229

Org Lens' projects table and project-detail hero fell back to the legacy v1 classifyHealthScore() bucketing whenever the warehouse's v2 HEALTH_SCORE_CATEGORY_V2 was null, reintroducing on the Snowflake/BFF side the exact fallback anti-pattern already banned on the Tinybird side. korg (The Linux Kernel Organization) showed a stale "Fair" label instead of the correct no-score state, because its legacy HEALTH_OVERALL_SCORE_V2 was still non-null even though the v2 category had gone null.

Both services now derive the health label from normalizeHealthScoreCategoryV2(HEALTH_SCORE_CATEGORY_V2) only, with no fallback to the v1 score. healthMetrics/metricsState are gated on the four warehouse percentage columns independently of the category, so they don't disappear just because the label happens to be null, and don't fabricate 0% for a dimension the warehouse hasn't measured. Response cache keys were bumped to drop rows computed under the old fallback logic.

This branch also fixes a regression independently reintroduced by IN-1262 (merged to main as fc7dc2544 while this ticket was in flight). That PR's mapHealthScore() fell back to classifyHealthScore(row.HEALTH_OVERALL_SCORE_V2 ?? 0) whenever the v2 category was null — the same anti-pattern this ticket removes. Rebasing onto the merged main surfaced the conflict and confirmed it; this branch's fix wins, and IN-1262's new healthMaxScore/healthCoveredCategoryCount fields (used for the partial-Health-Score UI treatment) are preserved unchanged.

Commits

  • stop falling back to legacy v1 health score — the projects-table fix
  • fix legacy v1 health fallback in detail hero too — same fix in the sibling detail-hero service
  • stop fabricating health data on round-2 review findings — AND-gate the four warehouse percentage columns instead of OR
  • drop dead HEALTH_OVERALL_SCORE_V2 field — remove the now-unused column from the shared row interface
  • log unrecognized v2 health category — WARN log when a non-null category fails to parse, so that case stays distinguishable from "not yet backfilled"

Test plan

  • yarn workspace lfx-one-ui test:server — 104 files / 2744 tests pass, including cases for: v2 category present, v2 category null, v2 category unrecognized (WARN logged), metrics present/partial/absent independent of the category.
  • yarn build and yarn lint:check clean.
  • No Tinybird or insights repo changes — Tinybird's health-label pipeline was already correct; this fix is isolated to lfx-self-serve's Snowflake/BFF mapping layer.

Org Lens Projects' health-score mapping fell back to legacy v1
classifyHealthScore() bucketing whenever the warehouse's v2
HEALTH_SCORE_CATEGORY_V2 was null, reintroducing on the Snowflake/BFF
side the fallback anti-pattern already banned on the Tinybird side.
This made projects like The Linux Kernel Organization show a stale
"Fair" label instead of the correct no-score state.

hasHealthScore()/mapHealthScore() now require a resolvable v2 category
and never fall back to the v1 score. Cache key bumped v3 -> v4 to drop
stale cached rows computed under the old fallback logic.

LFXV2-3379

Signed-off-by: Gašper Grom <gasper.grom@gmail.com>
LFXV2-3379

Extends the fix already applied to the Org Lens projects table to the
project detail hero, which independently reintroduced the same anti-pattern:
mapHealth() fell back to classifyHealthScore(overallScoreV2) whenever the v2
category was null, so a project could show "Unavailable" on the projects
table but a stale v1-derived band on its own detail page. mapHealth() now
returns the normalized v2 category only, matching the projects table.

Also tightens the projects table fix itself: hasHealthScore() no longer
requires the legacy HEALTH_OVERALL_SCORE_V2 column to be non-null (the v2
category alone is authoritative), and healthMetrics/metricsState are now
gated on the warehouse percentage columns being present, independent of
whether the health label's category happens to be null.

Signed-off-by: Gašper Grom <gasper.grom@gmail.com>
LFXV2-3379: fix-forward round 2 reviewer trio findings on the org-lens
health label/metrics fix. hasHealthMetrics() required only one of the
four warehouse percentage columns to be present, so roundMetric()'s
null-to-0 default fabricated a 0% value for genuinely-unmeasured
dimensions on partially-populated rows; it now requires all four.
Also bumps the projects and project-detail-hero response cache keys to
drop entries computed under the old logic, removes the now-dead
HEALTH_OVERALL_SCORE_V2 column from both services' queries, and
corrects two stale comments left over from the prior fix.

Signed-off-by: Gašper Grom <gasper.grom@gmail.com>
LFXV2-3379: round-3 reviewer trio finding. c24b79237/82ba2c837 already
removed HEALTH_OVERALL_SCORE_V2 from both services' SQL SELECTs, but
left it declared on the shared OrgLensProjectRow interface — a
row-interface/SELECT mismatch that would silently resolve to undefined
at runtime with no compile error. Removes the dead field and the
now-decorative test fixture keys/overrides that referenced it, and
retitles the affected tests to what they actually pin.

Signed-off-by: Gašper Grom <gasper.grom@gmail.com>
LFXV2-3379: full-branch reviewer trio finding (self-serve-code-review,
confirmed independently by self-serve-learnings-review). A non-null but
unparseable warehouse health_score_category_v2 silently degraded to
"unavailable" with no signal, indistinguishable from a project the
warehouse hasn't backfilled yet. Adds a WARN log in both services'
health mapping when the raw category is present but
normalizeHealthScoreCategoryV2 returns null.

Also rewrites classifyHealthScore's stale JSDoc, which still claimed to
be the shared classifier for both services after this branch removed
both of their calls to it in favor of the warehouse-computed category.

Signed-off-by: Gašper Grom <gasper.grom@gmail.com>
@gaspergrom
gaspergrom requested a review from a team as a code owner September 7, 2026 16:32
Copilot AI balanced review requested due to automatic review settings September 7, 2026 16:32
@coderabbitai

coderabbitai Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Essentials

Run ID: 3d66c889-fbfd-449f-82ba-c3ffb4f03394

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Comment @coderabbitai help to get the list of available commands.

@cursor

cursor Bot commented Sep 7, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Changes Snowflake/BFF health mapping and cached API payloads across Org Lens projects and project detail; behavior shifts for projects that previously showed v1-derived bands, though cache bumps and tests mitigate rollout risk.

Overview
LFXV2-3379 stops Org Lens from inferring health bands from the legacy v1 numeric score when Snowflake’s HEALTH_SCORE_CATEGORY_V2 is missing, null, or unrecognized. The projects list BFF and project-detail hero now treat the warehouse v2 category as the only source for the overall label (unavailable when it can’t be normalized), drop HEALTH_OVERALL_SCORE_V2 from queries/types, and bump Valkey cache keys so stale “Fair”-style rows aren’t served.

The project-detail hero’s healthMeta() now returns the shared Unavailable badge styling when health is null so the Health score section still renders, aligned with the projects table.

Health breakdown metrics are decoupled from the top-level label: healthMetrics are emitted only when all four warehouse percentage columns are present (avoiding fabricated 0% for partial data). Unrecognized non-null categories trigger a WARN log. Shared utils/docs clarify that callers must not fall back to classifyHealthScore().

Reviewed by Cursor Bugbot for commit 8ccd768. Bugbot is set up for automated code reviews on this repo. Configure here.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Removes legacy health-score fallback logic from Org Lens project summaries and detail heroes.

Changes:

  • Uses warehouse v2 categories exclusively.
  • Preserves independently available health metrics and partial-score metadata.
  • Updates cache versions, warnings, types, and unit tests.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/shared/src/utils/insights.utils.ts Documents v2 category authority.
packages/shared/src/interfaces/org-lens-projects.interface.ts Removes the obsolete raw score field.
apps/lfx-one/src/server/services/org-lens-projects.service.ts Revises list mapping, metrics gating, logging, and caching.
apps/lfx-one/src/server/services/org-lens-projects.service.spec.ts Tests category and metric availability behavior.
apps/lfx-one/src/server/services/org-lens-project-detail.service.ts Revises hero mapping, query, logging, and caching.
apps/lfx-one/src/server/services/org-lens-project-detail.service.spec.ts Tests category-only hero behavior.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread apps/lfx-one/src/server/services/org-lens-project-detail.service.ts Outdated
Comment thread apps/lfx-one/src/server/services/org-lens-projects.service.ts Outdated
LFXV2-3379: the project-detail hero omitted the health badge entirely
when the warehouse has no v2 health category, since healthMeta()
returned null and the template's @if has no @else. Render the same
"Unavailable" tag the Org Lens projects table already shows for this
case instead of hiding the section.

Signed-off-by: Gašper Grom <gasper.grom@gmail.com>
Copilot AI review requested due to automatic review settings September 7, 2026 18:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Comment thread apps/lfx-one/src/server/services/org-lens-projects.service.ts
Comment thread apps/lfx-one/src/server/services/org-lens-project-detail.service.ts
LFXV2-3379

- treat an empty-string warehouse category as malformed, not null, so the
  unrecognized-category WARN log still fires (mapHealth, mapProject)
- stop surfacing populated healthMetrics on a row with no health category,
  so metricsState and healthMetrics agree on what unavailable means
- correct two stale doc comments left over from the v1-fallback removal

Signed-off-by: Gašper Grom <gasper.grom@gmail.com>
Copilot AI review requested due to automatic review settings September 7, 2026 18:59

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 8da878d. Configure here.

Comment thread apps/lfx-one/src/server/services/org-lens-projects.service.ts Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Suppressed comments (1)

apps/lfx-one/src/server/services/org-lens-projects.service.ts:422

  • This comment now describes behavior that line 536 explicitly prevents: when the normalized category is null, healthMetrics is always empty even if all percentage columns are populated. Update it to document the category gate so future changes do not restore the inconsistent unavailable-label/metrics combination.
    // mapProject fills unselected org-relative metrics with placeholders and maps health/healthMetrics from the
    // columns above. metricsState here reflects only the health label (category present → 'health-only'; null →
    // 'unavailable') — healthMetrics is gated independently inside mapProject and may still be populated on an
    // 'unavailable' row if the warehouse percentage columns are present without a category.

Comment thread apps/lfx-one/src/server/services/org-lens-projects.service.spec.ts
LFXV2-3379: revert the category-gate added in the last round-2 fix
commit. It suppressed the metrics breakdown whenever the v2 category
was unresolvable, even when the warehouse percentage columns were
genuinely populated — the opposite of the no-fallback approach this
ticket targets. Insights renders each health sub-score off its own
null-ness independent of the top-level label; healthMetrics should do
the same. Restores the pre-existing (and still test-covered) behavior.

Signed-off-by: Gašper Grom <gasper.grom@gmail.com>
Copilot AI review requested due to automatic review settings September 7, 2026 19:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.

@gaspergrom
gaspergrom requested a review from MRashad26 September 7, 2026 19:51
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.

2 participants