Skip to content

perf(graphrag): cache exact query embeddings - #326

Merged
kl3inIT merged 4 commits into
mainfrom
perf/exact-query-embedding-cache
Aug 6, 2026
Merged

perf(graphrag): cache exact query embeddings#326
kl3inIT merged 4 commits into
mainfrom
perf/exact-query-embedding-cache

Conversation

@kl3inIT

@kl3inIT kl3inIT commented Aug 6, 2026

Copy link
Copy Markdown
Owner

Summary

  • add an exact per-input query-embedding cache shared by GraphRAG and canonical/hybrid retrieval
  • isolate entries by explicit projection namespace, normalized input, provider component/version, profile, and dimensions
  • support partial hits, input deduplication, bounded provider batches, and process-local single-flight that registers ownership before persistent lookup
  • persist validated vectors through the existing PostgreSQL ModelInvocationCache
  • enforce TTL and a hard per-namespace/operation row bound with atomic bounded writes and scheduled expired-row cleanup
  • expose bounded payload-free cache telemetry

Correctness and safety

  • authorization, retrieval, evidence, and citation verification still execute on cache hits
  • provider failures, cancellation, malformed vectors, count mismatches, and dimension mismatches are not persisted
  • interrupted followers stop waiting without cancelling a shared owner call
  • cache read/write/maintenance failures fail open to the embedding provider
  • PostgreSQL bounded writes serialize by namespace/operation with a transaction-scoped advisory lock; UPSERT and prune commit or roll back together
  • adapters without transactional bounded persistence reject cache writes instead of growing unbounded
  • raw queries, cache keys, tenant/actor/document identifiers, vectors, and credentials are not logged or emitted as metric labels

Verification

  • deterministic regressions for the miss-to-registration race with persistence success and with persistence unavailable/write failure
  • deterministic regression proving provider Error completes coalesced followers instead of leaving them blocked
  • deterministic regression proving a later setup Error releases every earlier flight owned by the same multi-input call
  • exact-hit reuse, partial-hit batching, deduplication, NFC normalization, tenant/profile/component/dimension isolation
  • provider/cancellation/malformed response and cache failure paths
  • canonical/hybrid and GraphRAG runtime reuse across independent requests
  • real PostgreSQL atomic bound, retained-newest keys, expired cleanup, Flyway migration, and namespace/operation isolation
  • ./gradlew clean check

Documentation impact

  • adds a Tegami patch entry describing the user-visible retrieval latency improvement
  • no public API or operator workflow changes

Scope

This is Phase 1 exact query text-to-vector caching only. It does not add semantic answer caching or retrieval-result caching, and it is not active in production until this PR is merged and deployed.

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@kl3inIT, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 11 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 1f92eb0e-bae5-4ef6-8757-67fcb48bdadf

📥 Commits

Reviewing files that changed from the base of the PR and between 85dc26e and d9a3de5.

📒 Files selected for processing (9)
  • .tegami/2026-08-06-exact-query-embedding-cache.md
  • apps/api/src/main/java/com/orgmemory/api/knowledge/SpringAiQueryEmbeddingAdapter.java
  • components/graph-rag-core/src/main/java/com/orgmemory/graphrag/query/CachingQueryEmbeddingService.java
  • components/graph-rag-core/src/test/java/com/orgmemory/graphrag/query/CachingQueryEmbeddingServiceTests.java
  • components/graph-rag-testkit/src/main/java/com/orgmemory/graphrag/testkit/InMemoryModelInvocationCache.java
  • components/graph-rag-testkit/src/test/java/com/orgmemory/graphrag/testkit/InMemoryModelInvocationCacheTests.java
  • core/src/main/java/com/orgmemory/core/knowledge/asset/KnowledgeProjectionNamespaces.java
  • core/src/test/java/com/orgmemory/core/knowledge/asset/KnowledgeProjectionNamespacesTests.java
  • integrations/graph-rag-postgres/src/test/java/com/orgmemory/graphrag/postgres/PostgresSharedProjectionIntegrationTests.java
📝 Walkthrough

Walkthrough

The PR adds a permission-scoped query embedding cache. It supports batching, deduplication, concurrent request coalescing, bounded persistence, telemetry, scheduled cleanup, runtime wiring, and PostgreSQL cache maintenance.

Changes

Query embedding cache

Layer / File(s) Summary
Caching service and cache contracts
components/graph-rag-core/...
Adds CachingQueryEmbeddingService, cache key generation, bounded cache operations, typed vector encoding, request coalescing, validation, and cache event contracts.
Runtime wiring and maintenance
apps/api/src/main/java/com/orgmemory/api/knowledge/*, apps/api/src/main/java/com/orgmemory/api/assistant/GraphRagRuntimeConfiguration.java, apps/api/src/main/resources/application.yml, components/graph-rag-testkit/...
Adds Spring configuration, validated properties, Micrometer metrics, scheduled cleanup, cached query execution, no-op fallbacks, and wiring tests.
PostgreSQL bounded persistence
integrations/graph-rag-postgres/..., core/src/main/resources/db/migration/V29__bound_query_embedding_cache_cleanup.sql
Adds bounded writes, advisory locking, pruning, expired-row deletion, supporting indexes, and PostgreSQL tests.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant LightRagQueryEngine
  participant CachingQueryEmbeddingService
  participant ModelInvocationCache
  participant TextEmbeddingPort
  LightRagQueryEngine->>CachingQueryEmbeddingService: Request embeddings
  CachingQueryEmbeddingService->>ModelInvocationCache: Read cache entries
  CachingQueryEmbeddingService->>TextEmbeddingPort: Embed cache misses
  TextEmbeddingPort-->>CachingQueryEmbeddingService: Return vectors
  CachingQueryEmbeddingService->>ModelInvocationCache: Store bounded entries
  CachingQueryEmbeddingService-->>LightRagQueryEngine: Return ordered vectors
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 2.29% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely identifies the main change: caching exact GraphRAG query embeddings.
Description check ✅ Passed The description covers the required summary, verification evidence, documentation impact, and scope, with only minor template checkbox differences.
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch perf/exact-query-embedding-cache

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Tegami

This repository uses Tegami to manage releases. When your changes affect published packages, add a changelog file under .tegami/ before merging.

Create a changelog → · Changelog format

Release preview

Package Bump Version
orgmemory minor 0.2.00.3.0

Changelogs in this PR

Changelog Title
2026-08-06-exact-query-embedding-cache.md Improvements

Run pnpm run tegami locally to create a changelog interactively.

Managed by Tegami.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@apps/api/src/main/java/com/orgmemory/api/knowledge/QueryEmbeddingCacheConfiguration.java`:
- Around line 104-120: Override putBounded in NoOpModelInvocationCache to accept
and discard bounded cache entries without throwing
UnsupportedOperationException, while preserving the existing no-op behavior of
get, put, and invalidate so runtimes without a cache adapter do not emit
CACHE_FAILURE.

In
`@apps/api/src/main/java/com/orgmemory/api/knowledge/SpringAiQueryEmbeddingAdapter.java`:
- Around line 68-76: Update SpringAiQueryEmbeddingAdapter’s embedding flow to
obtain the canonical-query ProjectionNamespace through a new factory method on
KnowledgeProjectionNamespaces instead of constructing it with raw "default" and
"canonical-query" literals. Ensure the factory centralizes the workspace and
collection values, then pass its result to embeddings.embedAll while preserving
the existing organization and profile arguments.

In
`@components/graph-rag-core/src/main/java/com/orgmemory/graphrag/query/CachingQueryEmbeddingService.java`:
- Around line 169-201: Update loadOwnedMisses to catch both RuntimeException and
Error, completing every future in ownedMisses exceptionally before rethrowing.
Preserve the existing finally cleanup and success behavior, matching the leader
path’s Error handling so followers always receive a terminal completion.

In
`@components/graph-rag-core/src/test/java/com/orgmemory/graphrag/query/CachingQueryEmbeddingServiceTests.java`:
- Around line 168-179: Update the PruneFailingModelInvocationCache test double
used by boundedPersistenceFailureDoesNotLeaveCacheRowsBehind so its putBounded
implementation persists the supplied entries and then triggers the existing
pruning failure, rather than relying on the interface default. Preserve the
existing prune override and assertions so the test verifies failed bounding
removes all persisted rows.

In
`@components/graph-rag-testkit/src/main/java/com/orgmemory/graphrag/testkit/InMemoryModelInvocationCache.java`:
- Around line 34-55: Update InMemoryModelInvocationCache.putBounded to validate
namespace, normalized operation, boundedEntries, now, and a strictly positive
maximumEntries before mutating entries; validate every boundedEntries key also
matches the namespace and normalized operation, rejecting invalid input
consistently with the production implementation.

In
`@integrations/graph-rag-postgres/src/test/java/com/orgmemory/graphrag/postgres/PostgresSharedProjectionIntegrationTests.java`:
- Around line 161-174: Extend the assertions after putBounded in
PostgresSharedProjectionIntegrationTests to query the retained input_hash values
from graph_model_invocation_cache using the same namespace and QUERY_EMBEDDING
filters. Assert that pruning retains the hashes corresponding to suffixes 2 and
3, while preserving the existing count assertion.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 8309a0ef-2bed-4c14-8602-fac2d44f0a2a

📥 Commits

Reviewing files that changed from the base of the PR and between 1417147 and 85dc26e.

📒 Files selected for processing (21)
  • apps/api/src/main/java/com/orgmemory/api/assistant/GraphRagRuntimeConfiguration.java
  • apps/api/src/main/java/com/orgmemory/api/knowledge/MicrometerQueryEmbeddingCacheEventSink.java
  • apps/api/src/main/java/com/orgmemory/api/knowledge/QueryEmbeddingCacheConfiguration.java
  • apps/api/src/main/java/com/orgmemory/api/knowledge/QueryEmbeddingCacheJanitor.java
  • apps/api/src/main/java/com/orgmemory/api/knowledge/QueryEmbeddingCacheProperties.java
  • apps/api/src/main/java/com/orgmemory/api/knowledge/SpringAiQueryEmbeddingAdapter.java
  • apps/api/src/main/resources/application.yml
  • apps/api/src/test/java/com/orgmemory/api/knowledge/QueryEmbeddingCacheWiringTests.java
  • components/graph-rag-core/src/main/java/com/orgmemory/graphrag/cache/ModelInvocationCache.java
  • components/graph-rag-core/src/main/java/com/orgmemory/graphrag/cache/ModelInvocationCacheKeys.java
  • components/graph-rag-core/src/main/java/com/orgmemory/graphrag/query/CachingQueryEmbeddingService.java
  • components/graph-rag-core/src/main/java/com/orgmemory/graphrag/query/LightRagQueryEngine.java
  • components/graph-rag-core/src/main/java/com/orgmemory/graphrag/query/QueryEmbeddingCacheEventSink.java
  • components/graph-rag-core/src/test/java/com/orgmemory/graphrag/query/CachingQueryEmbeddingServiceTests.java
  • components/graph-rag-testkit/src/main/java/com/orgmemory/graphrag/testkit/InMemoryModelInvocationCache.java
  • components/graph-rag-testkit/src/test/java/com/orgmemory/graphrag/testkit/LightRagQueryRuntimeConformanceTests.java
  • core/src/main/resources/db/migration/V29__bound_query_embedding_cache_cleanup.sql
  • integrations/graph-rag-postgres/src/main/java/com/orgmemory/graphrag/postgres/PostgresGraphRagCacheStore.java
  • integrations/graph-rag-postgres/src/main/java/com/orgmemory/graphrag/postgres/PostgresModelInvocationCache.java
  • integrations/graph-rag-postgres/src/test/java/com/orgmemory/graphrag/postgres/PostgresGraphRagCacheStoreTests.java
  • integrations/graph-rag-postgres/src/test/java/com/orgmemory/graphrag/postgres/PostgresSharedProjectionIntegrationTests.java
📜 Review details
⏰ Context from checks skipped due to timeout. (5)
  • GitHub Check: Backend · Java 25
  • GitHub Check: PostgreSQL GraphRAG
  • GitHub Check: Neo4j adapter
  • GitHub Check: OpenSearch adapter
  • GitHub Check: Web · Node 24
🧰 Additional context used
📓 Path-based instructions (4)
**/*

📄 CodeRabbit inference engine (AGENTS.md)

**/*: Treat the repository and runtime evidence as the engineering system of record; do not treat chat or Northstar as authoritative.
Before changing a domain, read its specification, test-coverage document, and applicable decision filenames.
Material decisions about domain boundaries, authorization, persistence, publication, concurrency, cache isolation, parity scope, or deployment require an independent architecture challenge and documented alternatives before implementation.
Do not use completed increment documents as the source for current behavior; use them only for history or archaeology.
Before using unfamiliar Spring Boot, Spring Modulith, Spring AI, Gradle, React, Vite, Tailwind, TypeScript, Next.js, or Fumadocs APIs, consult current official documentation, Context7, and the relevant verification skill.
Read docs/guidelines/agent-safety.md before retrieval, AI, MCP, permission, upload, graph, or export work; never commit secrets or customer data.
Keep ddl-auto=validate and pair every persisted-model change with a Flyway migration.
Use the testing harness; a terminating clean test is the JVM context gate, and bootRun is not verification.

Files:

  • core/src/main/resources/db/migration/V29__bound_query_embedding_cache_cleanup.sql
  • apps/api/src/main/java/com/orgmemory/api/knowledge/MicrometerQueryEmbeddingCacheEventSink.java
  • apps/api/src/main/java/com/orgmemory/api/knowledge/QueryEmbeddingCacheProperties.java
  • components/graph-rag-core/src/main/java/com/orgmemory/graphrag/query/QueryEmbeddingCacheEventSink.java
  • components/graph-rag-testkit/src/main/java/com/orgmemory/graphrag/testkit/InMemoryModelInvocationCache.java
  • apps/api/src/main/resources/application.yml
  • apps/api/src/main/java/com/orgmemory/api/knowledge/QueryEmbeddingCacheJanitor.java
  • components/graph-rag-core/src/main/java/com/orgmemory/graphrag/cache/ModelInvocationCacheKeys.java
  • integrations/graph-rag-postgres/src/test/java/com/orgmemory/graphrag/postgres/PostgresSharedProjectionIntegrationTests.java
  • components/graph-rag-core/src/main/java/com/orgmemory/graphrag/cache/ModelInvocationCache.java
  • components/graph-rag-testkit/src/test/java/com/orgmemory/graphrag/testkit/LightRagQueryRuntimeConformanceTests.java
  • apps/api/src/main/java/com/orgmemory/api/knowledge/SpringAiQueryEmbeddingAdapter.java
  • apps/api/src/main/java/com/orgmemory/api/knowledge/QueryEmbeddingCacheConfiguration.java
  • apps/api/src/main/java/com/orgmemory/api/assistant/GraphRagRuntimeConfiguration.java
  • apps/api/src/test/java/com/orgmemory/api/knowledge/QueryEmbeddingCacheWiringTests.java
  • integrations/graph-rag-postgres/src/main/java/com/orgmemory/graphrag/postgres/PostgresModelInvocationCache.java
  • components/graph-rag-core/src/test/java/com/orgmemory/graphrag/query/CachingQueryEmbeddingServiceTests.java
  • integrations/graph-rag-postgres/src/main/java/com/orgmemory/graphrag/postgres/PostgresGraphRagCacheStore.java
  • components/graph-rag-core/src/main/java/com/orgmemory/graphrag/query/LightRagQueryEngine.java
  • integrations/graph-rag-postgres/src/test/java/com/orgmemory/graphrag/postgres/PostgresGraphRagCacheStoreTests.java
  • components/graph-rag-core/src/main/java/com/orgmemory/graphrag/query/CachingQueryEmbeddingService.java
core/src/main/resources/db/migration/*.sql

⚙️ CodeRabbit configuration file

core/src/main/resources/db/migration/*.sql: The repository is pre-release: V1 is the intentionally resettable clean
baseline and development data carries no migration cost. Once a release
baseline is frozen, later Flyway migrations are immutable. Check tenant
isolation, foreign keys, uniqueness, indexes, append-only evidence
semantics, safe defaults, and PostgreSQL 18 plus pgvector compatibility.

Files:

  • core/src/main/resources/db/migration/V29__bound_query_embedding_cache_cleanup.sql
**/*.java

📄 CodeRabbit inference engine (AGENTS.md)

Apply IDE inspection only to edited backend Java files.

Files:

  • apps/api/src/main/java/com/orgmemory/api/knowledge/MicrometerQueryEmbeddingCacheEventSink.java
  • apps/api/src/main/java/com/orgmemory/api/knowledge/QueryEmbeddingCacheProperties.java
  • components/graph-rag-core/src/main/java/com/orgmemory/graphrag/query/QueryEmbeddingCacheEventSink.java
  • components/graph-rag-testkit/src/main/java/com/orgmemory/graphrag/testkit/InMemoryModelInvocationCache.java
  • apps/api/src/main/java/com/orgmemory/api/knowledge/QueryEmbeddingCacheJanitor.java
  • components/graph-rag-core/src/main/java/com/orgmemory/graphrag/cache/ModelInvocationCacheKeys.java
  • integrations/graph-rag-postgres/src/test/java/com/orgmemory/graphrag/postgres/PostgresSharedProjectionIntegrationTests.java
  • components/graph-rag-core/src/main/java/com/orgmemory/graphrag/cache/ModelInvocationCache.java
  • components/graph-rag-testkit/src/test/java/com/orgmemory/graphrag/testkit/LightRagQueryRuntimeConformanceTests.java
  • apps/api/src/main/java/com/orgmemory/api/knowledge/SpringAiQueryEmbeddingAdapter.java
  • apps/api/src/main/java/com/orgmemory/api/knowledge/QueryEmbeddingCacheConfiguration.java
  • apps/api/src/main/java/com/orgmemory/api/assistant/GraphRagRuntimeConfiguration.java
  • apps/api/src/test/java/com/orgmemory/api/knowledge/QueryEmbeddingCacheWiringTests.java
  • integrations/graph-rag-postgres/src/main/java/com/orgmemory/graphrag/postgres/PostgresModelInvocationCache.java
  • components/graph-rag-core/src/test/java/com/orgmemory/graphrag/query/CachingQueryEmbeddingServiceTests.java
  • integrations/graph-rag-postgres/src/main/java/com/orgmemory/graphrag/postgres/PostgresGraphRagCacheStore.java
  • components/graph-rag-core/src/main/java/com/orgmemory/graphrag/query/LightRagQueryEngine.java
  • integrations/graph-rag-postgres/src/test/java/com/orgmemory/graphrag/postgres/PostgresGraphRagCacheStoreTests.java
  • components/graph-rag-core/src/main/java/com/orgmemory/graphrag/query/CachingQueryEmbeddingService.java
apps/api/src/main/java/**/*.java

⚙️ CodeRabbit configuration file

apps/api/src/main/java/**/*.java: Enforce the browser-BFF and resource-server boundaries. Authentication
must resolve an active internal actor through the explicit issuer and
subject binding. Reject identity, tenant, roles, or permissions supplied
by request payloads, JWT email, or untrusted JWT role claims.

Files:

  • apps/api/src/main/java/com/orgmemory/api/knowledge/MicrometerQueryEmbeddingCacheEventSink.java
  • apps/api/src/main/java/com/orgmemory/api/knowledge/QueryEmbeddingCacheProperties.java
  • apps/api/src/main/java/com/orgmemory/api/knowledge/QueryEmbeddingCacheJanitor.java
  • apps/api/src/main/java/com/orgmemory/api/knowledge/SpringAiQueryEmbeddingAdapter.java
  • apps/api/src/main/java/com/orgmemory/api/knowledge/QueryEmbeddingCacheConfiguration.java
  • apps/api/src/main/java/com/orgmemory/api/assistant/GraphRagRuntimeConfiguration.java
🧠 Learnings (4)
📚 Learning: 2026-07-23T23:30:44.585Z
Learnt from: kl3inIT
Repo: kl3inIT/OrgMemory PR: 30
File: core/src/main/resources/db/migration/V32__evidence_scoped_graph_semantics.sql:0-0
Timestamp: 2026-07-23T23:30:44.585Z
Learning: For OrgMemory PostgreSQL Flyway migrations under core/src/main/resources/db/migration, do not recommend using `CREATE INDEX CONCURRENTLY` or `DROP INDEX CONCURRENTLY` inside application-owned Flyway migration SQL. Flyway’s schema-history connection may hold a transaction that can cause concurrent index operations to wait indefinitely (e.g., on a `virtualxid`), and docs/conventions.md forbids this pattern. If you need large production-table index replacement, pre-stage online index operations via the deployment pipeline (outside Flyway) rather than inside the migration; “ordinary” index replacement is acceptable for unreleased projections before production traffic.

Applied to files:

  • core/src/main/resources/db/migration/V29__bound_query_embedding_cache_cleanup.sql
📚 Learning: 2026-07-24T22:53:12.988Z
Learnt from: kl3inIT
Repo: kl3inIT/OrgMemory PR: 40
File: apps/api/src/main/java/com/orgmemory/api/knowledge/CitationContentController.java:0-0
Timestamp: 2026-07-24T22:53:12.988Z
Learning: For OrgMemory knowledge content handling in the API, treat `KnowledgeContentType` as the single closed policy (source of truth) for: canonical storage media type, browser-safe response media type, upload eligibility rules, and inline disposition behavior. Do not duplicate or bypass these decisions in controllers/services; route media-type and disposition logic through `KnowledgeContentType`. Specifically, Markdown should be stored with the canonical media type `text/markdown`, but served as `text/plain` when returning browser-safe citation preview content.

Applied to files:

  • apps/api/src/main/java/com/orgmemory/api/knowledge/MicrometerQueryEmbeddingCacheEventSink.java
  • apps/api/src/main/java/com/orgmemory/api/knowledge/QueryEmbeddingCacheProperties.java
  • apps/api/src/main/java/com/orgmemory/api/knowledge/QueryEmbeddingCacheJanitor.java
  • apps/api/src/main/java/com/orgmemory/api/knowledge/SpringAiQueryEmbeddingAdapter.java
  • apps/api/src/main/java/com/orgmemory/api/knowledge/QueryEmbeddingCacheConfiguration.java
📚 Learning: 2026-07-26T05:46:47.443Z
Learnt from: kl3inIT
Repo: kl3inIT/OrgMemory PR: 61
File: apps/mcp/src/main/java/com/orgmemory/mcp/McpSecurityConfiguration.java:50-52
Timestamp: 2026-07-26T05:46:47.443Z
Learning: In OrgMemory, treat the `apps/mcp` and `apps/api` as independent protocol adapter modules. When adjusting OAuth/wire-level scopes, do not introduce a shared Java constant or create a code dependency from `apps/mcp` to `apps/api` solely to deduplicate scope values. Instead, keep OAuth/scope constants adapter-local (e.g., in the relevant adapter/security configuration classes) and ensure cross-adapter consistency via automated realm/OAuth/authorization tests, rather than via shared wiring-level constants or cross-module references.

Applied to files:

  • apps/api/src/main/java/com/orgmemory/api/knowledge/MicrometerQueryEmbeddingCacheEventSink.java
  • apps/api/src/main/java/com/orgmemory/api/knowledge/QueryEmbeddingCacheProperties.java
  • apps/api/src/main/java/com/orgmemory/api/knowledge/QueryEmbeddingCacheJanitor.java
  • apps/api/src/main/java/com/orgmemory/api/knowledge/SpringAiQueryEmbeddingAdapter.java
  • apps/api/src/main/java/com/orgmemory/api/knowledge/QueryEmbeddingCacheConfiguration.java
  • apps/api/src/main/java/com/orgmemory/api/assistant/GraphRagRuntimeConfiguration.java
📚 Learning: 2026-08-05T04:37:30.530Z
Learnt from: kl3inIT
Repo: kl3inIT/OrgMemory PR: 296
File: integrations/graph-rag-postgres/src/test/java/com/orgmemory/graphrag/postgres/AuthorizedMultiSnapshotQueryIntegrationTests.java:34-52
Timestamp: 2026-08-05T04:37:30.530Z
Learning: In the integrations/graph-rag-postgres module, treat org.testcontainers.postgresql.PostgreSQLContainer as a non-generic type. Do not add type arguments such as <?> to PostgreSQLContainer declarations, because the resolved dependency type does not take parameters and compilation will fail.

Applied to files:

  • integrations/graph-rag-postgres/src/test/java/com/orgmemory/graphrag/postgres/PostgresSharedProjectionIntegrationTests.java
  • integrations/graph-rag-postgres/src/main/java/com/orgmemory/graphrag/postgres/PostgresModelInvocationCache.java
  • integrations/graph-rag-postgres/src/main/java/com/orgmemory/graphrag/postgres/PostgresGraphRagCacheStore.java
  • integrations/graph-rag-postgres/src/test/java/com/orgmemory/graphrag/postgres/PostgresGraphRagCacheStoreTests.java
🪛 PMD (7.26.0)
components/graph-rag-core/src/test/java/com/orgmemory/graphrag/query/CachingQueryEmbeddingServiceTests.java

[Medium] 514-514: PreserveStackTrace (Best Practices): Thrown exception does not preserve the stack trace of exception 'interrupted' on all code paths

(PreserveStackTrace (Best Practices))

components/graph-rag-core/src/main/java/com/orgmemory/graphrag/query/CachingQueryEmbeddingService.java

[Medium] 280-280: PreserveStackTrace (Best Practices): Thrown exception does not preserve the stack trace of exception 'interrupted' on all code paths

(PreserveStackTrace (Best Practices))


[Medium] 284-284: PreserveStackTrace (Best Practices): Thrown exception does not preserve the stack trace of exception 'failure' on all code paths

(PreserveStackTrace (Best Practices))


[Medium] 286-286: PreserveStackTrace (Best Practices): Thrown exception does not preserve the stack trace of exception 'failure' on all code paths

(PreserveStackTrace (Best Practices))

🪛 SQLFluff (4.2.2)
core/src/main/resources/db/migration/V29__bound_query_embedding_cache_cleanup.sql

[error] 1-8: CREATE INDEX should use CONCURRENTLY to avoid locking the table during the build.

(PG01)


[error] 10-11: CREATE INDEX should use CONCURRENTLY to avoid locking the table during the build.

(PG01)

🪛 Squawk (2.61.0)
core/src/main/resources/db/migration/V29__bound_query_embedding_cache_cleanup.sql

[warning] 1-8: During normal index creation, table updates are blocked, but reads are still allowed. Use concurrently to avoid blocking writes.

(require-concurrent-index-creation)


[warning] 10-11: During normal index creation, table updates are blocked, but reads are still allowed. Use concurrently to avoid blocking writes.

(require-concurrent-index-creation)

🔇 Additional comments (20)
core/src/main/resources/db/migration/V29__bound_query_embedding_cache_cleanup.sql (1)

1-8: LGTM!

Also applies to: 10-11

integrations/graph-rag-postgres/src/main/java/com/orgmemory/graphrag/postgres/PostgresGraphRagCacheStore.java (1)

15-15: LGTM!

Also applies to: 153-203, 216-295

integrations/graph-rag-postgres/src/main/java/com/orgmemory/graphrag/postgres/PostgresModelInvocationCache.java (1)

6-6: LGTM!

Also applies to: 39-66

integrations/graph-rag-postgres/src/test/java/com/orgmemory/graphrag/postgres/PostgresGraphRagCacheStoreTests.java (1)

4-4: LGTM!

Also applies to: 33-55

integrations/graph-rag-postgres/src/test/java/com/orgmemory/graphrag/postgres/PostgresSharedProjectionIntegrationTests.java (1)

11-11: LGTM!

Also applies to: 38-38, 128-160, 176-215

components/graph-rag-core/src/main/java/com/orgmemory/graphrag/cache/ModelInvocationCache.java (1)

5-5: LGTM!

Also applies to: 22-75

components/graph-rag-core/src/main/java/com/orgmemory/graphrag/cache/ModelInvocationCacheKeys.java (1)

11-12: LGTM!

Also applies to: 52-75, 119-126

components/graph-rag-core/src/main/java/com/orgmemory/graphrag/query/CachingQueryEmbeddingService.java (1)

297-322: LGTM!

components/graph-rag-core/src/test/java/com/orgmemory/graphrag/query/CachingQueryEmbeddingServiceTests.java (1)

260-290: LGTM!

Also applies to: 315-345

apps/api/src/main/java/com/orgmemory/api/knowledge/QueryEmbeddingCacheProperties.java (1)

6-56: LGTM!

apps/api/src/main/java/com/orgmemory/api/knowledge/SpringAiQueryEmbeddingAdapter.java (1)

12-40: LGTM!

components/graph-rag-core/src/main/java/com/orgmemory/graphrag/query/LightRagQueryEngine.java (1)

43-43: LGTM!

Also applies to: 56-94, 311-317

apps/api/src/main/java/com/orgmemory/api/knowledge/QueryEmbeddingCacheConfiguration.java (1)

43-49: 🩺 Stability & Availability

No change needed. PostgresGraphRagAutoConfiguration registers only one ModelInvocationCache bean (postgresqlModelInvocationCache), so ObjectProvider#getIfAvailable(NoOpModelInvocationCache::new) does not create an ambiguity.

components/graph-rag-core/src/main/java/com/orgmemory/graphrag/query/QueryEmbeddingCacheEventSink.java (1)

1-34: LGTM!

apps/api/src/main/java/com/orgmemory/api/assistant/GraphRagRuntimeConfiguration.java (1)

8-8: LGTM!

Also applies to: 55-55

apps/api/src/main/java/com/orgmemory/api/knowledge/MicrometerQueryEmbeddingCacheEventSink.java (1)

1-38: LGTM!

apps/api/src/main/java/com/orgmemory/api/knowledge/QueryEmbeddingCacheJanitor.java (1)

1-57: LGTM!

apps/api/src/main/resources/application.yml (1)

122-127: LGTM!

apps/api/src/test/java/com/orgmemory/api/knowledge/QueryEmbeddingCacheWiringTests.java (1)

1-256: LGTM!

components/graph-rag-testkit/src/test/java/com/orgmemory/graphrag/testkit/LightRagQueryRuntimeConformanceTests.java (1)

23-23: LGTM!

Also applies to: 41-42, 162-193

@kl3inIT
kl3inIT merged commit efd7c67 into main Aug 6, 2026
18 checks passed
@kl3inIT
kl3inIT deleted the perf/exact-query-embedding-cache branch August 6, 2026 14:35
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.

1 participant