Repository navigation
Conversation
…imit Two Tidepool Loop 1.0 behaviors the loop-1.0 preset did not restore: - Momentum gradual-transitions gate. linearMomentumEffect called hasGradualTransitions() with its hard-coded 40 mg/dL default, so noGradualTransitionsGate only bypassed the retrospective-correction gate despite documenting that it covers momentum too. Add a gradualTransitionThreshold parameter (default 40, nil = no gate) and pass nil from both prediction paths when noGradualTransitionsGate is set. Tidepool Loop 1.0's linearMomentumEffect guarded only continuity, calibration and provenance. - Max active insulin limit. Tidepool Loop 1.0's temp basal recommendation had no active-insulin limit; the port caps automatic dosing at maxBolus x maxActiveInsulinMultiplier, which with IOB above the limit caps the temp basal below scheduled even when a high is forecast. Add disableMaxActiveInsulinLimit (on in loop-1.0) to lift the limit. Defaults are unchanged; the existing 158 tests pass unmodified. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019XDFAzoY74eu61n3aTT54Z
…side the loop-1.0 preset Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019XDFAzoY74eu61n3aTT54Z
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.
Follow-up to #40. A review of the
loop-1.0preset against the Tidepool Loop 1.0 source (LoopWorkspacebuild-332, i.e. LoopKitbdad094and Loopcf10ea3) found two behaviors it did not restore.Momentum gradual-transitions gate
linearMomentumEffectcalledhasGradualTransitions()with its hard-coded 40 mg/dL default. SonoGradualTransitionsGateonly bypassed the retrospective-correction gate, even though its doc comment says it covers momentum too.This PR:
gradualTransitionThreshold: Double? = 40.0parameter, where nil means no gate;noGradualTransitionsGateis set.1.0's
linearMomentumEffectchecked only continuity, calibration and provenance (LoopKit GlucoseMath.swift:97-99).Max active insulin limit
1.0's temp-basal recommendation had no active-insulin limit (
Loop DoseMath.swift:340-386). The port caps automatic dosing atmaxBolus × maxActiveInsulinMultiplier. When IOB is above that limit, it caps the temp basal below scheduled even when a high is forecast.This PR adds
disableMaxActiveInsulinLimit, which is on inloop-1.0.Documentation
The
loop1preset's doc comment now lists the 1.0 behaviors callers must set through inputs:recommendationType = .tempBasaluseIntegralRetrospectiveCorrection = falseuseMidAbsorptionISF = falseIt also lists the dosing-side behaviors outside this package that callers must reproduce:
predictionStartat the CGM timestampNot addressed here
With IOB above the limit and a forecast high, the default path recommends a negative temp basal (−12.07 U/h in the new test's scenario before the flag is applied). The headroom cap pushes
maxBasalRatebelow zero and nothing clamps it back to 0. That's worth a separate fix.Testing
Defaults are unchanged: the 158 existing tests pass unmodified. Five new tests in
AlgorithmEmulationTestscover:🤖 Generated with Claude Code
https://claude.ai/code/session_019XDFAzoY74eu61n3aTT54Z