Skip to content

Cleanup: shared MatchScorer + remove dead import code (follow-up to #494)#498

Merged
ericgriffin merged 5 commits into
mainfrom
worktree-dive-matcher-cleanup
Jul 6, 2026
Merged

Cleanup: shared MatchScorer + remove dead import code (follow-up to #494)#498
ericgriffin merged 5 commits into
mainfrom
worktree-dive-matcher-cleanup

Conversation

@ericgriffin

@ericgriffin ericgriffin commented Jul 6, 2026

Copy link
Copy Markdown
Member

Follow-up to #494, addressing the four tech-debt items surfaced while investigating the dive-matching / file-import-consolidation work. Pure cleanup + one behavior-preserving refactor — no user-facing behavior change.

Stacked on #494 (base branch worktree-dive-match-consolidate). Merge #494 first; GitHub will retarget this to main afterward. The shared-scorer commit builds on #494's DiveMatcher time-gate, and the consolidation-UI removal keeps performConsolidations alive precisely because #494 wired it into UniversalAdapter.

1. Remove inert matcher params (7a71b3a)

findMatchingDiveWithScore declared a fingerprint param it never read (fingerprint matching happens upstream in detectDuplicate), and detectDuplicate declared an unused depthTolerance. Removed both (one real call site; zero for depthTolerance).

2. Remove the dead standalone UDDF import path (3364373)

uddf_import_providers.dart + UddfDuplicateChecker + UddfParserService + UddfEntityCard were unreachable — no route, page, or menu action mounts them; the live file-import path is UniversalAdapter. Deleted the 4 files + their 4 tests. (UddfEntityImporter, which the live path does use, is kept.)

3. Remove orphaned file-import consolidation UI (eeb783c)

The old standalone universal wizard's review path (ImportReviewStep, ImportDiveCard, UniversalImportNotifier.performImport + helpers, the diveResolutions state field, and the DiveDuplicateResolution enum) is superseded by the live UniversalAdapter. Removed it and its tests. performConsolidations is kept — it is now live via UniversalAdapter (from #494). UniversalImportNotifier itself stays (the adapter reads its state); only the dead performImport subtree was removed.

4. Extract a shared MatchScorer (a12fa71)

The two matchers (file-import DiveMatcher, download findMatchingDiveWithScore) had duplicated, subtly-divergent scoring logic. Every sub-score is a linear falloff, so this introduces a single bandScore(value, full, zero) primitive + a MatchScorer config (lib/core/matching/match_scorer.dart), and both matchers now delegate to it with their own weights / breakpoints / units:

  • file: 50/30/20, percent depth (10–20%), whole-minute time (5–15), gateOnZeroTime: true
  • download: 40/35/25, absolute-meter depth (0–5 m), ms time over the SQL tolerance window, no gate

Behavior-preserving: each matcher's existing tests pass unchanged; missing-data defaults and the percent-depth guard are expressed as caller-side sentinels (0 → 1.0 via a full: 0 band; infinity → 0.0). The misleading download-matcher comments ("within 0.5 m = 100%") are gone with the inline math.

Testing

  • Full suite green; flutter analyze clean (whole project); dart format clean.
  • New match_scorer_test.dart covers bandScore + MatchScorer (weights, gate, sentinels).
  • Net −3927 lines (263 insertions / 4190 deletions).

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

Follow-up cleanup to the dive-matching / file-import consolidation work (#494) that removes unreachable UDDF import code paths and consolidates fuzzy-matching scoring into a shared, config-driven scorer to keep file-import and download matching consistent.

Changes:

  • Removed unused/obsolete parameters in duplicate detection and updated affected tests.
  • Deleted dead standalone UDDF import providers/widgets and the orphaned universal-import “review/consolidation” UI subtree, along with their tests.
  • Introduced MatchScorer + bandScore as shared matching primitives and refactored both matchers to delegate to the shared scorer (behavior preserved via existing + new tests).

Reviewed changes

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

Show a summary per file
File Description
test/features/universal_import/presentation/providers/universal_import_notifier_test.dart Removes tests for deleted notifier behaviors (dive-resolution + performImport subtree).
test/features/universal_import/data/models/import_enums_test.dart Removes tests for deleted DiveDuplicateResolution.
test/features/dive_import/presentation/widgets/uddf_entity_card_test.dart Deletes tests for removed dead UDDF import UI widget.
test/features/dive_import/presentation/providers/uddf_import_providers_test.dart Deletes tests for removed dead UDDF import provider/notifier flow.
test/features/dive_import/data/services/uddf_parser_service_test.dart Deletes tests for removed dead UDDF parser wrapper service.
test/features/dive_import/data/services/uddf_duplicate_checker_test.dart Deletes tests for removed dead UDDF duplicate checker.
test/features/dive_computer/data/services/dive_import_service_test.dart Updates mocks/expectations for removed fingerprint argument.
test/core/matching/match_scorer_test.dart Adds focused unit coverage for shared scoring primitives and gating behavior.
lib/features/universal_import/presentation/widgets/import_review_step.dart Deletes unreachable/orphaned universal-import review UI step.
lib/features/universal_import/presentation/widgets/import_dive_card.dart Deletes unreachable/orphaned dive review card UI.
lib/features/universal_import/presentation/providers/universal_import_state.dart Removes diveResolutions from state now that the UI/flow is gone.
lib/features/universal_import/presentation/providers/universal_import_providers.dart Removes dead performImport + resolution logic and related unused imports.
lib/features/universal_import/data/services/import_duplicate_checker.dart Updates doc comment to avoid referencing deleted UDDF checker.
lib/features/universal_import/data/models/import_enums.dart Removes the unused DiveDuplicateResolution enum.
lib/features/dive_log/data/repositories/dive_computer_repository_impl.dart Refactors download-side match scoring to use shared MatchScorer.
lib/features/dive_import/presentation/widgets/uddf_entity_card.dart Deletes dead UDDF import UI widget implementation.
lib/features/dive_import/presentation/providers/uddf_import_providers.dart Deletes dead standalone UDDF import provider/notifier implementation.
lib/features/dive_import/domain/services/dive_matcher.dart Refactors file-import matcher to use shared MatchScorer with time gating preserved.
lib/features/dive_import/data/services/uddf_parser_service.dart Deletes dead UDDF parser wrapper service.
lib/features/dive_import/data/services/uddf_duplicate_checker.dart Deletes dead UDDF duplicate checker implementation.
lib/features/dive_computer/data/services/dive_import_service.dart Removes unused depthTolerance param and stops passing removed fingerprint.
lib/core/matching/match_scorer.dart Adds shared scorer implementation (bandScore + MatchScorer).

Base automatically changed from worktree-dive-match-consolidate to main July 6, 2026 15:44
@ericgriffin ericgriffin self-assigned this Jul 6, 2026
@ericgriffin ericgriffin moved this from Backlog to In review in Submersion Release Tracker Jul 6, 2026
@codecov

codecov Bot commented Jul 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.66667% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...ta/repositories/dive_computer_repository_impl.dart 85.71% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@ericgriffin ericgriffin merged commit a84ca6e into main Jul 6, 2026
19 checks passed
@github-project-automation github-project-automation Bot moved this from In review to Done in Submersion Release Tracker Jul 6, 2026
@ericgriffin ericgriffin deleted the worktree-dive-matcher-cleanup branch July 6, 2026 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants