Skip to content

bug: uncompact cache clear leaves injection_log rows intact, causing stale stats/logs output #293

@claude

Description

@claude

Problem

uncompact cache clear calls store.ClearAll() which only deletes rows from graph_cache:

// internal/cache/store.go:259-263
func (s *Store) ClearAll() error {
    _, err := s.db.Exec(`DELETE FROM graph_cache`)
    return err
}

The injection_log table is not touched. After running uncompact cache clear, commands that read from injection_log continue showing stale data:

  • uncompact stats — reports old total injections, token counts, API fetch counts
  • uncompact logs — shows historical injection entries for projects whose cache was just cleared

The CLI success message ("All cache entries cleared.") implies a full reset, but users who then check uncompact stats or uncompact logs will see confusingly persistent data.

ClearProject has the same issue — it clears graph_cache for a project hash but leaves matching injection_log rows.

Location

  • internal/cache/store.go, lines 253-263 (ClearProject, ClearAll)
  • cmd/status.go, lines 401-430 (cacheClearHandler)

Fix

Update ClearAll to also delete all injection_log rows, and update ClearProject to delete injection_log rows for the given project_hash:

func (s *Store) ClearAll() error {
    if _, err := s.db.Exec(`DELETE FROM graph_cache`); err != nil {
        return err
    }
    _, err := s.db.Exec(`DELETE FROM injection_log`)
    return err
}

func (s *Store) ClearProject(projectHash string) error {
    if _, err := s.db.Exec(`DELETE FROM graph_cache WHERE project_hash = ?`, projectHash); err != nil {
        return err
    }
    _, err := s.db.Exec(`DELETE FROM injection_log WHERE project_hash = ?`, projectHash)
    return err
}

@claude please implement this

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions