findRedirect = ({
  compartmentDescriptor,
  compartmentDescriptors,
  compartments,
  absoluteModuleSpecifier,
}) => {
  const moduleSpecifierLocation = new URL(absoluteModuleSpecifier, 'file:')
    .href;

  // a file:// URL string
  let someLocation = new URL('./', moduleSpecifierLocation).href;

  // we are guaranteed an absolute path, so we can search "up" for the compartment
  // due to the structure of `node_modules`

  // n === count of path components to the fs root
  for (;;) {
    if (
      someLocation !== ATTENUATORS_COMPARTMENT &&
      someLocation in compartments
    ) {
      const location = someLocation;
      const someCompartmentDescriptor = compartmentDescriptors[location];
      if (compartmentDescriptor === someCompartmentDescriptor) {
        // this compartmentDescriptor wants to dynamically load its own module
        // using an absolute path
        return undefined;
      }

      // this tests the compartment referred to by the absolute path
      // is a dependency of the compartment descriptor
      if (compartmentDescriptor.compartments.has(location)) {
        return {
          specifier: relativeSpecifier(moduleSpecifierLocation, location),
          compartment: compartments[location],
        };
      }

      // this tests if the compartment descriptor is a dependency of the
      // compartment referred to by the absolute path.
      // it may be in scope, but disallowed by policy.
      if (
        someCompartmentDescriptor.compartments.has(
          compartmentDescriptor.location,
        )
      ) {
        enforceModulePolicy(
          compartmentDescriptor.name,
          someCompartmentDescriptor,
          {
            errorHint: `Blocked in import hook. ${q(absoluteModuleSpecifier)} is part of the compartment map and resolves to ${location}`,
          },
        );
        return {
          specifier: relativeSpecifier(moduleSpecifierLocation, location),
          compartment: compartments[location],
        };
      }

      throw new Error(`Could not import module: ${q(absoluteModuleSpecifier)}`);
    } else {
      // go up a directory
      const parentLocation = new URL('../', someLocation).href;

      // afaict this behavior is consistent across both windows and posix
      if (parentLocation === someLocation) {
        throw new Error(
          `Could not import unknown module: ${q(absoluteModuleSpecifier)}`,
        );
      }

      someLocation = parentLocation;
    }
  }
}
Given a module specifier which is an absolute path, attempt to match it with
an existing compartment; return a {@link RedirectStaticModuleInterface} if found.

@throws If we determine `absoluteModuleSpecifier` is unknown
@param {FindRedirectParams} params Parameters
@returns {RedirectStaticModuleInterface|undefined} A redirect or nothing