Skip to content

Cache registry bug: edge vectors never registered, switch-back always full rebuild #331

@buildingjoshbetter

Description

@buildingjoshbetter

Problem

The vector cache registry has no "edge" entry after Phase 8 migration, causing every switch-back to edge tier to require a full re-embedding even if edge vectors were previously computed.

Root Cause

migrate_legacy_vec_tables() (vector_search.py:895-976) only registers the CURRENT tier group:

group = _active_tier_group()  # Returns whatever tier is active NOW
# Only creates a cache entry for THIS one group
conn.execute("INSERT OR REPLACE INTO vector_cache_registry ...", (group, ...))

If the user was on "base" or "pro" when the Phase 8 migration ran (commit ebe36ac), only the "basepro" group gets a cache entry. The "edge" group has NO entry.

Impact

When switching TO edge:

  1. resolve_rebuild_action() calls VectorCacheRegistry.get(conn, "edge")
  2. Returns None (no entry exists)
  3. Returns "full_rebuild" -- even if edge vectors existed before the upgrade

Combined with Bug #2 (last_embedded_id=0), this means:

  • Every tier switch in every direction always requires full rebuild
  • The delta-rebuild optimization (only embed new messages since last switch) is dead code
  • "Instant switch-back" feature documented in cache.py docstring never works

Expected Behavior

After any tier switch or migration, BOTH tier groups should have registry entries so that:

  • Switching Base->Edge uses cached edge vectors + only embeds delta
  • Switching Edge->Base uses cached basepro vectors + only embeds delta

Fix Options

  1. During migration: register both groups (current group with real data, other group with vector_count=0 and last_embedded_id=0)
  2. During _finalize_rebuild: ensure the completed group gets properly registered (see related issue about last_embedded_id=0)
  3. In resolve_rebuild_action: before returning "full_rebuild", check if the vec table actually exists with data (SELECT COUNT)

Files

  • truememory/vector_search.py line 913 (migration only registers current group)
  • truememory/tier_switch/cache.py lines 148-158 (resolve_rebuild_action logic)
  • Commit: ebe36ac (Phase 8 migration)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions