digestCompartmentMap = (compartmentMap, sources) => {
  const {
    compartments,
    entry: { compartment: entryCompartmentName, module: entryModuleSpecifier },
  } = compartmentMap;

  const oldToNewCompartmentNames = renameCompartments(compartments);
  const digestCompartments = translateCompartmentMap(
    compartments,
    sources,
    oldToNewCompartmentNames,
  );
  const digestEntryCompartmentName =
    oldToNewCompartmentNames[entryCompartmentName];
  const digestSources = renameSources(sources, oldToNewCompartmentNames);

  const digestCompartmentMap = {
    // TODO graceful migration from tags to conditions
    // https://github.com/endojs/endo/issues/2388
    tags: [],
    entry: {
      compartment: digestEntryCompartmentName,
      module: entryModuleSpecifier,
    },
    compartments: digestCompartments,
  };

  // Cross-check:
  // We assert that we have constructed a valid compartment map, not because it
  // might not be, but to ensure that the assertCompartmentMap function can
  // accept all valid compartment maps.
  assertCompartmentMap(digestCompartmentMap);

  const newToOldCompartmentNames = fromEntries(
    entries(oldToNewCompartmentNames).map(([oldName, newName]) => [
      newName,
      oldName,
    ]),
  );

  /** @type {DigestResult} */
  const digestResult = {
    compartmentMap: digestCompartmentMap,
    sources: digestSources,
    oldToNewCompartmentNames,
    newToOldCompartmentNames,
    compartmentRenames: newToOldCompartmentNames,
  };

  return digestResult;
}
@param {CompartmentMapDescriptor} compartmentMap
@param {Sources} sources
@returns {DigestResult}