    # File lib/chef/environment.rb, line 378
        def self.cdb_minimal_filtered_versions(name, couchdb=nil)
          version_constraints = cdb_load(name, couchdb).cookbook_versions.inject({}) {|res, (k,v)| res[k] = Chef::VersionConstraint.new(v); res}

          # inject all cookbooks into the hash while filtering out restricted versions, then sort the individual arrays
          cookbook_list = Chef::MinimalCookbookVersion.load_all(couchdb)

          filtered_list = cookbook_list.inject({}) do |res, cookbook|
            # FIXME: should cookbook.version return a Chef::Version?
            version               = Chef::Version.new(cookbook.version)
            requirement_satisfied = version_constraints.has_key?(cookbook.name) ? version_constraints[cookbook.name].include?(version) : true
            # we want a key for every cookbook, even if no versions are available
            res[cookbook.name] ||= []
            res[cookbook.name] << cookbook if requirement_satisfied
            res
          end

          sorted_list = filtered_list.inject({}) do |res, (cookbook_name, versions)|
            res[cookbook_name] = versions.sort.reverse
            res
          end

          sorted_list
        end