Skip to content

Bug: _mneme_recall swallows all exceptions; corrupt FTS5 index is invisible #146

@tcconnally

Description

@tcconnally

Severity: 🟡 Medium (observability gap)

memory.py:32–55 returns [] on any exception, with no logging. A corrupt SQLite FTS5 index (truncated WAL, schema-version mismatch after upgrade) silently returns "no results" forever, with no signal to the operator.

Suggested fix

def _mneme_recall(cfg, query, k=5, scope=None, type_filter=None):
    conn = _mneme_open_index(cfg)
    if conn is None:
        return []
    try:
        ...
    except sqlite3.DatabaseError as exc:
        audit_event(cfg, "directive_error",
                    directive="@memory", error=f"sqlite: {exc}",
                    hint="Run `perseus memory reindex` to rebuild.")
        print(f"⚠ Mnēmē FTS5 index error: {exc}", file=sys.stderr)
        return []
    except Exception as exc:
        audit_event(cfg, "directive_error", directive="@memory", error=str(exc))
        return []

Also ensure perseus memory reindex (or equivalent _cmd_memory_index in mneme_index.py:408) is surfaced in CLI help.

Acceptance criteria

  • Test: corrupt the FTS5 index, call _mneme_recall, assert audit log entry and stderr warning.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions