Skip to content

fix: improve static citation relevance and stream admission - #112

Merged
WilliamAGH merged 4 commits into
mainfrom
dev
Jul 18, 2026
Merged

fix: improve static citation relevance and stream admission#112
WilliamAGH merged 4 commits into
mainfrom
dev

Conversation

@WilliamAGH

@WilliamAGHWilliamAGH commented Jul 18, 2026

Copy link
Copy Markdown
Owner

Summary

  • recognize Java API type/member queries and rank exact API pages before citation deduplication and limiting
  • keep version filtering exact while removing version-text distortion from sparse citation discovery
  • emit the preparation SSE event before blocking retrieval/provider work and preserve cancellation through the preparation boundary
  • centralize every persisted Qdrant/document metadata field in one schema owner across production and test projections
  • normalize directly constructed API selectors and harden asynchronous test cleanup

Verification

  • 661 backend tests passed
  • 172 frontend tests passed
  • full build passed
  • frontend lint and Svelte checks passed with zero warnings or errors
  • PMD and SpotBugs passed with zero findings
  • random-port Tomcat/WebTestClient SSE boundary test passed
  • both GitHub Docker runtime smoke jobs passed
  • CodeRabbit completed; all review threads resolved
  • independent final review approved with high confidence

CopilotAI review requested due to automatic review settings July 18, 2026 14:27
@coderabbitai

coderabbitaiBot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

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

Next review available in:29 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7b1e98e8-8ed2-4865-8518-3d6c3c5c920a

📥 Commits

Reviewing files that changed from the base of the PR and between 13c7627 and d9056d6.

📒 Files selected for processing (31)
  • src/main/java/com/williamcallahan/javachat/application/search/JavaApiMethodSelector.java
  • src/main/java/com/williamcallahan/javachat/cli/GitHubRepoProcessor.java
  • src/main/java/com/williamcallahan/javachat/config/QdrantIndexInitializer.java
  • src/main/java/com/williamcallahan/javachat/service/AuditService.java
  • src/main/java/com/williamcallahan/javachat/service/ChatService.java
  • src/main/java/com/williamcallahan/javachat/service/DocsIngestionService.java
  • src/main/java/com/williamcallahan/javachat/service/DocumentFactory.java
  • src/main/java/com/williamcallahan/javachat/service/EmbeddingBatchEmbedder.java
  • src/main/java/com/williamcallahan/javachat/service/HybridVectorService.java
  • src/main/java/com/williamcallahan/javachat/service/QdrantCollectionRouter.java
  • src/main/java/com/williamcallahan/javachat/service/QdrantPayloadFieldSchema.java
  • src/main/java/com/williamcallahan/javachat/service/QdrantRetrievalConstraintBuilder.java
  • src/main/java/com/williamcallahan/javachat/service/QdrantScoredPointDocumentMapper.java
  • src/main/java/com/williamcallahan/javachat/service/RerankerService.java
  • src/main/java/com/williamcallahan/javachat/service/RetrievalService.java
  • src/main/java/com/williamcallahan/javachat/service/ingestion/IngestionProvenanceDeriver.java
  • src/main/java/com/williamcallahan/javachat/service/ingestion/LocalDocsFileIngestionProcessor.java
  • src/main/java/com/williamcallahan/javachat/service/ingestion/SourceCodeFileIngestionProcessor.java
  • src/main/java/com/williamcallahan/javachat/support/DocumentContentAdapter.java
  • src/test/java/com/williamcallahan/javachat/application/search/JavaApiMethodSelectorTest.java
  • src/test/java/com/williamcallahan/javachat/domain/SearchQualityLevelTest.java
  • src/test/java/com/williamcallahan/javachat/service/CitationCandidateRankerTest.java
  • src/test/java/com/williamcallahan/javachat/service/GuidedLearningServiceCitationTest.java
  • src/test/java/com/williamcallahan/javachat/service/HybridSearchServiceTest.java
  • src/test/java/com/williamcallahan/javachat/service/QdrantRetrievalConstraintBuilderTest.java
  • src/test/java/com/williamcallahan/javachat/service/RetrievalServiceCitationTest.java
  • src/test/java/com/williamcallahan/javachat/service/RetrievalServiceTest.java
  • src/test/java/com/williamcallahan/javachat/service/ingestion/IngestionProvenanceDeriverTest.java
  • src/test/java/com/williamcallahan/javachat/service/ingestion/SourceCodeFileIngestionProcessorTest.java
  • src/test/java/com/williamcallahan/javachat/web/ChatControllerStreamingFailureTest.java
  • src/test/java/com/williamcallahan/javachat/web/GuidedSseCitationEventTest.java
📝 Walkthrough

Walkthrough

The PR adds Java API method-selector parsing, sparse citation query expansion, deterministic Javadoc candidate ranking, canonical document metadata constants, and bounded-elastic scheduling for chat streaming. Tests cover selector parsing, retrieval behavior, citation ordering, SSE preparation, cancellation, and completion.

Changes

Java API citation selection

Layer / File(s)Summary
Selector parsing and Javadoc matching
src/main/java/.../JavaApiMethodSelector.java, src/test/.../JavaApiMethodSelectorTest.java
Parses qualified Type.method expressions, expands sparse queries, validates selectors, and matches Javadoc paths.
Citation metadata, retrieval, and ranking
src/main/java/.../DocsSourceRegistry.java, src/main/java/.../service/*, src/main/java/.../ingestion/*, src/test/.../service/*
Centralizes metadata identifiers, expands sparse citation searches, ranks Java API candidates, and updates retrieval and provenance tests to use registry values.
Asynchronous chat streaming
src/main/java/.../web/ChatController.java, src/test/.../web/*
Runs deferred SSE preparation and streaming on bounded elastic workers and tests status delivery, cancellation, interruption, and cleanup.

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

Sequence Diagram(s)

sequenceDiagram
participant Client
participant HybridSearchService
participant Qdrant
participant RetrievalService
participant CitationCandidateRanker
Client->>HybridSearchService: submit citation query
HybridSearchService->>HybridSearchService: expand selector terms
HybridSearchService->>Qdrant: perform sparse retrieval
Qdrant-->>RetrievalService: return candidates
RetrievalService->>CitationCandidateRanker: rank candidates
CitationCandidateRanker-->>RetrievalService: return ordered candidates
RetrievalService-->>Client: return citations
Loading

Possibly related PRs

Suggested labels:bug, enhancement, java, refactor

Suggested reviewers:copilot

Poem

Selectors bloom where queries roam,
Javadocs guide the citations home.
Sparse terms dance, candidates align,
SSE streams on bounded time.
Latches cheer as tests take flight—
Java docs sparkle bright! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check nameStatusExplanationResolution
Docstring Coverage⚠️ WarningDocstring coverage is 11.76% 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 nameStatusExplanation
Title check✅ PassedThe title is concise and clearly points to the two main changes: citation relevance and stream admission.
Description check✅ PassedThe description is directly related to the code changes and matches the PR objectives.
Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dev

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.

@coderabbitaicoderabbitaiBot added bug Something isn't working enhancement New feature or request java Pull requests that update java code refactor Code refactoring labels Jul 18, 2026

CopilotAI 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.

Pull request overview

This PR improves chat streaming admission and static citation relevance by ensuring an early “preparing” SSE event is emitted before potentially blocking work, and by making Java API citation discovery more deterministic and schema-consistent across ingestion/retrieval.

Changes:

  • Emit the preparation SSE status event before blocking retrieval/provider work and validate cancellation behavior across that boundary.
  • Improve static citation discovery for Java API type/member queries by expanding sparse queries and deterministically reordering candidates before deduplication/limiting.
  • Centralize ownership of Java API docType and Qdrant payload metadata field keys to eliminate scattered string literals.

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 2 comments.

Show a summary per file
FileDescription
src/main/java/com/williamcallahan/javachat/web/ChatController.javaMoves blocking preparation work behind a deferred boundary and schedules it on bounded elastic while keeping preparation SSE first.
src/test/java/com/williamcallahan/javachat/web/ChatPreparationSseIntegrationTest.javaAdds an integration test ensuring the server flushes the preparation SSE event before blocked retrieval completes.
src/test/java/com/williamcallahan/javachat/web/ChatControllerStreamingFailureTest.javaAdds unit tests verifying subscription returns after preparation, and that disposal interrupts blocked preparation without downstream work.
src/main/java/com/williamcallahan/javachat/service/RetrievalService.javaOrders citation candidates deterministically for Java API selectors and removes version-boost query distortion from citation discovery dispatch.
src/main/java/com/williamcallahan/javachat/service/HybridSearchService.javaExpands sparse citation query terms for Java API selectors before sparse encoding.
src/main/java/com/williamcallahan/javachat/application/search/JavaApiMethodSelector.javaIntroduces selector parsing and sparse-query expansion for explicit Type.method queries.
src/test/java/com/williamcallahan/javachat/application/search/JavaApiMethodSelectorTest.javaAdds coverage for selector parsing and path matching behavior.
src/main/java/com/williamcallahan/javachat/service/CitationCandidateRanker.javaAdds deterministic, local candidate ordering for citation conversion using selector evidence.
src/test/java/com/williamcallahan/javachat/service/CitationCandidateRankerTest.javaAdds tests validating ranker ordering rules and failure propagation for malformed URLs.
src/main/java/com/williamcallahan/javachat/config/DocsSourceRegistry.javaDefines canonical Java API document type token for consistent provenance and retrieval behavior.
src/main/java/com/williamcallahan/javachat/service/QdrantPayloadFieldSchema.javaCentralizes canonical metadata field keys used across Qdrant write/read paths.
src/main/java/com/williamcallahan/javachat/service/ingestion/IngestionProvenanceDeriver.javaProjects Java API doc type via canonical constant during provenance derivation.
src/test/java/com/williamcallahan/javachat/service/ingestion/IngestionProvenanceDeriverTest.javaAdds a test asserting Java API mirrors project the canonical doc type.
src/test/java/com/williamcallahan/javachat/service/RetrievalServiceTest.javaUpdates tests to use canonical official doc-set identities and adds citation ordering coverage.
src/test/java/com/williamcallahan/javachat/service/RetrievalServiceCitationTest.javaUpdates tests to use canonical Java API doc type and URL helpers.
src/test/java/com/williamcallahan/javachat/service/QdrantRetrievalConstraintBuilderTest.javaUpdates constrained filter test to use canonical doc type and official doc identities.
src/test/java/com/williamcallahan/javachat/service/HybridSearchServiceTest.javaUpdates hybrid/citation search tests for exact version filtering and selector expansion behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 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
`@src/main/java/com/williamcallahan/javachat/application/search/JavaApiMethodSelector.java`:
- Around line 203-209: Update requireNonBlank to trim the validated text before
returning it, while continuing to reject null and blank values using the
existing fieldName-specific exceptions. Ensure direct construction of selector
components stores normalized text so surrounding whitespace cannot produce
invalid paths or sparse terms.
In
`@src/test/java/com/williamcallahan/javachat/service/ingestion/IngestionProvenanceDeriverTest.java`:
- Around line 53-70: Replace positional same-typed test constructions with named
factories or builders: update IngestionProvenanceDeriverTest.java lines 53-70 to
use named provenance construction, QdrantRetrievalConstraintBuilderTest.java
lines 31-39 to use a named constrained-retrieval factory or builder, and
CitationCandidateRankerTest.java lines 122-142 to replace the five-string helper
with role-specific candidate factories. Preserve each test’s existing values and
behavior while eliminating ambiguous argument trains.
🪄 Autofix (Beta)

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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 99fe71e5-0e7c-4585-8b8c-8defad1a95f3

📥 Commits

Reviewing files that changed from the base of the PR and between fd574f2 and 13c7627.

📒 Files selected for processing (17)
  • src/main/java/com/williamcallahan/javachat/application/search/JavaApiMethodSelector.java
  • src/main/java/com/williamcallahan/javachat/config/DocsSourceRegistry.java
  • src/main/java/com/williamcallahan/javachat/service/CitationCandidateRanker.java
  • src/main/java/com/williamcallahan/javachat/service/HybridSearchService.java
  • src/main/java/com/williamcallahan/javachat/service/QdrantPayloadFieldSchema.java
  • src/main/java/com/williamcallahan/javachat/service/RetrievalService.java
  • src/main/java/com/williamcallahan/javachat/service/ingestion/IngestionProvenanceDeriver.java
  • src/main/java/com/williamcallahan/javachat/web/ChatController.java
  • src/test/java/com/williamcallahan/javachat/application/search/JavaApiMethodSelectorTest.java
  • src/test/java/com/williamcallahan/javachat/service/CitationCandidateRankerTest.java
  • src/test/java/com/williamcallahan/javachat/service/HybridSearchServiceTest.java
  • src/test/java/com/williamcallahan/javachat/service/QdrantRetrievalConstraintBuilderTest.java
  • src/test/java/com/williamcallahan/javachat/service/RetrievalServiceCitationTest.java
  • src/test/java/com/williamcallahan/javachat/service/RetrievalServiceTest.java
  • src/test/java/com/williamcallahan/javachat/service/ingestion/IngestionProvenanceDeriverTest.java
  • src/test/java/com/williamcallahan/javachat/web/ChatControllerStreamingFailureTest.java
  • src/test/java/com/williamcallahan/javachat/web/ChatPreparationSseIntegrationTest.java

@chatgpt-codex-connectorchatgpt-codex-connectorBot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit:13c7627331

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@WilliamAGH
WilliamAGH merged commit 9d727d8 into mainJul 18, 2026
7 checks passed
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugSomething isn't workingenhancementNew feature or requestjavaPull requests that update java coderefactorCode refactoring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@WilliamAGH