Looking at calibre's code for save-to-disk, for windows the max allowed path length is 240. For linux it is 1000. In both cases calibre reserves 4 characters for the extension.
If a path is too long then (roughly) calibre shortens it by computing how many extra characters there are (X) and how many path segments there are (P), then removing X/P characters from the center of each path segment.
You can control truncation yourself using the formatter function
shorten.