From 64c83cc957593dc4d08fb5442a1165a3d8e4aab8 Mon Sep 17 00:00:00 2001 From: alex-poor Date: Fri, 20 Nov 2026 21:48:39 +1300 Subject: [PATCH 1/2] fix(autoisf): honour lgsThreshold preference (was inert) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Mainline ships the lgsThreshold override commented out in the autoISF determine_basal (DetermineBasalSMB keeps it active), so the user's Low Glucose Suspend threshold setting silently did nothing whenever autoISF was the active APS — the suspend floor fell back to the target-derived default (~4.4 mmol at target 6.5). Re-enable the block, identical to the SMB plugin's, so the pref can raise the floor. Co-Authored-By: Claude Opus 4.8 --- .../openAPSAutoISF/DetermineBasalAutoISF.kt | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/plugins/aps/src/main/kotlin/app/aaps/plugins/aps/openAPSAutoISF/DetermineBasalAutoISF.kt b/plugins/aps/src/main/kotlin/app/aaps/plugins/aps/openAPSAutoISF/DetermineBasalAutoISF.kt index e145fa15fb1c..6aa1e57c800e 100644 --- a/plugins/aps/src/main/kotlin/app/aaps/plugins/aps/openAPSAutoISF/DetermineBasalAutoISF.kt +++ b/plugins/aps/src/main/kotlin/app/aaps/plugins/aps/openAPSAutoISF/DetermineBasalAutoISF.kt @@ -389,13 +389,17 @@ class DetermineBasalAutoISF @Inject constructor( // min_bg of 90 -> threshold of 65, 100 -> 70 110 -> 75, and 130 -> 85 var threshold = min_bg - 0.5 * (min_bg - 40) - // if (profile.lgsThreshold != null) { - // val lgsThreshold = profile.lgsThreshold ?: error("lgsThreshold missing") - // if (lgsThreshold > threshold) { - // consoleError.add("Threshold set from ${convert_bg(threshold)} to ${convert_bg(lgsThreshold.toDouble())}; ") - // threshold = lgsThreshold.toDouble() - // } - // } + // Honour the user's Low Glucose Suspend threshold preference. Mainline ships this block + // commented out in the autoISF plugin (DetermineBasalSMB.kt keeps it active), so the + // lgsThreshold setting is silently inert whenever autoISF is the active APS. Re-enabled so + // the pref can raise the suspend floor above the target-derived default. + if (profile.lgsThreshold != null) { + val lgsThreshold = profile.lgsThreshold ?: error("lgsThreshold missing") + if (lgsThreshold > threshold) { + consoleError.add("Threshold set from ${convert_bg(threshold)} to ${convert_bg(lgsThreshold.toDouble())}; ") + threshold = lgsThreshold.toDouble() + } + } //console.error(reservoir_data); From 41e3f1e232bf8c99601f9ec5ee95d9bd7118112a Mon Sep 17 00:00:00 2001 From: alex-poor Date: Fri, 20 Nov 2026 21:48:39 +1300 Subject: [PATCH 2/2] fix(objectives): drop SMB objective gate so SMB works without re-walking objectives MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit isSMBModeEnabled forced SMB off whenever the SMB objective was not started. After the CamAPS->autoISF switch that objective was never started, so SMB was silently disabled for an experienced operator who has run SMB on this loop before — autoISF ran basal-only for days. Remove the objective- progression gate. SMB is still gated by closed-loop (SafetyPlugin) and the use_smb preference, so the real safety checks are untouched. Co-Authored-By: Claude Opus 4.8 --- .../plugins/constraints/objectives/ObjectivesPlugin.kt | 8 ++++---- .../constraints/objectives/ObjectivesPluginTest.kt | 8 +++++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/plugins/constraints/src/main/kotlin/app/aaps/plugins/constraints/objectives/ObjectivesPlugin.kt b/plugins/constraints/src/main/kotlin/app/aaps/plugins/constraints/objectives/ObjectivesPlugin.kt index fc45caa6787d..bb1df552148d 100644 --- a/plugins/constraints/src/main/kotlin/app/aaps/plugins/constraints/objectives/ObjectivesPlugin.kt +++ b/plugins/constraints/src/main/kotlin/app/aaps/plugins/constraints/objectives/ObjectivesPlugin.kt @@ -106,10 +106,10 @@ class ObjectivesPlugin @Inject constructor( } override fun isSMBModeEnabled(value: Constraint): Constraint { - // Check if initialized - if (objectives.isEmpty()) return value - if (!objectives[SMB_OBJECTIVE].isStarted) - value.set(false, rh.gs(R.string.objectivenotstarted, SMB_OBJECTIVE + 1), this) + // Objectives SMB gate removed for this build: the operator has run SMB on this loop before + // and does not need the progression re-walked after a device/build change. SMB is still + // gated by closed-loop (SafetyPlugin) and the use_smb preference, so this only drops the + // objective-progression requirement, not the real safety checks. return value } diff --git a/plugins/constraints/src/test/kotlin/app/aaps/plugins/constraints/objectives/ObjectivesPluginTest.kt b/plugins/constraints/src/test/kotlin/app/aaps/plugins/constraints/objectives/ObjectivesPluginTest.kt index 8cfd64312243..97786b8ebb93 100644 --- a/plugins/constraints/src/test/kotlin/app/aaps/plugins/constraints/objectives/ObjectivesPluginTest.kt +++ b/plugins/constraints/src/test/kotlin/app/aaps/plugins/constraints/objectives/ObjectivesPluginTest.kt @@ -98,10 +98,12 @@ class ObjectivesPluginTest : TestBaseWithProfile() { assertThat(c.value()).isFalse() } - @Test fun notStartedObjective10ShouldLimitSMBMode() { + @Test fun smbModeIsNotGatedByObjective() { + // The Objectives SMB gate was intentionally removed for this build (operator has run SMB + // before). An unstarted SMB objective must NOT disable SMB mode here; closed-loop and the + // use_smb preference remain the real gates elsewhere. objectivesPlugin.objectives[Objectives.SMB_OBJECTIVE].startedOn = 0 val c = objectivesPlugin.isSMBModeEnabled(ConstraintObject(true, aapsLogger)) - assertThat(c.getReasons()).contains("Objective 9 not started") - assertThat(c.value()).isFalse() + assertThat(c.value()).isTrue() } }