diff --git a/tools/path-normalization.mjs b/tools/path-normalization.mjs index 97f8bc234..1be3c5f64 100644 --- a/tools/path-normalization.mjs +++ b/tools/path-normalization.mjs @@ -94,5 +94,8 @@ export function pathNormalize(target, opts = {}) { if (e && e.code && e.code !== 'ENOENT') throw e; // surface real FS errors; fail-close handled by caller real = resolved; // ENOENT — best-effort resolved path for unknown-state files } - return caseFold(real, platform); + // Smoke 5 integration fix (2026-05-30): normalize ALL separators to forward slashes + // regardless of platform. DEFAULT_PROTECTED_PATTERNS regexes are forward-slash only. + // Without this, win32 path.resolve + realpath returns backslashes and patterns miss. + return caseFold(real, platform).split('\\').join('/'); } diff --git a/tools/path-normalization.test.mjs b/tools/path-normalization.test.mjs index b6c77d6a7..2a9611812 100644 --- a/tools/path-normalization.test.mjs +++ b/tools/path-normalization.test.mjs @@ -78,6 +78,20 @@ describe('pathNormalize', () => { it('expands ~ and resolves', () => { expect(pathNormalize('~/x', { homedir: '/h', realpath: (p) => p, resolve: (p) => p, platform: 'linux', env: {} })).toBe('/h/x'); }); + // Smoke 5 integration bug 2026-05-30 — Stream A pathNormalize returned backslashes + // on win32, breaking DEFAULT_PROTECTED_PATTERNS regex (forward-slash-only) match. + // Fix: normalize all separators to forward slashes in output, regardless of platform. + it('normalizes backslashes to forward slashes on win32 (integration fix for protected patterns)', () => { + const result = pathNormalize('~/foo/bar.jsonl', { + homedir: 'C:\\Users\\Admin', + realpath: (p) => p, + resolve: path.win32.resolve, + platform: 'win32', + env: {}, + }); + expect(result).not.toMatch(/\\/); + expect(result.includes('/')).toBe(true); + }); it('collapses .. via path.resolve', () => { // Use path.posix.resolve to simulate POSIX behaviour cross-platform const result = pathNormalize('a/../b', { realpath: (p) => p, resolve: path.posix.resolve, platform: 'linux', homedir: '/h', env: {} });