PDX-517: refactor(mcp): dedup screen-context rule on structured test_item_id#231
Merged
Merged
Conversation
…item_id RCA: UI-SCREEN-CONTEXT-001 de-duped its two heuristics by parsing the testItemId out of the human-readable violation message, so steps lacking a testItemId all rendered testItemId=N/A and two genuinely-distinct offending steps collided on the shared N/A key and silently merged into one (under-count); any message rewording also broke the dedup. Fix: Added an optional BPViolation.test_item_id field populated by flagAssertsOnNewScreen/flagStepsAfterSave from the offending step's tid, and changed validateUiAssertScreenContext to de-dup on that structured key, treating absent/N/A/empty ids as always-unique so distinct id-less steps no longer merge while same-step double-flags still collapse to one (96.25 parity).
Quality Orchestrator🟢 LOW · 🧪 Tests to Run · Running 1 of 57 tests
▶ Run commandnpx vitest run \
unit/mcp/bestPracticesEngine.test.ts⚡ quality-orchestrator · |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
UI-SCREEN-CONTEXT-001(src/mcp/tools/bestPracticesEngine.ts) runs two heuristics —flagAssertsOnNewScreenandflagStepsAfterSave— that can both flag the SAME offending step. To avoid double-penalising, it de-duplicated by parsing thetestItemIdout of the human-readable violation message (/testItemId=([^\s)]+)/).That message-parse dedup was fragile:
testItemIdrender astestItemId=N/A, so two genuinely-different offending steps that both lack atestItemIdcollided on the shared keyN/Aand silently merged into one violation (under-count).This PR replaces the message-parse key with a structured key.
Changes
test_item_id?: stringfield to theBPViolationinterface.testItemId?param tomakeViolation; it setstest_item_idon the returned violation when provided.flagAssertsOnNewScreen/flagStepsAfterSavenow pass the offending step'sstepContext(step).tidso each violation carries its structuredtest_item_id.validateUiAssertScreenContextnow de-dups ontest_item_idinstead ofviolationTestItemId(message). Absent /N/A/ empty ids are treated as always-unique (never merged).violationTestItemIdhelper and updated the explanatory comment block to describe the structured-key dedup.testItemId-less offending steps are BOTH reported (noN/Acollision); the existing bad-fixture test still pins exactly 1 violation /quality_score96.25 (same-step double-flag still merges).No behaviour change for valid input. Severity/weight unchanged (major / 5). No rule added or removed (rule count unchanged); no rule JSON
description/notestext changed, so the validation rule registry did not need regeneration. No user-facingdocs/mcp.mddescription changed.Jira
https://provartesting.atlassian.net/browse/PDX-517
Test plan
yarn compile— clean (freshtsc --noEmitclean)nyc mocha "test/**/*.test.ts") — 1508 passing, 0 failingtestItemId-less steps both reported (noN/Amerge)quality_score96.25 (same step, both heuristics)node scripts/mcp-smoke.cjs— 30/30 deterministic tools PASS (3provar_automation_*/provar_testrun_*env-timeout flakes, unrelated to this change)yarn lint— clean (incl.lint:script-names)