Conversation
TestSummary: TBD Configuration
Test 1Delete Trio for SE 3rd gen phone running iOS 26.
Add Glucose simulator as CGM and rPi DASH as pump.
Test 2Delete Trio for SE 3rd gen phone running iOS 26.
Add Glucose simulator as CGM and rPi DASH as pump.
no difference. Make sure I really have the new build. Do another delete Trio and rebuild again. |
Test SummaryInitial look is good - no unexpected negative IOB after pump and CGM are attached to a fresh build. Test 3Earlier tests were done before the PR was ready for testing. Delete Trio from SE 3rd gen phone running iOS 26.
Add Glucose simulator as CGM and rPi DASH as pump.
Observe IOB
|
kingst
left a comment
There was a problem hiding this comment.
This review is based on code review only, I haven't tested this.
In general, this is a real bug and we should fix it, thank you for driving this.
I'd like to suggest two alternatives that might simplify things. Conceptually, I think it's better to remove orphaned resumes vs injecting a suspend since it'll simplify the logic.
One aspect that is important is ensuring that oref gets consistent behavior across all functions that operate on pump events: meal, autosens, and iob. So any time any of these functions pull pump events, the orphaned resume should be filtered out.
I would define an invariant that is simple, something like: "any resumes that don't have a preceding suspend within DIA or 24h time duration are orphaned resumes" and filter these out. It'll probably require pulling more pump events but I don't want to have a case where IoB doesn't have a resume and then it shows up later in meal.
In terms of the way to implement this, I can see two possibilities:
- Filter in memory for all oref functions
- Filter when new pump events arrive and don't store orphaned resumes
Neither is perfect so I don't have a strong opinion one way or the other about how we implement this.
Test SummaryThis test was performed on 2026-01-29. It was successful. Using code from this PR prevented negative IOB for a new installation. Test DetailsThese are my raw notes: Do a new test with dev. Take a "pump break" for several hours. To do this, must use a real pump. So set up 2 phones with MDT pumps. 2026-01-26 10:05 - end the Eversense Trio test on the 2nd gen SE phone. was running experimental/medtrum-eversense branch from Mike Plante Set up Nightscout as CGM for both phones. For red 2nd gen SE, do not allow any uploading to NS. Set up Therapy settings for both phones to be identical for Trio. build fresh copies of dev on each phone and let the pump / phone / app come to equilibrium. cgm cgm_steady_state_110_two_days.txt 299 $ns_url_test $api_secret; Therapy settings: all default settings except set basal rates to 1 U/hr, CR to 10 g/U and ISF to 50 mg/dL/U fiasp insulin selected at 10:30 build: 576d323 (HEAD -> dev, origin/dev) CI: Bump APP_DEV_VERSION to 0.6.0.46 [skip ci] on each phone. disconnect each phone from xcode. The 3rd gen phone has not been running anything for a long time. The 2nd gen phone was being used for an eversense test using a DASH rpi pump. Let them come to equilibrium over the next 2 hours. Got distracted with other things. 2nd gen - delete the pump at 16:00
merge dev into fix-negative-iob-after-onboarding, local name: dev_merge_into_pr903 Build this onto the 2 phones and let them stablize overnight. 2026-01-30 order: 2nd Gen (DASH), then 3rd Gen (MDT)
|
…ative-iob-after-onboarding
|
@kingst as discusses (privately), I have synced this PR with latest @marionbarker no additional testing needed; we only synced this with |
This isn't a real algorithm yet, it's just a sketch to demonstrate a concept. I think this change simplifies the logic and handles the edge cases, but I don't know enough about the behavior of non omnipod pumps to know if this change is the right one to make. It definitely handles two cases: - new users - pump breaks
Test SummarySuccess ConfigurationSE 2nd gen phone running iOS 18.7
Therapy settings (default except for basal rates) and maxIOB:
CGM: Nightscout: Use constant CGM value of 110 mg/dL Note - this was my second test tonight. First one I did not have the flat rate (used glucose simulator) and I had SMB/UAM enabled. Observe IOB
Looking back at the initial test (see #903 (comment))
|
marionbarker
left a comment
There was a problem hiding this comment.
I did another test and am retracting my earlier approval. I'll post the test next.
Test❌ This test failed in that a significant negative IOB was reported. ConfigurationContinuing the test from #903 (comment) SE 2nd gen phone running iOS 18.7
NarrativeThis test was performed 2026-02-27 starting just past 8 am PST.
ScreenshotsGraphic below shows
Log Filezip today's log file |
Test✅ The 24 hour pump gap test and the long suspend test appear nominal. Test 24 hour gapTest results for adding a DASH pump more than 24 hours after last pod was deactivated. Scheduled basal for therapy settings is 2.0 U/hr.
Test SuspendSuspend the pod.
|
Test SummaryThe odd behavior of massive negative IOB did not recur. Medtronic TestingContinue from the previous comment. This test took place on 2026-02-28. For this deletion of the MDT pump, I came from the Devices, Pump, MDT screen to delete the pump instead of coming from the Main screen. I went straight to the add pump from there without returning to the main screen.
Let the MDT / Trio combination run overnight. |
Test SummaryI was once again not able to reproduce the error in #903 (comment) Test Narrative2026-02-28 at 21:48 - noticed signal loss, MDT pump not responsive, changed the battery, working again. Let test continue. 2026-03-01 08:55 Continue with the test where delete MDT and add DASH.
Once again - the odd negative IOB behavior was not repeated. Start Over with Blank Slate09:11 Deactivate the pod from the app
09:13 Delete the Trio app from the phone.
New Test, Fresh Trio buildoops - I planned to do the fresh trio build test but got busy on other tasks. However, on 12-March-2026, I installed Trio dev onto a phone with no app for PR 975 and saw the large negative IOB. |
Test SummaryDelete Trio from test phone. ✅ Initial test - new pump added to fresh install successful. No indication of negative IOB. Configuration
Omnipod DASH TestingThis test took place on 2026-03-19 at 13:00 PDT
statusLet this test run for an hour and then test changing to another pump |
Test Continuation✅ Successful test Continue the test from comment: #903 (comment) Configurationupdate build to commit: 609bf1e Test NarrativeNote
Screenshots
|
marionbarker
left a comment
There was a problem hiding this comment.
Approve from test.
I did a cursory review and note that sonarclous wants changes. Leaving that up to the developers to handle.
…ter-onboarding Fix negative IOB on fresh installs (nightscout#898)


Summary
This PR fixes cases where negative IOB can occur when pump history contains a
resumewithout a precedingsuspend(e.g. fresh installs of newly onboarded Trio users).Fixes: #898
Changes
The logic now detects resume-only states within the DIA (duration of insulin action) window and injects a simulated suspend event 1s before the resume only if no real suspend exists in the relevant history window. This gives oref a safe baseline without altering valid pump history.