@@ -7,6 +7,8 @@ import path from "node:path";
77import { afterEach , describe , expect , it } from "vitest" ;
88import YAML from "yaml" ;
99
10+ import { SHIPPED_MANAGED_IMAGE_AGENTS } from "./managed-image/contract" ;
11+ import { MANAGED_STARTUP_MERGED_CA_FILE } from "./managed-startup/image-runtime" ;
1012import { prepareInitialSandboxCreatePolicy } from "./initial-policy" ;
1113
1214type PolicyRule = {
@@ -70,6 +72,39 @@ describe("initial sandbox policy real preset merge", () => {
7072 { path : [ "agents" , "hermes" , "policy-permissive.yaml" ] , agent : "hermes" } ,
7173 ] as const ;
7274
75+ const managedStartupCaPolicyCases = [
76+ ...shippingPolicyCases ,
77+ {
78+ path : [ "agents" , "langchain-deepagents-code" , "policy-additions.yaml" ] ,
79+ agent : "langchain-deepagents-code" ,
80+ } ,
81+ ] as const ;
82+
83+ it ( "covers every shipped managed-image agent in the managed startup CA policy cases" , ( ) => {
84+ expect ( new Set ( managedStartupCaPolicyCases . map ( ( { agent } ) => agent ) ) ) . toEqual (
85+ new Set ( SHIPPED_MANAGED_IMAGE_AGENTS ) ,
86+ ) ;
87+ } ) ;
88+
89+ it . each ( managedStartupCaPolicyCases ) (
90+ "grants $agent policy $path exact read-only access to the managed startup CA bundle (#9360)" ,
91+ ( policyCase ) => {
92+ const prepared = prepareInitialSandboxCreatePolicy ( repoPath ( ...policyCase . path ) , [ ] , {
93+ agentName : policyCase . agent ,
94+ } ) ;
95+ const policy = readPreparedPolicy ( prepared ) ;
96+ const readOnly = policy . filesystem_policy ?. read_only ?? [ ] ;
97+ const readWrite = policy . filesystem_policy ?. read_write ?? [ ] ;
98+
99+ expect ( readOnly , policyCase . path . join ( "/" ) ) . toContain ( MANAGED_STARTUP_MERGED_CA_FILE ) ;
100+ expect ( readWrite , policyCase . path . join ( "/" ) ) . not . toContain ( MANAGED_STARTUP_MERGED_CA_FILE ) ;
101+ expect ( readOnly , policyCase . path . join ( "/" ) ) . not . toContain ( "/run" ) ;
102+ expect ( readWrite , policyCase . path . join ( "/" ) ) . not . toContain ( "/run" ) ;
103+ expect ( readOnly , policyCase . path . join ( "/" ) ) . not . toContain ( "/run/nemoclaw" ) ;
104+ expect ( readWrite , policyCase . path . join ( "/" ) ) . not . toContain ( "/run/nemoclaw" ) ;
105+ } ,
106+ ) ;
107+
73108 it . each ( [
74109 {
75110 path : [ "nemoclaw-blueprint" , "policies" , "openclaw-sandbox.yaml" ] ,
0 commit comments