  Type 1 Diabetes (T1D) is a metabolic disorder where an individual's pancreas
stops producing insulin. To compensate, they inject synthetic insulin. Computer
systems, called automated insulin delivery systems, exist that inject insulin
automatically. However, insulin is a dangerous hormone, where too much insulin
can kill people in a matter of hours and too little insulin can kill people in
a matter of days.
  In this paper, we take on the challenge of building a new trustworthy
automated insulin delivery system, called GlucOS. In our design, we apply
separation principles to keep our implementation simple, we use formal methods
to prove correct the most critical parts of the system, and we design novel
security mechanisms and policies to withstand malicious components and attacks
on the system.
  We report on real world use for one individual for 6 months using GlucOS. Our
data shows that for this individual, our ML-based algorithm runs safely and
manages their T1D effectively. We also run our system on 21 virtual humans
using simulations and show that our security and safety mechanisms enable ML to
improve their core T1D measures of metabolic health by 4.3\% on average.
Finally, we show that our security and safety mechanisms maintain recommended
levels of control over T1D even in the face of active attacks that would have
otherwise led to death.
  GlucOS is open source and our code is available on GitHub.
