fix(context): score every snapshot entry before applying the candidate cap - #31
Merged
Merged
Conversation
…e cap run_context took ceil(max_candidates/scopes) entries per scope in snapshot order before scoring, so most entries in a large scope were never considered (200 entries, default flags: only 128 scored, a late-sorting match was never returned) and a failed scope's share of the budget was lost. Every entry is now scored; --max-candidates caps the merged, ranked list. Output adds scored_count; candidate_count now counts the ranked candidates kept after the cap. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
2 tasks done
This was referenced Oct 4, 2026
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
pk contextused to cut each scope toceil(max_candidates / scopes)entries in snapshot order before scoring them. A large KB was therefore mostly invisible to recall:Change (
pk-cli/src/main.rs::run_context):--max-candidatescaps the merged, ranked list after de-duplication.scored_count.candidate_countnow means "ranked candidates kept after the cap".The existing test
candidate_budget_is_shared_across_requested_scopesasserted the old count of inspected entries. It now assertsscored_count = 5andcandidate_count = 1.This is part of the team-aware learning work, plan PR A1 (skill-pack
docs/plans/team-aware-learning-memory-implementation.md).Test plan
cargo test -p pk-cli --test context_scoringpasses. It covers a 200-entry scope with the last-by-id match recalled, a failed scope that does not reserve budget, and byte-identical output across runs with the stated ordering.cargo test -p pk-cli --test contextpasses.results=[]withcandidate_count=128.🤖 Generated with Claude Code