refactor(mcp): consolidate local-path redaction into one shared module - #6339
Conversation
The MCP CLI carried three separately-maintained local-path redactors — `redactLocalPath` (lib/local-branch.js), `redactLocalValidationPaths` and `sanitizeDiagnosticText` (bin/loopover-mcp.js) — so a single redaction fix had to be repeated and kept in sync three times. Consolidate them into packages/loopover-mcp/lib/redact-local-path.js, keeping both mechanisms the call sites need as named functions: `redactLocalPath` (regex heuristic that detects an unknown path in free text) and `redactKnownLocalPaths` (exact substring substitution of known tokens/paths). The heuristic is the strict superset of the two former regex variants, so no call site redacts less than before. All three former call sites now import from the shared module; behavior is preserved. A future redaction fix now happens in one place. Closes JSONbored#6264
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
|
Tip ✅ LoopOver review result - approve/merge recommendedReview updated: 2026-07-16 02:52:19 UTC
Review summary Nits — 5 non-blocking
Decision drivers
Context & advisory signals — never blocks the verdict
Linked issue satisfactionAddressed Review context
Contributor next steps
Signal definitions
🧪 Chat with LoopOverAsk LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.
Full command reference: https://gittensory.aethereal.dev/docs/loopover-commands 🧪 Experimental — new and may change. 🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed 💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by LoopOver, a quiet PR intelligence layer for OSS maintainers.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6339 +/- ##
=======================================
Coverage 95.60% 95.60%
=======================================
Files 596 596
Lines 47140 47140
Branches 15008 15008
=======================================
Hits 45068 45068
Misses 1290 1290
Partials 782 782
Flags with carried forward coverage won't be shown. Click here to find out more. |
Summary
packages/loopover-mcp/lib/redact-local-path.js, so a future redaction fix (e.g. the sibling(-prefix bug in fix(mcp): local-path redaction regex misses the most common stack-trace shape, risking a real path leak upstream #6258) only has to happen once.redactLocalPath(regex heuristic that DETECTS an unknown path in free text →<local-path>) andredactKnownLocalPaths(exact substring substitution that redacts KNOWN tokens/paths →[redacted]/[local-path]). They solve different problems, so neither is forced onto the other.lib/local-branch.jsre-exports and usesredactLocalPath(was a local copy).bin/loopover-mcp.jssanitizeValidationText/sanitizeCacheStringuseredactLocalPath(the former localredactLocalValidationPathsis removed).bin/loopover-mcp.jssanitizeDiagnosticTextis now a thin wrapper overredactKnownLocalPaths, passing the same session tokens and config/cwd/home paths it gathered before.The consolidated heuristic is the strict superset of the two former regex variants (the space-aware, both-slash validation pattern plus the mid-token home/Windows-root pass), so no call site redacts less than it did before — it only ever redacts the same or more. Behavior at each of the three sites is preserved; the
(-prefix leak fix itself is out of scope here and left for #6258, which now becomes a one-line change in this single module.Scope
type(scope): short summaryConventional Commit format.CONTRIBUTING.mdand does not reintroduce GitHub Pages, VitePress,site/, orCNAME.Closes #6264).Validation
git diff --checknpm run actionlintnpm run typechecknpm run test:coverage— the changed source lives entirely in Codecov-ignored paths (packages/loopover-mcp/**,scripts/**,test/**; coverageincludeissrc/**,packages/loopover-engine/src/**,packages/loopover-miner/lib/**), so this diff has no instrumented lines and nocodecov/patchobligation. Verified behavior instead by running the full unit suite: 16739 passed. The only failures (15, inminer-discover-cli,miner-live-issue-snapshot,selfhost-ams-reporting) are pre-existing and environment-only (sqlite3binary / GitHub token absent locally) — reproduced identically with the change stashed, and none of those files reference the changed code.npm run test:workers— not applicable; no worker (src/**) code changed.npm run build:mcpnpm run test:mcp-pack(newlib/redact-local-path.jsadded to the package allowlist)npm run ui:openapi:check— not applicable; no API/schema change.npm run ui:lint/ui:typecheck/ui:build— not applicable; no UI change.npm audit --audit-level=moderate— 0 vulnerabilities.test/unit/redact-local-path.test.tscovers both functions (unix/home/Windows roots, spaced segments, mid-token roots, nullish/empty input, longest-first path ordering, non-string coercion, token/path filtering). The existing call-site tests (local-scorer-adapter.test.ts,mcp-cli-packets.test.ts) still pass unchanged against the consolidated module.Safety
Notes
redactPrivateValidationMetrics(economic/identity-term redaction, not path redaction) is intentionally left inbin/— it is a different concern and out of this issue's scope.Closes #6264