Autonomous development for real products. Governed agents build from specs you approve, follow the rules you set, and nothing merges until another agent proves it. Your decisions, judgement and taste are the bar that work must clear. Declare your vision and let agents build it.
JavaScript agentic-codingai-agentsai-governanceautonomous-agentsclaude-codeclicode-reviewcodexcoding-agentsdeveloper-toolsgit-hooksllmlocal-firstmulti-agentsoftware-factoryspec-driven-developmentverificationvibe-coding
fix(gate): keep Unicode ranges out of browser admission [C7]
Corey Olsonf763599fabe3
diff --git a/src/module-imports.js b/src/module-imports.jsindex 99e989f8..ce501137 100644--- a/src/module-imports.js+++ b/src/module-imports.js@@ -133,7 +133,12 @@ export function commonJsIn(sources) {...[...source.matchAll(UNICODE_ESCAPE)].map((match) => match.index),])]);const variants = sources.flatMap((source, index) =>- occurrences[index].map((at) => `${source.slice(0, at)}\u0000${source.slice(at)}`),+ occurrences[index].map((at) => {+ // Poison after an escape: before a range endpoint, NUL can invalidate a harmless regex range.+ const escaped = /^\\u(?:[\da-fA-F]{4}|\{[\da-fA-F]{1,6}\})/u.exec(source.slice(at));+ const cut = at + (escaped?.[0].length ?? 0);+ return `${source.slice(0, cut)}\u0000${source.slice(cut)}`;+ }),);const looks = look([...sources, ...variants]);let next = sources.length;diff --git a/test/run-tests-reporter.test.js b/test/run-tests-reporter.test.jsindex 5691a783..62924b77 100644--- a/test/run-tests-reporter.test.js+++ b/test/run-tests-reporter.test.js@@ -78,7 +78,9 @@ test('run-tests never injects timing reporters beside caller reporter options [C]) {const run = runReporterFixture(t, reporterArgs, { PULLBOARD_TEST_TIMING_PROFILE: join(tmpdir(), 'must-not-inject') });assert.equal(run.result.status, 0, run.output);- assert.deepEqual(run.childArgs.slice(4, -1), reporterArgs, 'only the exact caller reporter flags reach Node');+ const preload = run.childArgs.indexOf('--import');+ assert.equal(run.childArgs[preload + 1], runner, 'the production watchdog preload reaches Node');+ assert.deepEqual(run.childArgs.slice(preload + 2, -1), reporterArgs, 'only the exact caller reporter flags reach Node');assert.match(run.output, /ℹ tests 1/u);assert.doesNotMatch(run.output, /gate-profile-reporter|"files":/u);}diff --git a/test/test-resources.test.js b/test/test-resources.test.jsindex a3ee076f..f00dd694 100644--- a/test/test-resources.test.js+++ b/test/test-resources.test.js@@ -73,3 +73,17 @@ test('only actual CommonJS loader words trigger browser admission in JavaScript'node:module can create a loader through aliases or computed properties');assert.equal(await testsNeedBrowser(root, ['test/browser.test.cjs']), true);});++test('Unicode ranges do not turn ordinary tests into browser files [C7]', async t => {+ const root = sourceFixture(t, {+ 'test/plain.test.js': "import '../config.js';",+ 'config.js': String.raw`export const controlCharacters = /[\u0000-\u001f\u007f-\u009f]/u;`,+ 'test/escaped-loader.test.js': String.raw`const load = requ\u0069re;`,+ 'test/escaped-braced-loader.test.js': String.raw`const load = requ\u{69}re;`,+ });+ assert.equal(await testsNeedBrowser(root, ['test/plain.test.js']), false,+ 'a control-character regex in a shared config helper does not reserve a browser slot');+ assert.equal(await testsNeedBrowser(root, ['test/escaped-loader.test.js']), true,+ 'an escaped loader identifier still requires conservative browser admission');+ assert.equal(await testsNeedBrowser(root, ['test/escaped-braced-loader.test.js']), true);+});