diff --git a/src/DeductionManager.cpp b/src/DeductionManager.cpp index d8fac43..df060af 100644 --- a/src/DeductionManager.cpp +++ b/src/DeductionManager.cpp @@ -31,6 +31,15 @@ bool DeductionManager::begin() { // Static allocation — honors the no-new-heap rule. mutex_ = xSemaphoreCreateMutexStatic(&mutexBuffer_); } + if (mutex_ != nullptr) { + // Create the namespace so read-only opens don't log NOT_FOUND (#358). + Preferences prefs; + if (prefs.begin("deductions", false)) { + prefs.end(); + } else { + Serial.println("DeductionManager: could not create deductions NVS namespace"); + } + } #endif return mutex_ != nullptr; } diff --git a/src/DeductionManager.h b/src/DeductionManager.h index 3c9241d..169e81d 100644 --- a/src/DeductionManager.h +++ b/src/DeductionManager.h @@ -30,7 +30,8 @@ class DeductionManager { public: static DeductionManager& getInstance(); - // One-time init: statically allocates the tracker mutex (no new heap). + // One-time init: statically allocates the tracker mutex (no new heap) and + // creates the "deductions" NVS namespace so read-only lookups find it. // Must be called during setup() before NFC and HA tasks start. Returns // false if the mutex could not be created — deduction is then disabled // (every apply fails closed, NVS pending survives).