From 355fbc6947f71444394109c1d39e4339273d6301 Mon Sep 17 00:00:00 2001 From: sonlndv Date: Thu, 23 Jul 2026 08:46:49 +0700 Subject: [PATCH] =?UTF-8?q?fix(doctor):=20two=20false-positive/timeout=20f?= =?UTF-8?q?ixes=20=E2=80=94=20drift=20walk=20skips=20node=5Fmodules;=20bar?= =?UTF-8?q?e-tweet=20skips=20inline-code=20+=20cited=20lines=20(#1772)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(drift): skip node_modules/dist/build in multi-source drift walk The drift walker recursed into node_modules (50k+ files in RN/Astro repos), exhausting the time budget before completing, so multi_source_drift always reported 'walk hit limit/timeout' on real projects. Skip heavy non-content dirs + add a deadline check on directory descent. * fix(integrity): skip inline-code spans + [Source:] citations in bare-tweet detection Recipe/doc pages that show the CORRECT citation format inline (e.g. `Tweeted about {topic} [Source: X, @handle, date]`) were false-flagged. The fenced-code skip didn't cover inline backticks; add inline-code stripping + an explicit-citation exemption. --------- Co-authored-by: Son Le --- src/commands/integrity.ts | 11 ++++++++++- src/core/multi-source-drift.ts | 8 ++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/commands/integrity.ts b/src/commands/integrity.ts index c883c1b48..42bfdef3d 100644 --- a/src/commands/integrity.ts +++ b/src/commands/integrity.ts @@ -98,8 +98,17 @@ export function findBareTweetHits(compiledTruth: string, slug: string): BareTwee } // If the line already contains a tweet URL, it's cited — skip if (URL_NEARBY_RE.test(line)) continue; + // If the line carries an explicit source citation (e.g. + // "[Source: X, @handle, 2026-05-28]"), it's already attributed — skip. + // Catches instructional/example lines in recipe docs that demonstrate + // the CORRECT citation format. (v0.42.x) + if (/\[\s*source:/i.test(line)) continue; + // Strip inline-code spans (`...`) before matching: phrases shown as + // inline-code templates in docs are examples, not bare claims. The + // fenced-code skip above only covers ``` blocks, not inline backticks. + const lineForMatch = line.replace(/`[^`]*`/g, ''); for (const re of BARE_TWEET_PHRASES) { - const m = line.match(re); + const m = lineForMatch.match(re); if (m) { hits.push({ slug, line: i + 1, rawLine: line.trim(), phrase: m[0] }); break; // one finding per line is enough diff --git a/src/core/multi-source-drift.ts b/src/core/multi-source-drift.ts index 2064c48f4..e01f34ec4 100644 --- a/src/core/multi-source-drift.ts +++ b/src/core/multi-source-drift.ts @@ -87,6 +87,11 @@ function walkMarkdownAndMdxFiles( for (const entry of entries) { if (truncated) return; if (entry.startsWith('.')) continue; + // Skip heavy non-content dirs so the walk doesn't exhaust the time + // budget on dependency/build trees (node_modules can be 50k+ files + // with zero .md). These are never gbrain page sources. + if (entry === 'node_modules' || entry === 'dist' || entry === 'build' || + entry === '.next' || entry === 'vendor' || entry === 'target') continue; const full = join(d, entry); let isDir = false; try { @@ -95,6 +100,9 @@ function walkMarkdownAndMdxFiles( continue; } if (isDir) { + // Time check on directory descent too, so a deep dependency-free + // tree still respects the deadline even before any .md is found. + if (Date.now() >= deadlineMs) { truncated = true; return; } walk(full); continue; }