Repository navigation
Index-backed adaptive context signals and token budgets - #643
Conversation
Route context and next through the SDK signal store with cursor provenance, stable caller-independent snapshots, dynamic overlays, explicit token budgets, and MCP/CLI contract parity. Expose the effective transactional metadata-index cursor, harden fallback and namespace validation, document the shared pipeline, close pm-3hps with exact coverage and packed-consumer evidence, and record new GitHub issue lineage.
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
📝 WalkthroughWalkthroughAdds a workspace-backed context relevance signal store, derived-index provenance, token-budget controls, and ranking explanation fields to ChangesContext relevance pipeline
PM records
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant CLI
participant ContextSignalStore
participant RankingPipeline
participant Output
CLI->>ContextSignalStore: read workspace context signals
ContextSignalStore-->>CLI: candidates, cursor, source, warnings
CLI->>RankingPipeline: score candidates with token budget
RankingPipeline-->>CLI: ranked and packed entries
CLI->>Output: render filters and ranking.feature_store
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
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 |
|
@greptileai please review the complete current head, including SDK boundary safety, derived-cache correctness, context/next parity, and test quality. |
|
/gemini review |
|
@coderabbitai full review |
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
✅ Action performedFull review finished. Your plan includes PR reviews subject to rate limits. More reviews will be available in 3 minutes. |
Merging this PR will degrade performance by 0%
|
| Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|
| ❌ | createQueryFingerprint |
514.4 µs | 514.7 µs | -0.07% |
| ❌ | decodeQueryCursor |
116 µs | 116.1 µs | -0.05% |
| ❌ | tokenizeAlphaNumeric |
367.3 µs | 367.3 µs | -0.02% |
| ❌ | score query over 2000 docs |
5.6 ms | 5.6 ms | 0% |
| ⚡ | encodeQueryCursor |
101.2 µs | 101.1 µs | +0.06% |
| ⚡ | stableStringify (nested contract) |
161.3 µs | 161.2 µs | +0.06% |
| ⚡ | build index (200 docs x 40 words) |
8.4 ms | 8.4 ms | +0.01% |
| ⚡ | jaccardSimilarity |
153.3 µs | 153.3 µs | +0.01% |
| ⚡ | build index (2000 docs x 80 words) |
161.4 ms | 161.4 ms | 0% |
| ⚡ | tokenize + score query over 2000 docs |
7.5 ms | 7.5 ms | 0% |
Tip
Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing feat/index-backed-adaptive-context (471fcea) with main (e96bb03)
|
@gemini-code-assist The two sunset notices contain no code findings and confirm that this reviewer is no longer available. Both notices were read and rated; the exact-head local and CI review loop remains enforced through the active reviewers and required gates. |
|
@coderabbitai The initial rate-limit notice and completion response were both read and rated. No CodeRabbit code findings were emitted for 5693fda. A fresh full review will be requested after the review-fix push, once the stated availability window has elapsed. |
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
|
@codspeedbot The report was read and rated. Its four flagged benchmarks are untouched by this PR, were compared across different runtime environments, and range from 0 percent to -0.03 percent, while six untouched benchmarks improved by up to 0.1 percent. The repository context-scale acceptance benchmark passed independently; these simulation deltas are environment noise, not an actionable regression. |
|
@sourcery-ai The rate-limit-only review was read and rated. It contains no code finding to address; exact-head static, type, duplication, security, and coverage gates remain authoritative for this round. |
|
Your plan includes PR reviews subject to rate limits. Reviews are available now. |
Remove stale context signal imports identified by DeepScan and CI. Split the broad command integration scenario around a shared fixture so strict complexity enforcement stays enabled, and record the complete review-fix evidence in pm-3hps.
|
@greptileai please review the complete current head 24d95e7, including the review-gate fixes, SDK boundary safety, derived-cache correctness, context and next parity, and test quality. |
|
/gemini review |
|
@coderabbitai full review |
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
✅ Action performedFull review finished. Your plan includes PR reviews subject to rate limits. More reviews will be available in 59 minutes. |
Your reading of the report is correct — there is no actionable regression here. Confirmed from the run data (head
None of the flagged benchmarks ( For the record: cross-CPU comparisons are the one case where sub-0.1% Simulation deltas should be treated skeptically. If you want to remove this class of noise on future runs, pinning the CodSpeed runner to a consistent CPU class is the reliable fix. Summary
Was this response helpful? React with 👍 or 👎 to help us improve CodSpeedBot. |
Merge the daily release head through the field-aware tracker merge path, retain the adaptive-context changelog entry as unreleased work, and record exact-head review evidence before the final CI round.
|
@greptileai please review the complete current head 63f4b2f after the 2026.7.22 release merge, including tracker merge integrity, SDK boundary safety, derived-cache correctness, context and next parity, and test quality. |
|
/gemini review |
|
@coderabbitai full review |
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
✅ Action performedFull review finished. Your plan includes PR reviews subject to rate limits. More reviews will be available in 47 minutes. |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
src/cli/commands/context.ts (1)
1973-1994: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winRecompute the fallback token budget after scaling
limit.resolveContextLimitAtScaleonly clamps full-depth runs on large corpora down toDEFAULT_CONTEXT_LIMIT, buttokenBudgetis still derived from the pre-scaledlimit. When that scale adjustment kicks in, the packer gets an oversized budget and can skip the intended degradation step.🤖 Prompt for 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. In `@src/cli/commands/context.ts` around lines 1973 - 1994, Update the context settings construction around resolveContextLimitAtScale and tokenBudget so the fallback budget is calculated from the final scaled limit, not the original limit. Ensure the scaled limit is assigned or otherwise applied before calling resolveContextTokenBudget, while preserving the existing minimum budget of 256 and all other returned fields.tests/fixtures/contracts/full.json (1)
1063-1113: 🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick winAdd the missing
claimflags forexplainRankingandtokenBudget.
pm claimexposes both fields in the tool-parameter schema, but the CLI registration doesn’t accept or forward them, so CLI and SDK/MCP callers diverge.🤖 Prompt for 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. In `@tests/fixtures/contracts/full.json` around lines 1063 - 1113, Update the claim command fixture to register the missing explainRanking and tokenBudget flags alongside the existing claim flags, ensuring both are accepted and forwarded consistently with the tool-parameter schema.
🤖 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/cli/commands/context.ts`:
- Around line 608-622: Update resolveContextTokenBudget so string inputs are
validated against the same positive-integer rule as numeric inputs before
parseIntegerLimit can emit its non-negative error. Ensure invalid negative and
fractional values consistently throw the existing “--token-budget must be a
positive integer” PmCliError, while preserving fallback behavior for undefined
input and returning valid integer budgets.
---
Outside diff comments:
In `@src/cli/commands/context.ts`:
- Around line 1973-1994: Update the context settings construction around
resolveContextLimitAtScale and tokenBudget so the fallback budget is calculated
from the final scaled limit, not the original limit. Ensure the scaled limit is
assigned or otherwise applied before calling resolveContextTokenBudget, while
preserving the existing minimum budget of 256 and all other returned fields.
In `@tests/fixtures/contracts/full.json`:
- Around line 1063-1113: Update the claim command fixture to register the
missing explainRanking and tokenBudget flags alongside the existing claim flags,
ensuring both are accepted and forwarded consistently with the tool-parameter
schema.
🪄 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: Repository UI (base), Organization UI (inherited)
Review profile: ASSERTIVE
Plan: Pro
Run ID: afcccfff-7193-4152-bae7-18a8491789bc
📒 Files selected for processing (34)
.agents/pm/extensions/.managed-extensions.json.agents/pm/features/pm-4k6b.toon.agents/pm/features/pm-801d.toon.agents/pm/history/pm-3hps.jsonl.agents/pm/history/pm-4k6b.jsonl.agents/pm/history/pm-801d.jsonl.agents/pm/history/pm-lcnk2n.jsonl.agents/pm/history/pm-tz2ikr.jsonl.agents/pm/history/pm-ypuc39.jsonl.agents/pm/issues/pm-lcnk2n.toon.agents/pm/issues/pm-tz2ikr.toon.agents/pm/issues/pm-ypuc39.toon.agents/pm/tasks/pm-3hps.toonCHANGELOG.mddocs/CONTEXT_RELEVANCE.mddocs/PERFORMANCE.mddocs/README.mdsrc/cli/commands/context.tssrc/cli/commands/next.tssrc/cli/register-list-query.tssrc/cli/registration-helpers.tssrc/core/store/item-metadata-cache.tssrc/sdk/cli-contracts/commander-types.tssrc/sdk/cli-contracts/flag-contracts.tssrc/sdk/cli-contracts/tool-option-contracts.tssrc/sdk/cli-contracts/tool-parameter-tables.tssrc/sdk/cli-contracts/tool-schema.tssrc/sdk/context-signal-store.tssrc/sdk/item-metadata-index.tstests/fixtures/contracts/full.jsontests/unit/commands/context-relevance-command.spec.tstests/unit/commands/register-commands.spec.tstests/unit/core/item/item-metadata-derived-index.spec.tstests/unit/sdk/context-signal-store.spec.ts
Upgrade the managed pm-changelog extension to 2026.7.22, regenerate after fetching v2026.7.22, and preserve the new adaptive-context work under Unreleased. Record the duplicate-safe package lifecycle refresh finding in pm-tnud and exact CI root-cause evidence in pm-3hps.
|
@greptileai please review the complete current head 1bce65d, including latest pm-changelog alignment, tracker integrity, SDK boundary safety, derived-cache correctness, context and next parity, and test quality. |
|
/gemini review |
|
@coderabbitai full review |
✅ Action performedFull review finished. Your plan includes PR reviews subject to rate limits. More reviews will be available in 40 minutes. |
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
Normalize token-budget validation, bind default packing budgets to the scale-adjusted context limit, and expose claim-next ranking controls consistently across CLI, SDK contracts, completions, and aliases. Record exact-coverage verification and close the active feature-store item.
|
Resolved all three delayed CodeRabbit findings in 471fcea: unified positive token-budget errors, calculated the default packing budget after scale-adjusting the context limit, and added pm claim --next token-budget/explain-ranking parity across CLI routing, contracts, aliases, and completions. The focused suite passes 229/229 and the full suite passes 6,080 tests at exact 100/100/100/100 coverage. The review summary's 42.31% docstring estimate is not the repository gate: quality:static measured and enforced 100% total/exported/member docstring coverage on this head. Please review the new head.\n\n@greptileai please review the latest head.\n/gemini review\n@coderabbitai full review |
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
|
✅ Action performedFull review finished. Your plan includes PR reviews subject to rate limits. More reviews will be available in 21 minutes. |
|
Final bot-response audit for head 471fcea: I read and reacted to every delayed and current CodeRabbit/Gemini status, review, and inline response. Gemini's three sunset notices are acknowledged as unavailable service responses. CodeRabbit's earlier rate-limit notices are acknowledged; its latest-head pass and inline confirmation are up-voted, the corrected thread is resolved, and its old-head outside-diff findings are covered by 471fcea. Repository-enforced docstring coverage remains 100%, despite CodeRabbit's unrelated heuristic warning. No new actionable finding remains. |
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Summary
pm contextandpm nextthrough the public SDK signal store with metadata-index cursor provenance and isolated projection namespaces--token-budgetcontrols and explained feature-store metadata across CLI, SDK, MCP schemas, runtime contracts, and generated fixturespm lineage
GitHub intake discovered during this implementation is documented without expanding PR scope: pm-ypuc39 / GH-641, pm-lcnk2n / GH-642, and pm-tz2ikr / GH-638.
Verification
contextrebuilt -> fresh reuse, independentnextstorage, SDK cursor access, derived-index provenance, and a 192-token boundThe aggregate scale check still reports the pre-existing unrelated
gettoken baselines (CLI 1,042 > 322; SDK 701 > 288), already documented on pm-801d. Context itself remains within the product latency and token targets.Tracker state
pm-3hpsis closed with full evidence.pm-4k6bandpm-801dare open/unclaimed because their canonical 100k/1M acceptance remains intentionally unmet. No pm items are in progress.Summary by cubic
Routes
pm contextandpm nextthrough a shared SDK signal store with index-backed snapshots, explainable ranking, and explicit token budgets, now with normalized validation and sensible defaults. Also surfaces ranking controls onpm claim --next.New Features
readWorkspaceContextSignals/ContextSignalStore; isolatescontext/nextnamespaces and persists caller-independent signals with dynamic overlays per read.--token-budget(alias--token_budget) and--explain-rankingtocontext,next, andclaim --next; wired across CLI flags, commander contracts, completions, tool option contracts, parameter schema/tables, and generated fixtures.readItemMetadataDerivedIndexStatefor the effective cursor with safe fallback; add “Context Relevance and Packing” guide and performance notes; changelog entry kept in Unreleased andpm-changelogupgraded to2026.7.22. Tracks progress: closespm-3hps; advancespm-4k6bandpm-801d. Records GitHub intake:pm-ypuc39,pm-lcnk2n,pm-tz2ikr.Bug Fixes
--token-budgetvalidation and bound default packing budgets to the scale-adjusted context limit.Written for commit 471fcea. Summary will update on new commits.