           addDefsWithoutGraph
         }
         else {
-          fingerprintChanged(.interface, "main")
-          fingerprintChanged(.implementation, "main")
-
-          let affectedInputs = removeInputFromInvocation
-            ? ["other"]
-            : [removedInput, "other"]
-          for input in affectedInputs {
-            trace {
-              TraceStep(.interface, sourceFileProvide: "main")
-              TraceStep(.interface, topLevel: "foo", input: "main")
-              TraceStep(.implementation,
-                        sourceFileProvide: input,
-                        input: input == removedInput && afterRestoringBadPriors ? nil : input)
-            }
-          }
-          let affectedInputsInBuild = affectedInputs.filter(inputs.contains)
-          queuingLater(affectedInputsInBuild)
-          schedulingInvalidated(affectedInputsInBuild)
-          let affectedInputsInInvocationOrder = inputs.filter(affectedInputsInBuild.contains)
-          findingBatchingCompiling(affectedInputsInInvocationOrder)
-          reading(deps: affectedInputsInInvocationOrder)
+          // At this point in the result builder:
+          // (!removeInputFromInvocation || priorsAreStaleFromBeforeInputWasRemoved) && removedFileDependsOnChangedFileAndMainWasChanged
+
+          integrateChangedMainWithPriors(
+            removedInput: removedInput,
+            defining: topLevelName,
+            affectedInputs: affectedInputs,
+            affectedInputsInBuild: affectedInputsInBuild,
+            affectedInputsInInvocationOrder: affectedInputsInInvocationOrder,
+            removeInputFromInvocation: removeInputFromInvocation)
         }
         schedLinking
       }

      schedulingPostCompileJobs
      compiling("main", "other")
      reading(deps: "main", "other")
      fingerprintsMissing(.topLevel(name: "foo"), "main")
      fingerprintsMissing(.topLevel(name: "bar"), "other")
      linking
    }
  }

  @DiagsBuilder func reading(deps inputs: String...) -> [Diagnostic.Message] {
    reading(deps: inputs)
  }
  
  @DiagsBuilder func fingerprintChanged(_ aspect: DependencyKey.DeclAspect, _ input: String) -> [Diagnostic.Message] {
    "Incremental compilation: Fingerprint changed for existing \(aspect) of source file from \(input).swiftdeps in \(input).swift"
  }
 @DiagsBuilder func fingerprintsChanged(_ input: String) -> [Diagnostic.Message] {
    for aspect: DependencyKey.DeclAspect in [.interface, .implementation] {
      fingerprintChanged(aspect, input)
    }
  }
  
   @DiagsBuilder func fingerprintsMissingOfTopLevelName(name: String, _ input: String) -> [Diagnostic.Message] {
    for aspect: DependencyKey.DeclAspect in [.interface, .implementation] {
      "Incremental compilation: Fingerprint missing for existing \(aspect) of top-level name '\(name)' in \(input).swift"
    }
  }

