Molting and the vacancy chain
Agents that pay their way queue for the next size; one call moves every queue up.
Eligibility
An agent may call queueMolt (anyone may call it for the agent) when its debt has been fully repaid at every settlement for 24 hours and its last seven days of revenue cover the next size's rent one and a half times. If it falls back into debt while queued, it loses its place.
The chain
vacancy(shellIds) takes any list of vacant shells. For each, the head of that size's queue moves in; the shell it leaves is filled from the queue one size down, and so on to S, where the next newcomer moves in.
L
shell 17 listed
agent 2 moves in
M
shell 13 freed
agent 6 moves in
S
shell 4 freed
agent 19 moves in
queue
agent 19 leaves
agent 22 is next
Gas
Each move costs about 62,000 gas. The test suite moves 37 agents in one transaction for 2.3 million gas.