Skip to content
This repository was archived by the owner on Apr 2, 2026. It is now read-only.
This repository was archived by the owner on Apr 2, 2026. It is now read-only.

bug: snapshot.Clear is never called in runWithoutCache, so snapshots persist across multiple sessions until TTL expires #395

@claude

Description

@claude

Problem

The runWithCache and runLocalMode functions in cmd/run.go both call snapshot.Clear(proj.RootDir) after consuming the session snapshot (lines 232, 358, 423). This ensures the snapshot is one-shot: it's injected once then deleted.

However, runWithoutCache (cmd/run.go:385) does not call snapshot.Clear. If the cache is unavailable and runWithoutCache is called, any present session snapshot is injected into the context bomb but never cleared. On the next run invocation, the same snapshot is read again and injected a second time, and so on — until the 24-hour TTL in snapshot.DefaultTTL finally expires the file.

This means a pre-compact snapshot can be re-injected into every context bomb for up to 24 hours if the cache is consistently unavailable (e.g. on a machine with a corrupted SQLite file).

Steps to reproduce

  1. Run uncompact pre-compact to write a snapshot.
  2. Delete or corrupt the SQLite cache so cache.Open fails.
  3. Run uncompact run multiple times.
  4. Observe the snapshot section repeating in every context bomb output.

Fix

Add snapshot.Clear in runWithoutCache after the snapshot is successfully included in the rendered output, matching the pattern used in runWithCache and runLocalMode:

// After rendering and printing output, clear the snapshot so it isn't re-injected.
if snap != nil {
    if clearErr := snapshot.Clear(proj.RootDir); clearErr != nil {
        logFn("[warn] snapshot clear error: %v", clearErr)
    }
}

Location

  • cmd/run.go:385 (runWithoutCache — missing snapshot.Clear call)
  • Compare with cmd/run.go:232, cmd/run.go:358, cmd/run.go:423 (all call snapshot.Clear)

@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