Skip to content

Conversation

@zharinov
Copy link
Contributor

@zharinov zharinov commented Dec 27, 2025

Summary

CI grammar cache didn't invalidate when generator code changed, causing stale parsers to be published (e.g., PR #77's ABI 15 fix didn't take effect).

Solution

Two-layer caching:

  1. xtask cache: keyed on xtask/Cargo.lock + xtask/src/**/*.rs
  2. grammar cache: keyed on xtask hash + xtask cache-key output, with restore-keys for incremental rebuilds

The xtask cache-key command reuses existing compute_cache_key() logic (tree-sitter version, grammar files, dependencies).

The CI grammar cache key was missing xtask source changes, causing
stale parsers to be published (e.g., PR bearcove#77's ABI 15 fix didn't take
effect because ABI 14 parsers were served from cache).

Solution: Two-layer caching with single source of truth.

Layer 1: Cache xtask binary
- Key: hashFiles('xtask/Cargo.lock', 'xtask/src/**/*.rs')
- Invalidates when generator code changes

Layer 2: Cache grammar generation
- Key: computed by `xtask cache-key` at runtime
- Reuses existing compute_cache_key() logic which hashes:
  - tree-sitter CLI version
  - grammar.js and grammar/ files
  - common/ directory
  - dependency grammars

When xtask source changes, Layer 1 misses → xtask rebuilds →
xtask cache-key produces fresh hash → Layer 2 also invalidates.
@zharinov zharinov changed the title Fix CI cache invalidation for generator code changes Unify CI and grammar caches Dec 27, 2025
@zharinov zharinov changed the title Unify CI and grammar caches Unify CI and grammar cache keys Dec 27, 2025
@fasterthanlime
Copy link
Collaborator

CI grammar cache didn't invalidate

Aaaah crap thanks for looking into it.

@fasterthanlime fasterthanlime merged commit 0f8780e into bearcove:main Dec 27, 2025
17 checks passed
@fasterthanlime
Copy link
Collaborator

I pushed v2.4.6 — should release itself gently over the next.. 15 minutes.

@zharinov
Copy link
Contributor Author

No problem! It was the beautiful Opus session 😁

@zharinov zharinov deleted the fix-cache-invalidation branch December 27, 2025 17:53
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.

2 participants