Repository navigation
Conversation
…p does The MCP tools and the CLI mined patterns with whitespace-only splitting, so compact JSON lines became a few huge tokens and nearly every line got its own pattern. The web app's drain3 miner splits on ASCII punctuation. Use the same delimiters in a shared miner config. Date masks stay. With punctuation splitting, a mask is kept as a token of its own, and the drill-down predicate matches the raw date it replaced (up to three runs, separator beside it optional). Also fix the Drain port's tokenizer: it trimmed before turning delimiters into spaces, so a line starting or ending with one got an empty token, which drain3 never produces.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: bf11c06 The changes in this PR will be included in the next version bump. This PR includes changesets to release 5 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 |
🟡 Tier 3 — StandardIntroduces new logic, modifies core functionality, or touches areas with non-trivial risk. Why this tier:
Review process: Full human review — logic, architecture, edge cases. Stats
|
Duplicate code analysisNo new duplicate code introduced by this PR. jscpd compared this branch against |
| .map((t, i) => | ||
| i === 0 | ||
| ? toRegex(t) | ||
| : (maskTokens.has(t) || maskTokens.has(tokens[i - 1]) |
There was a problem hiding this comment.
🔴 P1 — With delimiters, <DATE> matches any 1–3 words, and the separators beside it are optional, so the drill-down whereSnippet matches lines without a date
The mask is [^sep]+(?:[sep][^sep]+){0,2} and both neighbours join with [sep]*. Nothing requires the value to look like a date, and a literal or <*> next to the mask can match part of a word. For example, the mined template ts <DATE> <*> msg done matches tsunami 5 msg done (ts + una + mi/5), and the new test locks in m('<DATE> started', 'boot started') === true. So PATTERN_MATCH_SEMANTICS (patternDrilldown.ts:92-94) is wrong when it promises "the same literal tokens in the same positions" and "a date of up to three tokens". Fix: make the mask regex date-shaped (for example, require a digit in the first run, or a month/weekday name). Make the separator optional only where the masker can glue a date to its neighbour: after a klog severity letter [IWEF] on the left, and before a T\d token on the right (see the lookaheads in config.ts:35,71). Everywhere else keep [sep]+. Flip the boot started assertion to false.
Nothing blocks merge automatically, but a maintainer will expect this fixed if it is a real defect in code this PR changes. If it is about surrounding code, reply and say so instead of patching. Do not widen the PR. How to respond
There was a problem hiding this comment.
Fixed in bf11c06. <DATE> now matches up to three date parts (digits, or month and weekday names). The separator beside it is optional only after a klog severity letter and before a T time, which are the two places the masker leaves none. boot started, job-42-x started and tsunami 5 msg done no longer match, and PATTERN_MATCH_SEMANTICS is updated. In ClickHouse, every mined pattern's drill-down still matches all its sampled members: 0 misses over 6,979 samples from 723 patterns on two synthetic corpora and 67k real log lines.
PR Review
6 finding(s): 🔴 0 P0/P1 · 🟡 0 P2 · 🔵 6 P3 No inline comments. 6 P3 folded at the bottom. 🔵 6 P3 — no action needed before merge
Priority comes from a separate grading pass over the finished review. P3 is folded here instead of posted inline. No finding blocks merge automatically; a maintainer decides. |
Deep Review✅ No critical issues found. The escaping chain for the SQL-embedded regexes is sound (a crafted log body cannot break out of the string literal — 🟡 P2 — recommended
🔵 P3 nitpicks (3)
Reviewers (5): security, maintainability, performance, project-standards, kieran-typescript. Testing gaps:
No finding blocks merge automatically. A maintainer will expect P0/P1 findings in code this PR changes to be fixed; P2/P3 are your call -- fix or reply. Never fix findings about surrounding code here; reply instead. Do not widen the PR. How to respond |
E2E Test Results✅ All tests passed • 473 passed • 1 skipped • 1096s
Tests ran across 4 shards in parallel. |
With punctuation delimiters, <DATE> matched any one to three runs and the separators beside it were optional, so a drill-down matched lines with no date (`ts <DATE> <*> msg done` matched `tsunami 5 msg done`). A mask now matches up to three date parts: digits, or month and weekday names. The separator beside it is optional only where the masker leaves none: after a klog severity letter (I1104) and before a T time (2026-11-04T06).
|
Re Deep Review: the |
|
Re the second Claude review round: no P0–P2 left, so per AGENTS.md I am stopping on automated findings here. Two of the P3s are worth follow-ups rather than more changes in this PR:
Ready for a maintainer review. |
|
Re Deep Review round 2: the P2 (the |
Summary
MCP (
event_patterns,emerging_signals, search denoise) and the CLI pattern view split log bodies on whitespace only. The web app's Event patterns view (drain3 in Pyodide) splits on ASCII punctuation as well. On compact bodies like JSON, whitespace splitting leaves each line as a few huge tokens. Nearly every line becomes its own pattern, with templates like<*> completed"}, and MCP and the UI give different patterns for the same data.This PR puts the web app's delimiters in a shared miner config (
createPatternMinerConfig,PATTERN_REGEX_OPTIONS) that MCP and the CLI both use. The web app's miner is unchanged.Date masks are kept (#3551 added them so
emerging_signalsstops reporting the same pattern as both emerging and disappeared across days). Under punctuation splitting, the<and>around a mask became separators, so templates held a bareDATEand the drill-downwhereSnippetmatched no dated line. Two changes fix that:2026-11-04T06:12:12Zmines as<DATE> T06 12 12Z.2026-11-04,04/Nov/2026), and the separator beside it is optional.Drain port fix: the TS port trimmed the line before turning delimiters into spaces, so a line starting or ending with a delimiter got an empty token. drain3 never produces one. This was latent, because nothing passed delimiters to the port until now.
Parity with drain3: with no masks, the TS port now gives the same cluster ids and templates as drain3 0.9.11, with whitespace or punctuation delimiters. Checked on two 10k-line synthetic corpora (JSON from pino, zap, logrus and structlog; logfmt and plain text from the hdx-eval generators) and 67k lines from a local ClickStack. The checks were one-off scripts and are not in this PR.
Effect on MCP/CLI patterns (number of patterns covering 90% of lines):
The ClickStack data gets worse: values whose punctuation varies split one pattern into several (
kind-worker3vskind-control-plane,4.5msvs45ms). The web app's drain3 has the same weakness there (21).Known limit: if a date and a plain word appear in the same position on lines of the same length, Drain merges them into
<*>, and drill-down misses the dated lines. Lines where the date is a prefix, the common case, are not affected.How to reproduce
Starting point:
yarn dev(MCP needs the API), with a log source whose bodies are compact JSON, e.g.{"level":"info","msg":"user 42 logged in","ts":"2026-11-04T06:12:12Z"}.On
main:displayType: "event_patterns"on that source.{"level":"info","msg":"user <*> logged <*>. Any line whose key order or field count differs, or whose first value varies, becomes a separate pattern.On this branch:
level info msg user <*> logged in ts <DATE> <*> <*> <*>, and the lines group into a few patterns.whereSnippetinclickstack_search. It returns that pattern's dated lines.How to test on Vercel preview
N/A — non-UI change. The web app's miner is not touched.
References
🤖 Generated with Claude Code