fix(context): compute require_citations gate after the max_chars budget#175
fix(context): compute require_citations gate after the max_chars budget#175seekmistar01 wants to merge 1 commit into
Conversation
`build_context_pack` computed the `uncited` claim list (and therefore the `require_citations` gate failure and the `uncited_items` reported in `quality`) over the full item list, then the `max_chars` budget popped tail items. So a ContextPack could be returned `ok=False` with `uncited_items=[...]` naming claims that are not present in `pack["items"]` at all — the consumer is told the pack failed citation requirements because of items it never received. Move the citation-gate computation to after the budget step so it only considers the items actually returned. Add a regression test asserting `uncited_items` is a subset of the returned items when `max_chars` and `require_citations` are combined. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Warning Review limit reached
More reviews will be available in 55 minutes and 4 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
ReviewSummary: The PR correctly moves the What works
Suggestions
VerdictApprove — Minimal, correct fix for the exact issue described; regression test is in place; no out-of-scope changes. |
|
@codex review |
|
Codex Review: Didn't find any major issues. 🚀 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Summary
Closes #174
build_context_packcomputed theuncitedclaim list (and thus therequire_citationsgate failure and theuncited_itemsreported inquality) over the full item list, then themax_charsbudget popped tail items. So a ContextPack could come backok=Falsewithuncited_items=[...]naming claims that aren't present inpack["items"]— failing the pack for citation reasons driven by items the consumer never received.Change
src/vouch/context.py— move therequire_citations/uncitedcomputation to after themax_charsbudget step, so it only considers the items actually returned.tests/test_context.py—test_require_citations_only_considers_returned_items: withmax_chars+require_citations, asserts every id inquality.uncited_itemsis in the returned items.Why it's safe
max_charsbudget (nothing is popped, so pre- vs post-budget computation is identical).Verification
pytest tests/test_context.py— 6 passed (existing + the new regression test).ruff checkclean.