Skip to content

Use LoopAlgorithm's experiments, and add Guard + Runway - #2608

Merged
ps2 merged 2 commits into
next-devfrom
feature/guard-and-runway-experiment
Oct 24, 2026
Merged

ps2 merged 2 commits into
next-devfrom
feature/guard-and-runway-experiment

Conversation

@ps2

@ps2 ps2 commented Oct 24, 2026 •

Copy link
Copy Markdown
Collaborator

LoopKit/LoopAlgorithm#10 moved the algorithm experiments into LoopAlgorithm and added a new one, guardAndRunway. This switches Loop over to them and adds a setting for the new one.

  • Experiments go in the algorithm input. fetchData passes the enabled set (experiments) and volatilityBaseline. Integral RC and Glucose Based Partial Application now run through LoopAlgorithm, so the app-side application factor strategies are removed; their math was identical to LoopAlgorithm's.
  • Guard + Runway setting. A new row under Settings → Algorithm Experiments, with a description screen and a toggle, like the existing two.
  • Volatility baseline. The median σ5 over four weeks of glucose, from GlucoseVolatility.baseline(_:). It is refreshed once a day, or hourly until there is a day of glucose; until then the algorithm uses the band at full depth.
  • Records. Dosing decisions record each experiment by its LoopAlgorithm name, and the guard + runway entry carries the baseline. The diagnostic report lists the active experiments and the baseline.
  • Naming. LoopAlgorithm's experiment type is ExperimentOption (Rename AlgorithmExperiment to ExperimentOption LoopAlgorithm#11), so it doesn't clash with LoopKit's AlgorithmExperiment record.

Needs LoopKit/LoopAlgorithm#11 (the rename); the LoopWorkspace bump will follow once both merge.

Tested: Loop builds against LoopAlgorithm with #11 and stock LoopKit next-dev; LoopTests (344) and LoopKitTests (507) pass. Not yet run in the simulator with the experiment switched on.

ps2 added 2 commits October 24, 2026 13:13
LoopAlgorithm now implements the algorithm experiments (LoopKit/LoopAlgorithm#10).
Pass the enabled set and the volatility baseline in the algorithm input instead of
computing the glucose-based application factor and switching integral RC in Loop.
The removed application factor strategies matched LoopAlgorithm's factor exactly.

Guard + Runway gets a row in Algorithm Experiments. Its volatility baseline is the
median sigma5 over four weeks of glucose, refreshed daily (hourly until there is a
day of glucose). Dosing decisions record each experiment by its LoopAlgorithm name,
with the baseline for guard + runway, and the diagnostic report lists both.

LoopKit also declares an AlgorithmExperiment, so LoopAlgorithm's is referred to
through the LoopAlgorithmExperiment typealias.
LoopAlgorithm renamed its experiment type, so the LoopAlgorithmExperiment typealias and the LoopKit.AlgorithmExperiment qualifications are no longer needed.
@ps2
ps2 merged commit 6d0a891 into next-dev Oct 24, 2026
@ps2
ps2 deleted the feature/guard-and-runway-experiment branch October 24, 2026 18:46
AndEliRich pushed a commit to AndEliRich/LoopWorkspace that referenced this pull request Oct 24, 2026
…t, welcome screen width

- LoopAlgorithm: optional algorithm experiments (LoopKit/LoopAlgorithm#10), type renamed to ExperimentOption (LoopKit/LoopAlgorithm#11)
- Loop: use LoopAlgorithm's experiments, and add Guard + Runway (LoopKit/Loop#2608)
- LoopOnboarding: limit the welcome screen to a readable width (LoopKit/LoopOnboarding#39)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant