The problem becomes norm when you hit endgame, beaconed, legendary quality stage, and you need to handle mixed flows. But breaks the game engine when you stress test Space Age's new machines that support belt stacking. As a gamer with knowledge of programming and circuit networks, I can fix this, but the typical gamer shouldn't be "fixing" such problems, which require advanced engineering knowledge.
I will use as an example Fulgora and scrap recycling.
The two most notorious troublemakers that miss it are the recycler and the stack inserter
- The recycler got a patch that reshuffled priority to increase throughput. But when you push the machine to its limits... Holmium ore is rarely unloaded properly, even if it should have the highest priority. The engine is fine to stay at 46-50 holmium limit, even if it will clog itself next cycle again and again.
- Stack inserter is supposed to wait for input while handling belts, and it's OK to wait to pick up a full stack, but there still should be a timeout. But this same logic shouldn't be applied to the containers (chests, machines) when unloading, and should be more picky and smarter. Recycling a low density structure will deadlock itself in less than 2 seconds if you use the stack inserter, because it will wait for steel where there are 100 copper plates to unload in the machine.
Unload logic priority pseudocode(I avoided some negations even if it shortens logic):
1. Sort items descending (like insertion sort and dynamic sorting on a small set of items)
1.1 (optional) sort by difference to the item's stack limit and the projected amount produced in the next machine cycle that will cross the limit threshold
2. If the machine supports stack size and belt stacking(like stack inserter), and you pull from "container" (chests, machines)
2.1 Pick up the first item where item count >= stack size and do "working logic"
2.2 else "wait and don't pick up anything logic"
3. Pick up the first item and do "working logic"
4. Return to point 1.
Blueprint with showcase and potential fix(you need creative mode with infinity chests):