I don't know how to write scripts, but I would guess you could write one to preserve the top object. (Or really the script would probably have to do what we did "manually", which is duplicate the top object first. Because I think it's hard coded....and maybe not even just hard coded, but maybe can't be done any other way. I'm not sure what gives me that idea, but I have the impression that the top object must be sacrificed, by definition.) (could be wrong impression but fwiw
)
For the 2nd part, I'm not sure I completely understand, about the object used as the "cutting edge". It's always the object on top which provides the cutting edge, and you have to choose that. Or even sometimes draw it. So I'm not sure if a script could choose it for you. And for aligning the object....it seems like a script would need a lot of input from you about how you want it aligned.
Or do you mean that you want the script to draw the object that you need? I guess if you could give the script enough input, it would work.
Someone who understands Inkscape, as well as scripts, a lot better than I do, can give you a better answer.
But if you're thinking of doing this with a new extension or extensions, here's some info to get you started down that road:
https://inkscape.org/en/develop/extensions/I'm curious what is the situation on your canvas where simply duplicating the top object takes too much time. It is that you want to do a lot of path operations at the same time (or at least very quickly)? We already have extensions to do many path operations at once, using just one top object to "cut" all the others. I guess it must already have some code for this? Although it might not be in the language you wanted to use
https://inkscape.org/en/~Moini/%E2%98%85multi-bool-extension-cut-difference-division.
Your last question about "path averaging algorithm", I'm not sure. What is that? It sounds like the math which would be used in interpolation. Or other LPEs or extensions? Or maybe in Union? If it's part of a path operation, or related to one, you can ask it here. Otherwise, I think Beyond the Basics board would be best. It might be a question for developers, who unfortunately rarely visit forums.
You might want to check out the development mailing list and/or user mailing list, which is read and often answered by deveopers. Or you could search the archives if you don't want to subscribe.
https://sourceforge.net/p/inkscape/mailman/ Also you might find Launchpad interesting, which is Inkscape's bug tracker (and also where feature requests are made).
https://launchpad.net/inkscape I'm sure it must be a treasure trove for budding developers.