@@ -409,6 +409,66 @@ describe("Codex app-server thread lifecycle bindings", () => {
409409 } ) ;
410410 } ) ;
411411
412+ it ( "cold-resumes a warm thread when final config adds an image-generation deny" , async ( ) => {
413+ const sessionFile = path . join ( tempDir , "warm-image-deny-session.jsonl" ) ;
414+ const workspaceDir = path . join ( tempDir , "warm-image-deny-workspace" ) ;
415+ const params = createParams ( sessionFile , workspaceDir ) ;
416+ const request = vi . fn ( async ( method : string , _params ?: unknown ) => {
417+ if ( method === "configRequirements/read" ) {
418+ return { requirements : null } ;
419+ }
420+ if ( method === "thread/start" || method === "thread/resume" ) {
421+ return threadStartResult ( "thread-warm-image-deny" ) ;
422+ }
423+ if ( method === "thread/unsubscribe" ) {
424+ return { } ;
425+ }
426+ throw new Error ( `unexpected method: ${ method } ` ) ;
427+ } ) ;
428+ const client = {
429+ getInstanceId : ( ) => "client-warm-image-deny" ,
430+ request,
431+ addNotificationHandler : ( ) => ( ) => undefined ,
432+ addRequestHandler : ( ) => ( ) => undefined ,
433+ addCloseHandler : ( ) => ( ) => undefined ,
434+ } as never ;
435+ ensureCodexAppServerClientRuntime ( client , { agentDir : workspaceDir } ) ;
436+ const common = {
437+ client,
438+ params,
439+ cwd : workspaceDir ,
440+ dynamicTools : [ ] ,
441+ appServer : createThreadLifecycleAppServerOptions ( ) ,
442+ userMcpServersEnabled : false ,
443+ } ;
444+
445+ const started = await startOrResumeThread ( common ) ;
446+ await expect (
447+ retainCodexAppServerLiveThread (
448+ client ,
449+ started . threadId ,
450+ undefined ,
451+ started . liveThreadConfigFingerprint ,
452+ ) ,
453+ ) . resolves . toBe ( true ) ;
454+ params . pluginHarnessToolPolicySafeDeniedTools = [ "image_generate" ] ;
455+ const resumed = await startOrResumeThread ( common ) ;
456+
457+ expect ( resumed ) . toMatchObject ( {
458+ threadId : "thread-warm-image-deny" ,
459+ lifecycle : { action : "resumed" } ,
460+ } ) ;
461+ expect ( request . mock . calls . map ( ( [ method ] ) => method ) ) . toEqual ( [
462+ "thread/start" ,
463+ "configRequirements/read" ,
464+ "thread/unsubscribe" ,
465+ "thread/resume" ,
466+ ] ) ;
467+ expect ( request . mock . calls . find ( ( [ method ] ) => method === "thread/resume" ) ?. [ 1 ] ) . toMatchObject ( {
468+ config : { "features.image_generation" : false } ,
469+ } ) ;
470+ } ) ;
471+
412472 it ( "keeps a warm native session across sticky environment selection changes" , async ( ) => {
413473 const sessionFile = path . join ( tempDir , "environment-session.jsonl" ) ;
414474 const workspaceDir = path . join ( tempDir , "environment-workspace" ) ;
@@ -1711,6 +1771,34 @@ describe("Codex app-server thread lifecycle bindings", () => {
17111771 ] ) ;
17121772 } ) ;
17131773
1774+ it ( "fails closed when requirements pin denied image generation on" , async ( ) => {
1775+ const sessionFile = path . join ( tempDir , "session.jsonl" ) ;
1776+ const workspaceDir = path . join ( tempDir , "workspace" ) ;
1777+ const params = createParams ( sessionFile , workspaceDir ) ;
1778+ params . pluginHarnessToolPolicySafeDeniedTools = [ "image_generate" ] ;
1779+ const request = vi . fn ( async ( method : string ) => {
1780+ if ( method === "config/read" ) {
1781+ return { config : { } , layers : [ ] } ;
1782+ }
1783+ if ( method === "configRequirements/read" ) {
1784+ return { requirements : { featureRequirements : { image_generation : true } } } ;
1785+ }
1786+ throw new Error ( `unexpected method: ${ method } ` ) ;
1787+ } ) ;
1788+
1789+ await expect (
1790+ startOrResumeThread ( {
1791+ client : { request } as never ,
1792+ params,
1793+ cwd : workspaceDir ,
1794+ dynamicTools : [ ] ,
1795+ appServer : createThreadLifecycleAppServerOptions ( ) ,
1796+ userMcpServersEnabled : false ,
1797+ } ) ,
1798+ ) . rejects . toThrow ( "cannot override required feature image_generation" ) ;
1799+ expect ( request . mock . calls . map ( ( [ method ] ) => method ) ) . toEqual ( [ "configRequirements/read" ] ) ;
1800+ } ) ;
1801+
17141802 it . each ( [
17151803 "apps" ,
17161804 "artifact" ,
0 commit comments