feat: make ADR topK limit configurable via analysis.max_relevant_adrs - #193
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Newly added documentation/comments inaccurately describe Engine.Run as passing topK to SearchRejected even though it uses SearchWithDebugInfo in debug mode.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
This PR makes the per-file “relevant ADRs” top‑K limit configurable via analysis.max_relevant_adrs, replacing the previously hardcoded topKADRs = 3 in Engine.Run and documenting the decision for future maintenance.
Changes:
- Add
config.Analysis.MaxRelevantADRs(yaml:"max_relevant_adrs") and apply it inEngine.Runwith a<= 0fallback to the existing default of 3. - Update the analysis pipeline to pass the configured
topKtoVectorStore.Search(non-debug) andVectorStore.SearchWithDebugInfo(debug). - Add an ADR documenting the change and add regression tests covering both “raised limit” and “defaulting to 3”.
File summaries
| File | Description |
|---|---|
| internal/config/config.go | Adds MaxRelevantADRs to config schema (new YAML key). |
| internal/analysis/engine.go | Reads configured topK once per run and uses it for search calls. |
| internal/analysis/analysis_test.go | Adds tests proving topK can be raised and that <= 0 defaults to 3. |
| docs/arch/0020-configurable-topk-adr-limit.md | New ADR documenting rationale/behavior of configurable topK. |
| CLAUDE.md | Updates repository guidance to describe configurable topK rather than fixed “top‑3”. |
Review details
- Files reviewed: 5/5 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Tgenz1213
force-pushed
the
worktree-issue-189-topk-config
branch
from
September 17, 2026 03:34
46a340e to
f8e67ea
Compare
Replaces the hardcoded topKADRs=3 constant in Engine.Run with a config field following the same <= 0 fallback pattern as max_concurrency, so a corpus with legitimately more than 3 relevant ADRs per file can raise the limit without a custom build. Closes #189 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Tgenz1213
force-pushed
the
worktree-issue-189-topk-config
branch
from
September 17, 2026 03:35
f8e67ea to
d65cd2f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
const topKADRs = 3inEngine.Runwith a newanalysis.max_relevant_adrsconfig field (config.Analysis.MaxRelevantADRs, plainint), following the same<= 0-falls-back-to-default pattern already used byanalysis.max_concurrency— a topK of 0 or negative has no legitimate meaning, so the*intnil-default pattern used elsewhere inVectorStoreisn't needed here.Engine.Runnow reads this value once per run and passes it to bothStore.Search(non-debug path) andStore.SearchWithDebugInfo(--debugpath). No interface changes were needed ininternal/indexsince both already tooktopKas a parameter.docs/arch/0020-configurable-topk-adr-limit.mddocumenting the decision, including confirming (not changing) thatPgStore.Search'sMaxSearchCandidates(1000) internal cap still comfortably exceeds any reasonable configured topK.CLAUDE.md'sinternal/analysissection to describe the config field instead of citing "top-3" as a fixed fact.Deviations from the issue
None — implemented exactly per the acceptance criteria in #189.
Test plan
internal/analysis/analysis_test.go:TestRun_MaxRelevantADRs_RaisesLimitAboveDefault— a 4-ADR fixture (all passing scope + threshold via identical embeddings) confirms all 4 reach the LLM-judgment step whenmax_relevant_adrs: 4.TestRun_MaxRelevantADRs_DefaultsToThreeWhenUnsetOrNonPositive— confirms both0and-1fall back to the default of 3 (regression test pinning old behavior).go build ./...,go test ./...(full suite, includinginternal/index's Docker-backed pgvector integration tests) — all pass.golangci-lint run --timeout=5m— clean. Run via Docker (golangci/golangci-lint:v2.12.2) since the local Go toolchain (1.27.0) is newer than the installed golangci-lint's build (1.26.5), causing a panic locally — unrelated to this change, a pre-existing environment mismatch.main— no correctness issues found; confirmed the test fixtures genuinely make 4 ADRs qualify as candidates rather than trivially passing.Closes #189
🤖 Generated with Claude Code