Modular software, in which strongly-separated units of functionality can be independently added to and removed from a node’s running software, offers a promising approach to effective dynamic software updating in Wireless Sensor Networks (WSNs). Modular software updating approaches offer high efficiency, in terms of both network costs and update installation at nodes, as well as low disruption, allowing existing software to continue to operate during updates. Existing approaches however critically lack safety, relying on weakly-typed event-based programming abstractions for inter-module interaction. This precludes compile-time or composition-time verification of interoperability between dynamically loaded modules and therefore presents major risks for future large-scale production-class deployments. In this paper we present Lorien: a component-based modular operating environment that employs interface-based inter-component interaction to support completely type-safe software composition, while still supporting high update efficiency and low disruption. Our approach also has very wide scope, allowing almost 90% of software to be remotely updated on common sensor platforms such as the TelosB. We compare Lorien against existing modular designs, finding that the safety properties of Lorien are offered with near equal efficiency.