Skip to content

feat(cache): entity graph cache with GraphQL support#10

Merged
amondnet merged 10 commits into
mainfrom
amondnet/colossal-replace
Mar 29, 2026
Merged

feat(cache): entity graph cache with GraphQL support#10
amondnet merged 10 commits into
mainfrom
amondnet/colossal-replace

Conversation

@amondnet

@amondnet amondnet commented Mar 29, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Replace redb with libsql for entity-aware cache storage
  • Add EntityAwareCache facade with entity dependency tracking (node_id)
  • Enable GraphQL query caching with request classification
  • Cross-protocol cache invalidation (REST ↔ GraphQL via entity graph)

Track: entity-graph-cache-20260329
Resolves #9

Test plan

  • 62 unit tests passing (storage, entity_cache, entity, classify, key, proxy, ttl)
  • clippy clean, fmt check passing
  • Integration tests with emulate.dev
  • Manual verification: REST mutation invalidates GraphQL cache

Verification Checklist

Automated Tests

  • EntityAwareCache CRUD: get, store, remove, count (14 tests)
  • Entity registration + invalidation (entity deps tracking)
  • Cross-protocol invalidation via entity graph
  • GraphQL query caching + mutation detection
  • Request classifier (REST/GraphQL routing, 10 tests)
  • Entity extractor (REST + GraphQL node_id, 9 tests)
  • Prefix fallback for responses without node_id
  • graphql_cache_key deterministic + collision-resistant (4 tests)
  • 62 total unit tests passing

Observable Outcomes

  • After PATCH /repos/org/repo/issues/123, subsequent GET returns x-local-hub-cache: miss
  • After POST /graphql with query, repeat returns x-local-hub-cache: hit
  • After GraphQL mutation, related entity caches invalidated
  • local-hub status shows entry count from libsql database

Acceptance Criteria

  • AC-1: REST mutation invalidates REST + GraphQL caches via node_id
  • AC-2: GraphQL queries cached with x-local-hub-cache: hit
  • AC-3: GraphQL mutations pass through + invalidate entity caches
  • AC-4: Entity extraction finds node_id in REST/GraphQL responses
  • AC-5: Existing REST caching preserved (TTL, ETag, token isolation)
  • AC-6: libsql replaces redb

Entity graph-based cache invalidation with GraphQL caching support.
Unified rewrite approach with EntityAwareCache facade, migrating
from redb to libsql. Resolves #9.
Replace redb with libsql and introduce EntityAwareCache facade for
entity-based cache invalidation. Add GraphQL query caching with
request classification (REST GET/mutation, GraphQL query/mutation).

- storage.rs: libsql connection + schema DDL
- entity_cache.rs: EntityAwareCache with entity dependency tracking
- entity.rs: extract node_id from REST/GraphQL responses
- classify.rs: request classification for REST/GraphQL routing
- key.rs: add graphql_cache_key generation
- proxy.rs: unified handler with entity-aware flow
- error.rs: simplified to single libsql error variant

Resolves #9
Update product.md, tech-stack.md, CLAUDE.md to reflect:
- redb → libsql migration
- GraphQL caching now supported
- Entity graph invalidation added to caching strategy
…ol invalidation

forward_to_github now returns GithubResponse instead of axum::Response,
enabling entity extraction from mutation response bodies. handle_mutation
calls invalidate_by_entities() for cross-protocol cache invalidation
(REST ↔ GraphQL via node_id), with prefix invalidation as fallback.

Fixes FR-3, FR-5, FR-6 from entity-graph-cache spec.
- Remove expect() panic in count(), return 0 on empty result
- Return 400 on body read failure instead of silent empty bytes
- Treat subscription operations as non-cacheable (like mutations)
@amondnet
amondnet marked this pull request as ready for review March 29, 2026 09:15
@amondnet amondnet mentioned this pull request Mar 29, 2026
17 tasks
- Update taiki-e/install-action from broken SHA to v2.70.1
- Fix ESLint formatting in ARCHITECTURE.md, .mise.toml, dependabot.yml
- Fix missing newline in .superset/config.json
@codecov

codecov Bot commented Mar 29, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 76.94013% with 208 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
crates/server/src/proxy.rs 29.46% 158 Missing ⚠️
crates/server/src/entity_cache.rs 93.42% 24 Missing ⚠️
crates/server/src/entity.rs 89.47% 14 Missing ⚠️
crates/server/src/main.rs 0.00% 7 Missing ⚠️
crates/server/src/classify.rs 95.50% 4 Missing ⚠️
crates/server/src/storage.rs 97.61% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

- Upload both as separate flags to Codecov
- Update codecov.yml components for new module structure
- Integration tests cover proxy.rs handlers, improving patch coverage
@sonarqubecloud

Copy link
Copy Markdown

@amondnet
amondnet merged commit 8e3a3d1 into main Mar 29, 2026
7 of 8 checks passed
@amondnet
amondnet deleted the amondnet/colossal-replace branch March 29, 2026 09:33
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.

track: entity-graph-cache-20260329

1 participant