PDX-485: chore(mcp) — shared warningCodes.ts enum#182
Open
mrdailey99 wants to merge 2 commits into
Open
Conversation
…-thread feedback codes
RCA: Six sibling Provar MCP thread PRs (validation, properties, automation, RCA, JUnit, parallel-mode tuning) each independently emit warnings with ad-hoc string prefixes — `WARNING:`, `[provarHome]`, `WARN —` — producing inconsistent surface area for AI agents downstream and making cross-tool typo guidance ("Did you mean...?") harder to standardise. PDX-485 wants a single canonical enum the threads can import, so warning codes are coined once, formatted once, and documented once.
Fix: Adds src/mcp/utils/warningCodes.ts exporting WARNING_CODES (PROVARHOME-001, DATA-001, PARALLEL-001, SCHEMA-001, RUN-001, JUNIT-001), a WarningCode type derived from the enum, and a formatWarning(code, message, suggestion?) helper that emits `WARNING [<CODE>]: <message>` and appends ` Did you mean '<suggestion>'?` when a suggestion is provided. No call sites are touched in this PR — surface area is intentionally minimal so the six sibling thread PRs can import and adopt without merge conflicts. docs/mcp.md gains a new "Warning codes" reference table linked from the table of contents; per-row meanings are placeholders that subsequent thread PRs will refine.
Tests: New test/unit/mcp/utils/warningCodes.test.ts covers (1) each WARNING_CODES key maps to its expected wire string, (2) formatWarning without a suggestion returns the prefixed message exactly, (3) formatWarning with a suggestion appends the "Did you mean" suffix exactly, (4) an empty-string suggestion is treated as no suggestion. Validation: yarn compile clean, yarn lint clean, full mocha 1159 passing / 0 failing.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Quality Orchestrator🟢 LOW · 🧪 Tests to Run · Running 1 of 52 tests
▶ Run commandnpx vitest run \
unit/mcp/utils/warningCodes.test.ts⚡ quality-orchestrator · |
Contributor
There was a problem hiding this comment.
Pull request overview
Introduces a shared MCP warning code registry and formatter to standardize warning output across upcoming “thread-prep” changes, plus documentation and unit coverage for the new surface.
Changes:
- Added
WARNING_CODES,WarningCode, andformatWarning()utility for consistentWARNING [CODE]: ...formatting (with optional “Did you mean …?” suffix). - Added unit tests covering code/value mappings and formatter behavior (with and without suggestion).
- Documented the warning code table and warning message shape in
docs/mcp.md.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/mcp/utils/warningCodes.ts | Adds the canonical warning codes object, type, and formatter function. |
| test/unit/mcp/utils/warningCodes.test.ts | Adds unit tests validating code strings and formatter output. |
| docs/mcp.md | Adds a “Warning codes” section + TOC entry describing codes and output shape. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+14
to
+28
| const expected: Record<string, string> = { | ||
| PROVARHOME_001: 'PROVARHOME-001', | ||
| DATA_001: 'DATA-001', | ||
| PARALLEL_001: 'PARALLEL-001', | ||
| SCHEMA_001: 'SCHEMA-001', | ||
| RUN_001: 'RUN-001', | ||
| JUNIT_001: 'JUNIT-001', | ||
| }; | ||
| for (const [key, value] of Object.entries(expected)) { | ||
| assert.equal( | ||
| (WARNING_CODES as Record<string, string>)[key], | ||
| value, | ||
| `WARNING_CODES.${key} should equal '${value}'` | ||
| ); | ||
| } |
…DES test RCA: Copilot review on PR #182 flagged that the parity test only iterated the expected map and asserted forward-direction equality (expected key -> WARNING_CODES[key]). A new enum entry added without updating the test, or an accidentally-removed entry, would not fail the build. Bidirectional coverage was missing. Fix: Hoist the expected map to the describe scope so it is reusable. Add two new assertions: (a) Object.keys(WARNING_CODES).sort() deepEqual Object.keys(expected).sort() — guards against additions and omissions in the key set; (b) Object.values(WARNING_CODES).sort() deepEqual Object.values(expected).sort() — guards against value drift. Tests now fail loudly on silent enum drift in either direction.
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.
Context
Part of the Provar MCP thread-prep work (PDX-485). Six sibling thread PRs (validation, properties, automation, RCA, JUnit, parallel-mode tuning) will each surface warning text. Today each thread emits ad-hoc prefixes (
WARNING:,[provarHome],WARN —), producing inconsistent output for downstream AI agents and making cross-tool "Did you mean...?" guidance hard to standardise.This is the small, focused infrastructure PR that lands first so the six sibling PRs can import from a single source.
Why
formatWarning(code, message, suggestion?)standardises theDid you mean '<suggestion>'?suffix.What's in the diff
src/mcp/utils/warningCodes.ts—WARNING_CODESconst (PROVARHOME-001, DATA-001, PARALLEL-001, SCHEMA-001, RUN-001, JUNIT-001),WarningCodetype,formatWarning(code, message, suggestion?).test/unit/mcp/utils/warningCodes.test.ts— code-value parity table,formatWarningwith and without suggestion, empty-string suggestion edge case.docs/mcp.md— new "Warning codes" reference table + TOC entry. Per-row meanings are intentionally placeholders that subsequent thread PRs will refine as each surface stabilises.Out of scope (per the coordination plan)
package.json/server.jsonversion bump (handled in a sweeper PR).Test plan
yarn compile— cleanyarn lint— clean (incl. script-name lint)yarn test:only(bypassed wireit cache vianode_modules/.bin/nyc node_modules/.bin/mocha "test/**/*.test.ts") — 1159 passing, 0 failingRefs: PDX-485