@@ -80,6 +80,7 @@ enum CostUsageScanner {
8080 var contributingSessionIds : Set < String > = [ ]
8181 var seenFileIds : Set < String > = [ ]
8282 var seenCodexUsageRowKeys : Set < String > = [ ]
83+ var changedLineageInputs = false
8384 }
8485
8586 struct CodexScannedSession {
@@ -2473,6 +2474,7 @@ enum CostUsageScanner {
24732474 if Self . keepCachedCodexFileIfFresh ( input: input, context: context, cache: & cache, state: & state) {
24742475 return
24752476 }
2477+ state. changedLineageInputs = true
24762478 if try Self . appendCodexFileIncrementIfPossible ( input: input, context: context, cache: & cache, state: & state) {
24772479 return
24782480 }
@@ -2682,6 +2684,7 @@ enum CostUsageScanner {
26822684 let shouldDrop = shouldDropAllUnscannedFiles ||
26832685 old. touchesCodexScanWindow ( sinceKey: range. scanSinceKey, untilKey: range. scanUntilKey)
26842686 guard shouldDrop else { continue }
2687+ scanState. changedLineageInputs = true
26852688 Self . applyFileDays ( cache: & cache, fileDays: old. days, sign: - 1 )
26862689 cache. files. removeValue ( forKey: key)
26872690 }
@@ -2692,6 +2695,7 @@ enum CostUsageScanner {
26922695 guard old. touchesCodexScanWindow ( sinceKey: range. scanSinceKey, untilKey: range. scanUntilKey)
26932696 else { continue }
26942697 guard FileManager . default. fileExists ( atPath: key) else {
2698+ scanState. changedLineageInputs = true
26952699 Self . applyFileDays ( cache: & cache, fileDays: old. days, sign: - 1 )
26962700 cache. files. removeValue ( forKey: key)
26972701 continue
@@ -2708,12 +2712,14 @@ enum CostUsageScanner {
27082712 ? [ cachedUntilKey, range. scanUntilKey] . compactMap ( \. self) . max ( ) ?? range. scanUntilKey
27092713 : range. scanUntilKey
27102714 Self . pruneDays ( cache: & cache, sinceKey: retainedSinceKey, untilKey: retainedUntilKey)
2711- try Self . recordCodexLineageShadow (
2712- files: files,
2713- roots: plan. roots,
2714- cache: cache,
2715- range: range,
2716- checkCancellation: checkCancellation)
2715+ if scanState. changedLineageInputs {
2716+ try Self . recordCodexLineageShadow (
2717+ files: files,
2718+ roots: plan. roots,
2719+ cache: cache,
2720+ range: range,
2721+ checkCancellation: checkCancellation)
2722+ }
27172723 cache. roots = plan. rootsFingerprint
27182724 cache. scanSinceKey = retainedSinceKey
27192725 cache. scanUntilKey = retainedUntilKey
0 commit comments