Repository navigation
Leave manual glucose entries out of momentum, ICE and the RC smoothness gate - #14
Merged
Merged
Conversation
…ss gate A manual entry (fingerstick, calibration value, Nightscout meter reading) is a different measurement from the CGM, and Loop stores both with the same provenance, so the existing provenance checks never separated them. A meter value 30 mg/dL below the sensor was read as a sharp fall: in momentum it more than doubled the projected drop, and in insulin counteraction it produced two velocities from the meter/sensor offset that fed carb absorption and RC. A manual value 40+ off also turned RC off through the gradual-transitions gate. Each of these now runs on the CGM samples alone. The latest glucose, manual or not, is still the forecast's starting point.
This was referenced Oct 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
linearMomentumEffect,counteractionEffectsandhasGradualTransitionsnow ignore samples withwasUserEnteredand run on the CGM samples alone. The latest glucose, manual or not, is still the forecast's starting point.Why
Loop's
GlucoseStoregives every sample the same provenance (Loop's bundle id), so the existing provenance checks never kept a manual entry apart from the CGM readings around it. A meter value is a different measurement, and a change between it and a CGM reading isn't glucose movement:This matters more with LoopKit/G7SensorKit#102, which records every G7 calibration as a manual glucose entry. It also covers fingersticks from the bolus screen and Nightscout meter readings.
Tests
One test for each of the three paths: a manual entry inserted between CGM readings leaves the result unchanged. All three fail without the change. Full suite: 182 tests pass.