pub(crate) fn resolve(
        &self,
        affected: &Option<(Option<String>, Option<String>)>,
        patterns: &[String],
    ) -> Result<(HashMap<PackageName, PackageInclusionReason>, bool), ResolutionError> {
        // inference is None only if we are in the root
        let is_all_packages = patterns.is_empty() && self.inference.is_none() && affected.is_none();

        let filter_patterns = if is_all_packages {
            // return all packages in the workspace
            self.pkg_graph
                .packages()
                .filter(|(name, _)| matches!(name, PackageName::Other(_)))
                .map(|(name, _)| {
                    (
                        name.to_owned(),
                        PackageInclusionReason::IncludedByFilter {
                            filters: patterns.to_vec(),
                        },
                    )
                })
                .collect()
        } else {
            self.get_packages_from_patterns(affected, patterns)?
        };

        Ok((filter_patterns, is_all_packages))
    }
Resolves a set of filter patterns into a set of packages,
based on the current state of the workspace. The result is
guaranteed to be a subset of the packages in the workspace,
and non-empty. If the filter is empty, none of the packages
in the workspace will be returned.

It applies the following rules:
crates/turborepo-lib/src/run/scope/filter.rs