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
- Run
uncompact pre-compact to write a snapshot.
- Delete or corrupt the SQLite cache so
cache.Open fails.
- Run
uncompact run multiple times.
- 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
Problem
The
runWithCacheandrunLocalModefunctions incmd/run.goboth callsnapshot.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 callsnapshot.Clear. If the cache is unavailable andrunWithoutCacheis called, any present session snapshot is injected into the context bomb but never cleared. On the nextruninvocation, the same snapshot is read again and injected a second time, and so on — until the 24-hour TTL insnapshot.DefaultTTLfinally 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
uncompact pre-compactto write a snapshot.cache.Openfails.uncompact runmultiple times.Fix
Add
snapshot.ClearinrunWithoutCacheafter the snapshot is successfully included in the rendered output, matching the pattern used inrunWithCacheandrunLocalMode:Location
cmd/run.go:385(runWithoutCache— missingsnapshot.Clearcall)cmd/run.go:232,cmd/run.go:358,cmd/run.go:423(all callsnapshot.Clear)@claude please implement this