Skip to content

fix(ui): slop/duplicate trend card conflates two independently-nullable series into one shared 'latest week' reference #8667

Description

@JSONbored

⚠️ Definition of Done: this issue must be completed in full, in a single PR. Do not split this
work across multiple PRs, and do not defer any Deliverable below to a follow-up issue. A PR that
satisfies only some of the Deliverables, stubs a required test, or leaves a checkbox
partially-done does NOT resolve this issue and will be closed.

Context

apps/loopover-ui/src/components/site/app-panels/slop-duplicate-trend-card-model.ts:48-57's
latestWeekWithSignal finds the single most recent week with either signal present:

export function latestWeekWithSignal(weeks: SlopDuplicateTrendWeek[]): SlopDuplicateTrendWeek | null {
  for (let index = weeks.length - 1; index >= 0; index -= 1) {
    const week = weeks[index];
    if (!week) continue;
    if (week.slopFlagRatePct !== null || week.duplicateFlagRatePct !== null) return week;
  }
  return null;
}

slop-duplicate-trend-card.tsx:29,54-67 reuses this single latest result for BOTH the slop-flag
legend (latest?.slopBandLabel, latest?.slopFlagRatePct) and the duplicate-flag legend
(latest?.duplicateFlagRatePct). SlopDuplicateTrendWeek types both slopFlagRatePct and
duplicateFlagRatePct as independently nullable — so if the most recent week with any signal has
one series populated and the other null, the legend for the null series silently renders "—"/no
band even when an earlier week actually had real data for that series.

This is currently latent, not actively firing: today's backend generator
(src/services/maintainer-slop-duplicate-trend.ts) computes both rates from the same
openPullRequests denominator gate, so in practice the two series' null-ness stays in lockstep for
real production data. It is still a real, narrowly-scoped defect in a reusable helper that is
written generically and whose own type signature permits independent nullability — a latent bug
waiting for the backend generator to change (or a different caller to reuse this model), not a
hypothetical one.

Requirements

  • Compute the "latest week with signal" independently per series (one lookup for
    slopFlagRatePct, one for duplicateFlagRatePct), rather than one shared latest reused for
    both legends.
  • Do not change the current rendered output for real production data where both series' null-ness
    stays in lockstep (this must remain a behavior-preserving fix for today's data shape, only
    correcting the latent divergent-null case).

Deliverables

  • slop-duplicate-trend-card-model.ts exposes two independent "latest week with signal"
    lookups (or a single function parameterized by which series to check), one per series.
  • slop-duplicate-trend-card.tsx uses the correct per-series "latest" result for each legend,
    not one shared latest object.
  • A new test constructs a weeks array where the last signal-bearing week has one series null
    and an earlier week has that series populated, asserting the legend/band for that series
    reflects the earlier week's value — not "no signal".
  • Existing tests for the lockstep-null case (matching today's real production data shape)
    continue to pass unchanged.

All Deliverables above are required in the same PR.

Test Coverage Requirements

apps/** is excluded from codecov/patch gating, but apps/loopover-ui's own local vitest
coverage thresholds apply — the new test must exercise the divergent-null-per-series branch
directly, which has zero coverage today.

Expected Outcome

Each series in the slop/duplicate trend card independently reflects its own most recent
signal-bearing week, so a future change to the backend's null-generation logic (or a different
future caller of this model) cannot silently hide real data behind the other series' null value.

Links & Resources

  • apps/loopover-ui/src/components/site/app-panels/slop-duplicate-trend-card-model.ts:48-57
  • apps/loopover-ui/src/components/site/app-panels/slop-duplicate-trend-card.tsx:29,54-67
  • src/services/maintainer-slop-duplicate-trend.ts (the backend generator whose current denominator
    gate happens to keep both series' null-ness in lockstep today)

Metadata

Metadata

Assignees

No one assigned

    Labels

    gittensor:bugGittensor-scored bug fix — scores a 0.05x multiplier.help wantedExtra attention is needed

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions