Repository navigation
refactor(mcp): use the shared pattern predicate for drill-downs - #3663
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: 52672a1 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
| @@ -1,11 +1,11 @@ | |||
| import { minePatterns } from '@hyperdx/common-utils/dist/drain'; | |||
|
|
|||
| import { | |||
There was a problem hiding this comment.
🔵 minor — Tests for the common-utils predicate now sit in the api package, so common-utils' own suite doesn't cover them
Move the templateToRegex and buildPatternPredicate cases into packages/common-utils/src/__tests__/pattern-predicate.test.ts and keep only the andSql tests here. Today that file only tests extra delimiters and parsePatternPredicate. These cases cover escaping, quotes and backslashes, Unicode whitespace, empty templates and MAX_PREDICATE_TEMPLATE_LENGTH. Because they import the built @hyperdx/common-utils/dist/drain, changing pattern-predicate.ts and running the common-utils tests can't catch a regression in any of them. They also only run against whatever dist was last built.
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
There was a problem hiding this comment.
Keeping these here: they pin the exact whereSnippet this tool returns, and the common-utils suite now also covers the length limit and the no-option round trip (04c8a76).
PR Review
1 finding(s): 🔴 0 critical · 🟠 0 major · 🔵 1 minor 1 posted as inline comment(s) on the changed lines. Severity is the reviewer's own estimate and is used for ordering, not filtering. No finding blocks merge automatically; a maintainer decides. |
Deep Review✅ No critical issues found. This is a behavior-preserving refactor. The MCP Verification performed against the diff and both modules:
No P0/P1/P2/P3 findings. Reviewers (5): correctness, testing, maintainability, project-standards, previous-comments. Testing gaps: none — the existing |
🔵 Tier 2 — Low RiskSmall, isolated change with no API route or data model modifications. Why this tier:
Review process: AI review + quick human skim (target: 5–15 min). Reviewer validates AI assessment and checks for domain-specific concerns. Stats
|
Duplicate code analysisNo new duplicate code introduced by this PR. jscpd compared this branch against |
E2E Test Results✅ All tests passed • 469 passed • 1 skipped • 1059s
Tests ran across 4 shards in parallel. |
352748d to
4e0b97f
Compare
4e0b97f to
7d60a1b
Compare
clickstack_event_patterns now imports templateToRegex, buildPatternPredicate and MAX_PREDICATE_TEMPLATE_LENGTH from @hyperdx/common-utils/dist/drain, and its own copy is deleted. MCP mines without extra delimiters, so the whereSnippet it returns is unchanged. The existing patternDrilldown tests import from common-utils and pass as they are. Part of FR-385. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
7d60a1b to
52672a1
Compare
| @@ -1,11 +1,11 @@ | |||
| import { minePatterns } from '@hyperdx/common-utils/dist/drain'; | |||
|
|
|||
| import { | |||
There was a problem hiding this comment.
🔵 minor — Tests for the shared common-utils predicate are left in the api MCP test file
Move the templateToRegex and buildPatternPredicate describe blocks (lines 26-168) into packages/common-utils/src/__tests__/pattern-predicate.test.ts, leaving only andSql here. As it stands, the api package tests functions it no longer owns. The length-limit case is already in the common-utils file (lines 126-130) and the toJsRegex helper is duplicated there too. The common-utils file mostly covers the withPunctuation/python options, so the default JS-whitespace coverage (Unicode spaces, BOM, escaping, Drain round-trip) lives only in the api package. A change in common-utils could break that default and the common-utils suite would still pass.
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
Switches
clickstack_event_patternsto the shared pattern predicate from #3662 and deletes the MCP copy oftemplateToRegex,buildPatternPredicateandMAX_PREDICATE_TEMPLATE_LENGTH. Part of FR-385.Stack
Layer 2 of 4 in a GitHub stack (stack #3682). GitHub shows each layer's base as the branch below it, but the stack's base is
main: merging any PR lands it and every PR below it onmain, one squashed commit each. Each PR's diff is only its own layer, and CI runs as if each targetsmain:Summary
Pure refactor. MCP mines without extra delimiters, so the
whereSnippetit returns for each pattern is unchanged.PATTERN_MATCH_SEMANTICS,andSqlanduserWhereAsSqlstay inpatternDrilldown.ts, since only MCP uses them.Test plan
patternDrilldown.test.tstests import from common-utils and pass as they arejest src/mcpinpackages/api(29 suites, 578 tests),tsc --noEmit, eslint on the changed files, knip