Skip to content

fix(cli): prevent TypeError when retrieval_time_ms is null in daemon recall - #101

Closed
barrygfox wants to merge 1 commit into
qualixar:mainfrom
barrygfox:fix/retrieval-time-ms-none
Closed

fix(cli): prevent TypeError when retrieval_time_ms is null in daemon recall#101
barrygfox wants to merge 1 commit into
qualixar:mainfrom
barrygfox:fix/retrieval-time-ms-none

Conversation

@barrygfox

@barrygfox barrygfox commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Summary

Problem: cmd_recall crashes with TypeError when the daemon returns a response with null for retrieval_time_ms, or when the keyword fallback path is used (which returns score=None).

Root Cause: The _recall_keyword_fallback() function in unified_daemon.py was missing retrieval_time_ms entirely from its response dict.

Fix:

  1. Root cause fix (unified_daemon.py): Added retrieval_time_ms=0 to the keyword fallback response to make the daemon contract consistent across all code paths.

  2. CLI defensive handling (commands.py): Applied defensive or-0 pattern for both retrieval_time_ms (belt-and-suspenders against null injection) and score (keyword fallback returns score=None).

  3. Test coverage (test_recall_daemon_fallback.py): Added test_cmd_recall_via_keyword_fallback_has_retrieval_time to cover the keyword fallback path.

Changes

File Change
src/superlocalmemory/server/unified_daemon.py Added retrieval_time_ms: 0 to keyword fallback response
src/superlocalmemory/cli/commands.py Defensive or-0 for retrieval_time_ms and score formatting
tests/test_cli/test_recall_daemon_fallback.py New test for keyword fallback path

Pre-existing CI Failures

The Windows test failures (test (windows-latest, *)) are pre-existing and unrelated to this PR. Evidence:

  1. Windows tests fail on this PR across all Python versions (3.11, 3.12, 3.13, 3.14)
  2. Non-Windows tests (ubuntu-22.04, macos-14) all pass on this PR
  3. The same Windows test failures occur on main: verified by running test_wp06_ensure_venv.py on upstream/main at 71482d0 — tests pass on macOS but Windows tests were failing before this PR

The Windows failures are environmental (likely path/permission-related on Windows) and should be tracked separately.

@barrygfox
barrygfox marked this pull request as draft July 31, 2026 14:36
@barrygfox
barrygfox force-pushed the fix/retrieval-time-ms-none branch from 9903a73 to 880649a Compare July 31, 2026 14:38
@barrygfox
barrygfox marked this pull request as ready for review July 31, 2026 14:38
@barrygfox
barrygfox marked this pull request as draft July 31, 2026 14:48
@barrygfox
barrygfox force-pushed the fix/retrieval-time-ms-none branch from 880649a to b16164e Compare July 31, 2026 15:21
…rd fallback

Root cause fix: Add retrieval_time_ms=0 to _recall_keyword_fallback() response.
The keyword fallback path was missing this field entirely, which caused CLI
formatting to crash when attempting f"{None:.0f}ms".

Also fix score formatting for keyword fallback results (which have score=None)
by applying the same defensive or-0 pattern.

Fixes TypeError: unsupported format string passed to NoneType in cmd_recall
when the daemon returns a response with null/missing retrieval_time_ms.
@barrygfox
barrygfox force-pushed the fix/retrieval-time-ms-none branch from b16164e to 22681d2 Compare July 31, 2026 15:26
varun369 added a commit that referenced this pull request Aug 2, 2026
… SLM 3.8.11 release

Brings in the accumulated post-3.8.10 Windows hardening series (admission
deadline, contention, adapter sync, capture ACL enforcement) plus the
3.8.11 release commit fixing issues #102, #103 and merging PR #101.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

# Conflicts:
#	CHANGELOG.md
#	CITATION.cff
#	README.md
#	codex-plugin/AGENTS.md
#	codex-plugin/README.md
#	codex-plugin/_GENERATED.md
#	codex-plugin/skills/slm-cache/SKILL.md
#	codex-plugin/skills/slm-compress/SKILL.md
#	codex-plugin/skills/slm-governance/SKILL.md
#	codex-plugin/skills/slm-graph/SKILL.md
#	codex-plugin/skills/slm-loop/SKILL.md
#	codex-plugin/skills/slm-mesh/SKILL.md
#	codex-plugin/skills/slm-profile/SKILL.md
#	codex-plugin/skills/slm-recall/SKILL.md
#	codex-plugin/skills/slm-remember/SKILL.md
#	codex-plugin/skills/slm-scope/SKILL.md
#	codex-plugin/skills/slm-session/SKILL.md
#	codex-plugin/skills/slm-status/SKILL.md
#	copilot-plugin/.github/agents/slm-governance-advisor.agent.md
#	copilot-plugin/.github/agents/slm-loop-runner.agent.md
#	copilot-plugin/.github/agents/slm-memory-advisor.agent.md
#	copilot-plugin/.github/agents/slm-optimize-advisor.agent.md
#	copilot-plugin/.github/copilot-instructions.md
#	copilot-plugin/.github/prompts/slm-cache.prompt.md
#	copilot-plugin/.github/prompts/slm-compress.prompt.md
#	copilot-plugin/.github/prompts/slm-governance.prompt.md
#	copilot-plugin/.github/prompts/slm-graph.prompt.md
#	copilot-plugin/.github/prompts/slm-loop.prompt.md
#	copilot-plugin/.github/prompts/slm-mesh.prompt.md
#	copilot-plugin/.github/prompts/slm-profile.prompt.md
#	copilot-plugin/.github/prompts/slm-recall.prompt.md
#	copilot-plugin/.github/prompts/slm-remember.prompt.md
#	copilot-plugin/.github/prompts/slm-scope.prompt.md
#	copilot-plugin/.github/prompts/slm-session.prompt.md
#	copilot-plugin/.github/prompts/slm-status.prompt.md
#	copilot-plugin/README.md
#	copilot-plugin/_GENERATED.md
#	package-lock.json
#	package.json
#	plugin-src/agents/slm-governance-advisor.md
#	plugin-src/agents/slm-loop-runner.md
#	plugin-src/agents/slm-memory-advisor.md
#	plugin-src/agents/slm-optimize-advisor.md
#	plugin-src/manifest.json
#	plugin-src/requirements.txt
#	plugin-src/rules/AGENTS.md
#	plugin-src/rules/CLAUDE.md.fragment
#	plugin-src/skills/slm-cache/SKILL.md
#	plugin-src/skills/slm-compress/SKILL.md
#	plugin-src/skills/slm-governance/SKILL.md
#	plugin-src/skills/slm-graph/SKILL.md
#	plugin-src/skills/slm-loop/SKILL.md
#	plugin-src/skills/slm-mesh/SKILL.md
#	plugin-src/skills/slm-profile/SKILL.md
#	plugin-src/skills/slm-recall/SKILL.md
#	plugin-src/skills/slm-remember/SKILL.md
#	plugin-src/skills/slm-scope/SKILL.md
#	plugin-src/skills/slm-session/SKILL.md
#	plugin-src/skills/slm-status/SKILL.md
#	plugin/.claude-plugin/plugin.json
#	plugin/CLAUDE.md
#	plugin/agents/slm-governance-advisor.md
#	plugin/agents/slm-loop-runner.md
#	plugin/agents/slm-memory-advisor.md
#	plugin/agents/slm-optimize-advisor.md
#	plugin/requirements.txt
#	plugin/skills/slm-cache/SKILL.md
#	plugin/skills/slm-compress/SKILL.md
#	plugin/skills/slm-governance/SKILL.md
#	plugin/skills/slm-graph/SKILL.md
#	plugin/skills/slm-loop/SKILL.md
#	plugin/skills/slm-mesh/SKILL.md
#	plugin/skills/slm-profile/SKILL.md
#	plugin/skills/slm-recall/SKILL.md
#	plugin/skills/slm-remember/SKILL.md
#	plugin/skills/slm-scope/SKILL.md
#	plugin/skills/slm-session/SKILL.md
#	plugin/skills/slm-status/SKILL.md
#	pyproject.toml
#	src/superlocalmemory/__init__.py
#	tests/release/test_v37_rc_candidate_contract.py
#	tests/test_ci_guards/test_release_evidence.py
#	tests/test_ci_guards/test_release_package_surface.py
#	tests/test_cli/test_daemon_owned_discovery.py
#	uv.lock
@varun369

varun369 commented Aug 2, 2026

Copy link
Copy Markdown
Collaborator

Thanks for this — merged the fix in spirit as part of v3.8.11 (just published), with one addition: the daemon-side fix (retrieval_time_ms: 0 in _recall_keyword_fallback) had no test coverage. I verified this by reverting just that line and re-running the test suite — all 4 tests still passed, because the added test mocked daemon_request wholesale and never actually reached _recall_keyword_fallback.

Added a test that calls _recall_keyword_fallback directly, confirmed it fails without the daemon-side fix and passes with it, alongside your CLI-side null-guard test.

Closing this PR in favor of the squashed version in main — same fix, same authorship credit, just with the coverage gap closed. Appreciate the clear root-cause writeup, it made verifying this fast.

@varun369 varun369 closed this Aug 2, 2026
Speekerton pushed a commit to Speekerton/superlocalmemory that referenced this pull request Aug 2, 2026
…st reranker diagnostics

Fixes qualixar#102: explicit feedback now writes to the canonical learning.db store
(not a dead table nothing reads), and the missing learning_feedback.channel
column is added by migration M033 with existing rows preserved.

Fixes qualixar#103: the reranker now reports the real load failure instead of a
generic timeout, rejects unrecognized backends by name, and aborts on
permanent config errors instead of burning ~7.5 minutes of retries per
daemon start.

Merges PR qualixar#101 with the daemon-side test coverage it was missing (verified
by reverting the fix and confirming the original test suite stayed green).

Also: widens the MagicMock artifact guard to catch the directory-shaped
leak alongside the file-shaped one, and fixes the root cause of one such
leak in test_core_block_hygiene.py (a bare MagicMock double bypassing an
isinstance check).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants