A Theory of Local-to-Global Algorithms for One-Dimensional Spatial Multi-Agent Systems