Skip to content

fix: invalidate Cursor cache after missing-createdAt fix - #337

Closed
lincolnwan wants to merge 1 commit into
getagentseal:mainfrom
lincolnwan:fix/invalidate-cursor-cache-after-missing-createdAt-fix
Closed

lincolnwan wants to merge 1 commit into
getagentseal:mainfrom
lincolnwan:fix/invalidate-cursor-cache-after-missing-createdAt-fix

Conversation

@lincolnwan

Copy link
Copy Markdown

Summary

  • Bump Cursor result cache version from 3 to 4 so stale v3 caches are invalidated.
  • Respect CODEBURN_CACHE_DIR for Cursor result cache, matching docs and enabling isolated cache tests.
  • Add a regression test for old v3 Cursor caches created before the missing-createdAt fix.

Why

This follows up on fe2e622 ("Skip Cursor bubble rows that lack a createdAt timestamp") from PR #321; it invalidates caches generated before that parser fix.

That parser fix made fresh parsing skip Cursor bubble rows without createdAt, but existing ~/.cache/codeburn/cursor-results.json files could still contain v3 cached calls timestamped with parse time.

If the Cursor DB mtime/size did not change, CodeBurn would continue trusting that stale cache and still report phantom current-day usage.

Testing

  • npm test -- tests/cursor-cache.test.ts tests/providers/cursor.test.ts tests/providers/cursor-bubble-dedup.test.ts tests/providers/cursor-workspace-breakdown.test.ts
  • npx tsc --noEmit

Notes

This does not change Cursor parsing logic. It only invalidates previously poisoned Cursor result caches and adds coverage for that behavior.

@ozymandiashh

ozymandiashh commented May 17, 2026 •

Copy link
Copy Markdown
Collaborator

Rechecked #337 with a differential cache-invalidation repro, not just test/build output.

Behavior proof:

  • Created an isolated temporary HOME, so no real local cache was touched.
  • Created a dummy state.vscdb.
  • Created a synthetic stale ~/.cache/codeburn/cursor-results.json with:
    • version: 3
    • matching dbMtimeMs and dbSizeBytes
    • one cached Cursor call timestamped 2099-01-01T00:00:00.000Z

Baseline on current pre-fix behavior:

{
  "cacheAccepted": true,
  "callCount": 1,
  "firstTimestamp": "2099-01-01T00:00:00.000Z",
  "firstDeduplicationKey": "cursor:stale-v3-proof"
}

Result on #337:

{
  "cacheAccepted": false,
  "callCount": 0,
  "firstTimestamp": null,
  "firstDeduplicationKey": null
}

Additional validation:

  • npx vitest run tests/cursor-cache.test.ts tests/providers/cursor.test.ts tests/providers/cursor-bubble-dedup.test.ts tests/providers/cursor-workspace-breakdown.test.ts - 22/22 tests passed.
  • npx tsc --noEmit --pretty false - passed.
  • npm run build - passed.
  • git diff --check origin/main...HEAD - passed.
  • Claude Opus 4.7 effort max review - PASS.
  • Gemini 3.1 Pro Preview review - PASS.

Review note:

  • This PR correctly fixes the stale v3 cache problem after the missing-createdAt Cursor bubble-row parser fix.
  • It is intentionally cache-only and does not change Cursor parsing logic.
  • The separate Cursor agentKv / database-mtime timestamp attribution issue remains covered by Fix Cursor agentKv timestamp attribution #345.

No local project names, prompts, paths, session IDs, screenshots, usage values, costs, or private product details are included here.

@iamtoruk

Copy link
Copy Markdown
Member

Thanks! Superseded: the Cursor cache has since moved to v6 with its own migration/invalidation path (src/cursor-cache.ts), so this v3-era invalidation no longer applies and the PR conflicts with current main. Closing; if you hit a stale-cache case on the latest version, an issue with a repro would be great.

@iamtoruk iamtoruk closed this Jul 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants