Skip to content

fix(memory): guard fetchone() against None in MemoryStore add_fact and update_fact - #22702

Open
Ninso112 wants to merge 2 commits into
NousResearch:mainfrom
Ninso112:fix-memory-fetchone-guard
Open

Ninso112 wants to merge 2 commits into
NousResearch:mainfrom
Ninso112:fix-memory-fetchone-guard

Conversation

@Ninso112

@Ninso112 Ninso112 commented May 9, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add_fact(): raises RuntimeError with descriptive message when a concurrent delete removes the fact between a failed INSERT and the follow-up SELECT, instead of crashing with TypeError
  • update_fact(): falls back to category="general" when the category re-fetch returns no row after a concurrent delete
  • Added 5 tests covering normal dedup, concurrent delete in both methods, category skip, and non-existent fact handling

Closes #22660

Ninso112 added 2 commits May 9, 2026 18:20
… and long forms

The generated zsh completion script used invalid _arguments syntax:
'(-h --help){-h,--help}[...]'.  Zsh () groups must contain only single-letter
short options, not long options with spaces.  Changed to '(-)'{-h,--help}'[...]'
which is the standard zsh completion convention.

Closes NousResearch#22686
…d update_fact

add_fact() now raises RuntimeError when a concurrent delete removes the
fact between a failed INSERT and the follow-up SELECT, instead of
crashing with TypeError.  update_fact() falls back to category='general'
when the category re-fetch returns no row after a concurrent delete.

Closes NousResearch#22660
@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have comp/plugins Plugin system and bundled plugins tool/memory Memory tool and memory providers duplicate This issue or pull request already exists labels May 9, 2026
@alt-glitch

Copy link
Copy Markdown

Competing with #22660 (same fix — guard fetchone() in MemoryStore). #22660 is from the original author.

@teknium1 teknium1 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for covering the unguarded fetchone() paths. The memory portion still targets current-main code: plugins/memory/holographic/store.py:175-178 and :306-308 remain unguarded, and the latter re-fetch occurs after the commit at :290.

Problems

  • tests/hermes_cli/test_completion.py defines test_valid_zsh_arguments_syntax twice in this PR; the second definition shadows the first.
  • tests/plugins/memory/test_holographic_store_null_guards.py:21-24 creates a delete=False database but never removes it.
  • The zsh implementation is already on main at hermes_cli/completion.py:220-243, with stronger existing coverage at tests/hermes_cli/test_completion.py:148-187 (commits 8c4bec615 and 6d30b4a7e).

Suggested changes

  • Salvage the focused memory fix only, remove the duplicate test definition, and use tmp_path or unlink the temporary database.

Automated hermes-sweeper review.

assert "'(-)'{-h,--help}'" in out
assert "'(-)'{-V,--version}'" in out
assert "'(-)'{-p,--profile}'" in out

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a second definition of test_valid_zsh_arguments_syntax; Python silently replaces the first method with this one. Please keep only one copy so the intended coverage is not shadowed.

def store():
"""Create a MemoryStore backed by a temporary database."""
with tempfile.NamedTemporaryFile(suffix=".db", delete=False) as f:
path = f.name

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NamedTemporaryFile(delete=False) leaves the database behind because this fixture only closes the connection. Please use pytest's tmp_path fixture or unlink the file in teardown.

@teknium1 teknium1 added sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform area/memory Memory subsystem: store, providers, sync, background reviews labels Jul 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/memory Memory subsystem: store, providers, sync, background reviews comp/plugins Plugin system and bundled plugins duplicate This issue or pull request already exists P3 Low — cosmetic, nice to have sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state tool/memory Memory tool and memory providers type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants