Remove special handling of middleman actions.

Now that the only type of middleman is the runfiles one, we don't need to jump through a lot of hoops we had to for other sorts of middlemen that did not represent actual inputs to actions.

MiddlemanType is kept for the time being for an easier rollback of this change, if need be.

RELNOTES: Actions that create runfiles trees are now considered regular actions. This means that they are now reported in statistics, critical paths and the like.
PiperOrigin-RevId: 690642037
Change-Id: I472df8a8ad8235e5c8f616c8e354a5fd4739630e
diff --git a/src/main/java/com/google/devtools/build/lib/actions/ActionCacheChecker.java b/src/main/java/com/google/devtools/build/lib/actions/ActionCacheChecker.java
index e765121..081e977 100644
--- a/src/main/java/com/google/devtools/build/lib/actions/ActionCacheChecker.java
+++ b/src/main/java/com/google/devtools/build/lib/actions/ActionCacheChecker.java
@@ -42,7 +42,6 @@
 import com.google.devtools.build.lib.skyframe.TreeArtifactValue;
 import com.google.devtools.build.lib.skyframe.TreeArtifactValue.ArchivedRepresentation;
 import com.google.devtools.build.lib.vfs.OutputPermissions;
-import com.google.devtools.build.lib.vfs.Path;
 import com.google.devtools.build.lib.vfs.PathFragment;
 import java.io.FileNotFoundException;
 import java.io.IOException;
@@ -231,8 +230,8 @@
       }
     }
     for (Artifact artifact : actionInputs.toList()) {
-      mdMap.put(
-          artifact.getExecPathString(), getInputMetadataMaybe(inputMetadataProvider, artifact));
+      FileArtifactValue inputMetadata = getInputMetadataMaybe(inputMetadataProvider, artifact);
+      mdMap.put(artifact.getExecPathString(), inputMetadata);
     }
     return !Arrays.equals(MetadataDigestUtils.fromMetadata(mdMap), entry.getFileDigest());
   }
@@ -606,6 +605,7 @@
       actionCache.accountMiss(MissReason.UNCONDITIONAL_EXECUTION);
       return true;
     }
+
     if (entry == null) {
       reportNewAction(handler, action);
       actionCache.accountMiss(MissReason.NOT_CACHED);
@@ -657,7 +657,7 @@
       InputMetadataProvider inputMetadataProvider, Artifact artifact) throws IOException {
     FileArtifactValue metadata = inputMetadataProvider.getInputMetadata(artifact);
     return (metadata != null && artifact.isConstantMetadata())
-        ? ConstantMetadataValue.INSTANCE
+        ? FileArtifactValue.ConstantMetadataValue.INSTANCE
         : metadata;
   }
 
@@ -666,7 +666,7 @@
       throws IOException, InterruptedException {
     FileArtifactValue metadata = outputMetadataStore.getOutputMetadata(artifact);
     return (metadata != null && artifact.isConstantMetadata())
-        ? ConstantMetadataValue.INSTANCE
+        ? FileArtifactValue.ConstantMetadataValue.INSTANCE
         : metadata;
   }
 
@@ -992,44 +992,4 @@
     }
   }
 
-  private static final class ConstantMetadataValue extends FileArtifactValue
-      implements FileArtifactValue.Singleton {
-    static final ConstantMetadataValue INSTANCE = new ConstantMetadataValue();
-    // This needs to not be of length 0, so it is distinguishable from a missing digest when written
-    // into a Fingerprint.
-    private static final byte[] DIGEST = new byte[1];
-
-    private ConstantMetadataValue() {}
-
-    @Override
-    public FileStateType getType() {
-      return FileStateType.REGULAR_FILE;
-    }
-
-    @Override
-    public byte[] getDigest() {
-      return DIGEST;
-    }
-
-    @Override
-    public FileContentsProxy getContentsProxy() {
-      throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public long getSize() {
-      return 0;
-    }
-
-    @Override
-    public long getModifiedTime() {
-      return -1;
-    }
-
-    @Override
-    public boolean wasModifiedSinceDigest(Path path) {
-      throw new UnsupportedOperationException(
-          "ConstantMetadataValue doesn't support wasModifiedSinceDigest " + path.toString());
-    }
-  }
 }
diff --git a/src/main/java/com/google/devtools/build/lib/actions/ActionMiddlemanEvent.java b/src/main/java/com/google/devtools/build/lib/actions/ActionMiddlemanEvent.java
deleted file mode 100644
index 767a30c..0000000
--- a/src/main/java/com/google/devtools/build/lib/actions/ActionMiddlemanEvent.java
+++ /dev/null
@@ -1,72 +0,0 @@
-// Copyright 2015 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.actions;
-
-import com.google.common.base.Preconditions;
-import com.google.devtools.build.lib.events.ExtendedEventHandler.Postable;
-
-/**
- * This event is fired during the build, when a middleman action is executed. Middleman actions
- * don't usually do any computation but we need them in the critical path because they depend on
- * other actions.
- */
-public final class ActionMiddlemanEvent implements Postable {
-
-  private final Action action;
-  private final InputMetadataProvider inputMetadataProvider;
-  private final long nanoTimeStart;
-  private final long nanoTimeFinish;
-
-  /**
-   * Create an event for action that has been started.
-   *
-   * @param action the middleman action.
-   * @param inputMetadataProvider the metadata about the inputs of the action
-   * @param nanoTimeStart the time when the action was started. This allow us to record more
-   *     accurately the time spent by the middleman action, since even for middleman actions we
-   *     execute some.
-   */
-  public ActionMiddlemanEvent(
-      Action action,
-      InputMetadataProvider inputMetadataProvider,
-      long nanoTimeStart,
-      long nanoTimeFinish) {
-    Preconditions.checkArgument(action.getActionType().isMiddleman(),
-        "Only middleman actions should be passed: %s", action);
-    this.action = action;
-    this.inputMetadataProvider = inputMetadataProvider;
-    this.nanoTimeStart = nanoTimeStart;
-    this.nanoTimeFinish = nanoTimeFinish;
-  }
-
-  /**
-   * Returns the associated action.
-   */
-  public Action getAction() {
-    return action;
-  }
-
-  /** Returns the metadata of the inputs of the action. */
-  public InputMetadataProvider getInputMetadataProvider() {
-    return inputMetadataProvider;
-  }
-
-  public long getNanoTimeStart() {
-    return nanoTimeStart;
-  }
-
-  public long getNanoTimeFinish() {
-    return nanoTimeFinish;
-  }
-}
diff --git a/src/main/java/com/google/devtools/build/lib/actions/BUILD b/src/main/java/com/google/devtools/build/lib/actions/BUILD
index a0cb04a..050b6c4 100644
--- a/src/main/java/com/google/devtools/build/lib/actions/BUILD
+++ b/src/main/java/com/google/devtools/build/lib/actions/BUILD
@@ -58,7 +58,6 @@
         "ActionKeyContext.java",
         "ActionLogBufferPathGenerator.java",
         "ActionLookupValue.java",
-        "ActionMiddlemanEvent.java",
         "ActionOwner.java",
         "ActionProgressEvent.java",
         "ActionRegistry.java",
@@ -436,6 +435,7 @@
         ":file_metadata",
         ":runfiles_tree",
         "//src/main/java/com/google/devtools/build/lib/skyframe:tree_artifact_value",
+        "//src/main/java/com/google/devtools/build/lib/util",
         "//src/main/java/com/google/devtools/build/lib/util:hash_codes",
         "//src/main/java/com/google/devtools/build/skyframe:skyframe-objects",
         "//third_party:guava",
diff --git a/src/main/java/com/google/devtools/build/lib/actions/FileArtifactValue.java b/src/main/java/com/google/devtools/build/lib/actions/FileArtifactValue.java
index 774175e..704972c 100644
--- a/src/main/java/com/google/devtools/build/lib/actions/FileArtifactValue.java
+++ b/src/main/java/com/google/devtools/build/lib/actions/FileArtifactValue.java
@@ -972,4 +972,46 @@
       return "singleton marker artifact value (" + hashCode() + ")";
     }
   }
+
+  /** {@link FileArtifactValue} subclass for artifacts with constant metadata. A singleton. */
+  public static final class ConstantMetadataValue extends FileArtifactValue
+      implements FileArtifactValue.Singleton {
+    static final ConstantMetadataValue INSTANCE = new ConstantMetadataValue();
+    // This needs to not be of length 0, so it is distinguishable from a missing digest when written
+    // into a Fingerprint.
+    private static final byte[] DIGEST = new byte[1];
+
+    private ConstantMetadataValue() {}
+
+    @Override
+    public FileStateType getType() {
+      return FileStateType.REGULAR_FILE;
+    }
+
+    @Override
+    public byte[] getDigest() {
+      return DIGEST;
+    }
+
+    @Override
+    public FileContentsProxy getContentsProxy() {
+      throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public long getSize() {
+      return 0;
+    }
+
+    @Override
+    public long getModifiedTime() {
+      return -1;
+    }
+
+    @Override
+    public boolean wasModifiedSinceDigest(Path path) {
+      throw new UnsupportedOperationException(
+          "ConstantMetadataValue doesn't support wasModifiedSinceDigest " + path);
+    }
+  }
 }
diff --git a/src/main/java/com/google/devtools/build/lib/actions/MiddlemanAction.java b/src/main/java/com/google/devtools/build/lib/actions/MiddlemanAction.java
index 6ca6e8d..94b3fd8 100644
--- a/src/main/java/com/google/devtools/build/lib/actions/MiddlemanAction.java
+++ b/src/main/java/com/google/devtools/build/lib/actions/MiddlemanAction.java
@@ -22,6 +22,8 @@
 import com.google.devtools.build.lib.collect.nestedset.NestedSet;
 import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable;
 import com.google.devtools.build.lib.util.Fingerprint;
+import com.google.devtools.build.lib.vfs.BulkDeleter;
+import com.google.devtools.build.lib.vfs.Path;
 import javax.annotation.Nullable;
 
 /**
@@ -53,7 +55,18 @@
 
   @Override
   public ActionResult execute(ActionExecutionContext actionExecutionContext) {
-    throw new IllegalStateException("MiddlemanAction should never be executed");
+    return ActionResult.EMPTY;
+  }
+
+  @Override
+  public void prepare(
+      Path execRoot,
+      ArtifactPathResolver pathResolver,
+      @Nullable BulkDeleter bulkDeleter,
+      boolean cleanupArchivedArtifacts) {
+    // Runfiles trees are created as a side effect of building the output manifest, not the runfiles
+    // tree artifact. This method is overridden so that depending on the runfiles middleman does not
+    // delete the runfiles tree that's on the file system that someone decided it must be there.
   }
 
   @Override
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 c10146a..dca392b 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
@@ -13,7 +13,7 @@
 // limitations under the License.
 package com.google.devtools.build.lib.actions;
 
-/** The action type. */
+/** Deprecated, slated to be removed. */
 public enum MiddlemanType {
 
   /** A normal action. */
@@ -27,6 +27,9 @@
   RUNFILES_MIDDLEMAN;
 
   public boolean isMiddleman() {
-    return this != NORMAL;
+    // This value is always false, which means that in theory, the MiddlemanType enum is not useful
+    // anymore. It's kept here to facilitate an easy rollback for the change that made the enum
+    // unnecessary should trouble arise.
+    return false;
   }
 }
diff --git a/src/main/java/com/google/devtools/build/lib/actions/RunfilesArtifactValue.java b/src/main/java/com/google/devtools/build/lib/actions/RunfilesArtifactValue.java
index a3e933d..30ae791 100644
--- a/src/main/java/com/google/devtools/build/lib/actions/RunfilesArtifactValue.java
+++ b/src/main/java/com/google/devtools/build/lib/actions/RunfilesArtifactValue.java
@@ -18,7 +18,9 @@
 
 import com.google.common.base.MoreObjects;
 import com.google.common.collect.ImmutableList;
+import com.google.devtools.build.lib.actions.FileArtifactValue.ConstantMetadataValue;
 import com.google.devtools.build.lib.skyframe.TreeArtifactValue;
+import com.google.devtools.build.lib.util.Fingerprint;
 import com.google.devtools.build.lib.util.HashCodes;
 import com.google.devtools.build.skyframe.SkyValue;
 
@@ -43,13 +45,11 @@
   private final ImmutableList<TreeArtifactValue> treeValues;
 
   public RunfilesArtifactValue(
-      FileArtifactValue metadata,
       RunfilesTree runfilesTree,
       ImmutableList<Artifact> files,
       ImmutableList<FileArtifactValue> fileValues,
       ImmutableList<Artifact> trees,
       ImmutableList<TreeArtifactValue> treeValues) {
-    this.metadata = checkNotNull(metadata);
     this.runfilesTree = checkNotNull(runfilesTree);
     this.files = checkNotNull(files);
     this.fileValues = checkNotNull(fileValues);
@@ -59,10 +59,41 @@
         files.size() == fileValues.size() && trees.size() == treeValues.size(),
         "Size mismatch: %s",
         this);
+
+    // Compute the digest of this runfiles tree by combining its layout and the digests of every
+    // artifact it references.
+    this.metadata = FileArtifactValue.createProxy(computeDigest());
+  }
+
+  private byte[] computeDigest() {
+    Fingerprint result = new Fingerprint();
+
+    result.addInt(runfilesTree.getMapping().size());
+    for (var entry : runfilesTree.getMapping().entrySet()) {
+      result.addPath(entry.getKey());
+      result.addBoolean(entry.getValue() != null);
+      if (entry.getValue() != null) {
+        result.addPath(entry.getValue().getExecPath());
+      }
+    }
+
+    result.addInt(files.size());
+    for (int i = 0; i < files.size(); i++) {
+      FileArtifactValue value =
+          files.get(i).isConstantMetadata() ? ConstantMetadataValue.INSTANCE : fileValues.get(i);
+      value.addTo(result);
+    }
+
+    result.addInt(trees.size());
+    for (int i = 0; i < trees.size(); i++) {
+      result.addBytes(treeValues.get(i).getDigest());
+    }
+
+    return result.digestAndReset();
   }
 
   public RunfilesArtifactValue withOverriddenRunfilesTree(RunfilesTree overrideTree) {
-    return new RunfilesArtifactValue(metadata, overrideTree, files, fileValues, trees, treeValues);
+    return new RunfilesArtifactValue(overrideTree, files, fileValues, trees, treeValues);
   }
 
   /** Returns the data of the artifact for this value, as computed by the action cache checker. */
diff --git a/src/main/java/com/google/devtools/build/lib/buildtool/ExecutionProgressReceiver.java b/src/main/java/com/google/devtools/build/lib/buildtool/ExecutionProgressReceiver.java
index a7684e7..cb6cc8c 100644
--- a/src/main/java/com/google/devtools/build/lib/buildtool/ExecutionProgressReceiver.java
+++ b/src/main/java/com/google/devtools/build/lib/buildtool/ExecutionProgressReceiver.java
@@ -19,7 +19,6 @@
 import com.google.devtools.build.lib.actions.Action;
 import com.google.devtools.build.lib.actions.ActionExecutionStatusReporter;
 import com.google.devtools.build.lib.actions.ActionLookupData;
-import com.google.devtools.build.lib.actions.MiddlemanType;
 import com.google.devtools.build.lib.analysis.ConfiguredTargetValue;
 import com.google.devtools.build.lib.skyframe.ActionExecutionInactivityWatchdog;
 import com.google.devtools.build.lib.skyframe.AspectCompletionValue;
@@ -184,7 +183,7 @@
   }
 
   private static boolean isActionReportWorthy(Action action) {
-    return action.getActionType() == MiddlemanType.NORMAL;
+    return !action.getActionType().isMiddleman();
   }
 
   @Override
diff --git a/src/main/java/com/google/devtools/build/lib/metrics/criticalpath/CriticalPathComputer.java b/src/main/java/com/google/devtools/build/lib/metrics/criticalpath/CriticalPathComputer.java
index 6e5ad22..a6e6dff 100644
--- a/src/main/java/com/google/devtools/build/lib/metrics/criticalpath/CriticalPathComputer.java
+++ b/src/main/java/com/google/devtools/build/lib/metrics/criticalpath/CriticalPathComputer.java
@@ -26,7 +26,6 @@
 import com.google.devtools.build.lib.actions.ActionAnalysisMetadata;
 import com.google.devtools.build.lib.actions.ActionCompletionEvent;
 import com.google.devtools.build.lib.actions.ActionKeyContext;
-import com.google.devtools.build.lib.actions.ActionMiddlemanEvent;
 import com.google.devtools.build.lib.actions.ActionStartedEvent;
 import com.google.devtools.build.lib.actions.Actions;
 import com.google.devtools.build.lib.actions.AggregatedSpawnMetrics;
@@ -235,23 +234,6 @@
   }
 
   /**
-   * Record a middleman action execution. Even if middleman are almost instant, we record them
-   * because they depend on other actions and we need them for constructing the critical path.
-   *
-   * <p>For some rules with incorrect configuration transitions we might get notified several times
-   * for the same middleman. This should only happen if the actions are shared.
-   */
-  @Subscribe
-  @AllowConcurrentEvents
-  public void middlemanAction(ActionMiddlemanEvent event) throws InterruptedException {
-    Action action = event.getAction();
-    CriticalPathComponent component =
-        tryAddComponent(createComponent(action, event.getNanoTimeStart()));
-    finalizeActionStat(
-        event.getNanoTimeStart(), event.getNanoTimeFinish(), action, component, "middleman action");
-  }
-
-  /**
    * Try to add the component to the map of critical path components. If there is an existing
    * component for its primary output it uses that to update the rest of the outputs.
    *
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/ExecutionGraphModule.java b/src/main/java/com/google/devtools/build/lib/runtime/ExecutionGraphModule.java
index f931f4b..ea5cfcf 100644
--- a/src/main/java/com/google/devtools/build/lib/runtime/ExecutionGraphModule.java
+++ b/src/main/java/com/google/devtools/build/lib/runtime/ExecutionGraphModule.java
@@ -29,7 +29,6 @@
 import com.google.devtools.build.lib.actions.ActionCompletionEvent;
 import com.google.devtools.build.lib.actions.ActionExecutionMetadata;
 import com.google.devtools.build.lib.actions.ActionInput;
-import com.google.devtools.build.lib.actions.ActionMiddlemanEvent;
 import com.google.devtools.build.lib.actions.ActionOwner;
 import com.google.devtools.build.lib.actions.Artifact;
 import com.google.devtools.build.lib.actions.CachedActionEvent;
@@ -181,7 +180,6 @@
 
   private ActionDumpWriter writer;
   private CommandEnvironment env;
-  private ExecutionGraphOptions options;
   private NanosToMillisSinceEpochConverter nanosToMillis =
       BlazeClock.createNanosToMillisSinceEpochConverter();
   // Only relevant for Skymeld: there may be multiple events and we only count the first one.
@@ -200,11 +198,6 @@
   }
 
   @VisibleForTesting
-  void setOptions(ExecutionGraphOptions options) {
-    this.options = options;
-  }
-
-  @VisibleForTesting
   void setNanosToMillis(NanosToMillisSinceEpochConverter nanosToMillis) {
     this.nanosToMillis = nanosToMillis;
   }
@@ -234,7 +227,6 @@
                                 BuildReport.newBuilder().setCode(Code.BUILD_REPORT_WRITE_FAILED))
                             .build())));
       }
-      this.options = options;
     }
   }
 
@@ -329,24 +321,6 @@
         event.getNanoTimeFinish());
   }
 
-  /**
-   * Record a middleman action execution. We may not needs this since we expand the runfiles
-   * supplier inputs, but it's left here in case we need it.
-   *
-   * <p>TODO(vanja) remove this if it's not necessary.
-   */
-  @Subscribe
-  @AllowConcurrentEvents
-  public void middlemanAction(ActionMiddlemanEvent event) {
-    if (options.logMiddlemanActions) {
-      actionEvent(
-          event.getAction(),
-          event.getInputMetadataProvider(),
-          event.getNanoTimeStart(),
-          event.getNanoTimeFinish());
-    }
-  }
-
   private void actionEvent(
       Action action,
       InputMetadataProvider inputMetadataProvider,
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 9b12ffa..167023d 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
@@ -191,8 +191,7 @@
             "Null middleman action? %s",
             artifactDependencies);
 
-    FileArtifactValue individualMetadata = actionValue.getExistingFileArtifactValue(artifact);
-    return createRunfilesArtifactValue(artifact, (MiddlemanAction) action, individualMetadata, env);
+    return createRunfilesArtifactValue(artifact, (MiddlemanAction) action, env);
   }
 
   private static void mkdirForTreeArtifact(
@@ -382,7 +381,6 @@
   private static RunfilesArtifactValue createRunfilesArtifactValue(
       Artifact artifact,
       MiddlemanAction action,
-      FileArtifactValue value,
       SkyFunction.Environment env)
       throws InterruptedException {
     ImmutableList<Artifact> inputs = action.getInputs().toList();
@@ -425,7 +423,6 @@
     }
 
     return new RunfilesArtifactValue(
-        value,
         action.getRunfilesTree(),
         files.build(),
         fileValues.build(),
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeActionExecutor.java b/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeActionExecutor.java
index 6429b00..2ae3f90 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeActionExecutor.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeActionExecutor.java
@@ -43,7 +43,6 @@
 import com.google.devtools.build.lib.actions.ActionKeyContext;
 import com.google.devtools.build.lib.actions.ActionLogBufferPathGenerator;
 import com.google.devtools.build.lib.actions.ActionLookupData;
-import com.google.devtools.build.lib.actions.ActionMiddlemanEvent;
 import com.google.devtools.build.lib.actions.ActionOutputDirectoryHelper;
 import com.google.devtools.build.lib.actions.ActionOutputDirectoryHelper.CreateOutputDirectoryException;
 import com.google.devtools.build.lib.actions.ActionOwner;
@@ -688,13 +687,6 @@
 
       if (token == null) {
         boolean eventPosted = false;
-        // Notify BlazeRuntimeStatistics about the action middleman 'execution'.
-        if (action.getActionType().isMiddleman()) {
-          eventHandler.post(
-              new ActionMiddlemanEvent(
-                  action, inputMetadataProvider, actionStartTime, BlazeClock.nanoTime()));
-          eventPosted = true;
-        }
 
         if (action instanceof NotifyOnActionCacheHit notify) {
           ExtendedEventHandler contextEventHandler = selectEventHandler(action);
diff --git a/src/test/java/com/google/devtools/build/lib/actions/ActionCacheCheckerTest.java b/src/test/java/com/google/devtools/build/lib/actions/ActionCacheCheckerTest.java
index 18257f5..4ed7c32 100644
--- a/src/test/java/com/google/devtools/build/lib/actions/ActionCacheCheckerTest.java
+++ b/src/test/java/com/google/devtools/build/lib/actions/ActionCacheCheckerTest.java
@@ -44,15 +44,11 @@
 import com.google.devtools.build.lib.actions.cache.Protos.ActionCacheStatistics;
 import com.google.devtools.build.lib.actions.cache.Protos.ActionCacheStatistics.MissDetail;
 import com.google.devtools.build.lib.actions.cache.Protos.ActionCacheStatistics.MissReason;
-import com.google.devtools.build.lib.actions.util.ActionsTestUtil;
 import com.google.devtools.build.lib.actions.util.ActionsTestUtil.FakeArtifactResolverBase;
 import com.google.devtools.build.lib.actions.util.ActionsTestUtil.FakeInputMetadataHandlerBase;
 import com.google.devtools.build.lib.actions.util.ActionsTestUtil.MissDetailsBuilder;
 import com.google.devtools.build.lib.actions.util.ActionsTestUtil.NullAction;
 import com.google.devtools.build.lib.clock.Clock;
-import com.google.devtools.build.lib.collect.nestedset.NestedSet;
-import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder;
-import com.google.devtools.build.lib.collect.nestedset.Order;
 import com.google.devtools.build.lib.events.NullEventHandler;
 import com.google.devtools.build.lib.skyframe.TreeArtifactValue;
 import com.google.devtools.build.lib.testutil.ManualClock;
@@ -65,7 +61,6 @@
 import com.google.devtools.build.lib.vfs.OutputPermissions;
 import com.google.devtools.build.lib.vfs.Path;
 import com.google.devtools.build.lib.vfs.PathFragment;
-import com.google.devtools.build.lib.vfs.Root;
 import com.google.devtools.build.lib.vfs.inmemoryfs.InMemoryFileSystem;
 import com.google.testing.junit.testparameterinjector.TestParameter;
 import com.google.testing.junit.testparameterinjector.TestParameterInjector;
@@ -436,55 +431,6 @@
   }
 
   @Test
-  public void testMiddleman_notCached() throws Exception {
-    doTestNotCached(new NullMiddlemanAction(), MissReason.DIFFERENT_DEPS);
-  }
-
-  @Test
-  public void testMiddleman_cached() throws Exception {
-    doTestCached(new NullMiddlemanAction(), MissReason.DIFFERENT_DEPS);
-  }
-
-  @Test
-  public void testMiddleman_corruptedCacheEntry() throws Exception {
-    doTestCorruptedCacheEntry(new NullMiddlemanAction());
-  }
-
-  @Test
-  public void testMiddleman_differentFiles() throws Exception {
-    Action action =
-        new NullMiddlemanAction() {
-          @Override
-          public synchronized NestedSet<Artifact> getInputs() {
-            FileSystem fileSystem = getPrimaryOutput().getPath().getFileSystem();
-            Path path = fileSystem.getPath("/input");
-            ArtifactRoot root = ArtifactRoot.asSourceRoot(Root.fromPath(fileSystem.getPath("/")));
-            return NestedSetBuilder.create(
-                Order.STABLE_ORDER, ActionsTestUtil.createArtifact(root, path));
-          }
-        };
-    // Manually register outputs of middleman action in `filesToDelete` because it won't get a cache
-    // token to execute and register in `runAction`. Failing to delete outputs may populate the
-    // filesystem for other test cases. b/308017721
-    for (var output : action.getOutputs()) {
-      filesToDelete.add(output.getPath());
-    }
-    runAction(action); // Not cached so recorded as different deps.
-    writeContentAsLatin1(action.getPrimaryInput().getPath(), "modified");
-    runAction(action); // Cache miss because input files were modified.
-    writeContentAsLatin1(action.getPrimaryOutput().getPath(), "modified");
-    runAction(action); // Outputs are not considered for middleman actions, so this is a cache hit.
-    runAction(action); // Outputs are not considered for middleman actions, so this is a cache hit.
-
-    assertStatistics(
-        2,
-        new MissDetailsBuilder()
-            .set(MissReason.DIFFERENT_DEPS, 1)
-            .set(MissReason.DIFFERENT_FILES, 1)
-            .build());
-  }
-
-  @Test
   public void testDeletedConstantMetadataOutputCausesReexecution() throws Exception {
     SpecialArtifact output =
         SpecialArtifact.create(
@@ -1591,14 +1537,6 @@
     }
   }
 
-  /** A null middleman action. */
-  private static class NullMiddlemanAction extends NullAction {
-    @Override
-    public MiddlemanType getActionType() {
-      return MiddlemanType.RUNFILES_MIDDLEMAN;
-    }
-  }
-
   /** A fake metadata handler that is able to obtain metadata from the file system. */
   private static final class FakeInputMetadataHandler extends FakeInputMetadataHandlerBase {
     private final Map<Artifact, FileArtifactValue> fileMetadata = new HashMap<>();
diff --git a/src/test/java/com/google/devtools/build/lib/exec/util/FakeActionInputFileCache.java b/src/test/java/com/google/devtools/build/lib/exec/util/FakeActionInputFileCache.java
index 29ecf12..5b8c761 100644
--- a/src/test/java/com/google/devtools/build/lib/exec/util/FakeActionInputFileCache.java
+++ b/src/test/java/com/google/devtools/build/lib/exec/util/FakeActionInputFileCache.java
@@ -28,8 +28,6 @@
 
 /** A fake implementation of the {@link InputMetadataProvider} interface. */
 public final class FakeActionInputFileCache implements InputMetadataProvider {
-  private static final byte[] EMPTY_DIGEST = new byte[0];
-
   private final Map<ActionInput, FileArtifactValue> inputs = new HashMap<>();
   private final Map<ActionInput, RunfilesArtifactValue> runfilesInputs = new HashMap<>();
   private final List<RunfilesTree> runfilesTrees = new ArrayList<>();
@@ -43,7 +41,6 @@
   public void putRunfilesTree(ActionInput middleman, RunfilesTree runfilesTree) {
     RunfilesArtifactValue runfilesArtifactValue =
         new RunfilesArtifactValue(
-            FileArtifactValue.createForNormalFile(EMPTY_DIGEST, null, 0),
             runfilesTree,
             ImmutableList.of(),
             ImmutableList.of(),
diff --git a/src/test/java/com/google/devtools/build/lib/metrics/criticalpath/CriticalPathComputerTest.java b/src/test/java/com/google/devtools/build/lib/metrics/criticalpath/CriticalPathComputerTest.java
index 0a65d65..1d33d3c 100644
--- a/src/test/java/com/google/devtools/build/lib/metrics/criticalpath/CriticalPathComputerTest.java
+++ b/src/test/java/com/google/devtools/build/lib/metrics/criticalpath/CriticalPathComputerTest.java
@@ -27,7 +27,6 @@
 import com.google.devtools.build.lib.actions.ActionCompletionEvent;
 import com.google.devtools.build.lib.actions.ActionKeyContext;
 import com.google.devtools.build.lib.actions.ActionLookupData;
-import com.google.devtools.build.lib.actions.ActionMiddlemanEvent;
 import com.google.devtools.build.lib.actions.ActionStartedEvent;
 import com.google.devtools.build.lib.actions.AggregatedSpawnMetrics;
 import com.google.devtools.build.lib.actions.Artifact;
@@ -1004,9 +1003,6 @@
     long nanoTimeStart = clock.nanoTime();
     if (action.getActionType().isMiddleman()) {
       clock.advanceMillis(totalTime);
-      computer.middlemanAction(
-          new ActionMiddlemanEvent(
-              action, new FakeActionInputFileCache(), nanoTimeStart, clock.nanoTime()));
     } else {
       computer.actionStarted(new ActionStartedEvent(action, nanoTimeStart));
       clock.advanceMillis(totalTime);
diff --git a/src/test/java/com/google/devtools/build/lib/remote/FakeActionInputFileCache.java b/src/test/java/com/google/devtools/build/lib/remote/FakeActionInputFileCache.java
index e6d4fc23..1aacfde 100644
--- a/src/test/java/com/google/devtools/build/lib/remote/FakeActionInputFileCache.java
+++ b/src/test/java/com/google/devtools/build/lib/remote/FakeActionInputFileCache.java
@@ -87,7 +87,6 @@
     runfilesMap.put(
         runfilesMiddleman,
         new RunfilesArtifactValue(
-            FileArtifactValue.createForNormalFile(new byte[] {}, null, 0),
             runfilesTree,
             ImmutableList.of(),
             ImmutableList.of(),
diff --git a/src/test/java/com/google/devtools/build/lib/runtime/ExecutionGraphModuleTest.java b/src/test/java/com/google/devtools/build/lib/runtime/ExecutionGraphModuleTest.java
index c6ff72b..22ba122 100644
--- a/src/test/java/com/google/devtools/build/lib/runtime/ExecutionGraphModuleTest.java
+++ b/src/test/java/com/google/devtools/build/lib/runtime/ExecutionGraphModuleTest.java
@@ -415,8 +415,6 @@
   public void spawnAndAction_withSameOutputs() throws Exception {
     var buffer = new ByteArrayOutputStream();
     startLogging(eventBus, UUID.randomUUID(), buffer, DependencyInfo.ALL);
-    var options = new ExecutionGraphModule.ExecutionGraphOptions();
-    module.setOptions(options);
 
     module.spawnExecuted(
         new SpawnExecutedEvent(
@@ -451,8 +449,6 @@
   public void spawnAndAction_withDifferentOutputs() throws Exception {
     var buffer = new ByteArrayOutputStream();
     startLogging(eventBus, UUID.randomUUID(), buffer, DependencyInfo.ALL);
-    var options = new ExecutionGraphModule.ExecutionGraphOptions();
-    module.setOptions(options);
     var nanosToMillis = BlazeClock.createNanosToMillisSinceEpochConverter();
     module.setNanosToMillis(nanosToMillis);
 
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 a373895..94b00aa 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
@@ -154,16 +154,9 @@
     file(input1.getPath(), "source contents");
 
     SkyValue value = evaluateArtifactValue(output);
-
-    ActionLookupData generatingActionKey = output.getGeneratingActionKey();
-    EvaluationResult<ActionExecutionValue> runfilesActionResult = evaluate(generatingActionKey);
-    FileArtifactValue expectedMetadata =
-        runfilesActionResult.get(generatingActionKey).getExistingFileArtifactValue(output);
-
     assertThat(value)
         .isEqualTo(
             new RunfilesArtifactValue(
-                expectedMetadata,
                 mockRunfilesTree,
                 ImmutableList.of(input1, input2),
                 ImmutableList.of(createForTesting(input1), createForTesting(input2)),
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/rewinding/RewindingTestsHelper.java b/src/test/java/com/google/devtools/build/lib/skyframe/rewinding/RewindingTestsHelper.java
index 63af3e0..51da9fd 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/rewinding/RewindingTestsHelper.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/rewinding/RewindingTestsHelper.java
@@ -380,7 +380,6 @@
             "Executing genrule //test:rule1", "Executing genrule //test:rule2"),
         /* completedRewound= */ ImmutableList.of(),
         /* failedRewound= */ ImmutableList.of(),
-        /* exactlyOneMiddlemanEventChecks= */ ImmutableList.of(),
         /* actionRewindingPostLostInputCounts= */ ImmutableList.of(0));
 
     assertThat(rewoundKeys).isEmpty();
@@ -541,7 +540,6 @@
         /* completedRewound= */ ImmutableList.of(
             "Executing genrule //test:rule1_1", "Executing genrule //test:rule1_2"),
         /* failedRewound= */ ImmutableList.of("Executing genrule //test:rule2"),
-        /* exactlyOneMiddlemanEventChecks= */ ImmutableList.of(),
         /* actionRewindingPostLostInputCounts= */ ImmutableList.of(2));
 
     assertOnlyActionsRewound(rewoundKeys);
@@ -620,7 +618,6 @@
         /* runOnce= */ ImmutableList.of(),
         /* completedRewound= */ ImmutableList.of("Executing genrule //test:rule1"),
         /* failedRewound= */ ImmutableList.of("Executing genrule //test:rule2"),
-        /* exactlyOneMiddlemanEventChecks= */ ImmutableList.of(),
         /* actionRewindingPostLostInputCounts= */ ImmutableList.of(0, 1));
 
     assertOnlyActionsRewound(rewoundKeys);
@@ -680,7 +677,6 @@
         /* runOnce= */ ImmutableList.of(),
         /* completedRewound= */ ImmutableList.of("Executing genrule //test:rule1"),
         /* failedRewound= */ ImmutableList.of(),
-        /* exactlyOneMiddlemanEventChecks= */ ImmutableList.of(),
         /* expectResultReceivedForFailedRewound= */ false,
         /* actionRewindingPostLostInputCounts= */ ImmutableList.of(
             ActionRewindStrategy.MAX_REPEATED_LOST_INPUTS + 1));
@@ -824,7 +820,6 @@
         /* runOnce= */ ImmutableList.of("Executing genrule //test:rule1"),
         /* completedRewound= */ ImmutableList.of(),
         /* failedRewound= */ ImmutableList.of(),
-        /* exactlyOneMiddlemanEventChecks= */ ImmutableList.of(),
         /* actionRewindingPostLostInputCounts= */ ImmutableList.of(1));
     assertThat(
             recorder.getActionStartedEvents().stream()
@@ -992,7 +987,6 @@
         /* runOnce= */ ImmutableList.of("Executing genrule //test:rule1"),
         /* completedRewound= */ ImmutableList.of("Executing genrule //test:rule2"),
         /* failedRewound= */ ImmutableList.of("Executing genrule //test:rule3"),
-        /* exactlyOneMiddlemanEventChecks= */ ImmutableList.of(),
         /* actionRewindingPostLostInputCounts= */ ImmutableList.of(1));
 
     assertOnlyActionsRewound(rewoundKeys);
@@ -1089,7 +1083,6 @@
         /* completedRewound= */ ImmutableList.of(
             "Executing genrule //test:rule1", "Executing genrule //test:rule2"),
         /* failedRewound= */ ImmutableList.of("Executing genrule //test:rule3"),
-        /* exactlyOneMiddlemanEventChecks= */ ImmutableList.of(),
         /* actionRewindingPostLostInputCounts= */ ImmutableList.of(2));
 
     assertOnlyActionsRewound(rewoundKeys);
@@ -1188,7 +1181,6 @@
         /* runOnce= */ ImmutableList.of("Executing genrule //test:rule3"),
         /* completedRewound= */ ImmutableList.of("Executing genrule //test:rule1"),
         /* failedRewound= */ ImmutableList.of("Executing genrule //test:rule2"),
-        /* exactlyOneMiddlemanEventChecks= */ ImmutableList.of(),
         /* actionRewindingPostLostInputCounts= */ ImmutableList.of(1));
 
     assertOnlyActionsRewound(rewoundKeys);
@@ -1573,7 +1565,7 @@
             "Linking tree/libconsumes_tree.a"),
         /* completedRewound= */ ImmutableList.of("Action tree/make_cc_dir.cc"),
         /* failedRewound= */ ImmutableList.of("Compiling tree/make_cc_dir.cc/file1.cc"),
-        /* exactlyOneMiddlemanEventChecks= */ ImmutableList.of(),
+
         /* actionRewindingPostLostInputCounts= */ ImmutableList.of(1));
 
     assertThat(rewoundKeys).hasSize(1);
@@ -1682,7 +1674,6 @@
         /* completedRewound= */ ImmutableList.of(
             "Compiling tree/make_cc_dir.cc/file1.cc", "Compiling tree/make_cc_dir.cc/file2.cc"),
         /* failedRewound= */ ImmutableList.of("Linking tree/libconsumes_tree.so"),
-        /* exactlyOneMiddlemanEventChecks= */ ImmutableList.of(),
         /* actionRewindingPostLostInputCounts= */ ImmutableList.of(
             lostTreeFileArtifactNames.size()));
 
@@ -1801,10 +1792,6 @@
             "Executing genrule //middle:gen1 [for tool]",
             "Executing genrule //middle:gen2 [for tool]"),
         /* failedRewound= */ ImmutableList.of("Executing genrule //middle:tool_user"),
-        /* exactlyOneMiddlemanEventChecks= */ ImmutableList.of(
-            middlemanEvent ->
-                ActionEventRecorder.progressMessageOrPrettyPrint(middlemanEvent.getAction())
-                    .equals("runfiles for //middle:tool")),
         /* actionRewindingPostLostInputCounts= */ ImmutableList.of(lostRunfiles.size()));
 
     if (buildRunfileManifests()) {
@@ -1979,10 +1966,6 @@
         /* runOnce= */ ImmutableList.of("Executing genrule //test:rule3"),
         /* completedRewound= */ ImmutableList.of("Executing genrule //test:rule1 [for tool]"),
         /* failedRewound= */ ImmutableList.of("Executing genrule //test:rule2"),
-        /* exactlyOneMiddlemanEventChecks= */ ImmutableList.of(
-            middlemanEvent ->
-                ActionEventRecorder.progressMessageOrPrettyPrint(middlemanEvent.getAction())
-                    .equals("runfiles for //test:tool")),
         /* actionRewindingPostLostInputCounts= */ ImmutableList.of(1));
 
     if (buildRunfileManifests()) {
@@ -2133,10 +2116,6 @@
         /* runOnce= */ ImmutableList.of(),
         /* completedRewound= */ ImmutableList.of("Action middle/gen_tree_dir [for tool]"),
         /* failedRewound= */ ImmutableList.of("Executing genrule //middle:tool_user"),
-        /* exactlyOneMiddlemanEventChecks= */ ImmutableList.of(
-            middlemanEvent ->
-                ActionEventRecorder.progressMessageOrPrettyPrint(middlemanEvent.getAction())
-                    .equals("runfiles for //middle:tool")),
         /* actionRewindingPostLostInputCounts= */ ImmutableList.of(2));
 
     if (buildRunfileManifests()) {
@@ -2266,7 +2245,6 @@
         /* runOnce= */ ImmutableList.of(),
         /* completedRewound= */ ImmutableList.of("Executing genrule //test:gen"),
         /* failedRewound= */ ImmutableList.of("Running consumer"),
-        /* exactlyOneMiddlemanEventChecks= */ ImmutableList.of(),
         /* actionRewindingPostLostInputCounts= */ ImmutableList.of(1));
   }
 
@@ -2354,7 +2332,6 @@
             "Linking genheader/consumes_header", "Compiling genheader/consumes.cc"),
         /* completedRewound= */ ImmutableList.of("Executing genrule //genheader:gen_header"),
         /* failedRewound= */ ImmutableList.of(),
-        /* exactlyOneMiddlemanEventChecks= */ ImmutableList.of(),
         /* actionRewindingPostLostInputCounts= */ ImmutableList.of(1));
 
     assertOnlyActionsRewound(rewoundKeys);
@@ -2406,7 +2383,6 @@
         /* runOnce= */ ImmutableList.of("Linking genheader/consumes_header"),
         /* completedRewound= */ ImmutableList.of("Executing genrule //genheader:gen_header"),
         /* failedRewound= */ ImmutableList.of("Compiling genheader/consumes.cc"),
-        /* exactlyOneMiddlemanEventChecks= */ ImmutableList.of(),
         /* actionRewindingPostLostInputCounts= */ ImmutableList.of(1));
 
     assertOnlyActionsRewound(rewoundKeys);
@@ -2513,7 +2489,6 @@
             "Linking genheader/consumes_header"),
         /* completedRewound= */ ImmutableList.of("Executing genrule //genheader:gen_header"),
         /* failedRewound= */ ImmutableList.of(),
-        /* exactlyOneMiddlemanEventChecks= */ ImmutableList.of(),
         /* actionRewindingPostLostInputCounts= */ ImmutableList.of(1));
 
     assertOnlyActionsRewound(rewoundKeys);
@@ -2573,7 +2548,6 @@
             "Linking genheader/consumes_header", "Compiling genheader/intermediate.cc"),
         /* completedRewound= */ ImmutableList.of("Executing genrule //genheader:gen_header"),
         /* failedRewound= */ ImmutableList.of("Compiling genheader/consumes.cc"),
-        /* exactlyOneMiddlemanEventChecks= */ ImmutableList.of(),
         /* actionRewindingPostLostInputCounts= */ ImmutableList.of(1));
 
     assertOnlyActionsRewound(rewoundKeys);
diff --git a/src/test/java/com/google/devtools/build/lib/testutil/ActionEventRecorder.java b/src/test/java/com/google/devtools/build/lib/testutil/ActionEventRecorder.java
index fece452..3b9acbf 100644
--- a/src/test/java/com/google/devtools/build/lib/testutil/ActionEventRecorder.java
+++ b/src/test/java/com/google/devtools/build/lib/testutil/ActionEventRecorder.java
@@ -23,7 +23,6 @@
 import com.google.devtools.build.lib.actions.ActionCompletionEvent;
 import com.google.devtools.build.lib.actions.ActionExecutedEvent;
 import com.google.devtools.build.lib.actions.ActionExecutionMetadata;
-import com.google.devtools.build.lib.actions.ActionMiddlemanEvent;
 import com.google.devtools.build.lib.actions.ActionResultReceivedEvent;
 import com.google.devtools.build.lib.actions.ActionStartedEvent;
 import com.google.devtools.build.lib.actions.CachedActionEvent;
@@ -34,7 +33,6 @@
 import java.util.List;
 import java.util.function.Consumer;
 import java.util.function.Function;
-import java.util.function.Predicate;
 
 /** Records various action-related events for tests. */
 public final class ActionEventRecorder {
@@ -47,8 +45,6 @@
       Collections.synchronizedList(new ArrayList<>());
   private final List<ActionResultReceivedEvent> actionResultReceivedEvents =
       Collections.synchronizedList(new ArrayList<>());
-  private final List<ActionMiddlemanEvent> actionMiddlemanEvents =
-      Collections.synchronizedList(new ArrayList<>());
   private final List<CachedActionEvent> cachedActionEvents =
       Collections.synchronizedList(new ArrayList<>());
   private final List<ActionRewoundEvent> actionRewoundEvents =
@@ -117,13 +113,6 @@
   @SuppressWarnings("unused")
   @Subscribe
   @AllowConcurrentEvents
-  void actionMiddleman(ActionMiddlemanEvent event) {
-    actionMiddlemanEvents.add(event);
-  }
-
-  @SuppressWarnings("unused")
-  @Subscribe
-  @AllowConcurrentEvents
   void cachedAction(CachedActionEvent event) {
     cachedActionEvents.add(event);
   }
@@ -148,7 +137,6 @@
     actionCompletionEvents.clear();
     actionExecutedEvents.clear();
     actionResultReceivedEvents.clear();
-    actionMiddlemanEvents.clear();
     cachedActionEvents.clear();
     actionRewoundEvents.clear();
     actionRewindingStatsPosts.clear();
@@ -161,28 +149,24 @@
    * @param completedRewound Actions which ran and then are rewound by a later failed action
    * @param failedRewound Actions which fail because of lost inputs and which rewind themselves and
    *     the actions that generate those lost inputs
-   * @param exactlyOneMiddlemanEventChecks A list of predicates which should be satisfied exactly
-   *     once by the sequence of middleman events emitted
    */
   public void assertEvents(
       ImmutableList<String> runOnce,
       ImmutableList<String> completedRewound,
       ImmutableList<String> failedRewound,
-      ImmutableList<Predicate<ActionMiddlemanEvent>> exactlyOneMiddlemanEventChecks,
       ImmutableList<Integer> actionRewindingPostLostInputCounts) {
     assertEvents(
         runOnce,
         completedRewound,
         failedRewound,
-        exactlyOneMiddlemanEventChecks,
         /* expectResultReceivedForFailedRewound= */ true,
         actionRewindingPostLostInputCounts);
   }
 
   /**
-   * Like {@link #assertEvents(ImmutableList, ImmutableList, ImmutableList, ImmutableList,
-   * ImmutableList)}. The {@code expectResultReceivedForFailedRewound} should be true iff the failed
-   * rewound actions ever successfully complete.
+   * Like {@link #assertEvents(ImmutableList, ImmutableList, ImmutableList, ImmutableList)}. The
+   * {@code expectResultReceivedForFailedRewound} should be true iff the failed rewound actions ever
+   * successfully complete.
    *
    * @param expectResultReceivedForFailedRewound whether the failed rewound actions ever
    *     successfully complete, because no {@link ActionResultReceivedEvent} is emitted for a failed
@@ -192,7 +176,6 @@
       ImmutableList<String> runOnce,
       ImmutableList<String> completedRewound,
       ImmutableList<String> failedRewound,
-      ImmutableList<Predicate<ActionMiddlemanEvent>> exactlyOneMiddlemanEventChecks,
       boolean expectResultReceivedForFailedRewound,
       ImmutableList<Integer> actionRewindingPostLostInputCounts) {
     EventCountAsserter eventCountAsserter =
@@ -239,10 +222,6 @@
         /*expectedFailedRewoundEventCount=*/ 1);
 
     assertTotalLostInputCountsFromStats(actionRewindingPostLostInputCounts);
-
-    for (Predicate<ActionMiddlemanEvent> check : exactlyOneMiddlemanEventChecks) {
-      assertThat(actionMiddlemanEvents.stream().filter(check)).hasSize(1);
-    }
     assertThat(cachedActionEvents).isEmpty();
   }
 
diff --git a/src/test/shell/bazel/remote/remote_execution_test.sh b/src/test/shell/bazel/remote/remote_execution_test.sh
index 213874b..7c28e3f 100755
--- a/src/test/shell/bazel/remote/remote_execution_test.sh
+++ b/src/test/shell/bazel/remote/remote_execution_test.sh
@@ -2781,7 +2781,7 @@
     --disk_cache=$CACHEDIR \
     //a:test >& $TEST_log || fail "Failed to build //a:test"
 
-  expect_log "6 processes: 4 internal, 2 .*-sandbox"
+  expect_log "7 processes: 5 internal, 2 .*-sandbox"
 
   bazel clean
 
@@ -2789,7 +2789,7 @@
     --disk_cache=$CACHEDIR \
     //a:test >& $TEST_log || fail "Failed to build //a:test"
 
-  expect_log "6 processes: 2 disk cache hit, 4 internal"
+  expect_log "7 processes: 2 disk cache hit, 5 internal"
 }
 
 # Bazel assumes that non-ASCII characters in file contents (and, in
diff --git a/src/test/shell/integration/ui_test.sh b/src/test/shell/integration/ui_test.sh
index 96ce4d4..056213d 100755
--- a/src/test/shell/integration/ui_test.sh
+++ b/src/test/shell/integration/ui_test.sh
@@ -735,7 +735,7 @@
   expect_log "ERROR: 'run' only works with tests with one shard"
   # If we would print this again after the run failed, we would overwrite the
   # error message above.
-  expect_log_n "INFO: Build completed successfully, [456] total actions" 1
+  expect_log_n "INFO: Build completed successfully, [4567] total actions" 1
 }
 
 function test_exit_code_reported() {