How about checking whether existing analysis is the one you started with to create `updatedAnalysis`? I mean something like:

```scala
case (storedAnalysis, compileSetup) =>
  // make sure we are replacing the right instance of Analysis object
  assert(analysis == storedAnalysis, "Tried to replace unknown analysis in AnalysisStore.")
  agg.store.set(updatedAnalysis, compileSetup)
```

The only downside is that Analysis are fairly complicated objects and [`Analysis.equals`](https://github.com/sbt/sbt/blob/0.13/compile/inc/src/main/scala/sbt/inc/Analysis.scala#L252) doesn't optimize for the case of reference equality.