How can I detect long-lived connections and mark them for shaping
Solution 1:
The life-expectancy and actual longevity of a connection has ZERO relation on whether a connection should be shaped specially or not.
Some examples:
SSH, possibly long-lived, minutes, hours, days, weeks, even months. Still needing high priority to be responsive to user interaction.
Bittorrent (or similar protocols), randomly lived, some for seconds then disconnected, others for minutes or hours, then disconnected. Few lasting more than a day at a time.
Summary: The length of a connection has NOTHING to do with whether the connection is "bulk" or not, and whether or not the connection should be treated as bulk.
Not necessarily directly related, but useful:
Using traffic shaping, is limiting download traffic helpful or harmful?