@@ -132,21 +132,44 @@ function fakeRuntimeSeed() {
132132 [ 'scripts/lib/fake-runtime-only.js' ] ,
133133 'new runtime-only require must enter closure'
134134 )
135+
136+ // Dynamic path.join(__dirname, '..', '..', 'scripts', 'lib', ...) must also enter closure.
137+ const tmpJoin = fs . mkdtempSync ( path . join ( os . tmpdir ( ) , 'runtime-closure-join-' ) )
138+ fs . mkdirSync ( path . join ( tmpJoin , 'hooks' , '_runtime' ) , { recursive : true } )
139+ fs . mkdirSync ( path . join ( tmpJoin , 'scripts' , 'lib' ) , { recursive : true } )
140+ fs . writeFileSync (
141+ path . join ( tmpJoin , 'hooks' , '_runtime' , 'join-fixture.cjs' ) ,
142+ "const p = path.join(__dirname, '..', '..', 'scripts', 'lib', 'join-only-dep.js')\nrequire(p)\n"
143+ )
144+ fs . writeFileSync ( path . join ( tmpJoin , 'scripts' , 'lib' , 'join-only-dep.js' ) , "'use strict'\nmodule.exports = {}\n" )
145+ assert . deepStrictEqual (
146+ collectRuntimeScriptDeps ( tmpJoin , { roots : [ 'hooks/_runtime' ] } ) ,
147+ [ 'scripts/lib/join-only-dep.js' ] ,
148+ 'path.join scripts/lib dep must enter closure'
149+ )
135150}
136151
137- function sourcePackageToolSmoke ( ) {
138- const mem = path . join ( ROOT , 'mcp' , 'memory-server.js' )
139- const prof = path . join ( ROOT , 'mcp' , 'profile-server.js' )
140- const memR = mcpToolCallProbe ( mem , ROOT , 'memory_status' , { agent : 'grok' , project : 'devcodex' , limit : 2 } , {
152+ function allowlistOnlyMcpSmoke ( ) {
153+ const tmp = fs . mkdtempSync ( path . join ( os . tmpdir ( ) , 'runtime-closure-mcp-' ) )
154+ // MCP servers resolve ../hooks/_runtime and ../scripts/lib from package-shaped layout.
155+ copyDir ( path . join ( ROOT , 'mcp' ) , path . join ( tmp , 'mcp' ) )
156+ copyDir ( path . join ( ROOT , 'hooks' , '_runtime' ) , path . join ( tmp , 'hooks' , '_runtime' ) )
157+ copyRuntimeDeps ( tmp , CLAUDE_MCP_RUNTIME_SCRIPT_DEPS )
158+
159+ const mem = path . join ( tmp , 'mcp' , 'memory-server.js' )
160+ const prof = path . join ( tmp , 'mcp' , 'profile-server.js' )
161+ const initR = mcpInitializeProbe ( mem , tmp , { timeoutMs : 5000 } )
162+ assert . strictEqual ( initR . passed , true , `allowlist-only initialize failed: ${ initR . error } ` )
163+ const memR = mcpToolCallProbe ( mem , tmp , 'memory_status' , { agent : 'grok' , project : 'devcodex' , limit : 2 } , {
141164 timeoutMs : 8000
142165 } )
143- assert . strictEqual ( memR . passed , true , `memory smoke failed: ${ memR . error } ${ memR . textHead } ` )
144- const profR = mcpToolCallProbe ( prof , ROOT , 'profile_compose_entry_check' , {
166+ assert . strictEqual ( memR . passed , true , `allowlist-only memory smoke failed: ${ memR . error } ${ memR . textHead } ` )
167+ const profR = mcpToolCallProbe ( prof , tmp , 'profile_compose_entry_check' , {
145168 project : 'devcodex' ,
146169 status : 'PASS' ,
147170 nextStep : 'test'
148171 } , { timeoutMs : 8000 } )
149- assert . strictEqual ( profR . passed , true , `profile smoke failed: ${ profR . error } ${ profR . textHead } ` )
172+ assert . strictEqual ( profR . passed , true , `allowlist-only profile smoke failed: ${ profR . error } ${ profR . textHead } ` )
150173}
151174
152175function packlistContainsRuntimeClosure ( ) {
@@ -165,15 +188,9 @@ function packlistContainsRuntimeClosure() {
165188 assert . ok ( files . has ( 'scripts/lib/runtime-dependency-closure.js' ) , 'npm package must include runtime closure owner' )
166189}
167190
168- function initStillWorks ( ) {
169- const r = mcpInitializeProbe ( path . join ( ROOT , 'mcp' , 'memory-server.js' ) , ROOT , { timeoutMs : 5000 } )
170- assert . strictEqual ( r . passed , true , `initialize failed: ${ r . error } ` )
171- }
172-
173191closureCoverage ( )
174192fakeRuntimeSeed ( )
175193layoutReplaySmoke ( )
176- sourcePackageToolSmoke ( )
194+ allowlistOnlyMcpSmoke ( )
177195packlistContainsRuntimeClosure ( )
178- initStillWorks ( )
179196console . log ( 'test-mcp-runtime-closure: PASS' )
0 commit comments