you are correct, but aren't they quality-less items designated only by material and year?
Yes, so they're probably the easy case.
I guess for me restacking would ideally be implemented in two different ways:
1. actual restacking of truly identical items, i.e. two indistinguishable *turtle bone bolts* would be combined if they ended up in the same tile, container, or creature inventory
2. "virtual stacks" that would act like fake containers, i.e. if a dwarf throws 12 iron bolts and 10 bone bolts in his quiver, if you looked at the quiver you'd see "mixed bolts [22]". You could view its contents like an actual container to see the separate stacks of iron and bone bolts.
The issue would be how much items could differ in a "virtual stack," i.e. do they have to be the same item and material or just the same item type? Maybe there could be a tag in the item definition for stackable items, like [STACK_BY:ITEM], [STACK_BY:MATERIAL] (and item), and [STACK_BY:QUALITY] (and material and item), from least restrictive to most. The tags would also dictate how descriptive the virtual stack's name could be:
[STACK_BY:ITEM] -> mixed bolts[14]
[STACK_BY:MATERIAL] -> mixed
iron bolts [19]
[STACK_BY:QUALITY] ->
+mixed iron bolts [21]
+Ideally dwarves would also be smarter about splitting up stacks. Obviously they have SOME capability of this kind, i.e. firing a single bolt. But they don't know how to take a single bone from a stack for decorating, or how to split up *elephant meat [16]* so they can fit it into a barrel, or how to split off 25 bolts from that stack of 80 elephant bone bolts.
Wow that got long, sorry.