tweaking the decrescendi like the diminuendi and doing some minor changes, I
come up with:
Looks great! I'll definitely use this, though something tells me I won't run into quite as extreme a situation as your example :)
Checking my just-bought copy of Gould, I find on pg. 104 the rule that a broken hairpin should stop on the barline, with an example involving a key change at the line break. Maybe LilyPond's behavior should be reported as a bug (I couldn't find it listed, anyway) with your function as a workaround?
(One tiny thing: Mike went to the trouble of writing functions to determine a grob's system, and for consistency you could replace my calls to ly:grob-system with his find-system.)
Best,
David