Started up a new game, crafted some crates. Placed those crates and removed the stockpile I had so everything would be put into crates.
Sometime later I observed that my carpenter was just throwing his goods on the ground around his workshop after he made them. I can only assume he does not see a crate as a valid stockpile target.
drop_item_near_workshop is what they do when no stockpile is available. move_item_to_available_stockpile is what they do when they can find a stockpile. So wait_for_closest_stockpile_space is the important action here. This is defined in ai/actions/wait_for_closest_stockpile_space.luac.
In that file, they define stockpile in this fashion:
local stockpile_component=stockpile_entity:get_component('stonehearth:stockpile')
So it’s only looking for components of type stonehearth:stockpile. If you use the Debug Tools mod to examine an actual stockpile object on the ground, you will see it has that component. If you examine a crate/container, it does not have that component.
Therefore, the crafter AI for putting a finished item into storage cannot consider a crate to be a valid stockpile for placing an item.
Edit: The code for regular stockpile filling uses ai/actions/wait_for_storage_space.lua. that file looks for the stonehearth:storage component, which is on both containers and stockpiles.
Nice sleuthing!
Paging @not_owen_wilson , since he implemented the crates… Maybe the bug should be fixed by another dev, but we’ll let him know anyway.
I noticed the carpenter was preferring to drop crafted items in the general stockpile which was further away than the crates I had placed for him. I then removed the stockpile and watched the carpenter drop items on the ground near the crafting table.