def METHOD_NAME(
    results_by_tool_name: Mapping[str, Sequence[_ResultWithReport]],
    workspace: Workspace,
    dist_dir: DistDir,
    *,
    goal_name: str,
) -> None:
    disambiguated_dirs: set[str] = set()
    def write_report(digest: Digest, subdir: str) -> None:
        while subdir in disambiguated_dirs:
            # It's unlikely that two distinct partition descriptions will become the
            # same after path_safe(), but might as well be safe.
            subdir += "_"
        disambiguated_dirs.add(subdir)
        output_dir = str(dist_dir.relpath / goal_name / subdir)
        workspace.write_digest(digest, path_prefix=output_dir)
        logger.info(f"Wrote {goal_name} report files to {output_dir}.")
    for tool_name, results in results_by_tool_name.items():
        if len(results) == 1 and results[0].report != EMPTY_DIGEST:
            write_report(results[0].report, tool_name)
        else:
            for result in results:
                if result.report != EMPTY_DIGEST:
                    write_report(
                        result.report,
                        os.path.join(tool_name, path_safe(result.partition_description or "all")),
                    )