Skip to content

fix(deductions): create the deductions NVS namespace at startup to stop NOT_FOUND log noise - #362

Merged
sjordan0228 merged 1 commit into
devfrom
feature/nvs-notfound-tag-reads
Nov 29, 2026
Merged

sjordan0228 merged 1 commit into
devfrom
feature/nvs-notfound-tag-reads

Conversation

@sjordan0228

@sjordan0228 sjordan0228 commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

On a board that has never stored a pending deduction, every spool detection logs nvs_open failed: NOT_FOUND because readPendingLocked() opens the "deductions" namespace read-only and the namespace doesn't exist yet. The value read is still correct (0 pending); it just looks like an error. I'm fixing it by creating the empty namespace once in DeductionManager::begin() at startup (open read-write, then close), so the read-only lookup always finds it. This is one small edit in src/DeductionManager.cpp plus a one-clause doc update in src/DeductionManager.h. Read/write paths, values and behavior otherwise stay the same.

Closes #358

Verification

I ran make -C test/native test and pio run -e <env> followed by python scripts/check_flash_budget.py <env> for esp32dev, esp32s3zero, esp32c3, esp32s3devkitc, esp32c6, esp32c5 and seeed_xiao_esp32c6. All passed.

I have not tested this change on physical hardware.

Changelog entry (draft)

Summary by CodeRabbit

  • Improvements
    • Deduction storage is now initialized when the tracker starts. If storage cannot be opened, an error is logged.

@coderabbitai

coderabbitai Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

DeductionManager::begin() now opens and closes the deductions NVS namespace in read-write mode after mutex creation succeeds. It logs an error if opening fails. The return value remains based on whether the mutex exists.

Changes: Deduction namespace initialization

Layer / File(s) Summary
Create the namespace at startup
src/DeductionManager.cpp, src/DeductionManager.h
When mutex creation succeeds, begin() opens and closes the deductions namespace. It logs an error if opening fails. The comment documents that initialization creates the namespace for read-only lookups.

Estimated code review effort: 2 (Simple) | ~5 minutes

Change: Bug fix · Severity of issue fixed: Low

Merge Risk: Minimal · up to 83912

This change creates the empty deductions storage namespace at startup so that tag reads no longer log a spurious not-found error. Behavior is otherwise unchanged, and no merge-blocking risk was found.

Pre-merge checks: Passed 7

Check name Status Explanation
Title check Passed The title names the main change: creating the deductions NVS namespace at startup. It also gives the reason, which is to stop NOT_FOUND log noise. The diff matches this: begin() now opens the namespac…
Description check Passed The description covers the required content in substance. It has a Summary that explains the problem and fix, and a Verification section with the test commands and devices checked. It also states that…
Linked Issues check Passed Issue #358 requires creating the empty "deductions" NVS namespace once at startup (open read-write, then close) so the read-only lookup in readPendingLocked() finds it and stops logging nvs_open faile…
Out of Scope Changes check Passed The PR summary and the raw change summary show edits only to src/DeductionManager.cpp (+9/-0) and src/DeductionManager.h (+2/-1, comment only). The begin() change, the failure log line, and the header…
Public Attribution Passed No authorship credit to an automated assistant, model, or generation tool was found in the reviewed PR. - Changed files: src/DeductionManager.cpp and src/DeductionManager.h. The added lines contai…
Release-Only Version Metadata Passed The check fails only when a non-release PR edits CHANGELOG.md or changes a FIRMWARE_VERSION definition. PR #362 (sjordan0228, head feature/nvs-notfound-tag-reads, base dev) changes exactly two files: …
Task Memory Review Passed The PR changes two files: src/DeductionManager.cpp (+9 lines) and src/DeductionManager.h (comment only). I checked the committed diff against the review base. Findings: - The only new code is a `P…
Full details: Title check

Explanation

The title names the main change: creating the deductions NVS namespace at startup. It also gives the reason, which is to stop NOT_FOUND log noise. The diff matches this: begin() now opens the namespace read-write and closes it. The title follows conventional commit style and is 91 characters, slightly long but still clear.

Full details: Description check

Explanation

The description covers the required content in substance. It has a Summary that explains the problem and fix, and a Verification section with the test commands and devices checked. It also states that the author did not test on physical hardware. The template's Changes list and Checklist are missing. The Changes list is partly covered by the Summary. The Checklist asks for hardware testing, two-target compile checks, heap-allocation review, UserConfig.h check, and installer impact assessment. The author addressed compilation and flash budget, but did not state the installer impact or the heap-allocation review. The description also uses a changelog section, which the template does not include.

Resolution

Consider adding the template's Changes list and How to Test steps. Also state the checklist results. In particular, say whether the change adds NVS keys or needs a spoolsense-installer issue, and whether heap allocations were reviewed. The author should also say the hardware checkbox is unchecked, since no physical hardware test was done.

Full details: Linked Issues check

Explanation

Issue #358 requires creating the empty "deductions" NVS namespace once at startup (open read-write, then close) so the read-only lookup in readPendingLocked() finds it and stops logging nvs_open failed: NOT_FOUND. At the reviewed head, DeductionManager::begin() (src/DeductionManager.cpp) does this inside the NATIVE_TEST guard: after mutex creation succeeds, it calls Preferences::begin("deductions", false) and then end(), and logs an error if the open fails. readPendingLocked() still opens the namespace read-only and returns 0.0f for a missing key, so the value behavior is unchanged. The change is limited to the begin() path and a comment in DeductionManager.h, as the issue asks. No native test covers this path because the code is guarded by NATIVE_TEST, and the author reports no hardware test. The call site of begin() in main.cpp was not inspected in this review; the code path that creates the namespace is present at the reviewed head.

Full details: Out of Scope Changes check

Explanation

The PR summary and the raw change summary show edits only to src/DeductionManager.cpp (+9/-0) and src/DeductionManager.h (+2/-1, comment only). The begin() change, the failure log line, and the header comment all serve issue #358. No read/write value paths, settlement logic, or public declarations changed, per the raw summary ("Alterations to the declarations ... None"). The changelog draft in the PR description is documentation for the same fix. Note: the repository diff tool could not return the text diff, so this verdict relies on the supplied summary and the head file content, which matches the described change.

Full details: Public Attribution

Explanation

No authorship credit to an automated assistant, model, or generation tool was found in the reviewed PR. - Changed files: src/DeductionManager.cpp and src/DeductionManager.h. The added lines contain no attribution. A case-insensitive search of the added lines for assistant, model, vendor, and generation-tool names (for example Claude, Copilot, GPT, LLM, "generated", "co-authored", "assistant") returned no matches. - Commit: one commit, 839127f, with subject "fix(deductions): create the deductions NVS namespace at startup to stop NOT_FOUND log noise". The full commit message has no trailers, and the author is a human. - PR title and description: the title and description contain no attribution. The description's verification and changelog sections also contain none. - Primary PR author from the provider record: sjordan0228. This does not affect the check. The check is satisfied. No attribution was introduced.

Full details: Release-Only Version Metadata

Explanation

The check fails only when a non-release PR edits CHANGELOG.md or changes a FIRMWARE_VERSION definition. PR #362 (sjordan0228, head feature/nvs-notfound-tag-reads, base dev) changes exactly two files: src/DeductionManager.cpp and src/DeductionManager.h (both status M). The diff contains no CHANGELOG.md edit, no [Unreleased] section, and no FIRMWARE_VERSION change. The PR description's draft changelog entry is text only and was not committed to CHANGELOG.md. The FIRMWARE_VERSION occurrences in the repository (platformio.ini, scripts/gen_gzip_assets.py, src/*HTML.h) are unchanged by this PR. The PR title is not a release title, but that does not matter because no restricted edit occurred.

Full details: Task Memory Review

Explanation

The PR changes two files: src/DeductionManager.cpp (+9 lines) and src/DeductionManager.h (comment only). I checked the committed diff against the review base. Findings: - The only new code is a Preferences prefs; local, a prefs.begin("deductions", false) call, a prefs.end() call, and one Serial.println on failure. The Preferences object is a small stack object, far below the 1024-byte local buffer threshold. - The PR adds no new, malloc, realloc, JsonDocument, or growing container. - DeductionManager::begin() runs once from setup() in src/main.cpp:350, before the tasks start. It is not task code. The new code is not a callee of any task, so the check's scope does not reach it. - readPendingLocked() and the other read/write paths are unchanged. The diff does not alter their memory behavior. The check flags only new heap allocations, growing containers, or large new buffers in task code and its callees. None are present, so the check passes. The PR does not document heap or stack measurements. The check does not require them when no flagged item exists.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 9d4b31b and 839127f.

Files selected for processing: 2

  • src/DeductionManager.cpp
  • src/DeductionManager.h

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@github-actions github-actions Bot added the size/S Small change (10-50 lines) label Nov 29, 2026
@sjordan0228
sjordan0228 marked this pull request as ready for review November 29, 2026 14:38
@sjordan0228
sjordan0228 merged commit 28df959 into dev Nov 29, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/S Small change (10-50 lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant