Actually I meant I found a dfhack workaround for a DF glitch I finally can mark all the damn "edge items" using a single script and then autodump them away dfhack was the saviour, not the offender
I have yet to find a way to add the items to the map block though, I see them using the cursor but I cant select them, only dump them using autodump which complains about the items not being part of a block. But if "dead" doesn't mean dead, I still have to figure out how to distinguish between alive breathing entities and ... well ... guys who died at the border of the map.
I'm pretty sure there is a dfhack.items command to move an item from an inventory to the ground. The issue you are experiencing is that the item isn't a part of a block because it is part of an inventory. And to make matters worse it is a part of an inventory for a unit that is "stuck" in an inactive state. You can do a couple things
1. Unstuck the unit somehow. There are various scripts that try to do this, I think fix-migrants or fix-merchants or something like that deals with getting those units "unstuck"
2. Remove the unit entirely. I'm not sure if this would cause issues, but it might work.
3. If all you care about is the items, you can remove the items from the units inventory and place them on the ground. I believe dfhack.items.moveToGround would work for this.
As for checking whether the unit is dead (inactive) or Dead (as a doorknob), you should be able to check the corspe pieces and look for a corpse object if the unit is Dead. But actually if a unit dies they drop their items and so the items would actually be in a valid block if the unit is actually Dead.