Remove references to MiddlemanType.AGGREGATING_MIDDLEMAN.

Replace some occurrences with RUNFILES_MIDDLEMAN, and remove code where applicable.

PiperOrigin-RevId: 382262465
diff --git a/src/main/java/com/google/devtools/build/lib/BUILD b/src/main/java/com/google/devtools/build/lib/BUILD
index c10b1fc..3322a4f 100644
--- a/src/main/java/com/google/devtools/build/lib/BUILD
+++ b/src/main/java/com/google/devtools/build/lib/BUILD
@@ -95,7 +95,6 @@
         "//src/main/java/com/google/devtools/build/lib/ssd:srcs",
         "//src/main/java/com/google/devtools/build/lib/standalone:srcs",
         "//src/main/java/com/google/devtools/build/lib/supplier:srcs",
-        "//src/main/java/com/google/devtools/build/lib/testing/actions:srcs",
         "//src/main/java/com/google/devtools/build/lib/testing/common:srcs",
         "//src/main/java/com/google/devtools/build/lib/unix:srcs",
         "//src/main/java/com/google/devtools/build/lib/unsafe:srcs",
diff --git a/src/main/java/com/google/devtools/build/lib/actions/Artifact.java b/src/main/java/com/google/devtools/build/lib/actions/Artifact.java
index 9d17a22..fa92053 100644
--- a/src/main/java/com/google/devtools/build/lib/actions/Artifact.java
+++ b/src/main/java/com/google/devtools/build/lib/actions/Artifact.java
@@ -100,9 +100,8 @@
  *   <li>A directory of unknown contents, but not a TreeArtifact. This is a legacy facility and
  *       should not be used by any new rule implementations. In particular, the file system cache
  *       integrity checks fail for directories.
- *   <li>An 'aggregating middleman' special Artifact, which may be expanded using a {@link
- *       ArtifactExpander} at Action execution time. This is used by a handful of rules to save
- *       memory.
+ *   <li>A middleman special Artifact, which may be expanded using a {@link ArtifactExpander} at
+ *       Action execution time. This is used by a handful of rules to save memory.
  *   <li>A 'constant metadata' special Artifact. These represent real files, changes to which are
  *       ignored by the build system. They are useful for files which change frequently but do not
  *       affect the result of a build, such as timestamp files.
@@ -184,9 +183,8 @@
 
   /**
    * Returns a {@link SkyKey} that, when built, will produce this artifact. For source artifacts and
-   * generated artifacts that may aggregate other artifacts (middleman, since they may be
-   * aggregating middlemen, and tree), returns the artifact itself. For normal generated artifacts,
-   * returns the key of the generating action.
+   * generated artifacts that may aggregate other artifacts, returns the artifact itself. For normal
+   * generated artifacts, returns the key of the generating action.
    *
    * <p>Callers should use this method (or the related ones below) in preference to directly
    * requesting an {@link Artifact} to be built by Skyframe, since ordinary derived artifacts should
@@ -225,8 +223,8 @@
     /**
      * Expands the given artifact, and populates "output" with the result.
      *
-     * <p>{@code artifact.isMiddlemanArtifact() || artifact.isTreeArtifact()} must be true.
-     * Only aggregating middlemen and tree artifacts are expanded.
+     * <p>{@code artifact.isMiddlemanArtifact() || artifact.isTreeArtifact()} must be true. Only
+     * middlemen and tree artifacts are expanded.
      */
     void expand(Artifact artifact, Collection<? super Artifact> output);
 
@@ -1491,10 +1489,7 @@
     return Joiner.on(delimiter).join(toRootRelativePaths(artifacts));
   }
 
-  /**
-   * Adds a collection of artifacts to a given collection, with {@link
-   * MiddlemanType#AGGREGATING_MIDDLEMAN} middleman actions expanded once.
-   */
+  /** Adds a collection of artifacts to a given collection, with middleman actions expanded once. */
   static void addExpandedArtifacts(
       Iterable<Artifact> artifacts,
       Collection<? super Artifact> output,
diff --git a/src/main/java/com/google/devtools/build/lib/actions/MiddlemanType.java b/src/main/java/com/google/devtools/build/lib/actions/MiddlemanType.java
index 53d81e0..84b08f3 100644
--- a/src/main/java/com/google/devtools/build/lib/actions/MiddlemanType.java
+++ b/src/main/java/com/google/devtools/build/lib/actions/MiddlemanType.java
@@ -19,9 +19,6 @@
   /** A normal action. */
   NORMAL,
 
-  /** A normal middleman, which just encapsulates a list of artifacts. */
-  AGGREGATING_MIDDLEMAN,
-
   /**
    * A middleman that denotes a scheduling dependency.
    *
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/ActionInputMapHelper.java b/src/main/java/com/google/devtools/build/lib/skyframe/ActionInputMapHelper.java
index 4e6afaf..adc5992 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/ActionInputMapHelper.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/ActionInputMapHelper.java
@@ -75,9 +75,13 @@
       Environment env,
       MetadataConsumerForMetrics consumer)
       throws InterruptedException {
-    if (value instanceof AggregatingArtifactValue) {
-      AggregatingArtifactValue aggregatingValue = (AggregatingArtifactValue) value;
-      for (Pair<Artifact, FileArtifactValue> entry : aggregatingValue.getFileArtifacts()) {
+    if (value instanceof RunfilesArtifactValue) {
+      // Note: we don't expand the .runfiles/MANIFEST file into the inputs. The reason for that
+      // being that the MANIFEST file contains absolute paths that don't work with remote execution.
+      // Instead, the way the SpawnInputExpander expands runfiles is via the Runfiles class
+      // which contains all artifacts in the runfiles tree minus the MANIFEST file.
+      RunfilesArtifactValue runfilesArtifactValue = (RunfilesArtifactValue) value;
+      for (Pair<Artifact, FileArtifactValue> entry : runfilesArtifactValue.getFileArtifacts()) {
         Artifact artifact = entry.first;
         inputMap.put(artifact, entry.getSecond(), /*depOwner=*/ key);
         if (artifact.isFileset()) {
@@ -91,7 +95,7 @@
           consumer.accumulate(entry.getSecond());
         }
       }
-      for (Pair<Artifact, TreeArtifactValue> entry : aggregatingValue.getTreeArtifacts()) {
+      for (Pair<Artifact, TreeArtifactValue> entry : runfilesArtifactValue.getTreeArtifacts()) {
         expandTreeArtifactAndPopulateArtifactData(
             entry.getFirst(),
             Preconditions.checkNotNull(entry.getSecond()),
@@ -103,20 +107,7 @@
       }
       // We have to cache the "digest" of the aggregating value itself, because the action cache
       // checker may want it.
-      inputMap.put(key, aggregatingValue.getMetadata(), /*depOwner=*/ key);
-      // While not obvious at all this code exists to ensure that we don't expand the
-      // .runfiles/MANIFEST file into the inputs. The reason for that being that the MANIFEST
-      // file contains absolute paths that don't work with remote execution.
-      // Instead, the way the SpawnInputExpander expands runfiles is via the Runfiles class
-      // which contains all artifacts in the runfiles tree minus the MANIFEST file.
-      // TODO(buchgr): Clean this up and get rid of the RunfilesArtifactValue type.
-      if (!(value instanceof RunfilesArtifactValue)) {
-        ImmutableList.Builder<Artifact> expansionBuilder = ImmutableList.builder();
-        for (Pair<Artifact, FileArtifactValue> pair : aggregatingValue.getFileArtifacts()) {
-          expansionBuilder.add(Preconditions.checkNotNull(pair.getFirst()));
-        }
-        expandedArtifacts.put(key, expansionBuilder.build());
-      }
+      inputMap.put(key, runfilesArtifactValue.getMetadata(), /*depOwner=*/ key);
     } else if (value instanceof TreeArtifactValue) {
       TreeArtifactValue treeArtifactValue = (TreeArtifactValue) value;
       expandTreeArtifactAndPopulateArtifactData(
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/AggregatingArtifactValue.java b/src/main/java/com/google/devtools/build/lib/skyframe/AggregatingArtifactValue.java
deleted file mode 100644
index e9978fb..0000000
--- a/src/main/java/com/google/devtools/build/lib/skyframe/AggregatingArtifactValue.java
+++ /dev/null
@@ -1,85 +0,0 @@
-// Copyright 2014 The Bazel Authors. All rights reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//    http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-package com.google.devtools.build.lib.skyframe;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Preconditions;
-import com.google.common.collect.ImmutableList;
-import com.google.devtools.build.lib.actions.Artifact;
-import com.google.devtools.build.lib.actions.FileArtifactValue;
-import com.google.devtools.build.lib.util.Pair;
-import com.google.devtools.build.skyframe.SkyValue;
-import java.util.Collection;
-
-/** Value for aggregating artifacts, which must be expanded to a set of other artifacts. */
-class AggregatingArtifactValue implements SkyValue {
-  private final ImmutableList<Pair<Artifact, FileArtifactValue>> fileInputs;
-  private final ImmutableList<Pair<Artifact, TreeArtifactValue>> directoryInputs;
-  private final FileArtifactValue metadata;
-
-  AggregatingArtifactValue(
-      ImmutableList<Pair<Artifact, FileArtifactValue>> fileInputs,
-      ImmutableList<Pair<Artifact, TreeArtifactValue>> directoryInputs,
-      FileArtifactValue metadata) {
-    this.fileInputs = Preconditions.checkNotNull(fileInputs);
-    this.directoryInputs = Preconditions.checkNotNull(directoryInputs);
-    this.metadata = Preconditions.checkNotNull(metadata);
-  }
-
-  /** Returns the none tree artifacts that this artifact expands to, together with their data. */
-  Collection<Pair<Artifact, FileArtifactValue>> getFileArtifacts() {
-    return fileInputs;
-  }
-
-  /**
-   * Returns the tree artifacts that this artifact expands to, together with the information
-   * to which artifacts the tree artifacts expand to.
-   */
-  Collection<Pair<Artifact, TreeArtifactValue>> getTreeArtifacts() {
-    return directoryInputs;
-  }
-
-  /** Returns the data of the artifact for this value, as computed by the action cache checker. */
-  FileArtifactValue getMetadata() {
-    return metadata;
-  }
-
-  @SuppressWarnings("EqualsGetClass") // RunfilesArtifactValue not equal to Aggregating.
-  @Override
-  public boolean equals(Object o) {
-    if (this == o) {
-      return true;
-    }
-    if (o == null || getClass() != o.getClass()) {
-      return false;
-    }
-    AggregatingArtifactValue that = (AggregatingArtifactValue) o;
-    return metadata.equals(that.metadata)
-        && fileInputs.equals(that.fileInputs)
-        && directoryInputs.equals(that.directoryInputs);
-  }
-
-  @Override
-  public int hashCode() {
-    return 31 * 31 * directoryInputs.hashCode() + 31 * fileInputs.hashCode() + metadata.hashCode();
-  }
-
-  @Override
-  public String toString() {
-    return MoreObjects.toStringHelper(this)
-        .add("fileInputs", fileInputs)
-        .add("directoryInputs", directoryInputs)
-        .toString();
-  }
-}
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/ArtifactFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/ArtifactFunction.java
index e9d01a91..fb64dae 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/ArtifactFunction.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/ArtifactFunction.java
@@ -13,6 +13,8 @@
 // limitations under the License.
 package com.google.devtools.build.lib.skyframe;
 
+import static com.google.devtools.build.lib.actions.MiddlemanType.RUNFILES_MIDDLEMAN;
+
 import com.google.common.base.MoreObjects;
 import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableList;
@@ -32,7 +34,6 @@
 import com.google.devtools.build.lib.actions.FileValue;
 import com.google.devtools.build.lib.actions.FilesetTraversalParams.DirectTraversalRoot;
 import com.google.devtools.build.lib.actions.FilesetTraversalParams.PackageBoundaryMode;
-import com.google.devtools.build.lib.actions.MiddlemanType;
 import com.google.devtools.build.lib.bugreport.BugReport;
 import com.google.devtools.build.lib.cmdline.Label;
 import com.google.devtools.build.lib.events.Event;
@@ -143,7 +144,7 @@
             artifactDependencies);
     FileArtifactValue individualMetadata = actionValue.getExistingFileArtifactValue(artifact);
     if (isAggregatingValue(action)) {
-      return createAggregatingValue(artifact, action, individualMetadata, env);
+      return createRunfilesArtifactValue(artifact, action, individualMetadata, env);
     }
     return individualMetadata;
   }
@@ -340,7 +341,7 @@
   }
 
   @Nullable
-  private static AggregatingArtifactValue createAggregatingValue(
+  private static RunfilesArtifactValue createRunfilesArtifactValue(
       Artifact artifact,
       ActionAnalysisMetadata action,
       FileArtifactValue value,
@@ -367,9 +368,9 @@
       } else if (inputValue instanceof TreeArtifactValue) {
         directoryInputsBuilder.add(Pair.of(input, (TreeArtifactValue) inputValue));
       } else {
-        // We do not recurse in aggregating middleman artifacts.
+        // We do not recurse in middleman artifacts.
         Preconditions.checkState(
-            !(inputValue instanceof AggregatingArtifactValue),
+            !(inputValue instanceof RunfilesArtifactValue),
             "%s %s %s",
             artifact,
             action,
@@ -386,24 +387,16 @@
             Comparator.comparing(pair -> pair.getFirst().getExecPathString()),
             directoryInputsBuilder.build());
 
-    return (action.getActionType() == MiddlemanType.AGGREGATING_MIDDLEMAN)
-        ? new AggregatingArtifactValue(fileInputs, directoryInputs, value)
-        : new RunfilesArtifactValue(fileInputs, directoryInputs, value);
+    return new RunfilesArtifactValue(fileInputs, directoryInputs, value);
   }
 
   /**
    * Returns whether this value needs to contain the data of all its inputs. Currently only tests to
-   * see if the action is an aggregating or runfiles middleman action. However, may include Fileset
-   * artifacts in the future.
+   * see if the action is a runfiles middleman action. However, may include Fileset artifacts in the
+   * future.
    */
   private static boolean isAggregatingValue(ActionAnalysisMetadata action) {
-    switch (action.getActionType()) {
-      case AGGREGATING_MIDDLEMAN:
-      case RUNFILES_MIDDLEMAN:
-        return true;
-      default:
-        return false;
-    }
+    return action.getActionType() == RUNFILES_MIDDLEMAN;
   }
 
   @Override
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/BUILD b/src/main/java/com/google/devtools/build/lib/skyframe/BUILD
index 52c40f2..b6a9f23 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/BUILD
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/BUILD
@@ -421,7 +421,6 @@
     srcs = ["ActionInputMapHelper.java"],
     deps = [
         ":action_execution_value",
-        ":aggregating_artifact_value",
         ":metadata_consumer_for_metrics",
         ":runfiles_artifact_value",
         ":tree_artifact_value",
@@ -756,8 +755,8 @@
 )
 
 java_library(
-    name = "aggregating_artifact_value",
-    srcs = ["AggregatingArtifactValue.java"],
+    name = "runfiles_artifact_value",
+    srcs = ["RunfilesArtifactValue.java"],
     deps = [
         ":tree_artifact_value",
         "//src/main/java/com/google/devtools/build/lib/actions:artifacts",
@@ -789,7 +788,6 @@
     deps = [
         ":action_execution_value",
         ":action_template_expansion_value",
-        ":aggregating_artifact_value",
         ":coverage_report_value",
         ":detailed_exceptions",
         ":metadata_consumer_for_metrics",
@@ -2264,19 +2262,6 @@
 )
 
 java_library(
-    name = "runfiles_artifact_value",
-    srcs = ["RunfilesArtifactValue.java"],
-    deps = [
-        ":aggregating_artifact_value",
-        ":tree_artifact_value",
-        "//src/main/java/com/google/devtools/build/lib/actions:artifacts",
-        "//src/main/java/com/google/devtools/build/lib/actions:file_metadata",
-        "//src/main/java/com/google/devtools/build/lib/util",
-        "//third_party:guava",
-    ],
-)
-
-java_library(
     name = "sane_analysis_exception",
     srcs = ["SaneAnalysisException.java"],
     deps = [
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/RunfilesArtifactValue.java b/src/main/java/com/google/devtools/build/lib/skyframe/RunfilesArtifactValue.java
index 5d78d76..afe3c78 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/RunfilesArtifactValue.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/RunfilesArtifactValue.java
@@ -1,4 +1,4 @@
-// Copyright 2018 The Bazel Authors. All rights reserved.
+// Copyright 2014 The Bazel Authors. All rights reserved.
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
@@ -13,17 +13,73 @@
 // limitations under the License.
 package com.google.devtools.build.lib.skyframe;
 
+import com.google.common.base.MoreObjects;
+import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableList;
 import com.google.devtools.build.lib.actions.Artifact;
 import com.google.devtools.build.lib.actions.FileArtifactValue;
 import com.google.devtools.build.lib.util.Pair;
+import com.google.devtools.build.skyframe.SkyValue;
+import java.util.Collection;
 
 /** The artifacts behind a runfiles middleman. */
-final class RunfilesArtifactValue extends AggregatingArtifactValue {
+class RunfilesArtifactValue implements SkyValue {
+  private final ImmutableList<Pair<Artifact, FileArtifactValue>> fileInputs;
+  private final ImmutableList<Pair<Artifact, TreeArtifactValue>> directoryInputs;
+  private final FileArtifactValue metadata;
+
   RunfilesArtifactValue(
       ImmutableList<Pair<Artifact, FileArtifactValue>> fileInputs,
       ImmutableList<Pair<Artifact, TreeArtifactValue>> directoryInputs,
       FileArtifactValue metadata) {
-    super(fileInputs, directoryInputs, metadata);
+    this.fileInputs = Preconditions.checkNotNull(fileInputs);
+    this.directoryInputs = Preconditions.checkNotNull(directoryInputs);
+    this.metadata = Preconditions.checkNotNull(metadata);
+  }
+
+  /** Returns the none tree artifacts that this artifact expands to, together with their data. */
+  Collection<Pair<Artifact, FileArtifactValue>> getFileArtifacts() {
+    return fileInputs;
+  }
+
+  /**
+   * Returns the tree artifacts that this artifact expands to, together with the information to
+   * which artifacts the tree artifacts expand to.
+   */
+  Collection<Pair<Artifact, TreeArtifactValue>> getTreeArtifacts() {
+    return directoryInputs;
+  }
+
+  /** Returns the data of the artifact for this value, as computed by the action cache checker. */
+  FileArtifactValue getMetadata() {
+    return metadata;
+  }
+
+  @SuppressWarnings("EqualsGetClass") // RunfilesArtifactValue not equal to Aggregating.
+  @Override
+  public boolean equals(Object o) {
+    if (this == o) {
+      return true;
+    }
+    if (o == null || getClass() != o.getClass()) {
+      return false;
+    }
+    RunfilesArtifactValue that = (RunfilesArtifactValue) o;
+    return metadata.equals(that.metadata)
+        && fileInputs.equals(that.fileInputs)
+        && directoryInputs.equals(that.directoryInputs);
+  }
+
+  @Override
+  public int hashCode() {
+    return 31 * 31 * directoryInputs.hashCode() + 31 * fileInputs.hashCode() + metadata.hashCode();
+  }
+
+  @Override
+  public String toString() {
+    return MoreObjects.toStringHelper(this)
+        .add("fileInputs", fileInputs)
+        .add("directoryInputs", directoryInputs)
+        .toString();
   }
 }
diff --git a/src/main/java/com/google/devtools/build/lib/testing/actions/ArtifactExpanderHelper.java b/src/main/java/com/google/devtools/build/lib/testing/actions/ArtifactExpanderHelper.java
deleted file mode 100644
index 4cfa40a..0000000
--- a/src/main/java/com/google/devtools/build/lib/testing/actions/ArtifactExpanderHelper.java
+++ /dev/null
@@ -1,47 +0,0 @@
-// Copyright 2021 The Bazel Authors. All rights reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//    http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.devtools.build.lib.testing.actions;
-
-import com.google.common.base.Functions;
-import com.google.common.base.Preconditions;
-import com.google.devtools.build.lib.actions.ActionAnalysisMetadata;
-import com.google.devtools.build.lib.actions.ActionGraph;
-import com.google.devtools.build.lib.actions.Artifact;
-import com.google.devtools.build.lib.actions.Artifact.ArtifactExpander;
-import com.google.devtools.build.lib.actions.MiddlemanType;
-
-/** Helper utility to create {@link ArtifactExpander} instances. */
-public final class ArtifactExpanderHelper {
-  private ArtifactExpanderHelper() {}
-
-  public static ArtifactExpander actionGraphArtifactExpander(ActionGraph actionGraph) {
-    return (mm, output) -> {
-      // Skyframe is stricter in that it checks that "mm" is a input of the action, because
-      // it cannot expand arbitrary middlemen without access to a global action graph.
-      // We could check this constraint here too, but it seems unnecessary. This code is
-      // going away anyway.
-      Preconditions.checkArgument(mm.isMiddlemanArtifact(), "%s is not a middleman artifact", mm);
-      ActionAnalysisMetadata middlemanAction = actionGraph.getGeneratingAction(mm);
-      Preconditions.checkState(middlemanAction != null, mm);
-      // TODO(bazel-team): Consider expanding recursively or throwing an exception here.
-      // Most likely, this code will cause silent errors if we ever have a middleman that
-      // contains a middleman.
-      if (middlemanAction.getActionType() == MiddlemanType.AGGREGATING_MIDDLEMAN) {
-        Artifact.addNonMiddlemanArtifacts(
-            middlemanAction.getInputs().toList(), output, Functions.identity());
-      }
-    };
-  }
-}
diff --git a/src/main/java/com/google/devtools/build/lib/testing/actions/BUILD b/src/main/java/com/google/devtools/build/lib/testing/actions/BUILD
deleted file mode 100644
index b86183e..0000000
--- a/src/main/java/com/google/devtools/build/lib/testing/actions/BUILD
+++ /dev/null
@@ -1,26 +0,0 @@
-load("@rules_java//java:defs.bzl", "java_library")
-
-package(
-    default_testonly = True,
-    default_visibility = ["//src:__subpackages__"],
-)
-
-licenses(["notice"])
-
-filegroup(
-    name = "srcs",
-    testonly = False,
-    srcs = glob(["**"]),
-    visibility = ["//src:__subpackages__"],
-)
-
-java_library(
-    name = "artifact_expander_helper",
-    srcs = ["ArtifactExpanderHelper.java"],
-    deps = [
-        "//src/main/java/com/google/devtools/build/lib/actions",
-        "//src/main/java/com/google/devtools/build/lib/actions:artifacts",
-        "//src/main/java/com/google/devtools/build/lib/actions:middleman_type",
-        "//third_party:guava",
-    ],
-)
diff --git a/src/test/java/com/google/devtools/build/lib/actions/ArtifactTest.java b/src/test/java/com/google/devtools/build/lib/actions/ArtifactTest.java
index a0790c3..d9ff846 100644
--- a/src/test/java/com/google/devtools/build/lib/actions/ArtifactTest.java
+++ b/src/test/java/com/google/devtools/build/lib/actions/ArtifactTest.java
@@ -26,20 +26,16 @@
 import com.google.devtools.build.lib.actions.Artifact.SpecialArtifactType;
 import com.google.devtools.build.lib.actions.ArtifactResolver.ArtifactResolverSupplier;
 import com.google.devtools.build.lib.actions.ArtifactRoot.RootType;
-import com.google.devtools.build.lib.actions.MutableActionGraph.ActionConflictException;
 import com.google.devtools.build.lib.actions.util.ActionsTestUtil;
 import com.google.devtools.build.lib.actions.util.LabelArtifactOwner;
 import com.google.devtools.build.lib.cmdline.Label;
 import com.google.devtools.build.lib.cmdline.LabelConstants;
-import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder;
-import com.google.devtools.build.lib.collect.nestedset.Order;
 import com.google.devtools.build.lib.rules.cpp.CppFileTypes;
 import com.google.devtools.build.lib.rules.java.JavaSemantics;
 import com.google.devtools.build.lib.skyframe.serialization.AutoRegistry;
 import com.google.devtools.build.lib.skyframe.serialization.ObjectCodecs;
 import com.google.devtools.build.lib.skyframe.serialization.testutils.SerializationDepsUtils;
 import com.google.devtools.build.lib.skyframe.serialization.testutils.SerializationTester;
-import com.google.devtools.build.lib.testing.actions.ArtifactExpanderHelper;
 import com.google.devtools.build.lib.testutil.Scratch;
 import com.google.devtools.build.lib.util.FileType;
 import com.google.devtools.build.lib.util.FileTypeSet;
@@ -62,7 +58,6 @@
   private Scratch scratch;
   private Path execDir;
   private ArtifactRoot rootDir;
-  private final ActionKeyContext actionKeyContext = new ActionKeyContext();
 
   @Before
   public final void setRootDir() throws Exception  {
@@ -176,77 +171,24 @@
     assertThat(Actions.escapedPath(path)).isEqualTo("dir_Ssub_Udir_Sname_Cend");
   }
 
-  private List<Artifact> getFooBarArtifacts(MutableActionGraph actionGraph, boolean collapsedList)
-      throws Exception {
+  private List<Artifact> getFooBarArtifacts(boolean collapsedList) throws Exception {
     ArtifactRoot root = ArtifactRoot.asSourceRoot(Root.fromPath(scratch.dir("/foo")));
     Artifact aHeader1 = ActionsTestUtil.createArtifact(root, scratch.file("/foo/bar1.h"));
     Artifact aHeader2 = ActionsTestUtil.createArtifact(root, scratch.file("/foo/bar2.h"));
-    Artifact aHeader3 = ActionsTestUtil.createArtifact(root, scratch.file("/foo/bar3.h"));
-    ArtifactRoot middleRoot =
-        ArtifactRoot.asDerivedRoot(
-            scratch.dir("/foo"), RootType.Middleman, PathFragment.create("out"));
-    Artifact middleman = ActionsTestUtil.createArtifact(middleRoot, "middleman");
-    MiddlemanAction.create(
-        new ActionRegistry() {
-          @Override
-          public void registerAction(ActionAnalysisMetadata action) {
-            try {
-              actionGraph.registerAction(action);
-            } catch (ActionConflictException e) {
-              throw new IllegalStateException(e);
-            } catch (InterruptedException e) {
-              Thread.currentThread().interrupt();
-              throw new IllegalStateException("Didn't expect interrupt in test", e);
-            }
-          }
-
-          @Override
-          public ActionLookupKey getOwner() {
-            throw new UnsupportedOperationException();
-          }
-        },
-        ActionsTestUtil.NULL_ACTION_OWNER,
-        NestedSetBuilder.create(Order.STABLE_ORDER, aHeader1, aHeader2, aHeader3),
-        middleman,
-        "desc",
-        MiddlemanType.AGGREGATING_MIDDLEMAN);
-    return collapsedList ? Lists.newArrayList(aHeader1, middleman) :
-        Lists.newArrayList(aHeader1, aHeader2, middleman);
+    return collapsedList ? Lists.newArrayList(aHeader1) : Lists.newArrayList(aHeader1, aHeader2);
   }
 
   @Test
   public void testAddExecPaths() throws Exception {
     List<String> paths = new ArrayList<>();
-    MutableActionGraph actionGraph = new MapBasedActionGraph(actionKeyContext);
-    Artifact.addExecPaths(getFooBarArtifacts(actionGraph, false), paths);
+    Artifact.addExecPaths(getFooBarArtifacts(false), paths);
     assertThat(paths).containsExactly("bar1.h", "bar2.h");
   }
 
   @Test
-  public void testAddExpandedArtifacts() throws Exception {
-    List<Artifact> expanded = new ArrayList<>();
-    MutableActionGraph actionGraph = new MapBasedActionGraph(actionKeyContext);
-    List<Artifact> original = getFooBarArtifacts(actionGraph, true);
-    Artifact.addExpandedArtifacts(
-        original, expanded, ArtifactExpanderHelper.actionGraphArtifactExpander(actionGraph));
-
-    List<Artifact> manuallyExpanded = new ArrayList<>();
-    for (Artifact artifact : original) {
-      ActionAnalysisMetadata action = actionGraph.getGeneratingAction(artifact);
-      if (artifact.isMiddlemanArtifact()) {
-        manuallyExpanded.addAll(action.getInputs().toList());
-      } else {
-        manuallyExpanded.add(artifact);
-      }
-    }
-    assertThat(expanded).containsExactlyElementsIn(manuallyExpanded);
-  }
-
-  @Test
   public void testAddExecPathsNewActionGraph() throws Exception {
     List<String> paths = new ArrayList<>();
-    MutableActionGraph actionGraph = new MapBasedActionGraph(actionKeyContext);
-    Artifact.addExecPaths(getFooBarArtifacts(actionGraph, false), paths);
+    Artifact.addExecPaths(getFooBarArtifacts(false), paths);
     assertThat(paths).containsExactly("bar1.h", "bar2.h");
   }
 
diff --git a/src/test/java/com/google/devtools/build/lib/actions/BUILD b/src/test/java/com/google/devtools/build/lib/actions/BUILD
index 9338e7b..c31a3a7 100644
--- a/src/test/java/com/google/devtools/build/lib/actions/BUILD
+++ b/src/test/java/com/google/devtools/build/lib/actions/BUILD
@@ -53,7 +53,6 @@
         "//src/main/java/com/google/devtools/build/lib/skyframe/serialization",
         "//src/main/java/com/google/devtools/build/lib/skyframe/serialization/testutils",
         "//src/main/java/com/google/devtools/build/lib/skyframe/serialization/testutils:depsutils",
-        "//src/main/java/com/google/devtools/build/lib/testing/actions:artifact_expander_helper",
         "//src/main/java/com/google/devtools/build/lib/util",
         "//src/main/java/com/google/devtools/build/lib/util:filetype",
         "//src/main/java/com/google/devtools/build/lib/util:string",
diff --git a/src/test/java/com/google/devtools/build/lib/actions/util/ActionsTestUtil.java b/src/test/java/com/google/devtools/build/lib/actions/util/ActionsTestUtil.java
index 519680a..c5699a5 100644
--- a/src/test/java/com/google/devtools/build/lib/actions/util/ActionsTestUtil.java
+++ b/src/test/java/com/google/devtools/build/lib/actions/util/ActionsTestUtil.java
@@ -79,7 +79,6 @@
 import com.google.devtools.build.lib.skyframe.ActionTemplateExpansionValue.ActionTemplateExpansionKey;
 import com.google.devtools.build.lib.skyframe.TreeArtifactValue;
 import com.google.devtools.build.lib.skyframe.serialization.autocodec.SerializationConstant;
-import com.google.devtools.build.lib.testing.actions.ArtifactExpanderHelper;
 import com.google.devtools.build.lib.util.FileType;
 import com.google.devtools.build.lib.util.Fingerprint;
 import com.google.devtools.build.lib.util.ResourceUsage;
@@ -173,9 +172,7 @@
         eventHandler,
         ImmutableMap.copyOf(clientEnv),
         /*topLevelFilesets=*/ ImmutableMap.of(),
-        actionGraph == null
-            ? (artifact, output) -> {}
-            : ArtifactExpanderHelper.actionGraphArtifactExpander(actionGraph),
+        (artifact, output) -> {},
         /*actionFileSystem=*/ null,
         /*skyframeDepsResult=*/ null,
         NestedSetExpander.DEFAULT,
@@ -513,7 +510,8 @@
 
     @Override
     public MiddlemanType getActionType() {
-      return middleman ? MiddlemanType.AGGREGATING_MIDDLEMAN : super.getActionType();
+      // RUNFILES_MIDDLEMAN is chosen arbitrarily among the middleman types.
+      return middleman ? MiddlemanType.RUNFILES_MIDDLEMAN : super.getActionType();
     }
 
     @Override
diff --git a/src/test/java/com/google/devtools/build/lib/actions/util/BUILD b/src/test/java/com/google/devtools/build/lib/actions/util/BUILD
index 80cf794..72df533 100644
--- a/src/test/java/com/google/devtools/build/lib/actions/util/BUILD
+++ b/src/test/java/com/google/devtools/build/lib/actions/util/BUILD
@@ -38,7 +38,6 @@
         "//src/main/java/com/google/devtools/build/lib/skyframe:tree_artifact_value",
         "//src/main/java/com/google/devtools/build/lib/skyframe/serialization/autocodec",
         "//src/main/java/com/google/devtools/build/lib/skyframe/serialization/autocodec:serialization-constant",
-        "//src/main/java/com/google/devtools/build/lib/testing/actions:artifact_expander_helper",
         "//src/main/java/com/google/devtools/build/lib/util",
         "//src/main/java/com/google/devtools/build/lib/util:crash_failure_details",
         "//src/main/java/com/google/devtools/build/lib/util:detailed_exit_code",
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/ArtifactFunctionTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/ArtifactFunctionTest.java
index 58f4482..fa7140c 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/ArtifactFunctionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/ArtifactFunctionTest.java
@@ -149,7 +149,7 @@
         new DummyAction(
             NestedSetBuilder.create(Order.STABLE_ORDER, input1, input2, tree),
             output,
-            MiddlemanType.AGGREGATING_MIDDLEMAN);
+            MiddlemanType.RUNFILES_MIDDLEMAN);
     actions.add(action);
     file(input2.getPath(), "contents");
     file(input1.getPath(), "source contents");
@@ -158,8 +158,8 @@
             Artifact.keys(ImmutableSet.of(input2, input1, input2, tree)), SkyKey.class));
     SkyValue value = evaluateArtifactValue(output);
     ArrayList<Pair<Artifact, ?>> inputs = new ArrayList<>();
-    inputs.addAll(((AggregatingArtifactValue) value).getFileArtifacts());
-    inputs.addAll(((AggregatingArtifactValue) value).getTreeArtifacts());
+    inputs.addAll(((RunfilesArtifactValue) value).getFileArtifacts());
+    inputs.addAll(((RunfilesArtifactValue) value).getTreeArtifacts());
     assertThat(inputs)
         .containsExactly(
             Pair.of(input1, createForTesting(input1)),
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/BUILD b/src/test/java/com/google/devtools/build/lib/skyframe/BUILD
index 4d898b1..5c4311c 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/BUILD
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/BUILD
@@ -178,7 +178,6 @@
         "//src/main/java/com/google/devtools/build/lib/skyframe:action_sketch_function",
         "//src/main/java/com/google/devtools/build/lib/skyframe:action_template_expansion_function",
         "//src/main/java/com/google/devtools/build/lib/skyframe:action_template_expansion_value",
-        "//src/main/java/com/google/devtools/build/lib/skyframe:aggregating_artifact_value",
         "//src/main/java/com/google/devtools/build/lib/skyframe:artifact_function",
         "//src/main/java/com/google/devtools/build/lib/skyframe:aspect_value_key",
         "//src/main/java/com/google/devtools/build/lib/skyframe:bzl_compile",
@@ -230,6 +229,7 @@
         "//src/main/java/com/google/devtools/build/lib/skyframe:recursive_pkg_key",
         "//src/main/java/com/google/devtools/build/lib/skyframe:recursive_pkg_value",
         "//src/main/java/com/google/devtools/build/lib/skyframe:repository_mapping_value",
+        "//src/main/java/com/google/devtools/build/lib/skyframe:runfiles_artifact_value",
         "//src/main/java/com/google/devtools/build/lib/skyframe:sky_functions",
         "//src/main/java/com/google/devtools/build/lib/skyframe:skyframe_aware_action",
         "//src/main/java/com/google/devtools/build/lib/skyframe:skyframe_cluster",