-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path0039-Interval-gate-follow-up-fix-stale-6s-comments-align-.patch
More file actions
61 lines (56 loc) · 4.45 KB
/
Copy path0039-Interval-gate-follow-up-fix-stale-6s-comments-align-.patch
File metadata and controls
61 lines (56 loc) · 4.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
From 73b8bc3d91a71f64c1a4dea29a1d92b43d200140 Mon Sep 17 00:00:00 2001
From: toniuhlemann <99549438+toniuhlemann@users.noreply.github.com>
Date: Sun, 12 Jul 2026 16:12:18 +0200
Subject: [PATCH 39/42] Interval-gate follow-up: fix stale 6s comments, align
DetermineBasalSMB
The LoopPlugin constraints-gate comment still told the 6s story after
the code moved to 15s (patch 0038). Also align the inactive
openAPSSMB determine gate to the same 15s so every SMB interval gate
in the fork shares one semantics; comment-only elsewhere, no behaviour
change on the active AUTO_ISF path.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
---
.../kotlin/app/aaps/plugins/aps/loop/LoopPlugin.kt | 13 +++++++------
.../plugins/aps/openAPSSMB/DetermineBasalSMB.kt | 5 ++++-
2 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/plugins/aps/src/main/kotlin/app/aaps/plugins/aps/loop/LoopPlugin.kt b/plugins/aps/src/main/kotlin/app/aaps/plugins/aps/loop/LoopPlugin.kt
index 10560d02aa..bf1f615219 100644
--- a/plugins/aps/src/main/kotlin/app/aaps/plugins/aps/loop/LoopPlugin.kt
+++ b/plugins/aps/src/main/kotlin/app/aaps/plugins/aps/loop/LoopPlugin.kt
@@ -505,12 +505,13 @@ class LoopPlugin @Inject constructor(
resultAfterConstraints.smb = constraintChecker.applyBolusConstraints(resultAfterConstraints.smbConstraint!!).value()
// safety check for multiple SMBs
- // IOB-Action patch (2026-07-12): apply the SAME 6s tolerance the determine gate uses
- // (DetermineBasalAutoISF "lastBolusAge > SMBInterval - 6.0"). Without it, three enact
- // gates (here, applySMBRequest, CommandSMBBolus) enforced the FULL interval while
- // determine had already released the SMB at interval-6s: in the 54-60s window (1-min
- // CGM, smbinterval=1) a wanted SMB was silently zeroed by sub-second enact jitter and
- // never retried. Determine remains the planner; the enact gates just stop lying to it.
+ // IOB-Action patches (2026-07-12): all four gates (determine, here, applySMBRequest,
+ // CommandSMBBolus) share ONE tolerance — first 6s (so the enact gates stop silently
+ // zeroing determine-approved SMBs), then raised to 15s: the bolus RECORD lands ~10s
+ // after the decision, so with a 60s BG cadence the next cycle always saw an age of
+ // ~50s and waited — SMBInterval=1 effectively delivered every OTHER minute during
+ // sustained demand. Gate at interval-15s absorbs that enact offset; amounts remain
+ // capped by the smb ratio and the iobTH bands (cadence changes, budget does not).
val lastBolusTime = persistenceLayer.getNewestBolus()?.timestamp ?: 0L
if (lastBolusTime != 0L && lastBolusTime + T.mins(preferences.get(IntKey.ApsMaxSmbFrequency).toLong()).msecs() - T.secs(15).msecs() > dateUtil.now()) {
aapsLogger.debug(LTag.APS, "SMB requested but still in ${preferences.get(IntKey.ApsMaxSmbFrequency)} min interval")
diff --git a/plugins/aps/src/main/kotlin/app/aaps/plugins/aps/openAPSSMB/DetermineBasalSMB.kt b/plugins/aps/src/main/kotlin/app/aaps/plugins/aps/openAPSSMB/DetermineBasalSMB.kt
index b738d2315a..4ab3478dcd 100644
--- a/plugins/aps/src/main/kotlin/app/aaps/plugins/aps/openAPSSMB/DetermineBasalSMB.kt
+++ b/plugins/aps/src/main/kotlin/app/aaps/plugins/aps/openAPSSMB/DetermineBasalSMB.kt
@@ -1171,7 +1171,10 @@ class DetermineBasalSMB @Inject constructor(
val SMBInterval = min(10, max(1, profile.SMBInterval)) * 60.0 // in seconds
//console.error(naive_eventualBG, insulinReq, worstCaseInsulinReq, durationReq);
consoleError.add("naive_eventualBG $naive_eventualBG,${durationReq}m ${smbLowTempReq}U/h temp needed; last bolus ${round(lastBolusAge / 60.0, 1)}m ago; maxBolus: $maxBolus")
- if (lastBolusAge > SMBInterval - 6.0) { // 6s tolerance
+ // IOB-Action patch (2026-07-12): 15s tolerance, aligned with DetermineBasalAutoISF
+ // and the enact gates (absorbs the ~10s enact offset at interval==BG-cadence).
+ // This plugin is inactive on Toni's setup (AUTO_ISF runs) — consistency change.
+ if (lastBolusAge > SMBInterval - 15.0) { // 15s tolerance (enact offset)
if (microBolus > 0) {
rT.units = microBolus
rT.reason.append("Microbolusing ${microBolus}U. ")
--
2.50.0.windows.1