Skip to content

fix(dashboard): high-impact metric reflects active filters + codebase audit#131

Merged
edu-diaz merged 2 commits intomainfrom
fix/dashboard-high-impact-filter-and-cleanup
Apr 4, 2026
Merged

fix(dashboard): high-impact metric reflects active filters + codebase audit#131
edu-diaz merged 2 commits intomainfrom
fix/dashboard-high-impact-filter-and-cleanup

Conversation

@edu-diaz
Copy link
Copy Markdown
Contributor

@edu-diaz edu-diaz commented Apr 4, 2026

Summary

  • Fix high-impact metric: The "high impact" count in the dashboard stats bar now updates dynamically based on all active filters (name, source, and status). Previously it used baseFiltered which intentionally excluded the status filter for pill counts, but the high-impact number should reflect the currently visible set.
  • Extract shared filtering helpers: countHighImpact() and filterServices() extracted into format.ts as tested, reusable functions. This consolidates duplicate filtering logic between StatsBar.svelte and ServiceListView.svelte.
  • Add 17 tests: Full coverage for countHighImpact (threshold, edge cases) and filterServices (name, source, status, combined filters, and the specific high-impact-with-status-filter scenario).

What changed

File Change
StatsBar.svelte Derive fullyFiltered (applies status filter on top of baseFiltered), use countHighImpact()
format.ts Add countHighImpact() and filterServices() shared helpers
format.test.ts 17 new tests for the helpers
ServiceListView.svelte Use filterServices() instead of inline duplicate filtering logic
ui/ Rebuilt production bundle

Codebase audit findings

What was reviewed

  • Full Go backend (pkg/, internal/)
  • Dashboard frontend (pkg/dashboard/frontend/src/)
  • All documentation (docs/, README.md)
  • Validation layer (pkg/validation/crossfield.go)
  • Stale comments (grep for TODO/FIXME/HACK/XXX)

What was found and addressed

  • Bug: High-impact metric not reacting to status filter → fixed
  • DRY violation: Filtering logic duplicated between StatsBar and ServiceListView → extracted to filterServices()
  • Testability: High-impact threshold was an inline magic number → extracted as HIGH_IMPACT_THRESHOLD constant

What was found but intentionally NOT changed

  • Validator duplication in crossfield.go: The four validateXxxNamesUnique functions and the validateHealthInterface/validateMetricsInterface pair follow identical patterns. A generic helper could save ~60 lines, but the current explicit approach is more readable and debuggable. Each validator has distinct error codes and field paths, making the duplication intentional and low-risk. Not worth the abstraction cost.
  • Server struct size (pkg/dashboard/server.go): The Server struct has grown to 16 fields with multiple concerns (routing, aggregation, enrichment, caching). This is acknowledged complexity given the dashboard's scope. Would benefit from extraction into a SourceManager if it grows further, but no action needed now.
  • Architecture docs: The dashboard section in docs/architecture.md could be expanded to better reflect the actual scope (20+ source files, 27 types), but the current documentation is accurate — just concise.
  • Documentation: README, quickstart, architecture, CLI reference, and all feature docs were audited and found to be accurate and aligned with the implementation. No stale content detected.
  • No stale comments: Zero TODO/FIXME/HACK/XXX markers in the entire Go codebase.

Test plan

  • Frontend tests: 217 tests pass (5 files, including 17 new tests)
  • Go tests: all packages pass
  • go vet: clean
  • Frontend build: compiles successfully
  • Verify high-impact count updates on status filter change
  • Verify high-impact count updates on name filter
  • Verify high-impact count resets when filters are cleared
  • Verify combined filters work correctly

edu-diaz added 2 commits April 4, 2026 21:16
The "high impact" metric in StatsBar was computed from baseFiltered,
which excludes the status filter. This meant the count stayed static
when users filtered by Compliant/Warning/NonCompliant status.

Extract countHighImpact() and filterServices() into format.ts as shared
helpers, compute highBlastCount from the fully filtered set (including
status), and consolidate duplicate filtering logic in ServiceListView.

Add 17 tests covering countHighImpact and filterServices behavior,
including the specific scenario where status filtering should reduce
the high-impact count.
…, add pull_failed reason

classifyOCIError() incorrectly returned "not_found" for all unrecognised
errors, including RegistryUnreachableError (network/DNS failures). This
masked transient failures as missing artifacts. Now properly classifies
registry unreachable errors as "pull_failed" — a reason code already
documented in graph.go and source_oci.go but never wired up.

Additional cleanup:
- Extract collectOCIRepos() from depReposForService() to eliminate
  triple duplication of the extract+strip pattern
- Unexport version_tracking.go functions (NormalizeResolutionPolicy,
  ClassifyVersionPolicy, ComputeLatestAvailable, IsUpdateAvailable,
  MarkCurrentVersion) — all only used within the dashboard package
- Add pull_failed reason to frontend (label, tooltip, badge, actionable)
- Update tests for new error classification and reason handling
@edu-diaz edu-diaz merged commit 375660d into main Apr 4, 2026
13 checks passed
@edu-diaz edu-diaz deleted the fix/dashboard-high-impact-filter-and-cleanup branch April 4, 2026 19:28
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