Skip to content

[CmdPal] Golden-set relevance test harness for main-page ranking#49195

Draft
michaeljolley wants to merge 1 commit into
dev/mjolley/dev-mjolley-fast-first-paintfrom
dev/mjolley/relevance-harness
Draft

[CmdPal] Golden-set relevance test harness for main-page ranking#49195
michaeljolley wants to merge 1 commit into
dev/mjolley/dev-mjolley-fast-first-paintfrom
dev/mjolley/relevance-harness

Conversation

@michaeljolley

Copy link
Copy Markdown
Contributor

Phase 5 of the CmdPal search overhaul (stacked)

Stacked PR. Base is dev/mjolley/dev-mjolley-fast-first-paint (phase 4), not main. Keep as a draft; the human marks it ready.

What this adds

A golden-set relevance test harness that locks in main/root-page ranking quality and guards against regressions. It is the objective yardstick for "results seem logical and relevant." Test-only: no product code changed.

New file: Tests/Microsoft.CmdPal.UI.ViewModels.UnitTests/RelevanceHarnessTests.cs.

Golden set (11 cases) - each drives the REAL MainListPage.ScoreTopLevelItem over a representative fixture of apps + top-level commands, sorts exactly the way the product does (positive scores, descending, mirroring InternalListHelpers.FilterListWithScores / the existing RecentCommandsTests.GetMatches), and asserts ordering via readable AssertRank1(query, expected) / AssertRanksAbove(query, higher, lower) helpers. Easy to extend: add a fixture item and another constraint.

  • Tier ladder end to end: exact > prefix > acronym/word-boundary > fuzzy (paint, co, man).
  • Acronym surfaces the right app (vsc -> Visual Studio Code).
  • Frecency reorders WITHIN a tier only, never across (heavy use of a word-boundary match still sits below a prefix match for co).
  • Frecency breaks a within-tier tie (vs -> the used Visual Studio wins).
  • Per-provider Higher breaks an otherwise exact tie, and CANNOT cross a tier boundary.
  • Realistic "this was the complaint" cases: c (frecent Calculator at rank 1), code, set.

Per-tier ranker unit tests (16) for MainListRanker - the pieces the golden set cannot easily drive through mocks:

  • ClassifyTier boundaries incl. alias-exact (beats fallback) and fallback-floor.
  • Pack monotonicity: a higher tier with the worst within-tier score still outranks a lower tier with the best within-tier score.
  • Within-tier clamping (an absurd score never spills into the next tier), within-tier ordering, TierOf round-trip.
  • WithinTierScore ordering (lexical leads, frecency breaks ties) and ProviderBonus sign (Lower < Normal < Higher).

Determinism

Frecency cases inject uses through the phase-2 WithHistoryItem seam; no reliance on real extensions, registry, wall-clock, or machine state.

Test results (x64 host on this ARM64 box)

  • Microsoft.CmdPal.UI.ViewModels.UnitTests: 190/190 pass (27 new here: 11 golden + 16 per-tier).
  • All other CmdPal *.UnitTests: green (Common 225, Apps 28, Bookmarks 222, Indexer 35, Registry 66, RemoteDesktop 26, Shell 124/+1 skip, System 21, TimeDate 301, WebSearch 10, Toolkit 645/+1 skip).
  • WindowWalker: "Zero tests ran" - known pre-existing, ignored per plan.

Findings for human review

None. Every golden case matched the current ranker's behavior on the first run - no ranking bug surfaced, so nothing was changed and no case had to encode a known-bad ordering. If a future fixture reveals a genuine defect, prefer documenting it and asserting current behavior over silently changing ranking.

Co-authored-by: Copilot App 223556219+Copilot@users.noreply.github.com

Add RelevanceHarnessTests: a golden-set MSTest harness that drives the real MainListPage.ScoreTopLevelItem scoring path over a representative fixture of apps and top-level commands, sorts exactly as the product does (positive scores, descending), and asserts query -> expected ordering. Covers the tier ladder end to end (exact > prefix > acronym/word-boundary > fuzzy), frecency reordering within a tier only, per-provider Higher nudge breaking near-ties without crossing tiers, and realistic complaint cases (typing c, code, set surfaces the right thing at rank 1).

Also add focused per-tier MainListRanker unit tests: ClassifyTier boundaries (including alias-exact and fallback-floor), Pack monotonicity (a higher tier always outranks a lower one regardless of within-tier score), within-tier clamping and ordering, TierOf round-trip, and ProviderBonus sign.

Test-only change; no product behavior modified.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions Bot added the Product-Command Palette Refers to the Command Palette utility label Jul 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Product-Command Palette Refers to the Command Palette utility

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant