Skip to content

test: L2 contract check and index eval on every PR - #618

Open
chaitanyakdukkipaty wants to merge 9 commits into
feat/mcp-l1-unit-coveragefrom
feat/mcp-l2-contract-eval
Open

chaitanyakdukkipaty wants to merge 9 commits into
feat/mcp-l1-unit-coveragefrom
feat/mcp-l2-contract-eval

Conversation

@chaitanyakdukkipaty

@chaitanyakdukkipaty chaitanyakdukkipaty commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

L2 of the MCP Server regression (walkthrough, spec section 3). It checks the capability indexes on every PR. It calls no API and no AI model. CI runs it in its own Jenkins job, MCPServerL2Checks (browserstack/browserstack-cd#27363). Comment RUN_MCP_L2 to run only L2, RUN_MCP_L1 for only L1, or RUN_MCP_CHECKS for both.

Stacked on #610 (L1). Both branches have main merged (L2 needs the bug_capture index).

 check            question                                      runs in
 1 Truth          does each action return what the index says?  npm run check:contract (all indexes)
 2 Findable       is the right action near the top of search?   tests/l2/indexEval.test.ts         local + remote
 3 Right product  does a question go to the right product?      tests/l2/productRoutingEval.test.ts local + remote
 4 Complete       does every action have a test question?       tests/l2/indexCoverage.test.ts
 guard            no silent loosening of the checks             npm run eval:index:guard -- <target branch>

Old, known problems are recorded once (contract baselines, miss cases, the allowlist). Only new problems fail.

1. Truth: contract check on every index

  • check:contract runs scripts/check-contract-all.sh. It checks every capability/*.capability-index.json, so a new index is found by itself. An index with no baseline fails.
  • New baselines: app_accessibility, applive, devicecontrol, mobiledevicecontrol, tra. --against <ref> adds the diff mode as a report (it never fails).

2. Findable: ranking on the SHIPPED indexes

  • The ranking test read a frozen tm copy (v1.31). It now reads the shipped files, through scripts/lib/index-eval.ts, in 2 profiles: local, and remote (REMOTE_MCP=true).
  • tests/fixtures/search-eval.json → search-eval/tm.json. One fixture per product. tra and bug_capture have first cases; the others are empty (backfill track).
  • 51 tm cases name actions that v1.46 disables. They stay, and run again when an action is enabled.
  • Re-measured on v1.46, each with a why: 5 maxRanks loosened, 4 known misses promoted. The control row of eval-index.mts --against shows these came from changed text in existing entries, not from new entries.
  • The baseline (top1/top3/top8) is a floor: a better ranker passes.
  • A case can say "remote": "reference" (found but not callable on the hosted server: local_only) or "remote": "withheld".
  • eval-index.mts: --product, --profile, --fixture, --coverage, --guard. --against now works for every product.

3. Right product: routing eval

42 questions run through ambiguousProducts (the code behind listProducts). Each product has a settled case. The eval found wrong routes, fixed here with routing_terms (see the last commit):

Question Before Now
accessibility scan on my android app tra app_accessibility
show accessibility issues on my login page devicecontrol web_accessibility
accessibility issues on my login screen – app_accessibility
list the apps my team uploaded tm, no question the AI asks: applive or tm
list projects in test management the AI asks tm
  • page is shared by devicecontrol and web_accessibility, and screen by mobiledevicecontrol and app_accessibility, so the accessibility word decides. devicecontrol drops login page: that one term settled every login-page request on it.
  • "accessibility scan" was a tra word only. app_accessibility and web_accessibility now claim it too.
  • All other routing cases and the existing routing tests are unchanged.

4. Complete: coverage and allowlist

  • Every searchable action (645 in 9 indexes) has a search-eval case, or is on search-eval/allowlist.json (518 today). Disabled actions do not count.
  • The allowlist only shrinks. A new action needs a case in the same PR, new product or not.

Guard (CI, needs the target branch)

npm run eval:index:guard -- origin/main fails when an allowlist name is added, a maxRank goes up (or a case becomes a miss) without a new why, or a case is removed without a retired entry. The rules are a pure function with tests (tests/l2/indexEvalGuard.test.ts).

L2 in its own Vitest project

The 4 L2 test files are in tests/l2/ and run with npm run test:l2 (project l2). The unit project excludes them. npm test still runs all projects.

For developers

 You add an action to an index
   → add one user question for it in tests/fixtures/search-eval/<product>.json
   → check 1 fails: fix what `returns` says, or give the field a home in the response schema
   → check 2 fails for an old question: npx tsx scripts/eval-index.mts --product <p> --against main
     shows which new entries pushed it down. Fix the description, not the case.

Ticket draft (to file)

tm index: "create a test case in a folder" ranks 8th. For this request, 7 folder actions (create_folder, create_sub_folder, create_root_folder, …) rank above create_test_case. The cause is changed text in existing tm entries, not new entries: the eval control row is unchanged without the new ones. The L2 maxRank is 8 for now. Fix the create_test_case intent/aliases, then set the maxRank back to 3.

Open

  • .github/CODEOWNERS: the L2 paths are commented out until the QA team handle is known.

Test plan

  • npm run lint, npx tsc --noEmit: pass
  • npm run test:l2 (Vitest project l2, the 4 files in tests/l2/): 419 / 419 pass
  • npx vitest run --project unit --coverage: 2544 / 2544 pass, and the coverage floors pass. The unit project no longer runs the L2 tests, so an index change does not fail L1.
  • npm run check:contract -- --against origin/main: 9 indexes pass
  • npm run eval:index:guard -- origin/main: OK
  • Bad edits are caught: an allowlist name added, a maxRank raised with no why, a case removed, a new action with no case
  • RUN_MCP_L2 and RUN_MCP_L1 after browserstack/browserstack-cd#27363 is seeded

🤖 Generated with Claude Code

chaitanyakdukkipaty and others added 6 commits November 27, 2026 13:44
check:contract now runs scripts/check-contract-all.sh. It checks every
capability/*.capability-index.json against its baseline, and fails when an
index has no baseline. New baselines for app_accessibility, applive,
devicecontrol, mobiledevicecontrol and tra record today's findings, so only
new findings fail. --against <ref> adds the diff mode as a report.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…remote

The ranking test read a frozen tm copy (v1.31). It now reads every shipped
capability/*.capability-index.json, in the local and the remote profile
(REMOTE_MCP=true), through scripts/lib/index-eval.ts.

- tests/fixtures/search-eval.json moves to search-eval/tm.json. One fixture
  per product; tra starts with 2 cases, the others are empty (backfill track).
- tests/tools/indexEval.test.ts: maxRank per case, known misses, baseline
  floors. A case may say "remote": "reference" or "withheld".
- 51 tm cases name capabilities that v1.46 disables. They stay, and run again
  when a capability is enabled.
- Re-pinned on v1.46, each with a why: 5 maxRanks loosened, 4 misses promoted.
- eval-index.mts: --product, --profile, --fixture; --against now works for any
  product. The 3 scorer-behaviour tests stay on the frozen copy.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- tests/fixtures/product-routing-eval.json + productRoutingEval.test.ts:
  34 questions run through ambiguousProducts on the shipped indexes, local
  and remote. Each product has a settled case. 4 wrong routes today are
  recorded as "known": they do not block, and fail once they route right.
- indexCoverage.test.ts: every searchable capability (641) has a search-eval
  case or is on search-eval/allowlist.json (518 today). Stale allowlist
  names fail, so it shrinks as cases are added.
- eval-index.mts --guard --against <ref> (npm run eval:index:guard): the
  allowlist only shrinks, a looser maxRank needs a new why, a removed case
  needs a retired entry. The rules are a pure function with unit tests.
- eval-index.mts --coverage: coverage per product.
- .github/CODEOWNERS: the L2 paths, commented until the QA team handle is set.
- PR template: a box for capability-index changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
main adds bug_capture (4 searchable capabilities) with a contract baseline.
Each capability gets a search-eval case (6 cases, all at rank 1 in both
profiles), and the routing fixture gets a settled case and a clash case:
'bug' alone is also a tm word.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d the TM name

The L2 routing eval recorded 4 wrong routes. Fixed with routing_terms:
- app_accessibility, web_accessibility: "accessibility scan". It was a tra
  word only, so "accessibility scan on my android app" went to tra.
- "page" + accessibility = web_accessibility, "screen" + accessibility =
  app_accessibility. "page" is shared by devicecontrol and
  web_accessibility, and "screen" by mobiledevicecontrol and
  app_accessibility, so the accessibility word decides. devicecontrol drops
  "login page": its own term settled every login-page request on it, and
  its "page" term still covers browser tasks.
- applive: "team". "list the apps my team uploaded" settled on tm; now the
  AI asks between applive and tm, as tm runs also record the app version.
- tm: "test management". Naming the product did not route to it.
The "open my app in app live" case is replaced: applive only lists uploads,
and opening an app is runAppLiveSession, not a catalog capability.
New cases cover the page and screen rules. The other routing cases are
unchanged in both profiles.

The tm case "create a test case in a folder" names its open defect.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto (fallback from Default branch)
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Central YAML (base), Organization UI (inherited), Workspace UI (inherited); Enforced overrides: Organization
  • Review profile: ASSERTIVE
  • Plan: Enterprise
  • Run ID: 75e08643-5588-4898-ae35-d4f5a4a9dd58

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
chaitanyakdukkipaty and others added 2 commits November 27, 2026 15:49
A ref that did not resolve read as 'no files', so the guard printed OK
with nothing to compare.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The ranking, routing, coverage and guard tests move to tests/l2 and run
with `npm run test:l2` (project l2). The unit project no longer runs
them, so a separate CI job can run L2 and an index change does not fail
L1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant