Do you have any suggestions on how to implement that?
My idea was to, and the commencement of a siege, and possibly periodically after that in the case of protracted sieges, the besieging force would plan out their attack. This would mostly involve special pathing for things such as siege engines, building fortified storage for troops and supplies, possibly troop formations, and whatever else... This would involve pathing through solid ground, probably with a bias against, such as maybe counting soil as something like 50 spaces and rock as 200 for example. This would involve a lot of work on the part of the pathing, so you would only do it very occasionally and probably group the besieging army into clusters of units that would be pathed as a single entity.
Hopefully this way you could have the wagons and some guards march along with the main attack forces then stop short of the enemy defences and start building a walled area with lots of arrow slits. The main forces could march off down the main entrance and play with whatever is there, before running back to the fortifications that their friends built. And a group of tunnellers could march off with a small group of soldiers and poke a hole in the roof of your surface farm where there is only a tiny sliver of grass between your fort and the surface. Building destroyers and siege equipment could also benefit from a bit of pathing through solid objects...
Ideally this would be combined with some sort of intelligence gathering. Tunnel pathing might not occur to places that had not been scouted. Scouting could occur by recording where previous invasions had reached, which could be limited be stopping them quickly. Surveyors could march around the surface detecting open space beneath them, which could be stopped by killing the surveyors. Snatchers could report back the places that they had seen, and you might get raided by spies before a siege arrives. Or folk might just dig ditches down at random and hope they find something.
This could be coupled with an aversion system when it detects where their brethren have been injured and killed and makes pathing through these points steadily less desirable. That way the narrow corridor where a thousand goblins have died before would eventually become less desirable then digging a couple of tiles down to reach the far end of the corridor directly. Counters would include trapping the surface ground, building mining-resistant walls, building dummy-caverns filled with miasma, filling your walls with magma, burying your fortress as deep as you can, living under an aquifer...