Skip to content

fix(cli): report coverage on verbatim phrase matches in search (unbreaks main) - #5996

Closed
ernestt wants to merge 2 commits into
mainfrom
fix-cli-search-coverage-fields
Closed

ernestt wants to merge 2 commits into
mainfrom
fix-cli-search-coverage-fields

Conversation

@ernestt

@ernestt ernestt commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

What

main is red, and this one-line change is what fixes it.

scoreQuery in packages/cli/api/search/search.mjs declares its return as {score, reason, matched, total} | null. The top-tier branch added by #5289 — the whole query matching a name or a declared keyword verbatim, promoted above the token-sum path — returns only {score, reason}:

if (full && full.score >= 90) {
  return {score: full.score + 100, reason: full.reason};
}

Two consequences, one cosmetic in CI and one real.

It fails the build. Under checkJs that is TS2739, so the "Verify the published CLI ./api type surface" step exits non-zero:

api/search/search.mjs(277,5): error TS2739: Type '{ score: number; reason: string; }' is missing
the following properties from type '{ score: number; reason: string; matched: number; total: number; }':
matched, total

That step sits ahead of Run pnpm test, so on every PR the test check fails without a single test running. It also fails build-storybook and build-sandbox, which skips the visual-evidence job, so visual-acceptance fails too with "Stable visual evidence could not be published" and no frame report. Both of my open PRs are red on this and neither has anything to do with it.

It also loses real information. matched/total exist so callers can tell "matched one word of three" from "matched all three" — build gates its pages group on that, and the JSDoc says as much. The strongest possible hit was the one hit that reported nothing, so that caller was reading undefined.

The fix

The function already has an asFull helper for precisely this case, used by both other whole-phrase branches:

// A whole-phrase hit answered the whole query by definition.
const asFull = hit => ({...hit, matched: total, total});

The promoted branch is a whole-phrase hit too — more emphatically so, since it requires a verbatim match on a name or an authored keyword. So it routes through the same helper. Scores and ordering are untouched; the object just carries the two fields it always claimed to.

Test plan

  • Reproduced the failure locally against main's copy of the file — same TS2739, same line — then confirmed node .github/scripts/cli-api-types-verify.mjs goes green with the change: "All published type-surface checks passed."
  • vitest run packages/cli/api/search against main's test file — 30 passed, including the ranking tests fix(cli): rank exact keyword phrase matches above token-sum scores #5289 added. No expectations needed changing, which is the point: this is additive to the returned object.

Provenance

Introduced in f44af81 (#5289). It landed after main's last CI run, and that run had already failed on an unrelated "package.json exports are stale!", so the break went unnoticed.

Changeset included.

Made with Cursor

scoreQuery declares {score, reason, matched, total}, but the top-tier
branch added in #5289 returned only {score, reason}. That is a type error
under checkJs, which fails the published CLI api type-surface check on
main, and it left callers that gate on coverage (build's pages group)
reading undefined for the strongest kind of match.

Routes the branch through the existing asFull helper: a verbatim match on
the whole query has answered every concept in it by definition.

Co-authored-by: Cursor <[email protected]>
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Sep 3, 2026
@vercel

vercel Bot commented Sep 3, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Sep 3, 2026 11:40pm UTC

Request Review

@ernestt

ernestt commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

Closing this — not mine to land. Leaving the diagnosis here for whoever picks it up.

packages/cli/api/search/search.mjs:277 returns {score, reason} where the JSDoc @returns declares {score, reason, matched, total}, so checkJs raises TS2739 and the "Verify the published CLI ./api type surface" step fails. That step runs before Run pnpm test, so test fails with zero tests executed, and it also fails build-storybook/build-sandbox, which skips the visual-evidence job and leaves visual-acceptance with nothing to publish. Every PR on current main is red for this reason.

The fix is to route that branch through the asFull helper already defined a few lines above, which the function's other whole-phrase branches use — a verbatim match on the whole query has answered every concept in it by definition. Verified on this branch: cli-api-types-verify.mjs passes and all 30 search tests pass unchanged.

Introduced in f44af81 (#5289). It landed after main's last CI run, and that run had already failed on an unrelated "package.json exports are stale!", so it went unnoticed.

@ernestt ernestt closed this Sep 3, 2026
@ernestt
ernestt deleted the fix-cli-search-coverage-fields branch September 3, 2026 23:57

This branch was successfully deployed

1 active deployment
Preview — 5a9f4979 Deployed Sep 3, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant