Merging filter layer down messes up top layer in stack

If I have two paint layers, A and B, and a filter layer (Levels) on top of the stack, merging the filter layer down with the topmost paint layer A copies the pixels from layer B into Layer A. So essentially it’s as if I had merged the whole stack down and copied the result into layer A. I expect groups would limit the extent to which things are unexpectedly merged, but haven’t tested.

Of course there’s no simple way to bake a single filter layer to multiple separate layers, so merging down is an odd operation to do. I think it’s a bit unsafe the way it is, though, since the image on the canvas still looks fine, until the user takes a look at what the layer contents are. I think it would be better if, when merging a filter layer with a layer below it, the filter would only be applied to the layer being merged to. This would probably not be the result the user wants, but it would at least be immediately obvious that the user needs to do things differently.

Use of a group does limit the extent of the effects of the filter layer but that’s not the point of your argument.
As you say, merging down a filter layer (that is applied to the entire layer stack) onto the layer below it is an odd operation to do.
However, the end result is not what I’d ‘instinctively’ expect from merging two adjacent layers, because it picks up everything it sees underneath it.
This may be a case of, “that’s the way it is so don’t do that”. It may be a case suitable for changing.

With every Merge operation in Krita the assumption is that you want the merged result to look as close to the previous state as possible. At the end of the day, every merge operation is lossy and user must be aware of that.

I appreciate that there’s no ideal solution here, since merging an adjustment layer down when it affects multiple layers with transparency below it is a bit of an iffy thing to do. My issue with it is just that right now, the way it works seems a bit dangerous. Merging an adjustment layer down is something you might do accidentally or as an oversight, and it will just destroy the top layer currently.

I think I’ve had enough discussions with other developers and people who use Krita professionally to conclude that a consistent concept just has higher priority for Krita than keeping users from making mistakes based on wrong assumptions.
Guess we need to accept that…

And yes, I don’t see a more “correct” variant in this particular case.
The obvious choice to affect only one layer is to make a filter mask instead of a filter layer.

However, I still want to implement an alternative “merge into target layer” function that can save me a lot of steps on something I do quite regularly.

Merging any “unnusual” layer is dangerous - merging layers with different blending modes than Normal is often dangerous, merging filter layers and anything else that builds upon the whole stack.

That’s true, I’ve spent my share of time figuring out how to merge complex stacks of blending mode layers down. You merge, it looks wrong, you scratch your head for a while and remember that layer there was set to “multiply”. But the important thing is that you notice something went wrong, because the end result on screen changes when you do your merge. That’s not the case here. This behaviour is IMO unexpected, destructive and easily missed by the user, which doesn’t seem like a great combination.

To look at it another way, would the user have any reason to expect “merge down” to mean “flatten image, but keep all layers except the top one”? (Leaving out the complications groups add to this description.)