@@ -402,7 +402,7 @@ func TestStrictModeFirewallValidation(t *testing.T) {
402402 }
403403 })
404404
405- t .Run ("strict mode skips validation when sandbox.agent is false" , func (t * testing.T ) {
405+ t .Run ("strict mode refuses sandbox.agent: false for copilot " , func (t * testing.T ) {
406406 compiler := NewCompiler (false , "" , "test" )
407407 compiler .SetStrictMode (true )
408408
@@ -419,8 +419,39 @@ func TestStrictModeFirewallValidation(t *testing.T) {
419419 }
420420
421421 err := compiler .validateStrictFirewall ("copilot" , networkPerms , sandboxConfig )
422- if err != nil {
423- t .Errorf ("Expected no error when sandbox.agent is false, got: %v" , err )
422+ if err == nil {
423+ t .Error ("Expected error when sandbox.agent is false in strict mode for copilot" )
424+ }
425+ expectedMsg := "sandbox.agent: false"
426+ if ! strings .Contains (err .Error (), expectedMsg ) {
427+ t .Errorf ("Expected error message to contain '%s', got: %v" , expectedMsg , err )
428+ }
429+ })
430+
431+ t .Run ("strict mode refuses sandbox.agent: false for all engines" , func (t * testing.T ) {
432+ compiler := NewCompiler (false , "" , "test" )
433+ compiler .SetStrictMode (true )
434+
435+ networkPerms := & NetworkPermissions {
436+ Allowed : []string {"example.com" },
437+ ExplicitlyDefined : true ,
438+ Firewall : nil ,
439+ }
440+
441+ sandboxConfig := & SandboxConfig {
442+ Agent : & AgentSandboxConfig {
443+ Disabled : true ,
444+ },
445+ }
446+
447+ // All engines should refuse sandbox.agent: false in strict mode
448+ err := compiler .validateStrictFirewall ("claude" , networkPerms , sandboxConfig )
449+ if err == nil {
450+ t .Error ("Expected error for non-copilot engine with sandbox.agent: false in strict mode" )
451+ }
452+ expectedMsg := "sandbox.agent: false"
453+ if ! strings .Contains (err .Error (), expectedMsg ) {
454+ t .Errorf ("Expected error message to contain '%s', got: %v" , expectedMsg , err )
424455 }
425456 })
426457
@@ -459,4 +490,26 @@ func TestStrictModeFirewallValidation(t *testing.T) {
459490 t .Errorf ("Expected no error in non-strict mode, got: %v" , err )
460491 }
461492 })
493+
494+ t .Run ("non-strict mode allows sandbox.agent: false for copilot" , func (t * testing.T ) {
495+ compiler := NewCompiler (false , "" , "test" )
496+ compiler .SetStrictMode (false )
497+
498+ networkPerms := & NetworkPermissions {
499+ Allowed : []string {"example.com" },
500+ ExplicitlyDefined : true ,
501+ Firewall : nil ,
502+ }
503+
504+ sandboxConfig := & SandboxConfig {
505+ Agent : & AgentSandboxConfig {
506+ Disabled : true ,
507+ },
508+ }
509+
510+ err := compiler .validateStrictFirewall ("copilot" , networkPerms , sandboxConfig )
511+ if err != nil {
512+ t .Errorf ("Expected no error in non-strict mode with sandbox.agent: false, got: %v" , err )
513+ }
514+ })
462515}
0 commit comments