Here is a compilable example. It is a bit long, but I think it is pretty close to minimal.
In its defence: the first 32 lines are, effectively, snippet 739 modified to produce "dynamic text" instead of "text dynamic" (in this case, "mp dolce" instead of, say, "meno f").
The remaining few lines are one part from a very heavily redacted movement of a quintet.
The unwelcome spacing between the 4th and 5th notes goes away if one:
transposes the second bar up an octave; or
comments out the key signature; or
comments out \new StaffGroup; or
uncomments the line containing DynamicLineSpanner.staff-padding
I think I can live with the final option, assuming I can localise the staff-padding change when I apply it to the big score. Problem solved; sorry for the noise.
Here's the code, attached, in case either I'm missing something obvious, or the modified snippet 739 is useful to someone.